graphdb-workbench 3.4.0-TR3 → 3.4.0-TR5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/dist/19057.a52dd7b0e356e884a792.bundle.js +3 -0
  2. package/dist/19057.a52dd7b0e356e884a792.bundle.js.map +1 -0
  3. package/dist/23236.1490d29a6e40f437885b.bundle.js +2 -0
  4. package/dist/23236.1490d29a6e40f437885b.bundle.js.map +1 -0
  5. package/dist/24125.0fd6b7797f2630fe59c6.bundle.js +2 -0
  6. package/dist/24125.0fd6b7797f2630fe59c6.bundle.js.map +1 -0
  7. package/dist/24690.79fd696f08f3ebbb1c6f.bundle.js +2 -0
  8. package/dist/24690.79fd696f08f3ebbb1c6f.bundle.js.map +1 -0
  9. package/dist/{3395.8452312923e6a77d2ffd.bundle.js → 3395.8dfba5922c8aad6d860c.bundle.js} +2 -2
  10. package/dist/3395.8dfba5922c8aad6d860c.bundle.js.map +1 -0
  11. package/dist/34985.8ef74b317fc8bff7e8e1.bundle.js +2 -0
  12. package/dist/34985.8ef74b317fc8bff7e8e1.bundle.js.map +1 -0
  13. package/dist/50244.69475a004173b61902a8.bundle.js +2 -0
  14. package/dist/50244.69475a004173b61902a8.bundle.js.map +1 -0
  15. package/dist/60447.4fd8b4ce9b95b98deade.bundle.js +2 -0
  16. package/dist/60447.4fd8b4ce9b95b98deade.bundle.js.map +1 -0
  17. package/dist/63842.68a1c5451a236b8ede97.bundle.js +2 -0
  18. package/dist/63842.68a1c5451a236b8ede97.bundle.js.map +1 -0
  19. package/dist/{64709.9f6594f730a4b54d6fc9.bundle.js → 64709.93e616541b4b18e88892.bundle.js} +2 -2
  20. package/dist/{64709.9f6594f730a4b54d6fc9.bundle.js.map → 64709.93e616541b4b18e88892.bundle.js.map} +1 -1
  21. package/dist/{65677.038185dcd07233e07f52.bundle.js → 65677.77bf484a0da0eec48f0b.bundle.js} +2 -2
  22. package/dist/{65677.038185dcd07233e07f52.bundle.js.map → 65677.77bf484a0da0eec48f0b.bundle.js.map} +1 -1
  23. package/dist/66574.cae68c94f87ba873b322.bundle.js +2 -0
  24. package/dist/66574.cae68c94f87ba873b322.bundle.js.map +1 -0
  25. package/dist/{80933.ef5e85af9b19067ee89b.bundle.js → 80933.ddbcb2688f7d93009c04.bundle.js} +2 -2
  26. package/dist/{80933.ef5e85af9b19067ee89b.bundle.js.map → 80933.ddbcb2688f7d93009c04.bundle.js.map} +1 -1
  27. package/dist/{82917.e537e5e649be4a5a0e20.bundle.js → 82917.e234e043395ff0b7d48f.bundle.js} +2 -2
  28. package/dist/82917.e234e043395ff0b7d48f.bundle.js.map +1 -0
  29. package/dist/{86099.acb890d2b6e1d841c4c3.bundle.js → 86099.0abe4f96d87490fe332e.bundle.js} +2 -2
  30. package/dist/{86099.acb890d2b6e1d841c4c3.bundle.js.map → 86099.0abe4f96d87490fe332e.bundle.js.map} +1 -1
  31. package/dist/{90418.0a737513ff59bfee423a.bundle.js → 90418.ee1af575862a64c12457.bundle.js} +2 -2
  32. package/dist/90418.ee1af575862a64c12457.bundle.js.map +1 -0
  33. package/dist/{96972.896f91c5874df70d14bb.bundle.js → 96972.fc25a13bb1bc69ad785c.bundle.js} +2 -2
  34. package/dist/96972.fc25a13bb1bc69ad785c.bundle.js.map +1 -0
  35. package/dist/9923.74654347e1812dd0f90a.bundle.js +3 -0
  36. package/dist/9923.74654347e1812dd0f90a.bundle.js.map +1 -0
  37. package/dist/api/models/application-settings/application-settings.d.ts +8 -1
  38. package/dist/api/models/application-settings/test/application-settings.spec.d.ts +1 -0
  39. package/dist/api/ontotext-workbench-api.js +1 -1
  40. package/dist/api/ontotext-workbench-api.js.map +1 -1
  41. package/dist/api/services/application-settings/application-settings-storage.service.d.ts +6 -0
  42. package/dist/api/services/runtime-configuration/runtime-configuration-context.service.d.ts +20 -0
  43. package/dist/api/services/theme/theme.service.d.ts +14 -3
  44. package/dist/css/explore.css +1 -1
  45. package/dist/css/lib/ontotext-yasgui-web-component.css +1 -1
  46. package/dist/css/user.css +1 -1
  47. package/dist/i18n/locale-en.json +4 -1
  48. package/dist/i18n/locale-fr.json +6 -3
  49. package/dist/index.html +9 -9
  50. package/dist/js/angular/clustermanagement/templates/cluster-nodes-configuration.html +1 -1
  51. package/dist/js/angular/core/directives/autocomplete/templates/autocomplete.html +1 -1
  52. package/dist/js/angular/core/directives/dynamic-form/templates/dynamic-form.html +1 -1
  53. package/dist/js/angular/core/directives/operations-statuses-monitor/templates/operations-statuses-monitor.html +1 -1
  54. package/dist/js/angular/core/directives/rdfresourcesearch/templates/rdfResourceSearchTemplate.html +1 -1
  55. package/dist/js/angular/core/directives/shuttle-multiselect/templates/shuttle-multiselect.html +1 -1
  56. package/dist/js/angular/core/directives/yasgui-component/templates/yasgui-component.html +2 -2
  57. package/dist/js/angular/core/templates/cookie-policy/cookie-consent.html +1 -1
  58. package/dist/js/angular/core/templates/cookie-policy/cookie-policy.html +1 -1
  59. package/dist/js/angular/core/templates/editable-content/editable-content.html +1 -1
  60. package/dist/js/angular/core/templates/markdown-content/markdown-content.html +1 -1
  61. package/dist/js/angular/core/templates/search-resource-input.html +1 -1
  62. package/dist/js/angular/graphql/templates/create-graphql-endpoint.html +2 -2
  63. package/dist/js/angular/graphql/templates/graphql-endpoint-management.html +1 -1
  64. package/dist/js/angular/graphql/templates/graphql-playground.html +2 -2
  65. package/dist/js/angular/graphql/templates/modal/endpoint-configuration-modal.html +1 -1
  66. package/dist/js/angular/graphql/templates/modal/endpoint-generation-failure-result-modal.html +1 -1
  67. package/dist/js/angular/graphql/templates/modal/import-endpoint-definition-modal.html +1 -1
  68. package/dist/js/angular/security/templates/user.html +13 -16
  69. package/dist/js/angular/ttyg/templates/agent-list.html +1 -1
  70. package/dist/js/angular/ttyg/templates/agent-select-menu.html +1 -1
  71. package/dist/js/angular/ttyg/templates/chat-item-detail.html +1 -1
  72. package/dist/js/angular/ttyg/templates/chat-list.html +1 -1
  73. package/dist/js/angular/ttyg/templates/chat-panel.html +1 -1
  74. package/dist/js/angular/ttyg/templates/modal/agent-instructions-explain-modal.html +1 -1
  75. package/dist/js/angular/ttyg/templates/modal/agent-settings-modal.html +3 -3
  76. package/dist/js/angular/ttyg/templates/modal/external-integration-configuration-modal.html +1 -1
  77. package/dist/js/angular/ttyg/templates/no-agents-view.html +1 -1
  78. package/dist/js/angular/ttyg/templates/ttyg.html +1 -1
  79. package/dist/{legacyWorkbench.77dd92ce99a75c4ee674.js → legacyWorkbench.cb08fa647eed6afe60e8.js} +3 -3
  80. package/dist/{legacyWorkbench.77dd92ce99a75c4ee674.js.map → legacyWorkbench.cb08fa647eed6afe60e8.js.map} +1 -1
  81. package/dist/{main.6db145d35852092cde59.js → main.1198f08d1cc597b94cbc.js} +3 -3
  82. package/dist/main.1198f08d1cc597b94cbc.js.map +1 -0
  83. package/dist/pages/aclmanagement.html +1 -1
  84. package/dist/pages/autocomplete.html +1 -1
  85. package/dist/pages/choose-repository-type.html +1 -1
  86. package/dist/pages/cluster-management/clusterInfo.html +3 -3
  87. package/dist/pages/create-index.html +5 -3
  88. package/dist/pages/dependencies.html +3 -3
  89. package/dist/pages/domainRangeInfo.html +2 -2
  90. package/dist/pages/edit.html +1 -1
  91. package/dist/pages/explore.html +72 -75
  92. package/dist/pages/export.html +1 -1
  93. package/dist/pages/find.html +1 -1
  94. package/dist/pages/graph-config/saveGraphConfig.html +8 -8
  95. package/dist/pages/graphs-visualizations.html +7 -7
  96. package/dist/pages/guides.html +1 -1
  97. package/dist/pages/home.html +1 -1
  98. package/dist/pages/import.html +2 -2
  99. package/dist/pages/jdbc-create.html +1 -1
  100. package/dist/pages/jdbc.html +1 -1
  101. package/dist/pages/monitor/backup-and-restore.html +1 -1
  102. package/dist/pages/monitor/queries.html +1 -1
  103. package/dist/pages/monitor/resources.html +1 -1
  104. package/dist/pages/namespaces.html +2 -2
  105. package/dist/pages/plugins.html +1 -1
  106. package/dist/pages/rdfClassHierarchyInfo.html +7 -7
  107. package/dist/pages/rdfrank.html +2 -2
  108. package/dist/pages/repositories.html +1 -1
  109. package/dist/pages/repository.html +1 -1
  110. package/dist/pages/similarity-indexes.html +1 -1
  111. package/dist/pages/sparql-editor.html +1 -1
  112. package/dist/pages/sparql-template-create.html +1 -1
  113. package/dist/pages/sparql-templates.html +1 -1
  114. package/dist/pages/ux-test1.html +2 -2
  115. package/dist/pages/webapi.html +2 -2
  116. package/dist/res/swagger5/index.html +11 -11
  117. package/dist/shared-components/cjs/onto-graph-explore-split-button.cjs.entry.js +1 -1
  118. package/dist/shared-components/collection/components/onto-graph-explore-split-button/onto-graph-explore-split-button.js +1 -1
  119. package/dist/shared-components/esm/onto-graph-explore-split-button.entry.js +1 -1
  120. package/dist/shared-components/shared-components/p-cd5cc683.entry.js +1 -0
  121. package/dist/shared-components/shared-components/shared-components.esm.js +1 -1
  122. package/package.json +1 -1
  123. package/dist/19057.c644732712725c1a6d3d.bundle.js +0 -3
  124. package/dist/19057.c644732712725c1a6d3d.bundle.js.map +0 -1
  125. package/dist/23236.36dabf6a87d61107178d.bundle.js +0 -2
  126. package/dist/23236.36dabf6a87d61107178d.bundle.js.map +0 -1
  127. package/dist/24125.fc41760fdae44b0480c8.bundle.js +0 -2
  128. package/dist/24125.fc41760fdae44b0480c8.bundle.js.map +0 -1
  129. package/dist/24690.d4ed1c24eded4eb0da85.bundle.js +0 -2
  130. package/dist/24690.d4ed1c24eded4eb0da85.bundle.js.map +0 -1
  131. package/dist/3395.8452312923e6a77d2ffd.bundle.js.map +0 -1
  132. package/dist/34985.a6b52e4b364c7efd3046.bundle.js +0 -2
  133. package/dist/34985.a6b52e4b364c7efd3046.bundle.js.map +0 -1
  134. package/dist/50244.35b37c35412261341adb.bundle.js +0 -2
  135. package/dist/50244.35b37c35412261341adb.bundle.js.map +0 -1
  136. package/dist/60447.fd8b44d92859a3481ad7.bundle.js +0 -2
  137. package/dist/60447.fd8b44d92859a3481ad7.bundle.js.map +0 -1
  138. package/dist/63842.e62b43ae192a642531c6.bundle.js +0 -2
  139. package/dist/63842.e62b43ae192a642531c6.bundle.js.map +0 -1
  140. package/dist/66574.8591bdbb6983d8d07c04.bundle.js +0 -2
  141. package/dist/66574.8591bdbb6983d8d07c04.bundle.js.map +0 -1
  142. package/dist/82917.e537e5e649be4a5a0e20.bundle.js.map +0 -1
  143. package/dist/90418.0a737513ff59bfee423a.bundle.js.map +0 -1
  144. package/dist/96972.896f91c5874df70d14bb.bundle.js.map +0 -1
  145. package/dist/9923.6963c46c47330a6ba2d0.bundle.js +0 -3
  146. package/dist/9923.6963c46c47330a6ba2d0.bundle.js.map +0 -1
  147. package/dist/main.6db145d35852092cde59.js.map +0 -1
  148. package/dist/shared-components/shared-components/p-1b143527.entry.js +0 -1
  149. /package/dist/{19057.c644732712725c1a6d3d.bundle.js.LICENSE.txt → 19057.a52dd7b0e356e884a792.bundle.js.LICENSE.txt} +0 -0
  150. /package/dist/{9923.6963c46c47330a6ba2d0.bundle.js.LICENSE.txt → 9923.74654347e1812dd0f90a.bundle.js.LICENSE.txt} +0 -0
  151. /package/dist/{legacyWorkbench.77dd92ce99a75c4ee674.js.LICENSE.txt → legacyWorkbench.cb08fa647eed6afe60e8.js.LICENSE.txt} +0 -0
  152. /package/dist/{main.6db145d35852092cde59.js.LICENSE.txt → main.1198f08d1cc597b94cbc.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see ontotext-workbench-api.js.LICENSE.txt */
2
- var t={355(t,e){var r,i,s,n,o,a,c,h,u,l,p,d={userAgent:!1},g={},f=f||(r=Math,s=(i={}).lib={},n=s.Base=function(){function t(){}return{extend:function(e){t.prototype=this;var r=new t;return e&&r.mixIn(e),r.hasOwnProperty("init")||(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),o=s.WordArray=n.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var e=this.words,r=t.words,i=this.sigBytes,s=t.sigBytes;if(this.clamp(),i%4)for(var n=0;n<s;n++){var o=r[n>>>2]>>>24-n%4*8&255;e[i+n>>>2]|=o<<24-(i+n)%4*8}else for(n=0;n<s;n+=4)e[i+n>>>2]=r[n>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=r.ceil(e/4)},clone:function(){var t=n.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i<t;i+=4)e.push(4294967296*r.random()|0);return new o.init(e,t)}}),a=i.enc={},c=a.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],s=0;s<r;s++){var n=e[s>>>2]>>>24-s%4*8&255;i.push((n>>>4).toString(16)),i.push((15&n).toString(16))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i+=2)r[i>>>3]|=parseInt(t.substr(i,2),16)<<24-i%8*4;return new o.init(r,e/2)}},h=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],s=0;s<r;s++){var n=e[s>>>2]>>>24-s%4*8&255;i.push(String.fromCharCode(n))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i++)r[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;return new o.init(r,e)}},u=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(h.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return h.parse(unescape(encodeURIComponent(t)))}},l=s.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=u.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,s=e.sigBytes,n=this.blockSize,a=s/(4*n),c=(a=t?r.ceil(a):r.max((0|a)-this._minBufferSize,0))*n,h=r.min(4*c,s);if(c){for(var u=0;u<c;u+=n)this._doProcessBlock(i,u);var l=i.splice(0,c);e.sigBytes-=h}return new o.init(l,h)},clone:function(){var t=n.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),s.Hasher=l.extend({cfg:n.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,r){return new t.init(r).finalize(e)}},_createHmacHelper:function(t){return function(e,r){return new p.HMAC.init(t,r).finalize(e)}}}),p=i.algo={},i);!function(){var t,e=(t=f).lib,r=e.Base,i=e.WordArray;(t=t.x64={}).Word=r.extend({init:function(t,e){this.high=t,this.low=e}}),t.WordArray=r.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:8*t.length},toX32:function(){for(var t=this.words,e=t.length,r=[],s=0;s<e;s++){var n=t[s];r.push(n.high),r.push(n.low)}return i.create(r,this.sigBytes)},clone:function(){for(var t=r.clone.call(this),e=t.words=this.words.slice(0),i=e.length,s=0;s<i;s++)e[s]=e[s].clone();return t}})}(),f.lib.Cipher||function(){var t=(p=f).lib,e=t.Base,r=t.WordArray,i=t.BufferedBlockAlgorithm,s=p.enc.Base64,n=p.algo.EvpKDF,o=t.Cipher=i.extend({cfg:e.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){i.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(t){return{encrypt:function(e,r,i){return("string"==typeof r?d:l).encrypt(t,e,r,i)},decrypt:function(e,r,i){return("string"==typeof r?d:l).decrypt(t,e,r,i)}}}});t.StreamCipher=o.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var a=p.mode={},c=function(t,e,r){var i=this._iv;i?this._iv=void 0:i=this._prevBlock;for(var s=0;s<r;s++)t[e+s]^=i[s]},h=(t.BlockCipherMode=e.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}})).extend();h.Encryptor=h.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize;c.call(this,t,e,i),r.encryptBlock(t,e),this._prevBlock=t.slice(e,e+i)}}),h.Decryptor=h.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,s=t.slice(e,e+i);r.decryptBlock(t,e),c.call(this,t,e,i),this._prevBlock=s}}),a=a.CBC=h,h=(p.pad={}).Pkcs7={pad:function(t,e){for(var i,s=(i=(i=4*e)-t.sigBytes%i)<<24|i<<16|i<<8|i,n=[],o=0;o<i;o+=4)n.push(s);i=r.create(n,i),t.concat(i)},unpad:function(t){t.sigBytes-=255&t.words[t.sigBytes-1>>>2]}},t.BlockCipher=o.extend({cfg:o.cfg.extend({mode:a,padding:h}),reset:function(){o.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var r=e.createEncryptor;else r=e.createDecryptor,this._minBufferSize=1;this._mode=r.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var u=t.CipherParams=e.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),l=(a=(p.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?r.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=r.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return u.create({ciphertext:t,salt:i})}},t.SerializableCipher=e.extend({cfg:e.extend({format:a}),encrypt:function(t,e,r,i){i=this.cfg.extend(i);var s=t.createEncryptor(r,i);return e=s.finalize(e),s=s.cfg,u.create({ciphertext:e,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:i.format})},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),t.createDecryptor(r,i).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),p=(p.kdf={}).OpenSSL={execute:function(t,e,i,s){return s||(s=r.random(8)),t=n.create({keySize:e+i}).compute(t,s),i=r.create(t.words.slice(e),4*i),t.sigBytes=4*e,u.create({key:t,iv:i,salt:s})}},d=t.PasswordBasedCipher=l.extend({cfg:l.cfg.extend({kdf:p}),encrypt:function(t,e,r,i){return r=(i=this.cfg.extend(i)).kdf.execute(r,t.keySize,t.ivSize),i.iv=r.iv,(t=l.encrypt.call(this,t,e,r.key,i)).mixIn(r),t},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),r=i.kdf.execute(r,t.keySize,t.ivSize,e.salt),i.iv=r.iv,l.decrypt.call(this,t,e,r.key,i)}})}(),function(){for(var t=f,e=t.lib.BlockCipher,r=t.algo,i=[],s=[],n=[],o=[],a=[],c=[],h=[],u=[],l=[],p=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var m=0,y=0;for(g=0;256>g;g++){var v=(v=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&v^99;i[m]=v,s[v]=m;var S=d[m],E=d[S],x=d[E],w=257*d[v]^16843008*v;n[m]=w<<24|w>>>8,o[m]=w<<16|w>>>16,a[m]=w<<8|w>>>24,c[m]=w,w=16843009*x^65537*E^257*S^16843008*m,h[v]=w<<24|w>>>8,u[v]=w<<16|w>>>16,l[v]=w<<8|w>>>24,p[v]=w,m?(m=S^d[d[d[x^S]]],y^=d[d[y]]):m=y=1}var A=[0,1,2,4,8,16,32,64,128,27,54];r=r.AES=e.extend({_doReset:function(){for(var t=(r=this._key).words,e=r.sigBytes/4,r=4*((this._nRounds=e+6)+1),s=this._keySchedule=[],n=0;n<r;n++)if(n<e)s[n]=t[n];else{var o=s[n-1];n%e?6<e&&4==n%e&&(o=i[o>>>24]<<24|i[o>>>16&255]<<16|i[o>>>8&255]<<8|i[255&o]):(o=i[(o=o<<8|o>>>24)>>>24]<<24|i[o>>>16&255]<<16|i[o>>>8&255]<<8|i[255&o],o^=A[n/e|0]<<24),s[n]=s[n-e]^o}for(t=this._invKeySchedule=[],e=0;e<r;e++)n=r-e,o=e%4?s[n]:s[n-4],t[e]=4>e||4>=n?o:h[i[o>>>24]]^u[i[o>>>16&255]]^l[i[o>>>8&255]]^p[i[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,n,o,a,c,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,h,u,l,p,s),r=t[e+1],t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,i,s,n,o,a){for(var c=this._nRounds,h=t[e]^r[0],u=t[e+1]^r[1],l=t[e+2]^r[2],p=t[e+3]^r[3],d=4,g=1;g<c;g++){var f=i[h>>>24]^s[u>>>16&255]^n[l>>>8&255]^o[255&p]^r[d++],m=i[u>>>24]^s[l>>>16&255]^n[p>>>8&255]^o[255&h]^r[d++],y=i[l>>>24]^s[p>>>16&255]^n[h>>>8&255]^o[255&u]^r[d++];p=i[p>>>24]^s[h>>>16&255]^n[u>>>8&255]^o[255&l]^r[d++],h=f,u=m,l=y}f=(a[h>>>24]<<24|a[u>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^r[d++],m=(a[u>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^r[d++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&u])^r[d++],p=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[u>>>8&255]<<8|a[255&l])^r[d++],t[e]=f,t[e+1]=m,t[e+2]=y,t[e+3]=p},keySize:8}),t.AES=e._createHelper(r)}(),function(){function t(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<<t}function e(t,e){var r=(this._rBlock>>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<<t}var r=f,i=(s=r.lib).WordArray,s=s.BlockCipher,n=r.algo,o=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],h=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],u=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],l=n.DES=s.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;56>r;r++){var i=o[r]-1;e[r]=t[i>>>5]>>>31-i%32&1}for(t=this._subKeys=[],i=0;16>i;i++){var s=t[i]=[],n=c[i];for(r=0;24>r;r++)s[r/6|0]|=e[(a[r]-1+n)%28]<<31-r%6,s[4+(r/6|0)]|=e[28+(a[r+24]-1+n)%28]<<31-r%6;for(s[0]=s[0]<<1|s[0]>>>31,r=1;7>r;r++)s[r]>>>=4*(r-1)+3;s[7]=s[7]<<5|s[7]>>>27}for(e=this._invSubKeys=[],r=0;16>r;r++)e[r]=t[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(r,i,s){this._lBlock=r[i],this._rBlock=r[i+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var n=0;16>n;n++){for(var o=s[n],a=this._lBlock,c=this._rBlock,l=0,p=0;8>p;p++)l|=h[p][((c^o[p])&u[p])>>>0];this._lBlock=c,this._rBlock=a^l}s=this._lBlock,this._lBlock=this._rBlock,this._rBlock=s,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),r[i]=this._lBlock,r[i+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=s._createHelper(l),n=n.TripleDES=s.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(i.create(t.slice(0,2))),this._des2=l.createEncryptor(i.create(t.slice(2,4))),this._des3=l.createEncryptor(i.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=s._createHelper(n)}(),function(){var t=f,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,i=this._map;t.clamp(),t=[];for(var s=0;s<r;s+=3)for(var n=(e[s>>>2]>>>24-s%4*8&255)<<16|(e[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|e[s+2>>>2]>>>24-(s+2)%4*8&255,o=0;4>o&&s+.75*o<r;o++)t.push(i.charAt(n>>>6*(3-o)&63));if(e=i.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var r=t.length,i=this._map;(s=i.charAt(64))&&-1!=(s=t.indexOf(s))&&(r=s);for(var s=[],n=0,o=0;o<r;o++)if(o%4){var a=i.indexOf(t.charAt(o-1))<<o%4*2,c=i.indexOf(t.charAt(o))>>>6-o%4*2;s[n>>>2]|=(a|c)<<24-n%4*8,n++}return e.create(s,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,r,i,s,n,o){return((t=t+(e&r|~e&i)+s+o)<<n|t>>>32-n)+e}function r(t,e,r,i,s,n,o){return((t=t+(e&i|r&~i)+s+o)<<n|t>>>32-n)+e}function i(t,e,r,i,s,n,o){return((t=t+(e^r^i)+s+o)<<n|t>>>32-n)+e}function s(t,e,r,i,s,n,o){return((t=t+(r^(e|~i))+s+o)<<n|t>>>32-n)+e}for(var n=f,o=(c=n.lib).WordArray,a=c.Hasher,c=n.algo,h=[],u=0;64>u;u++)h[u]=4294967296*t.abs(t.sin(u+1))|0;c=c.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,n){for(var o=0;16>o;o++){var a=t[c=n+o];t[c]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var c=t[n+0],u=(a=t[n+1],t[n+2]),l=t[n+3],p=t[n+4],d=t[n+5],g=t[n+6],f=t[n+7],m=t[n+8],y=t[n+9],v=t[n+10],S=t[n+11],E=t[n+12],x=t[n+13],w=t[n+14],A=t[n+15],b=e(b=o[0],R=o[1],I=o[2],C=o[3],c,7,h[0]),C=e(C,b,R,I,a,12,h[1]),I=e(I,C,b,R,u,17,h[2]),R=e(R,I,C,b,l,22,h[3]);b=e(b,R,I,C,p,7,h[4]),C=e(C,b,R,I,d,12,h[5]),I=e(I,C,b,R,g,17,h[6]),R=e(R,I,C,b,f,22,h[7]),b=e(b,R,I,C,m,7,h[8]),C=e(C,b,R,I,y,12,h[9]),I=e(I,C,b,R,v,17,h[10]),R=e(R,I,C,b,S,22,h[11]),b=e(b,R,I,C,E,7,h[12]),C=e(C,b,R,I,x,12,h[13]),I=e(I,C,b,R,w,17,h[14]),b=r(b,R=e(R,I,C,b,A,22,h[15]),I,C,a,5,h[16]),C=r(C,b,R,I,g,9,h[17]),I=r(I,C,b,R,S,14,h[18]),R=r(R,I,C,b,c,20,h[19]),b=r(b,R,I,C,d,5,h[20]),C=r(C,b,R,I,v,9,h[21]),I=r(I,C,b,R,A,14,h[22]),R=r(R,I,C,b,p,20,h[23]),b=r(b,R,I,C,y,5,h[24]),C=r(C,b,R,I,w,9,h[25]),I=r(I,C,b,R,l,14,h[26]),R=r(R,I,C,b,m,20,h[27]),b=r(b,R,I,C,x,5,h[28]),C=r(C,b,R,I,u,9,h[29]),I=r(I,C,b,R,f,14,h[30]),b=i(b,R=r(R,I,C,b,E,20,h[31]),I,C,d,4,h[32]),C=i(C,b,R,I,m,11,h[33]),I=i(I,C,b,R,S,16,h[34]),R=i(R,I,C,b,w,23,h[35]),b=i(b,R,I,C,a,4,h[36]),C=i(C,b,R,I,p,11,h[37]),I=i(I,C,b,R,f,16,h[38]),R=i(R,I,C,b,v,23,h[39]),b=i(b,R,I,C,x,4,h[40]),C=i(C,b,R,I,c,11,h[41]),I=i(I,C,b,R,l,16,h[42]),R=i(R,I,C,b,g,23,h[43]),b=i(b,R,I,C,y,4,h[44]),C=i(C,b,R,I,E,11,h[45]),I=i(I,C,b,R,A,16,h[46]),b=s(b,R=i(R,I,C,b,u,23,h[47]),I,C,c,6,h[48]),C=s(C,b,R,I,f,10,h[49]),I=s(I,C,b,R,w,15,h[50]),R=s(R,I,C,b,d,21,h[51]),b=s(b,R,I,C,E,6,h[52]),C=s(C,b,R,I,l,10,h[53]),I=s(I,C,b,R,v,15,h[54]),R=s(R,I,C,b,a,21,h[55]),b=s(b,R,I,C,m,6,h[56]),C=s(C,b,R,I,A,10,h[57]),I=s(I,C,b,R,g,15,h[58]),R=s(R,I,C,b,x,21,h[59]),b=s(b,R,I,C,p,6,h[60]),C=s(C,b,R,I,S,10,h[61]),I=s(I,C,b,R,u,15,h[62]),R=s(R,I,C,b,y,21,h[63]),o[0]=o[0]+b|0,o[1]=o[1]+R|0,o[2]=o[2]+I|0,o[3]=o[3]+C|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;r[s>>>5]|=128<<24-s%32;var n=t.floor(i/4294967296);for(r[15+(s+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),r[14+(s+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(r.length+1),this._process(),r=(e=this._hash).words,i=0;4>i;i++)s=r[i],r[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),n.MD5=a._createHelper(c),n.HmacMD5=a._createHmacHelper(c)}(Math),function(){var t=f,e=(s=t.lib).WordArray,r=s.Hasher,i=[],s=t.algo.SHA1=r.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,s=r[0],n=r[1],o=r[2],a=r[3],c=r[4],h=0;80>h;h++){if(16>h)i[h]=0|t[e+h];else{var u=i[h-3]^i[h-8]^i[h-14]^i[h-16];i[h]=u<<1|u>>>31}u=(s<<5|s>>>27)+c+i[h],u=20>h?u+(1518500249+(n&o|~n&a)):40>h?u+(1859775393+(n^o^a)):60>h?u+((n&o|n&a|o&a)-1894007588):u+((n^o^a)-899497514),c=a,a=o,o=n<<30|n>>>2,n=s,s=u}r[0]=r[0]+s|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(i+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=r._createHelper(s),t.HmacSHA1=r._createHmacHelper(s)}(),function(t){for(var e=f,r=(s=e.lib).WordArray,i=s.Hasher,s=e.algo,n=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},c=2,h=0;64>h;){var u;t:{u=c;for(var l=t.sqrt(u),p=2;p<=l;p++)if(!(u%p)){u=!1;break t}u=!0}u&&(8>h&&(n[h]=a(t.pow(c,.5))),o[h]=a(t.pow(c,1/3)),h++),c++}var d=[];s=s.SHA256=i.extend({_doReset:function(){this._hash=new r.init(n.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],s=r[1],n=r[2],a=r[3],c=r[4],h=r[5],u=r[6],l=r[7],p=0;64>p;p++){if(16>p)d[p]=0|t[e+p];else{var g=d[p-15],f=d[p-2];d[p]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[p-7]+((f<<15|f>>>17)^(f<<13|f>>>19)^f>>>10)+d[p-16]}g=l+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&h^~c&u)+o[p]+d[p],f=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&s^i&n^s&n),l=u,u=h,h=c,c=a+g|0,a=n,n=s,s=i,i=g+f|0}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+n|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0,r[5]=r[5]+h|0,r[6]=r[6]+u|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;return r[s>>>5]|=128<<24-s%32,r[14+(s+64>>>9<<4)]=t.floor(i/4294967296),r[15+(s+64>>>9<<4)]=i,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA256=i._createHelper(s),e.HmacSHA256=i._createHmacHelper(s)}(Math),function(){var t=f,e=t.lib.WordArray,r=(i=t.algo).SHA256,i=i.SHA224=r.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=r._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=r._createHelper(i),t.HmacSHA224=r._createHmacHelper(i)}(),function(){function t(){return i.create.apply(i,arguments)}for(var e=f,r=e.lib.Hasher,i=(n=e.x64).Word,s=n.WordArray,n=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],c=0;80>c;c++)a[c]=t();n=n.SHA512=r.extend({_doReset:function(){this._hash=new s.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=(l=this._hash.words)[0],i=l[1],s=l[2],n=l[3],c=l[4],h=l[5],u=l[6],l=l[7],p=r.high,d=r.low,g=i.high,f=i.low,m=s.high,y=s.low,v=n.high,S=n.low,E=c.high,x=c.low,w=h.high,A=h.low,b=u.high,C=u.low,I=l.high,R=l.low,T=p,F=d,P=g,D=f,O=m,N=y,_=v,L=S,B=E,H=x,k=w,U=A,j=b,V=C,M=I,K=R,q=0;80>q;q++){var G=a[q];if(16>q)var $=G.high=0|t[e+2*q],W=G.low=0|t[e+2*q+1];else{$=((W=($=a[q-15]).high)>>>1|(J=$.low)<<31)^(W>>>8|J<<24)^W>>>7;var J=(J>>>1|W<<31)^(J>>>8|W<<24)^(J>>>7|W<<25),z=((W=(z=a[q-2]).high)>>>19|(Y=z.low)<<13)^(W<<3|Y>>>29)^W>>>6,Y=(Y>>>19|W<<13)^(Y<<3|W>>>29)^(Y>>>6|W<<26),X=(W=a[q-7]).high,Q=(Z=a[q-16]).high,Z=Z.low;$=($=($=$+X+((W=J+W.low)>>>0<J>>>0?1:0))+z+((W+=Y)>>>0<Y>>>0?1:0))+Q+((W+=Z)>>>0<Z>>>0?1:0),G.high=$,G.low=W}X=B&k^~B&j,Z=H&U^~H&V,G=T&P^T&O^P&O;var tt=F&D^F&N^D&N,et=(J=(T>>>28|F<<4)^(T<<30|F>>>2)^(T<<25|F>>>7),z=(F>>>28|T<<4)^(F<<30|T>>>2)^(F<<25|T>>>7),(Y=o[q]).high),rt=Y.low;Q=M+((B>>>14|H<<18)^(B>>>18|H<<14)^(B<<23|H>>>9))+((Y=K+((H>>>14|B<<18)^(H>>>18|B<<14)^(H<<23|B>>>9)))>>>0<K>>>0?1:0),M=j,K=V,j=k,V=U,k=B,U=H,B=_+(Q=(Q=(Q=Q+X+((Y+=Z)>>>0<Z>>>0?1:0))+et+((Y+=rt)>>>0<rt>>>0?1:0))+$+((Y+=W)>>>0<W>>>0?1:0))+((H=L+Y|0)>>>0<L>>>0?1:0)|0,_=O,L=N,O=P,N=D,P=T,D=F,T=Q+(G=J+G+((W=z+tt)>>>0<z>>>0?1:0))+((F=Y+W|0)>>>0<Y>>>0?1:0)|0}d=r.low=d+F,r.high=p+T+(d>>>0<F>>>0?1:0),f=i.low=f+D,i.high=g+P+(f>>>0<D>>>0?1:0),y=s.low=y+N,s.high=m+O+(y>>>0<N>>>0?1:0),S=n.low=S+L,n.high=v+_+(S>>>0<L>>>0?1:0),x=c.low=x+H,c.high=E+B+(x>>>0<H>>>0?1:0),A=h.low=A+U,h.high=w+k+(A>>>0<U>>>0?1:0),C=u.low=C+V,u.high=b+j+(C>>>0<V>>>0?1:0),R=l.low=R+K,l.high=I+M+(R>>>0<K>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[30+(i+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(i+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=r._createHelper(n),e.HmacSHA512=r._createHmacHelper(n)}(),function(){var t=f,e=(s=t.x64).Word,r=s.WordArray,i=(s=t.algo).SHA512,s=s.SHA384=i.extend({_doReset:function(){this._hash=new r.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=i._createHelper(s),t.HmacSHA384=i._createHmacHelper(s)}(),function(){var t=f,e=(i=t.lib).WordArray,r=i.Hasher,i=t.algo,s=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),n=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),c=e.create([0,1518500249,1859775393,2400959708,2840853838]),h=e.create([1352829926,1548603684,1836072691,2053994217,0]);i=i.RIPEMD160=r.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;16>r;r++){var i=t[x=e+r];t[x]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var u,l,p,d,g,f,m,y,v,S,E,x=this._hash.words,w=(i=c.words,h.words),A=s.words,b=n.words,C=o.words,I=a.words;for(f=u=x[0],m=l=x[1],y=p=x[2],v=d=x[3],S=g=x[4],r=0;80>r;r+=1)E=u+t[e+A[r]]|0,E=16>r?E+((l^p^d)+i[0]):32>r?E+((l&p|~l&d)+i[1]):48>r?E+(((l|~p)^d)+i[2]):64>r?E+((l&d|p&~d)+i[3]):E+((l^(p|~d))+i[4]),E=(E=(E|=0)<<C[r]|E>>>32-C[r])+g|0,u=g,g=d,d=p<<10|p>>>22,p=l,l=E,E=f+t[e+b[r]]|0,E=16>r?E+((m^(y|~v))+w[0]):32>r?E+((m&v|y&~v)+w[1]):48>r?E+(((m|~y)^v)+w[2]):64>r?E+((m&y|~m&v)+w[3]):E+((m^y^v)+w[4]),E=(E=(E|=0)<<I[r]|E>>>32-I[r])+S|0,f=S,S=v,v=y<<10|y>>>22,y=m,m=E;E=x[1]+p+v|0,x[1]=x[2]+d+S|0,x[2]=x[3]+g+f|0,x[3]=x[4]+u+m|0,x[4]=x[0]+l+y|0,x[0]=E},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;for(e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,r=0;5>r;r++)i=e[r],e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}}),t.RIPEMD160=r._createHelper(i),t.HmacRIPEMD160=r._createHmacHelper(i)}(Math),function(){var t=f,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,r){t=this._hasher=new t.init,"string"==typeof r&&(r=e.parse(r));var i=t.blockSize,s=4*i;r.sigBytes>s&&(r=t.finalize(r)),r.clamp();for(var n=this._oKey=r.clone(),o=this._iKey=r.clone(),a=n.words,c=o.words,h=0;h<i;h++)a[h]^=1549556828,c[h]^=909522486;n.sigBytes=o.sigBytes=s,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher;return t=e.finalize(t),e.reset(),e.finalize(this._oKey.clone().concat(t))}})}(),function(){var t,e=f,r=(t=e.lib).Base,i=t.WordArray,s=(t=e.algo).HMAC,n=t.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:t.SHA1,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){var r=this.cfg,n=s.create(r.hasher,t),o=i.create(),a=i.create([1]),c=o.words,h=a.words,u=r.keySize;for(r=r.iterations;c.length<u;){var l=n.update(e).finalize(a);n.reset();for(var p=l.words,d=p.length,g=l,f=1;f<r;f++){g=n.finalize(g),n.reset();for(var m=g.words,y=0;y<d;y++)p[y]^=m[y]}o.concat(l),h[0]++}return o.sigBytes=4*u,o}});e.PBKDF2=function(t,e,r){return n.create(r).compute(t,e)}}();var m,y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function v(t){var e,r,i="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),i+=y.charAt(r>>6)+y.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),i+=y.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),i+=y.charAt(r>>2)+y.charAt((3&r)<<4));(3&i.length)>0;)i+="=";return i}function S(t){var e,r,i,s="",n=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e)(i=y.indexOf(t.charAt(e)))<0||(0==n?(s+=C(i>>2),r=3&i,n=1):1==n?(s+=C(r<<2|i>>4),r=15&i,n=2):2==n?(s+=C(r),s+=C(i>>2),r=3&i,n=3):(s+=C(r<<2|i>>4),s+=C(15&i),n=0));return 1==n&&(s+=C(r<<2)),s}function E(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function x(){return new E(null)}"Microsoft Internet Explorer"==d.appName?(E.prototype.am=function(t,e,r,i,s,n){for(var o=32767&e,a=e>>15;--n>=0;){var c=32767&this[t],h=this[t++]>>15,u=a*c+h*o;s=((c=o*c+((32767&u)<<15)+r[i]+(1073741823&s))>>>30)+(u>>>15)+a*h+(s>>>30),r[i++]=1073741823&c}return s},m=30):"Netscape"!=d.appName?(E.prototype.am=function(t,e,r,i,s,n){for(;--n>=0;){var o=e*this[t++]+r[i]+s;s=Math.floor(o/67108864),r[i++]=67108863&o}return s},m=26):(E.prototype.am=function(t,e,r,i,s,n){for(var o=16383&e,a=e>>14;--n>=0;){var c=16383&this[t],h=this[t++]>>14,u=a*c+h*o;s=((c=o*c+((16383&u)<<14)+r[i]+s)>>28)+(u>>14)+a*h,r[i++]=268435455&c}return s},m=28),E.prototype.DB=m,E.prototype.DM=(1<<m)-1,E.prototype.DV=1<<m,E.prototype.FV=Math.pow(2,52),E.prototype.F1=52-m,E.prototype.F2=2*m-52;var w,A,b=new Array;for(w="0".charCodeAt(0),A=0;A<=9;++A)b[w++]=A;for(w="a".charCodeAt(0),A=10;A<36;++A)b[w++]=A;for(w="A".charCodeAt(0),A=10;A<36;++A)b[w++]=A;function C(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function I(t,e){var r=b[t.charCodeAt(e)];return null==r?-1:r}function R(t){var e=x();return e.fromInt(t),e}function T(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function F(t){this.m=t}function P(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function D(t,e){return t&e}function O(t,e){return t|e}function N(t,e){return t^e}function _(t,e){return t&~e}function L(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function B(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function H(){}function k(t){return t}function U(t){this.r2=x(),this.q3=x(),E.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}F.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},F.prototype.revert=function(t){return t},F.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},F.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},F.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},P.prototype.convert=function(t){var e=x();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(E.ZERO)>0&&this.m.subTo(e,e),e},P.prototype.revert=function(t){var e=x();return t.copyTo(e),this.reduce(e),e},P.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],i=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},P.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},P.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},E.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},E.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},E.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var i=t.length,s=!1,n=0;--i>=0;){var o=8==r?255&t[i]:I(t,i);o<0?"-"==t.charAt(i)&&(s=!0):(s=!1,0==n?this[this.t++]=o:n+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-n)-1)<<n,this[this.t++]=o>>this.DB-n):this[this.t-1]|=o<<n,(n+=r)>=this.DB&&(n-=this.DB))}8==r&&128&t[0]&&(this.s=-1,n>0&&(this[this.t-1]|=(1<<this.DB-n)-1<<n)),this.clamp(),s&&E.ZERO.subTo(this,this)},E.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},E.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},E.prototype.drShiftTo=function(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},E.prototype.lShiftTo=function(t,e){var r,i=t%this.DB,s=this.DB-i,n=(1<<s)-1,o=Math.floor(t/this.DB),a=this.s<<i&this.DM;for(r=this.t-1;r>=0;--r)e[r+o+1]=this[r]>>s|a,a=(this[r]&n)<<i;for(r=o-1;r>=0;--r)e[r]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},E.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,s=this.DB-i,n=(1<<i)-1;e[0]=this[r]>>i;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&n)<<s,e[o-r]=this[o]>>i;i>0&&(e[this.t-r-1]|=(this.s&n)<<s),e.t=this.t-r,e.clamp()}},E.prototype.subTo=function(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()},E.prototype.multiplyTo=function(t,e){var r=this.abs(),i=t.abs(),s=r.t;for(e.t=s+i.t;--s>=0;)e[s]=0;for(s=0;s<i.t;++s)e[s+r.t]=r.am(0,i[s],e,s,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&E.ZERO.subTo(e,e)},E.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var i=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,i,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},E.prototype.divRemTo=function(t,e,r){var i=t.abs();if(!(i.t<=0)){var s=this.abs();if(s.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=x());var n=x(),o=this.s,a=t.s,c=this.DB-T(i[i.t-1]);c>0?(i.lShiftTo(c,n),s.lShiftTo(c,r)):(i.copyTo(n),s.copyTo(r));var h=n.t,u=n[h-1];if(0!=u){var l=u*(1<<this.F1)+(h>1?n[h-2]>>this.F2:0),p=this.FV/l,d=(1<<this.F1)/l,g=1<<this.F2,f=r.t,m=f-h,y=null==e?x():e;for(n.dlShiftTo(m,y),r.compareTo(y)>=0&&(r[r.t++]=1,r.subTo(y,r)),E.ONE.dlShiftTo(h,y),y.subTo(n,n);n.t<h;)n[n.t++]=0;for(;--m>=0;){var v=r[--f]==u?this.DM:Math.floor(r[f]*p+(r[f-1]+g)*d);if((r[f]+=n.am(0,v,r,m,0,h))<v)for(n.dlShiftTo(m,y),r.subTo(y,r);r[f]<--v;)r.subTo(y,r)}null!=e&&(r.drShiftTo(h,e),o!=a&&E.ZERO.subTo(e,e)),r.t=h,r.clamp(),c>0&&r.rShiftTo(c,r),o<0&&E.ZERO.subTo(r,r)}}},E.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},E.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},E.prototype.exp=function(t,e){if(t>4294967295||t<1)return E.ONE;var r=x(),i=x(),s=e.convert(this),n=T(t)-1;for(s.copyTo(r);--n>=0;)if(e.sqrTo(r,i),(t&1<<n)>0)e.mulTo(i,s,r);else{var o=r;r=i,i=o}return e.revert(r)},E.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,i=(1<<e)-1,s=!1,n="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(s=!0,n=C(r));o>=0;)a<e?(r=(this[o]&(1<<a)-1)<<e-a,r|=this[--o]>>(a+=this.DB-e)):(r=this[o]>>(a-=e)&i,a<=0&&(a+=this.DB,--o)),r>0&&(s=!0),s&&(n+=C(r));return s?n:"0"},E.prototype.negate=function(){var t=x();return E.ZERO.subTo(this,t),t},E.prototype.abs=function(){return this.s<0?this.negate():this},E.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},E.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+T(this[this.t-1]^this.s&this.DM)},E.prototype.mod=function(t){var e=x();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(E.ZERO)>0&&t.subTo(e,e),e},E.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new F(e):new P(e),this.exp(t,r)},E.ZERO=R(0),E.ONE=R(1),H.prototype.convert=k,H.prototype.revert=k,H.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},H.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=x();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var j,V,M,K=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],q=(1<<26)/K[K.length-1];function G(){this.i=0,this.j=0,this.S=new Array}function $(){!function(t){V[M++]^=255&t,V[M++]^=t>>8&255,V[M++]^=t>>16&255,V[M++]^=t>>24&255,M>=256&&(M-=256)}((new Date).getTime())}if(E.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},E.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=R(r),s=x(),n=x(),o="";for(this.divRemTo(i,s,n);s.signum()>0;)o=(r+n.intValue()).toString(t).substr(1)+o,s.divRemTo(i,s,n);return n.intValue().toString(t)+o},E.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),s=!1,n=0,o=0,a=0;a<t.length;++a){var c=I(t,a);c<0?"-"==t.charAt(a)&&0==this.signum()&&(s=!0):(o=e*o+c,++n>=r&&(this.dMultiply(i),this.dAddOffset(o,0),n=0,o=0))}n>0&&(this.dMultiply(Math.pow(e,n)),this.dAddOffset(o,0)),s&&E.ZERO.subTo(this,this)},E.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(E.ONE.shiftLeft(t-1),O,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(E.ONE.shiftLeft(t-1),this);else{var i=new Array,s=7&t;i.length=1+(t>>3),e.nextBytes(i),s>0?i[0]&=(1<<s)-1:i[0]=0,this.fromString(i,256)}},E.prototype.bitwiseTo=function(t,e,r){var i,s,n=Math.min(t.t,this.t);for(i=0;i<n;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(s=t.s&this.DM,i=n;i<this.t;++i)r[i]=e(this[i],s);r.t=this.t}else{for(s=this.s&this.DM,i=n;i<t.t;++i)r[i]=e(s,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},E.prototype.changeBit=function(t,e){var r=E.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},E.prototype.addTo=function(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()},E.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},E.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},E.prototype.multiplyLowerTo=function(t,e,r){var i,s=Math.min(this.t+t.t,e);for(r.s=0,r.t=s;s>0;)r[--s]=0;for(i=r.t-this.t;s<i;++s)r[s+this.t]=this.am(0,t[s],r,s,0,this.t);for(i=Math.min(t.t,e);s<i;++s)this.am(0,t[s],r,s,0,e-s);r.clamp()},E.prototype.multiplyUpperTo=function(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-e);r.clamp(),r.drShiftTo(1,r)},E.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r},E.prototype.millerRabin=function(t){var e=this.subtract(E.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var i=e.shiftRight(r);(t=t+1>>1)>K.length&&(t=K.length);for(var s=x(),n=0;n<t;++n){s.fromInt(K[Math.floor(Math.random()*K.length)]);var o=s.modPow(i,this);if(0!=o.compareTo(E.ONE)&&0!=o.compareTo(e)){for(var a=1;a++<r&&0!=o.compareTo(e);)if(0==(o=o.modPowInt(2,this)).compareTo(E.ONE))return!1;if(0!=o.compareTo(e))return!1}}return!0},E.prototype.clone=function(){var t=x();return this.copyTo(t),t},E.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},E.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},E.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},E.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},E.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,i=this.DB-t*this.DB%8,s=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[s++]=r|this.s<<this.DB-i);t>=0;)i<8?(r=(this[t]&(1<<i)-1)<<8-i,r|=this[--t]>>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&r&&(r|=-256),0==s&&(128&this.s)!=(128&r)&&++s,(s>0||r!=this.s)&&(e[s++]=r);return e},E.prototype.equals=function(t){return 0==this.compareTo(t)},E.prototype.min=function(t){return this.compareTo(t)<0?this:t},E.prototype.max=function(t){return this.compareTo(t)>0?this:t},E.prototype.and=function(t){var e=x();return this.bitwiseTo(t,D,e),e},E.prototype.or=function(t){var e=x();return this.bitwiseTo(t,O,e),e},E.prototype.xor=function(t){var e=x();return this.bitwiseTo(t,N,e),e},E.prototype.andNot=function(t){var e=x();return this.bitwiseTo(t,_,e),e},E.prototype.not=function(){for(var t=x(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},E.prototype.shiftLeft=function(t){var e=x();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},E.prototype.shiftRight=function(t){var e=x();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},E.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+L(this[t]);return this.s<0?this.t*this.DB:-1},E.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=B(this[r]^e);return t},E.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)},E.prototype.setBit=function(t){return this.changeBit(t,O)},E.prototype.clearBit=function(t){return this.changeBit(t,_)},E.prototype.flipBit=function(t){return this.changeBit(t,N)},E.prototype.add=function(t){var e=x();return this.addTo(t,e),e},E.prototype.subtract=function(t){var e=x();return this.subTo(t,e),e},E.prototype.multiply=function(t){var e=x();return this.multiplyTo(t,e),e},E.prototype.divide=function(t){var e=x();return this.divRemTo(t,e,null),e},E.prototype.remainder=function(t){var e=x();return this.divRemTo(t,null,e),e},E.prototype.divideAndRemainder=function(t){var e=x(),r=x();return this.divRemTo(t,e,r),new Array(e,r)},E.prototype.modPow=function(t,e){var r,i,s=t.bitLength(),n=R(1);if(s<=0)return n;r=s<18?1:s<48?3:s<144?4:s<768?5:6,i=s<8?new F(e):e.isEven()?new U(e):new P(e);var o=new Array,a=3,c=r-1,h=(1<<r)-1;if(o[1]=i.convert(this),r>1){var u=x();for(i.sqrTo(o[1],u);a<=h;)o[a]=x(),i.mulTo(u,o[a-2],o[a]),a+=2}var l,p,d=t.t-1,g=!0,f=x();for(s=T(t[d])-1;d>=0;){for(s>=c?l=t[d]>>s-c&h:(l=(t[d]&(1<<s+1)-1)<<c-s,d>0&&(l|=t[d-1]>>this.DB+s-c)),a=r;!(1&l);)l>>=1,--a;if((s-=a)<0&&(s+=this.DB,--d),g)o[l].copyTo(n),g=!1;else{for(;a>1;)i.sqrTo(n,f),i.sqrTo(f,n),a-=2;a>0?i.sqrTo(n,f):(p=n,n=f,f=p),i.mulTo(f,o[l],n)}for(;d>=0&&!(t[d]&1<<s);)i.sqrTo(n,f),p=n,n=f,f=p,--s<0&&(s=this.DB-1,--d)}return i.revert(n)},E.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return E.ZERO;for(var r=t.clone(),i=this.clone(),s=R(1),n=R(0),o=R(0),a=R(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(s.isEven()&&n.isEven()||(s.addTo(this,s),n.subTo(t,n)),s.rShiftTo(1,s)):n.isEven()||n.subTo(t,n),n.rShiftTo(1,n);for(;i.isEven();)i.rShiftTo(1,i),e?(o.isEven()&&a.isEven()||(o.addTo(this,o),a.subTo(t,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(i)>=0?(r.subTo(i,r),e&&s.subTo(o,s),n.subTo(a,n)):(i.subTo(r,i),e&&o.subTo(s,o),a.subTo(n,a))}return 0!=i.compareTo(E.ONE)?E.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},E.prototype.pow=function(t){return this.exp(t,new H)},E.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var s=e.getLowestSetBit(),n=r.getLowestSetBit();if(n<0)return e;for(s<n&&(n=s),n>0&&(e.rShiftTo(n,e),r.rShiftTo(n,r));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return n>0&&r.lShiftTo(n,r),r},E.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=K[K.length-1]){for(e=0;e<K.length;++e)if(r[0]==K[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<K.length;){for(var i=K[e],s=e+1;s<K.length&&i<q;)i*=K[s++];for(i=r.modInt(i);e<s;)if(i%K[e++]==0)return!1}return r.millerRabin(t)},E.prototype.square=function(){var t=x();return this.squareTo(t),t},G.prototype.init=function(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0},G.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]},null==V){var W;if(V=new Array,M=0,void 0!==g&&(void 0!==g.crypto||void 0!==g.msCrypto)){var J=g.crypto||g.msCrypto;if(J.getRandomValues){var z=new Uint8Array(32);for(J.getRandomValues(z),W=0;W<32;++W)V[M++]=z[W]}else if("Netscape"==d.appName&&d.appVersion<"5"){var Y=g.crypto.random(32);for(W=0;W<Y.length;++W)V[M++]=255&Y.charCodeAt(W)}}for(;M<256;)W=Math.floor(65536*Math.random()),V[M++]=W>>>8,V[M++]=255&W;M=0,$()}function X(){if(null==j){for($(),(j=new G).init(V),M=0;M<V.length;++M)V[M]=0;M=0}return j.next()}function Q(){}function Z(t,e){return new E(t,e)}function tt(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function et(t,e){this.x=e,this.q=t}function rt(t,e,r,i){this.curve=t,this.x=e,this.y=r,this.z=null==i?E.ONE:i,this.zinv=null}function it(t,e,r){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(r),this.infinity=new rt(this,null,null)}Q.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=X()},tt.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},tt.prototype.setPublic=function(t,e){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof t)this.n=t,this.e=e;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA public key";this.n=Z(t,16),this.e=parseInt(e,16)}if(null==this.n||"function"!=typeof this.n.compareTo||this.n.compareTo(E.ONE)<=0||null==this.e||isNaN(this.e)||this.e<=0)throw"Invalid RSA public key"},tt.prototype.type="RSA",tt.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)},tt.prototype.setPrivate=function(t,e,r){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=r;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=Z(t,16),this.e=parseInt(e,16),this.d=Z(r,16)}},tt.prototype.setPrivateEx=function(t,e,r,i,s,n,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=Z(t,16),this.e=parseInt(e,16),this.d=Z(r,16),this.p=Z(i,16),this.q=Z(s,16),this.dmp1=Z(n,16),this.dmq1=Z(o,16),this.coeff=Z(a,16)},tt.prototype.generate=function(t,e){var r=new Q,i=t>>1;this.e=parseInt(e,16);for(var s=new E(e,16),n=t/2-100,o=E.ONE.shiftLeft(n);;){for(;this.p=new E(t-i,1,r),0!=this.p.subtract(E.ONE).gcd(s).compareTo(E.ONE)||!this.p.isProbablePrime(10););for(;this.q=new E(i,1,r),0!=this.q.subtract(E.ONE).gcd(s).compareTo(E.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var a=this.p;this.p=this.q,this.q=a}var c=this.q.subtract(this.p).abs();if(!(c.bitLength()<n||c.compareTo(o)<=0)){var h=this.p.subtract(E.ONE),u=this.q.subtract(E.ONE),l=h.multiply(u);if(0==l.gcd(s).compareTo(E.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=s.modInverse(l),this.dmp1=this.d.mod(h),this.dmq1=this.d.mod(u),this.coeff=this.q.modInverse(this.p);break}}}this.isPrivate=!0},et.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},et.prototype.toBigInteger=function(){return this.x},et.prototype.negate=function(){return new et(this.q,this.x.negate().mod(this.q))},et.prototype.add=function(t){return new et(this.q,this.x.add(t.toBigInteger()).mod(this.q))},et.prototype.subtract=function(t){return new et(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},et.prototype.multiply=function(t){return new et(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},et.prototype.square=function(){return new et(this.q,this.x.square().mod(this.q))},et.prototype.divide=function(t){return new et(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},et.prototype.sqrt=function(){return new et(this.q,this.x.sqrt().mod(this.q))},rt.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},rt.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},rt.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(E.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(E.ZERO))},rt.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(E.ZERO)&&!this.y.toBigInteger().equals(E.ZERO)},rt.prototype.negate=function(){return new rt(this.curve,this.x,this.y.negate(),this.z)},rt.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),r=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(E.ZERO.equals(r))return E.ZERO.equals(e)?this.twice():this.curve.getInfinity();var i=new E("3"),s=this.x.toBigInteger(),n=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),r.square()),a=o.multiply(r),c=s.multiply(o),h=e.square().multiply(this.z),u=h.subtract(c.shiftLeft(1)).multiply(t.z).subtract(a).multiply(r).mod(this.curve.q),l=c.multiply(i).multiply(e).subtract(n.multiply(a)).subtract(h.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),p=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new rt(this.curve,this.curve.fromBigInteger(u),this.curve.fromBigInteger(l),p)},rt.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new E("3"),e=this.x.toBigInteger(),r=this.y.toBigInteger(),i=r.multiply(this.z),s=i.multiply(r).mod(this.curve.q),n=this.curve.a.toBigInteger(),o=e.square().multiply(t);E.ZERO.equals(n)||(o=o.add(this.z.square().multiply(n)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(s)).shiftLeft(1).multiply(i).mod(this.curve.q),c=o.multiply(t).multiply(e).subtract(s.shiftLeft(1)).shiftLeft(2).multiply(s).subtract(o.square().multiply(o)).mod(this.curve.q),h=i.square().multiply(i).shiftLeft(3).mod(this.curve.q);return new rt(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(c),h)},rt.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,i=r.multiply(new E("3")),s=this.negate(),n=this,o=this.curve.q.subtract(t),a=o.multiply(new E("3")),c=new rt(this.curve,this.x,this.y),h=c.negate();for(e=i.bitLength()-2;e>0;--e){n=n.twice();var u=i.testBit(e);u!=r.testBit(e)&&(n=n.add(u?this:s))}for(e=a.bitLength()-2;e>0;--e){c=c.twice();var l=a.testBit(e);l!=o.testBit(e)&&(c=c.add(l?c:h))}return n},rt.prototype.multiplyTwo=function(t,e,r){var i;i=t.bitLength()>r.bitLength()?t.bitLength()-1:r.bitLength()-1;for(var s=this.curve.getInfinity(),n=this.add(e);i>=0;)s=s.twice(),t.testBit(i)?s=r.testBit(i)?s.add(n):s.add(this):r.testBit(i)&&(s=s.add(e)),--i;return s},it.prototype.getQ=function(){return this.q},it.prototype.getA=function(){return this.a},it.prototype.getB=function(){return this.b},it.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},it.prototype.getInfinity=function(){return this.infinity},it.prototype.fromBigInteger=function(t){return new et(this.q,t)},it.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=t.substr(0,2),r=(t.substr(2),this.fromBigInteger(new E(a,16))),i=this.getA(),s=this.getB(),n=r.square().add(i).multiply(r).add(s).sqrt();return"03"==e&&(n=n.negate()),new rt(this,r,n);case 4:case 6:case 7:var o=(t.length-2)/2,a=t.substr(2,o),c=t.substr(o+2,o);return new rt(this,this.fromBigInteger(new E(a,16)),this.fromBigInteger(new E(c,16)));default:return null}},et.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},rt.prototype.getEncoded=function(t){var e=function(t,e){var r=t.toByteArrayUnsigned();if(e<r.length)r=r.slice(r.length-e);else for(;e>r.length;)r.unshift(0);return r},r=this.getX().toBigInteger(),i=this.getY().toBigInteger(),s=e(r,32);return t?i.isEven()?s.unshift(2):s.unshift(3):(s.unshift(4),s=s.concat(e(i,32))),s},rt.decodeFrom=function(t,e){e[0];var r=e.length-1,i=e.slice(1,1+r/2),s=e.slice(1+r/2,1+r);i.unshift(0),s.unshift(0);var n=new E(i),o=new E(s);return new rt(t,t.fromBigInteger(n),t.fromBigInteger(o))},rt.decodeFromHex=function(t,e){e.substr(0,2);var r=e.length-2,i=e.substr(2,r/2),s=e.substr(2+r/2,r/2),n=new E(i,16),o=new E(s,16);return new rt(t,t.fromBigInteger(n),t.fromBigInteger(o))},rt.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),r=t.y.subtract(this.y).divide(e),i=r.square().subtract(this.x).subtract(t.x),s=r.multiply(this.x.subtract(i)).subtract(this.y);return new rt(this.curve,i,s)},rt.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(E.valueOf(2)),e=this.curve.fromBigInteger(E.valueOf(3)),r=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),i=r.square().subtract(this.x.multiply(t)),s=r.multiply(this.x.subtract(i)).subtract(this.y);return new rt(this.curve,i,s)},rt.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,i=r.multiply(new E("3")),s=this.negate(),n=this;for(e=i.bitLength()-2;e>0;--e){n=n.twice();var o=i.testBit(e);o!=r.testBit(e)&&(n=n.add2D(o?this:s))}return n},rt.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),i=this.curve.getB().toBigInteger(),s=this.curve.getQ(),n=e.multiply(e).mod(s),o=t.multiply(t).multiply(t).add(r.multiply(t)).add(i).mod(s);return n.equals(o)},rt.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},rt.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(e.compareTo(E.ONE)<0||e.compareTo(t.subtract(E.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(E.ONE)<0||r.compareTo(t.subtract(E.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};var st=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),r={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function i(t,e,i){return e?r[e]:String.fromCharCode(parseInt(i,16))}var s=new String(""),n=Object.hasOwnProperty;return function(r,o){var a,c,h=r.match(t),u=h[0],l=!1;"{"===u?a={}:"["===u?a=[]:(a=[],l=!0);for(var p=[a],d=1-l,g=h.length;d<g;++d){var f;switch((u=h[d]).charCodeAt(0)){default:(f=p[0])[c||f.length]=+u,c=void 0;break;case 34:if(-1!==(u=u.substring(1,u.length-1)).indexOf("\\")&&(u=u.replace(e,i)),f=p[0],!c){if(!(f instanceof Array)){c=u||s;break}c=f.length}f[c]=u,c=void 0;break;case 91:f=p[0],p.unshift(f[c||f.length]=[]),c=void 0;break;case 93:case 125:p.shift();break;case 102:(f=p[0])[c||f.length]=!1,c=void 0;break;case 110:(f=p[0])[c||f.length]=null,c=void 0;break;case 116:(f=p[0])[c||f.length]=!0,c=void 0;break;case 123:f=p[0],p.unshift(f[c||f.length]={}),c=void 0}}if(l){if(1!==p.length)throw new Error;a=a[0]}else if(p.length)throw new Error;if(o){var m=function(t,e){var r=t[e];if(r&&"object"==typeof r){var i=null;for(var s in r)if(n.call(r,s)&&r!==t){var a=m(r,s);void 0!==a?r[s]=a:(i||(i=[]),i.push(s))}if(i)for(var c=i.length;--c>=0;)delete r[i[c]]}return o.call(t,e,r)};a=m({"":a},"")}return a}}();void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),nt.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){return Ht(t)},this.getPEMStringFromHex=function(t,e){return Et(t,e)},this.newObject=function(t){var e=nt.asn1,r=e.ASN1Object,i=e.DERBoolean,s=e.DERInteger,n=e.DERBitString,o=e.DEROctetString,a=e.DERNull,c=e.DERObjectIdentifier,h=e.DEREnumerated,u=e.DERUTF8String,l=e.DERNumericString,p=e.DERPrintableString,d=e.DERTeletexString,g=e.DERIA5String,f=e.DERUTCTime,m=e.DERGeneralizedTime,y=e.DERVisibleString,v=e.DERBMPString,S=e.DERSequence,E=e.DERSet,x=e.DERTaggedObject,w=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var A=Object.keys(t);if(1!=A.length)throw new Error("key of param shall be only one.");var b=A[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+b+":"))throw new Error("undefined key: "+b);if("bool"==b)return new i(t[b]);if("int"==b)return new s(t[b]);if("bitstr"==b)return new n(t[b]);if("octstr"==b)return new o(t[b]);if("null"==b)return new a(t[b]);if("oid"==b)return new c(t[b]);if("enum"==b)return new h(t[b]);if("utf8str"==b)return new u(t[b]);if("numstr"==b)return new l(t[b]);if("prnstr"==b)return new p(t[b]);if("telstr"==b)return new d(t[b]);if("ia5str"==b)return new g(t[b]);if("utctime"==b)return new f(t[b]);if("gentime"==b)return new m(t[b]);if("visstr"==b)return new y(t[b]);if("bmpstr"==b)return new v(t[b]);if("asn1"==b)return new r(t[b]);if("seq"==b){for(var C=t[b],I=[],R=0;R<C.length;R++){var T=w(C[R]);I.push(T)}return new S({array:I})}if("set"==b){for(C=t[b],I=[],R=0;R<C.length;R++)T=w(C[R]),I.push(T);return new E({array:I})}if("tag"==b){var F=t[b];if("[object Array]"===Object.prototype.toString.call(F)&&3==F.length){var P=w(F[2]);return new x({tag:F[0],explicit:F[1],obj:P})}return new x(F)}},this.jsonToASN1HEX=function(t){return this.newObject(t).tohex()}},nt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),i=(e=Math.floor(r/40)+"."+r%40,""),s=2;s<t.length;s+=2){var n=("00000000"+parseInt(t.substr(s,2),16).toString(2)).slice(-8);i+=n.substr(1,7),"0"==n.substr(0,1)&&(e=e+"."+new E(i,2).toString(10),i="")}return e},nt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",i=new E(t,10).toString(2),s=7-i.length%7;7==s&&(s=0);for(var n="",o=0;o<s;o++)n+="0";for(i=n+i,o=0;o<i.length-1;o+=7){var a=i.substr(o,7);o!=i.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",s=t.split("."),n=40*parseInt(s[0])+parseInt(s[1]);i+=e(n),s.splice(0,2);for(var o=0;o<s.length;o++)i+=r(s[o]);return i},nt.asn1.ASN1Object=function(t){this.params=null,this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n=0,v="+this.hV);var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var r=e.length/2;if(r>15)throw new Error("ASN.1 length too long to represent by 8x: n = "+t.toString(16));return(128+r).toString(16)+e},this.tohex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.getValueHex=function(){return this.tohex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(t){this.params=t},null!=t&&null!=t.tlv&&(this.hTLV=t.tlv,this.isModified=!1)},nt.asn1.DERAbstractString=function(t){nt.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=ft(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},Vt(nt.asn1.DERAbstractString,nt.asn1.ASN1Object),nt.asn1.DERAbstractTime=function(t){nt.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){var e=t.getTime()+6e4*t.getTimezoneOffset();return new Date(e)},this.formatDate=function(t,e,r){var i=this.zeroPadding,s=this.localDateToUTC(t),n=String(s.getFullYear());"utc"==e&&(n=n.substr(2,2));var o=n+i(String(s.getMonth()+1),2)+i(String(s.getDate()),2)+i(String(s.getHours()),2)+i(String(s.getMinutes()),2)+i(String(s.getSeconds()),2);if(!0===r){var a=s.getMilliseconds();if(0!=a){var c=i(String(a),3);o=o+"."+(c=c.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.setByParam=function(t){this.hV=null,this.hTLV=null,this.params=t},this.getString=function(){},this.setString=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.str=t},this.setByDate=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.date=t},this.setByDateValue=function(t,e,r,i,s,n){var o=new Date(Date.UTC(t,e-1,r,i,s,n,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},Vt(nt.asn1.DERAbstractTime,nt.asn1.ASN1Object),nt.asn1.DERAbstractStructured=function(t){nt.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},Vt(nt.asn1.DERAbstractStructured,nt.asn1.ASN1Object),nt.asn1.DERBoolean=function(t){nt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},Vt(nt.asn1.DERBoolean,nt.asn1.ASN1Object),nt.asn1.DERInteger=function(t){nt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var e=Ht;this.setByBigInteger=function(t){this.isModified=!0,this.params={bigint:t}},this.setByInteger=function(t){this.isModified=!0,this.params=t},this.setValueHex=function(t){this.isModified=!0,this.params={hex:t}},this.getFreshValueHex=function(){var t=this.params,r=null;if(null==t)throw new Error("value not set");if("object"==typeof t&&null!=t.hex)return this.hV=t.hex,this.hV;if("number"==typeof t)r=new E(String(t),10);else if(null!=t.int)r=new E(String(t.int),10);else{if(null==t.bigint)throw new Error("wrong parameter");r=t.bigint}return this.hV=e(r),this.hV},null!=t&&(this.params=t)},Vt(nt.asn1.DERInteger,nt.asn1.ASN1Object),nt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=nt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.tohex()}nt.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0),t+="0000000".substr(0,e);for(var r="",i=0;i<t.length-1;i+=8){var s=t.substr(i,8),n=parseInt(s,2).toString(16);1==n.length&&(n="0"+n),r+=n}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},Vt(nt.asn1.DERBitString,nt.asn1.ASN1Object),nt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=nt.asn1.ASN1Util.newObject(t.obj);t.hex=e.tohex()}nt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Vt(nt.asn1.DEROctetString,nt.asn1.DERAbstractString),nt.asn1.DERNull=function(){nt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Vt(nt.asn1.DERNull,nt.asn1.ASN1Object),nt.asn1.DERObjectIdentifier=function(t){nt.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){var e=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",i=parseInt(t,10).toString(2),s=7-i.length%7;7==s&&(s=0);for(var n="",o=0;o<s;o++)n+="0";for(i=n+i,o=0;o<i.length-1;o+=7){var a=i.substr(o,7);o!=i.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};try{if(!t.match(/^[0-9.]+$/))return null;var i="",s=t.split("."),n=40*parseInt(s[0],10)+parseInt(s[1],10);i+=e(n),s.splice(0,2);for(var o=0;o<s.length;o++)i+=r(s[o]);return i}catch(t){return null}}(t);if(null==e)throw new Error("malformed oid string: "+t);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){var e=nt.asn1.x509.OID.name2oid(t);if(""===e)throw new Error("DERObjectIdentifier oidName undefined: "+t);this.setValueOidString(e)},this.setValueNameOrOid=function(t){t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){"string"==typeof t?this.setValueNameOrOid(t):void 0!==t.oid?this.setValueNameOrOid(t.oid):void 0!==t.name?this.setValueNameOrOid(t.name):void 0!==t.hex&&this.setValueHex(t.hex)},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.DERObjectIdentifier,nt.asn1.ASN1Object),nt.asn1.DEREnumerated=function(t){nt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=Ht(t)},this.setByInteger=function(t){var e=new E(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},Vt(nt.asn1.DEREnumerated,nt.asn1.ASN1Object),nt.asn1.DERUTF8String=function(t){nt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Vt(nt.asn1.DERUTF8String,nt.asn1.DERAbstractString),nt.asn1.DERNumericString=function(t){nt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Vt(nt.asn1.DERNumericString,nt.asn1.DERAbstractString),nt.asn1.DERPrintableString=function(t){nt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Vt(nt.asn1.DERPrintableString,nt.asn1.DERAbstractString),nt.asn1.DERTeletexString=function(t){nt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Vt(nt.asn1.DERTeletexString,nt.asn1.DERAbstractString),nt.asn1.DERIA5String=function(t){nt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Vt(nt.asn1.DERIA5String,nt.asn1.DERAbstractString),nt.asn1.DERVisibleString=function(t){nt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},Vt(nt.asn1.DERVisibleString,nt.asn1.DERAbstractString),nt.asn1.DERBMPString=function(t){nt.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},Vt(nt.asn1.DERBMPString,nt.asn1.DERAbstractString),nt.asn1.DERUTCTime=function(t){nt.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.params=void 0,this.getFreshValueHex=function(){var t=this.params;if(null==this.params&&(t={date:new Date}),"string"==typeof t){if(!t.match(/^[0-9]{12}Z$/)&&!t.match(/^[0-9]{12}\.[0-9]+Z$/))throw new Error("malformed string for UTCTime: "+t);this.hV=ut(t)}else if(null!=t.str)this.hV=ut(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ut(this.formatDate(e,"utc",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ut(this.formatDate(t.date,"utc",r))}else t instanceof Date&&(this.hV=ut(this.formatDate(t,"utc")));if(null==this.hV)throw new Error("parameter not specified properly for UTCTime");return this.hV},null!=t&&this.setByParam(t)},Vt(nt.asn1.DERUTCTime,nt.asn1.DERAbstractTime),nt.asn1.DERGeneralizedTime=function(t){nt.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.params=t,this.getFreshValueHex=function(){var t=this.params;if(null==this.params&&(t={date:new Date}),"string"==typeof t){if(!t.match(/^[0-9]{14}Z$/)&&!t.match(/^[0-9]{14}\.[0-9]+Z$/))throw new Error("malformed string for GeneralizedTime: "+t);this.hV=ut(t)}else if(null!=t.str)this.hV=ut(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ut(this.formatDate(e,"gen",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ut(this.formatDate(t.date,"gen",r))}else t instanceof Date&&(this.hV=ut(this.formatDate(t,"gen")));if(null==this.hV)throw new Error("parameter not specified properly for GeneralizedTime");return this.hV},null!=t&&this.setByParam(t)},Vt(nt.asn1.DERGeneralizedTime,nt.asn1.DERAbstractTime),nt.asn1.DERSequence=function(t){nt.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].tohex();return this.hV=t,this.hV}},Vt(nt.asn1.DERSequence,nt.asn1.DERAbstractStructured),nt.asn1.DERSet=function(t){nt.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.tohex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},Vt(nt.asn1.DERSet,nt.asn1.DERAbstractStructured),nt.asn1.DERTaggedObject=function(t){nt.asn1.DERTaggedObject.superclass.constructor.call(this);var e=nt.asn1,r=ct,i=r.getV,s=(r.isASN1HEX,e.ASN1Util.newObject);this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.params={tag:"a0",explicit:!0},this.setASN1Object=function(t,e,r){this.params={tag:e,explicit:t,obj:r}},this.getFreshValueHex=function(){var t=this.params;if(null==t.explicit&&(t.explicit=!0),null!=t.tage&&(t.tag=t.tage,t.explicit=!0),null!=t.tagi&&(t.tag=t.tagi,t.explicit=!1),null!=t.str)this.hV=ft(t.str);else if(null!=t.hex)this.hV=t.hex;else{if(null==t.obj)throw new Error("str, hex nor obj not specified");var r;t.obj instanceof e.ASN1Object?r=t.obj.tohex():"object"==typeof t.obj&&(r=s(t.obj).tohex()),t.explicit?this.hV=r:this.hV=i(r,0)}return null==t.tag&&(t.tag="a0"),this.hT=t.tag,this.hTLV=null,this.isModified=!0,this.hV},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.DERTaggedObject,nt.asn1.ASN1Object);var nt,ot,at,ct=new function(){};function ht(t){for(var e="",r=0;r<t.length;r++){var i=t[r].toString(16);1==i.length&&(i="0"+i),e+=i}return e}function ut(t){return ht(function(t){for(var e=new Array,r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}(t))}function lt(t){return(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function pt(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function dt(t){return t.length%2==1&&(t="0"+t),lt(v(t))}function gt(t){return S(pt(t))}function ft(t){return wt(Dt(t)).toLowerCase()}function mt(t){try{return decodeURIComponent(At(t))}catch(t){return null}}function yt(t){return mt(function(t){for(var e=t.match(/.{1,2}/g),r=[],i=0;i<e.length;i++){var s=parseInt(e[i],16);161<=s&&s<=191?(r.push("c2"),r.push(e[i])):192<=s&&s<=255?(r.push("c3"),r.push((s-64).toString(16))):r.push(e[i])}return r.join("")}(t))}function vt(t){for(var e="",r=0;r<t.length-1;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e}function St(t){for(var e="",r=0;r<t.length;r++)e+=("0"+t.charCodeAt(r).toString(16)).slice(-2);return e}function Et(t,e){return"-----BEGIN "+e+"-----\r\n"+function(t){return(t=t.replace(new RegExp("(.{64})","g"),"$1\r\n")).replace(/\s+$/,"")}(function(t){return v(t)}(t))+"\r\n-----END "+e+"-----\r\n"}function xt(t,e){if(-1==t.indexOf("-----BEGIN "))throw new Error("can't find PEM header");return function(t){return S(t.replace(/[^0-9A-Za-z\/+=]*/g,""))}(t=void 0!==e?(t=t.replace(new RegExp("^[^]*-----BEGIN "+e+"-----"),"")).replace(new RegExp("-----END "+e+"-----[^]*$"),""):(t=t.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function wt(t){return t.replace(/%/g,"")}function At(t){return t.replace(/(..)/g,"%$1")}function bt(t){var e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;var r=(t=t.toLowerCase()).split(":").length-1;if(r<2)throw e;var i=":".repeat(7-r+2),s=(t=t.replace("::",i)).split(":");if(8!=s.length)throw e;for(var n=0;n<8;n++)s[n]=("0000"+s[n]).slice(-4);return s.join("")}function Ct(t){if(!t.match(/^[0-9A-Fa-f]{32}$/))throw new Error("malformed IPv6 address: "+t);var e=(t=t.toLowerCase()).match(/.{1,4}/g);e=e.map(function(t){return t.replace(/^0+/,"")}),e=e.map(function(t){return""==t?"0":t});var r=(t=":"+e.join(":")+":").match(/:(0:){2,}/g);if(null==r)return t.slice(1,-1);var i=r.sort().slice(-1)[0];return"::"!=(t=t.replace(i.substr(0,i.length-1),":")).substr(0,2)&&(t=t.substr(1)),"::"!=t.substr(-2,2)&&(t=t.substr(0,t.length-1)),t}function It(t){var e=new Error("malformed hex value");if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8==t.length)try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}else if(16==t.length)try{return It(t.substr(0,8))+"/"+Rt(t.substr(8))}catch(t){throw e}else{if(32==t.length)return Ct(t);if(64!=t.length)return t;try{return Ct(t.substr(0,32))+"/"+Rt(t.substr(32))}catch(t){throw e}}}function Rt(t){var e,r=new Error("malformed mask");try{e=new E(t,16).toString(2)}catch(t){throw r}if(!e.match(/^1*0*$/))throw r;return e.replace(/0+$/,"").length}function Tt(t){var e=new Error("malformed IP address");if(!(t=t.toLowerCase(t)).match(/^[0-9a-f.:/]+$/))throw e;if(!t.match(/^[0-9.]+$/)){var r;if(t.match(/^[0-9.]+\/[0-9]+$/))return Tt((r=t.split("/"))[0])+Ft(parseInt(r[1]),32);if(t.match(/^[0-9a-f:]+$/)&&-1!==t.indexOf(":"))return bt(t);if(t.match(/^[0-9a-f:]+\/[0-9]+$/)&&-1!==t.indexOf(":"))return bt((r=t.split("/"))[0])+Ft(parseInt(r[1]),128);throw e}var i=t.split(".");if(4!==i.length)throw e;var s="";try{for(var n=0;n<4;n++)s+=("0"+parseInt(i[n]).toString(16)).slice(-2);return s}catch(t){throw e}}function Ft(t,e){return 32==e&&0==t?"00000000":128==e&&0==t?"00000000000000000000000000000000":new E(Array(t+1).join("1")+Array(e-t+1).join("0"),2).toString(16)}function Pt(t){var e=t.match(/.{4}/g).map(function(t){var e=parseInt(t.substr(0,2),16),r=parseInt(t.substr(2),16);if(0==e&r<128)return String.fromCharCode(r);if(e<8){var i=128|63&r;return mt((192|(7&e)<<3|(192&r)>>6).toString(16)+i.toString(16))}i=128|(15&e)<<2|(192&r)>>6;var s=128|63&r;return mt((224|(240&e)>>4).toString(16)+i.toString(16)+s.toString(16))});return e.join("")}function Dt(t){for(var e=encodeURIComponent(t),r="",i=0;i<e.length;i++)"%"==e[i]?(r+=e.substr(i,3),i+=2):r=r+"%"+ut(e[i]);return r}function Ot(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))}function Nt(t){return!!t.match(/^[0-9A-Za-z-_.]+$/)}function _t(t){return t.length%2==1?"0"+t:t.substr(0,1)>"7"?"00"+t:t}function Lt(t){if(!Ot(t))return null;try{var e=[],r=t.substr(0,2),i=parseInt(r,16);e[0]=new String(Math.floor(i/40)),e[1]=new String(i%40);for(var s=t.substr(2),n=[],o=0;o<s.length/2;o++)n.push(parseInt(s.substr(2*o,2),16));var a=[],c="";for(o=0;o<n.length;o++)128&n[o]?c+=kt((127&n[o]).toString(2),7):(c+=kt((127&n[o]).toString(2),7),a.push(new String(parseInt(c,2))),c="");var h=e.join(".");return a.length>0&&(h=h+"."+a.join(".")),h}catch(t){return null}}function Bt(t){return Ht(new E(String(t),10))}function Ht(t){var e=t.toString(16);if("-"!=e.substr(0,1))return e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e),e;var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var i="",s=0;s<r;s++)i+="f";return new E(i,16).xor(t).add(E.ONE).toString(16).replace(/^-/,"")}ct.getLblen=function(t,e){if("8"!=t.substr(e+2,1))return 1;var r=parseInt(t.substr(e+3,1));return 0==r?-1:0<r&&r<10?r+1:-2},ct.getL=function(t,e){var r=ct.getLblen(t,e);return r<1?"":t.substr(e+2,2*r)},ct.getVblen=function(t,e){var r;return""==(r=ct.getL(t,e))?-1:("8"===r.substr(0,1)?new E(r.substr(2),16):new E(r,16)).intValue()},ct.getVidx=function(t,e){var r=ct.getLblen(t,e);return r<0?r:e+2*(r+1)},ct.getV=function(t,e){var r=ct.getVidx(t,e),i=ct.getVblen(t,e);return t.substr(r,2*i)},ct.getTLV=function(t,e){return t.substr(e,2)+ct.getL(t,e)+ct.getV(t,e)},ct.getTLVblen=function(t,e){return 2+2*ct.getLblen(t,e)+2*ct.getVblen(t,e)},ct.getNextSiblingIdx=function(t,e){return ct.getVidx(t,e)+2*ct.getVblen(t,e)},ct.getChildIdx=function(t,e){var r,i,s,n=ct,o=[];r=n.getVidx(t,e),i=2*n.getVblen(t,e),"03"==t.substr(e,2)&&(r+=2,i-=2),s=0;for(var a=r;s<=i;){var c=n.getTLVblen(t,a);if((s+=c)<=i&&o.push(a),a+=c,s>=i)break}return o},ct.getNthChildIdx=function(t,e,r){return ct.getChildIdx(t,e)[r]},ct.getIdxbyList=function(t,e,r,i){var s,n,o=ct;return 0==r.length?void 0!==i&&t.substr(e,2)!==i?-1:e:(s=r.shift())>=(n=o.getChildIdx(t,e)).length?-1:o.getIdxbyList(t,n[s],r,i)},ct.getIdxbyListEx=function(t,e,r,i){var s,n,o=ct;if(0==r.length)return void 0!==i&&t.substr(e,2)!==i?-1:e;s=r.shift(),n=o.getChildIdx(t,e);for(var a=0,c=0;c<n.length;c++){var h=t.substr(n[c],2);if("number"==typeof s&&!o.isContextTag(h)&&a==s||"string"==typeof s&&o.isContextTag(h,s))return o.getIdxbyListEx(t,n[c],r,i);o.isContextTag(h)||a++}return-1},ct.getTLVbyList=function(t,e,r,i){var s=ct,n=s.getIdxbyList(t,e,r,i);return-1==n||n>=t.length?null:s.getTLV(t,n)},ct.getTLVbyListEx=function(t,e,r,i){var s=ct,n=s.getIdxbyListEx(t,e,r,i);return-1==n?null:s.getTLV(t,n)},ct.getVbyList=function(t,e,r,i,s){var n,o,a=ct;return-1==(n=a.getIdxbyList(t,e,r,i))||n>=t.length?null:(o=a.getV(t,n),!0===s&&(o=o.substr(2)),o)},ct.getVbyListEx=function(t,e,r,i,s){var n,o,a=ct;return-1==(n=a.getIdxbyListEx(t,e,r,i))?null:(o=a.getV(t,n),"03"==t.substr(n,2)&&!1!==s&&(o=o.substr(2)),o)},ct.getInt=function(t,e,r){null==r&&(r=-1);try{var i=t.substr(e,2);if("02"!=i&&"03"!=i)return r;var s=ct.getV(t,e);return"02"==i?parseInt(s,16):function(t){if(t.length%2!=0)return-1;if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return-1;try{var e=t.substr(0,2);if("00"==e)return parseInt(t.substr(2),16);var r=parseInt(e,16);if(r>7)return-1;var i=t.substr(2),s=parseInt(i,16).toString(2);"0"==s&&(s="00000000"),s=s.slice(0,0-r);var n=parseInt(s,2);return NaN==n?-1:n}catch(t){return-1}}(s)}catch(t){return r}},ct.getOID=function(t,e,r){null==r&&(r=null);try{return"06"!=t.substr(e,2)?r:Lt(ct.getV(t,e))}catch(t){return r}},ct.getOIDName=function(t,e,r){null==r&&(r=null);try{var i=ct.getOID(t,e,r);if(i==r)return r;var s=nt.asn1.x509.OID.oid2name(i);return""==s?i:s}catch(t){return r}},ct.getString=function(t,e,r){null==r&&(r=null);try{return vt(ct.getV(t,e))}catch(t){return r}},ct.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},r=[],i=t.substr(0,2),s=parseInt(i,16);r[0]=new String(Math.floor(s/40)),r[1]=new String(s%40);for(var n=t.substr(2),o=[],a=0;a<n.length/2;a++)o.push(parseInt(n.substr(2*a,2),16));var c=[],h="";for(a=0;a<o.length;a++)128&o[a]?h+=e((127&o[a]).toString(2),7):(h+=e((127&o[a]).toString(2),7),c.push(new String(parseInt(h,2))),h="");var u=r.join(".");return c.length>0&&(u=u+"."+c.join(".")),u},ct.dump=function(t,e,r,i){var s=ct,n=s.getV,o=s.dump,a=s.getChildIdx,c=t;t instanceof nt.asn1.ASN1Object&&(c=t.tohex());var h=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===r&&(r=0),void 0===i&&(i="");var u,l=e.ommit_long_octet;if("01"==(u=c.substr(r,2)))return"00"==(p=n(c,r))?i+"BOOLEAN FALSE\n":i+"BOOLEAN TRUE\n";if("02"==u)return i+"INTEGER "+h(p=n(c,r),l)+"\n";if("03"==u){var p=n(c,r);return s.isASN1HEX(p.substr(2))?(x=i+"BITSTRING, encapsulates\n")+o(p.substr(2),e,0,i+" "):i+"BITSTRING "+h(p,l)+"\n"}if("04"==u)return p=n(c,r),s.isASN1HEX(p)?(x=i+"OCTETSTRING, encapsulates\n")+o(p,e,0,i+" "):i+"OCTETSTRING "+h(p,l)+"\n";if("05"==u)return i+"NULL\n";if("06"==u){var d=n(c,r),g=nt.asn1.ASN1Util.oidHexToInt(d),f=nt.asn1.x509.OID.oid2name(g),m=g.replace(/\./g," ");return""!=f?i+"ObjectIdentifier "+f+" ("+m+")\n":i+"ObjectIdentifier ("+m+")\n"}if("0a"==u)return i+"ENUMERATED "+parseInt(n(c,r))+"\n";if("0c"==u)return i+"UTF8String '"+mt(n(c,r))+"'\n";if("13"==u)return i+"PrintableString '"+mt(n(c,r))+"'\n";if("14"==u)return i+"TeletexString '"+mt(n(c,r))+"'\n";if("16"==u)return i+"IA5String '"+mt(n(c,r))+"'\n";if("17"==u)return i+"UTCTime "+mt(n(c,r))+"\n";if("18"==u)return i+"GeneralizedTime "+mt(n(c,r))+"\n";if("1a"==u)return i+"VisualString '"+mt(n(c,r))+"'\n";if("1e"==u)return i+"BMPString '"+Pt(n(c,r))+"'\n";if("30"==u){if("3000"==c.substr(r,4))return i+"SEQUENCE {}\n";x=i+"SEQUENCE\n";var y=e;if((2==(E=a(c,r)).length||3==E.length)&&"06"==c.substr(E[0],2)&&"04"==c.substr(E[E.length-1],2)){f=s.oidname(n(c,E[0]));var v=JSON.parse(JSON.stringify(e));v.x509ExtName=f,y=v}for(var S=0;S<E.length;S++)x+=o(c,y,E[S],i+" ");return x}if("31"==u){x=i+"SET\n";var E=a(c,r);for(S=0;S<E.length;S++)x+=o(c,e,E[S],i+" ");return x}if(128&(u=parseInt(u,16))){var x,w=31&u;if(32&u){for(x=i+"["+w+"]\n",E=a(c,r),S=0;S<E.length;S++)x+=o(c,e,E[S],i+" ");return x}return p=n(c,r),ct.isASN1HEX(p)?(x=i+"["+w+"]\n")+o(p,e,0,i+" "):(("68747470"==p.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==w)&&(p=mt(p)),i+"["+w+"] "+p+"\n")}return i+"UNKNOWN("+u+") "+n(c,r)+"\n"},ct.parse=function(t){var e=ct,r=e.parse,i=e.isASN1HEX,s=e.getV,n=e.getTLV,o=e.getChildIdx,a=nt.asn1,c=a.ASN1Util.oidHexToInt,h=a.x509.OID.oid2name,u=mt,l=Pt,p=yt,d={"0c":"utf8str",12:"numstr",13:"prnstr",14:"telstr",16:"ia5str",17:"utctime",18:"gentime","1a":"visstr","1e":"bmpstr",30:"seq",31:"set"},g=t.substr(0,2),f={},m=s(t,0);if("01"==g)return"0101ff"==t?{bool:!0}:{bool:!1};if("02"==g)return{int:{hex:m}};if("03"==g)try{if("00"!=m.substr(0,2))throw"not encap";var y=m.substr(2);if(!i(y))throw"not encap";return{bitstr:{obj:r(y)}}}catch(t){var v=null;return m.length<=10&&(v=function(t){if("string"!=typeof t)return null;if(t.length%2!=0)return null;if(!t.match(/^[0-9a-f]+$/))return null;try{var e=parseInt(t.substr(0,2),16);if(e<0||7<e)return null;for(var r=t.substr(2),i="",s=0;s<r.length;s+=2){var n=r.substr(s,2),o=parseInt(n,16).toString(2);i+=o=("0000000"+o).slice(-8)}return i.substr(0,i.length-e)}catch(t){return null}}(m)),null==v?{bitstr:{hex:m}}:{bitstr:{bin:v}}}else if("04"==g)try{if(!i(m))throw"not encap";return{octstr:{obj:r(m)}}}catch(t){return{octstr:{hex:m}}}else{if("05"==g)return{null:""};if("06"==g){var S=c(m),E=h(S);return""==E?{oid:S}:{oid:E}}if("0a"==g)return m.length>4?{enum:{hex:m}}:{enum:parseInt(m,16)};if("30"==g||"31"==g)return f[d[g]]=function(t){for(var e=[],i=o(t,0),s=0;s<i.length;s++){var a=i[s],c=n(t,a),h=r(c);e.push(h)}return e}(t),f;if("14"==g){var x=p(m);return f[d[g]]={str:x},f}if("1e"==g)return x=l(m),f[d[g]]={str:x},f;if(-1!=":0c:12:13:16:17:18:1a:".indexOf(g))return x=u(m),f[d[g]]={str:x},f;if(g.match(/^8[0-9]$/))return null==(x=u(m))|""==x||null!=x.match(/[\x00-\x1F\x7F-\x9F]/)||null!=x.match(/[\u0000-\u001F\u0080–\u009F]/)?{tag:{tag:g,explicit:!1,hex:m}}:{tag:{tag:g,explicit:!1,str:x}};if(!g.match(/^a[0-9]$/)){var w=new nt.asn1.ASN1Object;return w.hV=m,{asn1:{tlv:g+w.getLengthHexFromValue()+m}}}try{if(!i(m))throw new Error("not encap");return{tag:{tag:g,explicit:!0,obj:r(m)}}}catch(t){return{tag:{tag:g,explicit:!0,hex:m}}}}},ct.isContextTag=function(t,e){var r,i;t=t.toLowerCase();try{r=parseInt(t,16)}catch(t){return-1}if(void 0===e)return 128==(192&r);try{return null!=e.match(/^\[[0-9]+\]$/)&&!((i=parseInt(e.substr(1,e.length-1),10))>31)&&128==(192&r)&&(31&r)==i}catch(t){return!1}},ct.isASN1HEX=function(t){var e=ct;if(t.length%2==1)return!1;var r=e.getVblen(t,0),i=t.substr(0,2),s=e.getL(t,0);return t.length-i.length-s.length==2*r},ct.checkStrictDER=function(t,e,r,i,s){var n=ct;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!nt.lang.String.isHex(t))throw new Error("not hex string");r=t.length,s=(i=t.length/2)<128?1:Math.ceil(i.toString(16))+1}if(n.getL(t,e).length>2*s)throw new Error("L of TLV too long: idx="+e);var o=n.getVblen(t,e);if(o>i)throw new Error("value of L too long than hex: idx="+e);var a=n.getTLV(t,e),c=a.length-2-n.getL(t,e).length;if(c!==2*o)throw new Error("V string length and L's value not the same:"+c+"/"+2*o);if(0===e&&t.length!=a.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+a.length);var h=t.substr(e,2);if("02"===h){var u=n.getVidx(t,e);if("00"==t.substr(u,2)&&t.charCodeAt(u+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(h,16)){for(var l=n.getVblen(t,e),p=0,d=n.getChildIdx(t,e),g=0;g<d.length;g++)p+=n.getTLV(t,d[g]).length,n.checkStrictDER(t,d[g],r,i,s);if(2*l!=p)throw new Error("sum of children's TLV length and L unmatch: "+2*l+"!="+p)}},ct.oidname=function(t){var e=nt.asn1;nt.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var r=e.x509.OID.oid2name(t);return""===r&&(r=t),r},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.x509&&nt.asn1.x509||(nt.asn1.x509={}),nt.asn1.x509.Certificate=function(t){nt.asn1.x509.Certificate.superclass.constructor.call(this);var e=nt.asn1,r=e.DERBitString,i=e.DERSequence,s=e.x509,n=s.TBSCertificate,o=s.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.sigalg;null!=t.sigalg.name&&(e=t.sigalg.name);var r=t.tbsobj.tohex(),i=new nt.crypto.Signature({alg:e});i.init(t.cakey),i.updateHex(r),t.sighex=i.sign()},this.getPEM=function(){return Et(this.tohex(),"CERTIFICATE")},this.tohex=function(){var t=this.params;if(null!=t.tbsobj&&null!=t.tbsobj||(t.tbsobj=new n(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new o({name:t.sigalg})),e.push(new r({hex:"00"+t.sighex})),new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},Vt(nt.asn1.x509.Certificate,nt.asn1.ASN1Object),nt.asn1.x509.TBSCertificate=function(t){nt.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=nt.asn1,r=e.x509,i=e.DERTaggedObject,s=e.DERInteger,n=e.DERSequence,o=r.AlgorithmIdentifier,a=r.Time,c=r.X500Name,h=r.Extensions,u=r.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=[],e=this.params;if(null!=e.version||1!=e.version){var r=2;null!=e.version&&(r=e.version-1);var l=new i({obj:new s({int:r})});t.push(l)}return t.push(new s(e.serial)),t.push(new o({name:e.sigalg})),t.push(new c(e.issuer)),t.push(new n({array:[new a(e.notbefore),new a(e.notafter)]})),t.push(new c(e.subject)),t.push(new u(Mt.getKey(e.sbjpubkey))),void 0!==e.ext&&e.ext.length>0&&t.push(new i({tag:"a3",obj:new h(e.ext)})),new nt.asn1.DERSequence({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.TBSCertificate,nt.asn1.ASN1Object),nt.asn1.x509.Extensions=function(t){nt.asn1.x509.Extensions.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.tohex=function(){for(var t=[],e=0;e<this.aParam.length;e++){var s=this.aParam[e],n=s.extname,o=null;if(null!=s.extn)o=new i.PrivateExtension(s);else if("subjectKeyIdentifier"==n)o=new i.SubjectKeyIdentifier(s);else if("keyUsage"==n)o=new i.KeyUsage(s);else if("subjectAltName"==n)o=new i.SubjectAltName(s);else if("issuerAltName"==n)o=new i.IssuerAltName(s);else if("basicConstraints"==n)o=new i.BasicConstraints(s);else if("nameConstraints"==n)o=new i.NameConstraints(s);else if("cRLDistributionPoints"==n)o=new i.CRLDistributionPoints(s);else if("certificatePolicies"==n)o=new i.CertificatePolicies(s);else if("policyMappings"==n)o=new i.PolicyMappings(s);else if("policyConstraints"==n)o=new i.PolicyConstraints(s);else if("inhibitAnyPolicy"==n)o=new i.InhibitAnyPolicy(s);else if("authorityKeyIdentifier"==n)o=new i.AuthorityKeyIdentifier(s);else if("extKeyUsage"==n)o=new i.ExtKeyUsage(s);else if("authorityInfoAccess"==n)o=new i.AuthorityInfoAccess(s);else if("cRLNumber"==n)o=new i.CRLNumber(s);else if("cRLReason"==n)o=new i.CRLReason(s);else if("ocspNonce"==n)o=new i.OCSPNonce(s);else if("ocspNoCheck"==n)o=new i.OCSPNoCheck(s);else if("adobeTimeStamp"==n)o=new i.AdobeTimeStamp(s);else{if("subjectDirectoryAttributes"!=n)throw new Error("extension not supported:"+JSON.stringify(s));o=new i.SubjectDirectoryAttributes(s)}null!=o&&t.push(o)}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.x509.Extensions,nt.asn1.ASN1Object),nt.asn1.x509.Extension=function(t){nt.asn1.x509.Extension.superclass.constructor.call(this);var e=nt.asn1,r=e.DERObjectIdentifier,i=e.DEROctetString,s=(e.DERBitString,e.DERBoolean),n=e.DERSequence;this.tohex=function(){var t=new r({oid:this.oid}),e=new i({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new s),o.push(e),new n({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},Vt(nt.asn1.x509.Extension,nt.asn1.ASN1Object),nt.asn1.x509.KeyUsage=function(t){nt.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Error,r={digitalSignature:0,nonRepudiation:1,keyEncipherment:2,dataEncipherment:3,keyAgreement:4,keyCertSign:5,cRLSign:6,encipherOnly:7,decipherOnly:8};this.getExtnValueHex=function(){var t=this.getBinValue();return this.asn1ExtnValue=new nt.asn1.DERBitString({bin:t}),this.asn1ExtnValue.tohex()},this.getBinValue=function(){var t=this.params;if("object"!=typeof t||"object"!=typeof t.names&&"string"!=typeof t.bin)throw new e("parameter not yet set");if(null!=t.names)return Ut(t.names,r);if(null!=t.bin)return t.bin;throw new e("parameter not set properly")},this.oid="2.5.29.15",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.KeyUsage,nt.asn1.x509.Extension),nt.asn1.x509.BasicConstraints=function(t){nt.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERBoolean,i=e.DERInteger,s=e.DERSequence;this.getExtnValueHex=function(){var t=new Array;this.cA&&t.push(new r),this.pathLen>-1&&t.push(new i({int:this.pathLen}));var e=new s({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.tohex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},Vt(nt.asn1.x509.BasicConstraints,nt.asn1.x509.Extension),nt.asn1.x509.CRLDistributionPoints=function(t){nt.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=nt.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(t){for(var i=[],s=0;s<t.length;s++)if(t[s]instanceof nt.asn1.ASN1Object)i.push(t[s]);else{var n=new r.DistributionPoint(t[s]);i.push(n)}this.asn1ExtnValue=new e.DERSequence({array:i})},this.setByOneURI=function(t){var e=new r.DistributionPoint({fulluri:t});this.setByDPArray([e])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},Vt(nt.asn1.x509.CRLDistributionPoints,nt.asn1.x509.Extension),nt.asn1.x509.DistributionPoint=function(t){nt.asn1.x509.DistributionPoint.superclass.constructor.call(this);var e=nt.asn1,r=e.x509.DistributionPointName;this.tohex=function(){var t=new e.DERSequence;if(null!=this.asn1DP){var r=new e.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});t.appendASN1Object(r)}return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.dpobj?this.asn1DP=t.dpobj:void 0!==t.dpname?this.asn1DP=new r(t.dpname):void 0!==t.fulluri&&(this.asn1DP=new r({full:[{uri:t.fulluri}]})))},Vt(nt.asn1.x509.DistributionPoint,nt.asn1.ASN1Object),nt.asn1.x509.DistributionPointName=function(t){nt.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=nt.asn1,r=e.DERTaggedObject;if(this.tohex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new r({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t)if(e.x509.GeneralNames.prototype.isPrototypeOf(t))this.type="full",this.tag="a0",this.asn1V=t;else{if(void 0===t.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new e.x509.GeneralNames(t.full)}},Vt(nt.asn1.x509.DistributionPointName,nt.asn1.ASN1Object),nt.asn1.x509.CertificatePolicies=function(t){nt.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=nt.asn1,r=e.x509,i=e.DERSequence,s=r.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new s(this.params.array[e]));var r=new i({array:t});return this.asn1ExtnValue=r,this.asn1ExtnValue.tohex()},this.oid="2.5.29.32",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.CertificatePolicies,nt.asn1.x509.Extension),nt.asn1.x509.PolicyInformation=function(t){nt.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=e.x509.PolicyQualifierInfo;this.params=null,this.tohex=function(){if(void 0===this.params.policyoid&&void 0===this.params.array)throw new Error("parameter oid and array missing");var t=[new i(this.params.policyoid)];if(void 0!==this.params.array){for(var e=[],n=0;n<this.params.array.length;n++)e.push(new s(this.params.array[n]));e.length>0&&t.push(new r({array:e}))}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.PolicyInformation,nt.asn1.ASN1Object),nt.asn1.x509.PolicyQualifierInfo=function(t){nt.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERSequence,i=e.DERIA5String,s=e.DERObjectIdentifier,n=e.x509.UserNotice;this.params=null,this.tohex=function(){return void 0!==this.params.cps?new r({array:[new s({oid:"1.3.6.1.5.5.7.2.1"}),new i({str:this.params.cps})]}).tohex():null!=this.params.unotice?new r({array:[new s({oid:"1.3.6.1.5.5.7.2.2"}),new n(this.params.unotice)]}).tohex():void 0},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.PolicyQualifierInfo,nt.asn1.ASN1Object),nt.asn1.x509.UserNotice=function(t){nt.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=nt.asn1.DERSequence,r=(nt.asn1.DERInteger,nt.asn1.x509.DisplayText),i=nt.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new i(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new r(this.params.exptext)),new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.UserNotice,nt.asn1.ASN1Object),nt.asn1.x509.NoticeReference=function(t){nt.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=nt.asn1.DERSequence,r=nt.asn1.DERInteger,i=nt.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var t=[];if(void 0!==this.params.org&&t.push(new i(this.params.org)),void 0!==this.params.noticenum){for(var s=[],n=this.params.noticenum,o=0;o<n.length;o++)s.push(new r(n[o]));t.push(new e({array:s}))}if(0==t.length)throw new Error("parameter is empty");return new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.NoticeReference,nt.asn1.ASN1Object),nt.asn1.x509.DisplayText=function(t){nt.asn1.x509.DisplayText.superclass.constructor.call(this,t),this.hT="0c",void 0!==t&&("ia5"===t.type?this.hT="16":"vis"===t.type?this.hT="1a":"bmp"===t.type&&(this.hT="1e"))},Vt(nt.asn1.x509.DisplayText,nt.asn1.DERAbstractString),nt.asn1.x509.PolicyMappings=function(t){nt.asn1.x509.PolicyMappings.superclass.constructor.call(this,t);var e=nt.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){for(var t=this.params,e=[],i=0;i<t.array.length;i++){var s=t.array[i];e.push({seq:[{oid:s[0]},{oid:s[1]}]})}return this.asn1ExtnValue=r({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.33",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.PolicyMappings,nt.asn1.x509.Extension),nt.asn1.x509.PolicyConstraints=function(t){nt.asn1.x509.PolicyConstraints.superclass.constructor.call(this,t);var e=nt.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];return null!=t.reqexp&&e.push({tag:{tagi:"80",obj:{int:t.reqexp}}}),null!=t.inhibit&&e.push({tag:{tagi:"81",obj:{int:t.inhibit}}}),this.asn1ExtnValue=r({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.36",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.PolicyConstraints,nt.asn1.x509.Extension),nt.asn1.x509.InhibitAnyPolicy=function(t){nt.asn1.x509.InhibitAnyPolicy.superclass.constructor.call(this,t);var e=nt.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=r({int:this.params.skip}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.54",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.InhibitAnyPolicy,nt.asn1.x509.Extension),nt.asn1.x509.NameConstraints=function(t){nt.asn1.x509.NameConstraints.superclass.constructor.call(this,t);var e=nt.asn1,r=e.x509,i=e.ASN1Util.newObject,s=r.GeneralSubtree;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];if(null!=t.permit&&null!=t.permit.length){for(var r=[],n=0;n<t.permit.length;n++)r.push(new s(t.permit[n]));e.push({tag:{tagi:"a0",obj:{seq:r}}})}if(null!=t.exclude&&null!=t.exclude.length){var o=[];for(n=0;n<t.exclude.length;n++)o.push(new s(t.exclude[n]));e.push({tag:{tagi:"a1",obj:{seq:o}}})}return this.asn1ExtnValue=i({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.30",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.NameConstraints,nt.asn1.x509.Extension),nt.asn1.x509.GeneralSubtree=function(t){nt.asn1.x509.GeneralSubtree.superclass.constructor.call(this);var e=nt.asn1,r=e.x509.GeneralName,i=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,e=[new r(t)];return null!=t.min&&e.push({tag:{tagi:"80",obj:{int:t.min}}}),null!=t.max&&e.push({tag:{tagi:"81",obj:{int:t.max}}}),i({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.GeneralSubtree,nt.asn1.ASN1Object),nt.asn1.x509.ExtKeyUsage=function(t){nt.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=nt.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var r=0;r<t.length;r++){var i=new e.DERObjectIdentifier(t[r]);this.asn1ExtnValue.appendASN1Object(i)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.37",void 0!==t&&void 0!==t.array&&this.setPurposeArray(t.array)},Vt(nt.asn1.x509.ExtKeyUsage,nt.asn1.x509.Extension),nt.asn1.x509.AuthorityKeyIdentifier=function(t){nt.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=nt,r=e.asn1,i=r.DERTaggedObject,s=r.x509.GeneralNames;e.crypto.Util.isKey,this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var t=new Array;this.asn1KID&&t.push(new i({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&t.push(new i({explicit:!1,tag:"a1",obj:new s([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&t.push(new i({explicit:!1,tag:"82",obj:this.asn1CertSN}));var e=new r.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new nt.asn1.DEROctetString(t);else if("object"==typeof t&&nt.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN ")){var e=t;"string"==typeof t&&(e=Mt.getKey(t));var r=Mt.getKeyID(e);this.asn1KID=new nt.asn1.DEROctetString({hex:r})}},this.setCertIssuerByParam=function(t){void 0!==t.str||void 0!==t.ldapstr||void 0!==t.hex||void 0!==t.certsubject||void 0!==t.certissuer?this.asn1CertIssuer=new nt.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new nt.asn1.x509.X500Name({certissuer:t}))},this.setCertSNByParam=function(t){if(void 0!==t.str||void 0!==t.bigint||void 0!==t.hex)this.asn1CertSN=new nt.asn1.DERInteger(t);else if("string"==typeof t&&-1!=t.indexOf("BEGIN ")&&t.indexOf("CERTIFICATE")){var e=new $t;e.readCertPEM(t);var r=e.getSerialNumberHex();this.asn1CertSN=new nt.asn1.DERInteger({hex:r})}},this.oid="2.5.29.35",void 0!==t&&(void 0!==t.kid&&this.setKIDByParam(t.kid),void 0!==t.issuer&&this.setCertIssuerByParam(t.issuer),void 0!==t.sn&&this.setCertSNByParam(t.sn),void 0!==t.issuersn&&"string"==typeof t.issuersn&&-1!=t.issuersn.indexOf("BEGIN ")&&t.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(t.issuersn),this.setCertIssuerByParam(t.issuersn)))},Vt(nt.asn1.x509.AuthorityKeyIdentifier,nt.asn1.x509.Extension),nt.asn1.x509.SubjectKeyIdentifier=function(t){nt.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var e=nt.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new e(t);else if("object"==typeof t&&nt.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN")){var r=t;"string"==typeof t&&(r=Mt.getKey(t));var i=Mt.getKeyID(r);this.asn1KID=new nt.asn1.DEROctetString({hex:i})}},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},Vt(nt.asn1.x509.SubjectKeyIdentifier,nt.asn1.x509.Extension),nt.asn1.x509.AuthorityInfoAccess=function(t){nt.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,r=nt.asn1,i=r.DERSequence,s=r.DERObjectIdentifier,n=r.x509.GeneralName,o=0;o<t.length;o++){var a,c=t[o];if(void 0!==c.ocsp)a=new i({array:[new s({oid:"1.3.6.1.5.5.7.48.1"}),new n({uri:c.ocsp})]});else{if(void 0===c.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(c));a=new i({array:[new s({oid:"1.3.6.1.5.5.7.48.2"}),new n({uri:c.caissuer})]})}e.push(a)}this.asn1ExtnValue=new i({array:e})},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==t&&void 0!==t.array&&this.setAccessDescriptionArray(t.array)},Vt(nt.asn1.x509.AuthorityInfoAccess,nt.asn1.x509.Extension),nt.asn1.x509.SubjectAltName=function(t){nt.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new nt.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.17",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},Vt(nt.asn1.x509.SubjectAltName,nt.asn1.x509.Extension),nt.asn1.x509.IssuerAltName=function(t){nt.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new nt.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.18",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},Vt(nt.asn1.x509.IssuerAltName,nt.asn1.x509.Extension),nt.asn1.x509.SubjectDirectoryAttributes=function(t){nt.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERSequence,i=e.ASN1Util.newObject,s=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var n=this.params.array[e];if(null==n.attr||null==n.array){var o={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==n.attr)o.seq[0].oid=s(n.attr),o.seq[1].set[0]={gentime:n.str};else if("placeOfBirth"==n.attr)o.seq[0].oid=s(n.attr),o.seq[1].set[0]={utf8str:n.str};else if("gender"==n.attr)o.seq[0].oid=s(n.attr),o.seq[1].set[0]={prnstr:n.str};else if("countryOfCitizenship"==n.attr)o.seq[0].oid=s(n.attr),o.seq[1].set[0]={prnstr:n.str};else{if("countryOfResidence"!=n.attr)throw new Error("unsupported attribute: "+n.attr);o.seq[0].oid=s(n.attr),o.seq[1].set[0]={prnstr:n.str}}t.push(new i(o))}else{var a={seq:[{oid:n.attr},{set:n.array}]};t.push(i(a))}}var c=new r({array:t});return this.asn1ExtnValue=c,this.asn1ExtnValue.tohex()},this.oid="2.5.29.9",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.SubjectDirectoryAttributes,nt.asn1.x509.Extension),nt.asn1.x509.PrivateExtension=function(t){nt.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=nt,r=e.lang.String.isHex,i=e.asn1,s=i.x509.OID.name2oid,n=i.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=s(t.extname),this.params=t},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var t=this.params.extn;if("string"==typeof t&&r(t))return t;if("object"==typeof t)try{return n(t).tohex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},Vt(nt.asn1.x509.PrivateExtension,nt.asn1.x509.Extension),nt.asn1.x509.CRL=function(t){nt.asn1.x509.CRL.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.DERBitString,s=e.x509,n=s.AlgorithmIdentifier,o=s.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new o(this.params).tohex(),e=new nt.crypto.Signature({alg:this.params.sigalg});e.init(this.params.cakey),e.updateHex(t);var r=e.sign();this.params.sighex=r},this.getPEM=function(){return Et(this.tohex(),"X509 CRL")},this.tohex=function(){var t=this.params;if(null==t.tbsobj&&(t.tbsobj=new o(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new n({name:t.sigalg})),e.push(new i({hex:"00"+t.sighex})),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},Vt(nt.asn1.x509.CRL,nt.asn1.ASN1Object),nt.asn1.x509.TBSCertList=function(t){nt.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=nt.asn1,r=e.DERInteger,i=e.DERSequence,s=e.DERTaggedObject,n=(e.DERObjectIdentifier,e.x509),o=n.AlgorithmIdentifier,a=n.Time,c=n.Extensions,h=n.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,s=0;s<e.length;s++){var n=[new r(e[s].sn),new a(e[s].date)];null!=e[s].ext&&n.push(new c(e[s].ext)),t.push(new i({array:n}))}return new i({array:t})},this.tohex=function(){var t=[],e=this.params;if(null!=e.version){var n=e.version-1,u=new r({int:n});t.push(u)}if(t.push(new o({name:e.sigalg})),t.push(new h(e.issuer)),t.push(new a(e.thisupdate)),null!=e.nextupdate&&t.push(new a(e.nextupdate)),null!=e.revcert&&t.push(this.getRevCertSequence()),null!=e.ext){var l=new c(e.ext);t.push(new s({tag:"a0",explicit:!0,obj:l}))}return new i({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.TBSCertList,nt.asn1.ASN1Object),nt.asn1.x509.CRLEntry=function(t){nt.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=nt.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.tohex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},Vt(nt.asn1.x509.CRLEntry,nt.asn1.ASN1Object),nt.asn1.x509.CRLNumber=function(t){nt.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DERInteger(this.params.num),this.asn1ExtnValue.tohex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},Vt(nt.asn1.x509.CRLNumber,nt.asn1.x509.Extension),nt.asn1.x509.CRLReason=function(t){nt.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.tohex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},Vt(nt.asn1.x509.CRLReason,nt.asn1.x509.Extension),nt.asn1.x509.OCSPNonce=function(t){nt.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DEROctetString(this.params),this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},Vt(nt.asn1.x509.OCSPNonce,nt.asn1.x509.Extension),nt.asn1.x509.OCSPNoCheck=function(t){nt.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DERNull,this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},Vt(nt.asn1.x509.OCSPNoCheck,nt.asn1.x509.Extension),nt.asn1.x509.AdobeTimeStamp=function(t){nt.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERInteger,i=e.DERBoolean,s=e.DERSequence,n=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new r(1)];return e.push(new n({uri:t.uri})),null!=t.reqauth&&e.push(new i(t.reqauth)),this.asn1ExtnValue=new s({array:e}),this.asn1ExtnValue.tohex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.AdobeTimeStamp,nt.asn1.x509.Extension),nt.asn1.x509.X500Name=function(t){nt.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=nt.asn1,r=e.x509,i=r.RDN;this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.split("/");r.shift();for(var s=[],n=0;n<r.length;n++)if(r[n].match(/^[^=]+=.+$/))s.push(r[n]);else{var o=s.length-1;s[o]=s[o]+"/"+r[n]}for(n=0;n<s.length;n++)this.asn1Array.push(new i({str:s[n],rule:this.sRule}))},this.setByLdapString=function(t,e){void 0!==e&&(this.sRule=e);var i=r.X500Name.ldapToCompat(t);this.setByString(i,e)},this.setByObject=function(t,e){for(var r in void 0!==e&&(this.sRule=e),t)if(t.hasOwnProperty(r)){var s=new i({str:r+"="+t[r],rule:this.sRule});this.asn1Array?this.asn1Array.push(s):this.asn1Array=[s]}},this.setByParam=function(t){var e;void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.array?this.paramArray=t.array:void 0!==t.str?this.setByString(t.str):void 0!==t.ldapstr?this.setByLdapString(t.ldapstr):void 0!==t.hex?this.hTLV=t.hex:void 0!==t.certissuer?((e=new $t).readCertPEM(t.certissuer),this.hTLV=e.getIssuerHex()):void 0!==t.certsubject?((e=new $t).readCertPEM(t.certsubject),this.hTLV=e.getSubjectHex()):"object"==typeof t&&void 0===t.certsubject&&void 0===t.certissuer&&this.setByObject(t)},this.tohex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r={array:this.paramArray[t]};"utf8"!=this.sRule&&(r.rule=this.sRule);var s=new i(r);this.asn1Array.push(s)}var n=new e.DERSequence({array:this.asn1Array});return this.hTLV=n.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.X500Name,nt.asn1.ASN1Object),nt.asn1.x509.X500Name.compatToLDAP=function(t){if("/"!==t.substr(0,1))throw"malformed input";var e=(t=t.substr(1)).split("/");return e.reverse(),e=e.map(function(t){return t.replace(/,/,"\\,")}),e.join(",")},nt.asn1.x509.X500Name.onelineToLDAP=function(t){return nt.asn1.x509.X500Name.compatToLDAP(t)},nt.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),r=!1,i=[],s=0;e.length>0;s++){var n=e.shift();if(!0===r){var o=(i.pop()+","+n).replace(/\\,/g,",");i.push(o),r=!1}else i.push(n);"\\"===n.substr(-1,1)&&(r=!0)}return i=i.map(function(t){return t.replace("/","\\/")}),i.reverse(),"/"+i.join("/")},nt.asn1.x509.X500Name.ldapToOneline=function(t){return nt.asn1.x509.X500Name.ldapToCompat(t)},nt.asn1.x509.RDN=function(t){nt.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=nt.asn1.x509.AttributeTypeAndValue;this.setByParam=function(t){void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.str&&this.addByMultiValuedString(t.str),void 0!==t.array&&(this.paramArray=t.array)},this.addByString=function(t){this.asn1Array.push(new nt.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=nt.asn1.x509.RDN.parseString(t),r=0;r<e.length;r++)this.addByString(e[r])},this.tohex=function(){if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r=this.paramArray[t];void 0!==r.rule&&"utf8"!=this.sRule&&(r.rule=this.sRule);var i=new e(r);this.asn1Array.push(i)}var s=new nt.asn1.DERSet({array:this.asn1Array});return this.TLV=s.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.RDN,nt.asn1.ASN1Object),nt.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),r=!1,i=[],s=0;e.length>0;s++){var n=e.shift();if(!0===r){var o=(i.pop()+"+"+n).replace(/\\\+/g,"+");i.push(o),r=!1}else i.push(n);"\\"===n.substr(-1,1)&&(r=!0)}var a=!1,c=[];for(s=0;i.length>0;s++){if(n=i.shift(),!0===a){var h=c.pop();n.match(/"$/)?(o=(h+"+"+n).replace(/^([^=]+)="(.*)"$/,"$1=$2"),c.push(o),a=!1):c.push(h+"+"+n)}else c.push(n);n.match(/^[^=]+="/)&&(a=!0)}return c},nt.asn1.x509.AttributeTypeAndValue=function(t){nt.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=nt,r=e.asn1,i=r.DERSequence,s=r.DERUTF8String,n=r.DERPrintableString,o=r.DERTeletexString,a=r.DERIA5String,c=r.DERVisibleString,h=r.DERBMPString,u=e.lang.String.isMail,l=e.lang.String.isPrintable;this.setByParam=function(t){if(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.ds&&(this.dsType=t.ds),void 0===t.value&&void 0!==t.str){var e=t.str.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=e[1],this.sValue=e[2]}else this.sType=t.type,this.sValue=t.value},this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.match(/^([^=]+)=(.+)$/);if(!r)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(r[1],r[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,r=this.sRule;return"prn"===r?"CN"==t&&u(e)?"ia5":l(e)?"prn":"utf8":"utf8"===r?"CN"==t&&u(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,r){void 0!==r&&(this.sRule=r),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new s({str:e});if("prn"==t)return new n({str:e});if("tel"==t)return new o({str:e});if("ia5"==t)return new a({str:e});if("vis"==t)return new c({str:e});if("bmp"==t)return new h({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.tohex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=nt.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),r=new i({array:[t,e]});return this.TLV=r.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.AttributeTypeAndValue,nt.asn1.ASN1Object),nt.asn1.x509.SubjectPublicKeyInfo=function(t){nt.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=nt,r=e.asn1,i=r.DERInteger,s=r.DERBitString,n=r.DERObjectIdentifier,o=r.DERSequence,a=r.ASN1Util.newObject,c=r.x509.AlgorithmIdentifier,h=e.crypto;h.ECDSA,h.DSA,this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.tohex=function(){var t=this.getASN1Object();return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(t){try{if(t instanceof tt){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).tohex();this.asn1AlgId=new c({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+e})}}catch(t){}try{if(t instanceof nt.crypto.ECDSA){var r=new n({name:t.curveName});this.asn1AlgId=new c({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new s({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof nt.crypto.DSA){r=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}),this.asn1AlgId=new c({name:"dsa",asn1params:r});var o=new i({bigint:t.y});this.asn1SubjPKey=new s({hex:"00"+o.tohex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},Vt(nt.asn1.x509.SubjectPublicKeyInfo,nt.asn1.ASN1Object),nt.asn1.x509.Time=function(t){nt.asn1.x509.Time.superclass.constructor.call(this);var e=nt.asn1,r=e.DERUTCTime,i=e.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(t){this.timeParams=t},this.setByParam=function(t){this.params=t},this.getType=function(t){return t.match(/^[0-9]{12}Z$/)?"utc":t.match(/^[0-9]{14}Z$/)?"gen":t.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":t.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var t=this.params,e=null;if("string"==typeof t&&(t={str:t}),null==t||!t.str||null!=t.type&&null!=t.type||(t.type=this.getType(t.str)),null!=t&&t.str?("utc"==t.type&&(e=new r(t.str)),"gen"==t.type&&(e=new i(t.str))):e="gen"==this.type?new i:new r,null==e)throw new Error("wrong setting for Time");return this.TLV=e.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},nt.asn1.x509.Time_bak=function(t){nt.asn1.x509.Time_bak.superclass.constructor.call(this);var e=nt.asn1,r=e.DERUTCTime,i=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.tohex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new r(this.timeParams):new i(this.timeParams):"utc"==this.type?new r:new i,this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},Vt(nt.asn1.x509.Time,nt.asn1.ASN1Object),nt.asn1.x509.AlgorithmIdentifier=function(t){nt.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=nt.asn1,r=e.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.tohex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t=null;for(var i in r)i===this.nameAlg&&(t=r[i]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var s=[this.asn1Alg];null!==this.asn1Params&&s.push(this.asn1Params);var n=new e.DERSequence({array:s});return this.hTLV=n.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){void 0!==this.nameAlg.name&&(this.nameAlg=this.nameAlg.name);var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},Vt(nt.asn1.x509.AlgorithmIdentifier,nt.asn1.ASN1Object),nt.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},nt.asn1.x509.GeneralName=function(t){nt.asn1.x509.GeneralName.superclass.constructor.call(this);var e=nt.asn1,r=e.x509,i=r.X500Name,s=r.OtherName,n=e.DERIA5String,o=(e.DERPrintableString,e.DEROctetString),a=e.DERTaggedObject,c=e.ASN1Object,h=Error;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e,r=this.params,u=!1;if(void 0!==r.other)t="a0",e=new s(r.other);else if(void 0!==r.rfc822)t="81",e=new n({str:r.rfc822});else if(void 0!==r.dns)t="82",e=new n({str:r.dns});else if(void 0!==r.dn)t="a4",u=!0,e="string"==typeof r.dn?new i({str:r.dn}):r.dn instanceof nt.asn1.x509.X500Name?r.dn:new i(r.dn);else if(void 0!==r.ldapdn)t="a4",u=!0,e=new i({ldapstr:r.ldapdn});else if(void 0!==r.certissuer||void 0!==r.certsubj){var l,p;t="a4",u=!0;var d=null;if(void 0!==r.certsubj?(l=!1,p=r.certsubj):(l=!0,p=r.certissuer),p.match(/^[0-9A-Fa-f]+$/),-1!=p.indexOf("-----BEGIN ")&&(d=xt(p)),null==d)throw new Error("certsubj/certissuer not cert");var g,f=new $t;f.hex=d,g=l?f.getIssuerHex():f.getSubjectHex(),(e=new c).hTLV=g}else if(void 0!==r.uri)t="86",e=new n({str:r.uri});else{if(void 0===r.ip)throw new h("improper params");var m;t="87";var y=r.ip;try{if(y.match(/^[0-9a-f]+$/)){var v=y.length;if(8!=v&&16!=v&&32!=v&&64!=v)throw"err";m=y}else m=Tt(y)}catch(t){throw new h("malformed IP address: "+r.ip+":"+t.message)}e=new o({hex:m})}return new a({tag:t,explicit:u,obj:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.GeneralName,nt.asn1.ASN1Object),nt.asn1.x509.GeneralNames=function(t){nt.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=nt.asn1;this.setByParamArray=function(t){for(var r=0;r<t.length;r++){var i=new e.x509.GeneralName(t[r]);this.asn1Array.push(i)}},this.tohex=function(){return new e.DERSequence({array:this.asn1Array}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.asn1Array=new Array,void 0!==t&&this.setByParamArray(t)},Vt(nt.asn1.x509.GeneralNames,nt.asn1.ASN1Object),nt.asn1.x509.OtherName=function(t){nt.asn1.x509.OtherName.superclass.constructor.call(this);var e=nt.asn1,r=e.DERObjectIdentifier,i=e.DERSequence,s=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null==t.oid||null==t.value)throw new Error("oid or value not specified");var e=new r({oid:t.oid}),n=s({tag:{tag:"a0",explicit:!0,obj:t.value}});return new i({array:[e,n]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.OtherName,nt.asn1.ASN1Object),nt.asn1.x509.OID=new function(){var t=nt.asn1.DERObjectIdentifier;this.name2oidList={"aes128-CBC":"2.16.840.1.101.3.4.1.2","aes256-CBC":"2.16.840.1.101.3.4.1.42",sha1:"1.3.14.3.2.26",sha256:"2.16.840.1.101.3.4.2.1",sha384:"2.16.840.1.101.3.4.2.2",sha512:"2.16.840.1.101.3.4.2.3",sha224:"2.16.840.1.101.3.4.2.4",md5:"1.2.840.113549.2.5",md2:"1.3.14.7.2.2.1",ripemd160:"1.3.36.3.2.1",hmacWithSHA1:"1.2.840.113549.2.7",hmacWithSHA224:"1.2.840.113549.2.8",hmacWithSHA256:"1.2.840.113549.2.9",hmacWithSHA384:"1.2.840.113549.2.10",hmacWithSHA512:"1.2.840.113549.2.11",MD2withRSA:"1.2.840.113549.1.1.2",MD4withRSA:"1.2.840.113549.1.1.3",MD5withRSA:"1.2.840.113549.1.1.4",SHA1withRSA:"1.2.840.113549.1.1.5","pkcs1-MGF":"1.2.840.113549.1.1.8",rsaPSS:"1.2.840.113549.1.1.10",SHA224withRSA:"1.2.840.113549.1.1.14",SHA256withRSA:"1.2.840.113549.1.1.11",SHA384withRSA:"1.2.840.113549.1.1.12",SHA512withRSA:"1.2.840.113549.1.1.13",SHA1withECDSA:"1.2.840.10045.4.1",SHA224withECDSA:"1.2.840.10045.4.3.1",SHA256withECDSA:"1.2.840.10045.4.3.2",SHA384withECDSA:"1.2.840.10045.4.3.3",SHA512withECDSA:"1.2.840.10045.4.3.4",dsa:"1.2.840.10040.4.1",SHA1withDSA:"1.2.840.10040.4.3",SHA224withDSA:"2.16.840.1.101.3.4.3.1",SHA256withDSA:"2.16.840.1.101.3.4.3.2",rsaEncryption:"1.2.840.113549.1.1.1",commonName:"2.5.4.3",countryName:"2.5.4.6",localityName:"2.5.4.7",stateOrProvinceName:"2.5.4.8",streetAddress:"2.5.4.9",organizationName:"2.5.4.10",organizationalUnitName:"2.5.4.11",domainComponent:"0.9.2342.19200300.100.1.25",userId:"0.9.2342.19200300.100.1.1",surname:"2.5.4.4",givenName:"2.5.4.42",title:"2.5.4.12",distinguishedName:"2.5.4.49",emailAddress:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3",subjectDirectoryAttributes:"2.5.29.9",subjectKeyIdentifier:"2.5.29.14",keyUsage:"2.5.29.15",subjectAltName:"2.5.29.17",issuerAltName:"2.5.29.18",basicConstraints:"2.5.29.19",cRLNumber:"2.5.29.20",cRLReason:"2.5.29.21",nameConstraints:"2.5.29.30",cRLDistributionPoints:"2.5.29.31",certificatePolicies:"2.5.29.32",anyPolicy:"2.5.29.32.0",policyMappings:"2.5.29.33",authorityKeyIdentifier:"2.5.29.35",policyConstraints:"2.5.29.36",extKeyUsage:"2.5.29.37",inhibitAnyPolicy:"2.5.29.54",authorityInfoAccess:"1.3.6.1.5.5.7.1.1",ocsp:"1.3.6.1.5.5.7.48.1",ocspBasic:"1.3.6.1.5.5.7.48.1.1",ocspNonce:"1.3.6.1.5.5.7.48.1.2",ocspNoCheck:"1.3.6.1.5.5.7.48.1.5",caIssuers:"1.3.6.1.5.5.7.48.2",anyExtendedKeyUsage:"2.5.29.37.0",serverAuth:"1.3.6.1.5.5.7.3.1",clientAuth:"1.3.6.1.5.5.7.3.2",codeSigning:"1.3.6.1.5.5.7.3.3",emailProtection:"1.3.6.1.5.5.7.3.4",timeStamping:"1.3.6.1.5.5.7.3.8",ocspSigning:"1.3.6.1.5.5.7.3.9",smtpUTF8Mailbox:"1.3.6.1.5.5.7.8.9",dateOfBirth:"1.3.6.1.5.5.7.9.1",placeOfBirth:"1.3.6.1.5.5.7.9.2",gender:"1.3.6.1.5.5.7.9.3",countryOfCitizenship:"1.3.6.1.5.5.7.9.4",countryOfResidence:"1.3.6.1.5.5.7.9.5",ecPublicKey:"1.2.840.10045.2.1","P-256":"1.2.840.10045.3.1.7",secp256r1:"1.2.840.10045.3.1.7",secp256k1:"1.3.132.0.10",secp384r1:"1.3.132.0.34",secp521r1:"1.3.132.0.35",pkcs5PBES2:"1.2.840.113549.1.5.13",pkcs5PBKDF2:"1.2.840.113549.1.5.12","des-EDE3-CBC":"1.2.840.113549.3.7",data:"1.2.840.113549.1.7.1","signed-data":"1.2.840.113549.1.7.2","enveloped-data":"1.2.840.113549.1.7.3","digested-data":"1.2.840.113549.1.7.5","encrypted-data":"1.2.840.113549.1.7.6","authenticated-data":"1.2.840.113549.1.9.16.1.2",tstinfo:"1.2.840.113549.1.9.16.1.4",signingCertificate:"1.2.840.113549.1.9.16.2.12",timeStampToken:"1.2.840.113549.1.9.16.2.14",signaturePolicyIdentifier:"1.2.840.113549.1.9.16.2.15",etsArchiveTimeStamp:"1.2.840.113549.1.9.16.2.27",signingCertificateV2:"1.2.840.113549.1.9.16.2.47",etsArchiveTimeStampV2:"1.2.840.113549.1.9.16.2.48",extensionRequest:"1.2.840.113549.1.9.14",contentType:"1.2.840.113549.1.9.3",messageDigest:"1.2.840.113549.1.9.4",signingTime:"1.2.840.113549.1.9.5",counterSignature:"1.2.840.113549.1.9.6",archiveTimeStampV3:"0.4.0.1733.2.4",pdfRevocationInfoArchival:"1.2.840.113583.1.1.8",adobeTimeStamp:"1.2.840.113583.1.1.9.1",smimeMailboxLegacy:"2.23.140.1.5.1.1",smimeMailboxMulti:"2.23.140.1.5.1.2",smimeMailboxStrict:"2.23.140.1.5.1.3",smimeOrganizationLegacy:"2.23.140.1.5.2.1",smimeOrganizationMulti:"2.23.140.1.5.2.2",smimeOrganizationStrict:"2.23.140.1.5.2.3",smimeSponsorLegacy:"2.23.140.1.5.3.1",smimeSponsorMulti:"2.23.140.1.5.3.2",smimeSponsorStrict:"2.23.140.1.5.3.3",smimeIndividualLegacy:"2.23.140.1.5.4.1",smimeIndividualMulti:"2.23.140.1.5.4.2",smimeIndividualStrict:"2.23.140.1.5.4.3"},this.atype2oidList={CN:"2.5.4.3",L:"2.5.4.7",ST:"2.5.4.8",O:"2.5.4.10",OU:"2.5.4.11",C:"2.5.4.6",STREET:"2.5.4.9",DC:"0.9.2342.19200300.100.1.25",UID:"0.9.2342.19200300.100.1.1",SN:"2.5.4.4",T:"2.5.4.12",GN:"2.5.4.42",DN:"2.5.4.49",E:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",serialNumber:"2.5.4.5",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3"},this.objCache={},this.name2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];if(void 0===this.name2oidList[e])throw"Name of ObjectIdentifier not defined: "+e;var r=this.name2oidList[e],i=new t({oid:r});return this.objCache[e]=i,i},this.atype2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];var r;if(e.match(/^\d+\.\d+\.[0-9.]+$/))r=e;else if(void 0!==this.atype2oidList[e])r=this.atype2oidList[e];else{if(void 0===this.name2oidList[e])throw new Error("AttributeType name undefined: "+e);r=this.name2oidList[e]}var i=new t({oid:r});return this.objCache[e]=i,i},this.registerOIDs=function(t){if(this.checkOIDs(t))for(var e in t)this.name2oidList[e]=t[e]},this.checkOIDs=function(t){try{var e=Object.keys(t);return 0!=e.length&&(e.map(function(t,e,r){if(!this[t].match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch(t){return!1}}},nt.asn1.x509.OID.oid2name=function(t){var e=nt.asn1.x509.OID.name2oidList;for(var r in e)if(e[r]==t)return r;return""},nt.asn1.x509.OID.oid2atype=function(t){var e=nt.asn1.x509.OID.atype2oidList;for(var r in e)if(e[r]==t)return r;return t},nt.asn1.x509.OID.name2oid=function(t){if(t.match(/^[0-9.]+$/))return t;var e=nt.asn1.x509.OID.name2oidList;return void 0===e[t]?"":e[t]},nt.asn1.x509.X509Util={},nt.asn1.x509.X509Util.newCertPEM=function(t){var e=nt.asn1.x509;return e.TBSCertificate,new(0,e.Certificate)(t).getPEM()},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.cms&&nt.asn1.cms||(nt.asn1.cms={}),nt.asn1.cms.Attribute=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERSet,n=r.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(t){this.params=t},this.getValueArray=function(){throw new e("not yet implemented abstract")},this.tohex=function(){var t=new n({oid:this.typeOid}),e=new s({array:this.getValueArray()});return new i({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()}},Vt(nt.asn1.cms.Attribute,nt.asn1.ASN1Object),nt.asn1.cms.ContentType=function(t){var e=nt.asn1;e.cms.ContentType.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.3",this.getValueArray=function(){return[new e.DERObjectIdentifier(this.params.type)]},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.ContentType,nt.asn1.cms.Attribute),nt.asn1.cms.MessageDigest=function(t){var e=nt.asn1,r=e.DEROctetString;e.cms.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){return[new r(this.params)]},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.MessageDigest,nt.asn1.cms.Attribute),nt.asn1.cms.SigningTime=function(t){var e=nt.asn1;e.cms.SigningTime.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.5",this.getValueArray=function(){return[new e.x509.Time(this.params)]},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SigningTime,nt.asn1.cms.Attribute),nt.asn1.cms.SigningCertificate=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERSequence,n=i.cms,o=n.ESSCertID;r.crypto,n.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new e("parameter 'array' not specified");for(var r=this.params.array,i=[],n=0;n<r.length;n++){var a=r[n];0!=t.hasis||"string"!=typeof a||-1==a.indexOf("-----BEGIN")&&!ct.isASN1HEX(a)||(a={cert:a}),0!=a.hasis&&0==t.hasis&&(a.hasis=!1),i.push(new o(a))}var c=new s({array:i});return[new s({array:[c]})]},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SigningCertificate,nt.asn1.cms.Attribute),nt.asn1.cms.ESSCertID=function(t){nt.asn1.cms.ESSCertID.superclass.constructor.call(this);var e=Error,r=nt,i=r.asn1,s=i.DEROctetString,n=i.DERSequence,o=i.cms.IssuerSerial;this.params=null,this.getCertHash=function(t,i){if(null!=t.hash)return t.hash;if("string"==typeof t&&-1==t.indexOf("-----BEGIN")&&!ct.isASN1HEX(t))return t;var s,n,o;if("string"==typeof t)s=t;else{if(null==t.cert)throw new e("hash nor cert unspecified");s=t.cert}if(n=-1!=s.indexOf("-----BEGIN")?xt(s):s,"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?n=xt(t):ct.isASN1HEX(t)&&(n=t)),null!=t.alg)o=t.alg;else{if(null==i)throw new e("hash alg unspecified");o=i}return r.crypto.Util.hashHex(n,o)},this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha1"),r=[];return r.push(new s({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&r.push(new o(t)),new n({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.ESSCertID,nt.asn1.ASN1Object),nt.asn1.cms.SigningCertificateV2=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERSequence,n=(i.x509,i.cms),o=n.ESSCertIDv2;r.crypto,n.SigningCertificateV2.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.47",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new e("parameter 'array' not specified");for(var r=this.params.array,i=[],n=0;n<r.length;n++){var a=r[n];null==t.alg&&0!=t.hasis||"string"!=typeof a||-1==a.indexOf("-----BEGIN")&&!ct.isASN1HEX(a)||(a={cert:a}),null==a.alg&&null!=t.alg&&(a.alg=t.alg),0!=a.hasis&&0==t.hasis&&(a.hasis=!1),i.push(new o(a))}var c=new s({array:i});return[new s({array:[c]})]},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SigningCertificateV2,nt.asn1.cms.Attribute),nt.asn1.cms.ESSCertIDv2=function(t){nt.asn1.cms.ESSCertIDv2.superclass.constructor.call(this),Error;var e=nt.asn1,r=e.DEROctetString,i=e.DERSequence,s=e.cms.IssuerSerial,n=e.x509.AlgorithmIdentifier;this.params=null,this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha256"),o=[];return null!=t.alg&&"sha256"!=t.alg&&o.push(new n({name:t.alg})),o.push(new r({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&o.push(new s(t)),new i({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.ESSCertIDv2,nt.asn1.cms.ESSCertID),nt.asn1.cms.IssuerSerial=function(t){var e=Error,r=nt.asn1,i=r.DERInteger,s=r.DERSequence,n=r.cms,o=r.x509.GeneralNames,a=$t;n.IssuerSerial.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.tohex=function(){var t,r,n=this.params;if("string"==typeof n&&-1!=n.indexOf("-----BEGIN")||null!=n.cert){var c;c=null!=n.cert?n.cert:n;var h=new a;h.readCertPEM(c),t=h.getIssuer(),r={hex:h.getSerialNumberHex()}}else{if(null==n.issuer||!n.serial)throw new e("cert or issuer and serial parameter not specified");t=n.issuer,r=n.serial}var u=new o([{dn:t}]),l=new i(r);return new s({array:[u,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.IssuerSerial,nt.asn1.ASN1Object),nt.asn1.cms.SignerIdentifier=function(t){var e=nt.asn1,r=(e.DERInteger,e.DERSequence,e.cms),i=r.IssuerAndSerialNumber,s=r.SubjectKeyIdentifier;e.x509.X500Name,Error,r.SignerIdentifier.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("isssn"==t.type)return new i(t).tohex();if("skid"==t.type)return new s(t).tohex();throw new Error("wrong property for isssn or skid")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SignerIdentifier,nt.asn1.ASN1Object),nt.asn1.cms.IssuerAndSerialNumber=function(t){var e=nt.asn1,r=e.DERInteger,i=e.DERSequence,s=e.cms,n=e.x509.X500Name,o=$t,a=Error;s.IssuerAndSerialNumber.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e,s=this.params;if("string"==typeof s&&-1!=s.indexOf("-----BEGIN")||null!=s.cert){var c;c=null!=s.cert?s.cert:s;var h=new o;h.readCertPEM(c),t=h.getIssuer(),e={hex:h.getSerialNumberHex()}}else{if(null==s.issuer||!s.serial)throw new a("cert or issuer and serial parameter not specified");t=s.issuer,e=s.serial}var u=new n(t),l=new r(e);return new i({array:[u,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.IssuerAndSerialNumber,nt.asn1.ASN1Object),nt.asn1.cms.SubjectKeyIdentifier=function(t){var e=nt.asn1,r=(e.DERInteger,e.DERSequence,e.ASN1Util.newObject),i=e.cms,s=(i.IssuerAndSerialName,i.SubjectKeyIdentifier,e.x509.X500Name,$t),n=Error;i.SubjectKeyIdentifier.superclass.constructor.call(this),this.tohex=function(){var t,e=this.params;if(null==e.cert&&null==e.skid)throw new n("property cert nor skid undefined");return null!=e.cert?t=new s(e.cert).getExtSubjectKeyIdentifier().kid.hex:null!=e.skid&&(t=e.skid),r({tag:{tage:"a0",obj:{octstr:{hex:t}}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SubjectKeyIdentifier,nt.asn1.ASN1Object),nt.asn1.cms.AttributeList=function(t){var e=Error,r=nt.asn1,i=r.DERSet,s=r.cms;s.AttributeList.superclass.constructor.call(this),this.params=null,this.hTLV=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null!=this.hTLV)return this.hTLV;var r=!0;null!=t.sortflag&&(r=t.sortflag);for(var n=t.array,o=[],a=0;a<n.length;a++){var c=n[a],h=c.attr;if("contentType"==h)o.push(new s.ContentType(c));else if("messageDigest"==h)o.push(new s.MessageDigest(c));else if("signingTime"==h)o.push(new s.SigningTime(c));else if("signingCertificate"==h)o.push(new s.SigningCertificate(c));else if("signingCertificateV2"==h)o.push(new s.SigningCertificateV2(c));else if("signaturePolicyIdentifier"==h)o.push(new nt.asn1.cades.SignaturePolicyIdentifier(c));else{if("signatureTimeStamp"!=h&&"timeStampToken"!=h)throw new e("unknown attr: "+h);o.push(new nt.asn1.cades.SignatureTimeStamp(c))}}var u=new i({array:o,sortflag:r});return this.hTLV=u.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.AttributeList,nt.asn1.ASN1Object),nt.asn1.cms.SignerInfo=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERInteger,n=i.DEROctetString,o=i.DERSequence,a=i.DERTaggedObject,c=i.cms,h=c.SignerIdentifier,u=c.AttributeList,l=(c.ContentType,c.EncapsulatedContentInfo,c.MessageDigest,c.SignedData,i.x509.AlgorithmIdentifier),p=r.crypto,d=Mt;c.SignerInfo.superclass.constructor.call(this),this.params=null,this.sign=function(){var t=this.params,e=t.sigalg,r=new u(t.sattrs).tohex(),i=d.getKey(t.signkey),s=new p.Signature({alg:e});s.init(i),s.updateHex(r);var n=s.sign();t.sighex=n},this.tohex=function(){var t=this.params,r=[];if(r.push(new s({int:t.version})),r.push(new h(t.id)),r.push(new l({name:t.hashalg})),null!=t.sattrs){var i=new u(t.sattrs);try{r.push(new a({tag:"a0",explicit:!1,obj:i}))}catch(t){throw new e("si sattr error: "+t)}}if(null!=t.sigalgfield?r.push(new l({name:t.sigalgfield})):r.push(new l({name:t.sigalg})),null==t.sighex&&null!=t.signkey&&this.sign(),r.push(new n({hex:t.sighex})),null!=t.uattrs){i=new u(t.uattrs);try{r.push(new a({tag:"a1",explicit:!1,obj:i}))}catch(t){throw new e("si uattr error: "+t)}}return new o({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SignerInfo,nt.asn1.ASN1Object),nt.asn1.cms.EncapsulatedContentInfo=function(t){var e=nt.asn1,r=e.DERTaggedObject,i=e.DERSequence,s=e.DERObjectIdentifier,n=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];if(e.push(new s(t.type)),null!=t.content&&(null!=t.content.hex||null!=t.content.str)&&1!=t.isDetached){var o=new n(t.content),a=new r({tag:"a0",explicit:!0,obj:o});e.push(a)}return new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.EncapsulatedContentInfo,nt.asn1.ASN1Object),nt.asn1.cms.ContentInfo=function(t){var e=nt.asn1,r=e.DERTaggedObject,i=e.DERSequence,s=e.DERObjectIdentifier;e.x509.OID.name2obj,nt.asn1.cms.ContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];e.push(new s(t.type));var n=new r({tag:"a0",explicit:!0,obj:t.obj});return e.push(n),new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.ContentInfo,nt.asn1.ASN1Object),nt.asn1.cms.SignedData=function(t){Error;var e=nt.asn1,r=(e.ASN1Object,e.DERInteger),i=e.DERSet,s=e.DERSequence,n=(e.DERTaggedObject,e.cms),o=n.EncapsulatedContentInfo,a=n.SignerInfo,c=n.ContentInfo,h=n.CertificateSet,u=n.RevocationInfoChoices,l=e.x509.AlgorithmIdentifier;nt.asn1.cms.SignedData.superclass.constructor.call(this),this.params=null,this.checkAndFixParam=function(){var t=this.params;this._setDigestAlgs(t),this._setContentTypeByEContent(t),this._setMessageDigestByEContent(t),this._setSignerInfoVersion(t),this._setSignedDataVersion(t)},this._setDigestAlgs=function(t){for(var e={},r=t.sinfos,i=0;i<r.length;i++)e[r[i].hashalg]=1;t.hashalgs=Object.keys(e).sort()},this._setContentTypeByEContent=function(t){for(var e=t.econtent.type,r=t.sinfos,i=0;i<r.length;i++){var s=r[i];this._getAttrParamByName(s,"contentType").type=e}},this._setMessageDigestByEContent=function(t){var e=t.econtent,r=(t.econtent.type,e.content.hex);null==r&&"data"==e.type&&null!=e.content.str&&(r=St(e.content.str));for(var i=t.sinfos,s=0;s<i.length;s++){var n=i[s],o=n.hashalg,a=this._getAttrParamByName(n,"messageDigest"),c=nt.crypto.Util.hashHex(r,o);a.hex=c}},this._getAttrParamByName=function(t,e){for(var r=t.sattrs.array,i=0;i<r.length;i++)if(r[i].attr==e)return r[i]},this._setSignerInfoVersion=function(t){for(var e=t.sinfos,r=0;r<e.length;r++){var i=e[r],s=1;"skid"==i.id.type&&(s=3),i.version=s}},this._setSignedDataVersion=function(t){var e=this._getSignedDataVersion(t);t.version=e},this._getSignedDataVersion=function(t){if(null!=t.revinfos)for(var e=t.revinfos,r=0;r<e.length;r++)if(null!=e[r].ocsp)return 5;var i=t.sinfos;for(r=0;r<i.length;r++)if(3==t.sinfos[r].version)return 3;return"data"!=t.econtent.type?3:1},this.tohex=function(){var t=this.params;null!=this.getEncodedHexPrepare&&this.getEncodedHexPrepare(),1!=t.fixed&&this.checkAndFixParam();var e=[];e.push(new r({int:t.version}));for(var n=[],c=0;c<t.hashalgs.length;c++){var p=t.hashalgs[c];n.push(new l({name:p}))}e.push(new i({array:n})),e.push(new o(t.econtent)),null!=t.certs&&e.push(new h(t.certs)),null!=t.revinfos&&e.push(new u(t.revinfos));var d=[];for(c=0;c<t.sinfos.length;c++){var g=t.sinfos[c];d.push(new a(g))}return e.push(new i({array:d})),new s({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.getContentInfo=function(){return new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SignedData,nt.asn1.ASN1Object),nt.asn1.cms.CertificateSet=function(t){nt.asn1.cms.CertificateSet.superclass.constructor.call(this);var e=Error,r=nt.asn1,i=r.DERTaggedObject,s=r.DERSet,n=r.ASN1Object;this.params=null,this.tohex=function(){var t,r=this.params,o=[];if(r instanceof Array)t=r;else{if(null==r.array)throw new e("cert array not specified");t=r.array}for(var a=0;a<t.length;a++){var c=xt(t[a]),h=new n;h.hTLV=c,o.push(h)}var u={array:o};0==r.sortflag&&(u.sortflag=!1);var l=new s(u);return new i({tag:"a0",explicit:!1,obj:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.CertificateSet,nt.asn1.ASN1Object),nt.asn1.cms.RevocationInfoChoices=function(t){nt.asn1.cms.RevocationInfoChoices.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!t instanceof Array)throw new Error("params is not array");for(var e=[],r=0;r<t.length;r++)e.push(new nt.asn1.cms.RevocationInfoChoice(t[r]));return nt.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:{set:e}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.RevocationInfoChoices,nt.asn1.ASN1Object),nt.asn1.cms.RevocationInfoChoice=function(t){nt.asn1.cms.RevocationInfoChoice.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(null!=t.crl&&"string"==typeof t.crl){var e=t.crl;return-1!=t.crl.indexOf("-----BEGIN")&&(e=xt(t.crl)),e}if(null!=t.ocsp)return nt.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:new nt.asn1.cms.OtherRevocationFormat(t)}}).tohex();throw new Error("property crl or ocsp undefined")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.RevocationInfoChoice,nt.asn1.ASN1Object),nt.asn1.cms.OtherRevocationFormat=function(t){nt.asn1.cms.OtherRevocationFormat.superclass.constructor.call(this);var e=Error,r=nt,i=r.asn1.ASN1Util.newObject,s=r.lang.String.isHex;this.params=null,this.tohex=function(){var t=this.params;if(null==t.ocsp)throw new e("property ocsp not specified");if(!s(t.ocsp)||!ct.isASN1HEX(t.ocsp))throw new e("ocsp value not ASN.1 hex string");return i({seq:[{oid:"1.3.6.1.5.5.7.16.2"},{asn1:{tlv:t.ocsp}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.OtherRevocationFormat,nt.asn1.ASN1Object),nt.asn1.cms.CMSUtil=new function(){},nt.asn1.cms.CMSUtil.newSignedData=function(t){return new nt.asn1.cms.SignedData(t)},nt.asn1.cms.CMSUtil.verifySignedData=function(t){var e=nt,r=e.asn1,i=r.cms,s=(i.SignerInfo,i.SignedData,i.SigningTime,i.SigningCertificate,i.SigningCertificateV2,r.cades.SignaturePolicyIdentifier,e.lang.String.isHex),n=ct,o=n.getVbyList,a=n.getTLVbyList,c=n.getIdxbyList,h=n.getChildIdx,u=n.getTLV,l=n.oidname,p=e.crypto.Util.hashHex;void 0===t.cms&&s(t.cms);var d=t.cms,g=function(t,e){var r=e.idx;e.signerid_issuer1=a(t,r,[1,0],"30"),e.signerid_serial1=o(t,r,[1,1],"02"),e.hashalg=l(o(t,r,[2,0],"06"));var i=c(t,r,[3],"a0");e.idxSignedAttrs=i,f(t,e,i);var s=h(t,r).length;if(s<6)throw"malformed SignerInfo";e.sigalg=l(o(t,r,[s-2,0],"06")),e.sigval=o(t,r,[s-1],"04")},f=function(t,e,r){var i=h(t,r);e.signedAttrIdxList=i;for(var s=0;s<i.length;s++){var n,a=i[s],c=o(t,a,[0],"06");"2a864886f70d010905"===c?(n=mt(o(t,a,[1,0])),e.saSigningTime=n):"2a864886f70d010904"===c&&(n=o(t,a,[1,0],"04"),e.saMessageDigest=n)}},m=function(t,e,r,i){r.verifyDetail={};var s=r.verifyDetail,n=e.parse.econtent,o=r.hashalg,a=r.saMessageDigest;s.validMessageDigest=!1,p(n,o)===a&&(s.validMessageDigest=!0),function(t,e,r){var i,s=e.parse.certsIdx;if(void 0===e.certs){i=[],e.certkeys=[];for(var n=h(t,s),o=0;o<n.length;o++){var a=u(t,n[o]),c=new $t;c.readCertHex(a),i[o]=c,e.certkeys[o]=c.getPublicKey()}e.certs=i}else i=e.certs;for(e.cccc=i.length,e.cccci=n.length,o=0;o<i.length;o++){var l=c.getIssuerHex(),p=c.getSerialNumberHex();r.signerid_issuer1===l&&r.signerid_serial1===p&&(r.certkey_idx=o)}}(t,e,r),s.validSignatureValue=!1;var c=r.sigalg,l="31"+u(t,r.idxSignedAttrs).substr(2);r.signedattrshex=l;var d=e.certs[r.certkey_idx].getPublicKey(),g=new nt.crypto.Signature({alg:c});g.init(d),g.updateHex(l);var f=g.verify(r.sigval);s.validSignatureValue_isValid=f,!0===f&&(s.validSignatureValue=!0),r.isValid=!1,s.validMessageDigest&&s.validSignatureValue&&(r.isValid=!0)},y={isValid:!1,parse:{}};return function(t,e){if("2a864886f70d010702"!==o(t,0,[0],"06"))return e;e.cmsType="signedData",e.econtent=o(t,0,[1,0,2,1,0]),function(t,e){for(var r,i=3;i<6;i++)if(void 0!==(r=c(t,0,[1,0,i]))){var s=t.substr(r,2);"a0"===s&&(e.certsIdx=r),"a1"===s&&(e.revinfosIdx=r),"31"===s&&(e.signerinfosIdx=r)}}(t,e),e.signerInfos=[],function(t,e){var r=e.signerinfosIdx;if(void 0!==r){var i=h(t,r);e.signerInfoIdxList=i;for(var s=0;s<i.length;s++){var n={idx:i[s]};g(t,n),e.signerInfos.push(n)}}}(t,e)}(d,y.parse),function(t,e){for(var r=e.parse.signerInfos,i=r.length,s=!0,n=0;n<i;n++){var o=r[n];m(t,e,o),o.isValid||(s=!1)}e.isValid=s}(d,y),y},nt.asn1.cms.CMSParser=function(){var t=Error,e=$t,r=new e,i=ct,s=i.getV,n=i.getTLV,o=(i.getIdxbyList,i.getTLVbyList),a=i.getTLVbyListEx,c=i.getVbyList,h=i.getVbyListEx,u=i.getChildIdx;this.getCMSSignedData=function(t){var e=o(t,0,[1,0]);return this.getSignedData(e)},this.getSignedData=function(t){var e=u(t,0),r={},i=s(t,e[0]),o=parseInt(i,16);r.version=o;var c=n(t,e[1]);r.hashalgs=this.getHashAlgArray(c);var h=n(t,e[2]);r.econtent=this.getEContent(h);var l=a(t,0,["[0]"]);null!=l&&(r.certs=this.getCertificateSet(l)),a(t,0,["[1]"]);var p=a(t,0,[3]);return r.sinfos=this.getSignerInfos(p),r},this.getHashAlgArray=function(t){for(var r=u(t,0),i=new e,s=[],o=0;o<r.length;o++){var a=n(t,r[o]),c=i.getAlgorithmIdentifierName(a);s.push(c)}return s},this.getEContent=function(t){var e={},r=c(t,0,[0]),i=c(t,0,[1,0]);return e.type=nt.asn1.x509.OID.oid2name(ct.hextooidstr(r)),e.content={hex:i},e},this.getSignerInfos=function(t){for(var e=[],r=u(t,0),i=0;i<r.length;i++){var s=n(t,r[i]),o=this.getSignerInfo(s);e.push(o)}return e},this.getSignerInfo=function(t){var e={},s=u(t,0),o=i.getInt(t,s[0],-1);-1!=o&&(e.version=o);var c=n(t,s[1]),l=this.getIssuerAndSerialNumber(c);e.id=l;var p=n(t,s[2]),d=r.getAlgorithmIdentifierName(p);e.hashalg=d;var g=a(t,0,["[0]"]);if(null!=g){var f=this.getAttributeList(g);e.sattrs=f}var m=a(t,0,[3]),y=r.getAlgorithmIdentifierName(m);e.sigalg=y;var v=h(t,0,[4]);e.sighex=v;var S=a(t,0,["[1]"]);if(null!=S){var E=this.getAttributeList(S);e.uattrs=E}return e},this.getSignerIdentifier=function(t){if("30"==t.substr(0,2))return this.getIssuerAndSerialNumber(t);throw new Error("SKID of signerIdentifier not supported")},this.getIssuerAndSerialNumber=function(t){var e={type:"isssn"},i=u(t,0),o=n(t,i[0]);e.issuer=r.getX500Name(o);var a=s(t,i[1]);return e.serial={hex:a},e},this.getAttributeList=function(t){for(var e=[],r=u(t,0),i=0;i<r.length;i++){var s=n(t,r[i]),o=this.getAttribute(s);e.push(o)}return{array:e}},this.getAttribute=function(t){var e={},r=u(t,0),s=i.getOID(t,r[0]),o=nt.asn1.x509.OID.oid2name(s);e.attr=o;var a=n(t,r[1]),c=u(a,0);if(1==c.length)e.valhex=n(a,c[0]);else{for(var h=[],l=0;l<c.length;l++)h.push(n(a,c[l]));e.valhex=h}return"contentType"==o?this.setContentType(e):"messageDigest"==o?this.setMessageDigest(e):"signingTime"==o?this.setSigningTime(e):"signingCertificate"==o?this.setSigningCertificate(e):"signingCertificateV2"==o?this.setSigningCertificateV2(e):"signaturePolicyIdentifier"==o&&this.setSignaturePolicyIdentifier(e),e},this.setContentType=function(t){var e=i.getOIDName(t.valhex,0,null);null!=e&&(t.type=e,delete t.valhex)},this.setSigningTime=function(t){var e=mt(s(t.valhex,0));t.str=e,delete t.valhex},this.setMessageDigest=function(t){var e=s(t.valhex,0);t.hex=e,delete t.valhex},this.setSigningCertificate=function(t){var e=u(t.valhex,0);if(e.length>0){for(var r=n(t.valhex,e[0]),i=u(r,0),s=[],o=0;o<i.length;o++){var a=n(r,i[o]),c=this.getESSCertID(a);s.push(c)}t.array=s}if(e.length>1){var h=n(t.valhex,e[1]);t.polhex=h}delete t.valhex},this.setSignaturePolicyIdentifier=function(t){var r=u(t.valhex,0);if(r.length>0){var o=i.getOID(t.valhex,r[0]);t.oid=o}if(r.length>1){var a=new e,c=u(t.valhex,r[1]),h=n(t.valhex,c[0]),l=a.getAlgorithmIdentifierName(h);t.alg=l;var p=s(t.valhex,c[1]);t.hash=p}delete t.valhex},this.setSigningCertificateV2=function(t){var e=u(t.valhex,0);if(e.length>0){for(var r=n(t.valhex,e[0]),i=u(r,0),s=[],o=0;o<i.length;o++){var a=n(r,i[o]),c=this.getESSCertIDv2(a);s.push(c)}t.array=s}if(e.length>1){var h=n(t.valhex,e[1]);t.polhex=h}delete t.valhex},this.getESSCertID=function(t){var e={},r=u(t,0);if(r.length>0){var i=s(t,r[0]);e.hash=i}if(r.length>1){var o=n(t,r[1]),a=this.getIssuerSerial(o);null!=a.serial&&(e.serial=a.serial),null!=a.issuer&&(e.issuer=a.issuer)}return e},this.getESSCertIDv2=function(e){var i={},o=u(e,0);if(o.length<1||3<o.length)throw new t("wrong number of elements");var a=0;if("30"==e.substr(o[0],2)){var c=n(e,o[0]);i.alg=r.getAlgorithmIdentifierName(c),a++}else i.alg="sha256";var h=s(e,o[a]);if(i.hash=h,o.length>a+1){var l=n(e,o[a+1]),p=this.getIssuerSerial(l);i.issuer=p.issuer,i.serial=p.serial}return i},this.getIssuerSerial=function(t){var e={},i=u(t,0),o=n(t,i[0]),a=r.getGeneralNames(o)[0].dn;e.issuer=a;var c=s(t,i[1]);return e.serial={hex:c},e},this.getCertificateSet=function(t){for(var e=u(t,0),r=[],i=0;i<e.length;i++){var s=n(t,e[i]);if("30"==s.substr(0,2)){var o=Et(s,"CERTIFICATE");r.push(o)}}return{array:r,sortflag:!1}}},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.tsp&&nt.asn1.tsp||(nt.asn1.tsp={}),nt.asn1.tsp.TimeStampToken=function(t){var e=nt.asn1.tsp;e.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var t=new e.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=t.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.TimeStampToken,nt.asn1.cms.SignedData),nt.asn1.tsp.TSTInfo=function(t){Error;var e=nt.asn1,r=e.DERSequence,i=e.DERInteger,s=e.DERBoolean,n=e.DERGeneralizedTime,o=e.DERObjectIdentifier,a=e.DERTaggedObject,c=e.tsp,h=c.MessageImprint,u=c.Accuracy,l=(e.x509.X500Name,e.x509.GeneralName);if(c.TSTInfo.superclass.constructor.call(this),this.dVersion=new i({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var t=[this.dVersion];if(null==this.dPolicy)throw new Error("policy shall be specified.");if(t.push(this.dPolicy),null==this.dMessageImprint)throw new Error("messageImprint shall be specified.");if(t.push(this.dMessageImprint),null==this.dSerial)throw new Error("serialNumber shall be specified.");if(t.push(this.dSerial),null==this.dGenTime)throw new Error("genTime shall be specified.");t.push(this.dGenTime),null!=this.dAccuracy&&t.push(this.dAccuracy),null!=this.dOrdering&&t.push(this.dOrdering),null!=this.dNonce&&t.push(this.dNonce),null!=this.dTsa&&t.push(this.dTsa);var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t){if("string"==typeof t.policy){if(!t.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new o({oid:t.policy})}void 0!==t.messageImprint&&(this.dMessageImprint=new h(t.messageImprint)),void 0!==t.serial&&(this.dSerial=new i(t.serial)),void 0!==t.genTime&&(this.dGenTime=new n(t.genTime)),void 0!==t.accuracy&&(this.dAccuracy=new u(t.accuracy)),void 0!==t.ordering&&1==t.ordering&&(this.dOrdering=new s),void 0!==t.nonce&&(this.dNonce=new i(t.nonce)),void 0!==t.tsa&&(this.dTsa=new a({tag:"a0",explicit:!0,obj:new l({dn:t.tsa})}))}},Vt(nt.asn1.tsp.TSTInfo,nt.asn1.ASN1Object),nt.asn1.tsp.Accuracy=function(t){var e=nt.asn1,r=e.ASN1Util.newObject;e.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return null!=t.seconds&&"number"==typeof t.seconds&&e.push({int:t.seconds}),null!=t.millis&&"number"==typeof t.millis&&e.push({tag:{tagi:"80",obj:{int:t.millis}}}),null!=t.micros&&"number"==typeof t.micros&&e.push({tag:{tagi:"81",obj:{int:t.micros}}}),r({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.Accuracy,nt.asn1.ASN1Object),nt.asn1.tsp.MessageImprint=function(t){var e=nt.asn1,r=e.DERSequence,i=e.DEROctetString,s=e.x509.AlgorithmIdentifier;e.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=new s({name:t.alg}),n=new i({hex:t.hash});return new r({array:[e,n]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.tsp.MessageImprint,nt.asn1.ASN1Object),nt.asn1.tsp.TimeStampReq=function(t){var e=nt.asn1,r=e.DERSequence,i=e.DERInteger,s=e.DERBoolean,n=(e.ASN1Object,e.DERObjectIdentifier),o=e.tsp,a=o.MessageImprint;o.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new i({int:1})),t.messageImprint instanceof nt.asn1.ASN1Object?e.push(t.messageImprint):e.push(new a(t.messageImprint)),null!=t.policy&&e.push(new n(t.policy)),null!=t.nonce&&e.push(new i(t.nonce)),1==t.certreq&&e.push(new s),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.TimeStampReq,nt.asn1.ASN1Object),nt.asn1.tsp.TimeStampResp=function(t){var e=nt.asn1,r=e.DERSequence,i=(e.ASN1Object,e.tsp),s=i.PKIStatusInfo;i.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,n=[];if(null!=t.econtent||null!=t.tst)if(null!=t.statusinfo?n.push(new s(t.statusinfo)):n.push(new s("granted")),null!=t.econtent)n.push(new i.TimeStampToken(t).getContentInfo());else{if(!(t.tst instanceof e.ASN1Object))throw new Error("improper member tst value");n.push(t.tst)}else{if(null==t.statusinfo)throw new Error("parameter for token nor statusinfo not specified");n.push(new s(t.statusinfo))}return new r({array:n}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.TimeStampResp,nt.asn1.ASN1Object),nt.asn1.tsp.PKIStatusInfo=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.tsp,n=s.PKIStatus,o=s.PKIFreeText,a=s.PKIFailureInfo;s.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,r=[];if("string"==typeof t)r.push(new n(t));else{if(null==t.status)throw new e("property 'status' unspecified");r.push(new n(t.status)),null!=t.statusstr&&r.push(new o(t.statusstr)),null!=t.failinfo&&r.push(new a(t.failinfo))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.PKIStatusInfo,nt.asn1.ASN1Object),nt.asn1.tsp.PKIStatus=function(t){var e=Error,r=nt.asn1,i=r.DERInteger;r.tsp.PKIStatus.superclass.constructor.call(this);var s={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null,this.tohex=function(){var t,r=this.params;if("string"==typeof r)try{t=s[r]}catch(t){throw new e("undefined name: "+r)}else{if("number"!=typeof r)throw new e("unsupported params");t=r}return new i({int:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.PKIStatus,nt.asn1.ASN1Object),nt.asn1.tsp.PKIFreeText=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERUTF8String;r.tsp.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!(t instanceof Array))throw new e("wrong params: not array");for(var r=[],n=0;n<t.length;n++)r.push(new s({str:t[n]}));return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.PKIFreeText,nt.asn1.ASN1Object),nt.asn1.tsp.PKIFailureInfo=function(t){var e=Error,r=nt.asn1,i=r.DERBitString,s=r.tsp.PKIFailureInfo,n={badAlg:0,badRequest:2,badDataFormat:5,timeNotAvailable:14,unacceptedPolicy:15,unacceptedExtension:16,addInfoNotAvailable:17,systemFailure:25};s.superclass.constructor.call(this),this.params=null,this.getBinValue=function(){var t=this.params,r=0;if("number"==typeof t&&0<=t&&t<=25){for(var i=(r|=1<<t).toString(2),s="",o=i.length-1;o>=0;o--)s+=i[o];return s}if("string"==typeof t&&null!=n[t])return Ut([t],n);if("object"==typeof t&&null!=t.length)return Ut(t,n);throw new e("wrong params")},this.tohex=function(){this.params;var t=this.getBinValue();return new i({bin:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.PKIFailureInfo,nt.asn1.ASN1Object),nt.asn1.tsp.AbstractTSAAdapter=function(t){this.getTSTHex=function(t,e){throw"not implemented yet"}},nt.asn1.tsp.SimpleTSAAdapter=function(t){var e=nt,r=e.asn1.tsp,i=e.crypto.Util.hashHex;r.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(t,e){var s=i(t,e);this.params.econtent.content.messageImprint={alg:e,hash:s},this.params.econtent.content.serial={int:this.serial++};var n=Math.floor(1e9*Math.random());return this.params.econtent.content.nonce={int:n},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},Vt(nt.asn1.tsp.SimpleTSAAdapter,nt.asn1.tsp.AbstractTSAAdapter),nt.asn1.tsp.FixedTSAAdapter=function(t){var e=nt,r=e.asn1.tsp,i=e.crypto.Util.hashHex;r.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(t,e){var s=i(t,e);return this.params.econtent.content.messageImprint={alg:e,hash:s},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},Vt(nt.asn1.tsp.FixedTSAAdapter,nt.asn1.tsp.AbstractTSAAdapter),nt.asn1.tsp.TSPUtil=new function(){},nt.asn1.tsp.TSPUtil.newTimeStampToken=function(t){return new nt.asn1.tsp.TimeStampToken(t)},nt.asn1.tsp.TSPUtil.parseTimeStampReq=function(t){return(new nt.asn1.tsp.TSPParser).getTimeStampReq(t)},nt.asn1.tsp.TSPUtil.parseMessageImprint=function(t){return(new nt.asn1.tsp.TSPParser).getMessageImprint(t)},nt.asn1.tsp.TSPParser=function(){Error;var t=new $t,e=ct,r=e.getV,i=e.getTLV,s=e.getIdxbyList,n=(e.getTLVbyListEx,e.getChildIdx),o=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],a={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(t){var e=n(t,0);if(1==e.length)return this.getPKIStatusInfo(i(t,e[0]));if(e.length>1){var r=this.getPKIStatusInfo(i(t,e[0])),s=i(t,e[1]),o=this.getToken(s);return o.statusinfo=r,o}},this.getToken=function(t){var e=(new nt.asn1.cms.CMSParser).getCMSSignedData(t);return this.setTSTInfo(e),e},this.setTSTInfo=function(t){var e=t.econtent;if("tstinfo"==e.type){var r=e.content.hex,i=this.getTSTInfo(r);e.content=i}},this.getTSTInfo=function(e){var s={},o=n(e,0),a=r(e,o[1]);s.policy=Lt(a);var c=i(e,o[2]);s.messageImprint=this.getMessageImprint(c);var h=r(e,o[3]);s.serial={hex:h};var u=r(e,o[4]);s.genTime={str:mt(u)};var l=0;if(o.length>5&&"30"==e.substr(o[5],2)){var p=i(e,o[5]);s.accuracy=this.getAccuracy(p),l++}if(o.length>5+l&&"01"==e.substr(o[5+l],2)&&("ff"==r(e,o[5+l])&&(s.ordering=!0),l++),o.length>5+l&&"02"==e.substr(o[5+l],2)){var d=r(e,o[5+l]);s.nonce={hex:d},l++}if(o.length>5+l&&"a0"==e.substr(o[5+l],2)){var g=i(e,o[5+l]);g="30"+g.substr(2),pGeneralNames=t.getGeneralNames(g);var f=pGeneralNames[0].dn;s.tsa=f,l++}if(o.length>5+l&&"a1"==e.substr(o[5+l],2)){var m=i(e,o[5+l]);m="30"+m.substr(2);var y=t.getExtParamArray(m);s.ext=y,l++}return s},this.getAccuracy=function(t){for(var e={},i=n(t,0),s=0;s<i.length;s++){var o=t.substr(i[s],2),a=r(t,i[s]),c=parseInt(a,16);"02"==o?e.seconds=c:"80"==o?e.millis=c:"81"==o&&(e.micros=c)}return e},this.getMessageImprint=function(t){if("30"!=t.substr(0,2))throw new Error("head of messageImprint hex shall be x30");var i={},o=(n(t,0),s(t,0,[0,0])),a=r(t,o),c=e.hextooidstr(a),h=nt.asn1.x509.OID.oid2name(c);if(""==h)throw new Error("hashAlg name undefined: "+c);var u=h,l=s(t,0,[1]);return i.alg=u,i.hash=r(t,l),i},this.getPKIStatusInfo=function(t){var e={},s=n(t,0),a=0;try{var c=r(t,s[0]),h=parseInt(c,16);e.status=o[h]}catch(t){}if(s.length>1&&"30"==t.substr(s[1],2)){var u=i(t,s[1]);e.statusstr=this.getPKIFreeText(u),a++}if(s.length>a&&"03"==t.substr(s[1+a],2)){var l=i(t,s[1+a]);e.failinfo=this.getPKIFailureInfo(l)}return e},this.getPKIFreeText=function(t){for(var r=[],i=n(t,0),s=0;s<i.length;s++)r.push(e.getString(t,i[s]));return r},this.getPKIFailureInfo=function(t){var r=e.getInt(t,0);return null!=a[r]?a[r]:r},this.getTimeStampReq=function(t){var s={certreq:!1},o=n(t,0);if(o.length<2)throw new Error("TimeStampReq must have at least 2 items");var a=i(t,o[1]);s.messageImprint=nt.asn1.tsp.TSPUtil.parseMessageImprint(a);for(var c=2;c<o.length;c++){var h=o[c],u=t.substr(h,2);if("06"==u){var l=r(t,h);s.policy=e.hextooidstr(l)}"02"==u&&(s.nonce=r(t,h)),"01"==u&&(s.certreq=!0)}return s}},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.cades&&nt.asn1.cades||(nt.asn1.cades={}),nt.asn1.cades.SignaturePolicyIdentifier=function(t){var e=nt.asn1.cades,r=e.SignaturePolicyId;e.SignaturePolicyIdentifier.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.15",this.params=null,this.getValueArray=function(){return[new r(this.params)]},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.SignaturePolicyIdentifier,nt.asn1.cms.Attribute),nt.asn1.cades.SignaturePolicyId=function(t){var e=nt.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=(e.x509.AlgorithmIdentifier,e.cades),n=s.SignaturePolicyId,o=s.OtherHashAlgAndValue;n.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new i(t.oid)),e.push(new o(t)),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.SignaturePolicyId,nt.asn1.ASN1Object),nt.asn1.cades.OtherHashAlgAndValue=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DEROctetString,n=r.x509.AlgorithmIdentifier;r.cades.OtherHashAlgAndValue.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(null==t.alg)throw new e("property 'alg' not specified");if(null==t.hash&&null==t.cert)throw new e("property 'hash' nor 'cert' not specified");var r=null;if(null!=t.hash)r=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new e("cert not string");var o=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(o=xt(t.cert)),r=nt.crypto.Util.hashHex(o,t.alg)}var a=[];return a.push(new n({name:t.alg})),a.push(new s({hex:r})),new i({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.OtherHashAlgAndValue,nt.asn1.ASN1Object),nt.asn1.cades.OtherHashValue=function(t){nt.asn1.cades.OtherHashValue.superclass.constructor.call(this);var e=Error,r=nt,i=(r.lang.String.isHex,r.asn1.DEROctetString);r.crypto.Util.hashHex,this.params=null,this.tohex=function(){var t=this.params;if(null==t.hash&&null==t.cert)throw new e("hash or cert not specified");var r=null;if(null!=t.hash)r=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new e("cert not string");var s=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(s=xt(t.cert)),r=nt.crypto.Util.hashHex(s,"sha1")}return new i({hex:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.OtherHashValue,nt.asn1.ASN1Object),nt.asn1.cades.SignatureTimeStamp=function(t){var e=Error,r=nt,i=r.lang.String.isHex,s=r.asn1,n=s.ASN1Object;s.x509,s.cades.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var t=this.params;if(null!=t.tst){if(i(t.tst))return(r=new n).hTLV=t.tst,[r];if(t.tst instanceof n)return[t.tst];throw new e("params.tst has wrong value")}if(null!=t.res){var r,s=t.res;if(s instanceof n&&(s=s.tohex()),"string"!=typeof s||!i(s))throw new e("params.res has wrong value");return ct.getTLVbyList(s,0,[1]),(r=new n).hTLV=t.tst,[r]}},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.SignatureTimeStamp,nt.asn1.cms.Attribute),nt.asn1.cades.CompleteCertificateRefs=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERSequence,n=i.cades,o=n.OtherCertID,a=r.lang.String.isHex;n.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var t=this.params,r=[],i=0;i<t.array.length;i++){var n=t.array[i];if("string"==typeof n)if(-1!=n.indexOf("-----BEGIN"))n={cert:n};else{if(!a(n))throw new e("unsupported value: "+n);n={hash:n}}null!=t.alg&&null==n.alg&&(n.alg=t.alg),null!=t.hasis&&null==n.hasis&&(n.hasis=t.hasis);var c=new o(n);r.push(c)}return[new s({array:r})]},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.CompleteCertificateRefs,nt.asn1.cms.Attribute),nt.asn1.cades.OtherCertID=function(t){var e=nt.asn1,r=e.DERSequence,i=e.cms.IssuerSerial,s=e.cades,n=s.OtherHashValue,o=s.OtherHashAlgAndValue;s.OtherCertID.superclass.constructor.call(this),this.params=t,this.tohex=function(){var t=this.params;"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:_isHex(t)&&(t={hash:t}));var e,s=[];if(e=null!=t.alg?new o(t):new n(t),s.push(e),null!=t.cert&&1==t.hasis||null!=t.issuer&&null!=t.serial){var a=new i(t);s.push(a)}return new r({array:s}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.OtherCertID,nt.asn1.ASN1Object),nt.asn1.cades.OtherHash=function(t){Error;var e=nt,r=e.asn1,i=(r.cms,r.cades),s=i.OtherHashAlgAndValue,n=i.OtherHashValue,o=(e.crypto.Util.hashHex,e.lang.String.isHex);i.OtherHash.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;return"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:o(t)&&(t={hash:t})),(null!=t.alg?new s(t):new n(t)).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.OtherHash,nt.asn1.ASN1Object),nt.asn1.cades.CAdESUtil=new function(){},nt.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned=function(t){return(new nt.asn1.cms.CMSParser).getCMSSignedData(t)},nt.asn1.cades.CAdESUtil.parseSignerInfoForAddingUnsigned=function(t,e,r){var i=ct,s=i.getChildIdx,n=i.getTLV,o=i.getV,a=nt.asn1,c=a.ASN1Object,h=a.cms,u=h.AttributeList,l=h.SignerInfo,p={},d=s(t,e);if(6!=d.length)throw"not supported items for SignerInfo (!=6)";var g=d.shift();p.version=n(t,g);var f=d.shift();p.si=n(t,f);var m=d.shift();p.digalg=n(t,m);var y=d.shift();p.sattrs=n(t,y);var v=d.shift();p.sigalg=n(t,v);var S=d.shift();p.sig=n(t,S),p.sigval=o(t,S);var E=null;return p.obj=new l,(E=new c).hTLV=p.version,p.obj.dCMSVersion=E,(E=new c).hTLV=p.si,p.obj.dSignerIdentifier=E,(E=new c).hTLV=p.digalg,p.obj.dDigestAlgorithm=E,(E=new c).hTLV=p.sattrs,p.obj.dSignedAttrs=E,(E=new c).hTLV=p.sigalg,p.obj.dSigAlg=E,(E=new c).hTLV=p.sig,p.obj.dSig=E,p.obj.dUnsignedAttrs=new u,p},void 0!==nt.asn1.csr&&nt.asn1.csr||(nt.asn1.csr={}),nt.asn1.csr.CertificationRequest=function(t){var e=nt.asn1,r=e.DERBitString,i=e.DERSequence,s=e.csr,n=(e.x509,s.CertificationRequestInfo);s.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.sign=function(){var t=new n(this.params).tohex(),e=new nt.crypto.Signature({alg:this.params.sigalg});e.init(this.params.sbjprvkey),e.updateHex(t);var r=e.sign();this.params.sighex=r},this.getPEM=function(){return Et(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var t=this.params,e=new nt.asn1.csr.CertificationRequestInfo(this.params),s=new nt.asn1.x509.AlgorithmIdentifier({name:t.sigalg});if(null==t.sighex&&null!=t.sbjprvkey&&this.sign(),null==t.sighex)throw new Error("sighex or sbjprvkey parameter not defined");var n=new r({hex:"00"+t.sighex});return new i({array:[e,s,n]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.csr.CertificationRequest,nt.asn1.ASN1Object),nt.asn1.csr.CertificationRequestInfo=function(t){var e=nt.asn1,r=(e.DERBitString,e.DERSequence),i=e.DERInteger,s=e.DERUTF8String,n=e.DERTaggedObject,o=e.ASN1Util.newObject,a=e.csr,c=e.x509,h=c.X500Name,u=c.Extensions,l=c.SubjectPublicKeyInfo;a.AttributeList,a.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(t){null!=t&&(this.params=t)},this.tohex=function(){var t=this.params,e=[];if(e.push(new i({int:0})),e.push(new h(t.subject)),e.push(new l(Mt.getKey(t.sbjpubkey))),null!=t.attrs){var a=function(t){for(var e=Error,r=nt.asn1.x509.Extensions,i=[],s=0;s<t.length;s++){var n=t[s],o=n.attr;if("extensionRequest"==o){var a={seq:[{oid:"1.2.840.113549.1.9.14"},{set:[new r(n.ext)]}]};i.push(a)}else if("unstructuredName"==o)a={seq:[{oid:"1.2.840.113549.1.9.2"},{set:n.names}]},i.push(a);else{if("challengePassword"!=o)throw new e("unknown CSR attribute");a={seq:[{oid:"1.2.840.113549.1.9.7"},{set:[{utf8str:n.password}]}]},i.push(a)}}return{set:i}}(t.attrs),c=o({tag:{tage:"a0",obj:a}});e.push(c)}else if(null!=t.extreq){var p=new u(t.extreq);c=o({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[p]}]}}}),e.push(c)}else e.push(new n({tag:"a0",explicit:!1,obj:new s({str:""})}));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.csr.CertificationRequestInfo,nt.asn1.ASN1Object),nt.asn1.csr.AttributeList=function(t){},Vt(nt.asn1.csr.AttributeList,nt.asn1.ASN1Object),nt.asn1.csr.CSRUtil=new function(){},nt.asn1.csr.CSRUtil.newCSRPEM=function(t){return new nt.asn1.csr.CertificationRequest(t).getPEM()},nt.asn1.csr.CSRUtil.getParam=function(t,e){var r=ct,i=r.getV,s=r.getIdxbyList,n=r.getTLVbyList,o=r.getTLVbyListEx,a=r.getVbyListEx,c={};if(-1==t.indexOf("-----BEGIN CERTIFICATE REQUEST"))throw new Error("argument is not PEM file");var h=xt(t,"CERTIFICATE REQUEST");e&&(c.tbs=n(h,0,[0]));try{var u=o(h,0,[0,1]);if("3000"==u)c.subject={};else{var l=new $t;c.subject=l.getX500Name(u)}}catch(t){}var p=o(h,0,[0,2]),d=Mt.getKey(p,null,"pkcs8pub");c.sbjpubkey=Mt.getPEM(d,"PKCS8PUB");var g=function(t){var e=s(t,0,[0,3,0,0],"06");return"2a864886f70d01090e"!=i(t,e)?null:n(t,0,[0,3,0,1,0],"30")}(h);l=new $t,null!=g&&(c.extreq=l.getExtParamArray(g));try{var f=o(h,0,[1],"30");l=new $t,c.sigalg=l.getAlgorithmIdentifierName(f)}catch(t){}try{var m=a(h,0,[2]);c.sighex=m}catch(t){}return c},nt.asn1.csr.CSRUtil.verifySignature=function(t){try{var e=null;if("string"==typeof t&&-1!=t.indexOf("-----BEGIN CERTIFICATE REQUEST")?e=nt.asn1.csr.CSRUtil.getParam(t,!0):"object"==typeof t&&null!=t.sbjpubkey&&null!=t.sigalg&&null!=t.sighex&&null!=t.tbs&&(e=t),null==e)return!1;var r=new nt.crypto.Signature({alg:e.sigalg});return r.init(e.sbjpubkey),r.updateHex(e.tbs),r.verify(e.sighex)}catch(t){return alert(t),!1}},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.ocsp&&nt.asn1.ocsp||(nt.asn1.ocsp={}),nt.asn1.ocsp.DEFAULT_HASH="sha1",nt.asn1.ocsp.OCSPResponse=function(t){nt.asn1.ocsp.OCSPResponse.superclass.constructor.call(this),nt.asn1.DEREnumerated;var e=nt.asn1.ASN1Util.newObject,r=nt.asn1.ocsp.ResponseBytes,i=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var t=this.params.resstatus;return"number"==typeof t?t:"string"!=typeof t?-1:i.indexOf(t)},this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,i=this._getStatusCode();if(-1==i)throw new Error("responseStatus not supported: "+t.resstatus);if(0!=i)return e({seq:[{enum:{int:i}}]}).tohex();var s=new r(t);return e({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:s}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.OCSPResponse,nt.asn1.ASN1Object),nt.asn1.ocsp.ResponseBytes=function(t){nt.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=e.DEROctetString,n=e.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if("ocspBasic"!=t.restype)throw new Error("not supported responseType: "+t.restype);var e=new n(t),o=[];return o.push(new i({name:"ocspBasic"})),o.push(new s({hex:e.tohex()})),new r({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.ResponseBytes,nt.asn1.ASN1Object),nt.asn1.ocsp.BasicOCSPResponse=function(t){nt.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var e=Error,r=nt.asn1,i=r.ASN1Object,s=r.DERSequence,n=(r.DERGeneralizedTime,r.DERTaggedObject),o=r.DERBitString,a=(r.x509.Extensions,r.x509.AlgorithmIdentifier),c=r.ocsp;c.ResponderID,_SingleResponseList=c.SingleResponseList,_ResponseData=c.ResponseData,this.params=null,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.tbsresp.tohex(),r=new nt.crypto.Signature({alg:t.sigalg});r.init(t.reskey),r.updateHex(e),t.sighex=r.sign()},this.tohex=function(){var t=this.params;null==t.tbsresp&&(t.tbsresp=new _ResponseData(t)),null==t.sighex&&null!=t.reskey&&this.sign();var r=[];if(r.push(t.tbsresp),r.push(new a({name:t.sigalg})),r.push(new o({hex:"00"+t.sighex})),null!=t.certs&&null!=t.certs.length){for(var c=[],h=0;h<t.certs.length;h++){var u=t.certs[h],l=null;if(ct.isASN1HEX(u))l=u;else{if(!u.match(/-----BEGIN/))throw new e("certs["+h+"] not hex or PEM");l=xt(u)}c.push(new i({tlv:l}))}var p=new s({array:c});r.push(new n({tag:"a0",explicit:!0,obj:p}))}return new s({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.BasicOCSPResponse,nt.asn1.ASN1Object),nt.asn1.ocsp.ResponseData=function(t){nt.asn1.ocsp.ResponseData.superclass.constructor.call(this);var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERGeneralizedTime,n=r.DERTaggedObject,o=r.x509.Extensions,a=r.ocsp,c=a.ResponderID;_SingleResponseList=a.SingleResponseList,this.params=null,this.tohex=function(){var t=this.params;null!=t.respid&&new e("respid not specified"),null!=t.prodat&&new e("prodat not specified"),null!=t.array&&new e("array not specified");var r=[];if(r.push(new c(t.respid)),r.push(new s(t.prodat)),r.push(new _SingleResponseList(t.array)),null!=t.ext){var a=new o(t.ext);r.push(new n({tag:"a1",explicit:!0,obj:a}))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.ResponseData,nt.asn1.ASN1Object),nt.asn1.ocsp.ResponderID=function(t){nt.asn1.ocsp.ResponderID.superclass.constructor.call(this);var e=nt,r=e.asn1,i=r.ASN1Util.newObject,s=r.x509.X500Name,n=e.lang.String.isHex,o=Error;this.params=null,this.tohex=function(){var t=this.params;if(null!=t.key){var e,r=null;if("string"==typeof t.key?(n(t.key)&&(r=t.key),t.key.match(/-----BEGIN CERTIFICATE/)&&null!=(e=new $t(t.key).getExtSubjectKeyIdentifier())&&(r=e.kid.hex)):t.key instanceof $t&&null!=(e=t.key.getExtSubjectKeyIdentifier())&&(r=e.kid.hex),null==r)throw new o("wrong key member value");return i({tag:{tag:"a2",explicit:!0,obj:{octstr:{hex:r}}}}).tohex()}if(null!=t.name){var a=null;if("string"==typeof t.name&&t.name.match(/-----BEGIN CERTIFICATE/)?a=new $t(t.name).getSubject():t.name instanceof $t?a=t.name.getSubject():"object"!=typeof t.name||null==t.name.array&&null==t.name.str||(a=t.name),null==a)throw new o("wrong name member value");return i({tag:{tag:"a1",explicit:!0,obj:new s(a)}}).tohex()}throw new o("key or name not specified")},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.ResponderID,nt.asn1.ASN1Object),nt.asn1.ocsp.SingleResponseList=function(t){nt.asn1.ocsp.SingleResponseList.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.ocsp.SingleResponse;this.params=null,this.tohex=function(){var t=this.params;if("object"!=typeof t||null==t.length)throw new Error("params not specified properly");for(var e=[],s=0;s<t.length;s++)e.push(new i(t[s]));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.SingleResponseList,nt.asn1.ASN1Object),nt.asn1.ocsp.SingleResponse=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERGeneralizedTime,n=r.DERTaggedObject,o=r.ocsp,a=o.CertID,c=o.CertStatus,h=r.x509.Extensions;o.SingleResponse.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,r=[];if(null==t.certid)throw new e("certid unspecified");if(null==t.status)throw new e("status unspecified");if(null==t.thisupdate)throw new e("thisupdate unspecified");if(r.push(new a(t.certid)),r.push(new c(t.status)),r.push(new s(t.thisupdate)),null!=t.nextupdate){var o=new s(t.nextupdate);r.push(new n({tag:"a0",explicit:!0,obj:o}))}if(null!=t.ext){var u=new h(t.ext);r.push(new n({tag:"a1",explicit:!0,obj:u}))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.SingleResponse,nt.asn1.ASN1Object),nt.asn1.ocsp.CertID=function(t){var e=nt,r=e.asn1,i=r.DEROctetString,s=r.DERInteger,n=r.DERSequence,o=r.x509.AlgorithmIdentifier,a=r.ocsp,c=(a.DEFAULT_HASH,e.crypto.Util.hashHex),h=$t,u=ct.getVbyList;a.CertID.superclass.constructor.call(this),this.DEFAULT_HASH="sha1",this.params=null,this.setByValue=function(t,e,r,i){null==i&&(i=this.DEFAULT_HASH),this.params={alg:i,issname:t,isskey:e,sbjsn:r}},this.setByCert=function(t,e,r){null==r&&(r=this.DEFAULT_HASH),this.params={alg:r,issuerCert:t,subjectCert:e}},this.getParamByCerts=function(t,e,r){null==r&&(r=this.DEFAULT_HASH);var i=new h(t),s=new h(e),n=c(i.getSubjectHex(),r),o=i.getPublicKeyHex();return{alg:r,issname:n,isskey:c(u(o,0,[1],"03",!0),r),sbjsn:s.getSerialNumberHex()}},this.tohex=function(){if("object"!=typeof this.params)throw new Error("params not set");var t,e,r,a,c=this.params;if(a=null==c.alg?this.DEFAULT_HASH:c.alg,null!=c.issuerCert&&null!=c.subjectCert){var h=this.getParamByCerts(c.issuerCert,c.subjectCert,a);t=h.issname,e=h.isskey,r=h.sbjsn}else{if(null==c.issname||null==c.isskey||null==c.sbjsn)throw new Error("required param members not defined");t=c.issname,e=c.isskey,r=c.sbjsn}var u=new o({name:a}),l=new i({hex:t}),p=new i({hex:e}),d=new s({hex:r}),g=new n({array:[u,l,p,d]});return this.hTLV=g.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.CertID,nt.asn1.ASN1Object),nt.asn1.ocsp.CertStatus=function(t){nt.asn1.ocsp.CertStatus.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("good"==t.status)return"8000";if("unknown"==t.status)return"8200";if("revoked"==t.status){var e=[{gentime:{str:t.time}}];null!=t.reason&&e.push({tag:{tag:"a0",explicit:!0,obj:{enum:{int:t.reason}}}});var r={tag:"a1",explicit:!1,obj:{seq:e}};return nt.asn1.ASN1Util.newObject({tag:r}).tohex()}throw new Error("bad status")},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.CertStatus,nt.asn1.ASN1Object),nt.asn1.ocsp.Request=function(t){var e=nt.asn1,r=e.DERSequence,i=e.ocsp;if(i.Request.superclass.constructor.call(this),this.dReqCert=null,this.dExt=null,this.tohex=function(){var t=[];if(null===this.dReqCert)throw"reqCert not set";t.push(this.dReqCert);var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t){var s=new i.CertID(t);this.dReqCert=s}},Vt(nt.asn1.ocsp.Request,nt.asn1.ASN1Object),nt.asn1.ocsp.TBSRequest=function(t){var e=nt.asn1,r=e.DERSequence,i=e.ocsp;i.TBSRequest.superclass.constructor.call(this),this.version=0,this.dRequestorName=null,this.dRequestList=[],this.dRequestExt=null,this.setRequestListByParam=function(t){for(var e=[],r=0;r<t.length;r++){var s=new i.Request(t[0]);e.push(s)}this.dRequestList=e},this.tohex=function(){var t=[];if(0!==this.version)throw"not supported version: "+this.version;if(null!==this.dRequestorName)throw"requestorName not supported";var e=new r({array:this.dRequestList});if(t.push(e),null!==this.dRequestExt)throw"requestExtensions not supported";var i=new r({array:t});return this.hTLV=i.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList&&this.setRequestListByParam(t.reqList)},Vt(nt.asn1.ocsp.TBSRequest,nt.asn1.ASN1Object),nt.asn1.ocsp.OCSPRequest=function(t){var e=nt.asn1,r=e.DERSequence,i=e.ocsp;if(i.OCSPRequest.superclass.constructor.call(this),this.dTbsRequest=null,this.dOptionalSignature=null,this.tohex=function(){var t=[];if(null===this.dTbsRequest)throw"tbsRequest not set";if(t.push(this.dTbsRequest),null!==this.dOptionalSignature)throw"optionalSignature not supported";var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList){var s=new i.TBSRequest(t);this.dTbsRequest=s}},Vt(nt.asn1.ocsp.OCSPRequest,nt.asn1.ASN1Object),nt.asn1.ocsp.OCSPUtil={},nt.asn1.ocsp.OCSPUtil.getRequestHex=function(t,e,r){var i=nt.asn1.ocsp;void 0===r&&(r=i.DEFAULT_HASH);var s={alg:r,issuerCert:t,subjectCert:e};return new i.OCSPRequest({reqList:[s]}).tohex()},nt.asn1.ocsp.OCSPUtil.getOCSPResponseInfo=function(t){var e=ct,r=e.getVbyList,i=e.getVbyListEx,s=e.getIdxbyList,n=(e.getIdxbyListEx,e.getV),o={};try{var a=i(t,0,[0],"0a");o.responseStatus=parseInt(a,16)}catch(t){}if(0!==o.responseStatus)return o;try{var c=s(t,0,[1,0,1,0,0,2,0,1]);"80"===t.substr(c,2)?o.certStatus="good":"a1"===t.substr(c,2)?(o.certStatus="revoked",o.revocationTime=mt(r(t,c,[0]))):"82"===t.substr(c,2)&&(o.certStatus="unknown")}catch(t){}try{var h=s(t,0,[1,0,1,0,0,2,0,2]);o.thisUpdate=mt(n(t,h))}catch(t){}try{var u=s(t,0,[1,0,1,0,0,2,0,3]);"a0"===t.substr(u,2)&&(o.nextUpdate=mt(r(t,u,[0])))}catch(t){}return o},nt.asn1.ocsp.OCSPParser=function(){var t=Error,e=$t,r=new e,i=ct,s=i.getV,n=i.getTLV,o=i.getIdxbyList,a=i.getVbyList,c=i.getTLVbyList,h=i.getVbyListEx,u=i.getTLVbyListEx,l=i.getChildIdx;this.getOCSPRequest=function(e){var r=l(e,0);if(1!=r.length&&2!=r.length)throw new t("wrong number elements: "+r.length);return this.getTBSRequest(n(e,r[0]))},this.getTBSRequest=function(t){var e={},i=u(t,0,[0],"30");e.array=this.getRequestList(i);var s=u(t,0,["[2]",0],"30");return null!=s&&(e.ext=r.getExtParamArray(s)),e},this.getRequestList=function(t){for(var e=[],r=l(t,0),i=0;i<r.length;i++)t=n(t,r[i]),e.push(this.getRequest(t));return e},this.getRequest=function(e){var i=l(e,0);if(1!=i.length&&2!=i.length)throw new t("wrong number elements: "+i.length);var s=this.getCertID(n(e,i[0]));if(2==i.length){var a=o(e,0,[1,0]);s.ext=r.getExtParamArray(n(e,a))}return s},this.getCertID=function(r){var i=l(r,0);if(4!=i.length)throw new t("wrong number elements: "+i.length);var o=new e,a={};return a.alg=o.getAlgorithmIdentifierName(n(r,i[0])),a.issname=s(r,i[1]),a.isskey=s(r,i[2]),a.sbjsn=s(r,i[3]),a},this.getOCSPResponse=function(t){var e,r=l(t,0),i=s(t,r[0]),n=parseInt(i);if(1==r.length)return{resstatus:n};var o=c(t,0,[1,0]);return(e=this.getResponseBytes(o)).resstatus=n,e},this.getResponseBytes=function(t){var e,r=l(t,0),i=c(t,0,[1,0]);e=this.getBasicOCSPResponse(i);var n=s(t,r[0]);return e.restype=nt.asn1.x509.OID.oid2name(Lt(n)),e},this.getBasicOCSPResponse=function(t){var e,r=l(t,0);e=this.getResponseData(n(t,r[0]));var i=new $t;e.alg=i.getAlgorithmIdentifierName(n(t,r[1]));var o=s(t,r[2]);e.sighex=o.substr(2);var a=h(t,0,["[0]"]);if(null!=a){for(var c=l(a,0),u=[],p=0;p<c.length;p++){var d=n(a,c[p]);u.push(d)}e.certs=u}return e},this.getResponseData=function(t){var e=l(t,0),r=e.length,i={},o=0;"a0"==t.substr(e[0],2)&&o++,i.respid=this.getResponderID(n(t,e[o++]));var a=s(t,e[o++]);if(i.prodat=mt(a),i.array=this.getSingleResponseList(n(t,e[o++])),"a1"==t.substr(e[r-1],2)){var h=c(t,e[r-1],[0]),u=new $t;i.ext=u.getExtParamArray(h)}return i},this.getResponderID=function(t){var e={};if("a2"==t.substr(0,2)){var r=a(t,0,[0]);e.key=r}if("a1"==t.substr(0,2)){var i=c(t,0,[0]),s=new $t;e.name=s.getX500Name(i)}return e},this.getSingleResponseList=function(t){for(var e=l(t,0),r=[],i=0;i<e.length;i++){var s=this.getSingleResponse(n(t,e[i]));r.push(s)}return r},this.getSingleResponse=function(t){var e=l(t,0),r={},i=this.getCertID(n(t,e[0]));r.certid=i;var o=this.getCertStatus(n(t,e[1]));if(r.status=o,"18"==t.substr(e[2],2)){var h=s(t,e[2]);r.thisupdate=mt(h)}for(var u=3;u<e.length;u++){if("a0"==t.substr(e[u],2)){var p=a(t,e[u],[0],"18");r.nextupdate=mt(p)}if("a1"==t.substr(e[u],2)){var d=new $t,g=c(t,0,[u,0]);r.ext=d.getExtParamArray(g)}}return r},this.getCertStatus=function(t){var e={};if("8000"==t)return{status:"good"};if("8200"==t)return{status:"unknown"};if("a1"==t.substr(0,2)){e.status="revoked";var r=mt(a(t,0,[0]));e.time=r}return e}},void 0!==nt&&nt||(nt={}),void 0!==nt.lang&&nt.lang||(nt.lang={}),nt.lang.String=function(){},"function"==typeof Buffer?(ot=function(t){return lt(Buffer.from(t,"utf8").toString("base64"))},at=function(t){return Buffer.from(pt(t),"base64").toString("utf8")}):(ot=function(t){return dt(wt(Dt(t)))},at=function(t){return decodeURIComponent(At(gt(t)))}),nt.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},nt.lang.String.isHex=function(t){return Ot(t)},nt.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},nt.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=pt(t),nt.lang.String.isBase64(t))},nt.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},nt.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},nt.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},nt.lang.String.isMail=function(t){return null!==t.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var kt=function(t,e,r){return null==r&&(r="0"),t.length>=e?t:new Array(e-t.length+1).join(r)+t};function Ut(t,e){for(var r=0,i=0;i<t.length;i++)r|=1<<e[t[i]];var s=r.toString(2),n="";for(i=s.length-1;i>=0;i--)n+=s[i];return n}function jt(t,e,r){if("object"==typeof t){e=String(e).split(".");for(var i=0;i<e.length&&t;i++){var s=e[i];s.match(/^[0-9]+$/)&&(s=parseInt(s)),t=t[s]}return t||!1===t?t:r}}function Vt(t,e){var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e)}void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:f.algo.MD5,sha1:f.algo.SHA1,sha224:f.algo.SHA224,sha256:f.algo.SHA256,sha384:f.algo.SHA384,sha512:f.algo.SHA512,ripemd160:f.algo.RIPEMD160},this.getDigestInfoHex=function(t,e){if(void 0===this.DIGESTINFOHEAD[e])throw"alg not supported in Util.DIGESTINFOHEAD: "+e;return this.DIGESTINFOHEAD[e]+t},this.getPaddedDigestInfoHex=function(t,e,r){var i=this.getDigestInfoHex(t,e),s=r/4;if(i.length+22>s)throw"key is too short for SigAlg: keylen="+r+","+e;for(var n="00"+i,o="",a=s-4-n.length,c=0;c<a;c+=2)o+="ff";return"0001"+o+n},this.hashString=function(t,e){return new nt.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new nt.crypto.MessageDigest({alg:e}).digestHex(t)},this.sha1=function(t){return this.hashString(t,"sha1")},this.sha256=function(t){return this.hashString(t,"sha256")},this.sha256Hex=function(t){return this.hashHex(t,"sha256")},this.sha512=function(t){return this.hashString(t,"sha512")},this.sha512Hex=function(t){return this.hashHex(t,"sha512")},this.isKey=function(t){return t instanceof tt||t instanceof nt.crypto.DSA||t instanceof nt.crypto.ECDSA}},nt.crypto.Util.md5=function(t){return new nt.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},nt.crypto.Util.ripemd160=function(t){return new nt.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},nt.crypto.Util.SECURERANDOMGEN=new Q,nt.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return nt.crypto.Util.SECURERANDOMGEN.nextBytes(e),ht(e)},nt.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new E(nt.crypto.Util.getRandomHexOfNbytes(t),16)},nt.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,r=new Array((t-e)/8+1);return nt.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<e&255^255)&r[0],ht(r)},nt.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new E(nt.crypto.Util.getRandomHexOfNbits(t),16)},nt.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=nt.crypto.Util.getRandomBigIntegerOfNbits(e);if(t.compareTo(r)>=0)return r}},nt.crypto.Util.getRandomBigIntegerMinToMax=function(t,e){var r=t.compareTo(e);if(r>0)throw"biMin is greater than biMax";if(0==r)return t;var i=e.subtract(t);return nt.crypto.Util.getRandomBigIntegerZeroToMax(i).add(t)},nt.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=nt.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=nt.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=nt.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[t].create()}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=f.enc.Hex.parse(t);this.md.update(e)},this.digest=function(){return this.md.finalize().toString(f.enc.Hex)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}if(-1!=":sha256:".indexOf(t)&&"sjcl"==e){try{this.md=new sjcl.hash.sha256}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=sjcl.codec.hex.toBits(t);this.md.update(e)},this.digest=function(){var t=this.md.finalize();return sjcl.codec.hex.fromBits(t)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(t){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==t&&void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=nt.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},nt.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},nt.crypto.MessageDigest.getHashLength=function(t){var e=nt.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},nt.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},nt.crypto.Mac=function(t){this.setAlgAndProvider=function(t,e){if(null==(t=t.toLowerCase())&&(t="hmacsha1"),"hmac"!=(t=t.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+t;void 0===e&&(e=nt.crypto.Util.DEFAULTPROVIDER[t]),this.algProv=t+"/"+e;var r=t.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(r)&&"cryptojs"==e){try{var i=nt.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[r];this.mac=f.algo.HMAC.create(i,this.pass)}catch(t){throw"setAlgAndProvider hash alg set fail hashAlg="+r+"/"+t}this.updateString=function(t){this.mac.update(t)},this.updateHex=function(t){var e=f.enc.Hex.parse(t);this.mac.update(e)},this.doFinal=function(){return this.mac.finalize().toString(f.enc.Hex)},this.doFinalString=function(t){return this.updateString(t),this.doFinal()},this.doFinalHex=function(t){return this.updateHex(t),this.doFinal()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(t){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(t){if("string"==typeof t){var e=t;return t.length%2!=1&&t.match(/^[0-9A-Fa-f]+$/)||(e=St(t)),void(this.pass=f.enc.Hex.parse(e))}if("object"!=typeof t)throw"KJUR.crypto.Mac unsupported password type: "+t;if(e=null,void 0!==t.hex){if(t.hex.length%2!=0||!t.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+t.hex;e=t.hex}if(void 0!==t.utf8&&(e=ft(t.utf8)),void 0!==t.rstr&&(e=St(t.rstr)),void 0!==t.b64&&(e=S(t.b64)),void 0!==t.b64u&&(e=gt(t.b64u)),null==e)throw"KJUR.crypto.Mac unsupported password type: "+t;this.pass=f.enc.Hex.parse(e)},void 0!==t&&(void 0!==t.pass&&this.setPassword(t.pass),void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=nt.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},nt.crypto.Signature=function(t){var e=null;if(this._setAlgNames=function(){var t=this.algName.match(/^(.+)with(.+)$/);t&&(this.mdAlgName=t[1].toLowerCase(),this.pubkeyAlgName=t[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(t,e){for(var r="",i=e/4-t.length,s=0;s<i;s++)r+="0";return r+t},this.setAlgAndProvider=function(t,e){if(this._setAlgNames(),"cryptojs/jsrsa"!=e)throw new Error("provider not supported: "+e);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new nt.crypto.MessageDigest({alg:this.mdAlgName})}catch(t){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+t)}this.init=function(t,e){var r=null;try{r=void 0===e?Mt.getKey(t):Mt.getKey(t,e)}catch(t){throw"init failed:"+t}if(!0===r.isPrivate)this.prvKey=r,this.state="SIGN";else{if(!0!==r.isPublic)throw"init failed.:"+r;this.pubKey=r,this.state="VERIFY"}},this.updateString=function(t){this.md.updateString(t)},this.updateHex=function(t){this.md.updateHex(t)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==nt.crypto.ECDSA&&(this.prvKey=new nt.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof tt&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof tt&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof nt.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof nt.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(t){return this.updateString(t),this.sign()},this.signHex=function(t){return this.updateHex(t),this.sign()},this.verify=function(t){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==nt.crypto.ECDSA&&(this.pubKey=new nt.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof tt&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,t,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof tt&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==nt.crypto.ECDSA&&this.pubKey instanceof nt.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==nt.crypto.DSA&&this.pubKey instanceof nt.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(t,e){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(t){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(t){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(t){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(t){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=t,void 0!==t&&(void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov?this.provName=nt.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=t.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==t.psssaltlen&&(this.pssSaltLen=t.psssaltlen),void 0!==t.prvkeypem)){if(void 0!==t.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{e=Mt.getKey(t.prvkeypem),this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},nt.crypto.Cipher=function(t){},nt.crypto.Cipher.encrypt=function(t,e,r,i){if(null!=jt(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var s=e,n=t;null!=jt(i,"key")&&(s=i.key),null!=jt(i,"enc")&&(hEnc=i.enc);var o,a=f.enc.Hex.parse(s),c=f.enc.Hex.parse(n),h=f.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)o=f.TripleDES.encrypt(c,a,{iv:h});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);o=f.AES.encrypt(c,a,{iv:h})}return o+""}throw new Error("Cipher.encrypt: unsupported key or algorithm")},nt.crypto.Cipher.decrypt=function(t,e,r,i){if(null!=jt(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var s=e,n=t;null!=jt(i,"key")&&(s=i.key),null!=jt(i,"enc")&&(n=i.enc);var o,a=f.enc.Hex.parse(s),c=f.enc.Hex.parse(n),h=f.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)o=f.TripleDES.decrypt({ciphertext:c},a,{iv:h});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);o=f.AES.decrypt({ciphertext:c},a,{iv:h})}return f.enc.Hex.stringify(o)}throw new Error("Cipher.decrypt: unsupported key or algorithm")},nt.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040022":"secp384r1","2b81040023":"secp521r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}},void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.ECDSA=function(t){var e=Error,r=E,i=rt,s=nt.crypto.ECDSA,n=nt.crypto.ECParameterDB,o=s.getName,a=ct,c=a.getVbyListEx,h=a.isASN1HEX,u=new Q;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(t){return new r(t.bitLength(),u).mod(t.subtract(r.ONE)).add(r.ONE)},this.setNamedCurve=function(t){this.ecparams=n.getByName(t),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=t},this.setPrivateKeyHex=function(t){this.isPrivate=!0,this.prvKeyHex=t},this.setPublicKeyHex=function(t){this.isPublic=!0,this.pubKeyHex=t},this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if("04"!==t.substr(0,2))throw"this method supports uncompressed format(04) only";var e=this.ecparams.keycharlen;if(t.length!==2+2*e)throw"malformed public key hex length";var r={};return r.x=t.substr(2,e),r.y=t.substr(2+e),r},this.getShortNISTPCurveName=function(){var t=this.curveName;return"secp256r1"===t||"NIST P-256"===t||"P-256"===t||"prime256v1"===t?"P-256":"secp384r1"===t||"NIST P-384"===t||"P-384"===t?"P-384":"secp521r1"===t||"NIST P-521"===t||"P-521"===t?"P-521":null},this.generateKeyPairHex=function(){var t=this.ecparams.n,e=this.getBigRandom(t),r=this.ecparams.keycharlen,i=("0000000000"+e.toString(16)).slice(-r);return this.setPrivateKeyHex(i),{ecprvhex:i,ecpubhex:this.generatePublicKeyHex()}},this.generatePublicKeyHex=function(){var t=new r(this.prvKeyHex,16),e=this.ecparams.G.multiply(t),i=e.getX().toBigInteger(),s=e.getY().toBigInteger(),n=this.ecparams.keycharlen,o="04"+("0000000000"+i.toString(16)).slice(-n)+("0000000000"+s.toString(16)).slice(-n);return this.setPublicKeyHex(o),o},this.signWithMessageHash=function(t){return this.signHex(t,this.prvKeyHex)},this.signHex=function(t,e){var i=new r(e,16),n=this.ecparams.n,o=new r(t.substring(0,this.ecparams.keycharlen),16);do{var a=this.getBigRandom(n),c=this.ecparams.G.multiply(a).getX().toBigInteger().mod(n)}while(c.compareTo(r.ZERO)<=0);var h=a.modInverse(n).multiply(o.add(i.multiply(c))).mod(n);return s.biRSSigToASN1Sig(c,h)},this.sign=function(t,e){var i=e,s=this.ecparams.n,n=r.fromByteArrayUnsigned(t);do{var o=this.getBigRandom(s),a=this.ecparams.G.multiply(o).getX().toBigInteger().mod(s)}while(a.compareTo(E.ZERO)<=0);var c=o.modInverse(s).multiply(n.add(i.multiply(a))).mod(s);return this.serializeSig(a,c)},this.verifyWithMessageHash=function(t,e){return this.verifyHex(t,e,this.pubKeyHex)},this.verifyHex=function(t,e,n){try{var o,a,c=s.parseSigHex(e);o=c.r,a=c.s;var h=i.decodeFromHex(this.ecparams.curve,n),u=new r(t.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(u,o,a,h)}catch(t){return!1}},this.verify=function(t,e,s){var n,o,a;if(Bitcoin.Util.isArray(e)){var c=this.parseSig(e);n=c.r,o=c.s}else{if("object"!=typeof e||!e.r||!e.s)throw"Invalid value for signature";n=e.r,o=e.s}if(s instanceof rt)a=s;else{if(!Bitcoin.Util.isArray(s))throw"Invalid format for pubkey value, must be byte array or ECPointFp";a=i.decodeFrom(this.ecparams.curve,s)}var h=r.fromByteArrayUnsigned(t);return this.verifyRaw(h,n,o,a)},this.verifyRaw=function(t,e,i,s){var n=this.ecparams.n,o=this.ecparams.G;if(e.compareTo(r.ONE)<0||e.compareTo(n)>=0)return!1;if(i.compareTo(r.ONE)<0||i.compareTo(n)>=0)return!1;var a=i.modInverse(n),c=t.multiply(a).mod(n),h=e.multiply(a).mod(n);return o.multiply(c).add(s.multiply(h)).getX().toBigInteger().mod(n).equals(e)},this.serializeSig=function(t,e){var r=t.toByteArraySigned(),i=e.toByteArraySigned(),s=[];return s.push(2),s.push(r.length),(s=s.concat(r)).push(2),s.push(i.length),(s=s.concat(i)).unshift(s.length),s.unshift(48),s},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var s=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:r.fromByteArrayUnsigned(i),s:r.fromByteArrayUnsigned(s)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:r.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:r.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){if(!1===h(t))throw new Error("not ASN.1 hex string");var e,r,i;try{e=c(t,0,["[0]",0],"06"),r=c(t,0,[1],"04");try{i=c(t,0,["[1]",0],"03")}catch(t){}}catch(t){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=o(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){if(!1===h(t))throw new e("not ASN.1 hex string");var r,i,s;try{c(t,0,[1,0],"06"),r=c(t,0,[1,1],"06"),i=c(t,0,[2,0,1],"04");try{s=c(t,0,[2,0,"[1]",0],"03")}catch(t){}}catch(t){throw new e("malformed PKCS#8 plain ECC private key")}if(this.curveName=o(r),void 0===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(s),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===h(t))throw new e("not ASN.1 hex string");var r,i;try{c(t,0,[0,0],"06"),r=c(t,0,[0,1],"06"),i=c(t,0,[1],"03")}catch(t){throw new e("malformed PKCS#8 ECC public key")}if(this.curveName=o(r),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,r){if(!1===h(t))throw new e("not ASN.1 hex string");var i,s;try{i=c(t,0,[0,5,0,1],"06"),s=c(t,0,[0,5,1],"03")}catch(t){throw new e("malformed X.509 certificate ECC public key")}if(this.curveName=o(i),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(s)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},nt.crypto.ECDSA.parseSigHex=function(t){var e=nt.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new E(e.r,16),s:new E(e.s,16)}},nt.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=ct,r=e.getChildIdx,i=e.getV;if(e.checkStrictDER(t,0),"30"!=t.substr(0,2))throw new Error("signature is not a ASN.1 sequence");var s=r(t,0);if(2!=s.length)throw new Error("signature shall have two elements");var n=s[0],o=s[1];if("02"!=t.substr(n,2))throw new Error("1st item not ASN.1 integer");if("02"!=t.substr(o,2))throw new Error("2nd item not ASN.1 integer");return{r:i(t,n),s:i(t,o)}},nt.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=nt.crypto.ECDSA.parseSigHexInHexRS(t),r=e.r,i=e.s;if(r.length>=130&&r.length<=134){if(r.length%2!=0)throw Error("unknown ECDSA sig r length error");if(i.length%2!=0)throw Error("unknown ECDSA sig s length error");"00"==r.substr(0,2)&&(r=r.substr(2)),"00"==i.substr(0,2)&&(i=i.substr(2));var s=Math.max(r.length,i.length);return(r=("000000"+r).slice(-s))+("000000"+i).slice(-s)}if("00"==r.substr(0,2)&&r.length%32==2&&(r=r.substr(2)),"00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),r.length%32==30&&(r="00"+r),i.length%32==30&&(i="00"+i),r.length%32!=0)throw Error("unknown ECDSA sig r length error");if(i.length%32!=0)throw Error("unknown ECDSA sig s length error");return r+i},nt.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length%4!=0)throw Error("unknown ECDSA concatinated r-s sig length error");var e=t.substr(0,t.length/2),r=t.substr(t.length/2);return nt.crypto.ECDSA.hexRSSigToASN1Sig(e,r)},nt.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var r=new E(t,16),i=new E(e,16);return nt.crypto.ECDSA.biRSSigToASN1Sig(r,i)},nt.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var r=nt.asn1,i=new r.DERInteger({bigint:t}),s=new r.DERInteger({bigint:e});return new r.DERSequence({array:[i,s]}).tohex()},nt.crypto.ECDSA.getName=function(t){return"2b8104001f"===t?"secp192k1":"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040021"===t?"secp224r1":"2b81040022"===t?"secp384r1":"2b81040023"===t?"secp521r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp224r1|NIST P-224|P-224|".indexOf(t)?"secp224r1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":-1!=="|secp521r1|NIST P-521|P-521|".indexOf(t)?"secp521r1":null},void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.ECParameterDB=new function(){var t={},e={};function r(t){return new E(t,16)}this.getByName=function(r){var i=r;if(void 0!==e[i]&&(i=e[r]),void 0!==t[i])return t[i];throw"unregistered EC curve name: "+i},this.regist=function(i,s,n,o,a,c,h,u,l,p,d,g){t[i]={};var f=r(n),m=r(o),y=r(a),v=r(c),S=r(h),E=new it(f,m,y),x=E.decodePointHex("04"+u+l);t[i].name=i,t[i].keylen=s,t[i].keycharlen=2*Math.ceil(s/8),t[i].curve=E,t[i].G=x,t[i].n=v,t[i].h=S,t[i].oid=d,t[i].info=g;for(var w=0;w<p.length;w++)e[p[w]]=i}},nt.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),nt.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),nt.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),nt.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),nt.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),nt.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),nt.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),nt.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),nt.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),nt.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]),void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.DSA=function(){var t=ct,e=(t.getVbyList,t.getVbyListEx),r=t.isASN1HEX,i=E,s=E.ONE;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(t,e,r,i,s){this.isPrivate=!0,this.p=t,this.q=e,this.g=r,this.y=i,this.x=s},this.setPrivateHex=function(t,e,r,i,s){var n,o,a,c,h;n=new E(t,16),o=new E(e,16),a=new E(r,16),c="string"==typeof i&&i.length>1?new E(i,16):null,h=new E(s,16),this.setPrivate(n,o,a,c,h)},this.setPublic=function(t,e,r,i){!function(t,e,r,i){if(null==t||null==e||null==r||null==i)throw new Error("invalid DSA public key");if(s.compareTo(e)>=0||e.compareTo(t)>=0)throw new Error("invalid DSA public key");if(s.compareTo(r)>=0||r.compareTo(t)>=0)throw new Error("invalid DSA public key");if(s.compareTo(i)>=0||i.compareTo(t)>=0)throw new Error("invalid DSA public key");if(0!=r.modPow(e,t).compareTo(s))throw new Error("invalid DSA public key")}(t,e,r,i),this.isPublic=!0,this.p=t,this.q=e,this.g=r,this.y=i,this.x=null},this.setPublicHex=function(t,e,r,i){var s,n,o,a;s=new E(t,16),n=new E(e,16),o=new E(r,16),a=new E(i,16),this.setPublic(s,n,o,a)},this.signWithMessageHash=function(t){var e,r,i,s=this.p,n=this.q,o=this.g,a=(this.y,this.x),c=new E(t.substr(0,n.bitLength()/4),16);do{e=nt.crypto.Util.getRandomBigIntegerMinToMax(E.ONE.add(E.ONE),n.subtract(E.ONE)),r=o.modPow(e,s).mod(n),i=e.modInverse(n).multiply(c.add(a.multiply(r))).mod(n)}while(0==r.compareTo(E.ZERO)||0==i.compareTo(E.ZERO));return nt.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:r}},{int:{bigint:i}}]})},this.verifyWithMessageHash=function(t,e){var r=this.p,i=this.q,s=this.g,n=this.y,o=this.parseASN1Signature(e),a=o[0],c=o[1],h=new E(t.substr(0,i.bitLength()/4),16);if(E.ZERO.compareTo(a)>0||a.compareTo(i)>0)throw"invalid DSA signature";if(E.ZERO.compareTo(c)>=0||c.compareTo(i)>0)throw"invalid DSA signature";var u=c.modInverse(i),l=h.multiply(u).mod(i),p=a.multiply(u).mod(i);return 0==s.modPow(l,r).multiply(n.modPow(p,r)).mod(r).mod(i).compareTo(a)},this.parseASN1Signature=function(t){try{return[new i(e(t,0,[0],"02"),16),new i(e(t,0,[1],"02"),16)]}catch(t){throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(t){var i,s,n,o,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1],"02"),s=e(t,0,[2],"02"),n=e(t,0,[3],"02"),o=e(t,0,[4],"02"),a=e(t,0,[5],"02")}catch(t){throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(i,s,n,o,a)},this.readPKCS8PrvKeyHex=function(t){var i,s,n,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1,1,0],"02"),s=e(t,0,[1,1,1],"02"),n=e(t,0,[1,1,2],"02"),o=e(t,0,[2,0],"02")}catch(t){throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(i,s,n,null,o)},this.readPKCS8PubKeyHex=function(t){var i,s,n,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[0,1,0],"02"),s=e(t,0,[0,1,1],"02"),n=e(t,0,[0,1,2],"02"),o=e(t,0,[1,0],"02")}catch(t){throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(i,s,n,o)},this.readCertPubKeyHex=function(t,i){var s,n,o,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{s=e(t,0,[0,5,0,1,0],"02"),n=e(t,0,[0,5,0,1,1],"02"),o=e(t,0,[0,5,0,1,2],"02"),a=e(t,0,[0,5,1,0],"02")}catch(t){throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(s,n,o,a)}};var Mt=function(){var t=function(t,r,i){return e(f.AES,t,r,i)},e=function(t,e,r,i){var s=f.enc.Hex.parse(e),n=f.enc.Hex.parse(r),o=f.enc.Hex.parse(i),a={};a.key=n,a.iv=o,a.ciphertext=s;var c=t.decrypt(a,n,{iv:o});return f.enc.Hex.stringify(c)},r=function(t,e,r){return i(f.AES,t,e,r)},i=function(t,e,r,i){var s=f.enc.Hex.parse(e),n=f.enc.Hex.parse(r),o=f.enc.Hex.parse(i),a=t.encrypt(s,n,{iv:o}),c=f.enc.Hex.parse(a.toString());return f.enc.Base64.stringify(c)},s={"AES-256-CBC":{proc:t,eproc:r,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:r,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:r,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,r,i){return e(f.TripleDES,t,r,i)},eproc:function(t,e,r){return i(f.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,r,i){return e(f.DES,t,r,i)},eproc:function(t,e,r){return i(f.DES,t,e,r)},keylen:8,ivlen:8}},n=function(t){var e={},r=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));r&&(e.cipher=r[1],e.ivsalt=r[2]);var i=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));i&&(e.type=i[1]);var s=-1,n=0;-1!=t.indexOf("\r\n\r\n")&&(s=t.indexOf("\r\n\r\n"),n=2),-1!=t.indexOf("\n\n")&&(s=t.indexOf("\n\n"),n=1);var o=t.indexOf("-----END");if(-1!=s&&-1!=o){var a=t.substring(s+2*n,o-n);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,r){for(var i=r.substring(0,16),n=f.enc.Hex.parse(i),o=f.enc.Utf8.parse(e),a=s[t].keylen+s[t].ivlen,c="",h=null;;){var u=f.algo.MD5.create();if(null!=h&&u.update(h),u.update(o),u.update(n),h=u.finalize(),(c+=f.enc.Hex.stringify(h)).length>=2*a)break}var l={};return l.keyhex=c.substr(0,2*s[t].keylen),l.ivhex=c.substr(2*s[t].keylen,2*s[t].ivlen),l},a=function(t,e,r,i){var n=f.enc.Base64.parse(t),o=f.enc.Hex.stringify(n);return(0,s[e].proc)(o,r,i)};return{version:"1.0.0",parsePKCS5PEM:function(t){return n(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return o(t,e,r)},decryptKeyB64:function(t,e,r,i){return a(t,e,r,i)},getDecryptedKeyHex:function(t,e){var r=n(t),i=(r.type,r.cipher),s=r.ivsalt,c=r.data,h=o(i,e,s).keyhex;return a(c,i,h,s)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,i,n){var a="";if(void 0!==i&&null!=i||(i="AES-256-CBC"),void 0===s[i])throw new Error("KEYUTIL unsupported algorithm: "+i);if(void 0===n||null==n){var c=function(t){var e=f.lib.WordArray.random(t);return f.enc.Hex.stringify(e)}(s[i].ivlen);n=c.toUpperCase()}var h=function(t,e,r,i){return(0,s[e].eproc)(t,r,i)}(e,i,o(i,r,n).keyhex,n);return a="-----BEGIN "+t+" PRIVATE KEY-----\r\n",a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+i+","+n+"\r\n",a+="\r\n",(a+=h.replace(/(.{64})/g,"$1\r\n"))+"\r\n-----END "+t+" PRIVATE KEY-----\r\n"},getEncryptedPKCS8PEM:function(t,e,r){return Et(this.getEncryptedPKCS8Hex(t,e,r),"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(t,e,r){var i;(i=null==r||null==r?{}:JSON.parse(JSON.stringify(r))).plain=t,this.initPBES2Param(i),this.encryptPBES2Param(i,e);var s=this.generatePBES2ASN1Param(i);return nt.asn1.ASN1Util.newObject(s).tohex()},initPBES2Param:function(t){var e;null==jt(t,"encalg")&&(t.encalg="aes256-CBC"),null==jt(t,"iter")&&(t.iter=2048),null==jt(t,"prf")&&(t.prf="hmacWithSHA256"),null==jt(t,"salt")&&(t.salt=f.enc.Hex.stringify(f.lib.WordArray.random(8))),null==jt(t,"enciv")&&("des-EDE3-CBC"==t.encalg&&(e=8),"aes128-CBC"==t.encalg&&(e=16),"aes256-CBC"==t.encalg&&(e=16),t.enciv=f.enc.Hex.stringify(f.lib.WordArray.random(e)))},encryptPBES2Param:function(t,e){var r=Mt.getDKFromPBES2Param(t,e);try{var i=nt.crypto.Cipher.encrypt(t.plain,r,t.encalg,{iv:t.enciv})}catch(e){throw new Error("encrypt error: "+t.plain+" "+r+" "+t.encalg+" "+t.enciv)}t.enc=i},generatePBES2ASN1Param:function(t){var e={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:t.salt}},{int:{hex:Bt(t.iter)}}]}]},{seq:[{oid:t.encalg},{octstr:{hex:t.enciv}}]}]}]},{octstr:{hex:t.enc}}]};return"hmacWithSHA1"!=t.prf&&e.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:t.prf},{null:""}]}),e},parseHexOfEncryptedPKCS8:function(t){var e=ct,r=e.getChildIdx,i=e.getV,s={},n=r(t,0);if(2!=n.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+n.length);s.ciphertext=i(t,n[1]);var o=r(t,n[0]);if(2!=o.length)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+o.length);if("2a864886f70d01050d"!=i(t,o[0]))throw new Error("this only supports pkcs5PBES2");var a=r(t,o[1]);if(2!=o.length)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+a.length);var c=r(t,a[1]);if(2!=c.length)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+c.length);if("2a864886f70d0307"!=i(t,c[0]))throw"this only supports TripleDES";s.encryptionSchemeAlg="TripleDES",s.encryptionSchemeIV=i(t,c[1]);var h=r(t,a[0]);if(2!=h.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+h.length);if("2a864886f70d01050c"!=i(t,h[0]))throw new Error("this only supports pkcs5PBKDF2");var u=r(t,h[1]);if(u.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+u.length);s.pbkdf2Salt=i(t,u[0]);var l=i(t,u[1]);try{s.pbkdf2Iter=parseInt(l,16)}catch(t){throw new Error("malformed format pbkdf2Iter: "+l)}return s},getPBKDF2KeyHexFromParam:function(t,e){var r=f.enc.Hex.parse(t.pbkdf2Salt),i=t.pbkdf2Iter,s=f.PBKDF2(e,r,{keySize:6,iterations:i});return f.enc.Hex.stringify(s)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=xt(t,"ENCRYPTED PRIVATE KEY"),i=this.parseHexOfEncryptedPKCS8(r),s=Mt.getPBKDF2KeyHexFromParam(i,e),n={};n.ciphertext=f.enc.Hex.parse(i.ciphertext);var o=f.enc.Hex.parse(s),a=f.enc.Hex.parse(i.encryptionSchemeIV),c=f.TripleDES.decrypt(n,o,{iv:a});return f.enc.Hex.stringify(c)},parsePBES2:function(t){var e=ct.parse(t);if("pkcs5PBES2"!=jt(e,"seq.0.seq.0.oid")||"pkcs5PBKDF2"!=jt(e,"seq.0.seq.1.seq.0.seq.0.oid"))throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var r=jt(e,"seq.0.seq.1.seq.0.seq.1.seq");if(null==r)throw new Error("PBKDF2 parameter not found");var i=jt(r,"0.octstr.hex"),s=jt(r,"1.int.hex"),n=jt(r,"2.seq.0.oid","hmacWithSHA1"),o=-1;try{o=parseInt(s,16)}catch(t){throw new Error("iter not proper value")}var a=jt(e,"seq.0.seq.1.seq.1.seq.0.oid"),c=jt(e,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),h=jt(e,"seq.1.octstr.hex");if(null==a||null==c||null==h)throw new Error("encalg, enciv or enc is undefined");return{salt:i,iter:o,prf:n,encalg:a,enciv:c,enc:h}},getDKFromPBES2Param:function(t,e){var r={hmacWithSHA1:f.algo.SHA1,hmacWithSHA224:f.algo.SHA224,hmacWithSHA256:f.algo.SHA256,hmacWithSHA384:f.algo.SHA384,hmacWithSHA512:f.algo.SHA512}[t.prf];if(null==r)throw new Error("unsupported prf");var i={"des-EDE3-CBC":6,"aes128-CBC":4,"aes256-CBC":8}[t.encalg];if(null==i)throw new Error("unsupported encalg");var s=f.enc.Hex.parse(t.salt),n=t.iter;try{var o=f.PBKDF2(e,s,{keySize:i,iterations:n,hasher:r});return f.enc.Hex.stringify(o)}catch(r){throw new Error("PBKDF2 error: "+r+" "+JSON.stringify(t)+" "+e)}},getPlainHexFromEncryptedPKCS8PEM:function(t,e){if(-1==t.indexOf("BEGIN ENCRYPTED PRIVATE KEY"))throw new Error("not Encrypted PKCS#8 PEM string");var r,i=xt(t);try{r=Mt.parsePBES2(i)}catch(t){throw new Error("malformed PBES2 format: "+t.message)}var s=Mt.getDKFromPBES2Param(r,e);return nt.crypto.Cipher.decrypt(r.enc,s,r.encalg,{iv:r.enciv})},getKeyFromEncryptedPKCS8PEM:function(t,e){var r=this.getPlainHexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(t){var e=ct,r=e.getChildIdx,i=e.getV,s={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var n=r(t,0);if(n.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(n[1],2))throw new Error("malformed PKCS8 private key(code:003)");var o=r(t,n[1]);if(2!=o.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(o[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(s.algoid=i(t,o[0]),"06"==t.substr(o[1],2)&&(s.algparam=i(t,o[1])),"04"!=t.substr(n[2],2))throw new Error("malformed PKCS8 private key(code:006)");return s.keyidx=e.getVidx(t,n[2]),s},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=xt(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,r=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==r.algoid)e=new tt;else if("2a8648ce380401"==r.algoid)e=new nt.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw new Error("unsupported private key algorithm");e=new nt.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=ct.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new tt;else if("2a8648ce380401"===r)e=new nt.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw new Error("unsupported PKCS#8 public key hex");e=new nt.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=ct,r=e.getChildIdx,i=e.getV,s={};if("30"!=t.substr(0,2))throw new Error("malformed RSA key(code:001)");var n=r(t,0);if(2!=n.length)throw new Error("malformed RSA key(code:002)");if("02"!=t.substr(n[0],2))throw new Error("malformed RSA key(code:003)");if(s.n=i(t,n[0]),"02"!=t.substr(n[1],2))throw new Error("malformed RSA key(code:004)");return s.e=i(t,n[1]),s},parsePublicPKCS8Hex:function(t){var e=ct,r=e.getChildIdx,i=e.getV,s={algparam:null},n=r(t,0);if(2!=n.length)throw new Error("outer DERSequence shall have 2 elements: "+n.length);var o=n[0];if("30"!=t.substr(o,2))throw new Error("malformed PKCS8 public key(code:001)");var a=r(t,o);if(2!=a.length)throw new Error("malformed PKCS8 public key(code:002)");if("06"!=t.substr(a[0],2))throw new Error("malformed PKCS8 public key(code:003)");if(s.algoid=i(t,a[0]),"06"==t.substr(a[1],2)?s.algparam=i(t,a[1]):"30"==t.substr(a[1],2)&&(s.algparam={},s.algparam.p=e.getVbyList(t,a[1],[0],"02"),s.algparam.q=e.getVbyList(t,a[1],[1],"02"),s.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(n[1],2))throw new Error("malformed PKCS8 public key(code:004)");return s.key=i(t,n[1]).substr(2),s}}}();function Kt(t,e){for(var r="",i=e/4-t.length,s=0;s<i;s++)r+="0";return r+t}function qt(t,e,r){for(var i="",s=0;i.length<e;)i+=vt(r(St(t+String.fromCharCode.apply(String,[(4278190080&s)>>24,(16711680&s)>>16,(65280&s)>>8,255&s])))),s+=1;return i}function Gt(t){for(var e in nt.crypto.Util.DIGESTINFOHEAD){var r=nt.crypto.Util.DIGESTINFOHEAD[e],i=r.length;if(t.substring(0,i)==r)return[e,t.substring(i)]}return[]}function $t(t){var e,r=ct,i=r.getChildIdx,s=r.getV,n=(r.dump,r.parse),o=r.getTLV,a=r.getVbyList,c=r.getVbyListEx,h=r.getTLVbyList,u=r.getTLVbyListEx,l=r.getIdxbyList,p=r.getIdxbyListEx,d=r.getVidx,g=r.getInt,f=r.oidname,m=r.hextooidstr,y=xt,v=Error;try{e=nt.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(t){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null===this.hex||0!==this.version)return this.version;var t=h(this.hex,0,[0,0]);if("a0"==t.substr(0,2)){var e=h(t,0,[0]),r=g(e,0);if(r<0||2<r)throw new Error("malformed version field");return this.version=r+1,this.version}return this.version=1,this.foffset=-1,1},this.getSerialNumberHex=function(){return c(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var t=u(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(t)},this.getAlgorithmIdentifierName=function(t){for(var r in e)if(t===e[r])return r;return f(c(t,0,[0],"06"))},this.getIssuer=function(t,e){return this.getX500Name(this.getIssuerHex(),t,e)},this.getIssuerHex=function(){return h(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(t,e){return this.getX500Name(this.getSubjectHex(),t,e)},this.getSubjectHex=function(){return h(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var t=a(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),decodeURIComponent(t)},this.getNotAfter=function(){var t=a(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),decodeURIComponent(t)},this.getPublicKeyHex=function(){return this.getSPKI()},this.getSPKI=function(){return h(this.hex,0,[0,6+this.foffset],"30")},this.getSPKIValue=function(){var t=this.getSPKI();return null==t?null:a(t,0,[1],"03",!0)},this.getPublicKeyIdx=function(){return l(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return l(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Mt.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=h(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(t)},this.getSignatureValueHex=function(){return a(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmField(),r=this.getSignatureValueHex(),i=h(this.hex,0,[0],"30"),s=new nt.crypto.Signature({alg:e});return s.init(t),s.updateHex(i),s.verify(r)},this.parseExt=function(t){var e,n,o;if(void 0===t){if(o=this.hex,3!==this.version)return-1;e=l(o,0,[0,7,0],"30"),n=i(o,e)}else{o=xt(t);var c=l(o,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=s(o,c))return void(this.aExtInfo=new Array);e=l(o,0,[0,3,0,1,0],"30"),n=i(o,e),this.hex=o}this.aExtInfo=new Array;for(var h=0;h<n.length;h++){var u={critical:!1},p=0;3===i(o,n[h]).length&&(u.critical=!0,p=1),u.oid=r.hextooidstr(a(o,n[h],[0],"06"));var g=l(o,n[h],[1+p]);u.vidx=d(o,g),this.aExtInfo.push(u)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(t.match(/^[0-9.]+$/)||(r=nt.asn1.x509.OID.name2oid(t)),""!==r)for(var i=0;i<e.length;i++)if(e[i].oid===r)return e[i]},this.getCriticalExtV=function(t,e,r){if(null!=e)return[e,r];var i=this.getExtInfo(t);return null==i?[null,null]:[o(this.hex,i.vidx),i.critical]},this.getExtBasicConstraints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("basicConstraints");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var i={extname:"basicConstraints"};if(e&&(i.critical=!0),"3000"===t)return i;if("30030101ff"===t)return i.cA=!0,i;if("30060101ff02"===t.substr(0,12)){var n=s(t,10),a=parseInt(n,16);return i.cA=!0,i.pathLen=a,i}throw new Error("hExtV parse error: "+t)},this.getExtNameConstraints=function(t,e){var r=this.getCriticalExtV("nameConstraints",t,e);if(t=r[0],e=r[1],null!=t){var s={extname:"nameConstraints"};e&&(s.critical=!0);for(var n=i(t,0),a=0;a<n.length;a++){for(var c=[],h=i(t,n[a]),u=0;u<h.length;u++){var l=o(t,h[u]),p=this.getGeneralSubtree(l);c.push(p)}var d=t.substr(n[a],2);"a0"==d?s.permit=c:"a1"==d&&(s.exclude=c)}return s}},this.getGeneralSubtree=function(t){var e=i(t,0),r=e.length;if(r<1||2<r)throw new Error("wrong num elements");for(var n=this.getGeneralName(o(t,e[0])),a=1;a<r;a++){var c=t.substr(e[a],2),h=s(t,e[a]),u=parseInt(h,16);"80"==c&&(n.min=u),"81"==c&&(n.max=u)}return n},this.getExtKeyUsage=function(t,e){var r=this.getCriticalExtV("keyUsage",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"keyUsage"};return e&&(i.critical=!0),i.names=this.getExtKeyUsageString(t).split(","),i}},this.getExtKeyUsageBin=function(t){if(void 0===t){var e=this.getExtInfo("keyUsage");if(void 0===e)return"";t=o(this.hex,e.vidx)}if(8!=t.length&&10!=t.length)throw new Error("malformed key usage value: "+t);var r="000000000000000"+parseInt(t.substr(6),16).toString(2);return 8==t.length&&(r=r.slice(-8)),10==t.length&&(r=r.slice(-16)),""==(r=r.replace(/0+$/,""))&&(r="0"),r},this.getExtKeyUsageString=function(t){for(var e=this.getExtKeyUsageBin(t),r=new Array,i=0;i<e.length;i++)"1"==e.substr(i,1)&&r.push($t.KEYUSAGE_NAME[i]);return r.join(",")},this.getExtSubjectKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectKeyIdentifier");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var i={extname:"subjectKeyIdentifier"};e&&(i.critical=!0);var n=s(t,0);return i.kid={hex:n},i},this.getExtAuthorityKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityKeyIdentifier");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var n={extname:"authorityKeyIdentifier"};e&&(n.critical=!0);for(var a=i(t,0),c=0;c<a.length;c++){var h=t.substr(a[c],2);if("80"===h&&(n.kid={hex:s(t,a[c])}),"a1"===h){var u=o(t,a[c]),l=this.getGeneralNames(u);n.issuer=l[0].dn}"82"===h&&(n.sn={hex:s(t,a[c])})}return n},this.getExtExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("extKeyUsage");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var n={extname:"extKeyUsage",array:[]};e&&(n.critical=!0);for(var a=i(t,0),c=0;c<a.length;c++)n.array.push(f(s(t,a[c])));return n},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var e=new Array,r=o(this.hex,t.vidx);if(""===r)return e;for(var n=i(r,0),a=0;a<n.length;a++)e.push(f(s(r,n[a])));return e},this.getExtSubjectAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectAltName");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var i={extname:"subjectAltName",array:[]};return e&&(i.critical=!0),i.array=this.getGeneralNames(t),i},this.getExtIssuerAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("issuerAltName");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var i={extname:"issuerAltName",array:[]};return e&&(i.critical=!0),i.array=this.getGeneralNames(t),i},this.getGeneralNames=function(t){for(var e=i(t,0),r=[],s=0;s<e.length;s++){var n=this.getGeneralName(o(t,e[s]));void 0!==n&&r.push(n)}return r},this.getGeneralName=function(t){var e=t.substr(0,2),r=s(t,0),i=vt(r);return"81"==e?{rfc822:i}:"82"==e?{dns:i}:"86"==e?{uri:i}:"87"==e?{ip:It(r)}:"a4"==e?{dn:this.getX500Name(r)}:"a0"==e?{other:this.getOtherName(t)}:void 0},this.getExtSubjectAltName2=function(){var t,e,r,n=this.getExtInfo("subjectAltName");if(void 0===n)return n;for(var a=new Array,c=o(this.hex,n.vidx),h=i(c,0),u=0;u<h.length;u++)r=c.substr(h[u],2),t=s(c,h[u]),"81"===r&&(e=mt(t),a.push(["MAIL",e])),"82"===r&&(e=mt(t),a.push(["DNS",e])),"84"===r&&(e=$t.hex2dn(t,0),a.push(["DN",e])),"86"===r&&(e=mt(t),a.push(["URI",e])),"87"===r&&(e=It(t),a.push(["IP",e]));return a},this.getExtCRLDistributionPoints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("cRLDistributionPoints");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var s={extname:"cRLDistributionPoints",array:[]};e&&(s.critical=!0);for(var n=i(t,0),a=0;a<n.length;a++){var c=o(t,n[a]);s.array.push(this.getDistributionPoint(c))}return s},this.getDistributionPoint=function(t){for(var e={},r=i(t,0),s=0;s<r.length;s++){var n=t.substr(r[s],2),a=o(t,r[s]);"a0"==n&&(e.dpname=this.getDistributionPointName(a))}return e},this.getDistributionPointName=function(t){for(var e={},r=i(t,0),s=0;s<r.length;s++){var n=t.substr(r[s],2),a=o(t,r[s]);"a0"==n&&(e.full=this.getGeneralNames(a))}return e},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtCRLDistributionPoints();if(null==t)return t;for(var e=t.array,r=[],i=0;i<e.length;i++)try{null!=e[i].dpname.full[0].uri&&r.push(e[i].dpname.full[0].uri)}catch(t){}return r},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var e={ocsp:[],caissuer:[]},r=i(this.hex,t.vidx),s=0;s<r.length;s++){var n=a(this.hex,r[s],[0],"06"),o=a(this.hex,r[s],[1],"86");"2b06010505073001"===n&&e.ocsp.push(mt(o)),"2b06010505073002"===n&&e.caissuer.push(mt(o))}return e},this.getExtAuthorityInfoAccess=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityInfoAccess");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var s={extname:"authorityInfoAccess",array:[]};e&&(s.critical=!0);for(var n=i(t,0),h=0;h<n.length;h++){var u=c(t,n[h],[0],"06"),l=mt(a(t,n[h],[1],"86"));if("2b06010505073001"==u)s.array.push({ocsp:l});else{if("2b06010505073002"!=u)throw new Error("unknown method: "+u);s.array.push({caissuer:l})}}return s},this.getExtCertificatePolicies=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("certificatePolicies");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var s={extname:"certificatePolicies",array:[]};e&&(s.critical=!0);for(var n=i(t,0),a=0;a<n.length;a++){var c=o(t,n[a]),h=this.getPolicyInformation(c);s.array.push(h)}return s},this.getPolicyInformation=function(t){var e={},r=a(t,0,[0],"06");e.policyoid=f(r);var s=p(t,0,[1],"30");if(-1!=s){e.array=[];for(var n=i(t,s),c=0;c<n.length;c++){var h=o(t,n[c]),u=this.getPolicyQualifierInfo(h);e.array.push(u)}}return e},this.getOtherName=function(t){var e={},r=i(t,0),s=a(t,r[0],[],"06"),o=a(t,r[1],[]);return e.oid=f(s),e.value=n(o),e},this.getPolicyQualifierInfo=function(t){var e={},r=a(t,0,[0],"06");if("2b06010505070201"===r){var i=c(t,0,[1],"16");e.cps=vt(i)}else if("2b06010505070202"===r){var s=h(t,0,[1],"30");e.unotice=this.getUserNotice(s)}return e},this.getUserNotice=function(t){var e=null;try{return e=r.parse(t),this._asn1ToUnotice(e)}catch(t){return}},this._asn1ToUnotice=function(t){try{for(var e={},r=jt(t,"seq"),i=0;i<r.length;i++){var s=this._asn1ToNoticeRef(r[i]);null!=s&&(e.noticeref=s);var n=this.asn1ToDisplayText(r[i]);null!=n&&(e.exptext=n)}return Object.keys(e).length>0?e:void 0}catch(t){return}},this._asn1ToNoticeRef=function(t){try{for(var e={},r=jt(t,"seq"),i=0;i<r.length;i++){var s=this._asn1ToNoticeNum(r[i]);null!=s&&(e.noticenum=s);var n=this.asn1ToDisplayText(r[i]);null!=n&&(e.org=n)}return Object.keys(e).length>0?e:void 0}catch(t){return}},this._asn1ToNoticeNum=function(t){try{for(var e=jt(t,"seq"),r=[],i=0;i<e.length;i++){var s=e[i];r.push(parseInt(jt(s,"int.hex"),16))}return r}catch(t){return}},this.getDisplayText=function(t){var e={};return e.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[t.substr(0,2)],e.str=vt(s(t,0)),e},this.asn1ToDisplayText=function(t){return null!=t.utf8str?{type:"utf8",str:t.utf8str.str}:null!=t.ia5str?{type:"ia5",str:t.ia5str.str}:null!=t.visstr?{type:"vis",str:t.visstr.str}:null!=t.bmpstr?{type:"bmp",str:t.bmpstr.str}:null!=t.prnstr?{type:"prn",str:t.prnstr.str}:void 0},this.getExtPolicyMappings=function(t,e){var r=this.getCriticalExtV("policyMappings",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"policyMappings"};e&&(i.critical=!0);try{for(var s=n(t).seq,o=[],a=0;a<s.length;a++){var c=s[a].seq;o.push([c[0].oid,c[1].oid])}i.array=o}catch(t){throw new v("malformed policyMappings")}return i}},this.getExtPolicyConstraints=function(t,e){var r=this.getCriticalExtV("policyConstraints",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"policyConstraints"};e&&(i.critical=!0);var s=n(t);try{for(var o=s.seq,a=0;a<o.length;a++){var c=o[a].tag;0==c.explicit&&("80"==c.tag&&(i.reqexp=parseInt(c.hex,16)),"81"==c.tag&&(i.inhibit=parseInt(c.hex,16)))}}catch(t){return new v("malformed policyConstraints value")}return i}},this.getExtInhibitAnyPolicy=function(t,e){var r=this.getCriticalExtV("inhibitAnyPolicy",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"inhibitAnyPolicy"};e&&(i.critical=!0);var s=g(t,0);return-1==s?new v("wrong value"):(i.skip=s,i)}},this.getExtCRLNumber=function(t,e){var r={extname:"cRLNumber"};if(e&&(r.critical=!0),"02"==t.substr(0,2))return r.num={hex:s(t,0)},r;throw new v("hExtV parse error: "+t)},this.getExtCRLReason=function(t,e){var r={extname:"cRLReason"};if(e&&(r.critical=!0),"0a"==t.substr(0,2))return r.code=parseInt(s(t,0),16),r;throw new Error("hExtV parse error: "+t)},this.getExtOcspNonce=function(t,e){var r={extname:"ocspNonce"};e&&(r.critical=!0);var i=s(t,0);return r.hex=i,r},this.getExtOcspNoCheck=function(t,e){var r={extname:"ocspNoCheck"};return e&&(r.critical=!0),r},this.getExtAdobeTimeStamp=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("adobeTimeStamp");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var s={extname:"adobeTimeStamp"};e&&(s.critical=!0);var n=i(t,0);if(n.length>1){var a=o(t,n[1]),c=this.getGeneralName(a);null!=c.uri&&(s.uri=c.uri)}if(n.length>2){var h=o(t,n[2]);"0101ff"==h&&(s.reqauth=!0),"010100"==h&&(s.reqauth=!1)}return s},this.getExtSubjectDirectoryAttributes=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectDirectoryAttributes");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var i={extname:"subjectDirectoryAttributes"};e&&(i.critical=!0);try{for(var s=n(t),a=[],c=0;c<s.seq.length;c++){var h=s.seq[c],u=jt(h,"seq.0.oid"),l=jt(h,"seq.1.set");if(null==u||null==l)throw"error";a.push({attr:u,array:l})}return i.array=a,i}catch(t){throw new Error("malformed subjectDirectoryAttributes extension value")}};var S=function(t){var e={};try{var r=t.seq[0].oid,i=nt.asn1.x509.OID.name2oid(r);e.type=nt.asn1.x509.OID.oid2atype(i);var s=t.seq[1];if(null!=s.utf8str)e.ds="utf8",e.value=s.utf8str.str;else if(null!=s.numstr)e.ds="num",e.value=s.numstr.str;else if(null!=s.telstr)e.ds="tel",e.value=s.telstr.str;else if(null!=s.prnstr)e.ds="prn",e.value=s.prnstr.str;else if(null!=s.ia5str)e.ds="ia5",e.value=s.ia5str.str;else if(null!=s.visstr)e.ds="vis",e.value=s.visstr.str;else{if(null==s.bmpstr)throw"error";e.ds="bmp",e.value=s.bmpstr.str}return e}catch(t){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}},E=function(t){try{return t.set.map(function(t){return S(t)})}catch(t){throw new Error("improper ASN.1 parsed RDN: "+t)}};this.getX500NameRule=function(t){for(var e=null,r=[],i=0;i<t.length;i++)for(var s=t[i],n=0;n<s.length;n++)r.push(s[n]);for(i=0;i<r.length;i++){var o=r[i],a=o.ds,c=o.value,h=o.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=h)return"mixed";if(nt.lang.String.isMail(c))continue;return"mixed"}if("C"==h){if("prn"==a)continue;return"mixed"}if(null==e)e=a;else if(e!==a)return"mixed"}return null==e?"prn":e},this.getAttrTypeAndValue=function(t){var e=n(t);return S(e)},this.getRDN=function(t){var e=n(t);return E(e)},this.getX500NameArray=function(t){return function(t){try{return t.seq.map(function(t){return E(t)})}catch(t){throw new Error("improper ASN.1 parsed X500Name: "+t)}}(n(t))},this.getX500Name=function(t,e,r){var i=this.getX500NameArray(t),s={str:this.dnarraytostr(i)};return s.array=i,1==r&&(s.hex=t),1==e&&(s.canon=this.c14nRDNArray(i)),s},this.readCertPEM=function(t){this.readCertHex(y(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{l(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getParam=function(t){var e={};return null==t&&(t={}),e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(t.dncanon,t.dnhex),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(t.dncanon,t.dnhex),e.sbjpubkey=Et(this.getPublicKeyHex(),"PUBLIC KEY"),null!=this.aExtInfo&&this.aExtInfo.length>0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),1==t.tbshex&&(e.tbshex=h(this.hex,0,[0])),1==t.nodnarray&&(delete e.issuer.array,delete e.subject.array),e},this.getExtParamArray=function(t){null==t&&-1!=p(this.hex,0,[0,"[3]"])&&(t=u(this.hex,0,[0,"[3]",0],"30"));for(var e=[],r=i(t,0),s=0;s<r.length;s++){var n=o(t,r[s]),a=this.getExtParam(n);null!=a&&e.push(a)}return e},this.getExtParam=function(t){var e=i(t,0).length;if(2!=e&&3!=e)throw new Error("wrong number elements in Extension: "+e+" "+t);var r=m(a(t,0,[0],"06")),s=!1;3==e&&"0101ff"==h(t,0,[1])&&(s=!0);var o=h(t,0,[e-1,0]),c=void 0;if("2.5.29.14"==r?c=this.getExtSubjectKeyIdentifier(o,s):"2.5.29.15"==r?c=this.getExtKeyUsage(o,s):"2.5.29.17"==r?c=this.getExtSubjectAltName(o,s):"2.5.29.18"==r?c=this.getExtIssuerAltName(o,s):"2.5.29.19"==r?c=this.getExtBasicConstraints(o,s):"2.5.29.30"==r?c=this.getExtNameConstraints(o,s):"2.5.29.31"==r?c=this.getExtCRLDistributionPoints(o,s):"2.5.29.32"==r?c=this.getExtCertificatePolicies(o,s):"2.5.29.33"==r?c=this.getExtPolicyMappings(o,s):"2.5.29.35"==r?c=this.getExtAuthorityKeyIdentifier(o,s):"2.5.29.36"==r?c=this.getExtPolicyConstraints(o,s):"2.5.29.37"==r?c=this.getExtExtKeyUsage(o,s):"2.5.29.54"==r?c=this.getExtInhibitAnyPolicy(o,s):"1.3.6.1.5.5.7.1.1"==r?c=this.getExtAuthorityInfoAccess(o,s):"2.5.29.20"==r?c=this.getExtCRLNumber(o,s):"2.5.29.21"==r?c=this.getExtCRLReason(o,s):"2.5.29.9"==r?c=this.getExtSubjectDirectoryAttributes(o,s):"1.3.6.1.5.5.7.48.1.2"==r?c=this.getExtOcspNonce(o,s):"1.3.6.1.5.5.7.48.1.5"==r?c=this.getExtOcspNoCheck(o,s):"1.2.840.113583.1.1.9.1"==r?c=this.getExtAdobeTimeStamp(o,s):null!=$t.EXT_PARSER[r]&&(c=$t.EXT_PARSER[r](r,s,o)),null!=c)return c;var u={extname:r,extn:o};try{u.extn=n(o)}catch(t){}return s&&(u.critical=!0),u},this.findExt=function(t,e){for(var r=0;r<t.length;r++)if(t[r].extname==e)return t[r];return null},this.updateExtCDPFullURI=function(t,e){var r=this.findExt(t,"cRLDistributionPoints");if(null!=r&&null!=r.array)for(var i=r.array,s=0;s<i.length;s++)if(null!=i[s].dpname&&null!=i[s].dpname.full)for(var n=i[s].dpname.full,o=0;o<n.length;o++){var a=n[s];null!=a.uri&&(a.uri=e)}},this.updateExtAIAOCSP=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var i=r.array,s=0;s<i.length;s++)null!=i[s].ocsp&&(i[s].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var i=r.array,s=0;s<i.length;s++)null!=i[s].caissuer&&(i[s].caissuer=e)},this.dnarraytostr=function(t){return"/"+t.map(function(t){return function(t){return t.map(function(t){return function(t){return t.type+"="+t.value}(t).replace(/\+/,"\\+")}).join("+")}(t).replace(/\//,"\\/")}).join("/")},this.setCanonicalizedDN=function(t){var e;if(null!=t.str&&null==t.array){var r=new nt.asn1.x509.X500Name({str:t.str}).tohex();e=this.getX500NameArray(r)}else e=t.array;null==t.canon&&(t.canon=this.c14nRDNArray(e))},this.c14nRDNArray=function(t){for(var e=[],r=0;r<t.length;r++){for(var i=t[r],s=[],n=0;n<i.length;n++){var o=i[n],a=o.value;a=(a=(a=(a=a.replace(/^\s*/,"")).replace(/\s*$/,"")).replace(/\s+/g," ")).toLowerCase(),s.push(o.type.toLowerCase()+"="+a)}e.push(s.join("+"))}return"/"+e.join("/")},this.getInfo=function(){var t,e,r,i=function(t){for(var e="",r=" ",i="\n",s=t.array,n=0;n<s.length;n++){var o=s[n];null!=o.dn&&(e+=r+"dn: "+o.dn.str+i),null!=o.ip&&(e+=r+"ip: "+o.ip+i),null!=o.rfc822&&(e+=r+"rfc822: "+o.rfc822+i),null!=o.dns&&(e+=r+"dns: "+o.dns+i),null!=o.uri&&(e+=r+"uri: "+o.uri+i),null!=o.other&&(e+=r+"other: "+o.other.oid+"="+JSON.stringify(o.other.value).replace(/\"/g,"")+i)}return e.replace(/\n$/,"")},s=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var s=r[i];if(e+=" policy oid: "+s.policyoid+"\n",void 0!==s.array)for(var n=0;n<s.array.length;n++){var o=s.array[n];void 0!==o.cps&&(e+=" cps: "+o.cps+"\n")}}return e},n=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var s=r[i];try{void 0!==s.dpname.full[0].uri&&(e+=" "+s.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==s.dname.full[0].dn.hex&&(e+=" "+$t.hex2dn(s.dpname.full[0].dn.hex)+"\n")}catch(t){}}return e},o=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var s=r[i];void 0!==s.caissuer&&(e+=" caissuer: "+s.caissuer+"\n"),void 0!==s.ocsp&&(e+=" ocsp: "+s.ocsp+"\n")}return e};if(t="Basic Fields\n",t+=" serial number: "+this.getSerialNumberHex()+"\n",t+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",t+=" issuer: "+this.getIssuerString()+"\n",t+=" notBefore: "+this.getNotBefore()+"\n",t+=" notAfter: "+this.getNotAfter()+"\n",t+=" subject: "+this.getSubjectString()+"\n",t+=" subject public key info: \n",t+=" key algorithm: "+(e=this.getPublicKey()).type+"\n","RSA"===e.type&&(t+=" n="+_t(e.n.toString(16)).substr(0,16)+"...\n",t+=" e="+_t(e.e.toString(16))+"\n"),null!=(r=this.aExtInfo)){t+="X509v3 Extensions:\n";for(var a=0;a<r.length;a++){var c=r[a],h=nt.asn1.x509.OID.oid2name(c.oid);""===h&&(h=c.oid);var u="";if(!0===c.critical&&(u="CRITICAL"),t+=" "+h+" "+u+":\n","basicConstraints"===h){var l=this.getExtBasicConstraints();void 0===l.cA?t+=" {}\n":(t+=" cA=true",void 0!==l.pathLen&&(t+=", pathLen="+l.pathLen),t+="\n")}else{var p;if("policyMappings"==h)t+=" "+this.getExtPolicyMappings().array.map(function(t){var e=t;return e[0]+":"+e[1]}).join(", ")+"\n";else if("policyConstraints"==h)t+=" ",null!=(p=this.getExtPolicyConstraints()).reqexp&&(t+=" reqexp="+p.reqexp),null!=p.inhibit&&(t+=" inhibit="+p.inhibit),t+="\n";else if("inhibitAnyPolicy"==h)t+=" skip="+(p=this.getExtInhibitAnyPolicy()).skip+"\n";else if("keyUsage"==h)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"==h)t+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"==h){var d=this.getExtAuthorityKeyIdentifier();void 0!==d.kid&&(t+=" kid="+d.kid.hex+"\n")}else"extKeyUsage"==h?t+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n":"subjectAltName"==h?t+=i(this.getExtSubjectAltName())+"\n":"cRLDistributionPoints"==h?t+=n(this.getExtCRLDistributionPoints()):"authorityInfoAccess"==h?t+=o(this.getExtAuthorityInfoAccess()):"certificatePolicies"==h&&(t+=s(this.getExtCertificatePolicies()))}}}return(t+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n")+"signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?this.readCertPEM(t):nt.lang.String.isHex(t)&&this.readCertHex(t))}Mt.getKey=function(t,e,r){var i,s=(y=ct).getChildIdx,n=(y.getV,y.getVbyList),o=nt.crypto,a=o.ECDSA,c=o.DSA,h=tt,u=xt,l=Mt;if(void 0!==h&&t instanceof h)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==c&&t instanceof c)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new a({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new a({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(F=new h).setPublic(t.n,t.e),F;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(F=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),F;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(F=new h).setPrivate(t.n,t.e,t.d),F;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(F=new c).setPublic(t.p,t.q,t.g,t.y),F;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(F=new c).setPrivate(t.p,t.q,t.g,t.y,t.x),F;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(F=new h).setPublic(gt(t.n),gt(t.e)),F;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(F=new h).setPrivateEx(gt(t.n),gt(t.e),gt(t.d),gt(t.p),gt(t.q),gt(t.dp),gt(t.dq),gt(t.qi)),F;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(F=new h).setPrivate(gt(t.n),gt(t.e),gt(t.d)),F;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var p=(T=new a({curve:t.crv})).ecparams.keycharlen,d="04"+("0000000000"+gt(t.x)).slice(-p)+("0000000000"+gt(t.y)).slice(-p);return T.setPublicKeyHex(d),T}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){p=(T=new a({curve:t.crv})).ecparams.keycharlen,d="04"+("0000000000"+gt(t.x)).slice(-p)+("0000000000"+gt(t.y)).slice(-p);var g=("0000000000"+gt(t.d)).slice(-p);return T.setPublicKeyHex(d),T.setPrivateKeyHex(g),T}if("pkcs5prv"===r){var f,m=t,y=ct;if(9===(f=s(m,0)).length)(F=new h).readPKCS5PrvKeyHex(m);else if(6===f.length)(F=new c).readPKCS5PrvKeyHex(m);else{if(!(f.length>2&&"04"===m.substr(f[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(F=new a).readPKCS5PrvKeyHex(m)}return F}if("pkcs8prv"===r)return l.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return l._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return $t.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return $t.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=xt(t,"PUBLIC KEY");return l._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=u(t,"RSA PRIVATE KEY");return l.getKey(S,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var x=n(i=u(t,"DSA PRIVATE KEY"),0,[1],"02"),w=n(i,0,[2],"02"),A=n(i,0,[3],"02"),b=n(i,0,[4],"02"),C=n(i,0,[5],"02");return(F=new c).setPrivate(new E(x,16),new E(w,16),new E(A,16),new E(b,16),new E(C,16)),F}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED"))return S=u(t,"EC PRIVATE KEY"),l.getKey(S,null,"pkcs5prv");if(-1!=t.indexOf("-END PRIVATE KEY-"))return l.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var I=l.getDecryptedKeyHex(t,e),R=new tt;return R.readPKCS5PrvKeyHex(I),R}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var T,F=n(i=l.getDecryptedKeyHex(t,e),0,[1],"04"),P=n(i,0,[2,0],"06"),D=n(i,0,[3,0],"03").substr(2);if(void 0===nt.crypto.OID.oidhex2name[P])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+P);return(T=new a({curve:nt.crypto.OID.oidhex2name[P]})).setPublicKeyHex(D),T.setPrivateKeyHex(F),T.isPublic=!1,T}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED"))return x=n(i=l.getDecryptedKeyHex(t,e),0,[1],"02"),w=n(i,0,[2],"02"),A=n(i,0,[3],"02"),b=n(i,0,[4],"02"),C=n(i,0,[5],"02"),(F=new c).setPrivate(new E(x,16),new E(w,16),new E(A,16),new E(b,16),new E(C,16)),F;if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return l.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},Mt.generateKeypair=function(t,e){if("RSA"==t){var r=e;(o=new tt).generate(r,"10001"),o.isPrivate=!0,o.isPublic=!0;var i=new tt,s=o.n.toString(16),n=o.e.toString(16);return i.setPublic(s,n),i.isPrivate=!1,i.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=i,a}if("EC"==t){var o,a,c=e,h=new nt.crypto.ECDSA({curve:c}).generateKeyPairHex();return(o=new nt.crypto.ECDSA({curve:c})).setPublicKeyHex(h.ecpubhex),o.setPrivateKeyHex(h.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(i=new nt.crypto.ECDSA({curve:c})).setPublicKeyHex(h.ecpubhex),i.isPrivate=!1,i.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=i,a}throw new Error("unknown algorithm: "+t)},Mt.getPEM=function(t,e,r,i,s,n){var o=nt,a=o.asn1,c=a.DERObjectIdentifier,h=a.DERInteger,u=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,p=o.crypto,d=p.DSA,g=p.ECDSA,f=tt;function m(t){return u({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function y(t){return u({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function v(t){return u({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==f&&t instanceof f||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Et(w=new l(t).tohex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==f&&t instanceof f&&(void 0===r||null==r)&&1==t.isPrivate)return Et(w=m(t).tohex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===r||null==r)&&1==t.isPrivate){var S=new c({name:t.curveName}).tohex(),E=y(t).tohex(),x="";return(x+=Et(S,"EC PARAMETERS"))+Et(E,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===r||null==r)&&1==t.isPrivate)return Et(w=v(t).tohex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==f&&t instanceof f&&void 0!==r&&null!=r&&1==t.isPrivate){var w=m(t).tohex();return void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",w,r,i,n)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==r&&null!=r&&1==t.isPrivate)return w=y(t).tohex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",w,r,i,n);if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==r&&null!=r&&1==t.isPrivate)return w=v(t).tohex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",w,r,i,n);var A=function(t,e){if("string"==typeof e)return Mt.getEncryptedPKCS8PEM(t,e);if("object"==typeof e&&null!=jt(e,"passcode")){var r=JSON.parse(JSON.stringify(e)),i=r.passcode;return delete r.passcode,Mt.getEncryptedPKCS8PEM(t,i,r)}};if("PKCS8PRV"==e&&null!=f&&t instanceof f&&1==t.isPrivate){var b=m(t).tohex();return w=u({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(w,"PRIVATE KEY"):A(w,r)}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){var C={seq:[{int:1},{octstr:{hex:t.prvKeyHex}}]};return"string"==typeof t.pubKeyHex&&C.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}),b=new u(C).tohex(),w=u({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(w,"PRIVATE KEY"):A(w,r)}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate)return b=new h({bigint:t.x}).tohex(),w=u({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(w,"PRIVATE KEY"):A(w,r);throw new Error("unsupported object nor format")},Mt.getKeyFromCSRPEM=function(t){var e=xt(t,"CERTIFICATE REQUEST");return Mt.getKeyFromCSRHex(e)},Mt.getKeyFromCSRHex=function(t){var e=Mt.parseCSRHex(t);return Mt.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Mt.parseCSRHex=function(t){var e=ct,r=e.getChildIdx,i=e.getTLV,s={},n=t;if("30"!=n.substr(0,2))throw new Error("malformed CSR(code:001)");var o=r(n,0);if(o.length<1)throw new Error("malformed CSR(code:002)");if("30"!=n.substr(o[0],2))throw new Error("malformed CSR(code:003)");var a=r(n,o[0]);if(a.length<3)throw new Error("malformed CSR(code:004)");return s.p8pubkeyhex=i(n,a[2]),s},Mt.getKeyID=function(t){var e=Mt,r=ct;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var i=xt(e.getPEM(t)),s=r.getIdxbyList(i,0,[1]),n=r.getV(i,s).substring(2);return nt.crypto.Util.hashHex(n,"sha1")},Mt.getJWK=function(t,e,r,i,s){var n,o,a={},c=nt.crypto.Util.hashHex;if("string"==typeof t)n=Mt.getKey(t),-1!=t.indexOf("CERTIFICATE")&&(o=xt(t));else{if("object"!=typeof t)throw new Error("unsupported keyinfo type");t instanceof $t?(n=t.getPublicKey(),o=t.hex):n=t}if(n instanceof tt&&n.isPrivate)a.kty="RSA",a.n=dt(n.n.toString(16)),a.e=dt(n.e.toString(16)),a.d=dt(n.d.toString(16)),a.p=dt(n.p.toString(16)),a.q=dt(n.q.toString(16)),a.dp=dt(n.dmp1.toString(16)),a.dq=dt(n.dmq1.toString(16)),a.qi=dt(n.coeff.toString(16));else if(n instanceof tt&&n.isPublic)a.kty="RSA",a.n=dt(n.n.toString(16)),a.e=dt(n.e.toString(16));else if(n instanceof nt.crypto.ECDSA&&n.isPrivate){if("P-256"!==(u=n.getShortNISTPCurveName())&&"P-384"!==u&&"P-521"!==u)throw new Error("unsupported curve name for JWT: "+u);var h=n.getPublicKeyXYHex();a.kty="EC",a.crv=u,a.x=dt(h.x),a.y=dt(h.y),a.d=dt(n.prvKeyHex)}else if(n instanceof nt.crypto.ECDSA&&n.isPublic){var u;if("P-256"!==(u=n.getShortNISTPCurveName())&&"P-384"!==u&&"P-521"!==u)throw new Error("unsupported curve name for JWT: "+u);h=n.getPublicKeyXYHex(),a.kty="EC",a.crv=u,a.x=dt(h.x),a.y=dt(h.y)}if(null==a.kty)throw new Error("unsupported keyinfo");return n.isPrivate||1==e||(a.kid=nt.jws.JWS.getJWKthumbprint(a)),null!=o&&1!=r&&(a.x5c=[v(o)]),null!=o&&1!=i&&(a.x5t=lt(v(c(o,"sha1")))),null!=o&&1!=s&&(a["x5t#S256"]=lt(v(c(o,"sha256")))),a},Mt.getJWKFromKey=function(t){return Mt.getJWK(t,!0,!0,!0,!0)},tt.getPosArrayOfChildrenFromHex=function(t){return ct.getChildIdx(t,0)},tt.getHexValueArrayOfChildrenFromHex=function(t){var e,r=ct.getV,i=r(t,(e=tt.getPosArrayOfChildrenFromHex(t))[0]),s=r(t,e[1]),n=r(t,e[2]),o=r(t,e[3]),a=r(t,e[4]),c=r(t,e[5]),h=r(t,e[6]),u=r(t,e[7]),l=r(t,e[8]);return(e=new Array).push(i,s,n,o,a,c,h,u,l),e},tt.prototype.readPrivateKeyFromPEMString=function(t){var e=xt(t),r=tt.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])},tt.prototype.readPKCS5PrvKeyHex=function(t){var e=tt.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},tt.prototype.readPKCS8PrvKeyHex=function(t){var e,r,i,s,n,o,a,c,h=ct,u=h.getVbyListEx;if(!1===h.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=u(t,0,[2,0,1],"02"),r=u(t,0,[2,0,2],"02"),i=u(t,0,[2,0,3],"02"),s=u(t,0,[2,0,4],"02"),n=u(t,0,[2,0,5],"02"),o=u(t,0,[2,0,6],"02"),a=u(t,0,[2,0,7],"02"),c=u(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,i,s,n,o,a,c)},tt.prototype.readPKCS5PubKeyHex=function(t){var e=ct,r=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var i=e.getChildIdx(t,0);if(2!==i.length||"02"!==t.substr(i[0],2)||"02"!==t.substr(i[1],2))throw new Error("wrong hex for PKCS#5 public key");var s=r(t,i[0]),n=r(t,i[1]);this.setPublic(s,n)},tt.prototype.readPKCS8PubKeyHex=function(t){var e=ct;if(!1===e.isASN1HEX(t))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==e.getTLVbyListEx(t,0,[0,0]))throw new Error("not PKCS8 RSA public key");var r=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(r)},tt.prototype.readCertPubKeyHex=function(t,e){var r,i;(r=new $t).readCertHex(t),i=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(i)},tt.prototype.sign=function(t,e){var r=function(t){return nt.crypto.Util.hashString(t,e)}(t);return this.signWithMessageHash(r,e)},tt.prototype.signWithMessageHash=function(t,e){var r=Z(nt.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return Kt(this.doPrivate(r).toString(16),this.n.bitLength())},tt.prototype.signPSS=function(t,e,r){var i,s=(i=St(t),nt.crypto.Util.hashHex(i,e));return void 0===r&&(r=-1),this.signWithMessageHashPSS(s,e,r)},tt.prototype.signWithMessageHashPSS=function(t,e,r){var i,s=vt(t),n=s.length,o=this.n.bitLength()-1,a=Math.ceil(o/8),c=function(t){return nt.crypto.Util.hashHex(t,e)};if(-1===r||void 0===r)r=n;else if(-2===r)r=a-n-2;else if(r<-2)throw new Error("invalid salt length");if(a<n+r+2)throw new Error("data too long");var h="";r>0&&(h=new Array(r),(new Q).nextBytes(h),h=String.fromCharCode.apply(String,h));var u=vt(c(St("\0\0\0\0\0\0\0\0"+s+h))),l=[];for(i=0;i<a-r-n-2;i+=1)l[i]=0;var p=String.fromCharCode.apply(String,l)+""+h,d=qt(u,p.length,c),g=[];for(i=0;i<p.length;i+=1)g[i]=p.charCodeAt(i)^d.charCodeAt(i);var f=65280>>8*a-o&255;for(g[0]&=~f,i=0;i<n;i++)g.push(u.charCodeAt(i));return g.push(188),Kt(this.doPrivate(new E(g)).toString(16),this.n.bitLength())},tt.prototype.verify=function(t,e){if(null==(e=e.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var r=Z(e,16),i=this.n.bitLength();if(r.bitLength()>i)return!1;var s=this.doPublic(r).toString(16);if(s.length+3!=i/4)return!1;var n=Gt(s.replace(/^1f+00/,""));if(0==n.length)return!1;var o=n[0],a=n[1],c=function(t){return nt.crypto.Util.hashString(t,o)}(t);return a==c},tt.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=Z(e,16);if(r.bitLength()>this.n.bitLength())return 0;var i=Gt(this.doPublic(r).toString(16).replace(/^1f+00/,""));return 0!=i.length&&(i[0],i[1]==t)},tt.prototype.verifyPSS=function(t,e,r,i){var s,n=(s=St(t),nt.crypto.Util.hashHex(s,r));return void 0===i&&(i=-1),this.verifyWithMessageHashPSS(n,e,r,i)},tt.prototype.verifyWithMessageHashPSS=function(t,e,r,i){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var s,n=new E(e,16),o=function(t){return nt.crypto.Util.hashHex(t,r)},a=vt(t),c=a.length,h=this.n.bitLength()-1,u=Math.ceil(h/8);if(-1===i||void 0===i)i=c;else if(-2===i)i=u-c-2;else if(i<-2)throw new Error("invalid salt length");if(u<c+i+2)throw new Error("data too long");var l=this.doPublic(n).toByteArray();for(s=0;s<l.length;s+=1)l[s]&=255;for(;l.length<u;)l.unshift(0);if(188!==l[u-1])throw new Error("encoded message does not end in 0xbc");var p=(l=String.fromCharCode.apply(String,l)).substr(0,u-c-1),d=l.substr(p.length,c),g=65280>>8*u-h&255;if(0!==(p.charCodeAt(0)&g))throw new Error("bits beyond keysize not zero");var f=qt(d,p.length,o),m=[];for(s=0;s<p.length;s+=1)m[s]=p.charCodeAt(s)^f.charCodeAt(s);m[0]&=~g;var y=u-c-i-2;for(s=0;s<y;s+=1)if(0!==m[s])throw new Error("leftmost octets not zero");if(1!==m[y])throw new Error("0x01 marker not found");return d===vt(o(St("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,m.slice(-i)))))},tt.SALT_LEN_HLEN=-1,tt.SALT_LEN_MAX=-2,tt.SALT_LEN_RECOVER=-2,$t.EXT_PARSER={},$t.registExtParser=function(t,e){$t.EXT_PARSER[t]=e},$t.hex2dn=function(t,e){void 0===e&&(e=0);var r=new $t;return ct.getTLV(t,e),r.getX500Name(t).str},$t.hex2rdn=function(t,e){if(void 0===e&&(e=0),"31"!==t.substr(e,2))throw new Error("malformed RDN");for(var r=new Array,i=ct.getChildIdx(t,e),s=0;s<i.length;s++)r.push($t.hex2attrTypeValue(t,i[s]));return r=r.map(function(t){return t.replace("+","\\+")}),r.join("+")},$t.hex2attrTypeValue=function(t,e){var r=ct,i=r.getV;if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw new Error("malformed attribute type and value");var s=r.getChildIdx(t,e);2!==s.length||t.substr(s[0],2);var n=i(t,s[0]),o=nt.asn1.ASN1Util.oidHexToInt(n);return nt.asn1.x509.OID.oid2atype(o)+"="+vt(i(t,s[1]))},$t.getPublicKeyFromCertHex=function(t){var e=new $t;return e.readCertHex(t),e.getPublicKey()},$t.getPublicKeyFromCertPEM=function(t){var e=new $t;return e.readCertPEM(t),e.getPublicKey()},$t.getPublicKeyInfoPropOfCertPEM=function(t){var e,r,i=ct.getVbyList,s={algparam:null};return(e=new $t).readCertPEM(t),r=e.getPublicKeyHex(),s.keyhex=i(r,0,[1],"03").substr(2),s.algoid=i(r,0,[0,0],"06"),"2a8648ce3d0201"===s.algoid&&(s.algparam=i(r,0,[0,1],"06")),s},$t.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],void 0!==nt&&nt||(nt={}),void 0!==nt.jws&&nt.jws||(nt.jws={}),nt.jws.JWS=function(){var t=nt.jws.JWS.isSafeJSONString;this.parseJWS=function(e,r){if(void 0===this.parsedJWS||!r&&void 0===this.parsedJWS.sigvalH){var i=e.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==i)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var s=i[1],n=i[2],o=i[3],a=s+"."+n;if(this.parsedJWS={},this.parsedJWS.headB64U=s,this.parsedJWS.payloadB64U=n,this.parsedJWS.sigvalB64U=o,this.parsedJWS.si=a,!r){var c=gt(o),h=Z(c,16);this.parsedJWS.sigvalH=c,this.parsedJWS.sigvalBI=h}var u=at(s),l=at(n);if(this.parsedJWS.headS=u,this.parsedJWS.payloadS=l,!t(u,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+u}}},nt.jws.JWS.sign=function(t,e,r,i,s){var n,o,a,c=nt,h=c.jws.JWS,u=h.readSafeJSONString,l=h.isSafeJSONString,p=c.crypto,d=(p.ECDSA,p.Mac),g=p.Signature,f=JSON;if("string"!=typeof e&&"object"!=typeof e)throw"spHeader must be JSON string or object: "+e;if("object"==typeof e&&(o=e,n=f.stringify(o)),"string"==typeof e){if(!l(n=e))throw"JWS Head is not safe JSON string: "+n;o=u(n)}if(a=r,"object"==typeof r&&(a=f.stringify(r)),""!=t&&null!=t||void 0===o.alg||(t=o.alg),""!=t&&null!=t&&void 0===o.alg&&(o.alg=t,n=f.stringify(o)),t!==o.alg)throw"alg and sHeader.alg doesn't match: "+t+"!="+o.alg;var m=null;if(void 0===h.jwsalg2sigalg[t])throw"unsupported alg name: "+t;m=h.jwsalg2sigalg[t];var y=ot(n)+"."+ot(a),v="";if("Hmac"==m.substr(0,4)){if(void 0===i)throw"mac key shall be specified for HS* alg";var S=new d({alg:m,prov:"cryptojs",pass:i});S.updateString(y),v=S.doFinal()}else if(-1!=m.indexOf("withECDSA")){(x=new g({alg:m})).init(i,s),x.updateString(y);var E=x.sign();v=nt.crypto.ECDSA.asn1SigToConcatSig(E)}else{var x;"none"!=m&&((x=new g({alg:m})).init(i,s),x.updateString(y),v=x.sign())}return y+"."+dt(v)},nt.jws.JWS.verify=function(t,e,r){var i,s=nt,n=s.jws.JWS,o=n.readSafeJSONString,a=s.crypto,c=a.ECDSA,h=a.Mac,u=a.Signature;if(i=tt,!Nt(t))return!1;var l=t.split(".");if(3!==l.length)return!1;var p,d=l[0]+"."+l[1],g=gt(l[2]),f=o(at(l[0])),m=null;if(void 0===f.alg)throw"algorithm not specified in header";if(p=(m=f.alg).substr(0,2),null!=r&&"[object Array]"===Object.prototype.toString.call(r)&&r.length>0&&-1==(":"+r.join(":")+":").indexOf(":"+m+":"))throw"algorithm '"+m+"' not accepted in the list";if("none"!=m&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Mt.getKey(e)),!("RS"!=p&&"PS"!=p||e instanceof i))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==p&&!(e instanceof c))throw"key shall be a ECDSA obj for ES* algs";var y=null;if(void 0===n.jwsalg2sigalg[f.alg])throw"unsupported alg name: "+m;if("none"==(y=n.jwsalg2sigalg[m]))throw"not supported";if("Hmac"==y.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var v=new h({alg:y,pass:e});return v.updateString(d),g==v.doFinal()}if(-1!=y.indexOf("withECDSA")){var S,E=null;try{E=c.concatSigToASN1Sig(g)}catch(t){return!1}return(S=new u({alg:y})).init(e),S.updateString(d),S.verify(E)}return(S=new u({alg:y})).init(e),S.updateString(d),S.verify(g)},nt.jws.JWS.parse=function(t){var e,r,i,s=t.split("."),n={};if(2!=s.length&&3!=s.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=s[0],r=s[1],3==s.length&&(i=s[2]),n.headerObj=nt.jws.JWS.readSafeJSONString(at(e)),n.payloadObj=nt.jws.JWS.readSafeJSONString(at(r)),n.headerPP=JSON.stringify(n.headerObj,null," "),null==n.payloadObj?n.payloadPP=at(r):n.payloadPP=JSON.stringify(n.payloadObj,null," "),void 0!==i&&(n.sigHex=gt(i)),n},nt.jws.JWS.verifyJWT=function(t,e,r){var i=nt.jws,s=i.JWS,n=s.readSafeJSONString,o=s.inArray,a=s.includedArray;if(!Nt(t))return!1;var c=t.split(".");if(3!=c.length)return!1;var h=c[0],u=c[1],l=(gt(c[2]),n(at(h))),p=n(at(u));if(void 0===l.alg)return!1;if(void 0===r.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,r.alg))return!1;if(void 0!==p.iss&&"object"==typeof r.iss&&!o(p.iss,r.iss))return!1;if(void 0!==p.sub&&"object"==typeof r.sub&&!o(p.sub,r.sub))return!1;if(void 0!==p.aud&&"object"==typeof r.aud)if("string"==typeof p.aud){if(!o(p.aud,r.aud))return!1}else if("object"==typeof p.aud&&!a(p.aud,r.aud))return!1;var d=i.IntDate.getNow();return void 0!==r.verifyAt&&"number"==typeof r.verifyAt&&(d=r.verifyAt),void 0!==r.gracePeriod&&"number"==typeof r.gracePeriod||(r.gracePeriod=0),!(void 0!==p.exp&&"number"==typeof p.exp&&p.exp+r.gracePeriod<d||void 0!==p.nbf&&"number"==typeof p.nbf&&d<p.nbf-r.gracePeriod||void 0!==p.iat&&"number"==typeof p.iat&&d<p.iat-r.gracePeriod||void 0!==p.jti&&void 0!==r.jti&&p.jti!==r.jti||!s.verify(t,e,r.alg))},nt.jws.JWS.includedArray=function(t,e){var r=nt.jws.JWS.inArray;if(null===t)return!1;if("object"!=typeof t)return!1;if("number"!=typeof t.length)return!1;for(var i=0;i<t.length;i++)if(!r(t[i],e))return!1;return!0},nt.jws.JWS.inArray=function(t,e){if(null===e)return!1;if("object"!=typeof e)return!1;if("number"!=typeof e.length)return!1;for(var r=0;r<e.length;r++)if(e[r]==t)return!0;return!1},nt.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",ES512:"SHA512withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},nt.jws.JWS.isSafeJSONString=function(t,e,r){var i=null;try{return"object"!=typeof(i=st(t))||i.constructor===Array?0:(e&&(e[r]=i),1)}catch(t){return 0}},nt.jws.JWS.readSafeJSONString=function(t){var e=null;try{return"object"!=typeof(e=st(t))||e.constructor===Array?null:e}catch(t){return null}},nt.jws.JWS.getEncodedSignatureValueFromJWS=function(t){var e=t.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(null==e)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return e[1]},nt.jws.JWS.getJWKthumbprint=function(t){if("RSA"!==t.kty&&"EC"!==t.kty&&"oct"!==t.kty)throw"unsupported algorithm for JWK Thumprint";var e="{";if("RSA"===t.kty){if("string"!=typeof t.n||"string"!=typeof t.e)throw"wrong n and e value for RSA key";e+='"e":"'+t.e+'",',e+='"kty":"'+t.kty+'",',e+='"n":"'+t.n+'"}'}else if("EC"===t.kty){if("string"!=typeof t.crv||"string"!=typeof t.x||"string"!=typeof t.y)throw"wrong crv, x and y value for EC key";e+='"crv":"'+t.crv+'",',e+='"kty":"'+t.kty+'",',e+='"x":"'+t.x+'",',e+='"y":"'+t.y+'"}'}else if("oct"===t.kty){if("string"!=typeof t.k)throw"wrong k value for oct(symmetric) key";e+='"kty":"'+t.kty+'",',e+='"k":"'+t.k+'"}'}var r=St(e);return dt(nt.crypto.Util.hashHex(r,"sha256"))},nt.jws.IntDate={},nt.jws.IntDate.get=function(t){var e=nt.jws.IntDate,r=e.getNow,i=e.getZulu;if("now"==t)return r();if("now + 1hour"==t)return r()+3600;if("now + 1day"==t)return r()+86400;if("now + 1month"==t)return r()+2592e3;if("now + 1year"==t)return r()+31536e3;if(t.match(/Z$/))return i(t);if(t.match(/^[0-9]+$/))return parseInt(t);throw"unsupported format: "+t},nt.jws.IntDate.getZulu=function(t){return function(t){return Math.round(function(t){var e,r,i,s,n,o,a,c,h,u;if(u=(t=function(t){return t.match(/^[0-9]{12}Z$/)||t.match(/^[0-9]{12}[.][0-9]*Z$/)?t.match(/^[0-4]/)?"20"+t:"19"+t:t}(t)).match(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return e=parseInt(u[1]),r=parseInt(u[2])-1,i=parseInt(u[3]),s=parseInt(u[4]),n=parseInt(u[5]),o=parseInt(u[6]),a=0,""!==(c=u[7])&&(h=(c.substr(1)+"00").substr(0,3),a=parseInt(h)),Date.UTC(e,r,i,s,n,o,a);throw new Error("unsupported zulu format: "+t)}(t)/1e3)}(t)},nt.jws.IntDate.getNow=function(){return~~(new Date/1e3)},nt.jws.IntDate.intDate2UTCString=function(t){return new Date(1e3*t).toUTCString()},nt.jws.IntDate.intDate2Zulu=function(t){var e=new Date(1e3*t);return("0000"+e.getUTCFullYear()).slice(-4)+("00"+(e.getUTCMonth()+1)).slice(-2)+("00"+e.getUTCDate()).slice(-2)+("00"+e.getUTCHours()).slice(-2)+("00"+e.getUTCMinutes()).slice(-2)+("00"+e.getUTCSeconds()).slice(-2)+"Z"},void 0!==nt&&nt||(nt={}),void 0!==nt.jws&&nt.jws||(nt.jws={}),nt.jws.JWSJS=function(){var t=nt.jws.JWS,e=t.readSafeJSONString;this.aHeader=[],this.sPayload="",this.aSignature=[],this.init=function(){this.aHeader=[],this.sPayload=void 0,this.aSignature=[]},this.initWithJWS=function(t){this.init();var e=t.split(".");if(3!=e.length)throw"malformed input JWS";this.aHeader.push(e[0]),this.sPayload=e[1],this.aSignature.push(e[2])},this.addSignature=function(t,e,r,i){if(void 0===this.sPayload||null===this.sPayload)throw"there's no JSON-JS signature to add.";var s=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var n=nt.jws.JWS.sign(t,e,this.sPayload,r,i).split(".");n[0],n[2],this.aHeader.push(n[0]),this.aSignature.push(n[2])}catch(t){throw this.aHeader.length>s&&this.aHeader.pop(),this.aSignature.length>s&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e<t.length;e++){var r=t[e];if(2!==r.length)return!1;if(!1===this.verifyNth(e,r[0],r[1]))return!1}return!0},this.verifyNth=function(e,r,i){if(this.aHeader.length<=e||this.aSignature.length<=e)return!1;var s=this.aHeader[e],n=this.aSignature[e],o=s+"."+this.sPayload+"."+n,a=!1;try{a=t.verify(o,r,i)}catch(t){return!1}return a},this.readJWSJS=function(t){if("string"==typeof t){var r=e(t);if(null==r)throw"argument is not safe JSON object string";this.aHeader=r.headers,this.sPayload=r.payload,this.aSignature=r.signatures}else try{if(!(t.headers.length>0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignature=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},nt.crypto.ECDSA,nt.crypto.DSA,nt.crypto.Signature,nt.crypto.MessageDigest,nt.crypto.Mac,e.ym=Mt,e.wV=dt,e.cV=at,e.pj=nt,nt.crypto,nt.asn1,nt.jws,nt.lang}},e={};function r(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={exports:{}};return t[i](n,n.exports,r),n.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=function(t){return t.light="light",t.dark="dark",t}({});class s{theme="default";themeMode=i.light;constructor(t){t&&(this.theme=t.theme??this.theme,this.themeMode=t.themeMode??this.themeMode)}toString(){return JSON.stringify(this)}}class n{static deepEqual(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if("object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!n.deepEqual(t[r],e[r]))return!1;return!0}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;for(const i of r)if(!(i in e)||!n.deepEqual(t[i],e[i]))return!1;return!0}return!1}return!1}static deepCopy(t){if("object"!=typeof t||null==t||"function"==typeof t)return t;if(n.hasCopyMethod(t))return t.copy();const e=n.copyBuiltInType(t);return null!==e?e:n.copyPlainObject(t)}static copyBuiltInType(t){return Array.isArray(t)?t.map(t=>n.deepCopy(t)):t instanceof Date?new Date(t.getTime()):t instanceof RegExp?new RegExp(t.source,t.flags):t instanceof Map?new Map(Array.from(t.entries()).map(([t,e])=>[n.deepCopy(t),n.deepCopy(e)])):t instanceof Set?new Set(Array.from(t.values()).map(t=>n.deepCopy(t))):null}static copyPlainObject(t){const e=Object.create(Object.getPrototypeOf(t));for(const r of Object.keys(t))e[r]=n.deepCopy(t[r]);return e}static hasCopyMethod(t){return"object"==typeof t&&null!==t&&Object.prototype.hasOwnProperty.call(t,"copy")&&"function"==typeof t.copy}static isNullOrUndefined=t=>null==t;static mergeWithDefaults(t,e){if("object"!=typeof t||null===t)return t;const r=n.deepCopy(t);return Object.keys(e).forEach(t=>{const i=r[t],s=e[t];n.isNullOrUndefined(i)?r[t]=n.deepCopy(s):n.canRecursivelyMerge(i,s)&&(r[t]=n.mergeWithDefaults(i,s))}),r}static canRecursivelyMerge(t,e){return"object"==typeof t&&null!==t&&"object"==typeof e&&null!==e&&!Array.isArray(t)&&!Array.isArray(e)}}const o={BYTES:1,KB:1024,MB:1048576,GB:1024**3,TB:1024**4,PB:1024**5},a=/^(\d+(?:\.\d+)?)\s*(bytes|KB|MB|GB|TB|PB)$/i,h=/^\d+$/;class u{static convertToBytes(t){if(null==t)return 0;if("number"==typeof t)return t;if(t=t.trim(),h.test(t))return Number.parseInt(t,10);const e=a.exec(t);if(!e)return 0;const r=Number.parseFloat(e[1]),i=e[2];return r*o[i.toUpperCase()]}static convertToHumanReadable(t){if(!t)return"0 bytes";if("string"==typeof t&&(t=t.trim()),a.test(String(t)))return String(t);if("string"==typeof t&&(t=Number.parseFloat(t)),Number.isNaN(t)||t<=0)return"0 bytes";const e=Object.keys(o).reverse();for(const r of e){const e=o[r];if(t>=e){const i=t/e;return`${Number.isInteger(i)?i:i.toFixed(2)} ${"BYTES"===r?"bytes":r}`}}return"0 bytes"}}class c{static getWindow(){return window}static getParentWindow(){return c.getWindow().parent}static getReferer(){let t="*";if(c.getDocument().referrer)try{const e=new URL(c.getDocument().referrer);e.origin&&(t=e.origin)}catch(t){console.warn(`Failed to parse document.referrer: ${c.getDocument().referrer}. Using default targetOrigin '*'`,t)}return t}static getDocument(){return c.getWindow().document}static getPluginRegistry(){return c.getWindow().PluginRegistry}static setPluginRegistry(t){this.getWindow().PluginRegistry=t}static getCrypto(){return c.getWindow().crypto}static reloadPage(){c.getWindow().location.reload()}static getLocationHref(){return c.getWindow().location.href}static setLocationHref(t){c.getWindow().location.href=t}static getLocationQueryParams(){return c.getWindow().location.search}static getLocationHash(){return c.getWindow().location.hash}static matchMedia(t){return c.getWindow().matchMedia(t)}static getLocationPathname(){return c.getWindow().location.pathname}static getLocationOrigin(){return c.getWindow().location.origin}static getBaseHref(){return c.getDocument().querySelector("base")?.getAttribute("href")??"/"}static openWindow(t,e,r){c.getWindow().open(t,e,r)}static navigateSingleSpa(t){c.getWindow().singleSpa.navigateToUrl(t)}}class l{static isDevMode(){return c.getWindow().wbDevMode}}class d{static ABS_URI_REGEX=/^<?(http|urn).*>?/;static GRAPHS_VISUALIZATIONS_URL="graphs-visualizations";static RESOURCE_URL="resource";static BASE_DOCUMENTATION_URL="https://graphdb.ontotext.com/documentation/";static LATEST_UNOFFICIAL_VERSION="master";static shortenIri(t){const e=document.createElement("a");e.href=t;let r=e.hostname;return d.containsIPV4(e.hostname)||(r=e.hostname.split(".")[0]),r+":"+e.port}static containsIPV4(t){const e=t.split(".");for(let t=0,r=0;t<e.length;t++)if(parseInt(e[t],10)>=0&&parseInt(e[t],10)<=255?r++:r=0,4===r)return!0;return!1}static createAutocompleteRedirect(t,e){return`${t}?uri=${encodeURIComponent(e)}`}static removeAngleBrackets(t){return t?.startsWith("<")&&t?.endsWith(">")?t.substring(1,t.length-1):t}static isValidUri(t){let e=!1;if(this.hasValidProtocol(t))if(t.indexOf("http")>=0){const r=t.indexOf("//");e=r>4&&t.substring(r+2).length>0}else t.indexOf("urn")>=0&&(e=t.substring(4).length>0);return e}static resolveDocumentationUrl(t,e){if(!t||!e)throw new Error("Product version and endpoint path are required for documentation URL resolution.");const r=t.includes("-"),i=l.isDevMode()||r?this.LATEST_UNOFFICIAL_VERSION:t;return`${this.BASE_DOCUMENTATION_URL}${i}/${e}`}static hasAngleBrackets(t){return t.startsWith("<")&&t.endsWith(">")}static hasNoAngleBrackets(t){return!t.startsWith("<")&&!t.endsWith(">")}static hasValidProtocol(t){return this.ABS_URI_REGEX.test(t)&&(this.hasNoAngleBrackets(t)||this.hasAngleBrackets(t))}}class p{fibo1=0;fibo2=1;next(){const t=this.fibo2;return this.fibo2=this.fibo1+this.fibo2,this.fibo1=t,t}reset=()=>{this.fibo1=0,this.fibo2=1}}function g(t){return e=>{e?.preventDefault&&e.preventDefault(),f(t)}}function f(t){let e=t;e.startsWith(".")&&(e=e.slice(1)),e.startsWith("/")&&!e.startsWith(x())&&(e=x().slice(0,-1)+e),c.navigateSingleSpa(e)}function m(t){c.openWindow(t,"_blank","noopener,noreferrer")}function y(){return"/"===S()}function v(){return"/login"===S()}function S(){return c.getLocationPathname().substring(x().length-1)}function E(){return`${c.getLocationOrigin()}${x()}`}function x(){return c.getBaseHref()}function w(){return S().substring(1)}function A(){return S()+c.getLocationQueryParams()}function b(t,e){if(Object.values(t).includes(e))return e;throw new Error(`Invalid enum value '${e}' for enum ${JSON.stringify(t)}`)}class I{static now(){return Date.now()}}class C{copy(){return n.deepCopy(this)}}class R extends C{constructor(t=[]){super(),this.items=t}size(){return this.items.length}getItems(){return this.items}getFirstItem(){return this.items[0]}sort(t){this.items.sort(t)}filter(t){return this.items.filter(t)}find(t){return this.items.find(t)}isEmpty(){return 0===this.items.length}addToStart(t){this.items.unshift(t)}addItems(t){this.items.push(...t)}remove(t){const e=this.items.indexOf(t);-1!==e&&this.items.splice(e,1)}removeAll(){this.items=[]}}class T extends R{constructor(t){super(t)}add(t){this.items.push(t)}addAll(t){this.items.push(...t)}unsubscribeAll(){this.items.forEach(t=>t()),this.items=[]}}class F extends C{constructor(t){super(),this.id=t.id||"",this.title=t.title||"",this.type=t.type,this.sesameType=t.sesameType,this.uri=t.uri||"",this.externalUrl=t.externalUrl||"",this.location=t.location||"",this.state=t.state,this.local=t.local,this.readable=t.readable,this.writable=t.writable,this.unsupported=t.unsupported,this.isNew=t.isNew}toRepositoryReference(){return{id:this.id,location:this.location}}isOntop(){return"graphdb:OntopRepository"===this.sesameType}isFedx(){return"graphdb:FedXRepository"===this.sesameType}}const P=(t,e)=>{const r=t.location.localeCompare(e.location);return 0!==r?r:t.id.localeCompare(e.id)};class D extends R{constructor(t){super(t)}findRepository(t,e,r=!1){return super.find(i=>i.id===t&&(r||i.location===e))}sortByLocationAndId(){super.sort(P)}filterByRepository(t){return super.filter(this.createIdLocationFilter(t))}createIdLocationFilter(t){return e=>t.some(t=>t.id!==e.id||t.location!==e.location)}}class O extends C{constructor(t){super(),this.inferred=t?.inferred||0,this.total=t?.total||0,this.explicit=t?.explicit||0}}let N=function(t){return t.INACTIVE="INACTIVE",t.STARTING="STARTING",t.RUNNING="RUNNING",t.RESTARTING="RESTARTING",t.STOPPING="STOPPING",t}({}),_=function(t){return t.GRAPH_DB="graphdb",t.ONTOP="ontop",t.FEDX="fedx",t.SYSTEM="system",t.OTHER="other",t}({});const B="repositoryId";class L extends C{constructor(t){super(),this.uri=t?.uri||"",this.label=t?.label||"",this.username=t?.username||"",this.password=t?.password||"",this.authType=t?.authType,this.locationType=t?.locationType,this.active=t?.active,this.local=t?.local,this.system=t?.system,this.errorMsg=t?.errorMsg||"",this.defaultRepository=t?.defaultRepository||""}}let H=function(t){return t.GDB="GDB",t.ONTOPIC="ONTOPIC",t.SPARQL="SPARQL",t}({});class k{constructor(t){this.namespaces=t}getByPrefix(t){return this.namespaces[t]||""}}class U{constructor(t,e){this.NAME=t,this.payload=e}}const j={NAVIGATION_END:"navigationEnd",NAVIGATION_START:"navigationStart",LOGIN:"login",LOGOUT:"logout",APP_DATA_LOADED:"applicationDataLoaded",APPLICATION_MOUNTED:"applicationMounted",APPLICATION_UNMOUNTED:"applicationUnmounted",APPLICATION_CHANGED:"applicationChanged",APPLICATION_BEFORE_CHANGE:"applicationBeforeChange"};class V extends U{constructor(t,e){super(j.NAVIGATION_END,{oldUrl:t,newUrl:e})}}class M{}class K extends U{constructor(t,e,r){super(j.NAVIGATION_START,{oldUrl:t,newUrl:e,cancelNavigation:r})}}class q extends U{constructor(){super(j.APPLICATION_MOUNTED)}}class G extends U{constructor(){super(j.APPLICATION_UNMOUNTED)}}class $ extends U{constructor(){super(j.APPLICATION_BEFORE_CHANGE)}}class W extends U{constructor(){super(j.APPLICATION_CHANGED)}}class z extends U{constructor(){super(j.LOGOUT)}}class Y extends U{constructor(){super(j.LOGIN)}}let X=function(t){return t.NONE="NONE",t.BASIC="BASIC",t.SIGNATURE="SIGNATURE",t}({}),J=function(t){return t.ROLE_ADMIN="ROLE_ADMIN",t.ROLE_USER="ROLE_USER",t.ROLE_MONITORING="ROLE_MONITORING",t.ROLE_REPO_MANAGER="ROLE_REPO_MANAGER",t.ROLE_CLUSTER="ROLE_CLUSTER",t.IS_AUTHENTICATED_FULLY="IS_AUTHENTICATED_FULLY",t.SYSTEM_REPO="SYSTEM",t.READ_REPO="READ_REPO",t.READ_REPO_PREFIX="READ_REPO_",t.WRITE_REPO="WRITE_REPO",t.GRAPHQL="GRAPHQL",t.WRITE_REPO_PREFIX="WRITE_REPO_",t.GRAPHQL_PREFIX="GRAPHQL_",t.SUFFIX_DELIMITER=":",t.CUSTOM_PREFIX="CUSTOM_",t}({});class Q{static getRepoFromAuthority(t){return t.startsWith(J.READ_REPO_PREFIX)?{prefix:J.READ_REPO_PREFIX,repo:t.substring(J.READ_REPO_PREFIX.length)}:t.startsWith(J.WRITE_REPO_PREFIX)?{prefix:J.WRITE_REPO_PREFIX,repo:t.substring(J.WRITE_REPO_PREFIX.length)}:t.startsWith(J.GRAPHQL_PREFIX)?{prefix:J.GRAPHQL_PREFIX,repo:t.substring(J.GRAPHQL_PREFIX.length)}:null}}const Z=t=>{const e=J.SUFFIX_DELIMITER+J.GRAPHQL,r=t.getItems();if(!r.length)return r;const i=[],s={};let n=!1,o=!1,a=!1;r.forEach(t=>{const e=Q.getRepoFromAuthority(t);if(e){const{prefix:t,repo:i}=e,c=(s[r=i]||(s[r]={read:!1,write:!1,graphql:!1}),s[r]);t===J.READ_REPO_PREFIX?(c.read=!0,"*"===i&&(n=!0)):t===J.WRITE_REPO_PREFIX?(c.write=!0,"*"===i&&(o=!0)):t===J.GRAPHQL_PREFIX&&(c.graphql=!0,"*"===i&&(a=!0))}else i.push(t);var r});const c=[];return Object.keys(s).forEach(t=>{const r=s[t];r.graphql||a?r.write||o?c.push(`${J.WRITE_REPO_PREFIX}${t}${e}`,`${J.READ_REPO_PREFIX}${t}${e}`):(r.read||n)&&c.push(`${J.READ_REPO_PREFIX}${t}${e}`):r.write?c.push(`${J.WRITE_REPO_PREFIX}${t}`,`${J.READ_REPO_PREFIX}${t}`):r.read&&c.push(`${J.READ_REPO_PREFIX}${t}`)}),[...i,...c]},tt=t=>{if(!t)return new rt;const e=[],r=(t instanceof rt?t.getItems():t)??[];for(const t of r)et(t,e)||e.includes(t)||e.push(t);return new rt(e)};function et(t,e){if(!t.includes(J.SUFFIX_DELIMITER))return!1;const[r,i]=t.split(J.SUFFIX_DELIMITER);if(!r.startsWith(J.READ_REPO_PREFIX)&&!r.startsWith(J.WRITE_REPO_PREFIX)||i!==J.GRAPHQL)return!1;const s=Q.getRepoFromAuthority(r);if(!s)return!1;const{repo:n}=s,o=J.GRAPHQL_PREFIX+n;return e.includes(r)||e.push(r),e.includes(o)||e.push(o),!0}class rt extends R{WILDCARD="*";GQL_WILDCARD="*:GRAPHQL";constructor(t){super(t)}hasAuthority(t){return this.items.includes(t)}hasWildcardAuthority(t,e){const r=e?this.GQL_WILDCARD:this.WILDCARD;let i=!1;for(const e of this.items){if(!e.endsWith(r))continue;const s=e.substring(0,e.length-r.length);if(t.startsWith(s)){i=!0;break}}return i}getCustomRoles(){return this.getItems().filter(t=>0===t.indexOf(J.CUSTOM_PREFIX)).map(t=>t.substring(J.CUSTOM_PREFIX.length))}toUIModel(){const t={[J.READ_REPO]:{},[J.WRITE_REPO]:{},[J.GRAPHQL]:{}};return tt(this.getItems()).getItems().forEach(e=>{if(e.startsWith(J.READ_REPO_PREFIX)||e.startsWith(J.WRITE_REPO_PREFIX)||e.startsWith(J.GRAPHQL_PREFIX)){const r=Q.getRepoFromAuthority(e);if(r){const{prefix:e,repo:i}=r;e===J.READ_REPO_PREFIX?t[J.READ_REPO][i]=!0:e===J.WRITE_REPO_PREFIX?t[J.WRITE_REPO][i]=!0:e===J.GRAPHQL_PREFIX&&(t[J.GRAPHQL][i]=!0)}}}),t}toGraphdbAuthoritiesModel(){return Z(this)}getRepositoriesPermissions(){const t={},e=this.getItems();for(const r of e){const e=Q.getRepoFromAuthority(r);if(e){const{prefix:r,repo:i}=e,s=t[i]??{read:!1,write:!1,graphql:!1};r===J.READ_REPO_PREFIX?s.read=!0:r===J.WRITE_REPO_PREFIX?s.write=!0:r===J.GRAPHQL_PREFIX&&(s.graphql=!0),t[i]=s}}return t}}class it{constructor(t){this.DEFAULT_VIS_GRAPH_SCHEMA=t?.DEFAULT_VIS_GRAPH_SCHEMA??!0,this.DEFAULT_INFERENCE=t?.DEFAULT_INFERENCE??!0,this.DEFAULT_SAMEAS=t?.DEFAULT_SAMEAS??!0,this.IGNORE_SHARED_QUERIES=t?.IGNORE_SHARED_QUERIES??!1,this.EXECUTE_COUNT=t?.EXECUTE_COUNT??!0,this.COOKIE_CONSENT=t?.COOKIE_CONSENT}toJSON(){return{DEFAULT_VIS_GRAPH_SCHEMA:this.DEFAULT_VIS_GRAPH_SCHEMA,DEFAULT_INFERENCE:this.DEFAULT_INFERENCE,DEFAULT_SAMEAS:this.DEFAULT_SAMEAS,IGNORE_SHARED_QUERIES:this.IGNORE_SHARED_QUERIES,EXECUTE_COUNT:this.EXECUTE_COUNT,COOKIE_CONSENT:this.COOKIE_CONSENT}}}let st=function(t){return t.ADMIN="admin",t.REPO_MANAGER="repoManager",t.USER="user",t}({});class nt extends C{constructor(t){super(),this.username=t?.username??"",this.password=t?.password,this.confirmPassword=t?.confirmPassword,this.authorities=t?.authorities??new rt,this.appSettings=t?.appSettings??new it,this.dateCreated=t?.dateCreated??null,this.gptThreads=t?.gptThreads??[],this.external=t?.external??!1}getUserType(){return this.authorities.hasAuthority(J.ROLE_ADMIN)?st.ADMIN:this.authorities.hasAuthority(J.ROLE_REPO_MANAGER)?st.REPO_MANAGER:st.USER}getUserTypeDescription(){const t=this.getUserType();return t===st.USER?"User":t===st.REPO_MANAGER?"Repository manager":t===st.ADMIN?"Administrator":"Unknown"}}class ot extends C{toUser(){return new nt({username:this.username,authorities:this.authorities,appSettings:this.appSettings,external:this.external})}static fromUser(t){return new ot({username:t.username,authorities:t.authorities,appSettings:t.appSettings,external:t.external})}constructor(t){super(),this.external=t?.external??!1,this.username=t?.username??"",this.password=t?.password??"",this.authorities=t?.authorities??new rt,this.grantedAuthoritiesUiModel=tt(t?.authorities??[]),this.appSettings=t?.appSettings??new it}getCookieConsent(){return this.appSettings.COOKIE_CONSENT}setAuthorities(t=new rt){return this.authorities=t,this.grantedAuthoritiesUiModel=tt(t.getItems()),this}setAppSettings(t=new it){return this.appSettings=t,this}}class at extends C{constructor(t){super(),t&&(this.clientId=t.clientId,this.issuer=t.issuer,this.tokenType=t.tokenType,this.tokenAudience=t.tokenAudience,this.tokenIssuer=t.tokenIssuer,this.oidcTokenEndpoint=t.oidcTokenEndpoint,this.oidcJwksUri=t.oidcJwksUri,this.oidcEndSessionEndpoint=t.oidcEndSessionEndpoint,this.oidcAuthorizationEndpoint=t.oidcAuthorizationEndpoint,this.oidcScopesSupported=t.oidcScopesSupported||[],this.oracleDomain=t.oracleDomain,this.proxyOidc=t.proxyOidc||!1,this.authFlow=t.authFlow,this.extraScopes=t.extraScopes,this.authorizeParameters=t.authorizeParameters,this.openIdTokenUrl=this.proxyOidc?"rest/openid/token":this.oidcTokenEndpoint,this.openIdKeysUri=this.proxyOidc?"rest/openid/jwks":this.oidcJwksUri,this.openIdEndSessionUrl=this.oidcEndSessionEndpoint,this.supportsOfflineAccess=this.oidcScopesSupported.includes("offline_access"))}}const ht=t=>new rt(t);class ut extends C{constructor(t){super(),this.appSettings=t.appSettings,t.authorities instanceof rt?this.authorities=t.authorities:this.authorities=ht(t.authorities??[]),this.enabled=t.enabled}}const ct=t=>{const e=new ut({});return e.appSettings=new it(t.appSettings),e.authorities=ht(t.authorities||[]),e.enabled=t.enabled,e};class lt extends C{constructor(t){super(),this.authImplementation=t.authImplementation,this.enabled=t.enabled,this.passwordLoginEnabled=t.passwordLoginEnabled,this.freeAccess=ct(t.freeAccess),this.overrideAuth=ct(t.overrideAuth),this.openIdEnabled=t.openIdEnabled,this.freeAccessActive=t.freeAccess?.enabled,this.hasExternalAuth=t.hasExternalAuth,t.methodSettings?.openid&&(this.openidSecurityConfig=new at(t.methodSettings?.openid))}isEnabled(){return this.enabled??!1}isFreeAccessEnabled(){return this.freeAccess.enabled??!1}getFreeAccessAuthSettings(){return this.freeAccess}hasOverrideAuth(){return this.overrideAuth?.enabled??!1}}class dt extends C{pages={};isRestricted(t){return this.pages[t]??!1}setPageRestriction(t,e=!0){return this.pages[t]=e,this}}let pt=function(t){return t.READ="READ",t.WRITE="WRITE",t}({});class gt extends C{constructor(t){super(),this.expiryDate=t?.expiryDate,this.latestPublicationDate=t?.latestPublicationDate,this.licensee=t?.licensee||"",this.maxCpuCores=t?.maxCpuCores,this.product=t?.product,this.productType=t?.productType,this.licenseCapabilities=t?.licenseCapabilities,this.version=t?.version||"",this.installationId=t?.installationId||"",this.valid=t?.valid,this.typeOfUse=t?.typeOfUse||"",this.message=t?.message||"",this.present=t?.present||!1,this.usageRestriction=t?.usageRestriction||""}}class ft extends R{constructor(t){super(t)}}class mt{constructor(t){this.workbench=t.workbench,this.productType=t.productType,this.productVersion=t.productVersion,this.sesame=t.sesame,this.connectors=t.connectors,this.shortVersion=this.resolveShortVersion(t),this.ontop=t.ontop}resolveShortVersion(t){const e=t.productVersion;if(!e)return"";const r=/^(\d+\.\d+)/.exec(e),i=r?.[1]??e,s=/(-[^-]+)/.exec(e);return i+(s?.[1]??"")}}let yt=function(t){return t.CONSOLE="console",t}({}),vt=function(t){return t.DEBUG="DEBUG",t.INFO="INFO",t.WARN="WARN",t.ERROR="ERROR",t}({});const St=t=>Et[t],Et={[vt.DEBUG]:0,[vt.INFO]:1,[vt.WARN]:2,[vt.ERROR]:3};class xt{static SERVICE_INSTANCES=new Map;static get(t){if(!xt.SERVICE_INSTANCES.has(t.name)){const e=new t;xt.implementsLifecycleHooks(e)&&e.onCreated?.(),xt.SERVICE_INSTANCES.set(t.name,e)}return this.SERVICE_INSTANCES.get(t.name)}static implementsLifecycleHooks(t){return"object"==typeof t&&"function"==typeof t.onCreated}static getAllBySuperType(t){return Array.from(xt.SERVICE_INSTANCES.values()).filter(e=>e instanceof t)}}function wt(t){return xt.get(t)}const At=new Map([[yt.CONSOLE,wt(class{log(t,e,r){switch(t){case vt.DEBUG:console.debug(e,...r);break;case vt.INFO:console.info(e,...r);break;case vt.WARN:console.warn(e,...r);break;case vt.ERROR:console.error(e,...r);break;default:console.debug(e,...r)}}})]]);class bt{callbackFunctions=[];beforeChangeValidationPromises=[];afterValueChangeCallbackFunctions=[];setValue(t){n.deepEqual(this.value,t)||(this.value=this.getCopy(t),this.callbackFunctions.forEach(t=>t(this.getValue())),this.afterValueChangeCallbackFunctions.forEach(t=>t(this.getValue())))}getValue(){return this.getCopy(this.value)}subscribe(t,e,r){return this.callbackFunctions.push(t),e&&this.beforeChangeValidationPromises.push(e),r&&this.afterValueChangeCallbackFunctions.push(r),()=>{this.callbackFunctions=this.callbackFunctions.filter(e=>e!==t),this.beforeChangeValidationPromises=this.beforeChangeValidationPromises.filter(t=>t!==e),this.afterValueChangeCallbackFunctions=this.afterValueChangeCallbackFunctions.filter(t=>t!==r)}}async canUpdate(t){if(0===this.beforeChangeValidationPromises.length)return!0;const e=this.beforeChangeValidationPromises.map(e=>e(t));try{return(await Promise.all(e)).every(t=>t)}catch{return!1}}getCopy(t){if(null!=t)return n.hasCopyMethod(t)?t.copy():n.deepCopy(t)}}class It{subscribers=[];unsubFns=new T;subscribeToService(t){const e=this.subscribers.map(e=>t.subscribeAll(e.callback,e.beforeChangeValidationPromise,e.afterChangeCallback));return this.unsubFns.addAll(e),()=>e.forEach(t=>t())}subscribeToAllRegisteredContexts(t,e,r){const i=xt.getAllBySuperType(Ct).filter(t=>t.canSubscribeAll);for(const s of i)this.unsubFns.add(s.subscribeAll(t,e,r));const s={callback:t,beforeChangeValidationPromise:e,afterChangeCallback:r};this.subscribers.push(s);let n=!1;return()=>{if(n)return;n=!0,this.unsubFns.unsubscribeAll();const t=this.subscribers.indexOf(s);t>=0&&this.subscribers.splice(t,1)}}}class Ct{context=new Map;_canSubscribeAll=!1;onCreated(){this._canSubscribeAll=!0,xt.get(It).subscribeToService(this)}updateContextProperty(t,e){this.getOrCreateValueContext(t).setValue(e)}validatePropertyChange(t,e){return this.getOrCreateValueContext(t).canUpdate(e)}getContextPropertyValue(t){const e=this.context.get(t);return e?e.getValue():void 0}subscribe(t,e,r,i,s=!1){return!s&&e&&e(this.getContextPropertyValue(t)),i&&i(this.getContextPropertyValue(t)),this.getOrCreateValueContext(t).subscribe(e,r,i)}getDeserializedContext(){}deserializeProperty(t,e){const r=this.getDeserializedContext()?.[t];return r?r(e):e}subscribeAll(t,e,r,i=!1){const s=new T;for(const n of this.getContextFields())s.add(this.subscribe(n,t,e,r,i));return()=>s.unsubscribeAll()}getContextFields(){return Object.values(this).filter(t=>"string"==typeof t)}getOrCreateValueContext(t){let e=this.context.get(t);return e||(e=new bt,this.context.set(t,e)),e}canHandle(t){for(const e in this)if(this[e]===t)return!0;return!1}get canSubscribeAll(){return this._canSubscribeAll}}class Rt extends Ct{APPLICATION_CONFIGURATION="applicationConfiguration";updateApplicationConfiguration(t){this.updateContextProperty(this.APPLICATION_CONFIGURATION,t)}getApplicationConfiguration(){return this.getContextPropertyValue(this.APPLICATION_CONFIGURATION)}getApplicationLogoPath(t){const e=this.getApplicationConfiguration(),r=e.applicationLogoPaths,s=t===i.dark?i.light:i.dark;return r&&r[s]?r[s]:e.applicationLogoPath}}class Tt{loggers=At;constructor(t){this.module=t}debug(t,...e){this.log(vt.DEBUG,t,e)}error(t,...e){this.log(vt.ERROR,t,e)}info(t,...e){this.log(vt.INFO,t,e)}warn(t,...e){this.log(vt.WARN,t,e)}log(t,e,r){const i=this.loadConfiguration();i?.loggers.forEach(s=>{const n=this.loggers.get(s);if(!n)throw new Error(`Logger '${s}' not found`);if(St(i.minLogLevel)<=St(t)){const i=this.getFormattedMessage(t,e);n.log(t,i,r)}})}getFormattedMessage(t,e){return`[${t}] [${this.module}] [${(new Date).toLocaleString()}] ${e}`}loadConfiguration(){const t=wt(Rt).getApplicationConfiguration();return t?.loggerConfig}}class Ft{static loggerInstances=new Map;static getLoggerInstance(t){return this.loggerInstances.has(t)||this.loggerInstances.set(t,new Tt(t)),this.loggerInstances.get(t)}}class Pt{static get logger(){return Ft.getLoggerInstance("API")}}class Dt{logger=Pt.logger;constructor(t){this.value=t}getValue(){return this.value}isDefined(){return!n.isNullOrUndefined(this.value)}getValueOrDefault(t){return this.value||t}getAsJson(){if(null===this.value)return null;try{return JSON.parse(this.value)}catch(t){return this.logger.error("Error parsing JSON",t),null}}}class Ot{static GLOBAL_NAMESPACE="ontotext.gdb"}class Nt{constructor(t=[]){this.languages=t}getLanguageCodes(){return this.languages?.map(t=>t.key)}}const _t=["en","fr"];class Bt extends C{constructor(t){super(),this.defaultLanguage=t.defaultLanguage||"en",this.availableLanguages=t.availableLanguages||new Nt}}class Lt{constructor(t){this.policyAccepted=t?.policyAccepted,this.statistic=t?.statistic,this.thirdParty=t?.thirdParty,this.updatedAt=t?.updatedAt}hasChanged(){return void 0!==this.policyAccepted}static NOT_ACCEPTED_WITH_TRACKING(){return new Lt({policyAccepted:void 0,statistic:!0,thirdParty:!0})}static ACCEPTED_NO_TRACKING(){return new Lt({policyAccepted:!0,statistic:!1,thirdParty:!1})}static fromJSON(t){return new Lt({policyAccepted:t?.policyAccepted,statistic:t?.statistic,thirdParty:t?.thirdParty,updatedAt:t?.updatedAt})}}let Ht=function(t){return t.INFORMATION="INFORMATION",t.WARNING="WARNING",t.CRITICAL="CRITICAL",t}({});const kt={[Ht.INFORMATION]:0,[Ht.WARNING]:1,[Ht.CRITICAL]:2};class Ut extends C{constructor(t){super(),this.id=`${t.group}-${t.status}-${t.totalOperations}`,this.group=t.group,this.totalOperations=t.totalOperations,this.status=t.status}}class jt extends R{constructor(t){super(t)}}class Vt extends C{constructor(t){super(),this.status=t.status,this.allRunningOperations=t.allRunningOperations}toOperationsGroupSummary(){const t=new Map;return this.allRunningOperations.getItems().forEach(e=>{t.has(e.group)||t.set(e.group,new Ut({group:e.group,totalOperations:0,status:Ht.INFORMATION}));const r=t.get(e.group);r.totalOperations+=e.count,kt[e.status]>kt[r.status]&&(r.status=e.status)}),Array.from(t.values())}toOperationGroupSummaryList(){return new jt(this.toOperationsGroupSummary())}}class Mt extends R{constructor(t){super(t)}}let Kt=function(t){return t.UPDATES="updates",t.QUERIES="queries",t.IMPORT="imports",t.BACKUP_AND_RESTORE="backupAndRestore",t.CLUSTER_HEALTH="clusterHealth",t}({}),qt=function(t){return t.QUERY="QUERY",t.BACKUP="BACKUP",t.CLUSTER="CLUSTER",t.IMPORT="IMPORT",t}({});const Gt=[Kt.QUERIES,Kt.UPDATES,Kt.IMPORT],$t={[Kt.UPDATES]:"monitor/queries",[Kt.QUERIES]:"monitor/queries",[Kt.BACKUP_AND_RESTORE]:"monitor/backup-and-restore",[Kt.IMPORT]:"import",[Kt.CLUSTER_HEALTH]:"cluster"},Wt={[Kt.QUERIES]:qt.QUERY,[Kt.UPDATES]:qt.QUERY,[Kt.BACKUP_AND_RESTORE]:qt.BACKUP,[Kt.IMPORT]:qt.IMPORT,[Kt.CLUSTER_HEALTH]:qt.CLUSTER};class zt extends C{constructor(t){super(),this.value=t.value,this.status=t.status,this.type=t.type,this.id=`${t.status}-${t.type}-${t.value}`,this.count=this.getCount(this.type,this.value),this.group=Wt[this.type],this.href=$t[this.type],this.labelKey=this.getLabelKey(this.type,this.value)}getCount(t,e){return Gt.includes(t)?parseInt(e,10):0}getLabelKey(t,e){return Gt.includes(t)?t:e}}let Yt=function(t){return t.BOTTOM_RIGHT="bottom-right",t.BOTTOM_LEFT="bottom-left",t}({});class Xt{constructor(t){this.timeout=t?.timeout||5e3,this.onClick=t?.onClick,this.removeOnClick=t?.removeOnClick||!1,this.title=t?.title,this.translationParams=t?.translationParams}}class Jt extends Xt{constructor(t){super(),this.timeout=t.timeout,this.position=t.position}static getDefaultConfig(){return this.instance||(this.instance=new Jt({timeout:5e3,position:Yt.BOTTOM_RIGHT})),this.instance}}let Qt=function(t){return t.ERROR="error",t.INFO="info",t.SUCCESS="success",t.WARNING="warning",t}({});class Zt{static uuid(){const t=16;let e=(new Date).getTime(),r=1e3*(performance?.now()??0);return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let s=Math.random()*t;return e>0?(s=(e+s)%t|0,e=Math.floor(e/t)):(s=(r+s)%t|0,r=Math.floor(r/t)),("x"===i?s:3&s|8).toString(t)})}static generateRandomString(t){const e=new Uint32Array(t);return c.getCrypto().getRandomValues(e),Array.from(e,t=>("0"+t.toString(16)).substr(-2)).join("")}static hashCode(t){let e=0;for(let r=0,i=t.length;r<i;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}}class te extends C{constructor(){super(),this.id=Zt.uuid()}}class ee extends te{constructor(t,e,r){super(),this.type=t,this.message=e,this.config=r}}const re="create-toast-event";class ie extends R{constructor(t){super(t)}}let se=function(t){return t.CANCEL="cancel",t.EXIT="exit",t.DONT_SHOW_AGAIN="dontShowAgain",t}({});const ne="confirm-cancel-event";class oe{constructor(t,e){this.hasDontShowAgain=t,this.onClose=e}}class ae extends R{constructor(t){super(t)}}class he extends C{constructor(t){super(),this.setRadio(t.isRadio),this.setButtons(new ae(t.buttons))}getButtons(){return this.buttons}setButtons(t){this.buttons=t}isRadio(){return this.radio}setRadio(t){this.radio=t}selectButton(t){return this.isRadio()&&!t.selected&&(this.deselectAll(),t.selected=!0,t.callback()),this.copy()}deselectAll(){this.buttons.getItems().forEach(t=>t.selected=!1)}}class ue extends C{constructor(t){super(),this.id=t.id,this.label=t.label,this.selected=t.selected,this.callback=t.callback}}class ce extends R{constructor(t){super(t)}findSuggestionByValue(t){return this.items.find(e=>e.getValue()===t)}findHoveredSuggestion(){return this.items.find(t=>t.isHovered())}getHoveredSuggestionIndex(){return this.items.findIndex(t=>t.isHovered())}setHoveredStateAtIndex(t,e){const r=this.items[t];r&&r.setHovered(e)}unhoverAllSuggestions(){this.items.forEach(t=>t.setHovered(!1))}deselectAllSuggestions(){this.items.forEach(t=>t.setSelected(!1))}}class le extends C{constructor(t){super(),this.suggestions=t}hoverFirstSuggestion(){const t=this.suggestions.getFirstItem();if(t)return this.hoverSuggestion(t)}hoverSuggestion(t){return t&&(this.clearHoveredState(),t.setHovered(!0)),this.copy()}selectSuggestion(t){return t&&(this.clearSelectedState(),t.setSelected(!0)),this.copy()}getHoveredSuggestion(){return this.suggestions.findHoveredSuggestion()}hoverPreviousSuggestion(){const t=this.suggestions.getHoveredSuggestionIndex();return t>0&&(this.clearHoveredState(),this.suggestions.setHoveredStateAtIndex(t-1,!0)),this.copy()}hoverNextSuggestion(){const t=this.suggestions.getHoveredSuggestionIndex();return t<this.suggestions.size()-1&&(this.clearHoveredState(),this.suggestions.setHoveredStateAtIndex(t+1,!0)),this.copy()}clearSuggestions(){return this.suggestions=new ce,this.copy()}getByValue(t){return this.suggestions.findSuggestionByValue(t)}clearSelectedState(){this.suggestions.deselectAllSuggestions()}clearHoveredState(){this.suggestions.unhoverAllSuggestions()}}class de extends C{overrideToVisual=!1;constructor(t){super(),this.setId(t.id),this.setType(t.type),this.setValue(t.value),this.setDescription(t.description)}getId(){return this._id}setId(t){this._id=t}getType(){return this._type}setType(t){this._type=t}getValue(){return this._value}setValue(t){this._value=t}getDescription(){return this._description}setDescription(t){this._description=t}isHovered(){return this._hovered}setHovered(t){this._hovered=t}isSelected(){return this._selected}setSelected(t){this._selected=t}getOverrideToVisual(){return this.overrideToVisual}setOverrideToVisual(t){this.overrideToVisual=t}}let pe=function(t){return t.URI="uri",t.PREFIX="prefix",t}({});class ge{constructor(t,e){this.setSuggestion(t),this.setContext(e)}getSuggestion(){return this.suggestion}getContext(){return this.context}setContext(t){this.context=t}setSuggestion(t){this.suggestion=t}}let fe=function(t){return t.DATA_LOADED="DATA_LOADED",t}({});class me{constructor(t,e){this.entry=t,this.name=e}}class ye extends C{constructor(t){super(),this._pluginDefinitions=t}getPluginDefinitions(){return this._pluginDefinitions}}class ve extends R{}class Se{plugins=new ve;removePluginByFieldIdName(t){const e=this.fieldIdName;if(!e)return;const r=this.plugins.find(r=>r[e]===t[e]);r&&this.plugins.remove(r)}addPlugin(t){this.plugins.addItems([t])}getPlugins(){return this.plugins.getItems()}removePlugin(t){this.plugins.remove(t)}removeAllPlugins(){this.plugins.removeAll()}sort(t){this.plugins.sort(t)}}class Ee extends R{constructor(t){super(t)}}class xe extends C{_disabled=!1;constructor(t={}){super(),this._disabled=t.disabled??!1}get disabled(){return this._disabled}set disabled(t){this._disabled=t}}class we extends xe{constructor(t){super(),this._items=t.items||[]}get items(){return this._items}set items(t){this._items=t||[]}}class Ae{_order=0;_priority=0;constructor(t){this._label=t.label??"",this._labelKey=t.labelKey??"",this._href=t.href??"",this._documentationHref=t.documentationHref,this._order=t.order??this._order,this._priority=t.priority??this._priority,this._children=t.children,this._icon=t.icon,this._guideSelector=t.guideSelector,this._editions=t.editions,this._role=t.role,this._parent=t.parent,this._hrefFun=t.hrefFun,this._shouldShow=t.shouldShow,this._testSelector=t.testSelector}get label(){return this._label}set label(t){this._label=t}get labelKey(){return this._labelKey}set labelKey(t){this._labelKey=t}get href(){return this._href}set href(t){this._href=t}get documentationHref(){return this._documentationHref}set documentationHref(t){this._documentationHref=t}get children(){return this._children}set children(t){this._children=t}get icon(){return this._icon}set icon(t){this._icon=t}get guideSelector(){return this._guideSelector}set guideSelector(t){this._guideSelector=t}get editions(){return this._editions}set editions(t){this._editions=t}get role(){return this._role}set role(t){this._role=t}get parent(){return this._parent}set parent(t){this._parent=t}get hrefFun(){return this._hrefFun}set hrefFun(t){this._hrefFun=t}get shouldShow(){return this._shouldShow}set shouldShow(t){this._shouldShow=t}get testSelector(){return this._testSelector}set testSelector(t){this._testSelector=t}get order(){return this._order}set order(t){this._order=t}get priority(){return this._priority}set priority(t){this._priority=t}}class be extends xe{constructor(t){super(),this._url=t.url??"",this._module=t.module??"",this._path=t.path??"",this._chunk=t.chunk??"",this._controller=t.controller??"",this._templateUrl=t.templateUrl??"",this._title=t.title,this._reloadOnSearch=t.reloadOnSearch,this._helpInfo=t.helpInfo,this._documentationUrl=t.documentationUrl,this._allowAuthorities=t.allowAuthorities}get url(){return this._url}set url(t){this._url=t}get module(){return this._module}set module(t){this._module=t}get path(){return this._path}set path(t){this._path=t}get chunk(){return this._chunk}set chunk(t){this._chunk=t}get controller(){return this._controller}set controller(t){this._controller=t}get templateUrl(){return this._templateUrl}set templateUrl(t){this._templateUrl=t}get title(){return this._title}set title(t){this._title=t}get reloadOnSearch(){return this._reloadOnSearch}set reloadOnSearch(t){this._reloadOnSearch=t}get helpInfo(){return this._helpInfo}set helpInfo(t){this._helpInfo=t}get documentationUrl(){return this._documentationUrl}set documentationUrl(t){this._documentationUrl=t}get allowAuthorities(){return this._allowAuthorities}set allowAuthorities(t){this._allowAuthorities=t}}class Ie extends xe{constructor(t){super(t),this.guideBlockName=t.guideBlockName||"",this.getStep=t.getStep,this.getSteps=t.getSteps}}class Ce extends Se{static NAME="main.menu";name=Ce.NAME}class Re extends Se{static NAME="route";name=Re.NAME}class Te extends Se{static NAME="guide.step";name=Te.NAME;fieldIdName="guideBlockName"}class Fe extends Se{static NAME="themes";name=Fe.NAME}class Pe extends Error{constructor(t){super(`Guide step "${t}" is not correctly implemented. You need to implement either getStep or getSteps method in the GuidePlugin.`)}}class De extends C{constructor(t){super(),this.guideId=t.guideId?String(t.guideId):"",this.guideName=t.guideName||"",this.guideDescription=t.guideDescription||"",this.options=t.options??{},this.steps=t.steps??[],this.guideLevel=t.guideLevel,this.guideOrder=t.guideOrder}getId(){return this.guideId}getName(){return this.guideName}getDescription(){return this.guideDescription}getSteps(){return this.steps}getOptions(){return this.options}getTranslatedGuideName(){return this.options.translatedGuideName}setTranslatedGuideName(t){return this.options.translatedGuideName=t,this}getTranslatedGuideDescription(){return this.options.translatedGuideDescription}setTranslatedGuideDescription(t){return this.options.translatedGuideDescription=t,this}getRepositoryId(){return this.options.repositoryId}setRepositoryId(t){return this.options.repositoryId=t,this}getRepositoryIdBase(){return this.options.repositoryIdBase}setGuideLevelLabel(t){return this.guideLevelLabel=t,this}getGuideLevelLabel(){return this.guideLevelLabel}toStepsDescriptions(t,e){return this.getSteps().flatMap(r=>this._getSteps(r,this.getOptions(),t,e))}_getSteps(t,e,r,i){if(Array.isArray(t))return t.flatMap(t=>this._getSteps(t,{...e},r,i));const s=r.find(e=>e.guideBlockName===t.guideBlockName);if(!s)return[];const o={...s.options??{},...t.options,...e};let a=[];if(s.getSteps)a=a.concat(this._getSteps(n.deepCopy(s.getSteps(o,i)),e,r,i));else{if(!s.getStep)throw new Pe(s.guideBlockName);a.push(n.deepCopy(s.getStep(o,i)))}return a.forEach((t,e)=>{t.stepN=e,t.stepsTotalN=a.length}),a}}let Oe=function(t){return t.ERROR="error",t.INFO="info",t.SUCCESS="success",t.WARNING="warning",t}({});class Ne extends te{constructor(t){super(),this.code=t}withTitle(t){return this.title=t,this}withType(t){return this.type=t,this}withParameters(t){return this.parameters=t,this}static info(t){return new Ne(t).withType(Oe.INFO)}static error(t){return new Ne(t).withType(Oe.ERROR)}static warning(t){return new Ne(t).withType(Oe.WARNING)}static success(t){return new Ne(t).withType(Oe.SUCCESS)}}let _e=function(t){return t.SHOULD_TOAST="shouldToast",t}({});class Be{priority=0}class Le extends R{constructor(t){super(t)}}class He{constructor(t){this.url=t.url,this.method=t.method,this.headers={...t.headers},this.body=t.body}}class ke{constructor(t){this.status=t.status,this.statusText=t.statusText,this.headers=t.headers,this.config=t.config,this.originalResponse=t.originalResponse}}class Ue extends ke{constructor(t){super(t),this.data=t.data}}class je extends ke{constructor(t){super(t),this.data=t.data??null,this.status>=200&&this.status<300?this.message=`Http failure during parsing for ${t.config.url||"(unknown url)"}`:this.message=`Http failure response for ${t.config.url||"(unknown url)"}: ${t.status} ${t.statusText}`}get isClientError(){return this.status>=400&&this.status<500}get isServerError(){return this.status>=500&&this.status<600}}class Ve extends R{constructor(t=[]){super(t)}getFirstQuery(){return this.getFirstItem()}}class Me{constructor(t){this.queryName=t.queryName??"",this.query=t.query??"",this.owner=t.owner??"",this.isPublic=t.isPublic??!1,this.readonly=t.readonly??!1}}let Ke=function(t){return t.CENTER="center",t.START="start",t}({});class qe{constructor(t,e,r,i,s,n){this.status=t,this.command=e,this.messageLabelKey=r,this.parameters=i,this.message=s,this.iri=n}}const Ge={ERROR:"error",SUCCESS:"success"};let $e=function(t){return t.CREATE="create",t.REPAIR="repair",t.DROP="drop",t}({});class We extends C{constructor(t){super(),this.id=t.id,this.name=t.name,this.description=t.description,this.owner=t.owner,this.repositoryId=t.repositoryId,this.hint=t.hint,this.shared=t.shared,this.startMode=t.startMode,this.startIRI=t.startIRI,this.startIRILabel=t.startIRILabel,this.startQueryIncludeInferred=t.startQueryIncludeInferred,this.startQuerySameAs=t.startQuerySameAs,this.startGraphQuery=t.startGraphQuery,this.expandQuery=t.expandQuery,this.predicateLabelQuery=t.predicateLabelQuery,this.resourcePropertiesQuery=t.resourcePropertiesQuery,this.resourceQuery=t.resourceQuery}}class ze extends R{constructor(t){super(t)}getByStartMode(t){return this.items.filter(e=>e.startMode===t)}}let Ye=function(t){return t.SEARCH="search",t.NODE="node",t.QUERY="query",t}({}),Xe=function(t){return t.RETURN_URL="r",t.NO_ACCESS="noaccess",t.EXPIRED="expired",t}({});class Je{getStorage(){return localStorage}get(t,e=!0){const r=this.getStorage().getItem(e?this.getPrefixedKey(t):t);return new Dt(r)}getAsJson(t){const e=this.getStorage().getItem(t);if(e)try{return JSON.parse(e)}catch(e){return console.error(`Error parsing JSON from localStorage for key ${t}:`,e),null}return null}storeValue(t,e){this.getStorage().setItem(this.getPrefixedKey(t),e)}remove(t,e=!0){this.getStorage().removeItem(e?this.getPrefixedKey(t):t)}getPrefixedKey(t){const e=`${Ot.GLOBAL_NAMESPACE}.${this.NAMESPACE}.`,r=`${this.NAMESPACE}.`;return t.startsWith(e)?t:t.startsWith(r)?`${Ot.GLOBAL_NAMESPACE}.${t}`:`${e}${t}`}}class Qe{logger=Pt.logger;handleStorageChange(t){const e=t.key?.substring(Ot.GLOBAL_NAMESPACE.length+1);let r="",i="";e&&(r=e.substring(0,e.indexOf(".")),i=e.substring(r.length+1));const s=this.resolveHandler(r,i);if(s){let e;null!==t.newValue&&(e=s.deserializeProperty(i,t.newValue)),s.updateContextProperty(i,e)}}resolveHandler(t,e){if(!t)return void this.logger.warn("Namespace is required to resolve a context property change handler.");const r=xt.getAllBySuperType(Ct).find(t=>t.canHandle(e));if(r)return r;this.logger.warn(`No context property change handler found for namespace: ${t} and property: ${e}`)}}class Ze extends Je{NAMESPACE="application";SETTINGS="settings";logger=Pt.logger;OLD_SETTINGS_KEY="ls.workbench-settings";migrate(){if(this.get(this.SETTINGS).getValue())return;const t=this.getAsJson(this.OLD_SETTINGS_KEY);if(!t)return;this.logger.info("Begin migrating legacy application settings to new format...");const e=new s;e.theme=t.theme,t.mode&&t.mode===i.dark?e.themeMode=i.dark:e.themeMode=i.light,this.setApplicationSettings(e),this.getStorage().removeItem(this.OLD_SETTINGS_KEY),this.logger.info("Migration of legacy application settings completed. Old settings key removed.")}set(t,e){this.storeValue(t,e)}setApplicationSettings(t){this.set(this.SETTINGS,JSON.stringify(t))}getApplicationSettings(){const t=this.get(this.SETTINGS).getAsJson();return t?new s(t):new s}getThemeMode(){return this.getApplicationSettings().themeMode}isThemeModePresent(){const t=this.get(this.SETTINGS).getAsJson();return!!t&&void 0!==new s(t).themeMode}}class tr extends Ct{RUNTIME_CONFIGURATION="runtimeConfiguration";THEME_MODE="themeMode";updateRuntimeConfiguration(t){const e={...this.getRuntimeConfiguration()??{},...t};this.updateContextProperty(this.RUNTIME_CONFIGURATION,e)}onRuntimeConfigurationChanged(t){return this.subscribe(this.RUNTIME_CONFIGURATION,t)}getRuntimeConfiguration(){return this.getContextPropertyValue(this.RUNTIME_CONFIGURATION)}updateThemeMode(t){this.updateContextProperty(this.THEME_MODE,t)}onThemeModeChanged(t,e=!1){return this.subscribe(this.THEME_MODE,t,void 0,void 0,e)}}class er{applicationSettingsStorageService=wt(Ze);runtimeConfigurationContextService=wt(tr);rootSelector=":root";darkClass=i.dark;static CODE_EDITOR_DARK_THEME="moxer";applyDarkModeIfEnabled(){const t=this.isDarkModeEnabledInSettings()?i.dark:i.light;this.setThemeMode(t)}getCurrentThemeMode(){return this.isThemeModeSet()?this.isDarkModeEnabledInSettings()?i.dark:i.light:this.getPreferredScheme()}setThemeMode(t){const e=this.getRootElement();if(!e)return;const r=t===i.dark;e.classList.toggle(this.darkClass,r),this.runtimeConfigurationContextService.updateThemeMode(r?i.dark:i.light)}applyColorScheme(){this.isThemeModeSet()?this.applyDarkModeIfEnabled():this.setThemeMode(this.getPreferredScheme())}applyNewColorScheme(t){this.isThemeModeSet()||this.setThemeMode(t)}isDarkModeApplied(){const t=this.getRootElement();if(!t)return!1;const e=i.dark;return t.classList.contains(e)}isDarkModeEnabledInSettings(){const t=this.applicationSettingsStorageService.getApplicationSettings();return t?.themeMode===i.dark}isThemeModeSet(){return this.applicationSettingsStorageService.isThemeModePresent()}getCodeEditorThemeName(){return this.isDarkModeApplied()?er.CODE_EDITOR_DARK_THEME:void 0}getPreferredScheme(){return c.matchMedia("(prefers-color-scheme: dark)").matches?i.dark:i.light}getRootElement(){return document.querySelector(this.rootSelector)??null}}class rr{preProcessors=new R;postProcessors=new R;async preProcess(t){let e=t;for(const t of this.preProcessors.getItems())t.shouldProcess(e)&&(e=await t.process(e));return e}async postProcess(t){let e=t;for(const t of this.postProcessors.getItems())t.shouldProcess(e)&&(e=await t.process(e));return e}registerRequestInterceptors(t){this.preProcessors.addItems(t.getItems()),this.sortInterceptors(this.preProcessors)}registerResponseInterceptors(t){this.postProcessors.addItems(t.getItems()),this.sortInterceptors(this.postProcessors)}sortInterceptors(t){t.sort((t,e)=>e.priority-t.priority)}}class ir{emit(t){const e=new CustomEvent(t.NAME,{detail:t.payload});return this.getHostElement().dispatchEvent(e),e}subscribe(t,e){const r=t=>{t instanceof CustomEvent&&e(t.detail)};return this.getHostElement().addEventListener(t,r),()=>this.getHostElement().removeEventListener(t,r)}getHostElement(){return document.body}}const sr="http-request-done-event";class nr{interceptorService=xt.get(rr);eventEmitter=new ir;get(t,e){const{params:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"GET",{params:r,headers:i},"response"):this.request(t,"GET",{params:r,headers:i},"body")}post(t,e){const{body:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"POST",{body:r,headers:i},"response"):this.request(t,"POST",{body:r,headers:i},"body")}put(t,e){const{body:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"PUT",{body:r,headers:i},"response"):this.request(t,"PUT",{body:r,headers:i},"body")}patch(t,e){const{body:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"PATCH",{body:r,headers:i},"response"):this.request(t,"PATCH",{body:r,headers:i},"body")}delete(t,e){const{headers:r,responseType:i="body"}=e??{};return"response"===i?this.request(t,"DELETE",{headers:r},"response"):this.request(t,"DELETE",{headers:r},"body")}uploadFile(t,e,r="file",i,s){const n=new FormData;n.append(r,e,e instanceof File?e.name:void 0),s&&Object.entries(s).forEach(([t,e])=>{n.append(t,e)});const o={...i};return delete o["Content-Type"],this.post(t,{body:n,headers:o,responseType:"response"})}encodeURIComponentStrict(t){return encodeURIComponent(t).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16)})}request(t,e,r={},i="response"){const{fullUrl:s,headers:n}=this.getRequestConfig(t,r),o=new He({url:s,method:e,headers:n,body:r.body});let a;return this.executeRequest(o).then(async t=>{if(a=t,!t.ok){const e=await this.getDataFromResponse(i,t),r=new je({status:t.status,statusText:t.statusText,headers:this.extractHeaders(t),config:o,originalResponse:t,data:e});return Promise.reject(r)}const e=await this.getDataFromResponse(i,t);return"body"===i?e:new Ue({status:t.status,statusText:t.statusText,headers:this.extractHeaders(t),config:o,originalResponse:t,data:e})}).catch(t=>{if(t instanceof je)return Promise.reject(t);a??=t;const e=new je({status:a.status,statusText:a.statusText,headers:this.extractHeaders(a),config:o,originalResponse:a,data:null});return t?.message&&(e.message=t.message),Promise.reject(e)}).finally(()=>this.eventEmitter.emit({NAME:sr,payload:void 0}))}async getDataFromResponse(t,e){let r=null;if(r=await e.text(),!t||"body"===t||"response"===t)try{r=JSON.parse(r)}catch{}return r}getRequestConfig(t,e){const r=this.buildQueryParams(e.params),i=`${t}${r?`?${r}`:""}`,s=e.body instanceof FormData,n={Accept:"application/json, text/plain, */*",...e.headers};return s||(n["Content-Type"]=e.headers?.["Content-Type"]??"application/json"),{fullUrl:i,headers:n}}formatBody(t,e){return e?e instanceof FormData?e:t["Content-Type"]?.includes("application/json")?JSON.stringify(e):(t["Content-Type"]?.includes("application/x-www-form-urlencoded"),e):null}executeRequest(t){return this.interceptorService.preProcess(t).then(t=>{const e=this.formatBody(t.headers,t.body);return fetch(t.url,{method:t.method,headers:t.headers,body:e})}).then(t=>this.interceptorService.postProcess(t))}extractHeaders(t){const e={};return t.headers.forEach((t,r)=>{e[r]=t}),e}buildQueryParams(t={}){return new URLSearchParams(t).toString()}}class or extends nr{I18N_ENDPOINT="assets/i18n";getLanguage(t){return this.get(`${this.I18N_ENDPOINT}/${t}.json`)}getLanguageConfiguration(){return this.get(`${this.I18N_ENDPOINT}/language-config.json`)}}class ar extends Je{NAMESPACE="i18n";set(t,e){this.storeValue(t,e)}}class hr extends Ct{LANGUAGE_CONFIG="languageConfig";SELECTED_LANGUAGE="selectedLanguage";LANGUAGE_BUNDLE="languageBundle";DEFAULT_BUNDLE="defaultBundle";updateSelectedLanguage(t){this.validatePropertyChange(this.SELECTED_LANGUAGE,t).then(e=>{if(e){const e=t||xt.get(lr).getDefaultLanguage();xt.get(ar).set(this.SELECTED_LANGUAGE,e),this.updateContextProperty(this.SELECTED_LANGUAGE,t)}})}onSelectedLanguageChanged(t,e,r=!1){return this.subscribe(this.SELECTED_LANGUAGE,t,e,void 0,r)}updateLanguageBundle(t){this.updateContextProperty(this.LANGUAGE_BUNDLE,t)}onLanguageBundleChanged(t){return this.subscribe(this.LANGUAGE_BUNDLE,t)}getLanguageBundle(){return this.getContextPropertyValue(this.LANGUAGE_BUNDLE)}updateDefaultBundle(t){this.updateContextProperty(this.DEFAULT_BUNDLE,t)}getDefaultBundle(){return this.getContextPropertyValue(this.DEFAULT_BUNDLE)}getLanguageConfig(){return this.getContextPropertyValue(this.LANGUAGE_CONFIG)}setLanguageConfig(t){this.updateContextProperty(this.LANGUAGE_CONFIG,t)}getSelectedLanguage(){return this.getContextPropertyValue(this.SELECTED_LANGUAGE)}getDefaultLanguage(){return this.getLanguageConfig().defaultLanguage}}class ur extends C{constructor(t,e){super(),this.key=t,this.name=e}}function cr(t){const e=t.map(t=>new ur(t.key,t.name));return new Nt(e)}class lr{languageRestService=xt.get(or);languageContextService=xt.get(hr);getSupportedLanguages(){const t=this.languageContextService.getLanguageConfig();return t?t.availableLanguages.getLanguageCodes():_t}getLanguage(t){return this.languageRestService.getLanguage(t)}getLanguageConfiguration(){return this.languageRestService.getLanguageConfiguration().then(t=>{return new Bt({defaultLanguage:(e=t).defaultLanguage,availableLanguages:cr(e.availableLanguages)});var e})}getDefaultLanguage(){const t=this.languageContextService.getLanguageConfig();return t?t.defaultLanguage:"en"}}class dr extends nr{static REPOSITORIES_ENDPOINT="rest/repositories";getRepositories(){return this.get(`${dr.REPOSITORIES_ENDPOINT}/all`)}getRepositorySizeInfo(t){return this.get(`${dr.REPOSITORIES_ENDPOINT}/${t.id}/size?location=${encodeURIComponent(t.location)}`)}}const pr=t=>{if(!t||"object"!=typeof t)return new D;const e=[];return Object.entries(t).forEach(([,t])=>{Array.isArray(t)&&t.forEach(t=>{const r=new F({id:t.id,title:t.title,type:b(_,t.type),sesameType:t.sesameType,uri:t.uri,externalUrl:t.externalUrl,location:t.location,state:b(N,t.state),local:t.local,readable:t.readable,writable:t.writable,unsupported:t.unsupported});e.push(r)})}),new D(e)};class gr{constructor(){this.repositoryRestService=wt(dr)}async getRepositories(){const t=await this.repositoryRestService.getRepositories();return pr(t)}async getRepositorySizeInfo(t){return e=await this.repositoryRestService.getRepositorySizeInfo(t),new O(e);var e}}class fr extends Je{NAMESPACE="repository";logger=Pt.logger;SELECTED_REPOSITORY="selectedRepository";set(t,e){e?this.storeValue(t,e):this.remove(t)}setRepositoryReference(t){this.set(this.SELECTED_REPOSITORY,this.serializeRepositoryReference(t))}getRepositoryReference(){return this.deserializeRepositoryReference(this.get(this.SELECTED_REPOSITORY).getValueOrDefault('{"id": "", "location": ""}'))}removeRepositoryReference(){this.remove(this.SELECTED_REPOSITORY)}getActiveRepositoryId(){const t=this.getRepositoryReference();return t?.id}serializeRepositoryReference(t){return JSON.stringify(t)}deserializeRepositoryReference(t){if("string"==typeof t)try{return JSON.parse(t)}catch(t){this.logger.error("Error parsing repository reference",t)}}}class mr extends Ct{SELECTED_REPOSITORY="selectedRepository";REPOSITORY_LIST="repositoryList";updateSelectedRepository(t){const e=wt(fr),r=this.findRepository(t);return this.validatePropertyChange(this.SELECTED_REPOSITORY,r).then(i=>{i&&(r?e.setRepositoryReference(r.toRepositoryReference()):t||e.removeRepositoryReference(),this.updateContextProperty(this.SELECTED_REPOSITORY,r))})}getSelectedRepository(){return this.getContextPropertyValue(this.SELECTED_REPOSITORY)}onSelectedRepositoryChanged(t,e){return this.subscribe(this.SELECTED_REPOSITORY,t,e)}updateRepositoryList(t){return this.updateContextProperty(this.REPOSITORY_LIST,t)}getRepositoryList(){return this.getContextPropertyValue(this.REPOSITORY_LIST)||new D([])}onRepositoryListChanged(t){return this.subscribe(this.REPOSITORY_LIST,t)}getDeserializedContext(){return{[this.SELECTED_REPOSITORY]:this.deserializeRepository}}deserializeRepository=t=>new F(JSON.parse(t));findRepository(t,e=!1){if(t)return this.getRepositoryList().findRepository(t.id,t.location,e)}repositoryExists(t,e=!1){return void 0!==this.findRepository(t,e)}isActiveRepoOntopType(){return this.getSelectedRepository()?.isOntop()??!1}}class yr{GRAPHQL_REPO_AUTHORITY="GRAPHQL";SYSTEM_REPOSITORY_ID="SYSTEM";isSystemRepository(t){return t.id===this.SYSTEM_REPOSITORY_ID}getCurrentGqlRepoAuthority(t,e){return`${this.getCurrentRepoAuthority(t,e)}:${this.GRAPHQL_REPO_AUTHORITY}`}getOverallGqlRepoAuthority(t){return`${this.getOverallRepoAuthority(t)}:${this.GRAPHQL_REPO_AUTHORITY}`}getLocationSpecificId(t){return t.location?`${t.id}@${t.location}`:t.id}getCurrentRepoAuthority(t,e){return`${t}_REPO_${e}`}getOverallRepoAuthority(t){return`${t}_REPO_*`}}class vr extends nr{getActiveRepositoryLocation(){return this.get("rest/locations/active")}}const Sr=t=>new L({uri:t.uri,label:t.label,username:t.username??void 0,password:t.password??void 0,authType:t.authType?b(X,t.authType):void 0,locationType:t.locationType?b(H,t.locationType):void 0,active:t.active,local:t.local,system:t.system,errorMsg:t.errorMsg??"",defaultRepository:t.defaultRepository??void 0});class Er{constructor(){this.locationRestService=xt.get(vr)}getActiveRepositoryLocation(){return this.locationRestService.getActiveRepositoryLocation().then(Sr)}}class xr extends Ct{ACTIVE_REPOSITORY_LOCATION="activeRepositoryLocation";IS_LOADING="isLoading";updateActiveRepositoryLocation(t){this.updateContextProperty(this.ACTIVE_REPOSITORY_LOCATION,t)}onActiveLocationChanged(t){return this.subscribe(this.ACTIVE_REPOSITORY_LOCATION,t)}updateIsLoading(t){this.updateContextProperty(this.IS_LOADING,t)}onIsLoadingChanged(t){return this.subscribe(this.IS_LOADING,t)}}class wr extends nr{LICENSE_ENDPOINT="rest/graphdb-settings/license";LICENSE_INFO_ENDPOINT="rest/info/license";getLicense(){return this.get(this.LICENSE_ENDPOINT)}getIsLicenseHardcoded(){return this.get(`${this.LICENSE_ENDPOINT}/hardcoded`)}registerLicense(t){const e=new Uint8Array(t.length);for(let r=0;r<e.length;r++)e[r]=t.charCodeAt(r);return this.post(this.LICENSE_ENDPOINT,{body:e,headers:{"Content-Type":"application/octet-stream"}})}unregisterLicense(){return this.delete(this.LICENSE_ENDPOINT)}extractFromLicenseFile(t){return this.uploadFile(`${this.LICENSE_INFO_ENDPOINT}/to-base-64`,t,void 0,{Accept:"text/plain"}).then(t=>t.data)}validateLicense(t){return this.post(`${this.LICENSE_INFO_ENDPOINT}/validate`,{body:t,headers:{"Content-Type":"text/plain"}})}}let Ar=function(t){return t.GRAPHDB_LITE="GRAPHDB_LITE",t.GRAPHDB_SE="GRAPHDB_SE",t.GRAPHDB_ENTERPRISE="GRAPHDB_ENTERPRISE",t.GRAPHDB_SANDBOX="GRAPHDB_SANDBOX",t}({}),br=function(t){return t.FREE="free",t.STANDARD="standard",t.ENTERPRISE="enterprise",t.SANDBOX="sandbox",t}({});function Ir(t){return Object.values(br).find(e=>e===t)}const Cr=t=>{return new gt({expiryDate:t?.expiryDate?new Date(t.expiryDate):void 0,latestPublicationDate:t?.latestPublicationDate?new Date(t.latestPublicationDate):void 0,licensee:t?.licensee||"",maxCpuCores:t?.maxCpuCores,product:(e=t?.product,Object.values(Ar).find(t=>t===e)),productType:Ir(t?.productType),licenseCapabilities:Rr(t?.licenseCapabilities),version:t?.version||"",installationId:t?.installationId||"",valid:t?.valid,typeOfUse:t?.typeOfUse||"",message:t?.message||"",present:t?.present||!1,usageRestriction:t?.usageRestriction||""});var e};function Rr(t){const e=(t??[]).filter(t=>t?.trim());return new ft(e)}class Tr extends Ct{GRAPHDB_LICENSE="graphDbLicense";IS_LICENSE_HARDCODED="isLicenseHardcoded";updateGraphdbLicense(t){this.updateContextProperty(this.GRAPHDB_LICENSE,t)}onLicenseChanged(t){return this.subscribe(this.GRAPHDB_LICENSE,t)}getLicenseSnapshot(){return this.getContextPropertyValue(this.GRAPHDB_LICENSE)}updateIsLicenseHardcoded(t){this.updateContextProperty(this.IS_LICENSE_HARDCODED,!!t)}onIsLicenseHardcodedChanged(t){return this.subscribe(this.IS_LICENSE_HARDCODED,t)}isLicenseHardcodedSnapshot(){return this.getContextPropertyValue(this.IS_LICENSE_HARDCODED)}}class Fr{licenseRestService=wt(wr);licenseContextService=wt(Tr);trackableProductTypes=[br.FREE,br.SANDBOX];trackableTypesOfUse=["evaluation","this is an evaluation license"];async updateLicenseStatus(){const t=await this.getIsLicenseHardcoded();this.licenseContextService.updateIsLicenseHardcoded(t);const e=await this.getLicense();return this.licenseContextService.updateGraphdbLicense(e),e}async getLicense(){const t=await this.licenseRestService.getLicense();return Cr(t)}registerLicense(t){return this.licenseRestService.registerLicense(t).then(t=>Cr(t))}unregisterLicense(){return this.licenseRestService.unregisterLicense()}extractFromLicenseFile(t){return this.licenseRestService.extractFromLicenseFile(t)}getIsLicenseHardcoded(){return this.licenseRestService.getIsLicenseHardcoded()}validateLicense(t){return this.licenseRestService.validateLicense(t).then(t=>Cr(t))}isTrackableLicense(){const t=this.licenseContextService.getLicenseSnapshot(),e=t?.typeOfUse?.toLowerCase()||"",r=t?.productType;return!t?.present||this.trackableProductTypes.some(t=>t===r)||this.trackableTypesOfUse.includes(e)}}class Pr extends Ct{PRODUCT_INFO="productInfo";updateProductInfo(t){this.updateContextProperty(this.PRODUCT_INFO,t)}onProductInfoChanged(t){return this.subscribe(this.PRODUCT_INFO,t)}getProductInfo(){return this.getContextPropertyValue(this.PRODUCT_INFO)}}class Dr extends nr{VERSION_URL="rest/info/version";getProductInfoLocal(){return this.get(`${this.VERSION_URL}?local=1`)}}class Or{productInfoRestService=wt(Dr);async getProductInfoLocal(){const t=await this.productInfoRestService.getProductInfoLocal();return new mt({workbench:(e=t).Workbench||"",productType:e.productType||"",productVersion:e.productVersion||"",sesame:e.sesame||"",connectors:e.connectors||"",ontop:e.Ontop||""});var e}}class Nr extends Ct{RESTRICTED_PAGES="restrictedPages";SECURITY_CONFIG="securityConfig";AUTHENTICATED_USER="authenticatedUser";JSON_WEB_KEYS_SET="jsonWebKeysSet";IS_LOGGED_IN="isLoggedIn";getRestrictedPages(){return this.getContextPropertyValue(this.RESTRICTED_PAGES)||new dt}updateRestrictedPages(t){this.updateContextProperty(this.RESTRICTED_PAGES,t)}onRestrictedPagesChanged(t){return this.subscribe(this.RESTRICTED_PAGES,t)}updateSecurityConfig(t){this.updateContextProperty(this.SECURITY_CONFIG,t)}onSecurityConfigChanged(t){return this.subscribe(this.SECURITY_CONFIG,t)}getSecurityConfig(){return this.getContextPropertyValue(this.SECURITY_CONFIG)}updateAuthenticatedUser(t){this.updateContextProperty(this.AUTHENTICATED_USER,t)}onAuthenticatedUserChanged(t){return this.subscribe(this.AUTHENTICATED_USER,t)}getAuthenticatedUser(){return this.getContextPropertyValue(this.AUTHENTICATED_USER)}updateJsonWebKeysSet(t){this.updateContextProperty(this.JSON_WEB_KEYS_SET,t)}getJsonWebKeysSet(){return this.getContextPropertyValue(this.JSON_WEB_KEYS_SET)}updateIsLoggedIn(t){this.updateContextProperty(this.IS_LOGGED_IN,t)}getIsLoggedIn(){return this.getContextPropertyValue(this.IS_LOGGED_IN)}onUserLoginStatusChanged(t){return this.subscribe(this.IS_LOGGED_IN,t)}}class _r extends Je{accessToken="access_token";idToken="id_token";refreshToken="refresh_token";tokenType="token_type";pkceState="pkce_state";pkceCodeVerifier="pkce_code_verifier";nonce="nonce";returnUrl="return_url";NAMESPACE="auth.openid";set(t,e){this.storeValue(t,e)}setAccessToken(t){this.set(this.accessToken,t)}getAccessToken(){return this.get(this.accessToken)}clearAccessToken(){this.remove(this.accessToken)}setIdToken(t){this.set(this.idToken,t)}getIdToken(){return this.get(this.idToken)}clearIdToken(){this.remove(this.idToken)}setRefreshToken(t){this.set(this.refreshToken,t)}getRefreshToken(){return this.get(this.refreshToken)}clearRefreshToken(){this.remove(this.refreshToken)}setTokenType(t){this.set(this.tokenType,t)}getTokenType(){return this.get(this.tokenType)}clearTokenType(){this.remove(this.tokenType)}setPkceState(t){this.set(this.pkceState,t)}getPkceState(){return this.get(this.pkceState)}clearPkceState(){this.remove(this.pkceState)}setPkceCodeVerifier(t){this.set(this.pkceCodeVerifier,t)}getPkceCodeVerifier(){return this.get(this.pkceCodeVerifier)}clearPkceCodeVerifier(){this.remove(this.pkceCodeVerifier)}setNonce(t){this.set(this.nonce,t)}getNonce(){return this.get(this.nonce)}clearNonce(){this.remove(this.nonce)}setReturnUrl(t){this.set(this.returnUrl,t)}getReturnUrl(){return this.get(this.returnUrl)}clearReturnUrl(){this.remove(this.returnUrl)}clearTokens(){this.clearAccessToken(),this.clearIdToken(),this.clearRefreshToken()}}var Br=r(355);class Lr extends Error{constructor(t){super(),this.text=t}get message(){return`${this.constructor.name}: ${this.text}`}}class Hr extends Lr{}class kr extends Hr{constructor(){super("Invalid JWT token")}}let Ur=function(t){return t.ACCESS="access",t.ID="id",t.REFRESH="refresh",t}({});class jr{logger=Pt.logger;openidStorageService=wt(_r);securityContextService=wt(Nr);REFRESH_TOKEN_TOLERANCE=5e3;hasValidIdToken(t){return this.getTokenByType(Ur.ID)?this.verifyToken(Ur.ID,t)?(this.logger.debug("OpenID: valid id token found"),!0):(this.logger.debug("OpenID: stale id token"),!1):(this.logger.debug("OpenID: no id token"),!1)}hasValidRefreshToken(){const t=this.getTokenByType(Ur.REFRESH);if(!t)return this.logger.debug("OpenID: no refresh token"),!1;let e;try{e=this.getTokenPayload(t)}catch{return!0}return!(e.nbf&&1e3*e.nbf-Date.now()>this.REFRESH_TOKEN_TOLERANCE||e.exp&&Date.now()-1e3*e.exp>this.REFRESH_TOKEN_TOLERANCE||!e.iat)}saveTokens(t,e){t.refresh_token?this.openidStorageService.setRefreshToken(t.refresh_token):this.openidStorageService.clearRefreshToken(),t.access_token?this.openidStorageService.setAccessToken(t.access_token):this.openidStorageService.clearAccessToken(),t.id_token?this.openidStorageService.setIdToken(t.id_token):this.openidStorageService.clearIdToken(),this.openidStorageService.setTokenType(e.tokenType),this.logger.debug("OpenID: saved tokens"),this.openidStorageService.clearPkceState(),this.openidStorageService.clearPkceCodeVerifier()}authHeaderGraphDB(){return this.openidStorageService.getTokenType().getValue()===Ur.ID?"Bearer "+this.getTokenByType(Ur.ID):"Bearer "+this.getTokenByType(Ur.ACCESS)}getTokenHeader(t){try{const e=Br.pj.jws.JWS.readSafeJSONString((0,Br.cV)(t.split(".")[0]));if(e)return e}catch(t){throw this.logger.error("OpenID: token header decode failed",t),new kr}}getTokenPayload(t){try{const e=Br.pj.jws.JWS.readSafeJSONString((0,Br.cV)(t.split(".")[1]));if(e)return e}catch(t){throw this.logger.debug("Token payload decode error",t),new kr}}verifyToken(t,e){const r=this.getTokenByType(t);if(!r)return!1;let i;try{i=this.getTokenHeader(r)}catch{return!1}if(!i.kid)return t!==Ur.ID?i.error?(this.logger.debug(`OpenID: token ${t} is not a JWT token (token considered valid)`),!0):(this.logger.debug(`OpenID: invalid token ${t} (token is empty)`),!1):(this.logger.debug("OpenID: invalid token id (not a JWT token)"),!1);const s=this.securityContextService.getJsonWebKeysSet()?.[i.kid];if(!s)return this.logger.debug("OpenID: no key to verify JWT token (token considered invalid)"),!1;const n=Br.ym.getKey(s),o={alg:[i.alg],iss:[e.issuer]};return"id"===t?(o.aud=[e.clientId,e.issuer],o.nonce=[this.openidStorageService.getNonce().getValue()||""]):"access"===t&&(o.aud=[e.tokenAudience],o.iss=[e.tokenIssuer]),Br.pj.jws.JWS.verifyJWT(r,n,o)}clearTokens(){this.openidStorageService.clearTokens()}getTokenByType(t){return t===Ur.ID?this.openidStorageService.getIdToken().getValue():t===Ur.ACCESS?this.openidStorageService.getAccessToken().getValue():t===Ur.REFRESH?this.openidStorageService.getRefreshToken().getValue():null}}class Vr{static pkceChallengeFromVerifier(t){const e=new Br.pj.crypto.MessageDigest({alg:"sha256",prov:"cryptojs"});return(0,Br.wV)(e.digestString(t))}static parseQueryString(t){const e={access_token:null,code:null,id_token:null,state:null};let r;if(t){const t=c.getLocationHash().substring(1);r=new URLSearchParams(t)}else r=new URLSearchParams(c.getLocationQueryParams());return 0===r.size||Object.keys(e).forEach(t=>{const i=r.get(t);i&&(e[t]=decodeURIComponent(i))}),e}}class Mr extends Hr{constructor(t){super(`Invalid OpenID authentication flow: ${t}`)}}class Kr extends Hr{constructor(){super("Missing authorization code")}}let qr=function(t){return t.CODE="code",t.CODE_NO_PKCE="code_no_pkce",t.IMPLICIT="implicit",t}({}),Gr=function(t){return t.CODE="code",t.TOKEN="token id_token",t}({});class $r{items=[];enqueue(t){this.items.push(t)}dequeue(){return this.items.shift()}dequeueAll(){const t=[...this.items];return this.items=[],t}peek(){return this.items[0]}peekAll(){return[...this.items]}isEmpty(){return 0===this.items.length}size(){return this.items.length}}class Wr{notificationAddedCallbackFunctions=[];notifications=new $r;addNotification(t){this.notifications.enqueue(t),this.notifyAllNotificationAdded(t)}removeAllNotifications(){return this.notifications.dequeueAll()}onNotificationAdded(t){return t&&!this.notifications.isEmpty()&&this.notifyNotificationAdded(t),this.notificationAddedCallbackFunctions.push(t),()=>{this.notificationAddedCallbackFunctions=this.notificationAddedCallbackFunctions.filter(e=>e!==t)}}notifyNotificationAdded(t){this.notifications.peekAll().forEach(e=>t(e))}notifyAllNotificationAdded(t){for(const e of this.notificationAddedCallbackFunctions)e(t)}}function zr(t){wt(Wr).addNotification(t)}class Yr{logger=Pt.logger;tokenUtils=wt(jr);openidStorageService=wt(_r);async handleAuthorizationCode(t,e,r){if(!e.code)throw this.logger.error("OpenID: Missing authorization code"),new Kr;const i=`${E()}`;if(t.authFlow===qr.CODE)await this.handlePkceFlow(e,i,r);else{if(t.authFlow!==qr.CODE_NO_PKCE)throw this.logger.error("OpenID: Invalid OpenID authentication flow"),new Mr(t.authFlow);await this.handleCodeNoPkceFlow(e.code,i,r)}return!0}async handleImplicitFlow(t,e){this.tokenUtils.saveTokens(e,t)}checkExistingAuthentication(t){const e=this.tokenUtils.hasValidIdToken(t),r=this.tokenUtils.hasValidRefreshToken();return e||r}storeCodeFlowData(t){this.openidStorageService.setPkceState(t),this.openidStorageService.setPkceCodeVerifier(Zt.generateRandomString(28))}getCodeChallengeForCodeFlow(){const t=this.openidStorageService.getPkceCodeVerifier().getValue();if(!t)throw new Hr("Missing PKCE code verifier");return Vr.pkceChallengeFromVerifier(t)}async handlePkceFlow(t,e,r){const i=this.openidStorageService.getPkceState().getValue();if(i!==t.state)throw this.logger.debug(`OpenID: PKCE state mismatch ${i} != ${t.state}`),zr(Ne.error("openid.errors.invalid_pkce_state").withTitle("openid.errors.title").withParameters({[_e.SHOULD_TOAST]:!0})),new Hr(`PKCE state mismatch ${i} != ${t.state}`);if(!t.code)throw new Kr;const s=this.openidStorageService.getPkceCodeVerifier().getValue();await r(t.code,e,s)}async handleCodeNoPkceFlow(t,e,r){await r(t,e)}}class Xr extends Hr{constructor(){super("OpenID security configuration is not available")}}class Jr extends nr{securityContextService=wt(Nr);OAUTH_IDENTITY_DOMAIN_NAME_HEADER="X-OAuth-Identity-Domain-Name";getJSONWebKeySet(){return this.get(this.getJWKSEndpoint(),{headers:this.getDomainHeaders()})}refreshToken(t){const e={grant_type:"refresh_token",client_id:this.getClientId(),refresh_token:t},r={...this.getDomainHeaders(),"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},i=this.transformURLEncodedRequest(e);return this.post(this.getTokensEndpoint(),{body:i,headers:r})}getTokens(t,e,r){const i={grant_type:"authorization_code",client_id:this.getClientId(),redirect_uri:t,code:e};r&&(i.code_verifier=r);const s={...this.getDomainHeaders(),"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},n=this.transformURLEncodedRequest(i);return this.post(this.getTokensEndpoint(),{body:n,headers:s})}transformURLEncodedRequest(t){const e=new URLSearchParams;return Object.entries(t).forEach(([t,r])=>{e.append(t,r)}),e}getClientId(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.clientId;throw new Xr}getJWKSEndpoint(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.openIdKeysUri;throw new Xr}getTokensEndpoint(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.openIdTokenUrl;throw new Xr}getDomainHeaders(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;return t?.oracleDomain?{[this.OAUTH_IDENTITY_DOMAIN_NAME_HEADER]:t.oracleDomain}:{}}}class Qr{securityContextService=wt(Nr);buildLoginUrl(t,e,r){const i=this.getResponseType(),s=[...this.buildBaseParameters(i,r),...this.buildFlowSpecificParameters(t,e),...this.buildAdditionalParameters()];return`${this.getOpenIdConfig().oidcAuthorizationEndpoint}?${s.join("&")}`}buildLogoutUrl(t){const e=this.getOpenIdConfig(),r=e.clientId;return`${e.openIdEndSessionUrl}?client_id=${encodeURIComponent(r)}&post_logout_redirect_uri=${encodeURIComponent(t)}`}getOpenIdConfig(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(!t)throw new Xr;return t}getResponseType(){const t=this.getOpenIdConfig().authFlow;if(t===qr.CODE||t===qr.CODE_NO_PKCE)return Gr.CODE;if(t===qr.IMPLICIT)return Gr.TOKEN;throw new Mr(t)}buildBaseParameters(t,e){return[`response_type=${encodeURIComponent(t)}`,`scope=${encodeURIComponent(this.getScope())}`,`client_id=${encodeURIComponent(this.getOpenIdConfig().clientId)}`,`redirect_uri=${encodeURIComponent(e)}`]}buildFlowSpecificParameters(t,e){const r=this.getOpenIdConfig().authFlow,i=[];return r===qr.CODE?i.push(`state=${encodeURIComponent(t)}`,`code_challenge=${encodeURIComponent(e)}`,"code_challenge_method=S256"):r===qr.IMPLICIT&&i.push(`nonce=${encodeURIComponent(t)}`),i}buildAdditionalParameters(){const t=this.getOpenIdConfig(),e=[];return t.oracleDomain&&e.push(`domain=${encodeURIComponent(t.oracleDomain)}`),t.authorizeParameters&&e.push(t.authorizeParameters),e}getScope(){const t=["openid"];this.getOpenIdConfig().supportsOfflineAccess&&t.push("offline_access");const e=this.getOpenIdConfig().extraScopes;return e&&t.push(e),t.join(" ")}}class Zr{DEFAULT_REFRESH_CONFIGURATION={refreshAheadMs:6e4,minDelayMs:1e3};logger=Pt.logger;tokenUtils=wt(jr);openidStorageService=wt(_r);async setupTokensRefresh(t){const e=this.openidStorageService.getRefreshToken().getValue();if(!e||!this.shouldSetupRefresh(e))return this.clearRefreshTimer(),void this.logger.debug("OpenID: no valid refresh token");const r=this.openidStorageService.getAccessToken().getValue(),i=this.calculateRefreshDelay(r);i<this.DEFAULT_REFRESH_CONFIGURATION.minDelayMs?(this.logger.debug("OpenID: tokens need refresh now, "+i),await this.executeImmediateRefresh(e,t)):(this.logger.debug("OpenID: scheduling token refresh in",i/1e3,"seconds"),this.scheduleTokenRefresh(e,i,t))}clearRefreshTimer(){this.refreshTokensTimer&&(c.getWindow().clearTimeout(this.refreshTokensTimer),delete this.refreshTokensTimer)}shouldSetupRefresh(t){return!(!t||!this.tokenUtils.hasValidRefreshToken())}calculateRefreshDelay(t){let e;try{e=this.tokenUtils.getTokenPayload(t)}catch{return 0}return!e.exp||e.exp<=0?0:1e3*e.exp-Date.now()-this.DEFAULT_REFRESH_CONFIGURATION.refreshAheadMs}async executeImmediateRefresh(t,e){this.clearRefreshTimer(),this.logger.debug("OpenID: tokens will refresh now"),await e(t)}scheduleTokenRefresh(t,e,r){this.clearRefreshTimer(),this.refreshTokensTimer=c.getWindow().setTimeout(async()=>{this.logger.debug("OpenID: tokens will refresh now, "+e),await r(t)},e)}}class ti extends Je{jwtKey="jwt";authenticatedKey="authenticated";NAMESPACE="auth";set(t,e){this.storeValue(t,e)}getAuthToken(){return this.get(this.jwtKey)}setAuthenticated(t){this.storeValue(this.authenticatedKey,t?.toString()||"")}isAuthenticated(){return"true"===this.get(this.authenticatedKey).getValue()}setAuthToken(t){this.setAuthenticated(!0),this.set(this.jwtKey,t)}clearAuthToken(){this.remove(this.jwtKey)}isGDBorOpenIDToken(){const t=this.getAuthToken().getValue();return!(!t||!t.startsWith("GDB")&&!t.startsWith("Bearer"))}}class ei{constructor(t){this.notify=t}}class ri{eventSubscribers=new Map;emit(t){const e=this.eventSubscribers.get(t.NAME);e&&e.forEach(e=>{e.notify(n.deepCopy(t.payload))})}subscribe(t,e){const r=new ei(e),i=this.eventSubscribers.get(t);return i?i.push(r):this.eventSubscribers.set(t,[r]),()=>this.unsubscribe(t,r)}unsubscribe(t,e){const r=this.eventSubscribers.get(t);if(r){const i=r.indexOf(e);-1!==i&&r.splice(i,1),0===r.length&&this.eventSubscribers.delete(t)}}}class ii{logger=Pt.logger;openIdRestService=wt(Jr);openidStorageService=wt(_r);securityContextService=wt(Nr);tokenUtils=wt(jr);authenticationStorageService=wt(ti);authFlowHandler=wt(Yr);tokenRefreshManager=wt(Zr);openIdUrlBuilder=wt(Qr);getJSONWebKeySet(){return this.openIdRestService.getJSONWebKeySet()}getTokens(t,e,r){return this.openIdRestService.getTokens(t,e,r)}async refreshTokens(t){const e=this.getOpenIdConfig();try{const r=await this.openIdRestService.refreshToken(t);this.logger.debug("OpenID: refreshed tokens"),this.tokenUtils.saveTokens(r,e),this.authenticationStorageService.setAuthToken(this.tokenUtils.authHeaderGraphDB()),await this.setupTokensRefresh()}catch(t){this.logger.debug("OpenID: could not refresh tokens",t);let e="unknown error";t instanceof je&&(e=t.data?.error_description??"unknown error"),zr(Ne.error("openid.errors.cannot_refresh_token").withTitle("openid.errors.title").withParameters({error:e,[_e.SHOULD_TOAST]:!0})),this.softLogout(),wt(ri).emit(new z)}}async initializeOpenId(){const t=this.getOpenIdConfig();return await this.initializeJsonWebKeySet(),this.authFlowHandler.checkExistingAuthentication(t)?(await this.setupTokensRefresh(),!0):this.handleAuthenticationFlow()}async initializeJsonWebKeySet(){const t=await this.getJSONWebKeySet(),e=this.buildKeySet(t.keys);this.securityContextService.updateJsonWebKeysSet(e)}setupCodeFlow(t,e){this.authFlowHandler.storeCodeFlowData(t);const r=this.authFlowHandler.getCodeChallengeForCodeFlow(),i=this.getLoginUrl(t,r,e);this.redirectToUrl(i)}setupCodeNoPkceFlow(t,e){this.openidStorageService.clearPkceCodeVerifier();const r=this.getLoginUrl(t,"",e);this.redirectToUrl(r)}setupImplicitFlow(t,e){this.openidStorageService.setNonce(t);const r=this.getLoginUrl(t,"",e);this.redirectToUrl(r)}async setupTokensRefresh(){await this.tokenRefreshManager.setupTokensRefresh(this.refreshTokens.bind(this))}clearAuthentication(){this.authenticationStorageService.clearAuthToken(),this.tokenUtils.clearTokens(),this.tokenRefreshManager.clearRefreshTimer()}logout(t=!1){t?this.hardLogout(E()):this.softLogout()}getOpenIdConfig(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(!t)throw new Xr;return t}buildKeySet(t){const e={};return t.forEach(t=>{e[t.kid]=t}),e}async handleAuthenticationFlow(){const t=this.getOpenIdConfig();this.clearAuthentication();const e=t.authFlow===qr.IMPLICIT,r=Vr.parseQueryString(e);return r.code?this.authFlowHandler.handleAuthorizationCode(t,r,this.exchangeTokensForCode.bind(this)):!!r.id_token&&(await this.authFlowHandler.handleImplicitFlow(t,r),await this.setupTokensRefresh(),!0)}async exchangeTokensForCode(t,e,r){const i=this.getOpenIdConfig();try{const s=await this.getTokens(e,t,r);this.logger.debug("OpenID: successfully retrieved tokens"),this.tokenUtils.saveTokens(s,i),await this.setupTokensRefresh()}catch(t){throw this.logger.error("OpenID: Cannot retrieve token after login",{error:t}),zr(Ne.error("openid.errors.cannot_retrieve_token").withTitle("openid.errors.title").withParameters({error:t instanceof Error?t.message:String(t),[_e.SHOULD_TOAST]:!0})),new Hr("Cannot retrieve token after login")}}softLogout(){this.clearAuthentication()}hardLogout(t){this.softLogout();const e=this.getLogoutUrl(t);this.redirectToUrl(e)}redirectToUrl(t){c.setLocationHref(t)}getLoginUrl(t,e,r){return this.openIdUrlBuilder.buildLoginUrl(t,e,r)}getLogoutUrl(t){return this.openIdUrlBuilder.buildLogoutUrl(t)}}let si=function(t){return t.GDB_TOKEN="GDB_TOKEN",t.OPENID="OPENID",t.EXTERNAL="EXTERNAL",t.NO_SECURITY="NO_SECURITY",t}({});class ni{logger=Pt.logger;securityService=wt(mi);securityContextService=wt(Nr);type=si.NO_SECURITY;initialize(){return this.fetchAuthenticatedUser().then(t=>(this.securityContextService.updateAuthenticatedUser(t),!0)).catch(t=>(this.logger.error("Could not load authenticated user",t),!1))}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedAdminUser()}login(){return this.fetchAuthenticatedUser()}logout(){return Promise.resolve()}isAuthenticated(){return!!this.securityContextService.getAuthenticatedUser()}isExternal(){return!1}}class oi extends Hr{constructor(){super("OpenID user has no access rights")}}class ai{logger=Pt.logger;securityService=wt(mi);authenticationStorageService=wt(ti);authenticationService=wt(Ri);securityContextService=wt(Nr);openIdService=wt(ii);openidStorageService=wt(_r);tokenUtils=wt(jr);type=si.OPENID;constructor(){this.setupConfigurationListener()}async initialize(){this.loadSecurityConfiguration(),this.validateConfiguration();try{const t=await this.openIdService.initializeOpenId();t&&await this.handleSuccessfulAuthentication();const e=this.openidStorageService.getReturnUrl().getValue();return this.openidStorageService.clearReturnUrl(),t&&e&&f(e),t}catch(t){return this.handleAuthenticationError(t),!1}}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}login(){this.validateConfiguration();const t=this.getReturnUrl(),e=Zt.generateRandomString(28),r=this.openIdSecurityConfig.authFlow;return this.executeAuthFlow(r,e,t),new Promise(()=>{})}logout(){return this.openIdService.logout(),Promise.resolve()}isAuthenticated(){const t=this.authenticationStorageService.getAuthToken().getValue();return!this.authenticationService.isSecurityEnabled()||null!==t}isExternal(){return!1}setupConfigurationListener(){this.securityContextService.onSecurityConfigChanged(t=>{t&&(this.openIdSecurityConfig=t.openidSecurityConfig)})}loadSecurityConfiguration(){this.openIdSecurityConfig=this.securityContextService.getSecurityConfig()?.openidSecurityConfig}validateConfiguration(){if(!this.openIdSecurityConfig)throw new Xr}async handleSuccessfulAuthentication(){this.logger.debug("OpenID: authentication initialized"),this.authenticationStorageService.setAuthToken(this.tokenUtils.authHeaderGraphDB());try{await this.loadAndSetAuthenticatedUser()}catch(t){throw this.logger.debug("Could not load authenticated user",t),zr(Ne.error("openid.errors.user_no_access").withTitle("openid.errors.title").withParameters({[_e.SHOULD_TOAST]:!0})),new oi}}async loadAndSetAuthenticatedUser(){const t=await this.fetchAuthenticatedUser();t&&this.securityContextService.updateAuthenticatedUser(t)}handleAuthenticationError(t){this.authenticationStorageService.clearAuthToken(),this.logger.debug("OpenID: not logged or login error"),this.logger.error("Could not initialize OpenID authentication",t),this.openIdService.clearAuthentication()}getReturnUrl(){return`${E()}`}executeAuthFlow(t,e,r){switch(t){case qr.CODE:this.openIdService.setupCodeFlow(e,r);break;case qr.CODE_NO_PKCE:this.openIdService.setupCodeNoPkceFlow(e,r);break;case qr.IMPLICIT:this.openIdService.setupImplicitFlow(e,r);break;default:throw this.logger.debug(`OpenID: Invalid OpenID authentication flow: ${t}`),zr(Ne.error("openid.errors.unknown_flow").withTitle("openid.errors.title").withParameters({authFlow:t,[_e.SHOULD_TOAST]:!0})),new Mr(t)}}}class hi extends Lr{constructor(){super("Missing token in authentication header")}}const ui=t=>new ot({username:t.username,password:t.password,authorities:new rt(t.authorities),appSettings:new it(t.appSettings),external:t.external});class ci extends nr{SECURITY_ENDPOINT="rest/security";LOGIN_ENDPOINT="rest/login";SECURITY_USER_ENDPOINT=`${this.SECURITY_ENDPOINT}/users`;SECURITY_FREE_ACCESS_ENDPOINT=`${this.SECURITY_ENDPOINT}/free-access`;loginGdbToken(t,e){return this.post(this.LOGIN_ENDPOINT,{body:{username:t,password:e},responseType:"response"})}getSecurityConfig(){return this.get(`${this.SECURITY_ENDPOINT}/all`)}getAuthenticatedUser(){return this.get(`${this.SECURITY_ENDPOINT}/authenticated-user`)}getAdminUser(){return this.get(`${this.SECURITY_USER_ENDPOINT}/admin`)}getFreeAccess(){return this.get(this.SECURITY_FREE_ACCESS_ENDPOINT)}setFreeAccess(t){return this.post(this.SECURITY_FREE_ACCESS_ENDPOINT,{body:t})}}class li extends nr{SECURITY_ENDPOINT="rest/security";SECURITY_USER_ENDPOINT=`${this.SECURITY_ENDPOINT}/users`;getUser(t){return this.get(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`)}getUsers(){return this.get(`${this.SECURITY_USER_ENDPOINT}`)}createUser(t,e){return this.post(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`,{body:e})}updateUser(t,e){return this.put(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`,{body:e})}updateCurrentUser(t,e){return this.patch(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`,{body:e})}deleteUser(t){return this.delete(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`)}}class di{constructor(t){this.password=t?.password,this.grantedAuthorities=t?.grantedAuthorities??[],this.appSettings=t?.appSettings??{DEFAULT_SAMEAS:!0,DEFAULT_INFERENCE:!0,EXECUTE_COUNT:!0,IGNORE_SHARED_QUERIES:!1,DEFAULT_VIS_GRAPH_SCHEMA:!0}}}const pi=t=>new di({password:t.password,grantedAuthorities:t.authorities.toGraphdbAuthoritiesModel(),appSettings:t.appSettings.toJSON()}),gi=t=>new nt({username:t.username,authorities:new rt(t.grantedAuthorities),appSettings:new it({EXECUTE_COUNT:t.appSettings.EXECUTE_COUNT,DEFAULT_INFERENCE:t.appSettings.DEFAULT_INFERENCE,DEFAULT_SAMEAS:t.appSettings.DEFAULT_SAMEAS,DEFAULT_VIS_GRAPH_SCHEMA:t.appSettings.DEFAULT_VIS_GRAPH_SCHEMA,IGNORE_SHARED_QUERIES:t.appSettings.IGNORE_SHARED_QUERIES,COOKIE_CONSENT:t.appSettings.COOKIE_CONSENT?new Lt(t.appSettings.COOKIE_CONSENT):void 0}),dateCreated:new Date(t.dateCreated),gptThreads:t.gptThreads,external:t.external});class fi{static ADMIN_USERNAME="admin";usersRestService=wt(li);getUser(t){return this.usersRestService.getUser(t).then(t=>gi(t))}getUsers(){return this.usersRestService.getUsers().then(t=>t.map(t=>gi(t)))}getAdminUser(){return this.usersRestService.getUser(fi.ADMIN_USERNAME).then(t=>gi(t))}createUser(t){const e=pi(t);return this.usersRestService.createUser(t.username,e)}updateUser(t){const e=pi(t);return this.usersRestService.updateUser(t.username,e)}deleteUser(t){return this.usersRestService.deleteUser(t)}updateCurrentUser(t){const e=pi(t);return this.usersRestService.updateCurrentUser(t.username,e)}}class mi{securityRestService=wt(ci);securityContextService=wt(Nr);usersService=wt(fi);updateAuthenticatedUser(t){return this.usersService.updateCurrentUser(t)}getSecurityConfig(){return this.securityRestService.getSecurityConfig().then(t=>new lt(t))}getFreeAccess(){return this.securityRestService.getFreeAccess().then(function(t){return ct(t)})}setFreeAccess(t,e){const r={enabled:t};if(t){if(!e)throw new Error("Free access settings must be provided when enabling free access");r.authorities=Z(e?.authorities),r.appSettings={...e?.appSettings}}return this.securityRestService.setFreeAccess(r).then(()=>this.getSecurityConfig()).then(t=>{this.securityContextService.updateSecurityConfig(t)})}getAuthenticatedUser(){return this.securityRestService.getAuthenticatedUser().then(t=>ui(t))}getAuthenticatedAdminUser(){return this.usersService.getAdminUser().then(t=>ot.fromUser(t))}isPasswordLoginEnabled(){return this.securityContextService.getSecurityConfig()?.passwordLoginEnabled??!1}isOpenIDEnabled(){return this.securityContextService.getSecurityConfig()?.openIdEnabled??!1}loginGdbToken(t,e){return this.securityRestService.loginGdbToken(t,e)}}class yi{securityService=wt(mi);logger=Pt.logger;authStorageService=wt(ti);fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}async login(t){const{username:e,password:r}=t,i=await this.securityService.loginGdbToken(e,r),s=this.getAuthenticationHeader(i),n=ui(i.data);if(!s)throw new hi;return this.authStorageService.setAuthToken(s),n}getAuthenticationHeader(t){return t.headers.authorization}}class vi extends yi{securityContextService=wt(Nr);type=si.GDB_TOKEN;initialize(){const t=!!this.authStorageService.getAuthToken().getValue();return t?this.isCurrentRouteLogin()?Promise.resolve(t):Promise.resolve(!!this.securityContextService.getAuthenticatedUser()):Promise.resolve(!1)}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}logout(){return this.authStorageService.clearAuthToken(),Promise.resolve()}isAuthenticated(){return null!==this.authStorageService.getAuthToken().getValue()}isExternal(){return!1}isCurrentRouteLogin(){return"login"===w()}}class Si extends Lr{constructor(){super()}}class Ei extends yi{securityContextService=wt(Nr);type=si.EXTERNAL;initialize(){return Promise.resolve(!0)}isAuthenticated(){return!!this.securityContextService.getAuthenticatedUser()}logout(){throw new Si}isExternal(){return!0}}class xi{securityContextService=wt(Nr);authStorageService=wt(ti);resolveStrategy(t){return this.authStrategy=this._resolveStrategy(t),this.authStrategy}getAuthStrategy(){return this.authStrategy}_resolveStrategy(t){return t.isEnabled()?t.openIdEnabled?new ai:this.securityContextService.getAuthenticatedUser()&&!this.authStorageService.isGDBorOpenIDToken()?new Ei:new vi:new ni}}class wi{constructor(t,e){this.setRegex(t),this.setRouteParams(e)}getRegex(){return this.regex}setRegex(t){return this.regex=t,this}getRouteParams(){return this.routeParams}setRouteParams(t){return this.routeParams=t,this}}class Ai{routePlugins=c.getPluginRegistry().get(Re.NAME);getActiveRoute(t){const e=this.routePlugins.find(e=>this.routeToRegex(e.url).getRegex().test(t));return e?new be(e):void 0}routeToRegex(t){const e=[],r=t.replace(/([().])/g,"\\$1").replace(/(\/)?:(\w+)(\*\?|[?*])?/g,function(t,r,i,s){const n="?"===s||"*?"===s,o="*"===s||"*?"===s;return e.push(i),r=r||"",(n?"(?:"+r:r+"(?:")+(o?"(.+?)":"([^/]+)")+(n?"?)?":")")}).replace(/([/$*])/g,"\\$1");return new wi(new RegExp("^"+r+"(?:[?#]|$)"),new R(e))}}class bi{securityContextService=wt(Nr);repositoryStorageService=wt(fr);repositoryContextService=wt(mr);repositoryAuthorityService=wt(yr);hasFreeAccess(){const t=this.getSecurityConfig();return!(!t?.isEnabled()||!t?.freeAccess?.enabled)}initializeFreeAccess(){const t=this.getSecurityConfig();if(t?.isEnabled()&&t?.isFreeAccessEnabled()){const e=(new ot).setAuthorities(t.freeAccess.authorities).setAppSettings(t.freeAccess.appSettings);this.securityContextService.updateAuthenticatedUser(e)}}initializeOverrideAuth(){const t=this.getSecurityConfig();if(!t?.isEnabled()&&t?.hasOverrideAuth()){const e=new ot;e.username="overrideauth",e.setAuthorities(t.overrideAuth.authorities),e.setAppSettings(t.overrideAuth.appSettings),this.securityContextService.updateAuthenticatedUser(e)}}isAdmin(){return this.hasRole(J.ROLE_ADMIN)}isRepoManager(){return this.hasRole(J.ROLE_REPO_MANAGER)}hasRole(t){const e=this.getSecurityConfig(),r=this.getAuthenticatedUser();if(!t||!e?.isEnabled()&&!e?.hasOverrideAuth())return!0;if(!(Object.keys(r||{}).length>0))return!1;const i=J.IS_AUTHENTICATED_FULLY===t,s=!!r?.authorities.hasAuthority(t);return i||s}canReadRepo(t){if(!t||""===t.id)return!1;const e=this.getSecurityConfig(),r=this.getAuthenticatedUser();return!e?.isEnabled()||!!r&&(!!this.isAdminOrRepoManager()||!this.repositoryAuthorityService.isSystemRepository(t)&&this.hasBaseRights(pt.READ,t))}canWriteRepo(t){if(!t||""===t.id)return!1;const e=this.getSecurityConfig(),r=this.getAuthenticatedUser();return!e?.isEnabled()&&!e?.hasOverrideAuth()||!!r&&(!!this.isAdminOrRepoManager()||!this.repositoryAuthorityService.isSystemRepository(t)&&this.hasBaseRights(pt.WRITE,t))}canReadGqlRepo(t){return!(!t||""===t.id)&&this.hasGraphqlAuthority(pt.READ,t)}canWriteGqlRepo(t){return!(!t||""===t.id)&&this.hasGraphqlAuthority(pt.WRITE,t)}hasGqlRights(t){return this.canReadGqlRepo(t)||this.canWriteGqlRepo(t)}hasGraphqlRightsOverCurrentRepo(){const t=this.repositoryStorageService.getRepositoryReference(),e=this.repositoryContextService.findRepository(t);return this.canReadGqlRepo(e)||this.canWriteGqlRepo(e)}hasAuthority(){if(this.isAdminOrRepoManager())return!0;const t=wt(Ai).getActiveRoute(S());if(!t)return!1;if(!t.allowAuthorities)return!0;if(!wt(fr).getRepositoryReference()?.id)return!0;const e=this.getAuthenticatedUser();if(!e)return!0;if(t.allowAuthorities.length){const r=this.resolveAuthorities(t.allowAuthorities);return r.some(t=>e.authorities.hasAuthority(t))||r.some(t=>e.authorities.hasWildcardAuthority(t))}return!0}updatePermissions(){const t=this.securityContextService.getRestrictedPages(),e=this.securityContextService.getAuthenticatedUser(),r=this.isAdmin(),i=c.getWindow().PluginRegistry.get(Re.NAME),s=c.getWindow().PluginRegistry.get(Ce.NAME);i.forEach(i=>{const n=s.flatMap(t=>t.items).filter(t=>t.role?.startsWith("ROLE_")).find(t=>i.url.includes(t.href));if(!n)return;const o=!r&&!e?.authorities.hasAuthority(n.role??"");t.setPageRestriction(i.url,o)}),this.securityContextService.updateRestrictedPages(t)}resolveAuthorities(t){if(!t)return[];const e=wt(fr).getRepositoryReference();return e?.id?[...t.map(t=>t.replace("{repoId}",e.id)),...t.map(t=>t.replace("{repoId}","*"))]:t}getSecurityConfig(){return wt(Nr).getSecurityConfig()}getAuthenticatedUser(){return wt(Nr).getAuthenticatedUser()}hasBaseRights(t,e){const r=this.repositoryAuthorityService.getLocationSpecificId(e),i=this.repositoryAuthorityService.getCurrentRepoAuthority(t,r),s=this.repositoryAuthorityService.getOverallRepoAuthority(t),n=this.getAuthenticatedUser();return!!(n?.authorities.hasAuthority(i)||n?.authorities.hasAuthority(s)||n?.authorities.hasWildcardAuthority(i))}hasGraphqlAuthority(t,e){const r=this.securityContextService.getAuthenticatedUser();if(!r)return!1;const i=this.repositoryAuthorityService.getLocationSpecificId(e),s=this.repositoryAuthorityService.getCurrentGqlRepoAuthority(t,i),n=this.repositoryAuthorityService.getOverallGqlRepoAuthority(t);return r.authorities.hasAuthority(s)||r.authorities.hasAuthority(n)||r.authorities.hasWildcardAuthority(s,!0)}isAdminOrRepoManager(){return this.hasRole(J.ROLE_ADMIN)||this.hasRole(J.ROLE_REPO_MANAGER)}}class Ii extends Lr{constructor(){super("Authentication strategy not set")}}class Ci extends Ct{PREVIOUS_ROUTE="previousRoute";RETURN_URL="returnUrl";updatePreviousRoute(t){this.updateContextProperty(this.PREVIOUS_ROUTE,t)}getPreviousRoute(){let t=this.getContextPropertyValue(this.PREVIOUS_ROUTE);return t?.endsWith("#")&&(t=t.slice(0,-1)),t}updateReturnUrl(t){this.updateContextProperty(this.RETURN_URL,t)}getReturnUrl(){return this.getContextPropertyValue(this.RETURN_URL)}clearReturnUrl(){this.updateContextProperty(this.RETURN_URL,void 0)}}class Ri{eventService=wt(ri);authStrategyResolver=wt(xi);authorizationService=wt(bi);securityContextService=wt(Nr);authenticationStorageService=wt(ti);navigationContextService=wt(Ci);isAuthenticationStrategySet(){return!!this.authStrategyResolver.getAuthStrategy()}getCurrentUser(){return this.getAuthenticationStrategy().fetchAuthenticatedUser()}login(t,e){return this.getAuthenticationStrategy().login({username:t,password:e}).then(t=>{this.securityContextService.updateIsLoggedIn(!0),this.securityContextService.updateAuthenticatedUser(t),this.updateStrategy(),this.eventService.emit(new Y)})}logout(){const t=this.getAuthenticationStrategy();this.authenticationStorageService.setAuthenticated(!1);const e=S();return t.logout().then(()=>{v()||this.navigationContextService.updateReturnUrl(e),this.securityContextService.updateIsLoggedIn(!1),this.authorizationService.hasFreeAccess()?(this.authorizationService.initializeFreeAccess(),this.eventService.emit(new Y)):(f("login"),this.eventService.emit(new z))})}isLoggedIn(){const t=this.securityContextService.getIsLoggedIn()??!1,e=wt(Nr).getAuthenticatedUser();return this.isSecurityEnabled()&&t&&!!e}isAuthenticated(){return this.getAuthenticationStrategy().isAuthenticated()}isExternalUser(){return this.getAuthenticationStrategy().isExternal()}isSecurityEnabled(){return!!this.getSecurityConfig()?.isEnabled()}getSecurityConfig(){return wt(Nr).getSecurityConfig()}updateStrategy(){const t=this.getSecurityConfig();t&&this.authStrategyResolver.resolveStrategy(t)}getAuthenticationStrategy(){const t=this.authStrategyResolver.getAuthStrategy();if(!t)throw new Ii;return t}}class Ti extends Lr{constructor(t){super(t)}}class Fi{static DEFAULT_PATH="/";static MILLISECONDS_PER_DAY=864e5;path=Fi.DEFAULT_PATH;constructor(t,e,r={}){this.key=encodeURIComponent(t),this.value=encodeURIComponent(e),this.setOptions(r)}setOptions(t){const{expiration:e,path:r,domain:i,secure:s,httpOnly:n,sameSite:o}=t;return e&&this.setExpiration(e),this.setPath(r),i&&this.setDomain(i),s&&this.setSecure(),n&&this.setHttpOnly(),o&&this.setSameSite(o),this}setExpiration(t){if(!Number.isFinite(t))throw new Ti(`Invalid expiration value: ${t}`);const e=new Date(I.now()+t*Fi.MILLISECONDS_PER_DAY);return this.expires=e.toUTCString(),this}setPath(t){return this.path=t||Fi.DEFAULT_PATH,this}setDomain(t){return this.domain=t,this}setSecure(){return this.secure=!0,this}setHttpOnly(){return this.httpOnly=!0,this}setSameSite(t){return this.sameSite=t,this}build(){let t=`${this.key}=${this.value}`;return this.expires&&(t+=`; expires=${this.expires}`),t+=`; path=${this.path}`,this.domain&&(t+=`; domain=${this.domain}`),this.secure&&(t+="; secure"),this.httpOnly&&(t+="; HttpOnly"),this.sameSite&&(t+=`; SameSite=${this.sameSite}`),t}}class Pi{read(){return c.getDocument().cookie}write(t){c.getDocument().cookie=t}}class Di{constructor(t){this.store=t??new Pi}get(t){return this.parseCookies()[t]}set(t,e,r={}){this.store.write(new Fi(t,e,r).build())}remove(t){this.store.write(new Fi(t,"",{expiration:-1}).build())}getAll(){return this.parseCookies()}parseCookies(){const t={},e=this.store.read().split("; ");for(const r of e){const[e,i]=r.split("=");e&&i&&(t[decodeURIComponent(e)]=decodeURIComponent(i))}return t}}class Oi extends Je{NAMESPACE="tracking";COOKIE_CONSENT="cookieConsent";LEGACY_COOKIE_CONSENT="cookie-consent";logger=Pt.logger;set(t,e){this.storeValue(t,e)}setCookieConsent(t){this.set(this.COOKIE_CONSENT,JSON.stringify(t))}getCookieConsent(){this.migrateLegacyCookieConsent();const t=this.get(this.COOKIE_CONSENT).getAsJson();return t?new Lt(t):null}migrateLegacyCookieConsent(){const t=this.getAsJson(this.LEGACY_COOKIE_CONSENT);t&&(this.logger.info("Legacy cookie consent data found. Migrating to new key.",{legacyData:t}),this.setCookieConsent(t),this.remove(this.LEGACY_COOKIE_CONSENT,!1))}}const Ni="_wb";class _i{cookieService=wt(Di);timeProvider=I;get(){return this.cookieService.get(Ni)}set(t){const e=`WB1.${t}.${this.timeProvider.now()}`;this.cookieService.set(Ni,e,{expiration:400,sameSite:"Lax"})}setIfAbsent(t){this.get()||this.set(t)}remove(){this.cookieService.remove(Ni)}}class Bi{cookieService=wt(Di);isSettingUp=!1;setIfAbsent(){if(!this.isSettingUp&&!this.gtmScriptExists()&&(this.isSettingUp=!0,!this.gtmScriptExists())){c.getWindow().dataLayer&&(c.getWindow().dataLayer=[]);const t=c.getDocument().createElement("script");t.text="(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'}); var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:''; j.async=true; j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl; f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-WBP6C6Z4');",c.getDocument().getElementsByTagName("head")[0].appendChild(t)}}remove(){this.isSettingUp=!1,this.gtmScriptExists()&&this.removeGoogleAnalyticsScripts(),this.removeGoogleAnalyticsCookies()}removeGoogleAnalyticsCookies(){const t=this.cookieService.getAll();for(const[e]of Object.entries(t))e.startsWith("_ga")&&this.cookieService.remove(e)}removeGoogleAnalyticsScripts(){c.getWindow().dataLayer&&(c.getWindow().dataLayer=[]);const t=c.getDocument().getElementsByTagName("script"),e=/googletagmanager/i;for(let r=t.length-1;r>=0;r--)(t[r].src&&e.test(t[r].src)||e.test(t[r].text))&&t[r].remove();c.getWindow().google_tag_manager&&delete c.getWindow().google_tag_manager,c.getWindow().google_tag_data&&delete c.getWindow().google_tag_data}gtmScriptExists(){const t=c.getDocument().getElementsByTagName("script");return Array.from(t).some(t=>t.src?.includes("googletagmanager"))}}const Li="cookie-consent-changed-event";class Hi{securityService=wt(mi);securityContextService=wt(Nr);authenticationService=wt(Ri);authorizationService=wt(bi);trackingStorageService=wt(Oi);licenseService=wt(Fr);licenseContextService=wt(Tr);installationCookieService=wt(_i);googleAnalyticsCookieService=wt(Bi);eventEmitter=new ir;isTrackingAllowed(){return this.licenseService.isTrackableLicense()&&!c.getWindow().wbDevMode}acceptCookiePolicy(){const t=this.securityContextService.getAuthenticatedUser();if(t){this.updateUserCookieConsent(t),this.securityContextService.updateAuthenticatedUser(t);const e=this.securityContextService.getIsLoggedIn(),r=this.securityContextService.getSecurityConfig()?.isEnabled();if(r&&!e){const e=t.getCookieConsent();return e&&this.trackingStorageService.setCookieConsent(e),Promise.resolve().finally(()=>this.applyTrackingConsent())}return this.securityService.updateAuthenticatedUser(t.toUser()).then(()=>{this.eventEmitter.emit({NAME:Li,payload:t.appSettings.COOKIE_CONSENT})}).finally(()=>this.applyTrackingConsent())}return Promise.reject(new Error("No authenticated user found"))}getCookieConsent(){const t=this.securityContextService.getAuthenticatedUser();return t?.username?t.appSettings?.COOKIE_CONSENT?Lt.fromJSON(t.appSettings.COOKIE_CONSENT):Lt.NOT_ACCEPTED_WITH_TRACKING():this.authorizationService.hasFreeAccess()?this.trackingStorageService.getCookieConsent()||Lt.NOT_ACCEPTED_WITH_TRACKING():Lt.ACCEPTED_NO_TRACKING()}applyTrackingConsent(){if(!this.isTrackingAllowed())return this.cleanUpTracking(),Promise.resolve();{const t=this.getCookieConsent();if(t.hasChanged()&&!t.policyAccepted)return void this.cleanUpTracking();if(t.statistic){const t=this.licenseContextService.getLicenseSnapshot()?.installationId||"";this.installationCookieService.setIfAbsent(t)}else this.installationCookieService.remove();t.thirdParty?this.googleAnalyticsCookieService.setIfAbsent():this.googleAnalyticsCookieService.remove()}}cleanUpTracking(){this.installationCookieService.remove(),this.googleAnalyticsCookieService.remove()}updateUserCookieConsent(t){let e;e=t.appSettings?.COOKIE_CONSENT?new Lt(t.appSettings.COOKIE_CONSENT):new Lt({thirdParty:!0,statistic:!0}),e.policyAccepted=!0,e.updatedAt=Date.now(),t.appSettings.COOKIE_CONSENT=e}}class ki extends nr{MONITORING_ENDPOINT="rest/monitor";getOperations(t){return this.get(`${this.MONITORING_ENDPOINT}/repository/${t}/operations`)}deleteQuery(t,e){return this.delete(`${this.MONITORING_ENDPOINT}/repository/${e}/query?query=${encodeURIComponent(t)}`)}}const Ui={[Kt.CLUSTER_HEALTH]:0,[Kt.BACKUP_AND_RESTORE]:1,[Kt.IMPORT]:2,[Kt.QUERIES]:3,[Kt.UPDATES]:4},ji=t=>{if(!t?.status||!t.allRunningOperations)return new Vt({status:Ht.INFORMATION,allRunningOperations:new Mt([])});const e=t.allRunningOperations.map(t=>new zt({value:t.value||"",status:b(Ht,t.status),type:b(Kt,t.type)})),r=new Mt(e);return r.sort((t,e)=>Ui[t.type]-Ui[e.type]),new Vt({status:b(Ht,t.status),allRunningOperations:r})};class Vi{monitoringRestService=wt(ki);async getOperations(t){const e=await this.monitoringRestService.getOperations(t);return ji(e)}deleteQuery(t,e){return this.monitoringRestService.deleteQuery(t,e)}}class Mi extends Lr{constructor(){super("Class is not initializable")}}const Ki={[Oe.ERROR]:Qt.ERROR,[Oe.SUCCESS]:Qt.SUCCESS,[Oe.WARNING]:Qt.WARNING,[Oe.INFO]:Qt.INFO};class qi{constructor(){throw new Mi}static fromNotification(t){const e=this.notificationTypeToToastType(t.type);return new ee(e,t.code,{title:t.title,translationParams:this.toTranslationParams(t.parameters)})}static notificationTypeToToastType(t){return t?Ki[t]:Qt.INFO}static toTranslationParams(t){return t?Object.entries(t).map(([t,e])=>({key:t,value:String(e)})):[]}}class Gi{eventEmitter=new ir;notificationService=wt(Wr);constructor(){this.subscribeToNotificationEvents()}error(t,e){this.createToastElement(t,Qt.ERROR,e)}info(t,e){this.createToastElement(t,Qt.INFO,e)}success(t,e){this.createToastElement(t,Qt.SUCCESS,e)}warning(t,e){this.createToastElement(t,Qt.WARNING,e)}createToastElement(t,e,r){this.eventEmitter.emit({NAME:re,payload:new ee(e,t,r)})}subscribeToNotificationEvents(){this.notificationService.onNotificationAdded(t=>{if(t.parameters?.[_e.SHOULD_TOAST]){const e=qi.fromNotification(t);this.createToastElement(e.message,e.type,e.config)}})}}class $i extends nr{autocompleteRestPrefix="rest/autocomplete";search(t){return this.get(`${this.autocompleteRestPrefix}/query?q=${t}`)}enabled(){return this.get(`${this.autocompleteRestPrefix}/enabled`)}}class Wi{search(t){return xt.get($i).search(t).then(t=>(t=>{const e=t.suggestions.map(t=>new de({id:Zt.hashCode(`${t.type}-${t.value}-${t.description}`),type:b(pe,t.type),value:t.value,description:t.description}));return new le(new ce(e))})(t))}isAutocompleteEnabled(){return xt.get($i).enabled()}}class zi extends Je{ENABLED_KEY="enabled";NAMESPACE="autocomplete";set(t,e){this.storeValue(t,e)}isEnabled(){return"true"===this.get(this.ENABLED_KEY).value}setEnabled(t){this.set(this.ENABLED_KEY,t.toString())}}class Yi extends Ct{AUTOCOMPLETE_ENABLED="isAutocompleteEnabled";updateAutocompleteEnabled(t){this.updateContextProperty(this.AUTOCOMPLETE_ENABLED,t),xt.get(zi).setEnabled(t)}onAutocompleteEnabledChanged(t){return this.subscribe(this.AUTOCOMPLETE_ENABLED,t)}}const Xi=t=>{const e=(t?.results.bindings||[]).reduce((t,e)=>(t[e.prefix.value]=e.namespace.value,t),{});return new k(e)};class Ji extends nr{REPOSITORIES_ENDPOINT="repositories";getStatementsEndpoint(t){return`${this.REPOSITORIES_ENDPOINT}/${t}/statements`}getSparqlEndpoint(t){return`${this.REPOSITORIES_ENDPOINT}/${t}`}getNamespaces(t){return this.get(`${this.REPOSITORIES_ENDPOINT}/${t}/namespaces`)}}class Qi{rdf4jRestService=wt(Ji);getStatementsEndpoint(t){return this.rdf4jRestService.getStatementsEndpoint(t)}getSparqlEndpoint(t){return this.rdf4jRestService.getSparqlEndpoint(t)}}class Zi{rdf4jRestService=wt(Ji);async getNamespaces(t){const e=await this.rdf4jRestService.getNamespaces(t);return Xi(e)}}class ts extends Ct{NAMESPACES="namespaces";updateNamespaces(t){this.updateContextProperty(this.NAMESPACES,t)}onNamespacesChanged(t){return this.subscribe(this.NAMESPACES,t)}}class es extends Je{SELECTED_VIEW_KEY="selectedView";INPUT_KEY="input";LAST_SELECTED_KEY="lastSelected";NAMESPACE="resourceSearch";LEGACY_LAST_SELECTED_KEY="ls.rdf-search.resource-description";LEGACY_INPUT_KEY="ls.rdf-search.search-input";LEGACY_SELECTED_VIEW_KEY="ls.rdf-search.search-type";set(t,e){this.storeValue(t,e)}setSelectedView(t){this.set(this.SELECTED_VIEW_KEY,t),localStorage.setItem(this.LEGACY_SELECTED_VIEW_KEY,t)}getSelectedView(){return this.get(this.SELECTED_VIEW_KEY).getValue()||""}setInputValue(t){this.set(this.INPUT_KEY,t),localStorage.setItem(this.LEGACY_INPUT_KEY,t)}getInputValue(){return this.get(this.INPUT_KEY).getValue()||""}setLastSelected(t){this.set(this.LAST_SELECTED_KEY,t.getValue()),localStorage.setItem(this.LEGACY_LAST_SELECTED_KEY,t.getDescription()||"")}getLastSelectedValue(){return this.get(this.LAST_SELECTED_KEY).getValue()||""}clearStoredSearch(){this.remove(this.INPUT_KEY),this.remove(this.LAST_SELECTED_KEY),localStorage.removeItem(this.LEGACY_INPUT_KEY),localStorage.removeItem(this.LEGACY_LAST_SELECTED_KEY)}}class rs extends Ct{APPLICATION_DATA_STATE="applicationDataLoaded";APPLICATION_STATE_CHANGE="applicationStateChange";APPLICATION_STATE_BEFORE_CHANGE="applicationStateBeforeChange";updateApplicationDataState(t){this.updateContextProperty(this.APPLICATION_DATA_STATE,t)}onApplicationDataStateChanged(t){return this.subscribe(this.APPLICATION_DATA_STATE,t)}getApplicationDataState(){return this.getContextPropertyValue(this.APPLICATION_DATA_STATE)}updateApplicationStateChange(t){this.updateContextProperty(this.APPLICATION_STATE_CHANGE,t)}onApplicationStateChange(t){return this.subscribe(this.APPLICATION_STATE_CHANGE,t)}updateApplicationStateBeforeChange(t){this.updateContextProperty(this.APPLICATION_STATE_BEFORE_CHANGE,t)}onApplicationStateBeforeChange(t){return this.subscribe(this.APPLICATION_STATE_BEFORE_CHANGE,t)}}class is extends nr{configurationContextService=wt(Rt);logger=Pt.logger;getPluginsManifest(){const t=this.configurationContextService.getApplicationConfiguration();return this.get(t.pluginsManifestPath)}async loadPlugins(t){return await Promise.all(t.getPluginDefinitions().getItems().map(async t=>{try{const e=t.entry.startsWith("http")?t.entry:`${E()}${t.entry}`;return await import(e)}catch(e){this.logger.warn(`Failed to load plugin ${t.name}:`,e)}}))}}class ss{logger=Pt.logger;constructor(){this.pluginsRestService=xt.get(is)}async getPluginsManifest(){return(t=>{const e=t.plugins.map(t=>new me(t.entry,t.name));return new ye(new Ee(e))})(await this.pluginsRestService.getPluginsManifest())}async loadPlugins(){let t;try{t=await this.getPluginsManifest()}catch(t){this.logger.warn("Failed to load plugins manifest. Continue with the built-in plugins only.",t)}t&&(await this.pluginsRestService.loadPlugins(t)).filter(t=>void 0!==t).forEach(t=>{void 0!==t.register?t.register(c.getPluginRegistry()):this.logger.warn("Plugin module is missing the register method. Skipping registration.",t)})}}class ns extends Se{}class os extends Lr{constructor(t){super(`Extension point "${t.name}" is already registered.`)}}class as extends Lr{constructor(t){super(`Extension point "${t}" does not exist.`)}}class hs extends Lr{constructor(t,e,r){super(`There is already a plugin with the same order and priority. Extension point "${t.name}", order "${e}", priority "${r}".`)}}class us{extensionPoints={};constructor(t={}){this.extensionPoints=t}registerExtensionPoint(t){if(this.extensionPoints[t.name])throw new os(t);this.extensionPoints[t.name]=t}add(t,e){if(!e)return;const r=this.getExtensionPoint(t);(Array.isArray(e)?e:[e]).forEach(t=>this.registerPlugin(r,t))}get(t){return this.getExtensionPoint(t).getPlugins()}findPlugin(t,e){return this.get(t).find(e)}getExtensionPoints(){return this.extensionPoints}clear(t){this.getExtensionPoint(t).removeAllPlugins()}clearAll(){Object.values(this.extensionPoints).forEach(t=>t.removeAllPlugins())}getExtensionPoint(t){const e=this.extensionPoints[t];if(!e)throw new as(t);return e}registerPlugin(t,e){e.disabled||(t.removePluginByFieldIdName(e),t instanceof ns?this.processOrderedPlugin(e,t):t.addPlugin(e))}processOrderedPlugin(t,e){const r=e.getPlugins().find(e=>e.order===t.order);if(r){if(r.priority===t.priority)throw new hs(e,t.order,t.priority);t.priority>r.priority&&(e.removePlugin(r),e.addPlugin(t),e.sort((t,e)=>t.order-e.order))}else e.addPlugin(t),e.sort((t,e)=>t.order-e.order)}}const cs=JSON.parse('{"configUrl":"assets/configuration.default.json"}');class ls extends Lr{}class ds extends nr{async getConfiguration(){let t,e=cs;try{e=await this.get("assets/env.json")}catch{console.warn('No downloadable "env.json" was found. Fallback to default:',e)}try{if(t=await this.get(e.configUrl),t)return console.info(`Configuration file ${e.configUrl} was downloaded`,t),t}catch{throw new ls(`Failed to download configuration from "${e.configUrl}". Ensure that there is a\n "configuration.default.json" JSON file in the assets folder or provide an "env.json" file pointing to another\n configuration file.`)}}}class ps{configurationRestService=wt(ds);configurationContextService=wt(Rt);async getConfiguration(){const t=await this.configurationRestService.getConfiguration();return t&&this.configurationContextService.updateApplicationConfiguration(t),t}}const gs=t=>{if(!t)return{items:[]};const e=wt(mr).getSelectedRepository();let r="";return e&&(r=`${B}=${e.id}&`),{items:t.map(t=>({id:t,href:`sparql-template/create?${r}templateID=${encodeURIComponent(t)}`}))}};class fs extends nr{static SPARQL_ENDPOINT="rest/sparql";getSavedQuery(t,e){const r={name:t};return e&&(r.owner=e),this.get(`${fs.SPARQL_ENDPOINT}/saved-queries`,{params:r})}}const ms=t=>{if(!t||!Array.isArray(t))return new Ve;const e=wt(Nr),r=e.getAuthenticatedUser()?.username,i=t.map(t=>{const e=r!==t.owner;return new Me({queryName:t.name,query:t.body,owner:t.owner,isPublic:t.shared,readonly:e})});return new Ve(i)};class ys{sparqlRestService=wt(fs);async getSavedQuery(t,e){const r=await this.sparqlRestService.getSavedQuery(t,e);return ms(r)}}class vs extends Je{NAMESPACE="sparqlEditor";logger=Pt.logger;LAST_USED_REPOSITORY="lastUsedRepository";LEGACY_LAST_USED_REPOSITORY_KEY="ls.sparql-last-repo";set(t,e){this.storeValue(t,e)}setLastUsedRepository(t){this.set(this.LAST_USED_REPOSITORY,t)}getLastUsedRepository(){return this.migrateLastUsedRepositoryKey(),this.get(this.LAST_USED_REPOSITORY).getValue()}migrateLastUsedRepositoryKey(){const t=this.get(this.LEGACY_LAST_USED_REPOSITORY_KEY,!1).getValue();t&&(this.logger.info("Legacy last used repository data found. Migrating to new key.",{legacyData:t}),this.setLastUsedRepository(t),this.remove(this.LEGACY_LAST_USED_REPOSITORY_KEY,!1))}}class Ss{postMessage(t,e="*"){c.getParentWindow().postMessage(t,e)}}var Es=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===xs}(t)}(t)},xs="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function ws(t,e){return!1!==e.clone&&e.isMergeableObject(t)?Cs((r=t,Array.isArray(r)?[]:{}),t,e):t;var r}function As(t,e,r){return t.concat(e).map(function(t){return ws(t,r)})}function bs(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[]}(t))}function Is(t,e){try{return e in t}catch(t){return!1}}function Cs(t,e,r){(r=r||{}).arrayMerge=r.arrayMerge||As,r.isMergeableObject=r.isMergeableObject||Es,r.cloneUnlessOtherwiseSpecified=ws;var i=Array.isArray(e);return i===Array.isArray(t)?i?r.arrayMerge(t,e,r):function(t,e,r){var i={};return r.isMergeableObject(t)&&bs(t).forEach(function(e){i[e]=ws(t[e],r)}),bs(e).forEach(function(s){(function(t,e){return Is(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,s)||(Is(t,s)&&r.isMergeableObject(e[s])?i[s]=function(t,e){if(!e.customMerge)return Cs;var r=e.customMerge(t);return"function"==typeof r?r:Cs}(s,r)(t[s],e[s],r):i[s]=ws(e[s],r))}),i}(t,e,r):ws(e,r)}Cs.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,r){return Cs(t,r,e)},{})};var Rs=Cs;function Ts(t){return t instanceof HTMLElement}function Fs(t){return"function"==typeof t}function Ps(t){return"string"==typeof t}function Ds(t){return void 0===t}class Os{on(t,e,r,i=!1){return Ds(this.bindings)&&(this.bindings={}),Ds(this.bindings[t])&&(this.bindings[t]=[]),this.bindings[t].push({handler:e,ctx:r,once:i}),this}once(t,e,r){return this.on(t,e,r,!0)}off(t,e){return Ds(this.bindings)||Ds(this.bindings[t])||(Ds(e)?delete this.bindings[t]:this.bindings[t].forEach((r,i)=>{r.handler===e&&this.bindings[t].splice(i,1)})),this}trigger(t,...e){return!Ds(this.bindings)&&this.bindings[t]&&this.bindings[t].forEach((r,i)=>{const{ctx:s,handler:n,once:o}=r,a=s||this;n.apply(a,e),o&&this.bindings[t].splice(i,1)}),this}}function Ns(t){const e=Object.getOwnPropertyNames(t.constructor.prototype);for(let r=0;r<e.length;r++){const i=e[r],s=t[i];"constructor"!==i&&"function"==typeof s&&(t[i]=s.bind(t))}return t}function _s(t){return Ps(t)&&""!==t?"-"!==t.charAt(t.length-1)?`${t}-`:t:""}function Bs(t){return null==t||!t.element||!t.on}function Ls(){let t=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:3&r|8).toString(16)})}function Hs(){return Hs=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Hs.apply(this,arguments)}function ks(t,e){if(null==t)return{};var r,i,s={},n=Object.keys(t);for(i=0;i<n.length;i++)r=n[i],e.indexOf(r)>=0||(s[r]=t[r]);return s}const Us=Math.min,js=Math.max,Vs=Math.round,Ms=Math.floor,Ks=t=>({x:t,y:t}),qs={left:"right",right:"left",bottom:"top",top:"bottom"},Gs={start:"end",end:"start"};function $s(t,e,r){return js(t,Us(e,r))}function Ws(t,e){return"function"==typeof t?t(e):t}function zs(t){return t.split("-")[0]}function Ys(t){return t.split("-")[1]}function Xs(t){return"x"===t?"y":"x"}function Js(t){return"y"===t?"height":"width"}function Qs(t){return["top","bottom"].includes(zs(t))?"y":"x"}function Zs(t){return Xs(Qs(t))}function tn(t){return t.replace(/start|end/g,t=>Gs[t])}function en(t){return t.replace(/left|right|bottom|top/g,t=>qs[t])}function rn(t){return"number"!=typeof t?function(t){return Hs({top:0,right:0,bottom:0,left:0},t)}(t):{top:t,right:t,bottom:t,left:t}}function sn(t){return Hs({},t,{top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height})}const nn=["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"],on=["mainAxis","crossAxis","limiter"];function an(t,e,r){let{reference:i,floating:s}=t;const n=Qs(e),o=Zs(e),a=Js(o),c=zs(e),h="y"===n,u=i.x+i.width/2-s.width/2,l=i.y+i.height/2-s.height/2,p=i[a]/2-s[a]/2;let d;switch(c){case"top":d={x:u,y:i.y-s.height};break;case"bottom":d={x:u,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:l};break;case"left":d={x:i.x-s.width,y:l};break;default:d={x:i.x,y:i.y}}switch(Ys(e)){case"start":d[o]-=p*(r&&h?-1:1);break;case"end":d[o]+=p*(r&&h?-1:1)}return d}async function hn(t,e){var r;void 0===e&&(e={});const{x:i,y:s,platform:n,rects:o,elements:a,strategy:c}=t,{boundary:h="clippingAncestors",rootBoundary:u="viewport",elementContext:l="floating",altBoundary:p=!1,padding:d=0}=Ws(e,t),g=rn(d),f=a[p?"floating"===l?"reference":"floating":l],m=sn(await n.getClippingRect({element:null==(r=await(null==n.isElement?void 0:n.isElement(f)))||r?f:f.contextElement||await(null==n.getDocumentElement?void 0:n.getDocumentElement(a.floating)),boundary:h,rootBoundary:u,strategy:c})),y="floating"===l?Hs({},o.floating,{x:i,y:s}):o.reference,v=await(null==n.getOffsetParent?void 0:n.getOffsetParent(a.floating)),S=await(null==n.isElement?void 0:n.isElement(v))&&await(null==n.getScale?void 0:n.getScale(v))||{x:1,y:1},E=sn(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({rect:y,offsetParent:v,strategy:c}):y);return{top:(m.top-E.top+g.top)/S.y,bottom:(E.bottom-m.bottom+g.bottom)/S.y,left:(m.left-E.left+g.left)/S.x,right:(E.right-m.right+g.right)/S.x}}const un=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:r,y:i,placement:s,rects:n,middlewareData:o}=e,{offset:a=0,mainAxis:c=!0,crossAxis:h=!0}=Ws(t,e),u={x:r,y:i},l=Qs(s),p=Xs(l);let d=u[p],g=u[l];const f=Ws(a,e),m="number"==typeof f?{mainAxis:f,crossAxis:0}:Hs({mainAxis:0,crossAxis:0},f);if(c){const t="y"===p?"height":"width",e=n.reference[p]-n.floating[t]+m.mainAxis,r=n.reference[p]+n.reference[t]-m.mainAxis;d<e?d=e:d>r&&(d=r)}if(h){var y,v;const t="y"===p?"width":"height",e=["top","left"].includes(zs(s)),r=n.reference[l]-n.floating[t]+(e&&(null==(y=o.offset)?void 0:y[l])||0)+(e?0:m.crossAxis),i=n.reference[l]+n.reference[t]+(e?0:(null==(v=o.offset)?void 0:v[l])||0)-(e?m.crossAxis:0);g<r?g=r:g>i&&(g=i)}return{[p]:d,[l]:g}}}};function cn(t){return pn(t)?(t.nodeName||"").toLowerCase():"#document"}function ln(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function dn(t){var e;return null==(e=(pn(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function pn(t){return t instanceof Node||t instanceof ln(t).Node}function gn(t){return t instanceof Element||t instanceof ln(t).Element}function fn(t){return t instanceof HTMLElement||t instanceof ln(t).HTMLElement}function mn(t){return"undefined"!=typeof ShadowRoot&&(t instanceof ShadowRoot||t instanceof ln(t).ShadowRoot)}function yn(t){const{overflow:e,overflowX:r,overflowY:i,display:s}=wn(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+r)&&!["inline","contents"].includes(s)}function vn(t){return["table","td","th"].includes(cn(t))}function Sn(t){const e=En(),r=wn(t);return"none"!==r.transform||"none"!==r.perspective||!!r.containerType&&"normal"!==r.containerType||!e&&!!r.backdropFilter&&"none"!==r.backdropFilter||!e&&!!r.filter&&"none"!==r.filter||["transform","perspective","filter"].some(t=>(r.willChange||"").includes(t))||["paint","layout","strict","content"].some(t=>(r.contain||"").includes(t))}function En(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function xn(t){return["html","body","#document"].includes(cn(t))}function wn(t){return ln(t).getComputedStyle(t)}function An(t){return gn(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function bn(t){if("html"===cn(t))return t;const e=t.assignedSlot||t.parentNode||mn(t)&&t.host||dn(t);return mn(e)?e.host:e}function In(t){const e=bn(t);return xn(e)?t.ownerDocument?t.ownerDocument.body:t.body:fn(e)&&yn(e)?e:In(e)}function Cn(t,e){var r;void 0===e&&(e=[]);const i=In(t),s=i===(null==(r=t.ownerDocument)?void 0:r.body),n=ln(i);return s?e.concat(n,n.visualViewport||[],yn(i)?i:[]):e.concat(i,Cn(i))}function Rn(t){const e=wn(t);let r=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const s=fn(t),n=s?t.offsetWidth:r,o=s?t.offsetHeight:i,a=Vs(r)!==n||Vs(i)!==o;return a&&(r=n,i=o),{width:r,height:i,$:a}}function Tn(t){return gn(t)?t:t.contextElement}function Fn(t){const e=Tn(t);if(!fn(e))return Ks(1);const r=e.getBoundingClientRect(),{width:i,height:s,$:n}=Rn(e);let o=(n?Vs(r.width):r.width)/i,a=(n?Vs(r.height):r.height)/s;return o&&Number.isFinite(o)||(o=1),a&&Number.isFinite(a)||(a=1),{x:o,y:a}}const Pn=Ks(0);function Dn(t){const e=ln(t);return En()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:Pn}function On(t,e,r,i){void 0===e&&(e=!1),void 0===r&&(r=!1);const s=t.getBoundingClientRect(),n=Tn(t);let o=Ks(1);e&&(i?gn(i)&&(o=Fn(i)):o=Fn(t));const a=function(t,e,r){return void 0===e&&(e=!1),!(!r||e&&r!==ln(t))&&e}(n,r,i)?Dn(n):Ks(0);let c=(s.left+a.x)/o.x,h=(s.top+a.y)/o.y,u=s.width/o.x,l=s.height/o.y;if(n){const t=ln(n),e=i&&gn(i)?ln(i):i;let r=t.frameElement;for(;r&&i&&e!==t;){const t=Fn(r),e=r.getBoundingClientRect(),i=wn(r),s=e.left+(r.clientLeft+parseFloat(i.paddingLeft))*t.x,n=e.top+(r.clientTop+parseFloat(i.paddingTop))*t.y;c*=t.x,h*=t.y,u*=t.x,l*=t.y,c+=s,h+=n,r=ln(r).frameElement}}return sn({width:u,height:l,x:c,y:h})}function Nn(t){return On(dn(t)).left+An(t).scrollLeft}function _n(t,e,r){let i;if("viewport"===e)i=function(t,e){const r=ln(t),i=dn(t),s=r.visualViewport;let n=i.clientWidth,o=i.clientHeight,a=0,c=0;if(s){n=s.width,o=s.height;const t=En();(!t||t&&"fixed"===e)&&(a=s.offsetLeft,c=s.offsetTop)}return{width:n,height:o,x:a,y:c}}(t,r);else if("document"===e)i=function(t){const e=dn(t),r=An(t),i=t.ownerDocument.body,s=js(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),n=js(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let o=-r.scrollLeft+Nn(t);const a=-r.scrollTop;return"rtl"===wn(i).direction&&(o+=js(e.clientWidth,i.clientWidth)-s),{width:s,height:n,x:o,y:a}}(dn(t));else if(gn(e))i=function(t,e){const r=On(t,!0,"fixed"===e),i=r.top+t.clientTop,s=r.left+t.clientLeft,n=fn(t)?Fn(t):Ks(1);return{width:t.clientWidth*n.x,height:t.clientHeight*n.y,x:s*n.x,y:i*n.y}}(e,r);else{const r=Dn(t);i=Hs({},e,{x:e.x-r.x,y:e.y-r.y})}return sn(i)}function Bn(t,e){const r=bn(t);return!(r===e||!gn(r)||xn(r))&&("fixed"===wn(r).position||Bn(r,e))}function Ln(t,e,r){const i=fn(e),s=dn(e),n="fixed"===r,o=On(t,!0,n,e);let a={scrollLeft:0,scrollTop:0};const c=Ks(0);if(i||!i&&!n)if(("body"!==cn(e)||yn(s))&&(a=An(e)),i){const t=On(e,!0,n,e);c.x=t.x+e.clientLeft,c.y=t.y+e.clientTop}else s&&(c.x=Nn(s));return{x:o.left+a.scrollLeft-c.x,y:o.top+a.scrollTop-c.y,width:o.width,height:o.height}}function Hn(t,e){return fn(t)&&"fixed"!==wn(t).position?e?e(t):t.offsetParent:null}function kn(t,e){const r=ln(t);if(!fn(t))return r;let i=Hn(t,e);for(;i&&vn(i)&&"static"===wn(i).position;)i=Hn(i,e);return i&&("html"===cn(i)||"body"===cn(i)&&"static"===wn(i).position&&!Sn(i))?r:i||function(t){let e=bn(t);for(;fn(e)&&!xn(e);){if(Sn(e))return e;e=bn(e)}return null}(t)||r}const Un={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:r,strategy:i}=t;const s=fn(r),n=dn(r);if(r===n)return e;let o={scrollLeft:0,scrollTop:0},a=Ks(1);const c=Ks(0);if((s||!s&&"fixed"!==i)&&(("body"!==cn(r)||yn(n))&&(o=An(r)),fn(r))){const t=On(r);a=Fn(r),c.x=t.x+r.clientLeft,c.y=t.y+r.clientTop}return{width:e.width*a.x,height:e.height*a.y,x:e.x*a.x-o.scrollLeft*a.x+c.x,y:e.y*a.y-o.scrollTop*a.y+c.y}},getDocumentElement:dn,getClippingRect:function(t){let{element:e,boundary:r,rootBoundary:i,strategy:s}=t;const n=[..."clippingAncestors"===r?function(t,e){const r=e.get(t);if(r)return r;let i=Cn(t).filter(t=>gn(t)&&"body"!==cn(t)),s=null;const n="fixed"===wn(t).position;let o=n?bn(t):t;for(;gn(o)&&!xn(o);){const e=wn(o),r=Sn(o);r||"fixed"!==e.position||(s=null),(n?!r&&!s:!r&&"static"===e.position&&s&&["absolute","fixed"].includes(s.position)||yn(o)&&!r&&Bn(t,o))?i=i.filter(t=>t!==o):s=e,o=bn(o)}return e.set(t,i),i}(e,this._c):[].concat(r),i],o=n[0],a=n.reduce((t,r)=>{const i=_n(e,r,s);return t.top=js(i.top,t.top),t.right=Us(i.right,t.right),t.bottom=Us(i.bottom,t.bottom),t.left=js(i.left,t.left),t},_n(e,o,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:kn,getElementRects:async function(t){let{reference:e,floating:r,strategy:i}=t;const s=this.getOffsetParent||kn,n=this.getDimensions;return{reference:Ln(e,await s(r),i),floating:Hs({x:0,y:0},await n(r))}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){return Rn(t)},getScale:Fn,isElement:gn,isRTL:function(t){return"rtl"===wn(t).direction}};function jn(t){t.cleanup&&t.cleanup();const e=t._getResolvedAttachToOptions();let r=e.element;const i=function(t,e){const r={strategy:"absolute",middleware:[]},i=function(t){return!(!t.options.arrow||!t.el)&&t.el.querySelector(".shepherd-arrow")}(e);return Bs(t)||(r.middleware.push(function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var r;const{placement:i,middlewareData:s,rects:n,initialPlacement:o,platform:a,elements:c}=e,h=Ws(t,e),{mainAxis:u=!0,crossAxis:l=!0,fallbackPlacements:p,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:f=!0}=h,m=ks(h,nn),y=zs(i),v=zs(o)===o,S=await(null==a.isRTL?void 0:a.isRTL(c.floating)),E=p||(v||!f?[en(o)]:function(t){const e=en(t);return[tn(t),e,tn(e)]}(o));p||"none"===g||E.push(...function(t,e,r,i){const s=Ys(t);let n=function(t,e,r){const i=["left","right"],s=["right","left"],n=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return r?e?s:i:e?i:s;case"left":case"right":return e?n:o;default:return[]}}(zs(t),"start"===r,i);return s&&(n=n.map(t=>t+"-"+s),e&&(n=n.concat(n.map(tn)))),n}(o,f,g,S));const x=[o,...E],w=await hn(e,m),A=[];let b=(null==(r=s.flip)?void 0:r.overflows)||[];if(u&&A.push(w[y]),l){const t=function(t,e,r){void 0===r&&(r=!1);const i=Ys(t),s=Zs(t),n=Js(s);let o="x"===s?i===(r?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[n]>e.floating[n]&&(o=en(o)),[o,en(o)]}(i,n,S);A.push(w[t[0]],w[t[1]])}if(b=[...b,{placement:i,overflows:A}],!A.every(t=>t<=0)){var C,I;const t=((null==(C=s.flip)?void 0:C.index)||0)+1,e=x[t];if(e)return{data:{index:t,overflows:b},reset:{placement:e}};let r=null==(I=b.filter(t=>t.overflows[0]<=0).sort((t,e)=>t.overflows[1]-e.overflows[1])[0])?void 0:I.placement;if(!r)switch(d){case"bestFit":{var R;const t=null==(R=b.map(t=>[t.placement,t.overflows.filter(t=>t>0).reduce((t,e)=>t+e,0)]).sort((t,e)=>t[1]-e[1])[0])?void 0:R[0];t&&(r=t);break}case"initialPlacement":r=o}if(i!==r)return{reset:{placement:r}}}return{}}}}(),function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:r,y:i,placement:s}=e,n=Ws(t,e),{mainAxis:o=!0,crossAxis:a=!1,limiter:c={fn:t=>{let{x:e,y:r}=t;return{x:e,y:r}}}}=n,h=ks(n,on),u={x:r,y:i},l=await hn(e,h),p=Qs(zs(s)),d=Xs(p);let g=u[d],f=u[p];if(o){const t="y"===d?"bottom":"right";g=$s(g+l["y"===d?"top":"left"],g,g-l[t])}if(a){const t="y"===p?"bottom":"right";f=$s(f+l["y"===p?"top":"left"],f,f-l[t])}const m=c.fn(Hs({},e,{[d]:g,[p]:f}));return Hs({},m,{data:{x:m.x-r,y:m.y-i}})}}}({limiter:un(),crossAxis:!0})),i&&r.middleware.push((t=>({name:"arrow",options:t,async fn(e){const{x:r,y:i,placement:s,rects:n,platform:o,elements:a}=e,{element:c,padding:h=0}=Ws(t,e)||{};if(null==c)return{};const u=rn(h),l={x:r,y:i},p=Zs(s),d=Js(p),g=await o.getDimensions(c),f="y"===p,m=f?"top":"left",y=f?"bottom":"right",v=f?"clientHeight":"clientWidth",S=n.reference[d]+n.reference[p]-l[p]-n.floating[d],E=l[p]-n.reference[p],x=await(null==o.getOffsetParent?void 0:o.getOffsetParent(c));let w=x?x[v]:0;w&&await(null==o.isElement?void 0:o.isElement(x))||(w=a.floating[v]||n.floating[d]);const A=S/2-E/2,b=w/2-g[d]/2-1,C=Us(u[m],b),I=Us(u[y],b),R=C,T=w-g[d]-I,F=w/2-g[d]/2+A,P=$s(R,F,T),D=null!=Ys(s)&&F!=P&&n.reference[d]/2-(F<R?C:I)-g[d]/2<0?F<R?R-F:T-F:0;return{[p]:l[p]-D,data:{[p]:P,centerOffset:F-P+D}}}}))({element:i})),r.placement=t.on),Rs(e.options.floatingUIOptions||{},r)}(e,t),s=Bs(e);return s&&(r=document.body,t.shepherdElementComponent.getElement().classList.add("shepherd-centered")),t.cleanup=function(t,e,r,i){void 0===i&&(i={});const{ancestorScroll:s=!0,ancestorResize:n=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:c=!1}=i,h=Tn(t),u=s||n?[...h?Cn(h):[],...Cn(e)]:[];u.forEach(t=>{s&&t.addEventListener("scroll",r,{passive:!0}),n&&t.addEventListener("resize",r)});const l=h&&a?function(t,e){let r,i=null;const s=dn(t);function n(){clearTimeout(r),i&&i.disconnect(),i=null}return function o(a,c){void 0===a&&(a=!1),void 0===c&&(c=1),n();const{left:h,top:u,width:l,height:p}=t.getBoundingClientRect();if(a||e(),!l||!p)return;const d={rootMargin:-Ms(u)+"px "+-Ms(s.clientWidth-(h+l))+"px "+-Ms(s.clientHeight-(u+p))+"px "+-Ms(h)+"px",threshold:js(0,Us(1,c))||1};let g=!0;function f(t){const e=t[0].intersectionRatio;if(e!==c){if(!g)return o();e?o(!1,e):r=setTimeout(()=>{o(!1,1e-7)},100)}g=!1}try{i=new IntersectionObserver(f,Hs({},d,{root:s.ownerDocument}))}catch(t){i=new IntersectionObserver(f,d)}i.observe(t)}(!0),n}(h,r):null;let p,d=-1,g=null;o&&(g=new ResizeObserver(t=>{let[i]=t;i&&i.target===h&&g&&(g.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{g&&g.observe(e)})),r()}),h&&!c&&g.observe(h),g.observe(e));let f=c?On(t):null;return c&&function e(){const i=On(t);!f||i.x===f.x&&i.y===f.y&&i.width===f.width&&i.height===f.height||r(),f=i,p=requestAnimationFrame(e)}(),r(),()=>{u.forEach(t=>{s&&t.removeEventListener("scroll",r),n&&t.removeEventListener("resize",r)}),l&&l(),g&&g.disconnect(),g=null,c&&cancelAnimationFrame(p)}}(r,t.el,()=>{t.el?function(t,e,r,i){((t,e,r)=>{const i=new Map,s=Hs({platform:Un},r),n=Hs({},s.platform,{_c:i});return(async(t,e,r)=>{const{placement:i="bottom",strategy:s="absolute",middleware:n=[],platform:o}=r,a=n.filter(Boolean),c=await(null==o.isRTL?void 0:o.isRTL(e));let h=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:l}=an(h,i,c),p=i,d={},g=0;for(let r=0;r<a.length;r++){const{name:n,fn:f}=a[r],{x:m,y,data:v,reset:S}=await f({x:u,y:l,initialPlacement:i,placement:p,strategy:s,middlewareData:d,rects:h,platform:o,elements:{reference:t,floating:e}});u=null!=m?m:u,l=null!=y?y:l,d=Hs({},d,{[n]:Hs({},d[n],v)}),S&&g<=50&&(g++,"object"==typeof S&&(S.placement&&(p=S.placement),S.rects&&(h=!0===S.rects?await o.getElementRects({reference:t,floating:e,strategy:s}):S.rects),({x:u,y:l}=an(h,p,c))),r=-1)}return{x:u,y:l,placement:p,strategy:s,middlewareData:d}})(t,e,Hs({},s,{platform:n}))})(t,e.el,r).then(function(t,e){return({x:r,y:i,placement:s,middlewareData:n})=>t.el?(e?Object.assign(t.el.style,{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)"}):Object.assign(t.el.style,{position:"absolute",left:`${r}px`,top:`${i}px`}),t.el.dataset.popperPlacement=s,function(t,e){const r=t.querySelector(".shepherd-arrow");if(r&&e.arrow){const{x:t,y:i}=e.arrow;Object.assign(r.style,{left:null!=t?`${t}px`:"",top:null!=i?`${i}px`:""})}}(t.el,n),t):t}(e,i)).then(t=>new Promise(e=>{setTimeout(()=>e(t),300)})).then(t=>{t&&t.el&&t.el.focus({preventScroll:!0})})}(r,t,i,s):t.cleanup()}),t.target=e.element,i}function Vn(){}function Mn(t,e){for(const r in e)t[r]=e[r];return t}function Kn(t){return t()}function qn(){return Object.create(null)}function Gn(t){t.forEach(Kn)}function $n(t){return"function"==typeof t}function Wn(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function zn(t,e){t.appendChild(e)}function Yn(t,e,r){t.insertBefore(e,r||null)}function Xn(t){t.parentNode&&t.parentNode.removeChild(t)}function Jn(t){return document.createElement(t)}function Qn(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Zn(t){return document.createTextNode(t)}function to(){return Zn(" ")}function eo(t,e,r,i){return t.addEventListener(e,r,i),()=>t.removeEventListener(e,r,i)}function ro(t,e,r){null==r?t.removeAttribute(e):t.getAttribute(e)!==r&&t.setAttribute(e,r)}const io=["width","height"];function so(t,e){const r=Object.getOwnPropertyDescriptors(t.__proto__);for(const i in e)null==e[i]?t.removeAttribute(i):"style"===i?t.style.cssText=e[i]:"__value"===i?t.value=t[i]=e[i]:r[i]&&r[i].set&&-1===io.indexOf(i)?t[i]=e[i]:ro(t,i,e[i])}function no(t,e,r){t.classList[r?"add":"remove"](e)}let oo;function ao(t){oo=t}function ho(){if(!oo)throw new Error("Function called outside component initialization");return oo}function uo(t){ho().$$.after_update.push(t)}const co=[],lo=[];let po=[];const go=[],fo=Promise.resolve();let mo=!1;function yo(t){po.push(t)}const vo=new Set;let So=0;function Eo(){if(0!==So)return;const t=oo;do{try{for(;So<co.length;){const t=co[So];So++,ao(t),xo(t.$$)}}catch(t){throw co.length=0,So=0,t}for(ao(null),co.length=0,So=0;lo.length;)lo.pop()();for(let t=0;t<po.length;t+=1){const e=po[t];vo.has(e)||(vo.add(e),e())}po.length=0}while(co.length);for(;go.length;)go.pop()();mo=!1,vo.clear(),ao(t)}function xo(t){if(null!==t.fragment){t.update(),Gn(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(yo)}}const wo=new Set;let Ao;function bo(){Ao={r:0,c:[],p:Ao}}function Io(){Ao.r||Gn(Ao.c),Ao=Ao.p}function Co(t,e){t&&t.i&&(wo.delete(t),t.i(e))}function Ro(t,e,r,i){if(t&&t.o){if(wo.has(t))return;wo.add(t),Ao.c.push(()=>{wo.delete(t),i&&(r&&t.d(1),i())}),t.o(e)}else i&&i()}function To(t){t&&t.c()}function Fo(t,e,r,i){const{fragment:s,after_update:n}=t.$$;s&&s.m(e,r),i||yo(()=>{const e=t.$$.on_mount.map(Kn).filter($n);t.$$.on_destroy?t.$$.on_destroy.push(...e):Gn(e),t.$$.on_mount=[]}),n.forEach(yo)}function Po(t,e){const r=t.$$;null!==r.fragment&&(function(t){const e=[],r=[];po.forEach(i=>-1===t.indexOf(i)?e.push(i):r.push(i)),r.forEach(t=>t()),po=e}(r.after_update),Gn(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function Do(t,e,r,i,s,n,o,a=[-1]){const c=oo;ao(t);const h=t.$$={fragment:null,ctx:[],props:n,update:Vn,not_equal:s,bound:qn(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:qn(),dirty:a,skip_bound:!1,root:e.target||c.$$.root};o&&o(h.root);let u=!1;if(h.ctx=r?r(t,e.props||{},(e,r,...i)=>{const n=i.length?i[0]:r;return h.ctx&&s(h.ctx[e],h.ctx[e]=n)&&(!h.skip_bound&&h.bound[e]&&h.bound[e](n),u&&function(t,e){-1===t.$$.dirty[0]&&(co.push(t),mo||(mo=!0,fo.then(Eo)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}(t,e)),r}):[],h.update(),u=!0,Gn(h.before_update),h.fragment=!!i&&i(h.ctx),e.target){if(e.hydrate){const t=(l=e.target,Array.from(l.childNodes));h.fragment&&h.fragment.l(t),t.forEach(Xn)}else h.fragment&&h.fragment.c();e.intro&&Co(t.$$.fragment),Fo(t,e.target,e.anchor,e.customElement),Eo()}var l;ao(c)}class Oo{$destroy(){Po(this,1),this.$destroy=Vn}$on(t,e){if(!$n(e))return Vn;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(e),()=>{const t=r.indexOf(e);-1!==t&&r.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function No(t){let e,r,i,s,n;return{c(){e=Jn("button"),ro(e,"aria-label",r=t[3]?t[3]:null),ro(e,"class",i=`${t[1]||""} shepherd-button ${t[4]?"shepherd-button-secondary":""}`),e.disabled=t[2],ro(e,"tabindex","0")},m(r,i){Yn(r,e,i),e.innerHTML=t[5],s||(n=eo(e,"click",function(){$n(t[0])&&t[0].apply(this,arguments)}),s=!0)},p(s,[n]){t=s,32&n&&(e.innerHTML=t[5]),8&n&&r!==(r=t[3]?t[3]:null)&&ro(e,"aria-label",r),18&n&&i!==(i=`${t[1]||""} shepherd-button ${t[4]?"shepherd-button-secondary":""}`)&&ro(e,"class",i),4&n&&(e.disabled=t[2])},i:Vn,o:Vn,d(t){t&&Xn(e),s=!1,n()}}}function _o(t,e,r){let i,s,n,o,a,c,{config:h,step:u}=e;function l(t){return Fs(t)?t.call(u):t}return t.$$set=t=>{"config"in t&&r(6,h=t.config),"step"in t&&r(7,u=t.step)},t.$$.update=()=>{192&t.$$.dirty&&(r(0,i=h.action?h.action.bind(u.tour):null),r(1,s=h.classes),r(2,n=!!h.disabled&&l(h.disabled)),r(3,o=h.label?l(h.label):null),r(4,a=h.secondary),r(5,c=h.text?l(h.text):null))},[i,s,n,o,a,c,h,u]}class Bo extends Oo{constructor(t){super(),Do(this,t,_o,No,Wn,{config:6,step:7})}}function Lo(t,e,r){const i=t.slice();return i[2]=e[r],i}function Ho(t){let e,r,i=t[1],s=[];for(let e=0;e<i.length;e+=1)s[e]=ko(Lo(t,i,e));const n=t=>Ro(s[t],1,1,()=>{s[t]=null});return{c(){for(let t=0;t<s.length;t+=1)s[t].c();e=Zn("")},m(t,i){for(let e=0;e<s.length;e+=1)s[e]&&s[e].m(t,i);Yn(t,e,i),r=!0},p(t,r){if(3&r){let o;for(i=t[1],o=0;o<i.length;o+=1){const n=Lo(t,i,o);s[o]?(s[o].p(n,r),Co(s[o],1)):(s[o]=ko(n),s[o].c(),Co(s[o],1),s[o].m(e.parentNode,e))}for(bo(),o=i.length;o<s.length;o+=1)n(o);Io()}},i(t){if(!r){for(let t=0;t<i.length;t+=1)Co(s[t]);r=!0}},o(t){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)Ro(s[t]);r=!1},d(t){!function(t,e){for(let r=0;r<t.length;r+=1)t[r]&&t[r].d(e)}(s,t),t&&Xn(e)}}}function ko(t){let e,r;return e=new Bo({props:{config:t[2],step:t[0]}}),{c(){To(e.$$.fragment)},m(t,i){Fo(e,t,i),r=!0},p(t,r){const i={};2&r&&(i.config=t[2]),1&r&&(i.step=t[0]),e.$set(i)},i(t){r||(Co(e.$$.fragment,t),r=!0)},o(t){Ro(e.$$.fragment,t),r=!1},d(t){Po(e,t)}}}function Uo(t){let e,r,i=t[1]&&Ho(t);return{c(){e=Jn("footer"),i&&i.c(),ro(e,"class","shepherd-footer")},m(t,s){Yn(t,e,s),i&&i.m(e,null),r=!0},p(t,[r]){t[1]?i?(i.p(t,r),2&r&&Co(i,1)):(i=Ho(t),i.c(),Co(i,1),i.m(e,null)):i&&(bo(),Ro(i,1,1,()=>{i=null}),Io())},i(t){r||(Co(i),r=!0)},o(t){Ro(i),r=!1},d(t){t&&Xn(e),i&&i.d()}}}function jo(t,e,r){let i,{step:s}=e;return t.$$set=t=>{"step"in t&&r(0,s=t.step)},t.$$.update=()=>{1&t.$$.dirty&&r(1,i=s.options.buttons)},[s,i]}class Vo extends Oo{constructor(t){super(),Do(this,t,jo,Uo,Wn,{step:0})}}function Mo(t){let e,r,i,s,n;return{c(){e=Jn("button"),r=Jn("span"),r.textContent="×",ro(r,"aria-hidden","true"),ro(e,"aria-label",i=t[0].label?t[0].label:"Close Tour"),ro(e,"class","shepherd-cancel-icon"),ro(e,"type","button")},m(i,o){Yn(i,e,o),zn(e,r),s||(n=eo(e,"click",t[1]),s=!0)},p(t,[r]){1&r&&i!==(i=t[0].label?t[0].label:"Close Tour")&&ro(e,"aria-label",i)},i:Vn,o:Vn,d(t){t&&Xn(e),s=!1,n()}}}function Ko(t,e,r){let{cancelIcon:i,step:s}=e;return t.$$set=t=>{"cancelIcon"in t&&r(0,i=t.cancelIcon),"step"in t&&r(2,s=t.step)},[i,t=>{t.preventDefault(),s.cancel()},s]}class qo extends Oo{constructor(t){super(),Do(this,t,Ko,Mo,Wn,{cancelIcon:0,step:2})}}function Go(t){let e;return{c(){e=Jn("h3"),ro(e,"id",t[1]),ro(e,"class","shepherd-title")},m(r,i){Yn(r,e,i),t[3](e)},p(t,[r]){2&r&&ro(e,"id",t[1])},i:Vn,o:Vn,d(r){r&&Xn(e),t[3](null)}}}function $o(t,e,r){let{labelId:i,element:s,title:n}=e;return uo(()=>{Fs(n)&&r(2,n=n()),r(0,s.innerHTML=n,s)}),t.$$set=t=>{"labelId"in t&&r(1,i=t.labelId),"element"in t&&r(0,s=t.element),"title"in t&&r(2,n=t.title)},[s,i,n,function(t){lo[t?"unshift":"push"](()=>{s=t,r(0,s)})}]}class Wo extends Oo{constructor(t){super(),Do(this,t,$o,Go,Wn,{labelId:1,element:0,title:2})}}function zo(t){let e,r;return e=new Wo({props:{labelId:t[0],title:t[2]}}),{c(){To(e.$$.fragment)},m(t,i){Fo(e,t,i),r=!0},p(t,r){const i={};1&r&&(i.labelId=t[0]),4&r&&(i.title=t[2]),e.$set(i)},i(t){r||(Co(e.$$.fragment,t),r=!0)},o(t){Ro(e.$$.fragment,t),r=!1},d(t){Po(e,t)}}}function Yo(t){let e,r;return e=new qo({props:{cancelIcon:t[3],step:t[1]}}),{c(){To(e.$$.fragment)},m(t,i){Fo(e,t,i),r=!0},p(t,r){const i={};8&r&&(i.cancelIcon=t[3]),2&r&&(i.step=t[1]),e.$set(i)},i(t){r||(Co(e.$$.fragment,t),r=!0)},o(t){Ro(e.$$.fragment,t),r=!1},d(t){Po(e,t)}}}function Xo(t){let e,r,i,s=t[2]&&zo(t),n=t[3]&&t[3].enabled&&Yo(t);return{c(){e=Jn("header"),s&&s.c(),r=to(),n&&n.c(),ro(e,"class","shepherd-header")},m(t,o){Yn(t,e,o),s&&s.m(e,null),zn(e,r),n&&n.m(e,null),i=!0},p(t,[i]){t[2]?s?(s.p(t,i),4&i&&Co(s,1)):(s=zo(t),s.c(),Co(s,1),s.m(e,r)):s&&(bo(),Ro(s,1,1,()=>{s=null}),Io()),t[3]&&t[3].enabled?n?(n.p(t,i),8&i&&Co(n,1)):(n=Yo(t),n.c(),Co(n,1),n.m(e,null)):n&&(bo(),Ro(n,1,1,()=>{n=null}),Io())},i(t){i||(Co(s),Co(n),i=!0)},o(t){Ro(s),Ro(n),i=!1},d(t){t&&Xn(e),s&&s.d(),n&&n.d()}}}function Jo(t,e,r){let i,s,{labelId:n,step:o}=e;return t.$$set=t=>{"labelId"in t&&r(0,n=t.labelId),"step"in t&&r(1,o=t.step)},t.$$.update=()=>{2&t.$$.dirty&&(r(2,i=o.options.title),r(3,s=o.options.cancelIcon))},[n,o,i,s]}class Qo extends Oo{constructor(t){super(),Do(this,t,Jo,Xo,Wn,{labelId:0,step:1})}}function Zo(t){let e;return{c(){e=Jn("div"),ro(e,"class","shepherd-text"),ro(e,"id",t[1])},m(r,i){Yn(r,e,i),t[3](e)},p(t,[r]){2&r&&ro(e,"id",t[1])},i:Vn,o:Vn,d(r){r&&Xn(e),t[3](null)}}}function ta(t,e,r){let{descriptionId:i,element:s,step:n}=e;return uo(()=>{let{text:t}=n.options;Fs(t)&&(t=t.call(n)),Ts(t)?s.appendChild(t):r(0,s.innerHTML=t,s)}),t.$$set=t=>{"descriptionId"in t&&r(1,i=t.descriptionId),"element"in t&&r(0,s=t.element),"step"in t&&r(2,n=t.step)},[s,i,n,function(t){lo[t?"unshift":"push"](()=>{s=t,r(0,s)})}]}class ea extends Oo{constructor(t){super(),Do(this,t,ta,Zo,Wn,{descriptionId:1,element:0,step:2})}}function ra(t){let e,r;return e=new Qo({props:{labelId:t[1],step:t[2]}}),{c(){To(e.$$.fragment)},m(t,i){Fo(e,t,i),r=!0},p(t,r){const i={};2&r&&(i.labelId=t[1]),4&r&&(i.step=t[2]),e.$set(i)},i(t){r||(Co(e.$$.fragment,t),r=!0)},o(t){Ro(e.$$.fragment,t),r=!1},d(t){Po(e,t)}}}function ia(t){let e,r;return e=new ea({props:{descriptionId:t[0],step:t[2]}}),{c(){To(e.$$.fragment)},m(t,i){Fo(e,t,i),r=!0},p(t,r){const i={};1&r&&(i.descriptionId=t[0]),4&r&&(i.step=t[2]),e.$set(i)},i(t){r||(Co(e.$$.fragment,t),r=!0)},o(t){Ro(e.$$.fragment,t),r=!1},d(t){Po(e,t)}}}function sa(t){let e,r;return e=new Vo({props:{step:t[2]}}),{c(){To(e.$$.fragment)},m(t,i){Fo(e,t,i),r=!0},p(t,r){const i={};4&r&&(i.step=t[2]),e.$set(i)},i(t){r||(Co(e.$$.fragment,t),r=!0)},o(t){Ro(e.$$.fragment,t),r=!1},d(t){Po(e,t)}}}function na(t){let e,r,i,s,n=!Ds(t[2].options.title)||t[2].options.cancelIcon&&t[2].options.cancelIcon.enabled,o=!Ds(t[2].options.text),a=Array.isArray(t[2].options.buttons)&&t[2].options.buttons.length,c=n&&ra(t),h=o&&ia(t),u=a&&sa(t);return{c(){e=Jn("div"),c&&c.c(),r=to(),h&&h.c(),i=to(),u&&u.c(),ro(e,"class","shepherd-content")},m(t,n){Yn(t,e,n),c&&c.m(e,null),zn(e,r),h&&h.m(e,null),zn(e,i),u&&u.m(e,null),s=!0},p(t,[s]){4&s&&(n=!Ds(t[2].options.title)||t[2].options.cancelIcon&&t[2].options.cancelIcon.enabled),n?c?(c.p(t,s),4&s&&Co(c,1)):(c=ra(t),c.c(),Co(c,1),c.m(e,r)):c&&(bo(),Ro(c,1,1,()=>{c=null}),Io()),4&s&&(o=!Ds(t[2].options.text)),o?h?(h.p(t,s),4&s&&Co(h,1)):(h=ia(t),h.c(),Co(h,1),h.m(e,i)):h&&(bo(),Ro(h,1,1,()=>{h=null}),Io()),4&s&&(a=Array.isArray(t[2].options.buttons)&&t[2].options.buttons.length),a?u?(u.p(t,s),4&s&&Co(u,1)):(u=sa(t),u.c(),Co(u,1),u.m(e,null)):u&&(bo(),Ro(u,1,1,()=>{u=null}),Io())},i(t){s||(Co(c),Co(h),Co(u),s=!0)},o(t){Ro(c),Ro(h),Ro(u),s=!1},d(t){t&&Xn(e),c&&c.d(),h&&h.d(),u&&u.d()}}}function oa(t,e,r){let{descriptionId:i,labelId:s,step:n}=e;return t.$$set=t=>{"descriptionId"in t&&r(0,i=t.descriptionId),"labelId"in t&&r(1,s=t.labelId),"step"in t&&r(2,n=t.step)},[i,s,n]}class aa extends Oo{constructor(t){super(),Do(this,t,oa,na,Wn,{descriptionId:0,labelId:1,step:2})}}function ha(t){let e;return{c(){e=Jn("div"),ro(e,"class","shepherd-arrow"),ro(e,"data-popper-arrow","")},m(t,r){Yn(t,e,r)},d(t){t&&Xn(e)}}}function ua(t){let e,r,i,s,n,o,a,c,h=t[4].options.arrow&&t[4].options.attachTo&&t[4].options.attachTo.element&&t[4].options.attachTo.on&&ha();i=new aa({props:{descriptionId:t[2],labelId:t[3],step:t[4]}});let u=[{"aria-describedby":s=Ds(t[4].options.text)?null:t[2]},{"aria-labelledby":n=t[4].options.title?t[3]:null},t[1],{role:"dialog"},{tabindex:"0"}],l={};for(let t=0;t<u.length;t+=1)l=Mn(l,u[t]);return{c(){e=Jn("div"),h&&h.c(),r=to(),To(i.$$.fragment),so(e,l),no(e,"shepherd-has-cancel-icon",t[5]),no(e,"shepherd-has-title",t[6]),no(e,"shepherd-element",!0)},m(s,n){Yn(s,e,n),h&&h.m(e,null),zn(e,r),Fo(i,e,null),t[13](e),o=!0,a||(c=eo(e,"keydown",t[7]),a=!0)},p(t,[a]){t[4].options.arrow&&t[4].options.attachTo&&t[4].options.attachTo.element&&t[4].options.attachTo.on?h||(h=ha(),h.c(),h.m(e,r)):h&&(h.d(1),h=null);const c={};4&a&&(c.descriptionId=t[2]),8&a&&(c.labelId=t[3]),16&a&&(c.step=t[4]),i.$set(c),so(e,l=function(t,e){const r={},i={},s={$$scope:1};let n=t.length;for(;n--;){const o=t[n],a=e[n];if(a){for(const t in o)t in a||(i[t]=1);for(const t in a)s[t]||(r[t]=a[t],s[t]=1);t[n]=a}else for(const t in o)s[t]=1}for(const t in i)t in r||(r[t]=void 0);return r}(u,[(!o||20&a&&s!==(s=Ds(t[4].options.text)?null:t[2]))&&{"aria-describedby":s},(!o||24&a&&n!==(n=t[4].options.title?t[3]:null))&&{"aria-labelledby":n},2&a&&t[1],{role:"dialog"},{tabindex:"0"}])),no(e,"shepherd-has-cancel-icon",t[5]),no(e,"shepherd-has-title",t[6]),no(e,"shepherd-element",!0)},i(t){o||(Co(i.$$.fragment,t),o=!0)},o(t){Ro(i.$$.fragment,t),o=!1},d(r){r&&Xn(e),h&&h.d(),Po(i),t[13](null),a=!1,c()}}}function ca(t){return t.split(" ").filter(t=>!!t.length)}function la(t,e,r){let i,s,n,{classPrefix:o,element:a,descriptionId:c,firstFocusableElement:h,focusableElements:u,labelId:l,lastFocusableElement:p,step:d,dataStepId:g}=e;var f;return f=()=>{r(1,g={[`data-${o}shepherd-step-id`]:d.id}),r(9,u=a.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]')),r(8,h=u[0]),r(10,p=u[u.length-1])},ho().$$.on_mount.push(f),uo(()=>{n!==d.options.classes&&(function(t){if(Ps(t)){const e=ca(t);e.length&&a.classList.remove(...e)}}(n),n=d.options.classes,function(t){if(Ps(t)){const e=ca(t);e.length&&a.classList.add(...e)}}(n))}),t.$$set=t=>{"classPrefix"in t&&r(11,o=t.classPrefix),"element"in t&&r(0,a=t.element),"descriptionId"in t&&r(2,c=t.descriptionId),"firstFocusableElement"in t&&r(8,h=t.firstFocusableElement),"focusableElements"in t&&r(9,u=t.focusableElements),"labelId"in t&&r(3,l=t.labelId),"lastFocusableElement"in t&&r(10,p=t.lastFocusableElement),"step"in t&&r(4,d=t.step),"dataStepId"in t&&r(1,g=t.dataStepId)},t.$$.update=()=>{16&t.$$.dirty&&(r(5,i=d.options&&d.options.cancelIcon&&d.options.cancelIcon.enabled),r(6,s=d.options&&d.options.title))},[a,g,c,l,d,i,s,t=>{const{tour:e}=d;switch(t.keyCode){case 9:if(0===u.length){t.preventDefault();break}t.shiftKey?(document.activeElement===h||document.activeElement.classList.contains("shepherd-element"))&&(t.preventDefault(),p.focus()):document.activeElement===p&&(t.preventDefault(),h.focus());break;case 27:e.options.exitOnEsc&&(t.stopPropagation(),d.cancel());break;case 37:e.options.keyboardNavigation&&(t.stopPropagation(),e.back());break;case 39:e.options.keyboardNavigation&&(t.stopPropagation(),e.next())}},h,u,p,o,()=>a,function(t){lo[t?"unshift":"push"](()=>{a=t,r(0,a)})}]}class da extends Oo{constructor(t){super(),Do(this,t,la,ua,Wn,{classPrefix:11,element:0,descriptionId:2,firstFocusableElement:8,focusableElements:9,labelId:3,lastFocusableElement:10,step:4,dataStepId:1,getElement:12})}get getElement(){return this.$$.ctx[12]}}class pa extends Os{constructor(t,e={}){return super(t,e),this.tour=t,this.classPrefix=this.tour.options?_s(this.tour.options.classPrefix):"",this.styles=t.styles,this._resolvedAttachTo=null,Ns(this),this._setOptions(e),this}cancel(){this.tour.cancel(),this.trigger("cancel")}complete(){this.tour.complete(),this.trigger("complete")}destroy(){this.cleanup&&this.cleanup(),this.cleanup=null,Ts(this.el)&&(this.el.remove(),this.el=null),this._updateStepTargetOnHide(),this.trigger("destroy")}getTour(){return this.tour}hide(){this.tour.modal.hide(),this.trigger("before-hide"),this.el&&(this.el.hidden=!0),this._updateStepTargetOnHide(),this.trigger("hide")}_resolveAttachToOptions(){return this._resolvedAttachTo=function(t){const e=t.options.attachTo||{},r=Object.assign({},e);if(Fs(r.element)&&(r.element=r.element.call(t)),Ps(r.element)){try{r.element=document.querySelector(r.element)}catch(t){}r.element||console.error(`The element for this Shepherd step was not found ${e.element}`)}return r}(this),this._resolvedAttachTo}_getResolvedAttachToOptions(){return null===this._resolvedAttachTo?this._resolveAttachToOptions():this._resolvedAttachTo}isOpen(){return Boolean(this.el&&!this.el.hidden)}show(){return Fs(this.options.beforeShowPromise)?Promise.resolve(this.options.beforeShowPromise()).then(()=>this._show()):Promise.resolve(this._show())}updateStepOptions(t){Object.assign(this.options,t),this.shepherdElementComponent&&this.shepherdElementComponent.$set({step:this})}getElement(){return this.el}getTarget(){return this.target}_createTooltipContent(){const t=`${this.id}-description`,e=`${this.id}-label`;return this.shepherdElementComponent=new da({target:this.tour.options.stepsContainer||document.body,props:{classPrefix:this.classPrefix,descriptionId:t,labelId:e,step:this,styles:this.styles}}),this.shepherdElementComponent.getElement()}_scrollTo(t){const{element:e}=this._getResolvedAttachToOptions();Fs(this.options.scrollToHandler)?this.options.scrollToHandler(e):e instanceof Element&&"function"==typeof e.scrollIntoView&&e.scrollIntoView(t)}_getClassOptions(t){const e=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions,r=t.classes?t.classes:"",i=e&&e.classes?e.classes:"",s=[...r.split(" "),...i.split(" ")],n=new Set(s);return Array.from(n).join(" ").trim()}_setOptions(t={}){let e=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions;e=Rs({},e||{}),this.options=Object.assign({arrow:!0},e,t,function(t,e){return{floatingUIOptions:Rs(t.floatingUIOptions||{},e.floatingUIOptions||{})}}(e,t));const{when:r}=this.options;this.options.classes=this._getClassOptions(t),this.destroy(),this.id=this.options.id||`step-${Ls()}`,r&&Object.keys(r).forEach(t=>{this.on(t,r[t],this)})}_setupElements(){Ds(this.el)||this.destroy(),this.el=this._createTooltipContent(),this.options.advanceOn&&function(t){const{event:e,selector:r}=t.options.advanceOn||{};if(!e)return console.error("advanceOn was defined, but no event name was passed.");{const i=function(t,e){return r=>{if(e.isOpen()){const i=e.el&&r.currentTarget===e.el;(!Ds(t)&&r.currentTarget.matches(t)||i)&&e.tour.next()}}}(r,t);let s;try{s=document.querySelector(r)}catch(t){}if(!Ds(r)&&!s)return console.error(`No element was found for the selector supplied to advanceOn: ${r}`);s?(s.addEventListener(e,i),t.on("destroy",()=>s.removeEventListener(e,i))):(document.body.addEventListener(e,i,!0),t.on("destroy",()=>document.body.removeEventListener(e,i,!0)))}}(this),jn(this)}_show(){this.trigger("before-show"),this._resolveAttachToOptions(),this._setupElements(),this.tour.modal||this.tour._setupModal(),this.tour.modal.setupForStep(this),this._styleTargetElementForStep(this),this.el.hidden=!1,this.options.scrollTo&&setTimeout(()=>{this._scrollTo(this.options.scrollTo)}),this.el.hidden=!1;const t=this.shepherdElementComponent.getElement(),e=this.target||document.body;e.classList.add(`${this.classPrefix}shepherd-enabled`),e.classList.add(`${this.classPrefix}shepherd-target`),t.classList.add("shepherd-enabled"),this.trigger("show")}_styleTargetElementForStep(t){const e=t.target;e&&(t.options.highlightClass&&e.classList.add(t.options.highlightClass),e.classList.remove("shepherd-target-click-disabled"),!1===t.options.canClickTarget&&e.classList.add("shepherd-target-click-disabled"))}_updateStepTargetOnHide(){const t=this.target||document.body;this.options.highlightClass&&t.classList.remove(this.options.highlightClass),t.classList.remove("shepherd-target-click-disabled",`${this.classPrefix}shepherd-enabled`,`${this.classPrefix}shepherd-target`)}}function ga(t){let e,r,i,s,n;return{c(){e=Qn("svg"),r=Qn("path"),ro(r,"d",t[2]),ro(e,"class",i=(t[1]?"shepherd-modal-is-visible":"")+" shepherd-modal-overlay-container")},m(i,o){Yn(i,e,o),zn(e,r),t[11](e),s||(n=eo(e,"touchmove",t[3]),s=!0)},p(t,[s]){4&s&&ro(r,"d",t[2]),2&s&&i!==(i=(t[1]?"shepherd-modal-is-visible":"")+" shepherd-modal-overlay-container")&&ro(e,"class",i)},i:Vn,o:Vn,d(r){r&&Xn(e),t[11](null),s=!1,n()}}}function fa(t){if(!t)return null;const e=t instanceof HTMLElement&&window.getComputedStyle(t).overflowY;return"hidden"!==e&&"visible"!==e&&t.scrollHeight>=t.clientHeight?t:fa(t.parentElement)}function ma(t,e,r){let{element:i,openingProperties:s}=e;Ls();let n,o,a=!1;function c(){r(4,s={width:0,height:0,x:0,y:0,r:0})}function h(){r(1,a=!1),d()}function u(t=0,e=0,i,n){if(n){const{y:o,height:a}=function(t,e){const r=t.getBoundingClientRect();let i=r.y||r.top,s=r.bottom||i+r.height;if(e){const t=e.getBoundingClientRect(),r=t.y||t.top,n=t.bottom||r+t.height;i=Math.max(i,r),s=Math.min(s,n)}return{y:i,height:Math.max(s-i,0)}}(n,i),{x:c,width:h,left:u}=n.getBoundingClientRect();r(4,s={width:h+2*t,height:a+2*t,x:(c||u)-t,y:o-t,r:e})}else c()}function l(){r(1,a=!0)}c();const p=t=>{t.preventDefault()};function d(){n&&(cancelAnimationFrame(n),n=void 0),window.removeEventListener("touchmove",p,{passive:!1})}return t.$$set=t=>{"element"in t&&r(0,i=t.element),"openingProperties"in t&&r(4,s=t.openingProperties)},t.$$.update=()=>{16&t.$$.dirty&&r(2,o=function({width:t,height:e,x:r=0,y:i=0,r:s=0}){const{innerWidth:n,innerHeight:o}=window,{topLeft:a=0,topRight:c=0,bottomRight:h=0,bottomLeft:u=0}="number"==typeof s?{topLeft:s,topRight:s,bottomRight:s,bottomLeft:s}:s;return`M${n},${o}H0V0H${n}V${o}ZM${r+a},${i}a${a},${a},0,0,0-${a},${a}V${e+i-u}a${u},${u},0,0,0,${u},${u}H${t+r-h}a${h},${h},0,0,0,${h}-${h}V${i+c}a${c},${c},0,0,0-${c}-${c}Z`}(s))},[i,a,o,t=>{t.stopPropagation()},s,()=>i,c,h,u,function(t){d(),t.tour.options.useModalOverlay?(function(t){const{modalOverlayOpeningPadding:e,modalOverlayOpeningRadius:r}=t.options,i=fa(t.target),s=()=>{n=void 0,u(e,r,i,t.target),n=requestAnimationFrame(s)};s(),window.addEventListener("touchmove",p,{passive:!1})}(t),l()):h()},l,function(t){lo[t?"unshift":"push"](()=>{i=t,r(0,i)})}]}class ya extends Oo{constructor(t){super(),Do(this,t,ma,ga,Wn,{element:0,openingProperties:4,getElement:5,closeModalOpening:6,hide:7,positionModal:8,setupForStep:9,show:10})}get getElement(){return this.$$.ctx[5]}get closeModalOpening(){return this.$$.ctx[6]}get hide(){return this.$$.ctx[7]}get positionModal(){return this.$$.ctx[8]}get setupForStep(){return this.$$.ctx[9]}get show(){return this.$$.ctx[10]}}const va=new Os,Sa="undefined"==typeof window;class Ea{constructor(){}}Sa?Object.assign(va,{Tour:Ea,Step:Ea}):Object.assign(va,{Tour:class extends Os{constructor(t={}){return super(t),Ns(this),this.options=Object.assign({},{exitOnEsc:!0,keyboardNavigation:!0},t),this.classPrefix=_s(this.options.classPrefix),this.steps=[],this.addSteps(this.options.steps),["active","cancel","complete","inactive","show","start"].map(t=>{(t=>{this.on(t,e=>{(e=e||{}).tour=this,va.trigger(t,e)})})(t)}),this._setTourID(),this}addStep(t,e){let r=t;return r instanceof pa?r.tour=this:r=new pa(this,r),Ds(e)?this.steps.push(r):this.steps.splice(e,0,r),r}addSteps(t){return Array.isArray(t)&&t.forEach(t=>{this.addStep(t)}),this}back(){const t=this.steps.indexOf(this.currentStep);this.show(t-1,!1)}async cancel(){if(this.options.confirmCancel){const t="function"==typeof this.options.confirmCancel,e=this.options.confirmCancelMessage||"Are you sure you want to stop the tour?";(t?await this.options.confirmCancel():window.confirm(e))&&this._done("cancel")}else this._done("cancel")}complete(){this._done("complete")}getById(t){return this.steps.find(e=>e.id===t)}getCurrentStep(){return this.currentStep}hide(){const t=this.getCurrentStep();if(t)return t.hide()}isActive(){return va.activeTour===this}next(){const t=this.steps.indexOf(this.currentStep);t===this.steps.length-1?this.complete():this.show(t+1,!0)}removeStep(t){const e=this.getCurrentStep();this.steps.some((e,r)=>{if(e.id===t)return e.isOpen()&&e.hide(),e.destroy(),this.steps.splice(r,1),!0}),e&&e.id===t&&(this.currentStep=void 0,this.steps.length?this.show(0):this.cancel())}show(t=0,e=!0){const r=Ps(t)?this.getById(t):this.steps[t];r&&(this._updateStateBeforeShow(),Fs(r.options.showOn)&&!r.options.showOn()?this._skipStep(r,e):(this.trigger("show",{step:r,previous:this.currentStep}),this.currentStep=r,r.show()))}start(){this.trigger("start"),this.focusedElBeforeOpen=document.activeElement,this.currentStep=null,this._setupModal(),this._setupActiveTour(),this.next()}_done(t){const e=this.steps.indexOf(this.currentStep);if(Array.isArray(this.steps)&&this.steps.forEach(t=>t.destroy()),function(t){if(t){const{steps:e}=t;e.forEach(t=>{t.options&&!1===t.options.canClickTarget&&t.options.attachTo&&t.target instanceof HTMLElement&&t.target.classList.remove("shepherd-target-click-disabled")})}}(this),this.trigger(t,{index:e}),va.activeTour=null,this.trigger("inactive",{tour:this}),this.modal&&this.modal.hide(),("cancel"===t||"complete"===t)&&this.modal){const t=document.querySelector(".shepherd-modal-overlay-container");t&&t.remove()}Ts(this.focusedElBeforeOpen)&&this.focusedElBeforeOpen.focus()}_setupActiveTour(){this.trigger("active",{tour:this}),va.activeTour=this}_setupModal(){this.modal=new ya({target:this.options.modalContainer||document.body,props:{classPrefix:this.classPrefix,styles:this.styles}})}_skipStep(t,e){const r=this.steps.indexOf(t);if(r===this.steps.length-1)this.complete();else{const t=e?r+1:r-1;this.show(t,e)}}_updateStateBeforeShow(){this.currentStep&&this.currentStep.hide(),this.isActive()||this._setupActiveTour()}_setTourID(){const t=this.options.tourName||"tour";this.id=`${t}--${Ls()}`}},Step:pa});class xa{logger=Pt.logger;languageContextService=wt(hr);translate(t,e,r={}){if(e&&"object"==typeof e){const t=this.languageContextService.getSelectedLanguage()??this.languageContextService.getDefaultLanguage(),i=e[t];return i?this.sanitize(this.applyParameters(i,r)):(this.logger.warn(`Missing translation for language [${t}] in message object`),"")}t??=this.languageContextService.getLanguageBundle();let i=t?.[e];return i||(t=this.languageContextService.getDefaultBundle(),i=t?.[e]),i?this.sanitize(this.applyParameters(i,r)):(this.logger.warn(`Missing translation for [${e}] key`),e)}sanitize(t){return(new DOMParser).parseFromString(t,"text/html").body.innerText}applyParameters(t,e={}){return Object.entries(e).reduce((t,[e,r])=>this.replaceAll(t,e,r),t)}replaceAll(t,e,r){return t.split(`{{${e}}}`).join(r)}waitFor(t,e=1,r=!0){const i=this.resolveSelector(t);return new Promise((t,s)=>{let n=1e3*e;const o=setInterval(()=>{try{const e=document.querySelector(i);e?!r||this.isElementVisible(e)?(clearInterval(o),t(e)):(n-=100,n<0&&(clearInterval(o),this.logger.warn("Element is not visible: "+i),s(new Error("Element is not visible: "+i)))):(n-=100,n<0&&(clearInterval(o),this.logger.warn("Element is not found: "+i),s(new Error("Element is not found: "+i))))}catch(t){clearInterval(o),this.logger.error("Error when processing selector: "+i),this.logger.error(String(t)),s(t)}},100)})}getOrWaitFor(t,e=1,r=!0){const i=this.resolveSelector(t),s=document.querySelector(i);return!s||r&&!this.isElementVisible(s)?this.waitFor(t,e,r):Promise.resolve(s)}scrollToOffset(t){const e=("string"==typeof t?xa.SCROLL_OFFSET_MAP[t]:void 0)??t;c.getWindow().scrollTo({top:e,behavior:"smooth"})}isElementVisible(t){const e=c.getWindow().getComputedStyle(t),r=t.getBoundingClientRect();return"none"!==e.display&&"hidden"!==e.visibility&&"0"!==e.opacity&&0!==r.width&&0!==r.height}resolveSelector(t){return"function"==typeof t?t():t}static SCROLL_OFFSET_MAP={start:0,center:c.getWindow().innerHeight/2}}class wa extends Je{NAMESPACE="guides";GUIDE_ID="guide_id";CURRENT_STEP_ID="guide.current.step.id";STEP_HISTORY="guide.step.history";PAUSE="guide.pause";AUTOSTART="guides.autostart";set(t,e){this.storeValue(t,e)}getGuideId(){return this.get(this.GUIDE_ID).getValue()}setGuideId(t){this.set(this.GUIDE_ID,t)}getCurrentStepId(){return this.get(this.CURRENT_STEP_ID).getValue()}setCurrentStepId(t){this.set(this.CURRENT_STEP_ID,t)}getHistory(){const t=this.get(this.STEP_HISTORY).getAsJson();return Array.isArray(t)?t:[]}addStepToHistory(t){const e=this.getHistory();e.push(t),this.set(this.STEP_HISTORY,JSON.stringify(e))}removeLastStepFromHistory(){const t=this.getHistory();t.pop(),this.set(this.STEP_HISTORY,JSON.stringify(t))}getPreviousStepIdFromHistory(t){const e=this.getHistory();if(t){const r=e.indexOf(t);return r>0?e[r-1]:void 0}return e.length>1?e.at(-2):void 0}clearHistory(){this.remove(this.STEP_HISTORY)}isPaused(){return"true"===this.get(this.PAUSE).getValue()}setPaused(){this.set(this.PAUSE,"true")}clearPaused(){this.remove(this.PAUSE)}saveStep(t,e){this.setGuideId(t),this.setCurrentStepId(e)}isAutostartDisabled(t){const e=this.get(this.AUTOSTART).getAsJson();return!!e?.[t]?.disabled}disableAutostart(t){const e=this.get(this.AUTOSTART).getAsJson()||{};e[t]={disabled:!0},this.set(this.AUTOSTART,JSON.stringify(e))}clearAll(){this.remove(this.GUIDE_ID),this.remove(this.PAUSE),this.remove(this.CURRENT_STEP_ID),this.remove(this.STEP_HISTORY)}}class Aa{eventEmitter=new ir;confirmCancel(t){return new Promise(e=>{this.eventEmitter.emit({NAME:ne,payload:new oe(t,t=>e(t))})})}}const ba="nearest";class Ia{logger=Pt.logger;toastrService=wt(Gi);guideApi=wt(xa);guideStorage=wt(wa);guideAutostarted=null;onPause=()=>{};onCancel=()=>{};startGuide(t,e,r,i=!1,s=!0){if(i&&this.guideStorage.isAutostartDisabled(t))return;if(this.guideAutostarted=i,s&&this.guideStorage.clearHistory(),!e)return;const n=this.createGuide(t);this.addGuideSteps(n,e),this.doStartGuide(n,r)}resumeGuide(t,e,r){this.guideStorage.clearPaused(),this.startGuide(t,e,r,!1,!1)}isActive(){return!!va.activeTour&&!this.isPaused()}isPaused(){return this.guideStorage.isPaused()}getGuideId(){return this.guideStorage.getGuideId()}getCurrentStepId(){return this.guideStorage.getCurrentStepId()}isScrollingAllowed(){const t=va.activeTour?.getCurrentStep()?.options?.allowScroll;return!this.isActive()||!!t}subscribeToGuideCancel(t){"function"==typeof t&&(this.onCancel=t)}subscribeToGuidePause(t){"function"==typeof t&&(this.onPause=t)}getPreviousStepFromHistory(t){const e=this.guideStorage.getPreviousStepIdFromHistory(t);return va.activeTour?.steps.find(t=>t.id===e)}createGuide(t){return this.subscribeToGuideCanceled(),new va.Tour({tourName:t,useModalOverlay:!0,confirmCancel:()=>this.confirmGuideCancel(),defaultStepOptions:{classes:"shadow-md bg-purple-dark",scrollTo:{behavior:"smooth",block:ba,inline:ba}}})}addGuideSteps(t,e){if(e.length>0&&t.addStep(this.getFirstStep(t,e)),e.length>2)for(let r=1;r<e.length-1;r++)t.addStep(this.getMiddleStep(t,e,r));e.length>1&&t.addStep(this.getLastStep(t,e.at(-1)))}doStartGuide(t,e){this.guideStorage.clearPaused();let r=t.steps.findIndex(t=>t.options.id===e);r<0&&(r=0);const i=t.steps[r].options,s=i.url;s&&s!==S()&&f(s);const n=i.attachTo;if(n?.element){const e=i.maxWaitTime;this.guideApi.getOrWaitFor(n.element,e).then(()=>t.show(r)).catch(t=>{this.logger.error(String(t)),this.toastrService.error(this.guideApi.translate(void 0,"guide.start.unexpected.error.message"))})}else t.show(r)}subscribeToGuideCanceled(){const t=({tour:t})=>{this.guideStorage.clearAll();const e=t.getCurrentStep();e&&"function"==typeof e.hide&&e.hide(),this.guideAutostarted=null,this.onCancel&&this.onCancel()};this.guideCancelSubscription||(this.guideCancelSubscription=va.on("cancel",t)),this.guideCompleteSubscription||(this.guideCompleteSubscription=va.on("complete",t))}getFirstStep(t,e){const r=e.length>1?e[1]:void 0;return this.toGuideStep(t,void 0,e[0],r)}getMiddleStep(t,e,r){const i=e[r];return i.lastStep?this.getLastStep(t,i):this.toGuideStep(t,e[r-1],i,e[r+1])}getLastStep(t,e){const r=this.toGuideStep(t,void 0,e);return r.buttons.push(this.getBackToGuidesButton(t),this.getCancelButton(t)),r}toGuideStep(t,e,r,i){const s=this.toBaseGuideStep(t,r,()=>this.updateLocalStorage()),n=[];return r.skipPoint&&n.push(this.getSkipButton(t,r.skipButtonLabel)),!this.isDisablePreviousFlow(r)&&e&&n.push(this.getPreviousButton(t)),!this.isDisableNextFlow(r)&&i&&n.push(this.getNextButton(t,r,i)),s.buttons=n,s}toBaseGuideStep(t,e,r){let i;e.elementSelector&&(i={element:e.elementSelector,on:e.placement});const s=this.guideApi.sanitize(this.guideApi.translate(void 0,e.title||""));let n="";if(e.stepsTotalN&&e.stepsTotalN>1){const t=document.createElement("span");t.setAttribute("gdb-tooltip",this.guideApi.translate(void 0,"guide.block.progress.tooltip",e)),t.setAttribute("tooltip-placement","bottom"),t.innerText=this.guideApi.translate(void 0,"guide.block.progress",{n:String((e.stepN||0)+1),nn:String(e.stepsTotalN)}),n="&nbsp;&mdash;&nbsp;"+t.outerHTML}const o="readonly"!==e.type,a=e.extraPadding||0,c={id:String(e.id),title:s+n,text:()=>{const t=this.toParagraph(this.guideApi.translate(void 0,e.content||""));let r="";return e.extraContent&&(r=this.toParagraph(this.guideApi.translate(void 0,e.extraContent,e),e.extraContentClass)),t+r},url:e.url,maxWaitTime:e.maxWaitTime,cancelIcon:{enabled:!0},attachTo:i,modalOverlayOpeningPadding:a,modalOverlayOpeningRadius:0,canBePaused:e.canBePaused,advanceOn:e.advanceOn,showOn:e.showOn,scrollToHandler:e.scrollToHandler,classes:`guide-dialog ${e.class||""}-guide-dialog`,beforeShowPromise:this.getBeforeShowPromise(t,e),canClickTarget:o,keyboardNavigation:!1,skipPoint:e.skipPoint,skipButtonLabel:e.skipButtonLabel,skipFromHistory:e.skipFromHistory,onPreviousClick:e.onPreviousClick,initPreviousStep:e.initPreviousStep,forceReload:e.forceReload,isLastStep:!!e.lastStep,allowScroll:e.allowScroll,when:{show:this.getShowFunction(t,e,r)}};return"function"==typeof e.hide&&c.when&&(c.when.hide=e.hide(t,e)),c}getBeforeShowPromise(t,e){if("function"==typeof e.beforeShowPromise)return()=>e.beforeShowPromise(t,e)}getShowFunction(t,e,r){return"function"==typeof e.show?()=>{e.show(t,e)(),r(),this.whenStepShow(e)}:()=>{r(),this.whenStepShow(e)}}whenStepShow(t){const e=va.activeTour?.getCurrentStep();if(!e)return;const r=e.getElement();r&&(this.addTotalProgress(e,r),this.addTypeIcon(r,t))}getBackToGuidesButton(t){return this.getButton(this.guideApi.translate(void 0,"guide.back.to.guides.btn"),()=>this.backToGuides(t),!0)}getCancelButton(t){const e=this.getButton(this.guideApi.translate(void 0,"guide.common.close"),()=>this.completeGuide(t),!0);return e.classes+=" shepherd-cancel-button",e}getSkipButton(t,e){const r=this.guideApi.translate(void 0,e||"");return this.getButton(r,()=>this.skipSteps(t),!0)}getPreviousButton(t){const e=this.guideApi.translate(void 0,"guide.previous.btn"),r=this.getPreviousButtonAction(t),i=this.getButton(e,r);return i.classes+=" shepherd-prev-button",i}getNextButton(t,e,r){const i=this.guideApi.translate(void 0,"guide.next.btn"),s=this.getNextButtonAction(t,e,r),n=this.getButton(i,s);return n.classes+=" shepherd-next-button",n}getButton(t,e,r=!1){return{text:t,classes:r?"onto-btn onto-btn-secondary":"onto-btn onto-btn-primary",action:()=>{e()}}}getPreviousButtonAction(t){return()=>{const e=this.guideStorage.getPreviousStepIdFromHistory();let r;r=e?t.steps.find(t=>t.options.id===e):t.steps[0];const i=t.getCurrentStep();if(!i||!r)return;i.hide();const s=i.options.initPreviousStep;("function"==typeof s?s({GuideUtils:this.guideApi,ShepherdService:this},i.options.id):Promise.resolve()).then(()=>{const e=i.options.onPreviousClick;if("function"==typeof e)return void e(t).then(e=>{e||(i.hide(),t.show(r.id))}).catch(e=>{this.logger.error(String(e)),this.abortGuide(t)});const s=r.options;if(s.forceReload||s.url&&s.url!==i.options.url){const t=s.url;t&&S()!==t&&f(t)}i.hide(),t.show(r.id)}).catch(e=>{this.logger.error(String(e)),this.abortGuide(t)})}}getNextButtonAction(t,e,r){return()=>{e.onNextValidate&&e.onNextValidate(e).then(i=>{if(i)if("function"==typeof e.onNextClick){const r=e.onNextClick(t,e);r instanceof Promise&&r.catch(()=>this.abortGuide(t))}else r.url&&(r.forceReload||r.url!==e.url)&&f(r.url),t.next()})}}backToGuides(t){f("guides"),this.completeGuide(t)}async confirmGuideCancel(){const t=va.activeTour,e=t.steps.at(-1),r=t.getCurrentStep();if(e&&e.id===r?.id)return this.completeGuide(t),!0;t.hide();const i=await wt(Aa).confirmCancel(this.guideAutostarted??!1);if(i===se.CANCEL)return r&&t.show(r.id),!1;if(i===se.DONT_SHOW_AGAIN){const e=t.options.tourName;e&&this.guideStorage.disableAutostart(e)}return!0}completeGuide(t){if(this.guideAutostarted){const e=t.options.tourName;e&&this.guideStorage.disableAutostart(e)}t.complete()}abortGuide(t){this.toastrService.error(this.guideApi.translate(void 0,"guide.unexpected.error.message")),t.options.confirmCancel=!1,t.cancel()}pauseGuide(t){t.hide();const e=t.getCurrentStep();if(!e)return;const r=this.getStepWhichCanBePaused(t.steps,e.id);if(r){const e=t?.options?.tourName;e&&this.guideStorage.saveStep(e,r.options.id)}if(this.guideStorage.setPaused(),r){let t=!1;for(;!t;){const e=this.guideStorage.getHistory();e.length>0&&e.at(-1)!==r.options.id?this.guideStorage.removeLastStepFromHistory():t=!0}}this.onPause()}skipSteps(t){const e=t.getCurrentStep();if(!e)return;const r=t.steps.findIndex(t=>e.id===t.id);this.doStartGuide(t,this.getNextSkipPointId(t.steps,r))}getNextSkipPointId(t,e){for(let r=e+1;r<t.length;r++){const e=t[r];if(e.options.skipPoint)return e.id}return t.at(-1)?.id}getStepWhichCanBePaused(t,e){const r=t.findIndex(t=>t.id===e),i=t[r];return i.options.canBePaused?i:r>0?this.getStepWhichCanBePaused(t,t[r-1].id):void 0}updateLocalStorage(){const t=va.activeTour;if(!t)return;const e=t.getCurrentStep();if(!e)return;if(e.options.skipFromHistory)return void this.logger.info("Current step skipped from history",e.options.id);const r=t.steps.findIndex(t=>t.id===e.id),i=this.getCurrentStepId(),s=t.steps.findIndex(t=>t.id===i);r>s?this.guideStorage.addStepToHistory(e.options.id):s>r&&this.guideStorage.removeLastStepFromHistory();const n=t.options.tourName||"";this.guideStorage.saveStep(n,e.options.id)}toParagraph(t,e){if(t){const r=document.createElement("p");return e&&(r.className=e),r.innerHTML=t,r.outerHTML}return""}addTotalProgress(t,e){const r=va.activeTour?.steps;if(!r)return;const i=e.querySelector(".shepherd-content");if(!i)return;const s=document.createElement("div");s.className="shepherd-progress";const n=document.createElement("span");n.className="text-muted",n.innerText=this.guideApi.translate(void 0,"guide.total.progress",{n:String(r.indexOf(t)+1),nn:String(r.length)}),n.setAttribute("gdb-tooltip",this.guideApi.translate(void 0,"guide.total.progress.tooltip")),n.setAttribute("tooltip-placement","left"),s.appendChild(n),i.appendChild(s)}addTypeIcon(t,e){let r,i;switch(e.type){case"clickable":r="focus",i="mouse";break;case"input":r="edit",i="input";break;default:r="info",i="info"}const s=document.createElement("span");s.className="shepherd-step-type icon-"+r+" icon-1-25x",s.setAttribute("gdb-tooltip",this.guideApi.translate(void 0,"guide.step-type."+i)),s.setAttribute("tooltip-placement","bottom-right");const n=t.querySelector(".shepherd-header");n&&n.insertBefore(s,n.firstChild)}isDisablePreviousFlow(t){return t.disablePreviousFlow??!1}isDisableNextFlow(t){return t.disableNextFlow??!1}}class Ca extends Ct{PAUSED="isPaused";updatePaused(t){this.updateContextProperty(this.PAUSED,t)}isPaused(){return this.getContextPropertyValue(this.PAUSED)}}class Ra extends nr{GUIDES_ENDPOINT="rest/guides";getGuides(){return this.get(this.GUIDES_ENDPOINT)}}class Ta{shepherdService=wt(Ia);toastrService=wt(Gi);repositoryContextService=wt(mr);guideApi=wt(xa);guideContextService=wt(Ca);guidesRestService=wt(Ra);startGuide(t,e,r,i=!1){const s=wt(hr).getLanguageBundle();if(!t)return void this.toastrService.error(this.guideApi.translate(s,"guides.error.guide-not-found"));const n=t.getRepositoryIdBase();if(n){const e=this.repositoryContextService.getRepositoryList();t.setRepositoryId(n);const r=1e3;for(let i=2;i<=r&&e.findRepository(t.getRepositoryId(),"",!0);i++)t.setRepositoryId(n+i)}t.setTranslatedGuideName(this.guideApi.translate(s,t.getName())),t.setTranslatedGuideDescription(this.guideApi.translate(s,t.getDescription()));const o=c.getPluginRegistry().get(Te.NAME),a=t.toStepsDescriptions(o,e);a.forEach((t,e)=>{t.id=e,t.scrollOffset&&(t.scrollToHandler=()=>this.guideApi.scrollToOffset(t.scrollOffset))}),r?this.shepherdService.resumeGuide(t.getId(),a,r):this.shepherdService.startGuide(t.getId(),a,r,i),this.guideContextService.updatePaused(!1)}async getGuides(){return((t=[])=>t.map((t,e)=>{const r=void 0===t.guideId?String(Date.now()+e):String(t.guideId);return new De({guideId:r,guideName:t.guideName,guideDescription:t.guideDescription,options:t.options,steps:t.steps,guideOrder:t.guideOrder,guideLevel:t.guideLevel})}))(await this.guidesRestService.getGuides())}autoStartGuide(t,e){if(!t)return;const r=String(t);this.getGuides().then(t=>{const i=t.find(t=>t.getId()===r);i&&this.startGuide(i,e,void 0,!0)})}isScrollingAllowed(){return this.shepherdService.isScrollingAllowed()}isActive(){return this.shepherdService.isActive()}}class Fa extends nr{CONNECTORS_ENDPOINT="rest/connectors";checkConnector(t){return this.post(`${this.CONNECTORS_ENDPOINT}/check`,{body:t,headers:{"Content-Type":"text/plain"}})}}class Pa extends Error{constructor(t){super(`Unknown connector command: ${t}`)}}class Da{connectorsRestService=wt(Fa);async checkConnector(t){return(t=>{let e;if(t.command)if(t.hasSupport)if($e.CREATE===t.command)e=(t=>{const e=[{name:t.name}];return new qe(Ge.SUCCESS,t.command,"created.connector",e)})(t);else if($e.REPAIR===t.command)e=(t=>{const e=[{name:t.name}];return new qe(Ge.SUCCESS,t.command,"query.editor.repaired.connector",e)})(t);else{if($e.DROP!==t.command)throw new Pa(t.command);e=(t=>{const e=[{name:t.name}];return new qe(Ge.SUCCESS,t.command,"externalsync.delete.success.msg",e)})(t)}else e=(t=>{const e=[{connectorName:t.connectorName},{pluginName:t.pluginName}];return new qe(Ge.ERROR,t.command,"query.editor.inactive.plugin.warning.msg",e)})(t);else e=(t=>new qe(Ge.SUCCESS,t.command))(t);return e.iri=t.iri,e})(await this.connectorsRestService.checkConnector(t))}}class Oa extends nr{static EXPLORE_GRAPH_ENDPOINT="rest/explore-graph";getGraphConfigs(){return this.get(`${Oa.EXPLORE_GRAPH_ENDPOINT}/config`)}}const Na=t=>new We({id:t.id,name:t.name,description:t.description,owner:t.owner,repositoryId:t.repositoryId,hint:t.hint,shared:t.shared??!1,startMode:t.startMode??Ye.SEARCH,startIRI:t.startIRI,startIRILabel:t.startIRILabel,startQueryIncludeInferred:t.startQueryIncludeInferred??!0,startQuerySameAs:t.startQuerySameAs??!0,startGraphQuery:t.startGraphQuery,expandQuery:t.expandQuery,predicateLabelQuery:t.predicateLabelQuery,resourcePropertiesQuery:t.resourcePropertiesQuery,resourceQuery:t.resourceQuery});class _a{graphConfigRestService=wt(Oa);async getGraphConfigs(){return t=await this.graphConfigRestService.getGraphConfigs(),Array.isArray(t)?new ze(t.map(Na)):new ze;var t}}class Ba extends Be{authStorage=xt.get(ti);repositoryStorageService=xt.get(fr);securityContextService=xt.get(Nr);process(t){return t.headers=t.headers||{},this.populateHeaders(t.headers),Promise.resolve(t)}shouldProcess(t){return!this.isOpenIdUrl(t.url)}populateHeaders(t){t["X-Requested-With"]="XMLHttpRequest";const e=this.authStorage.getAuthToken().getValue();if(e&&(t.Authorization=e),!t["X-GraphDB-Repository"]){const e=this.repositoryStorageService.getRepositoryReference();e?.id&&(t["X-GraphDB-Repository"]=e.id),e?.location&&(t["X-GraphDB-Repository-Location"]=e.location)}}isOpenIdUrl(t){const e=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;return!!e&&[e?.openIdKeysUri,e?.openIdTokenUrl].some(e=>e&&t.indexOf(e)>-1)}}class La extends Be{authenticationStorageService=wt(ti);authenticationService=wt(Ri);shouldProcess(t){return 401===t.status}process(t){return this.shouldRedirectToLogin(t.url)?(this.authenticationStorageService.clearAuthToken(),v()||(f("login"),c.getWindow().location.reload()),Promise.reject(t)):Promise.resolve(t)}shouldRedirectToLogin(t){let e;try{e=this.authenticationService.isExternalUser()}catch(t){e=!1}return!t.includes("rest/security/authenticated-user")&&!e}}class Ha extends Be{securityContextService=wt(Nr);authenticationService=wt(Ri);logger=Pt.logger;shouldProcess(t){return 403===t.status}process(t){const e=S();return this.logger.warn("Permission to page denied. Some errors in the console are normal"),this.updateRestrictionsForPage(e),this.shouldRedirectToLogin()&&f("login"),Promise.reject(t)}updateRestrictionsForPage(t){const e=this.securityContextService.getRestrictedPages();e&&!e.isRestricted(t)&&(e.setPageRestriction(t),this.securityContextService.updateRestrictedPages(e))}shouldRedirectToLogin(){return!this.authenticationService.isAuthenticated()}}export{it as AppSettings,$ as ApplicationBeforeChange,W as ApplicationChanged,rs as ApplicationLifecycleContextService,q as ApplicationMounted,s as ApplicationSettings,Ze as ApplicationSettingsStorageService,G as ApplicationUnmounted,Ba as AuthRequestInterceptor,ut as AuthSettings,xi as AuthStrategyResolver,ot as AuthenticatedUser,Ri as AuthenticationService,ti as AuthenticationStorageService,X as AuthenticationType,J as Authority,rt as AuthorityList,bi as AuthorizationService,Yi as AutocompleteContextService,le as AutocompleteSearchResult,Wi as AutocompleteService,zi as AutocompleteStorageService,Nt as AvailableLanguagesList,qe as BeforeUpdateQueryResult,Ge as BeforeUpdateQueryResultStatus,Pi as BrowserCookieStore,l as BuildUtil,u as ByteUtils,ne as CONFIRM_CANCEL_EVENT,Li as COOKIE_CONSENT_CHANGED_EVENT,re as CREATE_TOAST_EVENT,se as CancelDialogAction,ft as CapabilityList,Rt as ConfigurationContextService,ds as ConfigurationRestService,ps as ConfigurationService,oe as ConfirmCancelPayload,$e as ConnectorCommand,Fa as ConnectorsRestService,Da as ConnectorsService,Ct as ContextService,It as ContextSubscriptionManager,Fi as CookieBuilder,Lt as CookieConsent,Di as CookieService,I as DateUtil,Aa as DialogService,Lr as ErrorBase,U as Event,ir as EventEmitter,j as EventName,ri as EventService,Se as ExtensionPoint,p as FibonacciGenerator,Bi as GoogleAnalyticsCookieService,We as GraphConfig,ze as GraphConfigList,_a as GraphConfigService,xa as GuideApi,Ca as GuideContextService,Ie as GuidePlugin,wa as GuideStorageService,Ra as GuidesRestService,Ta as GuidesService,sr as HTTP_REQUEST_DONE_EVENT,je as HttpErrorResponse,Be as HttpInterceptor,Le as HttpInterceptorList,He as HttpRequest,Ue as HttpResponse,ke as HttpResponseBase,_i as InstallationCookieService,De as InteractiveGuide,Te as InteractiveGuideExtensionPoint,rr as InterceptorService,Bt as LanguageConfig,hr as LanguageContextService,or as LanguageRestService,lr as LanguageService,ar as LanguageStorageService,gt as License,Tr as LicenseContextService,Fr as LicenseService,fe as LifecycleState,Je as LocalStorageService,Qe as LocalStorageSubscriptionHandlerService,Tt as LoggerService,Ft as Loggers,Y as Login,z as Logout,Ce as MainMenuExtensionPoint,Ae as MainMenuItem,we as MainMenuPlugin,C as Model,R as ModelList,ki as MonitoringRestService,Vi as MonitoringService,k as NamespaceMap,ts as NamespacesContextService,Zi as NamespacesService,Ci as NavigationContextService,V as NavigationEnd,M as NavigationEndPayload,K as NavigationStart,Ne as Notification,_e as NotificationParam,Wr as NotificationService,Oe as NotificationType,n as ObjectUtil,Gi as OntoToastrService,Yr as OpenIdAuthFlowHandler,Jr as OpenIdRestService,ii as OpenIdService,Zr as OpenIdTokenRefreshManager,Qr as OpenIdUrlBuilder,Vr as OpenIdUtils,at as OpenidSecurityConfig,_r as OpenidStorageService,zt as Operation,qt as OperationGroup,Ut as OperationGroupSummary,jt as OperationGroupSummaryList,Mt as OperationList,Ht as OperationStatus,Vt as OperationStatusSummary,Kt as OperationType,Ss as ParentWindowMessageService,xe as Plugin,me as PluginDefinition,Ee as PluginDefinitionList,us as PluginRegistry,ye as PluginsManifest,is as PluginsRestService,ss as PluginsService,mt as ProductInfo,Pr as ProductInfoContextService,Or as ProductInfoService,B as REPOSITORY_ID_PARAM,Qi as Rdf4jRepositoryService,Ji as Rdf4jRestService,F as Repository,yr as RepositoryAuthorityService,mr as RepositoryContextService,D as RepositoryList,L as RepositoryLocation,xr as RepositoryLocationContextService,Er as RepositoryLocationService,H as RepositoryLocationType,dr as RepositoryRestService,gr as RepositoryService,O as RepositorySizeInfo,N as RepositoryState,fr as RepositoryStorageService,_ as RepositoryType,es as ResourceSearchStorageService,dt as RestrictedPages,pt as Rights,Re as RouteExtensionPoint,be as RoutePlugin,tr as RuntimeConfigurationContextService,kt as STATUS_ORDER,Me as SavedQuery,Ve as SavedQueryList,Ke as ScrollLocation,ue as SearchButton,he as SearchButtonConfig,ae as SearchButtonList,lt as SecurityConfig,Nr as SecurityContextService,mi as SecurityService,xt as ServiceProvider,Ia as ShepherdService,fs as SparqlRestService,ys as SparqlService,vs as SparqlStorageService,Ye as StartMode,Dt as StorageData,Ot as StorageKey,T as SubscriptionList,de as Suggestion,ce as SuggestionList,ge as SuggestionSelectedPayload,pe as SuggestionType,i as ThemeMode,er as ThemeService,Fe as ThemesExtensionPoint,ee as ToastMessage,ie as ToastMessageList,Qt as ToastType,Jt as ToastrConfig,Yt as ToastrPosition,Hi as TrackingService,Oi as TrackingStorageService,La as UnauthenticatedInterceptor,Ha as UnauthorizedInterceptor,d as UriUtil,Xe as UrlPathParams,nt as User,st as UserType,fi as UsersService,c as WindowService,x as getBasePath,w as getCurrentRoute,A as getLocationPathWithQueryParams,E as getOrigin,S as getPathName,y as isHomePage,v as isLoginPage,ct as mapAuthSettingsResponseToModel,ui as mapAuthenticatedUserResponseToModel,tt as mapGrantedAuthoritiesResponseToModel,Xi as mapNamespaceResponseToModel,ji as mapOperationSummaryResponseToModel,pr as mapRepositoryListResponseToModel,ms as mapSavedQueryListResponseToModel,gs as mapSparqlTemplatesResponseToModel,pi as mapUserModelToRequest,gi as mapUserResponseToModel,f as navigate,g as navigateTo,zr as notify,m as openInNewTab,wt as service,b as toEnum};
2
+ var t={355(t,e){var r,i,s,n,o,a,h,c,u,l,d,p={userAgent:!1},g={},f=f||(r=Math,s=(i={}).lib={},n=s.Base=function(){function t(){}return{extend:function(e){t.prototype=this;var r=new t;return e&&r.mixIn(e),r.hasOwnProperty("init")||(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),o=s.WordArray=n.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||h).stringify(this)},concat:function(t){var e=this.words,r=t.words,i=this.sigBytes,s=t.sigBytes;if(this.clamp(),i%4)for(var n=0;n<s;n++){var o=r[n>>>2]>>>24-n%4*8&255;e[i+n>>>2]|=o<<24-(i+n)%4*8}else for(n=0;n<s;n+=4)e[i+n>>>2]=r[n>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=r.ceil(e/4)},clone:function(){var t=n.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i<t;i+=4)e.push(4294967296*r.random()|0);return new o.init(e,t)}}),a=i.enc={},h=a.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],s=0;s<r;s++){var n=e[s>>>2]>>>24-s%4*8&255;i.push((n>>>4).toString(16)),i.push((15&n).toString(16))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i+=2)r[i>>>3]|=parseInt(t.substr(i,2),16)<<24-i%8*4;return new o.init(r,e/2)}},c=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],s=0;s<r;s++){var n=e[s>>>2]>>>24-s%4*8&255;i.push(String.fromCharCode(n))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i++)r[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;return new o.init(r,e)}},u=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},l=s.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=u.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,s=e.sigBytes,n=this.blockSize,a=s/(4*n),h=(a=t?r.ceil(a):r.max((0|a)-this._minBufferSize,0))*n,c=r.min(4*h,s);if(h){for(var u=0;u<h;u+=n)this._doProcessBlock(i,u);var l=i.splice(0,h);e.sigBytes-=c}return new o.init(l,c)},clone:function(){var t=n.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),s.Hasher=l.extend({cfg:n.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,r){return new t.init(r).finalize(e)}},_createHmacHelper:function(t){return function(e,r){return new d.HMAC.init(t,r).finalize(e)}}}),d=i.algo={},i);!function(){var t,e=(t=f).lib,r=e.Base,i=e.WordArray;(t=t.x64={}).Word=r.extend({init:function(t,e){this.high=t,this.low=e}}),t.WordArray=r.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:8*t.length},toX32:function(){for(var t=this.words,e=t.length,r=[],s=0;s<e;s++){var n=t[s];r.push(n.high),r.push(n.low)}return i.create(r,this.sigBytes)},clone:function(){for(var t=r.clone.call(this),e=t.words=this.words.slice(0),i=e.length,s=0;s<i;s++)e[s]=e[s].clone();return t}})}(),f.lib.Cipher||function(){var t=(d=f).lib,e=t.Base,r=t.WordArray,i=t.BufferedBlockAlgorithm,s=d.enc.Base64,n=d.algo.EvpKDF,o=t.Cipher=i.extend({cfg:e.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){i.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(t){return{encrypt:function(e,r,i){return("string"==typeof r?p:l).encrypt(t,e,r,i)},decrypt:function(e,r,i){return("string"==typeof r?p:l).decrypt(t,e,r,i)}}}});t.StreamCipher=o.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var a=d.mode={},h=function(t,e,r){var i=this._iv;i?this._iv=void 0:i=this._prevBlock;for(var s=0;s<r;s++)t[e+s]^=i[s]},c=(t.BlockCipherMode=e.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}})).extend();c.Encryptor=c.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize;h.call(this,t,e,i),r.encryptBlock(t,e),this._prevBlock=t.slice(e,e+i)}}),c.Decryptor=c.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,s=t.slice(e,e+i);r.decryptBlock(t,e),h.call(this,t,e,i),this._prevBlock=s}}),a=a.CBC=c,c=(d.pad={}).Pkcs7={pad:function(t,e){for(var i,s=(i=(i=4*e)-t.sigBytes%i)<<24|i<<16|i<<8|i,n=[],o=0;o<i;o+=4)n.push(s);i=r.create(n,i),t.concat(i)},unpad:function(t){t.sigBytes-=255&t.words[t.sigBytes-1>>>2]}},t.BlockCipher=o.extend({cfg:o.cfg.extend({mode:a,padding:c}),reset:function(){o.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var r=e.createEncryptor;else r=e.createDecryptor,this._minBufferSize=1;this._mode=r.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var u=t.CipherParams=e.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),l=(a=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?r.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=r.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return u.create({ciphertext:t,salt:i})}},t.SerializableCipher=e.extend({cfg:e.extend({format:a}),encrypt:function(t,e,r,i){i=this.cfg.extend(i);var s=t.createEncryptor(r,i);return e=s.finalize(e),s=s.cfg,u.create({ciphertext:e,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:i.format})},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),t.createDecryptor(r,i).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,s){return s||(s=r.random(8)),t=n.create({keySize:e+i}).compute(t,s),i=r.create(t.words.slice(e),4*i),t.sigBytes=4*e,u.create({key:t,iv:i,salt:s})}},p=t.PasswordBasedCipher=l.extend({cfg:l.cfg.extend({kdf:d}),encrypt:function(t,e,r,i){return r=(i=this.cfg.extend(i)).kdf.execute(r,t.keySize,t.ivSize),i.iv=r.iv,(t=l.encrypt.call(this,t,e,r.key,i)).mixIn(r),t},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),r=i.kdf.execute(r,t.keySize,t.ivSize,e.salt),i.iv=r.iv,l.decrypt.call(this,t,e,r.key,i)}})}(),function(){for(var t=f,e=t.lib.BlockCipher,r=t.algo,i=[],s=[],n=[],o=[],a=[],h=[],c=[],u=[],l=[],d=[],p=[],g=0;256>g;g++)p[g]=128>g?g<<1:g<<1^283;var m=0,y=0;for(g=0;256>g;g++){var v=(v=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&v^99;i[m]=v,s[v]=m;var S=p[m],E=p[S],x=p[E],w=257*p[v]^16843008*v;n[m]=w<<24|w>>>8,o[m]=w<<16|w>>>16,a[m]=w<<8|w>>>24,h[m]=w,w=16843009*x^65537*E^257*S^16843008*m,c[v]=w<<24|w>>>8,u[v]=w<<16|w>>>16,l[v]=w<<8|w>>>24,d[v]=w,m?(m=S^p[p[p[x^S]]],y^=p[p[y]]):m=y=1}var A=[0,1,2,4,8,16,32,64,128,27,54];r=r.AES=e.extend({_doReset:function(){for(var t=(r=this._key).words,e=r.sigBytes/4,r=4*((this._nRounds=e+6)+1),s=this._keySchedule=[],n=0;n<r;n++)if(n<e)s[n]=t[n];else{var o=s[n-1];n%e?6<e&&4==n%e&&(o=i[o>>>24]<<24|i[o>>>16&255]<<16|i[o>>>8&255]<<8|i[255&o]):(o=i[(o=o<<8|o>>>24)>>>24]<<24|i[o>>>16&255]<<16|i[o>>>8&255]<<8|i[255&o],o^=A[n/e|0]<<24),s[n]=s[n-e]^o}for(t=this._invKeySchedule=[],e=0;e<r;e++)n=r-e,o=e%4?s[n]:s[n-4],t[e]=4>e||4>=n?o:c[i[o>>>24]]^u[i[o>>>16&255]]^l[i[o>>>8&255]]^d[i[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,n,o,a,h,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,c,u,l,d,s),r=t[e+1],t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,i,s,n,o,a){for(var h=this._nRounds,c=t[e]^r[0],u=t[e+1]^r[1],l=t[e+2]^r[2],d=t[e+3]^r[3],p=4,g=1;g<h;g++){var f=i[c>>>24]^s[u>>>16&255]^n[l>>>8&255]^o[255&d]^r[p++],m=i[u>>>24]^s[l>>>16&255]^n[d>>>8&255]^o[255&c]^r[p++],y=i[l>>>24]^s[d>>>16&255]^n[c>>>8&255]^o[255&u]^r[p++];d=i[d>>>24]^s[c>>>16&255]^n[u>>>8&255]^o[255&l]^r[p++],c=f,u=m,l=y}f=(a[c>>>24]<<24|a[u>>>16&255]<<16|a[l>>>8&255]<<8|a[255&d])^r[p++],m=(a[u>>>24]<<24|a[l>>>16&255]<<16|a[d>>>8&255]<<8|a[255&c])^r[p++],y=(a[l>>>24]<<24|a[d>>>16&255]<<16|a[c>>>8&255]<<8|a[255&u])^r[p++],d=(a[d>>>24]<<24|a[c>>>16&255]<<16|a[u>>>8&255]<<8|a[255&l])^r[p++],t[e]=f,t[e+1]=m,t[e+2]=y,t[e+3]=d},keySize:8}),t.AES=e._createHelper(r)}(),function(){function t(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<<t}function e(t,e){var r=(this._rBlock>>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<<t}var r=f,i=(s=r.lib).WordArray,s=s.BlockCipher,n=r.algo,o=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],h=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],c=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],u=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],l=n.DES=s.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;56>r;r++){var i=o[r]-1;e[r]=t[i>>>5]>>>31-i%32&1}for(t=this._subKeys=[],i=0;16>i;i++){var s=t[i]=[],n=h[i];for(r=0;24>r;r++)s[r/6|0]|=e[(a[r]-1+n)%28]<<31-r%6,s[4+(r/6|0)]|=e[28+(a[r+24]-1+n)%28]<<31-r%6;for(s[0]=s[0]<<1|s[0]>>>31,r=1;7>r;r++)s[r]>>>=4*(r-1)+3;s[7]=s[7]<<5|s[7]>>>27}for(e=this._invSubKeys=[],r=0;16>r;r++)e[r]=t[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(r,i,s){this._lBlock=r[i],this._rBlock=r[i+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var n=0;16>n;n++){for(var o=s[n],a=this._lBlock,h=this._rBlock,l=0,d=0;8>d;d++)l|=c[d][((h^o[d])&u[d])>>>0];this._lBlock=h,this._rBlock=a^l}s=this._lBlock,this._lBlock=this._rBlock,this._rBlock=s,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),r[i]=this._lBlock,r[i+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=s._createHelper(l),n=n.TripleDES=s.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(i.create(t.slice(0,2))),this._des2=l.createEncryptor(i.create(t.slice(2,4))),this._des3=l.createEncryptor(i.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=s._createHelper(n)}(),function(){var t=f,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,i=this._map;t.clamp(),t=[];for(var s=0;s<r;s+=3)for(var n=(e[s>>>2]>>>24-s%4*8&255)<<16|(e[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|e[s+2>>>2]>>>24-(s+2)%4*8&255,o=0;4>o&&s+.75*o<r;o++)t.push(i.charAt(n>>>6*(3-o)&63));if(e=i.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var r=t.length,i=this._map;(s=i.charAt(64))&&-1!=(s=t.indexOf(s))&&(r=s);for(var s=[],n=0,o=0;o<r;o++)if(o%4){var a=i.indexOf(t.charAt(o-1))<<o%4*2,h=i.indexOf(t.charAt(o))>>>6-o%4*2;s[n>>>2]|=(a|h)<<24-n%4*8,n++}return e.create(s,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,r,i,s,n,o){return((t=t+(e&r|~e&i)+s+o)<<n|t>>>32-n)+e}function r(t,e,r,i,s,n,o){return((t=t+(e&i|r&~i)+s+o)<<n|t>>>32-n)+e}function i(t,e,r,i,s,n,o){return((t=t+(e^r^i)+s+o)<<n|t>>>32-n)+e}function s(t,e,r,i,s,n,o){return((t=t+(r^(e|~i))+s+o)<<n|t>>>32-n)+e}for(var n=f,o=(h=n.lib).WordArray,a=h.Hasher,h=n.algo,c=[],u=0;64>u;u++)c[u]=4294967296*t.abs(t.sin(u+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,n){for(var o=0;16>o;o++){var a=t[h=n+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[n+0],u=(a=t[n+1],t[n+2]),l=t[n+3],d=t[n+4],p=t[n+5],g=t[n+6],f=t[n+7],m=t[n+8],y=t[n+9],v=t[n+10],S=t[n+11],E=t[n+12],x=t[n+13],w=t[n+14],A=t[n+15],b=e(b=o[0],T=o[1],I=o[2],C=o[3],h,7,c[0]),C=e(C,b,T,I,a,12,c[1]),I=e(I,C,b,T,u,17,c[2]),T=e(T,I,C,b,l,22,c[3]);b=e(b,T,I,C,d,7,c[4]),C=e(C,b,T,I,p,12,c[5]),I=e(I,C,b,T,g,17,c[6]),T=e(T,I,C,b,f,22,c[7]),b=e(b,T,I,C,m,7,c[8]),C=e(C,b,T,I,y,12,c[9]),I=e(I,C,b,T,v,17,c[10]),T=e(T,I,C,b,S,22,c[11]),b=e(b,T,I,C,E,7,c[12]),C=e(C,b,T,I,x,12,c[13]),I=e(I,C,b,T,w,17,c[14]),b=r(b,T=e(T,I,C,b,A,22,c[15]),I,C,a,5,c[16]),C=r(C,b,T,I,g,9,c[17]),I=r(I,C,b,T,S,14,c[18]),T=r(T,I,C,b,h,20,c[19]),b=r(b,T,I,C,p,5,c[20]),C=r(C,b,T,I,v,9,c[21]),I=r(I,C,b,T,A,14,c[22]),T=r(T,I,C,b,d,20,c[23]),b=r(b,T,I,C,y,5,c[24]),C=r(C,b,T,I,w,9,c[25]),I=r(I,C,b,T,l,14,c[26]),T=r(T,I,C,b,m,20,c[27]),b=r(b,T,I,C,x,5,c[28]),C=r(C,b,T,I,u,9,c[29]),I=r(I,C,b,T,f,14,c[30]),b=i(b,T=r(T,I,C,b,E,20,c[31]),I,C,p,4,c[32]),C=i(C,b,T,I,m,11,c[33]),I=i(I,C,b,T,S,16,c[34]),T=i(T,I,C,b,w,23,c[35]),b=i(b,T,I,C,a,4,c[36]),C=i(C,b,T,I,d,11,c[37]),I=i(I,C,b,T,f,16,c[38]),T=i(T,I,C,b,v,23,c[39]),b=i(b,T,I,C,x,4,c[40]),C=i(C,b,T,I,h,11,c[41]),I=i(I,C,b,T,l,16,c[42]),T=i(T,I,C,b,g,23,c[43]),b=i(b,T,I,C,y,4,c[44]),C=i(C,b,T,I,E,11,c[45]),I=i(I,C,b,T,A,16,c[46]),b=s(b,T=i(T,I,C,b,u,23,c[47]),I,C,h,6,c[48]),C=s(C,b,T,I,f,10,c[49]),I=s(I,C,b,T,w,15,c[50]),T=s(T,I,C,b,p,21,c[51]),b=s(b,T,I,C,E,6,c[52]),C=s(C,b,T,I,l,10,c[53]),I=s(I,C,b,T,v,15,c[54]),T=s(T,I,C,b,a,21,c[55]),b=s(b,T,I,C,m,6,c[56]),C=s(C,b,T,I,A,10,c[57]),I=s(I,C,b,T,g,15,c[58]),T=s(T,I,C,b,x,21,c[59]),b=s(b,T,I,C,d,6,c[60]),C=s(C,b,T,I,S,10,c[61]),I=s(I,C,b,T,u,15,c[62]),T=s(T,I,C,b,y,21,c[63]),o[0]=o[0]+b|0,o[1]=o[1]+T|0,o[2]=o[2]+I|0,o[3]=o[3]+C|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;r[s>>>5]|=128<<24-s%32;var n=t.floor(i/4294967296);for(r[15+(s+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),r[14+(s+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(r.length+1),this._process(),r=(e=this._hash).words,i=0;4>i;i++)s=r[i],r[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),n.MD5=a._createHelper(h),n.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=f,e=(s=t.lib).WordArray,r=s.Hasher,i=[],s=t.algo.SHA1=r.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,s=r[0],n=r[1],o=r[2],a=r[3],h=r[4],c=0;80>c;c++){if(16>c)i[c]=0|t[e+c];else{var u=i[c-3]^i[c-8]^i[c-14]^i[c-16];i[c]=u<<1|u>>>31}u=(s<<5|s>>>27)+h+i[c],u=20>c?u+(1518500249+(n&o|~n&a)):40>c?u+(1859775393+(n^o^a)):60>c?u+((n&o|n&a|o&a)-1894007588):u+((n^o^a)-899497514),h=a,a=o,o=n<<30|n>>>2,n=s,s=u}r[0]=r[0]+s|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(i+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=r._createHelper(s),t.HmacSHA1=r._createHmacHelper(s)}(),function(t){for(var e=f,r=(s=e.lib).WordArray,i=s.Hasher,s=e.algo,n=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,c=0;64>c;){var u;t:{u=h;for(var l=t.sqrt(u),d=2;d<=l;d++)if(!(u%d)){u=!1;break t}u=!0}u&&(8>c&&(n[c]=a(t.pow(h,.5))),o[c]=a(t.pow(h,1/3)),c++),h++}var p=[];s=s.SHA256=i.extend({_doReset:function(){this._hash=new r.init(n.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],s=r[1],n=r[2],a=r[3],h=r[4],c=r[5],u=r[6],l=r[7],d=0;64>d;d++){if(16>d)p[d]=0|t[e+d];else{var g=p[d-15],f=p[d-2];p[d]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+p[d-7]+((f<<15|f>>>17)^(f<<13|f>>>19)^f>>>10)+p[d-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&c^~h&u)+o[d]+p[d],f=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&s^i&n^s&n),l=u,u=c,c=h,h=a+g|0,a=n,n=s,s=i,i=g+f|0}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+n|0,r[3]=r[3]+a|0,r[4]=r[4]+h|0,r[5]=r[5]+c|0,r[6]=r[6]+u|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;return r[s>>>5]|=128<<24-s%32,r[14+(s+64>>>9<<4)]=t.floor(i/4294967296),r[15+(s+64>>>9<<4)]=i,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA256=i._createHelper(s),e.HmacSHA256=i._createHmacHelper(s)}(Math),function(){var t=f,e=t.lib.WordArray,r=(i=t.algo).SHA256,i=i.SHA224=r.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=r._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=r._createHelper(i),t.HmacSHA224=r._createHmacHelper(i)}(),function(){function t(){return i.create.apply(i,arguments)}for(var e=f,r=e.lib.Hasher,i=(n=e.x64).Word,s=n.WordArray,n=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();n=n.SHA512=r.extend({_doReset:function(){this._hash=new s.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=(l=this._hash.words)[0],i=l[1],s=l[2],n=l[3],h=l[4],c=l[5],u=l[6],l=l[7],d=r.high,p=r.low,g=i.high,f=i.low,m=s.high,y=s.low,v=n.high,S=n.low,E=h.high,x=h.low,w=c.high,A=c.low,b=u.high,C=u.low,I=l.high,T=l.low,R=d,F=p,P=g,D=f,O=m,N=y,_=v,L=S,B=E,H=x,k=w,U=A,j=b,V=C,M=I,K=T,q=0;80>q;q++){var G=a[q];if(16>q)var $=G.high=0|t[e+2*q],W=G.low=0|t[e+2*q+1];else{$=((W=($=a[q-15]).high)>>>1|(J=$.low)<<31)^(W>>>8|J<<24)^W>>>7;var J=(J>>>1|W<<31)^(J>>>8|W<<24)^(J>>>7|W<<25),z=((W=(z=a[q-2]).high)>>>19|(Y=z.low)<<13)^(W<<3|Y>>>29)^W>>>6,Y=(Y>>>19|W<<13)^(Y<<3|W>>>29)^(Y>>>6|W<<26),X=(W=a[q-7]).high,Q=(Z=a[q-16]).high,Z=Z.low;$=($=($=$+X+((W=J+W.low)>>>0<J>>>0?1:0))+z+((W+=Y)>>>0<Y>>>0?1:0))+Q+((W+=Z)>>>0<Z>>>0?1:0),G.high=$,G.low=W}X=B&k^~B&j,Z=H&U^~H&V,G=R&P^R&O^P&O;var tt=F&D^F&N^D&N,et=(J=(R>>>28|F<<4)^(R<<30|F>>>2)^(R<<25|F>>>7),z=(F>>>28|R<<4)^(F<<30|R>>>2)^(F<<25|R>>>7),(Y=o[q]).high),rt=Y.low;Q=M+((B>>>14|H<<18)^(B>>>18|H<<14)^(B<<23|H>>>9))+((Y=K+((H>>>14|B<<18)^(H>>>18|B<<14)^(H<<23|B>>>9)))>>>0<K>>>0?1:0),M=j,K=V,j=k,V=U,k=B,U=H,B=_+(Q=(Q=(Q=Q+X+((Y+=Z)>>>0<Z>>>0?1:0))+et+((Y+=rt)>>>0<rt>>>0?1:0))+$+((Y+=W)>>>0<W>>>0?1:0))+((H=L+Y|0)>>>0<L>>>0?1:0)|0,_=O,L=N,O=P,N=D,P=R,D=F,R=Q+(G=J+G+((W=z+tt)>>>0<z>>>0?1:0))+((F=Y+W|0)>>>0<Y>>>0?1:0)|0}p=r.low=p+F,r.high=d+R+(p>>>0<F>>>0?1:0),f=i.low=f+D,i.high=g+P+(f>>>0<D>>>0?1:0),y=s.low=y+N,s.high=m+O+(y>>>0<N>>>0?1:0),S=n.low=S+L,n.high=v+_+(S>>>0<L>>>0?1:0),x=h.low=x+H,h.high=E+B+(x>>>0<H>>>0?1:0),A=c.low=A+U,c.high=w+k+(A>>>0<U>>>0?1:0),C=u.low=C+V,u.high=b+j+(C>>>0<V>>>0?1:0),T=l.low=T+K,l.high=I+M+(T>>>0<K>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[30+(i+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(i+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=r._createHelper(n),e.HmacSHA512=r._createHmacHelper(n)}(),function(){var t=f,e=(s=t.x64).Word,r=s.WordArray,i=(s=t.algo).SHA512,s=s.SHA384=i.extend({_doReset:function(){this._hash=new r.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=i._createHelper(s),t.HmacSHA384=i._createHmacHelper(s)}(),function(){var t=f,e=(i=t.lib).WordArray,r=i.Hasher,i=t.algo,s=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),n=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),c=e.create([1352829926,1548603684,1836072691,2053994217,0]);i=i.RIPEMD160=r.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;16>r;r++){var i=t[x=e+r];t[x]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var u,l,d,p,g,f,m,y,v,S,E,x=this._hash.words,w=(i=h.words,c.words),A=s.words,b=n.words,C=o.words,I=a.words;for(f=u=x[0],m=l=x[1],y=d=x[2],v=p=x[3],S=g=x[4],r=0;80>r;r+=1)E=u+t[e+A[r]]|0,E=16>r?E+((l^d^p)+i[0]):32>r?E+((l&d|~l&p)+i[1]):48>r?E+(((l|~d)^p)+i[2]):64>r?E+((l&p|d&~p)+i[3]):E+((l^(d|~p))+i[4]),E=(E=(E|=0)<<C[r]|E>>>32-C[r])+g|0,u=g,g=p,p=d<<10|d>>>22,d=l,l=E,E=f+t[e+b[r]]|0,E=16>r?E+((m^(y|~v))+w[0]):32>r?E+((m&v|y&~v)+w[1]):48>r?E+(((m|~y)^v)+w[2]):64>r?E+((m&y|~m&v)+w[3]):E+((m^y^v)+w[4]),E=(E=(E|=0)<<I[r]|E>>>32-I[r])+S|0,f=S,S=v,v=y<<10|y>>>22,y=m,m=E;E=x[1]+d+v|0,x[1]=x[2]+p+S|0,x[2]=x[3]+g+f|0,x[3]=x[4]+u+m|0,x[4]=x[0]+l+y|0,x[0]=E},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;for(e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,r=0;5>r;r++)i=e[r],e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}}),t.RIPEMD160=r._createHelper(i),t.HmacRIPEMD160=r._createHmacHelper(i)}(Math),function(){var t=f,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,r){t=this._hasher=new t.init,"string"==typeof r&&(r=e.parse(r));var i=t.blockSize,s=4*i;r.sigBytes>s&&(r=t.finalize(r)),r.clamp();for(var n=this._oKey=r.clone(),o=this._iKey=r.clone(),a=n.words,h=o.words,c=0;c<i;c++)a[c]^=1549556828,h[c]^=909522486;n.sigBytes=o.sigBytes=s,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher;return t=e.finalize(t),e.reset(),e.finalize(this._oKey.clone().concat(t))}})}(),function(){var t,e=f,r=(t=e.lib).Base,i=t.WordArray,s=(t=e.algo).HMAC,n=t.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:t.SHA1,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){var r=this.cfg,n=s.create(r.hasher,t),o=i.create(),a=i.create([1]),h=o.words,c=a.words,u=r.keySize;for(r=r.iterations;h.length<u;){var l=n.update(e).finalize(a);n.reset();for(var d=l.words,p=d.length,g=l,f=1;f<r;f++){g=n.finalize(g),n.reset();for(var m=g.words,y=0;y<p;y++)d[y]^=m[y]}o.concat(l),c[0]++}return o.sigBytes=4*u,o}});e.PBKDF2=function(t,e,r){return n.create(r).compute(t,e)}}();var m,y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function v(t){var e,r,i="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),i+=y.charAt(r>>6)+y.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),i+=y.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),i+=y.charAt(r>>2)+y.charAt((3&r)<<4));(3&i.length)>0;)i+="=";return i}function S(t){var e,r,i,s="",n=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e)(i=y.indexOf(t.charAt(e)))<0||(0==n?(s+=C(i>>2),r=3&i,n=1):1==n?(s+=C(r<<2|i>>4),r=15&i,n=2):2==n?(s+=C(r),s+=C(i>>2),r=3&i,n=3):(s+=C(r<<2|i>>4),s+=C(15&i),n=0));return 1==n&&(s+=C(r<<2)),s}function E(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function x(){return new E(null)}"Microsoft Internet Explorer"==p.appName?(E.prototype.am=function(t,e,r,i,s,n){for(var o=32767&e,a=e>>15;--n>=0;){var h=32767&this[t],c=this[t++]>>15,u=a*h+c*o;s=((h=o*h+((32767&u)<<15)+r[i]+(1073741823&s))>>>30)+(u>>>15)+a*c+(s>>>30),r[i++]=1073741823&h}return s},m=30):"Netscape"!=p.appName?(E.prototype.am=function(t,e,r,i,s,n){for(;--n>=0;){var o=e*this[t++]+r[i]+s;s=Math.floor(o/67108864),r[i++]=67108863&o}return s},m=26):(E.prototype.am=function(t,e,r,i,s,n){for(var o=16383&e,a=e>>14;--n>=0;){var h=16383&this[t],c=this[t++]>>14,u=a*h+c*o;s=((h=o*h+((16383&u)<<14)+r[i]+s)>>28)+(u>>14)+a*c,r[i++]=268435455&h}return s},m=28),E.prototype.DB=m,E.prototype.DM=(1<<m)-1,E.prototype.DV=1<<m,E.prototype.FV=Math.pow(2,52),E.prototype.F1=52-m,E.prototype.F2=2*m-52;var w,A,b=new Array;for(w="0".charCodeAt(0),A=0;A<=9;++A)b[w++]=A;for(w="a".charCodeAt(0),A=10;A<36;++A)b[w++]=A;for(w="A".charCodeAt(0),A=10;A<36;++A)b[w++]=A;function C(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function I(t,e){var r=b[t.charCodeAt(e)];return null==r?-1:r}function T(t){var e=x();return e.fromInt(t),e}function R(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function F(t){this.m=t}function P(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function D(t,e){return t&e}function O(t,e){return t|e}function N(t,e){return t^e}function _(t,e){return t&~e}function L(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function B(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function H(){}function k(t){return t}function U(t){this.r2=x(),this.q3=x(),E.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}F.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},F.prototype.revert=function(t){return t},F.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},F.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},F.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},P.prototype.convert=function(t){var e=x();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(E.ZERO)>0&&this.m.subTo(e,e),e},P.prototype.revert=function(t){var e=x();return t.copyTo(e),this.reduce(e),e},P.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],i=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},P.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},P.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},E.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},E.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},E.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var i=t.length,s=!1,n=0;--i>=0;){var o=8==r?255&t[i]:I(t,i);o<0?"-"==t.charAt(i)&&(s=!0):(s=!1,0==n?this[this.t++]=o:n+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-n)-1)<<n,this[this.t++]=o>>this.DB-n):this[this.t-1]|=o<<n,(n+=r)>=this.DB&&(n-=this.DB))}8==r&&128&t[0]&&(this.s=-1,n>0&&(this[this.t-1]|=(1<<this.DB-n)-1<<n)),this.clamp(),s&&E.ZERO.subTo(this,this)},E.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},E.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},E.prototype.drShiftTo=function(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},E.prototype.lShiftTo=function(t,e){var r,i=t%this.DB,s=this.DB-i,n=(1<<s)-1,o=Math.floor(t/this.DB),a=this.s<<i&this.DM;for(r=this.t-1;r>=0;--r)e[r+o+1]=this[r]>>s|a,a=(this[r]&n)<<i;for(r=o-1;r>=0;--r)e[r]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},E.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,s=this.DB-i,n=(1<<i)-1;e[0]=this[r]>>i;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&n)<<s,e[o-r]=this[o]>>i;i>0&&(e[this.t-r-1]|=(this.s&n)<<s),e.t=this.t-r,e.clamp()}},E.prototype.subTo=function(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()},E.prototype.multiplyTo=function(t,e){var r=this.abs(),i=t.abs(),s=r.t;for(e.t=s+i.t;--s>=0;)e[s]=0;for(s=0;s<i.t;++s)e[s+r.t]=r.am(0,i[s],e,s,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&E.ZERO.subTo(e,e)},E.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var i=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,i,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},E.prototype.divRemTo=function(t,e,r){var i=t.abs();if(!(i.t<=0)){var s=this.abs();if(s.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=x());var n=x(),o=this.s,a=t.s,h=this.DB-R(i[i.t-1]);h>0?(i.lShiftTo(h,n),s.lShiftTo(h,r)):(i.copyTo(n),s.copyTo(r));var c=n.t,u=n[c-1];if(0!=u){var l=u*(1<<this.F1)+(c>1?n[c-2]>>this.F2:0),d=this.FV/l,p=(1<<this.F1)/l,g=1<<this.F2,f=r.t,m=f-c,y=null==e?x():e;for(n.dlShiftTo(m,y),r.compareTo(y)>=0&&(r[r.t++]=1,r.subTo(y,r)),E.ONE.dlShiftTo(c,y),y.subTo(n,n);n.t<c;)n[n.t++]=0;for(;--m>=0;){var v=r[--f]==u?this.DM:Math.floor(r[f]*d+(r[f-1]+g)*p);if((r[f]+=n.am(0,v,r,m,0,c))<v)for(n.dlShiftTo(m,y),r.subTo(y,r);r[f]<--v;)r.subTo(y,r)}null!=e&&(r.drShiftTo(c,e),o!=a&&E.ZERO.subTo(e,e)),r.t=c,r.clamp(),h>0&&r.rShiftTo(h,r),o<0&&E.ZERO.subTo(r,r)}}},E.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},E.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},E.prototype.exp=function(t,e){if(t>4294967295||t<1)return E.ONE;var r=x(),i=x(),s=e.convert(this),n=R(t)-1;for(s.copyTo(r);--n>=0;)if(e.sqrTo(r,i),(t&1<<n)>0)e.mulTo(i,s,r);else{var o=r;r=i,i=o}return e.revert(r)},E.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,i=(1<<e)-1,s=!1,n="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(s=!0,n=C(r));o>=0;)a<e?(r=(this[o]&(1<<a)-1)<<e-a,r|=this[--o]>>(a+=this.DB-e)):(r=this[o]>>(a-=e)&i,a<=0&&(a+=this.DB,--o)),r>0&&(s=!0),s&&(n+=C(r));return s?n:"0"},E.prototype.negate=function(){var t=x();return E.ZERO.subTo(this,t),t},E.prototype.abs=function(){return this.s<0?this.negate():this},E.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},E.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+R(this[this.t-1]^this.s&this.DM)},E.prototype.mod=function(t){var e=x();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(E.ZERO)>0&&t.subTo(e,e),e},E.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new F(e):new P(e),this.exp(t,r)},E.ZERO=T(0),E.ONE=T(1),H.prototype.convert=k,H.prototype.revert=k,H.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},H.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=x();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var j,V,M,K=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],q=(1<<26)/K[K.length-1];function G(){this.i=0,this.j=0,this.S=new Array}function $(){!function(t){V[M++]^=255&t,V[M++]^=t>>8&255,V[M++]^=t>>16&255,V[M++]^=t>>24&255,M>=256&&(M-=256)}((new Date).getTime())}if(E.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},E.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=T(r),s=x(),n=x(),o="";for(this.divRemTo(i,s,n);s.signum()>0;)o=(r+n.intValue()).toString(t).substr(1)+o,s.divRemTo(i,s,n);return n.intValue().toString(t)+o},E.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),s=!1,n=0,o=0,a=0;a<t.length;++a){var h=I(t,a);h<0?"-"==t.charAt(a)&&0==this.signum()&&(s=!0):(o=e*o+h,++n>=r&&(this.dMultiply(i),this.dAddOffset(o,0),n=0,o=0))}n>0&&(this.dMultiply(Math.pow(e,n)),this.dAddOffset(o,0)),s&&E.ZERO.subTo(this,this)},E.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(E.ONE.shiftLeft(t-1),O,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(E.ONE.shiftLeft(t-1),this);else{var i=new Array,s=7&t;i.length=1+(t>>3),e.nextBytes(i),s>0?i[0]&=(1<<s)-1:i[0]=0,this.fromString(i,256)}},E.prototype.bitwiseTo=function(t,e,r){var i,s,n=Math.min(t.t,this.t);for(i=0;i<n;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(s=t.s&this.DM,i=n;i<this.t;++i)r[i]=e(this[i],s);r.t=this.t}else{for(s=this.s&this.DM,i=n;i<t.t;++i)r[i]=e(s,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},E.prototype.changeBit=function(t,e){var r=E.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},E.prototype.addTo=function(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()},E.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},E.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},E.prototype.multiplyLowerTo=function(t,e,r){var i,s=Math.min(this.t+t.t,e);for(r.s=0,r.t=s;s>0;)r[--s]=0;for(i=r.t-this.t;s<i;++s)r[s+this.t]=this.am(0,t[s],r,s,0,this.t);for(i=Math.min(t.t,e);s<i;++s)this.am(0,t[s],r,s,0,e-s);r.clamp()},E.prototype.multiplyUpperTo=function(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-e);r.clamp(),r.drShiftTo(1,r)},E.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r},E.prototype.millerRabin=function(t){var e=this.subtract(E.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var i=e.shiftRight(r);(t=t+1>>1)>K.length&&(t=K.length);for(var s=x(),n=0;n<t;++n){s.fromInt(K[Math.floor(Math.random()*K.length)]);var o=s.modPow(i,this);if(0!=o.compareTo(E.ONE)&&0!=o.compareTo(e)){for(var a=1;a++<r&&0!=o.compareTo(e);)if(0==(o=o.modPowInt(2,this)).compareTo(E.ONE))return!1;if(0!=o.compareTo(e))return!1}}return!0},E.prototype.clone=function(){var t=x();return this.copyTo(t),t},E.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},E.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},E.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},E.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},E.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,i=this.DB-t*this.DB%8,s=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[s++]=r|this.s<<this.DB-i);t>=0;)i<8?(r=(this[t]&(1<<i)-1)<<8-i,r|=this[--t]>>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&r&&(r|=-256),0==s&&(128&this.s)!=(128&r)&&++s,(s>0||r!=this.s)&&(e[s++]=r);return e},E.prototype.equals=function(t){return 0==this.compareTo(t)},E.prototype.min=function(t){return this.compareTo(t)<0?this:t},E.prototype.max=function(t){return this.compareTo(t)>0?this:t},E.prototype.and=function(t){var e=x();return this.bitwiseTo(t,D,e),e},E.prototype.or=function(t){var e=x();return this.bitwiseTo(t,O,e),e},E.prototype.xor=function(t){var e=x();return this.bitwiseTo(t,N,e),e},E.prototype.andNot=function(t){var e=x();return this.bitwiseTo(t,_,e),e},E.prototype.not=function(){for(var t=x(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},E.prototype.shiftLeft=function(t){var e=x();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},E.prototype.shiftRight=function(t){var e=x();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},E.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+L(this[t]);return this.s<0?this.t*this.DB:-1},E.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=B(this[r]^e);return t},E.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)},E.prototype.setBit=function(t){return this.changeBit(t,O)},E.prototype.clearBit=function(t){return this.changeBit(t,_)},E.prototype.flipBit=function(t){return this.changeBit(t,N)},E.prototype.add=function(t){var e=x();return this.addTo(t,e),e},E.prototype.subtract=function(t){var e=x();return this.subTo(t,e),e},E.prototype.multiply=function(t){var e=x();return this.multiplyTo(t,e),e},E.prototype.divide=function(t){var e=x();return this.divRemTo(t,e,null),e},E.prototype.remainder=function(t){var e=x();return this.divRemTo(t,null,e),e},E.prototype.divideAndRemainder=function(t){var e=x(),r=x();return this.divRemTo(t,e,r),new Array(e,r)},E.prototype.modPow=function(t,e){var r,i,s=t.bitLength(),n=T(1);if(s<=0)return n;r=s<18?1:s<48?3:s<144?4:s<768?5:6,i=s<8?new F(e):e.isEven()?new U(e):new P(e);var o=new Array,a=3,h=r-1,c=(1<<r)-1;if(o[1]=i.convert(this),r>1){var u=x();for(i.sqrTo(o[1],u);a<=c;)o[a]=x(),i.mulTo(u,o[a-2],o[a]),a+=2}var l,d,p=t.t-1,g=!0,f=x();for(s=R(t[p])-1;p>=0;){for(s>=h?l=t[p]>>s-h&c:(l=(t[p]&(1<<s+1)-1)<<h-s,p>0&&(l|=t[p-1]>>this.DB+s-h)),a=r;!(1&l);)l>>=1,--a;if((s-=a)<0&&(s+=this.DB,--p),g)o[l].copyTo(n),g=!1;else{for(;a>1;)i.sqrTo(n,f),i.sqrTo(f,n),a-=2;a>0?i.sqrTo(n,f):(d=n,n=f,f=d),i.mulTo(f,o[l],n)}for(;p>=0&&!(t[p]&1<<s);)i.sqrTo(n,f),d=n,n=f,f=d,--s<0&&(s=this.DB-1,--p)}return i.revert(n)},E.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return E.ZERO;for(var r=t.clone(),i=this.clone(),s=T(1),n=T(0),o=T(0),a=T(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(s.isEven()&&n.isEven()||(s.addTo(this,s),n.subTo(t,n)),s.rShiftTo(1,s)):n.isEven()||n.subTo(t,n),n.rShiftTo(1,n);for(;i.isEven();)i.rShiftTo(1,i),e?(o.isEven()&&a.isEven()||(o.addTo(this,o),a.subTo(t,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(i)>=0?(r.subTo(i,r),e&&s.subTo(o,s),n.subTo(a,n)):(i.subTo(r,i),e&&o.subTo(s,o),a.subTo(n,a))}return 0!=i.compareTo(E.ONE)?E.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},E.prototype.pow=function(t){return this.exp(t,new H)},E.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var s=e.getLowestSetBit(),n=r.getLowestSetBit();if(n<0)return e;for(s<n&&(n=s),n>0&&(e.rShiftTo(n,e),r.rShiftTo(n,r));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return n>0&&r.lShiftTo(n,r),r},E.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=K[K.length-1]){for(e=0;e<K.length;++e)if(r[0]==K[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<K.length;){for(var i=K[e],s=e+1;s<K.length&&i<q;)i*=K[s++];for(i=r.modInt(i);e<s;)if(i%K[e++]==0)return!1}return r.millerRabin(t)},E.prototype.square=function(){var t=x();return this.squareTo(t),t},G.prototype.init=function(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0},G.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]},null==V){var W;if(V=new Array,M=0,void 0!==g&&(void 0!==g.crypto||void 0!==g.msCrypto)){var J=g.crypto||g.msCrypto;if(J.getRandomValues){var z=new Uint8Array(32);for(J.getRandomValues(z),W=0;W<32;++W)V[M++]=z[W]}else if("Netscape"==p.appName&&p.appVersion<"5"){var Y=g.crypto.random(32);for(W=0;W<Y.length;++W)V[M++]=255&Y.charCodeAt(W)}}for(;M<256;)W=Math.floor(65536*Math.random()),V[M++]=W>>>8,V[M++]=255&W;M=0,$()}function X(){if(null==j){for($(),(j=new G).init(V),M=0;M<V.length;++M)V[M]=0;M=0}return j.next()}function Q(){}function Z(t,e){return new E(t,e)}function tt(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function et(t,e){this.x=e,this.q=t}function rt(t,e,r,i){this.curve=t,this.x=e,this.y=r,this.z=null==i?E.ONE:i,this.zinv=null}function it(t,e,r){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(r),this.infinity=new rt(this,null,null)}Q.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=X()},tt.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},tt.prototype.setPublic=function(t,e){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof t)this.n=t,this.e=e;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA public key";this.n=Z(t,16),this.e=parseInt(e,16)}if(null==this.n||"function"!=typeof this.n.compareTo||this.n.compareTo(E.ONE)<=0||null==this.e||isNaN(this.e)||this.e<=0)throw"Invalid RSA public key"},tt.prototype.type="RSA",tt.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)},tt.prototype.setPrivate=function(t,e,r){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=r;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=Z(t,16),this.e=parseInt(e,16),this.d=Z(r,16)}},tt.prototype.setPrivateEx=function(t,e,r,i,s,n,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=Z(t,16),this.e=parseInt(e,16),this.d=Z(r,16),this.p=Z(i,16),this.q=Z(s,16),this.dmp1=Z(n,16),this.dmq1=Z(o,16),this.coeff=Z(a,16)},tt.prototype.generate=function(t,e){var r=new Q,i=t>>1;this.e=parseInt(e,16);for(var s=new E(e,16),n=t/2-100,o=E.ONE.shiftLeft(n);;){for(;this.p=new E(t-i,1,r),0!=this.p.subtract(E.ONE).gcd(s).compareTo(E.ONE)||!this.p.isProbablePrime(10););for(;this.q=new E(i,1,r),0!=this.q.subtract(E.ONE).gcd(s).compareTo(E.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var a=this.p;this.p=this.q,this.q=a}var h=this.q.subtract(this.p).abs();if(!(h.bitLength()<n||h.compareTo(o)<=0)){var c=this.p.subtract(E.ONE),u=this.q.subtract(E.ONE),l=c.multiply(u);if(0==l.gcd(s).compareTo(E.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=s.modInverse(l),this.dmp1=this.d.mod(c),this.dmq1=this.d.mod(u),this.coeff=this.q.modInverse(this.p);break}}}this.isPrivate=!0},et.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},et.prototype.toBigInteger=function(){return this.x},et.prototype.negate=function(){return new et(this.q,this.x.negate().mod(this.q))},et.prototype.add=function(t){return new et(this.q,this.x.add(t.toBigInteger()).mod(this.q))},et.prototype.subtract=function(t){return new et(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},et.prototype.multiply=function(t){return new et(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},et.prototype.square=function(){return new et(this.q,this.x.square().mod(this.q))},et.prototype.divide=function(t){return new et(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},et.prototype.sqrt=function(){return new et(this.q,this.x.sqrt().mod(this.q))},rt.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},rt.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},rt.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(E.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(E.ZERO))},rt.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(E.ZERO)&&!this.y.toBigInteger().equals(E.ZERO)},rt.prototype.negate=function(){return new rt(this.curve,this.x,this.y.negate(),this.z)},rt.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),r=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(E.ZERO.equals(r))return E.ZERO.equals(e)?this.twice():this.curve.getInfinity();var i=new E("3"),s=this.x.toBigInteger(),n=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),r.square()),a=o.multiply(r),h=s.multiply(o),c=e.square().multiply(this.z),u=c.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(r).mod(this.curve.q),l=h.multiply(i).multiply(e).subtract(n.multiply(a)).subtract(c.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),d=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new rt(this.curve,this.curve.fromBigInteger(u),this.curve.fromBigInteger(l),d)},rt.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new E("3"),e=this.x.toBigInteger(),r=this.y.toBigInteger(),i=r.multiply(this.z),s=i.multiply(r).mod(this.curve.q),n=this.curve.a.toBigInteger(),o=e.square().multiply(t);E.ZERO.equals(n)||(o=o.add(this.z.square().multiply(n)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(s)).shiftLeft(1).multiply(i).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(s.shiftLeft(1)).shiftLeft(2).multiply(s).subtract(o.square().multiply(o)).mod(this.curve.q),c=i.square().multiply(i).shiftLeft(3).mod(this.curve.q);return new rt(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),c)},rt.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,i=r.multiply(new E("3")),s=this.negate(),n=this,o=this.curve.q.subtract(t),a=o.multiply(new E("3")),h=new rt(this.curve,this.x,this.y),c=h.negate();for(e=i.bitLength()-2;e>0;--e){n=n.twice();var u=i.testBit(e);u!=r.testBit(e)&&(n=n.add(u?this:s))}for(e=a.bitLength()-2;e>0;--e){h=h.twice();var l=a.testBit(e);l!=o.testBit(e)&&(h=h.add(l?h:c))}return n},rt.prototype.multiplyTwo=function(t,e,r){var i;i=t.bitLength()>r.bitLength()?t.bitLength()-1:r.bitLength()-1;for(var s=this.curve.getInfinity(),n=this.add(e);i>=0;)s=s.twice(),t.testBit(i)?s=r.testBit(i)?s.add(n):s.add(this):r.testBit(i)&&(s=s.add(e)),--i;return s},it.prototype.getQ=function(){return this.q},it.prototype.getA=function(){return this.a},it.prototype.getB=function(){return this.b},it.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},it.prototype.getInfinity=function(){return this.infinity},it.prototype.fromBigInteger=function(t){return new et(this.q,t)},it.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=t.substr(0,2),r=(t.substr(2),this.fromBigInteger(new E(a,16))),i=this.getA(),s=this.getB(),n=r.square().add(i).multiply(r).add(s).sqrt();return"03"==e&&(n=n.negate()),new rt(this,r,n);case 4:case 6:case 7:var o=(t.length-2)/2,a=t.substr(2,o),h=t.substr(o+2,o);return new rt(this,this.fromBigInteger(new E(a,16)),this.fromBigInteger(new E(h,16)));default:return null}},et.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},rt.prototype.getEncoded=function(t){var e=function(t,e){var r=t.toByteArrayUnsigned();if(e<r.length)r=r.slice(r.length-e);else for(;e>r.length;)r.unshift(0);return r},r=this.getX().toBigInteger(),i=this.getY().toBigInteger(),s=e(r,32);return t?i.isEven()?s.unshift(2):s.unshift(3):(s.unshift(4),s=s.concat(e(i,32))),s},rt.decodeFrom=function(t,e){e[0];var r=e.length-1,i=e.slice(1,1+r/2),s=e.slice(1+r/2,1+r);i.unshift(0),s.unshift(0);var n=new E(i),o=new E(s);return new rt(t,t.fromBigInteger(n),t.fromBigInteger(o))},rt.decodeFromHex=function(t,e){e.substr(0,2);var r=e.length-2,i=e.substr(2,r/2),s=e.substr(2+r/2,r/2),n=new E(i,16),o=new E(s,16);return new rt(t,t.fromBigInteger(n),t.fromBigInteger(o))},rt.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),r=t.y.subtract(this.y).divide(e),i=r.square().subtract(this.x).subtract(t.x),s=r.multiply(this.x.subtract(i)).subtract(this.y);return new rt(this.curve,i,s)},rt.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(E.valueOf(2)),e=this.curve.fromBigInteger(E.valueOf(3)),r=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),i=r.square().subtract(this.x.multiply(t)),s=r.multiply(this.x.subtract(i)).subtract(this.y);return new rt(this.curve,i,s)},rt.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,i=r.multiply(new E("3")),s=this.negate(),n=this;for(e=i.bitLength()-2;e>0;--e){n=n.twice();var o=i.testBit(e);o!=r.testBit(e)&&(n=n.add2D(o?this:s))}return n},rt.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),i=this.curve.getB().toBigInteger(),s=this.curve.getQ(),n=e.multiply(e).mod(s),o=t.multiply(t).multiply(t).add(r.multiply(t)).add(i).mod(s);return n.equals(o)},rt.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},rt.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(e.compareTo(E.ONE)<0||e.compareTo(t.subtract(E.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(E.ONE)<0||r.compareTo(t.subtract(E.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};var st=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),r={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function i(t,e,i){return e?r[e]:String.fromCharCode(parseInt(i,16))}var s=new String(""),n=Object.hasOwnProperty;return function(r,o){var a,h,c=r.match(t),u=c[0],l=!1;"{"===u?a={}:"["===u?a=[]:(a=[],l=!0);for(var d=[a],p=1-l,g=c.length;p<g;++p){var f;switch((u=c[p]).charCodeAt(0)){default:(f=d[0])[h||f.length]=+u,h=void 0;break;case 34:if(-1!==(u=u.substring(1,u.length-1)).indexOf("\\")&&(u=u.replace(e,i)),f=d[0],!h){if(!(f instanceof Array)){h=u||s;break}h=f.length}f[h]=u,h=void 0;break;case 91:f=d[0],d.unshift(f[h||f.length]=[]),h=void 0;break;case 93:case 125:d.shift();break;case 102:(f=d[0])[h||f.length]=!1,h=void 0;break;case 110:(f=d[0])[h||f.length]=null,h=void 0;break;case 116:(f=d[0])[h||f.length]=!0,h=void 0;break;case 123:f=d[0],d.unshift(f[h||f.length]={}),h=void 0}}if(l){if(1!==d.length)throw new Error;a=a[0]}else if(d.length)throw new Error;if(o){var m=function(t,e){var r=t[e];if(r&&"object"==typeof r){var i=null;for(var s in r)if(n.call(r,s)&&r!==t){var a=m(r,s);void 0!==a?r[s]=a:(i||(i=[]),i.push(s))}if(i)for(var h=i.length;--h>=0;)delete r[i[h]]}return o.call(t,e,r)};a=m({"":a},"")}return a}}();void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),nt.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){return Ht(t)},this.getPEMStringFromHex=function(t,e){return Et(t,e)},this.newObject=function(t){var e=nt.asn1,r=e.ASN1Object,i=e.DERBoolean,s=e.DERInteger,n=e.DERBitString,o=e.DEROctetString,a=e.DERNull,h=e.DERObjectIdentifier,c=e.DEREnumerated,u=e.DERUTF8String,l=e.DERNumericString,d=e.DERPrintableString,p=e.DERTeletexString,g=e.DERIA5String,f=e.DERUTCTime,m=e.DERGeneralizedTime,y=e.DERVisibleString,v=e.DERBMPString,S=e.DERSequence,E=e.DERSet,x=e.DERTaggedObject,w=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var A=Object.keys(t);if(1!=A.length)throw new Error("key of param shall be only one.");var b=A[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+b+":"))throw new Error("undefined key: "+b);if("bool"==b)return new i(t[b]);if("int"==b)return new s(t[b]);if("bitstr"==b)return new n(t[b]);if("octstr"==b)return new o(t[b]);if("null"==b)return new a(t[b]);if("oid"==b)return new h(t[b]);if("enum"==b)return new c(t[b]);if("utf8str"==b)return new u(t[b]);if("numstr"==b)return new l(t[b]);if("prnstr"==b)return new d(t[b]);if("telstr"==b)return new p(t[b]);if("ia5str"==b)return new g(t[b]);if("utctime"==b)return new f(t[b]);if("gentime"==b)return new m(t[b]);if("visstr"==b)return new y(t[b]);if("bmpstr"==b)return new v(t[b]);if("asn1"==b)return new r(t[b]);if("seq"==b){for(var C=t[b],I=[],T=0;T<C.length;T++){var R=w(C[T]);I.push(R)}return new S({array:I})}if("set"==b){for(C=t[b],I=[],T=0;T<C.length;T++)R=w(C[T]),I.push(R);return new E({array:I})}if("tag"==b){var F=t[b];if("[object Array]"===Object.prototype.toString.call(F)&&3==F.length){var P=w(F[2]);return new x({tag:F[0],explicit:F[1],obj:P})}return new x(F)}},this.jsonToASN1HEX=function(t){return this.newObject(t).tohex()}},nt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),i=(e=Math.floor(r/40)+"."+r%40,""),s=2;s<t.length;s+=2){var n=("00000000"+parseInt(t.substr(s,2),16).toString(2)).slice(-8);i+=n.substr(1,7),"0"==n.substr(0,1)&&(e=e+"."+new E(i,2).toString(10),i="")}return e},nt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",i=new E(t,10).toString(2),s=7-i.length%7;7==s&&(s=0);for(var n="",o=0;o<s;o++)n+="0";for(i=n+i,o=0;o<i.length-1;o+=7){var a=i.substr(o,7);o!=i.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",s=t.split("."),n=40*parseInt(s[0])+parseInt(s[1]);i+=e(n),s.splice(0,2);for(var o=0;o<s.length;o++)i+=r(s[o]);return i},nt.asn1.ASN1Object=function(t){this.params=null,this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n=0,v="+this.hV);var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var r=e.length/2;if(r>15)throw new Error("ASN.1 length too long to represent by 8x: n = "+t.toString(16));return(128+r).toString(16)+e},this.tohex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.getValueHex=function(){return this.tohex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(t){this.params=t},null!=t&&null!=t.tlv&&(this.hTLV=t.tlv,this.isModified=!1)},nt.asn1.DERAbstractString=function(t){nt.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=ft(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},Vt(nt.asn1.DERAbstractString,nt.asn1.ASN1Object),nt.asn1.DERAbstractTime=function(t){nt.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){var e=t.getTime()+6e4*t.getTimezoneOffset();return new Date(e)},this.formatDate=function(t,e,r){var i=this.zeroPadding,s=this.localDateToUTC(t),n=String(s.getFullYear());"utc"==e&&(n=n.substr(2,2));var o=n+i(String(s.getMonth()+1),2)+i(String(s.getDate()),2)+i(String(s.getHours()),2)+i(String(s.getMinutes()),2)+i(String(s.getSeconds()),2);if(!0===r){var a=s.getMilliseconds();if(0!=a){var h=i(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.setByParam=function(t){this.hV=null,this.hTLV=null,this.params=t},this.getString=function(){},this.setString=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.str=t},this.setByDate=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.date=t},this.setByDateValue=function(t,e,r,i,s,n){var o=new Date(Date.UTC(t,e-1,r,i,s,n,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},Vt(nt.asn1.DERAbstractTime,nt.asn1.ASN1Object),nt.asn1.DERAbstractStructured=function(t){nt.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},Vt(nt.asn1.DERAbstractStructured,nt.asn1.ASN1Object),nt.asn1.DERBoolean=function(t){nt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},Vt(nt.asn1.DERBoolean,nt.asn1.ASN1Object),nt.asn1.DERInteger=function(t){nt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var e=Ht;this.setByBigInteger=function(t){this.isModified=!0,this.params={bigint:t}},this.setByInteger=function(t){this.isModified=!0,this.params=t},this.setValueHex=function(t){this.isModified=!0,this.params={hex:t}},this.getFreshValueHex=function(){var t=this.params,r=null;if(null==t)throw new Error("value not set");if("object"==typeof t&&null!=t.hex)return this.hV=t.hex,this.hV;if("number"==typeof t)r=new E(String(t),10);else if(null!=t.int)r=new E(String(t.int),10);else{if(null==t.bigint)throw new Error("wrong parameter");r=t.bigint}return this.hV=e(r),this.hV},null!=t&&(this.params=t)},Vt(nt.asn1.DERInteger,nt.asn1.ASN1Object),nt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=nt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.tohex()}nt.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0),t+="0000000".substr(0,e);for(var r="",i=0;i<t.length-1;i+=8){var s=t.substr(i,8),n=parseInt(s,2).toString(16);1==n.length&&(n="0"+n),r+=n}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},Vt(nt.asn1.DERBitString,nt.asn1.ASN1Object),nt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=nt.asn1.ASN1Util.newObject(t.obj);t.hex=e.tohex()}nt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Vt(nt.asn1.DEROctetString,nt.asn1.DERAbstractString),nt.asn1.DERNull=function(){nt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Vt(nt.asn1.DERNull,nt.asn1.ASN1Object),nt.asn1.DERObjectIdentifier=function(t){nt.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){var e=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",i=parseInt(t,10).toString(2),s=7-i.length%7;7==s&&(s=0);for(var n="",o=0;o<s;o++)n+="0";for(i=n+i,o=0;o<i.length-1;o+=7){var a=i.substr(o,7);o!=i.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};try{if(!t.match(/^[0-9.]+$/))return null;var i="",s=t.split("."),n=40*parseInt(s[0],10)+parseInt(s[1],10);i+=e(n),s.splice(0,2);for(var o=0;o<s.length;o++)i+=r(s[o]);return i}catch(t){return null}}(t);if(null==e)throw new Error("malformed oid string: "+t);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){var e=nt.asn1.x509.OID.name2oid(t);if(""===e)throw new Error("DERObjectIdentifier oidName undefined: "+t);this.setValueOidString(e)},this.setValueNameOrOid=function(t){t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){"string"==typeof t?this.setValueNameOrOid(t):void 0!==t.oid?this.setValueNameOrOid(t.oid):void 0!==t.name?this.setValueNameOrOid(t.name):void 0!==t.hex&&this.setValueHex(t.hex)},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.DERObjectIdentifier,nt.asn1.ASN1Object),nt.asn1.DEREnumerated=function(t){nt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=Ht(t)},this.setByInteger=function(t){var e=new E(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},Vt(nt.asn1.DEREnumerated,nt.asn1.ASN1Object),nt.asn1.DERUTF8String=function(t){nt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Vt(nt.asn1.DERUTF8String,nt.asn1.DERAbstractString),nt.asn1.DERNumericString=function(t){nt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Vt(nt.asn1.DERNumericString,nt.asn1.DERAbstractString),nt.asn1.DERPrintableString=function(t){nt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Vt(nt.asn1.DERPrintableString,nt.asn1.DERAbstractString),nt.asn1.DERTeletexString=function(t){nt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Vt(nt.asn1.DERTeletexString,nt.asn1.DERAbstractString),nt.asn1.DERIA5String=function(t){nt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Vt(nt.asn1.DERIA5String,nt.asn1.DERAbstractString),nt.asn1.DERVisibleString=function(t){nt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},Vt(nt.asn1.DERVisibleString,nt.asn1.DERAbstractString),nt.asn1.DERBMPString=function(t){nt.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},Vt(nt.asn1.DERBMPString,nt.asn1.DERAbstractString),nt.asn1.DERUTCTime=function(t){nt.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.params=void 0,this.getFreshValueHex=function(){var t=this.params;if(null==this.params&&(t={date:new Date}),"string"==typeof t){if(!t.match(/^[0-9]{12}Z$/)&&!t.match(/^[0-9]{12}\.[0-9]+Z$/))throw new Error("malformed string for UTCTime: "+t);this.hV=ut(t)}else if(null!=t.str)this.hV=ut(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ut(this.formatDate(e,"utc",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ut(this.formatDate(t.date,"utc",r))}else t instanceof Date&&(this.hV=ut(this.formatDate(t,"utc")));if(null==this.hV)throw new Error("parameter not specified properly for UTCTime");return this.hV},null!=t&&this.setByParam(t)},Vt(nt.asn1.DERUTCTime,nt.asn1.DERAbstractTime),nt.asn1.DERGeneralizedTime=function(t){nt.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.params=t,this.getFreshValueHex=function(){var t=this.params;if(null==this.params&&(t={date:new Date}),"string"==typeof t){if(!t.match(/^[0-9]{14}Z$/)&&!t.match(/^[0-9]{14}\.[0-9]+Z$/))throw new Error("malformed string for GeneralizedTime: "+t);this.hV=ut(t)}else if(null!=t.str)this.hV=ut(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ut(this.formatDate(e,"gen",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ut(this.formatDate(t.date,"gen",r))}else t instanceof Date&&(this.hV=ut(this.formatDate(t,"gen")));if(null==this.hV)throw new Error("parameter not specified properly for GeneralizedTime");return this.hV},null!=t&&this.setByParam(t)},Vt(nt.asn1.DERGeneralizedTime,nt.asn1.DERAbstractTime),nt.asn1.DERSequence=function(t){nt.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].tohex();return this.hV=t,this.hV}},Vt(nt.asn1.DERSequence,nt.asn1.DERAbstractStructured),nt.asn1.DERSet=function(t){nt.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.tohex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},Vt(nt.asn1.DERSet,nt.asn1.DERAbstractStructured),nt.asn1.DERTaggedObject=function(t){nt.asn1.DERTaggedObject.superclass.constructor.call(this);var e=nt.asn1,r=ht,i=r.getV,s=(r.isASN1HEX,e.ASN1Util.newObject);this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.params={tag:"a0",explicit:!0},this.setASN1Object=function(t,e,r){this.params={tag:e,explicit:t,obj:r}},this.getFreshValueHex=function(){var t=this.params;if(null==t.explicit&&(t.explicit=!0),null!=t.tage&&(t.tag=t.tage,t.explicit=!0),null!=t.tagi&&(t.tag=t.tagi,t.explicit=!1),null!=t.str)this.hV=ft(t.str);else if(null!=t.hex)this.hV=t.hex;else{if(null==t.obj)throw new Error("str, hex nor obj not specified");var r;t.obj instanceof e.ASN1Object?r=t.obj.tohex():"object"==typeof t.obj&&(r=s(t.obj).tohex()),t.explicit?this.hV=r:this.hV=i(r,0)}return null==t.tag&&(t.tag="a0"),this.hT=t.tag,this.hTLV=null,this.isModified=!0,this.hV},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.DERTaggedObject,nt.asn1.ASN1Object);var nt,ot,at,ht=new function(){};function ct(t){for(var e="",r=0;r<t.length;r++){var i=t[r].toString(16);1==i.length&&(i="0"+i),e+=i}return e}function ut(t){return ct(function(t){for(var e=new Array,r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}(t))}function lt(t){return(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function dt(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function pt(t){return t.length%2==1&&(t="0"+t),lt(v(t))}function gt(t){return S(dt(t))}function ft(t){return wt(Dt(t)).toLowerCase()}function mt(t){try{return decodeURIComponent(At(t))}catch(t){return null}}function yt(t){return mt(function(t){for(var e=t.match(/.{1,2}/g),r=[],i=0;i<e.length;i++){var s=parseInt(e[i],16);161<=s&&s<=191?(r.push("c2"),r.push(e[i])):192<=s&&s<=255?(r.push("c3"),r.push((s-64).toString(16))):r.push(e[i])}return r.join("")}(t))}function vt(t){for(var e="",r=0;r<t.length-1;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e}function St(t){for(var e="",r=0;r<t.length;r++)e+=("0"+t.charCodeAt(r).toString(16)).slice(-2);return e}function Et(t,e){return"-----BEGIN "+e+"-----\r\n"+function(t){return(t=t.replace(new RegExp("(.{64})","g"),"$1\r\n")).replace(/\s+$/,"")}(function(t){return v(t)}(t))+"\r\n-----END "+e+"-----\r\n"}function xt(t,e){if(-1==t.indexOf("-----BEGIN "))throw new Error("can't find PEM header");return function(t){return S(t.replace(/[^0-9A-Za-z\/+=]*/g,""))}(t=void 0!==e?(t=t.replace(new RegExp("^[^]*-----BEGIN "+e+"-----"),"")).replace(new RegExp("-----END "+e+"-----[^]*$"),""):(t=t.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function wt(t){return t.replace(/%/g,"")}function At(t){return t.replace(/(..)/g,"%$1")}function bt(t){var e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;var r=(t=t.toLowerCase()).split(":").length-1;if(r<2)throw e;var i=":".repeat(7-r+2),s=(t=t.replace("::",i)).split(":");if(8!=s.length)throw e;for(var n=0;n<8;n++)s[n]=("0000"+s[n]).slice(-4);return s.join("")}function Ct(t){if(!t.match(/^[0-9A-Fa-f]{32}$/))throw new Error("malformed IPv6 address: "+t);var e=(t=t.toLowerCase()).match(/.{1,4}/g);e=e.map(function(t){return t.replace(/^0+/,"")}),e=e.map(function(t){return""==t?"0":t});var r=(t=":"+e.join(":")+":").match(/:(0:){2,}/g);if(null==r)return t.slice(1,-1);var i=r.sort().slice(-1)[0];return"::"!=(t=t.replace(i.substr(0,i.length-1),":")).substr(0,2)&&(t=t.substr(1)),"::"!=t.substr(-2,2)&&(t=t.substr(0,t.length-1)),t}function It(t){var e=new Error("malformed hex value");if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8==t.length)try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}else if(16==t.length)try{return It(t.substr(0,8))+"/"+Tt(t.substr(8))}catch(t){throw e}else{if(32==t.length)return Ct(t);if(64!=t.length)return t;try{return Ct(t.substr(0,32))+"/"+Tt(t.substr(32))}catch(t){throw e}}}function Tt(t){var e,r=new Error("malformed mask");try{e=new E(t,16).toString(2)}catch(t){throw r}if(!e.match(/^1*0*$/))throw r;return e.replace(/0+$/,"").length}function Rt(t){var e=new Error("malformed IP address");if(!(t=t.toLowerCase(t)).match(/^[0-9a-f.:/]+$/))throw e;if(!t.match(/^[0-9.]+$/)){var r;if(t.match(/^[0-9.]+\/[0-9]+$/))return Rt((r=t.split("/"))[0])+Ft(parseInt(r[1]),32);if(t.match(/^[0-9a-f:]+$/)&&-1!==t.indexOf(":"))return bt(t);if(t.match(/^[0-9a-f:]+\/[0-9]+$/)&&-1!==t.indexOf(":"))return bt((r=t.split("/"))[0])+Ft(parseInt(r[1]),128);throw e}var i=t.split(".");if(4!==i.length)throw e;var s="";try{for(var n=0;n<4;n++)s+=("0"+parseInt(i[n]).toString(16)).slice(-2);return s}catch(t){throw e}}function Ft(t,e){return 32==e&&0==t?"00000000":128==e&&0==t?"00000000000000000000000000000000":new E(Array(t+1).join("1")+Array(e-t+1).join("0"),2).toString(16)}function Pt(t){var e=t.match(/.{4}/g).map(function(t){var e=parseInt(t.substr(0,2),16),r=parseInt(t.substr(2),16);if(0==e&r<128)return String.fromCharCode(r);if(e<8){var i=128|63&r;return mt((192|(7&e)<<3|(192&r)>>6).toString(16)+i.toString(16))}i=128|(15&e)<<2|(192&r)>>6;var s=128|63&r;return mt((224|(240&e)>>4).toString(16)+i.toString(16)+s.toString(16))});return e.join("")}function Dt(t){for(var e=encodeURIComponent(t),r="",i=0;i<e.length;i++)"%"==e[i]?(r+=e.substr(i,3),i+=2):r=r+"%"+ut(e[i]);return r}function Ot(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))}function Nt(t){return!!t.match(/^[0-9A-Za-z-_.]+$/)}function _t(t){return t.length%2==1?"0"+t:t.substr(0,1)>"7"?"00"+t:t}function Lt(t){if(!Ot(t))return null;try{var e=[],r=t.substr(0,2),i=parseInt(r,16);e[0]=new String(Math.floor(i/40)),e[1]=new String(i%40);for(var s=t.substr(2),n=[],o=0;o<s.length/2;o++)n.push(parseInt(s.substr(2*o,2),16));var a=[],h="";for(o=0;o<n.length;o++)128&n[o]?h+=kt((127&n[o]).toString(2),7):(h+=kt((127&n[o]).toString(2),7),a.push(new String(parseInt(h,2))),h="");var c=e.join(".");return a.length>0&&(c=c+"."+a.join(".")),c}catch(t){return null}}function Bt(t){return Ht(new E(String(t),10))}function Ht(t){var e=t.toString(16);if("-"!=e.substr(0,1))return e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e),e;var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var i="",s=0;s<r;s++)i+="f";return new E(i,16).xor(t).add(E.ONE).toString(16).replace(/^-/,"")}ht.getLblen=function(t,e){if("8"!=t.substr(e+2,1))return 1;var r=parseInt(t.substr(e+3,1));return 0==r?-1:0<r&&r<10?r+1:-2},ht.getL=function(t,e){var r=ht.getLblen(t,e);return r<1?"":t.substr(e+2,2*r)},ht.getVblen=function(t,e){var r;return""==(r=ht.getL(t,e))?-1:("8"===r.substr(0,1)?new E(r.substr(2),16):new E(r,16)).intValue()},ht.getVidx=function(t,e){var r=ht.getLblen(t,e);return r<0?r:e+2*(r+1)},ht.getV=function(t,e){var r=ht.getVidx(t,e),i=ht.getVblen(t,e);return t.substr(r,2*i)},ht.getTLV=function(t,e){return t.substr(e,2)+ht.getL(t,e)+ht.getV(t,e)},ht.getTLVblen=function(t,e){return 2+2*ht.getLblen(t,e)+2*ht.getVblen(t,e)},ht.getNextSiblingIdx=function(t,e){return ht.getVidx(t,e)+2*ht.getVblen(t,e)},ht.getChildIdx=function(t,e){var r,i,s,n=ht,o=[];r=n.getVidx(t,e),i=2*n.getVblen(t,e),"03"==t.substr(e,2)&&(r+=2,i-=2),s=0;for(var a=r;s<=i;){var h=n.getTLVblen(t,a);if((s+=h)<=i&&o.push(a),a+=h,s>=i)break}return o},ht.getNthChildIdx=function(t,e,r){return ht.getChildIdx(t,e)[r]},ht.getIdxbyList=function(t,e,r,i){var s,n,o=ht;return 0==r.length?void 0!==i&&t.substr(e,2)!==i?-1:e:(s=r.shift())>=(n=o.getChildIdx(t,e)).length?-1:o.getIdxbyList(t,n[s],r,i)},ht.getIdxbyListEx=function(t,e,r,i){var s,n,o=ht;if(0==r.length)return void 0!==i&&t.substr(e,2)!==i?-1:e;s=r.shift(),n=o.getChildIdx(t,e);for(var a=0,h=0;h<n.length;h++){var c=t.substr(n[h],2);if("number"==typeof s&&!o.isContextTag(c)&&a==s||"string"==typeof s&&o.isContextTag(c,s))return o.getIdxbyListEx(t,n[h],r,i);o.isContextTag(c)||a++}return-1},ht.getTLVbyList=function(t,e,r,i){var s=ht,n=s.getIdxbyList(t,e,r,i);return-1==n||n>=t.length?null:s.getTLV(t,n)},ht.getTLVbyListEx=function(t,e,r,i){var s=ht,n=s.getIdxbyListEx(t,e,r,i);return-1==n?null:s.getTLV(t,n)},ht.getVbyList=function(t,e,r,i,s){var n,o,a=ht;return-1==(n=a.getIdxbyList(t,e,r,i))||n>=t.length?null:(o=a.getV(t,n),!0===s&&(o=o.substr(2)),o)},ht.getVbyListEx=function(t,e,r,i,s){var n,o,a=ht;return-1==(n=a.getIdxbyListEx(t,e,r,i))?null:(o=a.getV(t,n),"03"==t.substr(n,2)&&!1!==s&&(o=o.substr(2)),o)},ht.getInt=function(t,e,r){null==r&&(r=-1);try{var i=t.substr(e,2);if("02"!=i&&"03"!=i)return r;var s=ht.getV(t,e);return"02"==i?parseInt(s,16):function(t){if(t.length%2!=0)return-1;if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return-1;try{var e=t.substr(0,2);if("00"==e)return parseInt(t.substr(2),16);var r=parseInt(e,16);if(r>7)return-1;var i=t.substr(2),s=parseInt(i,16).toString(2);"0"==s&&(s="00000000"),s=s.slice(0,0-r);var n=parseInt(s,2);return NaN==n?-1:n}catch(t){return-1}}(s)}catch(t){return r}},ht.getOID=function(t,e,r){null==r&&(r=null);try{return"06"!=t.substr(e,2)?r:Lt(ht.getV(t,e))}catch(t){return r}},ht.getOIDName=function(t,e,r){null==r&&(r=null);try{var i=ht.getOID(t,e,r);if(i==r)return r;var s=nt.asn1.x509.OID.oid2name(i);return""==s?i:s}catch(t){return r}},ht.getString=function(t,e,r){null==r&&(r=null);try{return vt(ht.getV(t,e))}catch(t){return r}},ht.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},r=[],i=t.substr(0,2),s=parseInt(i,16);r[0]=new String(Math.floor(s/40)),r[1]=new String(s%40);for(var n=t.substr(2),o=[],a=0;a<n.length/2;a++)o.push(parseInt(n.substr(2*a,2),16));var h=[],c="";for(a=0;a<o.length;a++)128&o[a]?c+=e((127&o[a]).toString(2),7):(c+=e((127&o[a]).toString(2),7),h.push(new String(parseInt(c,2))),c="");var u=r.join(".");return h.length>0&&(u=u+"."+h.join(".")),u},ht.dump=function(t,e,r,i){var s=ht,n=s.getV,o=s.dump,a=s.getChildIdx,h=t;t instanceof nt.asn1.ASN1Object&&(h=t.tohex());var c=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===r&&(r=0),void 0===i&&(i="");var u,l=e.ommit_long_octet;if("01"==(u=h.substr(r,2)))return"00"==(d=n(h,r))?i+"BOOLEAN FALSE\n":i+"BOOLEAN TRUE\n";if("02"==u)return i+"INTEGER "+c(d=n(h,r),l)+"\n";if("03"==u){var d=n(h,r);return s.isASN1HEX(d.substr(2))?(x=i+"BITSTRING, encapsulates\n")+o(d.substr(2),e,0,i+" "):i+"BITSTRING "+c(d,l)+"\n"}if("04"==u)return d=n(h,r),s.isASN1HEX(d)?(x=i+"OCTETSTRING, encapsulates\n")+o(d,e,0,i+" "):i+"OCTETSTRING "+c(d,l)+"\n";if("05"==u)return i+"NULL\n";if("06"==u){var p=n(h,r),g=nt.asn1.ASN1Util.oidHexToInt(p),f=nt.asn1.x509.OID.oid2name(g),m=g.replace(/\./g," ");return""!=f?i+"ObjectIdentifier "+f+" ("+m+")\n":i+"ObjectIdentifier ("+m+")\n"}if("0a"==u)return i+"ENUMERATED "+parseInt(n(h,r))+"\n";if("0c"==u)return i+"UTF8String '"+mt(n(h,r))+"'\n";if("13"==u)return i+"PrintableString '"+mt(n(h,r))+"'\n";if("14"==u)return i+"TeletexString '"+mt(n(h,r))+"'\n";if("16"==u)return i+"IA5String '"+mt(n(h,r))+"'\n";if("17"==u)return i+"UTCTime "+mt(n(h,r))+"\n";if("18"==u)return i+"GeneralizedTime "+mt(n(h,r))+"\n";if("1a"==u)return i+"VisualString '"+mt(n(h,r))+"'\n";if("1e"==u)return i+"BMPString '"+Pt(n(h,r))+"'\n";if("30"==u){if("3000"==h.substr(r,4))return i+"SEQUENCE {}\n";x=i+"SEQUENCE\n";var y=e;if((2==(E=a(h,r)).length||3==E.length)&&"06"==h.substr(E[0],2)&&"04"==h.substr(E[E.length-1],2)){f=s.oidname(n(h,E[0]));var v=JSON.parse(JSON.stringify(e));v.x509ExtName=f,y=v}for(var S=0;S<E.length;S++)x+=o(h,y,E[S],i+" ");return x}if("31"==u){x=i+"SET\n";var E=a(h,r);for(S=0;S<E.length;S++)x+=o(h,e,E[S],i+" ");return x}if(128&(u=parseInt(u,16))){var x,w=31&u;if(32&u){for(x=i+"["+w+"]\n",E=a(h,r),S=0;S<E.length;S++)x+=o(h,e,E[S],i+" ");return x}return d=n(h,r),ht.isASN1HEX(d)?(x=i+"["+w+"]\n")+o(d,e,0,i+" "):(("68747470"==d.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==w)&&(d=mt(d)),i+"["+w+"] "+d+"\n")}return i+"UNKNOWN("+u+") "+n(h,r)+"\n"},ht.parse=function(t){var e=ht,r=e.parse,i=e.isASN1HEX,s=e.getV,n=e.getTLV,o=e.getChildIdx,a=nt.asn1,h=a.ASN1Util.oidHexToInt,c=a.x509.OID.oid2name,u=mt,l=Pt,d=yt,p={"0c":"utf8str",12:"numstr",13:"prnstr",14:"telstr",16:"ia5str",17:"utctime",18:"gentime","1a":"visstr","1e":"bmpstr",30:"seq",31:"set"},g=t.substr(0,2),f={},m=s(t,0);if("01"==g)return"0101ff"==t?{bool:!0}:{bool:!1};if("02"==g)return{int:{hex:m}};if("03"==g)try{if("00"!=m.substr(0,2))throw"not encap";var y=m.substr(2);if(!i(y))throw"not encap";return{bitstr:{obj:r(y)}}}catch(t){var v=null;return m.length<=10&&(v=function(t){if("string"!=typeof t)return null;if(t.length%2!=0)return null;if(!t.match(/^[0-9a-f]+$/))return null;try{var e=parseInt(t.substr(0,2),16);if(e<0||7<e)return null;for(var r=t.substr(2),i="",s=0;s<r.length;s+=2){var n=r.substr(s,2),o=parseInt(n,16).toString(2);i+=o=("0000000"+o).slice(-8)}return i.substr(0,i.length-e)}catch(t){return null}}(m)),null==v?{bitstr:{hex:m}}:{bitstr:{bin:v}}}else if("04"==g)try{if(!i(m))throw"not encap";return{octstr:{obj:r(m)}}}catch(t){return{octstr:{hex:m}}}else{if("05"==g)return{null:""};if("06"==g){var S=h(m),E=c(S);return""==E?{oid:S}:{oid:E}}if("0a"==g)return m.length>4?{enum:{hex:m}}:{enum:parseInt(m,16)};if("30"==g||"31"==g)return f[p[g]]=function(t){for(var e=[],i=o(t,0),s=0;s<i.length;s++){var a=i[s],h=n(t,a),c=r(h);e.push(c)}return e}(t),f;if("14"==g){var x=d(m);return f[p[g]]={str:x},f}if("1e"==g)return x=l(m),f[p[g]]={str:x},f;if(-1!=":0c:12:13:16:17:18:1a:".indexOf(g))return x=u(m),f[p[g]]={str:x},f;if(g.match(/^8[0-9]$/))return null==(x=u(m))|""==x||null!=x.match(/[\x00-\x1F\x7F-\x9F]/)||null!=x.match(/[\u0000-\u001F\u0080–\u009F]/)?{tag:{tag:g,explicit:!1,hex:m}}:{tag:{tag:g,explicit:!1,str:x}};if(!g.match(/^a[0-9]$/)){var w=new nt.asn1.ASN1Object;return w.hV=m,{asn1:{tlv:g+w.getLengthHexFromValue()+m}}}try{if(!i(m))throw new Error("not encap");return{tag:{tag:g,explicit:!0,obj:r(m)}}}catch(t){return{tag:{tag:g,explicit:!0,hex:m}}}}},ht.isContextTag=function(t,e){var r,i;t=t.toLowerCase();try{r=parseInt(t,16)}catch(t){return-1}if(void 0===e)return 128==(192&r);try{return null!=e.match(/^\[[0-9]+\]$/)&&!((i=parseInt(e.substr(1,e.length-1),10))>31)&&128==(192&r)&&(31&r)==i}catch(t){return!1}},ht.isASN1HEX=function(t){var e=ht;if(t.length%2==1)return!1;var r=e.getVblen(t,0),i=t.substr(0,2),s=e.getL(t,0);return t.length-i.length-s.length==2*r},ht.checkStrictDER=function(t,e,r,i,s){var n=ht;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!nt.lang.String.isHex(t))throw new Error("not hex string");r=t.length,s=(i=t.length/2)<128?1:Math.ceil(i.toString(16))+1}if(n.getL(t,e).length>2*s)throw new Error("L of TLV too long: idx="+e);var o=n.getVblen(t,e);if(o>i)throw new Error("value of L too long than hex: idx="+e);var a=n.getTLV(t,e),h=a.length-2-n.getL(t,e).length;if(h!==2*o)throw new Error("V string length and L's value not the same:"+h+"/"+2*o);if(0===e&&t.length!=a.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+a.length);var c=t.substr(e,2);if("02"===c){var u=n.getVidx(t,e);if("00"==t.substr(u,2)&&t.charCodeAt(u+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(c,16)){for(var l=n.getVblen(t,e),d=0,p=n.getChildIdx(t,e),g=0;g<p.length;g++)d+=n.getTLV(t,p[g]).length,n.checkStrictDER(t,p[g],r,i,s);if(2*l!=d)throw new Error("sum of children's TLV length and L unmatch: "+2*l+"!="+d)}},ht.oidname=function(t){var e=nt.asn1;nt.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var r=e.x509.OID.oid2name(t);return""===r&&(r=t),r},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.x509&&nt.asn1.x509||(nt.asn1.x509={}),nt.asn1.x509.Certificate=function(t){nt.asn1.x509.Certificate.superclass.constructor.call(this);var e=nt.asn1,r=e.DERBitString,i=e.DERSequence,s=e.x509,n=s.TBSCertificate,o=s.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.sigalg;null!=t.sigalg.name&&(e=t.sigalg.name);var r=t.tbsobj.tohex(),i=new nt.crypto.Signature({alg:e});i.init(t.cakey),i.updateHex(r),t.sighex=i.sign()},this.getPEM=function(){return Et(this.tohex(),"CERTIFICATE")},this.tohex=function(){var t=this.params;if(null!=t.tbsobj&&null!=t.tbsobj||(t.tbsobj=new n(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new o({name:t.sigalg})),e.push(new r({hex:"00"+t.sighex})),new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},Vt(nt.asn1.x509.Certificate,nt.asn1.ASN1Object),nt.asn1.x509.TBSCertificate=function(t){nt.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=nt.asn1,r=e.x509,i=e.DERTaggedObject,s=e.DERInteger,n=e.DERSequence,o=r.AlgorithmIdentifier,a=r.Time,h=r.X500Name,c=r.Extensions,u=r.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=[],e=this.params;if(null!=e.version||1!=e.version){var r=2;null!=e.version&&(r=e.version-1);var l=new i({obj:new s({int:r})});t.push(l)}return t.push(new s(e.serial)),t.push(new o({name:e.sigalg})),t.push(new h(e.issuer)),t.push(new n({array:[new a(e.notbefore),new a(e.notafter)]})),t.push(new h(e.subject)),t.push(new u(Mt.getKey(e.sbjpubkey))),void 0!==e.ext&&e.ext.length>0&&t.push(new i({tag:"a3",obj:new c(e.ext)})),new nt.asn1.DERSequence({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.TBSCertificate,nt.asn1.ASN1Object),nt.asn1.x509.Extensions=function(t){nt.asn1.x509.Extensions.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.tohex=function(){for(var t=[],e=0;e<this.aParam.length;e++){var s=this.aParam[e],n=s.extname,o=null;if(null!=s.extn)o=new i.PrivateExtension(s);else if("subjectKeyIdentifier"==n)o=new i.SubjectKeyIdentifier(s);else if("keyUsage"==n)o=new i.KeyUsage(s);else if("subjectAltName"==n)o=new i.SubjectAltName(s);else if("issuerAltName"==n)o=new i.IssuerAltName(s);else if("basicConstraints"==n)o=new i.BasicConstraints(s);else if("nameConstraints"==n)o=new i.NameConstraints(s);else if("cRLDistributionPoints"==n)o=new i.CRLDistributionPoints(s);else if("certificatePolicies"==n)o=new i.CertificatePolicies(s);else if("policyMappings"==n)o=new i.PolicyMappings(s);else if("policyConstraints"==n)o=new i.PolicyConstraints(s);else if("inhibitAnyPolicy"==n)o=new i.InhibitAnyPolicy(s);else if("authorityKeyIdentifier"==n)o=new i.AuthorityKeyIdentifier(s);else if("extKeyUsage"==n)o=new i.ExtKeyUsage(s);else if("authorityInfoAccess"==n)o=new i.AuthorityInfoAccess(s);else if("cRLNumber"==n)o=new i.CRLNumber(s);else if("cRLReason"==n)o=new i.CRLReason(s);else if("ocspNonce"==n)o=new i.OCSPNonce(s);else if("ocspNoCheck"==n)o=new i.OCSPNoCheck(s);else if("adobeTimeStamp"==n)o=new i.AdobeTimeStamp(s);else{if("subjectDirectoryAttributes"!=n)throw new Error("extension not supported:"+JSON.stringify(s));o=new i.SubjectDirectoryAttributes(s)}null!=o&&t.push(o)}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.x509.Extensions,nt.asn1.ASN1Object),nt.asn1.x509.Extension=function(t){nt.asn1.x509.Extension.superclass.constructor.call(this);var e=nt.asn1,r=e.DERObjectIdentifier,i=e.DEROctetString,s=(e.DERBitString,e.DERBoolean),n=e.DERSequence;this.tohex=function(){var t=new r({oid:this.oid}),e=new i({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new s),o.push(e),new n({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},Vt(nt.asn1.x509.Extension,nt.asn1.ASN1Object),nt.asn1.x509.KeyUsage=function(t){nt.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Error,r={digitalSignature:0,nonRepudiation:1,keyEncipherment:2,dataEncipherment:3,keyAgreement:4,keyCertSign:5,cRLSign:6,encipherOnly:7,decipherOnly:8};this.getExtnValueHex=function(){var t=this.getBinValue();return this.asn1ExtnValue=new nt.asn1.DERBitString({bin:t}),this.asn1ExtnValue.tohex()},this.getBinValue=function(){var t=this.params;if("object"!=typeof t||"object"!=typeof t.names&&"string"!=typeof t.bin)throw new e("parameter not yet set");if(null!=t.names)return Ut(t.names,r);if(null!=t.bin)return t.bin;throw new e("parameter not set properly")},this.oid="2.5.29.15",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.KeyUsage,nt.asn1.x509.Extension),nt.asn1.x509.BasicConstraints=function(t){nt.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERBoolean,i=e.DERInteger,s=e.DERSequence;this.getExtnValueHex=function(){var t=new Array;this.cA&&t.push(new r),this.pathLen>-1&&t.push(new i({int:this.pathLen}));var e=new s({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.tohex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},Vt(nt.asn1.x509.BasicConstraints,nt.asn1.x509.Extension),nt.asn1.x509.CRLDistributionPoints=function(t){nt.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=nt.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(t){for(var i=[],s=0;s<t.length;s++)if(t[s]instanceof nt.asn1.ASN1Object)i.push(t[s]);else{var n=new r.DistributionPoint(t[s]);i.push(n)}this.asn1ExtnValue=new e.DERSequence({array:i})},this.setByOneURI=function(t){var e=new r.DistributionPoint({fulluri:t});this.setByDPArray([e])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},Vt(nt.asn1.x509.CRLDistributionPoints,nt.asn1.x509.Extension),nt.asn1.x509.DistributionPoint=function(t){nt.asn1.x509.DistributionPoint.superclass.constructor.call(this);var e=nt.asn1,r=e.x509.DistributionPointName;this.tohex=function(){var t=new e.DERSequence;if(null!=this.asn1DP){var r=new e.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});t.appendASN1Object(r)}return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.dpobj?this.asn1DP=t.dpobj:void 0!==t.dpname?this.asn1DP=new r(t.dpname):void 0!==t.fulluri&&(this.asn1DP=new r({full:[{uri:t.fulluri}]})))},Vt(nt.asn1.x509.DistributionPoint,nt.asn1.ASN1Object),nt.asn1.x509.DistributionPointName=function(t){nt.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=nt.asn1,r=e.DERTaggedObject;if(this.tohex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new r({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t)if(e.x509.GeneralNames.prototype.isPrototypeOf(t))this.type="full",this.tag="a0",this.asn1V=t;else{if(void 0===t.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new e.x509.GeneralNames(t.full)}},Vt(nt.asn1.x509.DistributionPointName,nt.asn1.ASN1Object),nt.asn1.x509.CertificatePolicies=function(t){nt.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=nt.asn1,r=e.x509,i=e.DERSequence,s=r.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new s(this.params.array[e]));var r=new i({array:t});return this.asn1ExtnValue=r,this.asn1ExtnValue.tohex()},this.oid="2.5.29.32",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.CertificatePolicies,nt.asn1.x509.Extension),nt.asn1.x509.PolicyInformation=function(t){nt.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=e.x509.PolicyQualifierInfo;this.params=null,this.tohex=function(){if(void 0===this.params.policyoid&&void 0===this.params.array)throw new Error("parameter oid and array missing");var t=[new i(this.params.policyoid)];if(void 0!==this.params.array){for(var e=[],n=0;n<this.params.array.length;n++)e.push(new s(this.params.array[n]));e.length>0&&t.push(new r({array:e}))}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.PolicyInformation,nt.asn1.ASN1Object),nt.asn1.x509.PolicyQualifierInfo=function(t){nt.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERSequence,i=e.DERIA5String,s=e.DERObjectIdentifier,n=e.x509.UserNotice;this.params=null,this.tohex=function(){return void 0!==this.params.cps?new r({array:[new s({oid:"1.3.6.1.5.5.7.2.1"}),new i({str:this.params.cps})]}).tohex():null!=this.params.unotice?new r({array:[new s({oid:"1.3.6.1.5.5.7.2.2"}),new n(this.params.unotice)]}).tohex():void 0},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.PolicyQualifierInfo,nt.asn1.ASN1Object),nt.asn1.x509.UserNotice=function(t){nt.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=nt.asn1.DERSequence,r=(nt.asn1.DERInteger,nt.asn1.x509.DisplayText),i=nt.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new i(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new r(this.params.exptext)),new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.UserNotice,nt.asn1.ASN1Object),nt.asn1.x509.NoticeReference=function(t){nt.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=nt.asn1.DERSequence,r=nt.asn1.DERInteger,i=nt.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var t=[];if(void 0!==this.params.org&&t.push(new i(this.params.org)),void 0!==this.params.noticenum){for(var s=[],n=this.params.noticenum,o=0;o<n.length;o++)s.push(new r(n[o]));t.push(new e({array:s}))}if(0==t.length)throw new Error("parameter is empty");return new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.NoticeReference,nt.asn1.ASN1Object),nt.asn1.x509.DisplayText=function(t){nt.asn1.x509.DisplayText.superclass.constructor.call(this,t),this.hT="0c",void 0!==t&&("ia5"===t.type?this.hT="16":"vis"===t.type?this.hT="1a":"bmp"===t.type&&(this.hT="1e"))},Vt(nt.asn1.x509.DisplayText,nt.asn1.DERAbstractString),nt.asn1.x509.PolicyMappings=function(t){nt.asn1.x509.PolicyMappings.superclass.constructor.call(this,t);var e=nt.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){for(var t=this.params,e=[],i=0;i<t.array.length;i++){var s=t.array[i];e.push({seq:[{oid:s[0]},{oid:s[1]}]})}return this.asn1ExtnValue=r({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.33",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.PolicyMappings,nt.asn1.x509.Extension),nt.asn1.x509.PolicyConstraints=function(t){nt.asn1.x509.PolicyConstraints.superclass.constructor.call(this,t);var e=nt.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];return null!=t.reqexp&&e.push({tag:{tagi:"80",obj:{int:t.reqexp}}}),null!=t.inhibit&&e.push({tag:{tagi:"81",obj:{int:t.inhibit}}}),this.asn1ExtnValue=r({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.36",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.PolicyConstraints,nt.asn1.x509.Extension),nt.asn1.x509.InhibitAnyPolicy=function(t){nt.asn1.x509.InhibitAnyPolicy.superclass.constructor.call(this,t);var e=nt.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=r({int:this.params.skip}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.54",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.InhibitAnyPolicy,nt.asn1.x509.Extension),nt.asn1.x509.NameConstraints=function(t){nt.asn1.x509.NameConstraints.superclass.constructor.call(this,t);var e=nt.asn1,r=e.x509,i=e.ASN1Util.newObject,s=r.GeneralSubtree;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];if(null!=t.permit&&null!=t.permit.length){for(var r=[],n=0;n<t.permit.length;n++)r.push(new s(t.permit[n]));e.push({tag:{tagi:"a0",obj:{seq:r}}})}if(null!=t.exclude&&null!=t.exclude.length){var o=[];for(n=0;n<t.exclude.length;n++)o.push(new s(t.exclude[n]));e.push({tag:{tagi:"a1",obj:{seq:o}}})}return this.asn1ExtnValue=i({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.30",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.NameConstraints,nt.asn1.x509.Extension),nt.asn1.x509.GeneralSubtree=function(t){nt.asn1.x509.GeneralSubtree.superclass.constructor.call(this);var e=nt.asn1,r=e.x509.GeneralName,i=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,e=[new r(t)];return null!=t.min&&e.push({tag:{tagi:"80",obj:{int:t.min}}}),null!=t.max&&e.push({tag:{tagi:"81",obj:{int:t.max}}}),i({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.GeneralSubtree,nt.asn1.ASN1Object),nt.asn1.x509.ExtKeyUsage=function(t){nt.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=nt.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var r=0;r<t.length;r++){var i=new e.DERObjectIdentifier(t[r]);this.asn1ExtnValue.appendASN1Object(i)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.37",void 0!==t&&void 0!==t.array&&this.setPurposeArray(t.array)},Vt(nt.asn1.x509.ExtKeyUsage,nt.asn1.x509.Extension),nt.asn1.x509.AuthorityKeyIdentifier=function(t){nt.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=nt,r=e.asn1,i=r.DERTaggedObject,s=r.x509.GeneralNames;e.crypto.Util.isKey,this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var t=new Array;this.asn1KID&&t.push(new i({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&t.push(new i({explicit:!1,tag:"a1",obj:new s([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&t.push(new i({explicit:!1,tag:"82",obj:this.asn1CertSN}));var e=new r.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new nt.asn1.DEROctetString(t);else if("object"==typeof t&&nt.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN ")){var e=t;"string"==typeof t&&(e=Mt.getKey(t));var r=Mt.getKeyID(e);this.asn1KID=new nt.asn1.DEROctetString({hex:r})}},this.setCertIssuerByParam=function(t){void 0!==t.str||void 0!==t.ldapstr||void 0!==t.hex||void 0!==t.certsubject||void 0!==t.certissuer?this.asn1CertIssuer=new nt.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new nt.asn1.x509.X500Name({certissuer:t}))},this.setCertSNByParam=function(t){if(void 0!==t.str||void 0!==t.bigint||void 0!==t.hex)this.asn1CertSN=new nt.asn1.DERInteger(t);else if("string"==typeof t&&-1!=t.indexOf("BEGIN ")&&t.indexOf("CERTIFICATE")){var e=new $t;e.readCertPEM(t);var r=e.getSerialNumberHex();this.asn1CertSN=new nt.asn1.DERInteger({hex:r})}},this.oid="2.5.29.35",void 0!==t&&(void 0!==t.kid&&this.setKIDByParam(t.kid),void 0!==t.issuer&&this.setCertIssuerByParam(t.issuer),void 0!==t.sn&&this.setCertSNByParam(t.sn),void 0!==t.issuersn&&"string"==typeof t.issuersn&&-1!=t.issuersn.indexOf("BEGIN ")&&t.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(t.issuersn),this.setCertIssuerByParam(t.issuersn)))},Vt(nt.asn1.x509.AuthorityKeyIdentifier,nt.asn1.x509.Extension),nt.asn1.x509.SubjectKeyIdentifier=function(t){nt.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var e=nt.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new e(t);else if("object"==typeof t&&nt.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN")){var r=t;"string"==typeof t&&(r=Mt.getKey(t));var i=Mt.getKeyID(r);this.asn1KID=new nt.asn1.DEROctetString({hex:i})}},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},Vt(nt.asn1.x509.SubjectKeyIdentifier,nt.asn1.x509.Extension),nt.asn1.x509.AuthorityInfoAccess=function(t){nt.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,r=nt.asn1,i=r.DERSequence,s=r.DERObjectIdentifier,n=r.x509.GeneralName,o=0;o<t.length;o++){var a,h=t[o];if(void 0!==h.ocsp)a=new i({array:[new s({oid:"1.3.6.1.5.5.7.48.1"}),new n({uri:h.ocsp})]});else{if(void 0===h.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(h));a=new i({array:[new s({oid:"1.3.6.1.5.5.7.48.2"}),new n({uri:h.caissuer})]})}e.push(a)}this.asn1ExtnValue=new i({array:e})},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==t&&void 0!==t.array&&this.setAccessDescriptionArray(t.array)},Vt(nt.asn1.x509.AuthorityInfoAccess,nt.asn1.x509.Extension),nt.asn1.x509.SubjectAltName=function(t){nt.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new nt.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.17",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},Vt(nt.asn1.x509.SubjectAltName,nt.asn1.x509.Extension),nt.asn1.x509.IssuerAltName=function(t){nt.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new nt.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.18",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},Vt(nt.asn1.x509.IssuerAltName,nt.asn1.x509.Extension),nt.asn1.x509.SubjectDirectoryAttributes=function(t){nt.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERSequence,i=e.ASN1Util.newObject,s=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var n=this.params.array[e];if(null==n.attr||null==n.array){var o={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==n.attr)o.seq[0].oid=s(n.attr),o.seq[1].set[0]={gentime:n.str};else if("placeOfBirth"==n.attr)o.seq[0].oid=s(n.attr),o.seq[1].set[0]={utf8str:n.str};else if("gender"==n.attr)o.seq[0].oid=s(n.attr),o.seq[1].set[0]={prnstr:n.str};else if("countryOfCitizenship"==n.attr)o.seq[0].oid=s(n.attr),o.seq[1].set[0]={prnstr:n.str};else{if("countryOfResidence"!=n.attr)throw new Error("unsupported attribute: "+n.attr);o.seq[0].oid=s(n.attr),o.seq[1].set[0]={prnstr:n.str}}t.push(new i(o))}else{var a={seq:[{oid:n.attr},{set:n.array}]};t.push(i(a))}}var h=new r({array:t});return this.asn1ExtnValue=h,this.asn1ExtnValue.tohex()},this.oid="2.5.29.9",void 0!==t&&(this.params=t)},Vt(nt.asn1.x509.SubjectDirectoryAttributes,nt.asn1.x509.Extension),nt.asn1.x509.PrivateExtension=function(t){nt.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=nt,r=e.lang.String.isHex,i=e.asn1,s=i.x509.OID.name2oid,n=i.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=s(t.extname),this.params=t},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var t=this.params.extn;if("string"==typeof t&&r(t))return t;if("object"==typeof t)try{return n(t).tohex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},Vt(nt.asn1.x509.PrivateExtension,nt.asn1.x509.Extension),nt.asn1.x509.CRL=function(t){nt.asn1.x509.CRL.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.DERBitString,s=e.x509,n=s.AlgorithmIdentifier,o=s.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new o(this.params).tohex(),e=new nt.crypto.Signature({alg:this.params.sigalg});e.init(this.params.cakey),e.updateHex(t);var r=e.sign();this.params.sighex=r},this.getPEM=function(){return Et(this.tohex(),"X509 CRL")},this.tohex=function(){var t=this.params;if(null==t.tbsobj&&(t.tbsobj=new o(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new n({name:t.sigalg})),e.push(new i({hex:"00"+t.sighex})),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},Vt(nt.asn1.x509.CRL,nt.asn1.ASN1Object),nt.asn1.x509.TBSCertList=function(t){nt.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=nt.asn1,r=e.DERInteger,i=e.DERSequence,s=e.DERTaggedObject,n=(e.DERObjectIdentifier,e.x509),o=n.AlgorithmIdentifier,a=n.Time,h=n.Extensions,c=n.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,s=0;s<e.length;s++){var n=[new r(e[s].sn),new a(e[s].date)];null!=e[s].ext&&n.push(new h(e[s].ext)),t.push(new i({array:n}))}return new i({array:t})},this.tohex=function(){var t=[],e=this.params;if(null!=e.version){var n=e.version-1,u=new r({int:n});t.push(u)}if(t.push(new o({name:e.sigalg})),t.push(new c(e.issuer)),t.push(new a(e.thisupdate)),null!=e.nextupdate&&t.push(new a(e.nextupdate)),null!=e.revcert&&t.push(this.getRevCertSequence()),null!=e.ext){var l=new h(e.ext);t.push(new s({tag:"a0",explicit:!0,obj:l}))}return new i({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.TBSCertList,nt.asn1.ASN1Object),nt.asn1.x509.CRLEntry=function(t){nt.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=nt.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.tohex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},Vt(nt.asn1.x509.CRLEntry,nt.asn1.ASN1Object),nt.asn1.x509.CRLNumber=function(t){nt.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DERInteger(this.params.num),this.asn1ExtnValue.tohex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},Vt(nt.asn1.x509.CRLNumber,nt.asn1.x509.Extension),nt.asn1.x509.CRLReason=function(t){nt.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.tohex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},Vt(nt.asn1.x509.CRLReason,nt.asn1.x509.Extension),nt.asn1.x509.OCSPNonce=function(t){nt.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DEROctetString(this.params),this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},Vt(nt.asn1.x509.OCSPNonce,nt.asn1.x509.Extension),nt.asn1.x509.OCSPNoCheck=function(t){nt.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DERNull,this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},Vt(nt.asn1.x509.OCSPNoCheck,nt.asn1.x509.Extension),nt.asn1.x509.AdobeTimeStamp=function(t){nt.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERInteger,i=e.DERBoolean,s=e.DERSequence,n=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new r(1)];return e.push(new n({uri:t.uri})),null!=t.reqauth&&e.push(new i(t.reqauth)),this.asn1ExtnValue=new s({array:e}),this.asn1ExtnValue.tohex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.AdobeTimeStamp,nt.asn1.x509.Extension),nt.asn1.x509.X500Name=function(t){nt.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=nt.asn1,r=e.x509,i=r.RDN;this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.split("/");r.shift();for(var s=[],n=0;n<r.length;n++)if(r[n].match(/^[^=]+=.+$/))s.push(r[n]);else{var o=s.length-1;s[o]=s[o]+"/"+r[n]}for(n=0;n<s.length;n++)this.asn1Array.push(new i({str:s[n],rule:this.sRule}))},this.setByLdapString=function(t,e){void 0!==e&&(this.sRule=e);var i=r.X500Name.ldapToCompat(t);this.setByString(i,e)},this.setByObject=function(t,e){for(var r in void 0!==e&&(this.sRule=e),t)if(t.hasOwnProperty(r)){var s=new i({str:r+"="+t[r],rule:this.sRule});this.asn1Array?this.asn1Array.push(s):this.asn1Array=[s]}},this.setByParam=function(t){var e;void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.array?this.paramArray=t.array:void 0!==t.str?this.setByString(t.str):void 0!==t.ldapstr?this.setByLdapString(t.ldapstr):void 0!==t.hex?this.hTLV=t.hex:void 0!==t.certissuer?((e=new $t).readCertPEM(t.certissuer),this.hTLV=e.getIssuerHex()):void 0!==t.certsubject?((e=new $t).readCertPEM(t.certsubject),this.hTLV=e.getSubjectHex()):"object"==typeof t&&void 0===t.certsubject&&void 0===t.certissuer&&this.setByObject(t)},this.tohex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r={array:this.paramArray[t]};"utf8"!=this.sRule&&(r.rule=this.sRule);var s=new i(r);this.asn1Array.push(s)}var n=new e.DERSequence({array:this.asn1Array});return this.hTLV=n.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.X500Name,nt.asn1.ASN1Object),nt.asn1.x509.X500Name.compatToLDAP=function(t){if("/"!==t.substr(0,1))throw"malformed input";var e=(t=t.substr(1)).split("/");return e.reverse(),e=e.map(function(t){return t.replace(/,/,"\\,")}),e.join(",")},nt.asn1.x509.X500Name.onelineToLDAP=function(t){return nt.asn1.x509.X500Name.compatToLDAP(t)},nt.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),r=!1,i=[],s=0;e.length>0;s++){var n=e.shift();if(!0===r){var o=(i.pop()+","+n).replace(/\\,/g,",");i.push(o),r=!1}else i.push(n);"\\"===n.substr(-1,1)&&(r=!0)}return i=i.map(function(t){return t.replace("/","\\/")}),i.reverse(),"/"+i.join("/")},nt.asn1.x509.X500Name.ldapToOneline=function(t){return nt.asn1.x509.X500Name.ldapToCompat(t)},nt.asn1.x509.RDN=function(t){nt.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=nt.asn1.x509.AttributeTypeAndValue;this.setByParam=function(t){void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.str&&this.addByMultiValuedString(t.str),void 0!==t.array&&(this.paramArray=t.array)},this.addByString=function(t){this.asn1Array.push(new nt.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=nt.asn1.x509.RDN.parseString(t),r=0;r<e.length;r++)this.addByString(e[r])},this.tohex=function(){if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r=this.paramArray[t];void 0!==r.rule&&"utf8"!=this.sRule&&(r.rule=this.sRule);var i=new e(r);this.asn1Array.push(i)}var s=new nt.asn1.DERSet({array:this.asn1Array});return this.TLV=s.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.RDN,nt.asn1.ASN1Object),nt.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),r=!1,i=[],s=0;e.length>0;s++){var n=e.shift();if(!0===r){var o=(i.pop()+"+"+n).replace(/\\\+/g,"+");i.push(o),r=!1}else i.push(n);"\\"===n.substr(-1,1)&&(r=!0)}var a=!1,h=[];for(s=0;i.length>0;s++){if(n=i.shift(),!0===a){var c=h.pop();n.match(/"$/)?(o=(c+"+"+n).replace(/^([^=]+)="(.*)"$/,"$1=$2"),h.push(o),a=!1):h.push(c+"+"+n)}else h.push(n);n.match(/^[^=]+="/)&&(a=!0)}return h},nt.asn1.x509.AttributeTypeAndValue=function(t){nt.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=nt,r=e.asn1,i=r.DERSequence,s=r.DERUTF8String,n=r.DERPrintableString,o=r.DERTeletexString,a=r.DERIA5String,h=r.DERVisibleString,c=r.DERBMPString,u=e.lang.String.isMail,l=e.lang.String.isPrintable;this.setByParam=function(t){if(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.ds&&(this.dsType=t.ds),void 0===t.value&&void 0!==t.str){var e=t.str.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=e[1],this.sValue=e[2]}else this.sType=t.type,this.sValue=t.value},this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.match(/^([^=]+)=(.+)$/);if(!r)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(r[1],r[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,r=this.sRule;return"prn"===r?"CN"==t&&u(e)?"ia5":l(e)?"prn":"utf8":"utf8"===r?"CN"==t&&u(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,r){void 0!==r&&(this.sRule=r),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new s({str:e});if("prn"==t)return new n({str:e});if("tel"==t)return new o({str:e});if("ia5"==t)return new a({str:e});if("vis"==t)return new h({str:e});if("bmp"==t)return new c({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.tohex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=nt.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),r=new i({array:[t,e]});return this.TLV=r.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.AttributeTypeAndValue,nt.asn1.ASN1Object),nt.asn1.x509.SubjectPublicKeyInfo=function(t){nt.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=nt,r=e.asn1,i=r.DERInteger,s=r.DERBitString,n=r.DERObjectIdentifier,o=r.DERSequence,a=r.ASN1Util.newObject,h=r.x509.AlgorithmIdentifier,c=e.crypto;c.ECDSA,c.DSA,this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.tohex=function(){var t=this.getASN1Object();return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(t){try{if(t instanceof tt){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).tohex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+e})}}catch(t){}try{if(t instanceof nt.crypto.ECDSA){var r=new n({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new s({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof nt.crypto.DSA){r=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}),this.asn1AlgId=new h({name:"dsa",asn1params:r});var o=new i({bigint:t.y});this.asn1SubjPKey=new s({hex:"00"+o.tohex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},Vt(nt.asn1.x509.SubjectPublicKeyInfo,nt.asn1.ASN1Object),nt.asn1.x509.Time=function(t){nt.asn1.x509.Time.superclass.constructor.call(this);var e=nt.asn1,r=e.DERUTCTime,i=e.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(t){this.timeParams=t},this.setByParam=function(t){this.params=t},this.getType=function(t){return t.match(/^[0-9]{12}Z$/)?"utc":t.match(/^[0-9]{14}Z$/)?"gen":t.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":t.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var t=this.params,e=null;if("string"==typeof t&&(t={str:t}),null==t||!t.str||null!=t.type&&null!=t.type||(t.type=this.getType(t.str)),null!=t&&t.str?("utc"==t.type&&(e=new r(t.str)),"gen"==t.type&&(e=new i(t.str))):e="gen"==this.type?new i:new r,null==e)throw new Error("wrong setting for Time");return this.TLV=e.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},nt.asn1.x509.Time_bak=function(t){nt.asn1.x509.Time_bak.superclass.constructor.call(this);var e=nt.asn1,r=e.DERUTCTime,i=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.tohex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new r(this.timeParams):new i(this.timeParams):"utc"==this.type?new r:new i,this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},Vt(nt.asn1.x509.Time,nt.asn1.ASN1Object),nt.asn1.x509.AlgorithmIdentifier=function(t){nt.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=nt.asn1,r=e.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.tohex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t=null;for(var i in r)i===this.nameAlg&&(t=r[i]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var s=[this.asn1Alg];null!==this.asn1Params&&s.push(this.asn1Params);var n=new e.DERSequence({array:s});return this.hTLV=n.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){void 0!==this.nameAlg.name&&(this.nameAlg=this.nameAlg.name);var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},Vt(nt.asn1.x509.AlgorithmIdentifier,nt.asn1.ASN1Object),nt.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},nt.asn1.x509.GeneralName=function(t){nt.asn1.x509.GeneralName.superclass.constructor.call(this);var e=nt.asn1,r=e.x509,i=r.X500Name,s=r.OtherName,n=e.DERIA5String,o=(e.DERPrintableString,e.DEROctetString),a=e.DERTaggedObject,h=e.ASN1Object,c=Error;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e,r=this.params,u=!1;if(void 0!==r.other)t="a0",e=new s(r.other);else if(void 0!==r.rfc822)t="81",e=new n({str:r.rfc822});else if(void 0!==r.dns)t="82",e=new n({str:r.dns});else if(void 0!==r.dn)t="a4",u=!0,e="string"==typeof r.dn?new i({str:r.dn}):r.dn instanceof nt.asn1.x509.X500Name?r.dn:new i(r.dn);else if(void 0!==r.ldapdn)t="a4",u=!0,e=new i({ldapstr:r.ldapdn});else if(void 0!==r.certissuer||void 0!==r.certsubj){var l,d;t="a4",u=!0;var p=null;if(void 0!==r.certsubj?(l=!1,d=r.certsubj):(l=!0,d=r.certissuer),d.match(/^[0-9A-Fa-f]+$/),-1!=d.indexOf("-----BEGIN ")&&(p=xt(d)),null==p)throw new Error("certsubj/certissuer not cert");var g,f=new $t;f.hex=p,g=l?f.getIssuerHex():f.getSubjectHex(),(e=new h).hTLV=g}else if(void 0!==r.uri)t="86",e=new n({str:r.uri});else{if(void 0===r.ip)throw new c("improper params");var m;t="87";var y=r.ip;try{if(y.match(/^[0-9a-f]+$/)){var v=y.length;if(8!=v&&16!=v&&32!=v&&64!=v)throw"err";m=y}else m=Rt(y)}catch(t){throw new c("malformed IP address: "+r.ip+":"+t.message)}e=new o({hex:m})}return new a({tag:t,explicit:u,obj:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.GeneralName,nt.asn1.ASN1Object),nt.asn1.x509.GeneralNames=function(t){nt.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=nt.asn1;this.setByParamArray=function(t){for(var r=0;r<t.length;r++){var i=new e.x509.GeneralName(t[r]);this.asn1Array.push(i)}},this.tohex=function(){return new e.DERSequence({array:this.asn1Array}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.asn1Array=new Array,void 0!==t&&this.setByParamArray(t)},Vt(nt.asn1.x509.GeneralNames,nt.asn1.ASN1Object),nt.asn1.x509.OtherName=function(t){nt.asn1.x509.OtherName.superclass.constructor.call(this);var e=nt.asn1,r=e.DERObjectIdentifier,i=e.DERSequence,s=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null==t.oid||null==t.value)throw new Error("oid or value not specified");var e=new r({oid:t.oid}),n=s({tag:{tag:"a0",explicit:!0,obj:t.value}});return new i({array:[e,n]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.x509.OtherName,nt.asn1.ASN1Object),nt.asn1.x509.OID=new function(){var t=nt.asn1.DERObjectIdentifier;this.name2oidList={"aes128-CBC":"2.16.840.1.101.3.4.1.2","aes256-CBC":"2.16.840.1.101.3.4.1.42",sha1:"1.3.14.3.2.26",sha256:"2.16.840.1.101.3.4.2.1",sha384:"2.16.840.1.101.3.4.2.2",sha512:"2.16.840.1.101.3.4.2.3",sha224:"2.16.840.1.101.3.4.2.4",md5:"1.2.840.113549.2.5",md2:"1.3.14.7.2.2.1",ripemd160:"1.3.36.3.2.1",hmacWithSHA1:"1.2.840.113549.2.7",hmacWithSHA224:"1.2.840.113549.2.8",hmacWithSHA256:"1.2.840.113549.2.9",hmacWithSHA384:"1.2.840.113549.2.10",hmacWithSHA512:"1.2.840.113549.2.11",MD2withRSA:"1.2.840.113549.1.1.2",MD4withRSA:"1.2.840.113549.1.1.3",MD5withRSA:"1.2.840.113549.1.1.4",SHA1withRSA:"1.2.840.113549.1.1.5","pkcs1-MGF":"1.2.840.113549.1.1.8",rsaPSS:"1.2.840.113549.1.1.10",SHA224withRSA:"1.2.840.113549.1.1.14",SHA256withRSA:"1.2.840.113549.1.1.11",SHA384withRSA:"1.2.840.113549.1.1.12",SHA512withRSA:"1.2.840.113549.1.1.13",SHA1withECDSA:"1.2.840.10045.4.1",SHA224withECDSA:"1.2.840.10045.4.3.1",SHA256withECDSA:"1.2.840.10045.4.3.2",SHA384withECDSA:"1.2.840.10045.4.3.3",SHA512withECDSA:"1.2.840.10045.4.3.4",dsa:"1.2.840.10040.4.1",SHA1withDSA:"1.2.840.10040.4.3",SHA224withDSA:"2.16.840.1.101.3.4.3.1",SHA256withDSA:"2.16.840.1.101.3.4.3.2",rsaEncryption:"1.2.840.113549.1.1.1",commonName:"2.5.4.3",countryName:"2.5.4.6",localityName:"2.5.4.7",stateOrProvinceName:"2.5.4.8",streetAddress:"2.5.4.9",organizationName:"2.5.4.10",organizationalUnitName:"2.5.4.11",domainComponent:"0.9.2342.19200300.100.1.25",userId:"0.9.2342.19200300.100.1.1",surname:"2.5.4.4",givenName:"2.5.4.42",title:"2.5.4.12",distinguishedName:"2.5.4.49",emailAddress:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3",subjectDirectoryAttributes:"2.5.29.9",subjectKeyIdentifier:"2.5.29.14",keyUsage:"2.5.29.15",subjectAltName:"2.5.29.17",issuerAltName:"2.5.29.18",basicConstraints:"2.5.29.19",cRLNumber:"2.5.29.20",cRLReason:"2.5.29.21",nameConstraints:"2.5.29.30",cRLDistributionPoints:"2.5.29.31",certificatePolicies:"2.5.29.32",anyPolicy:"2.5.29.32.0",policyMappings:"2.5.29.33",authorityKeyIdentifier:"2.5.29.35",policyConstraints:"2.5.29.36",extKeyUsage:"2.5.29.37",inhibitAnyPolicy:"2.5.29.54",authorityInfoAccess:"1.3.6.1.5.5.7.1.1",ocsp:"1.3.6.1.5.5.7.48.1",ocspBasic:"1.3.6.1.5.5.7.48.1.1",ocspNonce:"1.3.6.1.5.5.7.48.1.2",ocspNoCheck:"1.3.6.1.5.5.7.48.1.5",caIssuers:"1.3.6.1.5.5.7.48.2",anyExtendedKeyUsage:"2.5.29.37.0",serverAuth:"1.3.6.1.5.5.7.3.1",clientAuth:"1.3.6.1.5.5.7.3.2",codeSigning:"1.3.6.1.5.5.7.3.3",emailProtection:"1.3.6.1.5.5.7.3.4",timeStamping:"1.3.6.1.5.5.7.3.8",ocspSigning:"1.3.6.1.5.5.7.3.9",smtpUTF8Mailbox:"1.3.6.1.5.5.7.8.9",dateOfBirth:"1.3.6.1.5.5.7.9.1",placeOfBirth:"1.3.6.1.5.5.7.9.2",gender:"1.3.6.1.5.5.7.9.3",countryOfCitizenship:"1.3.6.1.5.5.7.9.4",countryOfResidence:"1.3.6.1.5.5.7.9.5",ecPublicKey:"1.2.840.10045.2.1","P-256":"1.2.840.10045.3.1.7",secp256r1:"1.2.840.10045.3.1.7",secp256k1:"1.3.132.0.10",secp384r1:"1.3.132.0.34",secp521r1:"1.3.132.0.35",pkcs5PBES2:"1.2.840.113549.1.5.13",pkcs5PBKDF2:"1.2.840.113549.1.5.12","des-EDE3-CBC":"1.2.840.113549.3.7",data:"1.2.840.113549.1.7.1","signed-data":"1.2.840.113549.1.7.2","enveloped-data":"1.2.840.113549.1.7.3","digested-data":"1.2.840.113549.1.7.5","encrypted-data":"1.2.840.113549.1.7.6","authenticated-data":"1.2.840.113549.1.9.16.1.2",tstinfo:"1.2.840.113549.1.9.16.1.4",signingCertificate:"1.2.840.113549.1.9.16.2.12",timeStampToken:"1.2.840.113549.1.9.16.2.14",signaturePolicyIdentifier:"1.2.840.113549.1.9.16.2.15",etsArchiveTimeStamp:"1.2.840.113549.1.9.16.2.27",signingCertificateV2:"1.2.840.113549.1.9.16.2.47",etsArchiveTimeStampV2:"1.2.840.113549.1.9.16.2.48",extensionRequest:"1.2.840.113549.1.9.14",contentType:"1.2.840.113549.1.9.3",messageDigest:"1.2.840.113549.1.9.4",signingTime:"1.2.840.113549.1.9.5",counterSignature:"1.2.840.113549.1.9.6",archiveTimeStampV3:"0.4.0.1733.2.4",pdfRevocationInfoArchival:"1.2.840.113583.1.1.8",adobeTimeStamp:"1.2.840.113583.1.1.9.1",smimeMailboxLegacy:"2.23.140.1.5.1.1",smimeMailboxMulti:"2.23.140.1.5.1.2",smimeMailboxStrict:"2.23.140.1.5.1.3",smimeOrganizationLegacy:"2.23.140.1.5.2.1",smimeOrganizationMulti:"2.23.140.1.5.2.2",smimeOrganizationStrict:"2.23.140.1.5.2.3",smimeSponsorLegacy:"2.23.140.1.5.3.1",smimeSponsorMulti:"2.23.140.1.5.3.2",smimeSponsorStrict:"2.23.140.1.5.3.3",smimeIndividualLegacy:"2.23.140.1.5.4.1",smimeIndividualMulti:"2.23.140.1.5.4.2",smimeIndividualStrict:"2.23.140.1.5.4.3"},this.atype2oidList={CN:"2.5.4.3",L:"2.5.4.7",ST:"2.5.4.8",O:"2.5.4.10",OU:"2.5.4.11",C:"2.5.4.6",STREET:"2.5.4.9",DC:"0.9.2342.19200300.100.1.25",UID:"0.9.2342.19200300.100.1.1",SN:"2.5.4.4",T:"2.5.4.12",GN:"2.5.4.42",DN:"2.5.4.49",E:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",serialNumber:"2.5.4.5",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3"},this.objCache={},this.name2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];if(void 0===this.name2oidList[e])throw"Name of ObjectIdentifier not defined: "+e;var r=this.name2oidList[e],i=new t({oid:r});return this.objCache[e]=i,i},this.atype2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];var r;if(e.match(/^\d+\.\d+\.[0-9.]+$/))r=e;else if(void 0!==this.atype2oidList[e])r=this.atype2oidList[e];else{if(void 0===this.name2oidList[e])throw new Error("AttributeType name undefined: "+e);r=this.name2oidList[e]}var i=new t({oid:r});return this.objCache[e]=i,i},this.registerOIDs=function(t){if(this.checkOIDs(t))for(var e in t)this.name2oidList[e]=t[e]},this.checkOIDs=function(t){try{var e=Object.keys(t);return 0!=e.length&&(e.map(function(t,e,r){if(!this[t].match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch(t){return!1}}},nt.asn1.x509.OID.oid2name=function(t){var e=nt.asn1.x509.OID.name2oidList;for(var r in e)if(e[r]==t)return r;return""},nt.asn1.x509.OID.oid2atype=function(t){var e=nt.asn1.x509.OID.atype2oidList;for(var r in e)if(e[r]==t)return r;return t},nt.asn1.x509.OID.name2oid=function(t){if(t.match(/^[0-9.]+$/))return t;var e=nt.asn1.x509.OID.name2oidList;return void 0===e[t]?"":e[t]},nt.asn1.x509.X509Util={},nt.asn1.x509.X509Util.newCertPEM=function(t){var e=nt.asn1.x509;return e.TBSCertificate,new(0,e.Certificate)(t).getPEM()},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.cms&&nt.asn1.cms||(nt.asn1.cms={}),nt.asn1.cms.Attribute=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERSet,n=r.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(t){this.params=t},this.getValueArray=function(){throw new e("not yet implemented abstract")},this.tohex=function(){var t=new n({oid:this.typeOid}),e=new s({array:this.getValueArray()});return new i({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()}},Vt(nt.asn1.cms.Attribute,nt.asn1.ASN1Object),nt.asn1.cms.ContentType=function(t){var e=nt.asn1;e.cms.ContentType.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.3",this.getValueArray=function(){return[new e.DERObjectIdentifier(this.params.type)]},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.ContentType,nt.asn1.cms.Attribute),nt.asn1.cms.MessageDigest=function(t){var e=nt.asn1,r=e.DEROctetString;e.cms.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){return[new r(this.params)]},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.MessageDigest,nt.asn1.cms.Attribute),nt.asn1.cms.SigningTime=function(t){var e=nt.asn1;e.cms.SigningTime.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.5",this.getValueArray=function(){return[new e.x509.Time(this.params)]},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SigningTime,nt.asn1.cms.Attribute),nt.asn1.cms.SigningCertificate=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERSequence,n=i.cms,o=n.ESSCertID;r.crypto,n.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new e("parameter 'array' not specified");for(var r=this.params.array,i=[],n=0;n<r.length;n++){var a=r[n];0!=t.hasis||"string"!=typeof a||-1==a.indexOf("-----BEGIN")&&!ht.isASN1HEX(a)||(a={cert:a}),0!=a.hasis&&0==t.hasis&&(a.hasis=!1),i.push(new o(a))}var h=new s({array:i});return[new s({array:[h]})]},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SigningCertificate,nt.asn1.cms.Attribute),nt.asn1.cms.ESSCertID=function(t){nt.asn1.cms.ESSCertID.superclass.constructor.call(this);var e=Error,r=nt,i=r.asn1,s=i.DEROctetString,n=i.DERSequence,o=i.cms.IssuerSerial;this.params=null,this.getCertHash=function(t,i){if(null!=t.hash)return t.hash;if("string"==typeof t&&-1==t.indexOf("-----BEGIN")&&!ht.isASN1HEX(t))return t;var s,n,o;if("string"==typeof t)s=t;else{if(null==t.cert)throw new e("hash nor cert unspecified");s=t.cert}if(n=-1!=s.indexOf("-----BEGIN")?xt(s):s,"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?n=xt(t):ht.isASN1HEX(t)&&(n=t)),null!=t.alg)o=t.alg;else{if(null==i)throw new e("hash alg unspecified");o=i}return r.crypto.Util.hashHex(n,o)},this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha1"),r=[];return r.push(new s({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&r.push(new o(t)),new n({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.ESSCertID,nt.asn1.ASN1Object),nt.asn1.cms.SigningCertificateV2=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERSequence,n=(i.x509,i.cms),o=n.ESSCertIDv2;r.crypto,n.SigningCertificateV2.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.47",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new e("parameter 'array' not specified");for(var r=this.params.array,i=[],n=0;n<r.length;n++){var a=r[n];null==t.alg&&0!=t.hasis||"string"!=typeof a||-1==a.indexOf("-----BEGIN")&&!ht.isASN1HEX(a)||(a={cert:a}),null==a.alg&&null!=t.alg&&(a.alg=t.alg),0!=a.hasis&&0==t.hasis&&(a.hasis=!1),i.push(new o(a))}var h=new s({array:i});return[new s({array:[h]})]},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SigningCertificateV2,nt.asn1.cms.Attribute),nt.asn1.cms.ESSCertIDv2=function(t){nt.asn1.cms.ESSCertIDv2.superclass.constructor.call(this),Error;var e=nt.asn1,r=e.DEROctetString,i=e.DERSequence,s=e.cms.IssuerSerial,n=e.x509.AlgorithmIdentifier;this.params=null,this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha256"),o=[];return null!=t.alg&&"sha256"!=t.alg&&o.push(new n({name:t.alg})),o.push(new r({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&o.push(new s(t)),new i({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.ESSCertIDv2,nt.asn1.cms.ESSCertID),nt.asn1.cms.IssuerSerial=function(t){var e=Error,r=nt.asn1,i=r.DERInteger,s=r.DERSequence,n=r.cms,o=r.x509.GeneralNames,a=$t;n.IssuerSerial.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.tohex=function(){var t,r,n=this.params;if("string"==typeof n&&-1!=n.indexOf("-----BEGIN")||null!=n.cert){var h;h=null!=n.cert?n.cert:n;var c=new a;c.readCertPEM(h),t=c.getIssuer(),r={hex:c.getSerialNumberHex()}}else{if(null==n.issuer||!n.serial)throw new e("cert or issuer and serial parameter not specified");t=n.issuer,r=n.serial}var u=new o([{dn:t}]),l=new i(r);return new s({array:[u,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.IssuerSerial,nt.asn1.ASN1Object),nt.asn1.cms.SignerIdentifier=function(t){var e=nt.asn1,r=(e.DERInteger,e.DERSequence,e.cms),i=r.IssuerAndSerialNumber,s=r.SubjectKeyIdentifier;e.x509.X500Name,Error,r.SignerIdentifier.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("isssn"==t.type)return new i(t).tohex();if("skid"==t.type)return new s(t).tohex();throw new Error("wrong property for isssn or skid")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SignerIdentifier,nt.asn1.ASN1Object),nt.asn1.cms.IssuerAndSerialNumber=function(t){var e=nt.asn1,r=e.DERInteger,i=e.DERSequence,s=e.cms,n=e.x509.X500Name,o=$t,a=Error;s.IssuerAndSerialNumber.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e,s=this.params;if("string"==typeof s&&-1!=s.indexOf("-----BEGIN")||null!=s.cert){var h;h=null!=s.cert?s.cert:s;var c=new o;c.readCertPEM(h),t=c.getIssuer(),e={hex:c.getSerialNumberHex()}}else{if(null==s.issuer||!s.serial)throw new a("cert or issuer and serial parameter not specified");t=s.issuer,e=s.serial}var u=new n(t),l=new r(e);return new i({array:[u,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.IssuerAndSerialNumber,nt.asn1.ASN1Object),nt.asn1.cms.SubjectKeyIdentifier=function(t){var e=nt.asn1,r=(e.DERInteger,e.DERSequence,e.ASN1Util.newObject),i=e.cms,s=(i.IssuerAndSerialName,i.SubjectKeyIdentifier,e.x509.X500Name,$t),n=Error;i.SubjectKeyIdentifier.superclass.constructor.call(this),this.tohex=function(){var t,e=this.params;if(null==e.cert&&null==e.skid)throw new n("property cert nor skid undefined");return null!=e.cert?t=new s(e.cert).getExtSubjectKeyIdentifier().kid.hex:null!=e.skid&&(t=e.skid),r({tag:{tage:"a0",obj:{octstr:{hex:t}}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SubjectKeyIdentifier,nt.asn1.ASN1Object),nt.asn1.cms.AttributeList=function(t){var e=Error,r=nt.asn1,i=r.DERSet,s=r.cms;s.AttributeList.superclass.constructor.call(this),this.params=null,this.hTLV=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null!=this.hTLV)return this.hTLV;var r=!0;null!=t.sortflag&&(r=t.sortflag);for(var n=t.array,o=[],a=0;a<n.length;a++){var h=n[a],c=h.attr;if("contentType"==c)o.push(new s.ContentType(h));else if("messageDigest"==c)o.push(new s.MessageDigest(h));else if("signingTime"==c)o.push(new s.SigningTime(h));else if("signingCertificate"==c)o.push(new s.SigningCertificate(h));else if("signingCertificateV2"==c)o.push(new s.SigningCertificateV2(h));else if("signaturePolicyIdentifier"==c)o.push(new nt.asn1.cades.SignaturePolicyIdentifier(h));else{if("signatureTimeStamp"!=c&&"timeStampToken"!=c)throw new e("unknown attr: "+c);o.push(new nt.asn1.cades.SignatureTimeStamp(h))}}var u=new i({array:o,sortflag:r});return this.hTLV=u.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.AttributeList,nt.asn1.ASN1Object),nt.asn1.cms.SignerInfo=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERInteger,n=i.DEROctetString,o=i.DERSequence,a=i.DERTaggedObject,h=i.cms,c=h.SignerIdentifier,u=h.AttributeList,l=(h.ContentType,h.EncapsulatedContentInfo,h.MessageDigest,h.SignedData,i.x509.AlgorithmIdentifier),d=r.crypto,p=Mt;h.SignerInfo.superclass.constructor.call(this),this.params=null,this.sign=function(){var t=this.params,e=t.sigalg,r=new u(t.sattrs).tohex(),i=p.getKey(t.signkey),s=new d.Signature({alg:e});s.init(i),s.updateHex(r);var n=s.sign();t.sighex=n},this.tohex=function(){var t=this.params,r=[];if(r.push(new s({int:t.version})),r.push(new c(t.id)),r.push(new l({name:t.hashalg})),null!=t.sattrs){var i=new u(t.sattrs);try{r.push(new a({tag:"a0",explicit:!1,obj:i}))}catch(t){throw new e("si sattr error: "+t)}}if(null!=t.sigalgfield?r.push(new l({name:t.sigalgfield})):r.push(new l({name:t.sigalg})),null==t.sighex&&null!=t.signkey&&this.sign(),r.push(new n({hex:t.sighex})),null!=t.uattrs){i=new u(t.uattrs);try{r.push(new a({tag:"a1",explicit:!1,obj:i}))}catch(t){throw new e("si uattr error: "+t)}}return new o({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SignerInfo,nt.asn1.ASN1Object),nt.asn1.cms.EncapsulatedContentInfo=function(t){var e=nt.asn1,r=e.DERTaggedObject,i=e.DERSequence,s=e.DERObjectIdentifier,n=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];if(e.push(new s(t.type)),null!=t.content&&(null!=t.content.hex||null!=t.content.str)&&1!=t.isDetached){var o=new n(t.content),a=new r({tag:"a0",explicit:!0,obj:o});e.push(a)}return new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.EncapsulatedContentInfo,nt.asn1.ASN1Object),nt.asn1.cms.ContentInfo=function(t){var e=nt.asn1,r=e.DERTaggedObject,i=e.DERSequence,s=e.DERObjectIdentifier;e.x509.OID.name2obj,nt.asn1.cms.ContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];e.push(new s(t.type));var n=new r({tag:"a0",explicit:!0,obj:t.obj});return e.push(n),new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.ContentInfo,nt.asn1.ASN1Object),nt.asn1.cms.SignedData=function(t){Error;var e=nt.asn1,r=(e.ASN1Object,e.DERInteger),i=e.DERSet,s=e.DERSequence,n=(e.DERTaggedObject,e.cms),o=n.EncapsulatedContentInfo,a=n.SignerInfo,h=n.ContentInfo,c=n.CertificateSet,u=n.RevocationInfoChoices,l=e.x509.AlgorithmIdentifier;nt.asn1.cms.SignedData.superclass.constructor.call(this),this.params=null,this.checkAndFixParam=function(){var t=this.params;this._setDigestAlgs(t),this._setContentTypeByEContent(t),this._setMessageDigestByEContent(t),this._setSignerInfoVersion(t),this._setSignedDataVersion(t)},this._setDigestAlgs=function(t){for(var e={},r=t.sinfos,i=0;i<r.length;i++)e[r[i].hashalg]=1;t.hashalgs=Object.keys(e).sort()},this._setContentTypeByEContent=function(t){for(var e=t.econtent.type,r=t.sinfos,i=0;i<r.length;i++){var s=r[i];this._getAttrParamByName(s,"contentType").type=e}},this._setMessageDigestByEContent=function(t){var e=t.econtent,r=(t.econtent.type,e.content.hex);null==r&&"data"==e.type&&null!=e.content.str&&(r=St(e.content.str));for(var i=t.sinfos,s=0;s<i.length;s++){var n=i[s],o=n.hashalg,a=this._getAttrParamByName(n,"messageDigest"),h=nt.crypto.Util.hashHex(r,o);a.hex=h}},this._getAttrParamByName=function(t,e){for(var r=t.sattrs.array,i=0;i<r.length;i++)if(r[i].attr==e)return r[i]},this._setSignerInfoVersion=function(t){for(var e=t.sinfos,r=0;r<e.length;r++){var i=e[r],s=1;"skid"==i.id.type&&(s=3),i.version=s}},this._setSignedDataVersion=function(t){var e=this._getSignedDataVersion(t);t.version=e},this._getSignedDataVersion=function(t){if(null!=t.revinfos)for(var e=t.revinfos,r=0;r<e.length;r++)if(null!=e[r].ocsp)return 5;var i=t.sinfos;for(r=0;r<i.length;r++)if(3==t.sinfos[r].version)return 3;return"data"!=t.econtent.type?3:1},this.tohex=function(){var t=this.params;null!=this.getEncodedHexPrepare&&this.getEncodedHexPrepare(),1!=t.fixed&&this.checkAndFixParam();var e=[];e.push(new r({int:t.version}));for(var n=[],h=0;h<t.hashalgs.length;h++){var d=t.hashalgs[h];n.push(new l({name:d}))}e.push(new i({array:n})),e.push(new o(t.econtent)),null!=t.certs&&e.push(new c(t.certs)),null!=t.revinfos&&e.push(new u(t.revinfos));var p=[];for(h=0;h<t.sinfos.length;h++){var g=t.sinfos[h];p.push(new a(g))}return e.push(new i({array:p})),new s({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.getContentInfo=function(){return new h({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.SignedData,nt.asn1.ASN1Object),nt.asn1.cms.CertificateSet=function(t){nt.asn1.cms.CertificateSet.superclass.constructor.call(this);var e=Error,r=nt.asn1,i=r.DERTaggedObject,s=r.DERSet,n=r.ASN1Object;this.params=null,this.tohex=function(){var t,r=this.params,o=[];if(r instanceof Array)t=r;else{if(null==r.array)throw new e("cert array not specified");t=r.array}for(var a=0;a<t.length;a++){var h=xt(t[a]),c=new n;c.hTLV=h,o.push(c)}var u={array:o};0==r.sortflag&&(u.sortflag=!1);var l=new s(u);return new i({tag:"a0",explicit:!1,obj:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.CertificateSet,nt.asn1.ASN1Object),nt.asn1.cms.RevocationInfoChoices=function(t){nt.asn1.cms.RevocationInfoChoices.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!t instanceof Array)throw new Error("params is not array");for(var e=[],r=0;r<t.length;r++)e.push(new nt.asn1.cms.RevocationInfoChoice(t[r]));return nt.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:{set:e}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.RevocationInfoChoices,nt.asn1.ASN1Object),nt.asn1.cms.RevocationInfoChoice=function(t){nt.asn1.cms.RevocationInfoChoice.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(null!=t.crl&&"string"==typeof t.crl){var e=t.crl;return-1!=t.crl.indexOf("-----BEGIN")&&(e=xt(t.crl)),e}if(null!=t.ocsp)return nt.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:new nt.asn1.cms.OtherRevocationFormat(t)}}).tohex();throw new Error("property crl or ocsp undefined")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.RevocationInfoChoice,nt.asn1.ASN1Object),nt.asn1.cms.OtherRevocationFormat=function(t){nt.asn1.cms.OtherRevocationFormat.superclass.constructor.call(this);var e=Error,r=nt,i=r.asn1.ASN1Util.newObject,s=r.lang.String.isHex;this.params=null,this.tohex=function(){var t=this.params;if(null==t.ocsp)throw new e("property ocsp not specified");if(!s(t.ocsp)||!ht.isASN1HEX(t.ocsp))throw new e("ocsp value not ASN.1 hex string");return i({seq:[{oid:"1.3.6.1.5.5.7.16.2"},{asn1:{tlv:t.ocsp}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cms.OtherRevocationFormat,nt.asn1.ASN1Object),nt.asn1.cms.CMSUtil=new function(){},nt.asn1.cms.CMSUtil.newSignedData=function(t){return new nt.asn1.cms.SignedData(t)},nt.asn1.cms.CMSUtil.verifySignedData=function(t){var e=nt,r=e.asn1,i=r.cms,s=(i.SignerInfo,i.SignedData,i.SigningTime,i.SigningCertificate,i.SigningCertificateV2,r.cades.SignaturePolicyIdentifier,e.lang.String.isHex),n=ht,o=n.getVbyList,a=n.getTLVbyList,h=n.getIdxbyList,c=n.getChildIdx,u=n.getTLV,l=n.oidname,d=e.crypto.Util.hashHex;void 0===t.cms&&s(t.cms);var p=t.cms,g=function(t,e){var r=e.idx;e.signerid_issuer1=a(t,r,[1,0],"30"),e.signerid_serial1=o(t,r,[1,1],"02"),e.hashalg=l(o(t,r,[2,0],"06"));var i=h(t,r,[3],"a0");e.idxSignedAttrs=i,f(t,e,i);var s=c(t,r).length;if(s<6)throw"malformed SignerInfo";e.sigalg=l(o(t,r,[s-2,0],"06")),e.sigval=o(t,r,[s-1],"04")},f=function(t,e,r){var i=c(t,r);e.signedAttrIdxList=i;for(var s=0;s<i.length;s++){var n,a=i[s],h=o(t,a,[0],"06");"2a864886f70d010905"===h?(n=mt(o(t,a,[1,0])),e.saSigningTime=n):"2a864886f70d010904"===h&&(n=o(t,a,[1,0],"04"),e.saMessageDigest=n)}},m=function(t,e,r,i){r.verifyDetail={};var s=r.verifyDetail,n=e.parse.econtent,o=r.hashalg,a=r.saMessageDigest;s.validMessageDigest=!1,d(n,o)===a&&(s.validMessageDigest=!0),function(t,e,r){var i,s=e.parse.certsIdx;if(void 0===e.certs){i=[],e.certkeys=[];for(var n=c(t,s),o=0;o<n.length;o++){var a=u(t,n[o]),h=new $t;h.readCertHex(a),i[o]=h,e.certkeys[o]=h.getPublicKey()}e.certs=i}else i=e.certs;for(e.cccc=i.length,e.cccci=n.length,o=0;o<i.length;o++){var l=h.getIssuerHex(),d=h.getSerialNumberHex();r.signerid_issuer1===l&&r.signerid_serial1===d&&(r.certkey_idx=o)}}(t,e,r),s.validSignatureValue=!1;var h=r.sigalg,l="31"+u(t,r.idxSignedAttrs).substr(2);r.signedattrshex=l;var p=e.certs[r.certkey_idx].getPublicKey(),g=new nt.crypto.Signature({alg:h});g.init(p),g.updateHex(l);var f=g.verify(r.sigval);s.validSignatureValue_isValid=f,!0===f&&(s.validSignatureValue=!0),r.isValid=!1,s.validMessageDigest&&s.validSignatureValue&&(r.isValid=!0)},y={isValid:!1,parse:{}};return function(t,e){if("2a864886f70d010702"!==o(t,0,[0],"06"))return e;e.cmsType="signedData",e.econtent=o(t,0,[1,0,2,1,0]),function(t,e){for(var r,i=3;i<6;i++)if(void 0!==(r=h(t,0,[1,0,i]))){var s=t.substr(r,2);"a0"===s&&(e.certsIdx=r),"a1"===s&&(e.revinfosIdx=r),"31"===s&&(e.signerinfosIdx=r)}}(t,e),e.signerInfos=[],function(t,e){var r=e.signerinfosIdx;if(void 0!==r){var i=c(t,r);e.signerInfoIdxList=i;for(var s=0;s<i.length;s++){var n={idx:i[s]};g(t,n),e.signerInfos.push(n)}}}(t,e)}(p,y.parse),function(t,e){for(var r=e.parse.signerInfos,i=r.length,s=!0,n=0;n<i;n++){var o=r[n];m(t,e,o),o.isValid||(s=!1)}e.isValid=s}(p,y),y},nt.asn1.cms.CMSParser=function(){var t=Error,e=$t,r=new e,i=ht,s=i.getV,n=i.getTLV,o=(i.getIdxbyList,i.getTLVbyList),a=i.getTLVbyListEx,h=i.getVbyList,c=i.getVbyListEx,u=i.getChildIdx;this.getCMSSignedData=function(t){var e=o(t,0,[1,0]);return this.getSignedData(e)},this.getSignedData=function(t){var e=u(t,0),r={},i=s(t,e[0]),o=parseInt(i,16);r.version=o;var h=n(t,e[1]);r.hashalgs=this.getHashAlgArray(h);var c=n(t,e[2]);r.econtent=this.getEContent(c);var l=a(t,0,["[0]"]);null!=l&&(r.certs=this.getCertificateSet(l)),a(t,0,["[1]"]);var d=a(t,0,[3]);return r.sinfos=this.getSignerInfos(d),r},this.getHashAlgArray=function(t){for(var r=u(t,0),i=new e,s=[],o=0;o<r.length;o++){var a=n(t,r[o]),h=i.getAlgorithmIdentifierName(a);s.push(h)}return s},this.getEContent=function(t){var e={},r=h(t,0,[0]),i=h(t,0,[1,0]);return e.type=nt.asn1.x509.OID.oid2name(ht.hextooidstr(r)),e.content={hex:i},e},this.getSignerInfos=function(t){for(var e=[],r=u(t,0),i=0;i<r.length;i++){var s=n(t,r[i]),o=this.getSignerInfo(s);e.push(o)}return e},this.getSignerInfo=function(t){var e={},s=u(t,0),o=i.getInt(t,s[0],-1);-1!=o&&(e.version=o);var h=n(t,s[1]),l=this.getIssuerAndSerialNumber(h);e.id=l;var d=n(t,s[2]),p=r.getAlgorithmIdentifierName(d);e.hashalg=p;var g=a(t,0,["[0]"]);if(null!=g){var f=this.getAttributeList(g);e.sattrs=f}var m=a(t,0,[3]),y=r.getAlgorithmIdentifierName(m);e.sigalg=y;var v=c(t,0,[4]);e.sighex=v;var S=a(t,0,["[1]"]);if(null!=S){var E=this.getAttributeList(S);e.uattrs=E}return e},this.getSignerIdentifier=function(t){if("30"==t.substr(0,2))return this.getIssuerAndSerialNumber(t);throw new Error("SKID of signerIdentifier not supported")},this.getIssuerAndSerialNumber=function(t){var e={type:"isssn"},i=u(t,0),o=n(t,i[0]);e.issuer=r.getX500Name(o);var a=s(t,i[1]);return e.serial={hex:a},e},this.getAttributeList=function(t){for(var e=[],r=u(t,0),i=0;i<r.length;i++){var s=n(t,r[i]),o=this.getAttribute(s);e.push(o)}return{array:e}},this.getAttribute=function(t){var e={},r=u(t,0),s=i.getOID(t,r[0]),o=nt.asn1.x509.OID.oid2name(s);e.attr=o;var a=n(t,r[1]),h=u(a,0);if(1==h.length)e.valhex=n(a,h[0]);else{for(var c=[],l=0;l<h.length;l++)c.push(n(a,h[l]));e.valhex=c}return"contentType"==o?this.setContentType(e):"messageDigest"==o?this.setMessageDigest(e):"signingTime"==o?this.setSigningTime(e):"signingCertificate"==o?this.setSigningCertificate(e):"signingCertificateV2"==o?this.setSigningCertificateV2(e):"signaturePolicyIdentifier"==o&&this.setSignaturePolicyIdentifier(e),e},this.setContentType=function(t){var e=i.getOIDName(t.valhex,0,null);null!=e&&(t.type=e,delete t.valhex)},this.setSigningTime=function(t){var e=mt(s(t.valhex,0));t.str=e,delete t.valhex},this.setMessageDigest=function(t){var e=s(t.valhex,0);t.hex=e,delete t.valhex},this.setSigningCertificate=function(t){var e=u(t.valhex,0);if(e.length>0){for(var r=n(t.valhex,e[0]),i=u(r,0),s=[],o=0;o<i.length;o++){var a=n(r,i[o]),h=this.getESSCertID(a);s.push(h)}t.array=s}if(e.length>1){var c=n(t.valhex,e[1]);t.polhex=c}delete t.valhex},this.setSignaturePolicyIdentifier=function(t){var r=u(t.valhex,0);if(r.length>0){var o=i.getOID(t.valhex,r[0]);t.oid=o}if(r.length>1){var a=new e,h=u(t.valhex,r[1]),c=n(t.valhex,h[0]),l=a.getAlgorithmIdentifierName(c);t.alg=l;var d=s(t.valhex,h[1]);t.hash=d}delete t.valhex},this.setSigningCertificateV2=function(t){var e=u(t.valhex,0);if(e.length>0){for(var r=n(t.valhex,e[0]),i=u(r,0),s=[],o=0;o<i.length;o++){var a=n(r,i[o]),h=this.getESSCertIDv2(a);s.push(h)}t.array=s}if(e.length>1){var c=n(t.valhex,e[1]);t.polhex=c}delete t.valhex},this.getESSCertID=function(t){var e={},r=u(t,0);if(r.length>0){var i=s(t,r[0]);e.hash=i}if(r.length>1){var o=n(t,r[1]),a=this.getIssuerSerial(o);null!=a.serial&&(e.serial=a.serial),null!=a.issuer&&(e.issuer=a.issuer)}return e},this.getESSCertIDv2=function(e){var i={},o=u(e,0);if(o.length<1||3<o.length)throw new t("wrong number of elements");var a=0;if("30"==e.substr(o[0],2)){var h=n(e,o[0]);i.alg=r.getAlgorithmIdentifierName(h),a++}else i.alg="sha256";var c=s(e,o[a]);if(i.hash=c,o.length>a+1){var l=n(e,o[a+1]),d=this.getIssuerSerial(l);i.issuer=d.issuer,i.serial=d.serial}return i},this.getIssuerSerial=function(t){var e={},i=u(t,0),o=n(t,i[0]),a=r.getGeneralNames(o)[0].dn;e.issuer=a;var h=s(t,i[1]);return e.serial={hex:h},e},this.getCertificateSet=function(t){for(var e=u(t,0),r=[],i=0;i<e.length;i++){var s=n(t,e[i]);if("30"==s.substr(0,2)){var o=Et(s,"CERTIFICATE");r.push(o)}}return{array:r,sortflag:!1}}},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.tsp&&nt.asn1.tsp||(nt.asn1.tsp={}),nt.asn1.tsp.TimeStampToken=function(t){var e=nt.asn1.tsp;e.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var t=new e.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=t.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.TimeStampToken,nt.asn1.cms.SignedData),nt.asn1.tsp.TSTInfo=function(t){Error;var e=nt.asn1,r=e.DERSequence,i=e.DERInteger,s=e.DERBoolean,n=e.DERGeneralizedTime,o=e.DERObjectIdentifier,a=e.DERTaggedObject,h=e.tsp,c=h.MessageImprint,u=h.Accuracy,l=(e.x509.X500Name,e.x509.GeneralName);if(h.TSTInfo.superclass.constructor.call(this),this.dVersion=new i({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var t=[this.dVersion];if(null==this.dPolicy)throw new Error("policy shall be specified.");if(t.push(this.dPolicy),null==this.dMessageImprint)throw new Error("messageImprint shall be specified.");if(t.push(this.dMessageImprint),null==this.dSerial)throw new Error("serialNumber shall be specified.");if(t.push(this.dSerial),null==this.dGenTime)throw new Error("genTime shall be specified.");t.push(this.dGenTime),null!=this.dAccuracy&&t.push(this.dAccuracy),null!=this.dOrdering&&t.push(this.dOrdering),null!=this.dNonce&&t.push(this.dNonce),null!=this.dTsa&&t.push(this.dTsa);var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t){if("string"==typeof t.policy){if(!t.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new o({oid:t.policy})}void 0!==t.messageImprint&&(this.dMessageImprint=new c(t.messageImprint)),void 0!==t.serial&&(this.dSerial=new i(t.serial)),void 0!==t.genTime&&(this.dGenTime=new n(t.genTime)),void 0!==t.accuracy&&(this.dAccuracy=new u(t.accuracy)),void 0!==t.ordering&&1==t.ordering&&(this.dOrdering=new s),void 0!==t.nonce&&(this.dNonce=new i(t.nonce)),void 0!==t.tsa&&(this.dTsa=new a({tag:"a0",explicit:!0,obj:new l({dn:t.tsa})}))}},Vt(nt.asn1.tsp.TSTInfo,nt.asn1.ASN1Object),nt.asn1.tsp.Accuracy=function(t){var e=nt.asn1,r=e.ASN1Util.newObject;e.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return null!=t.seconds&&"number"==typeof t.seconds&&e.push({int:t.seconds}),null!=t.millis&&"number"==typeof t.millis&&e.push({tag:{tagi:"80",obj:{int:t.millis}}}),null!=t.micros&&"number"==typeof t.micros&&e.push({tag:{tagi:"81",obj:{int:t.micros}}}),r({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.Accuracy,nt.asn1.ASN1Object),nt.asn1.tsp.MessageImprint=function(t){var e=nt.asn1,r=e.DERSequence,i=e.DEROctetString,s=e.x509.AlgorithmIdentifier;e.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=new s({name:t.alg}),n=new i({hex:t.hash});return new r({array:[e,n]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.tsp.MessageImprint,nt.asn1.ASN1Object),nt.asn1.tsp.TimeStampReq=function(t){var e=nt.asn1,r=e.DERSequence,i=e.DERInteger,s=e.DERBoolean,n=(e.ASN1Object,e.DERObjectIdentifier),o=e.tsp,a=o.MessageImprint;o.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new i({int:1})),t.messageImprint instanceof nt.asn1.ASN1Object?e.push(t.messageImprint):e.push(new a(t.messageImprint)),null!=t.policy&&e.push(new n(t.policy)),null!=t.nonce&&e.push(new i(t.nonce)),1==t.certreq&&e.push(new s),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.TimeStampReq,nt.asn1.ASN1Object),nt.asn1.tsp.TimeStampResp=function(t){var e=nt.asn1,r=e.DERSequence,i=(e.ASN1Object,e.tsp),s=i.PKIStatusInfo;i.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,n=[];if(null!=t.econtent||null!=t.tst)if(null!=t.statusinfo?n.push(new s(t.statusinfo)):n.push(new s("granted")),null!=t.econtent)n.push(new i.TimeStampToken(t).getContentInfo());else{if(!(t.tst instanceof e.ASN1Object))throw new Error("improper member tst value");n.push(t.tst)}else{if(null==t.statusinfo)throw new Error("parameter for token nor statusinfo not specified");n.push(new s(t.statusinfo))}return new r({array:n}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.TimeStampResp,nt.asn1.ASN1Object),nt.asn1.tsp.PKIStatusInfo=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.tsp,n=s.PKIStatus,o=s.PKIFreeText,a=s.PKIFailureInfo;s.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,r=[];if("string"==typeof t)r.push(new n(t));else{if(null==t.status)throw new e("property 'status' unspecified");r.push(new n(t.status)),null!=t.statusstr&&r.push(new o(t.statusstr)),null!=t.failinfo&&r.push(new a(t.failinfo))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.PKIStatusInfo,nt.asn1.ASN1Object),nt.asn1.tsp.PKIStatus=function(t){var e=Error,r=nt.asn1,i=r.DERInteger;r.tsp.PKIStatus.superclass.constructor.call(this);var s={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null,this.tohex=function(){var t,r=this.params;if("string"==typeof r)try{t=s[r]}catch(t){throw new e("undefined name: "+r)}else{if("number"!=typeof r)throw new e("unsupported params");t=r}return new i({int:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.PKIStatus,nt.asn1.ASN1Object),nt.asn1.tsp.PKIFreeText=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERUTF8String;r.tsp.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!(t instanceof Array))throw new e("wrong params: not array");for(var r=[],n=0;n<t.length;n++)r.push(new s({str:t[n]}));return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.PKIFreeText,nt.asn1.ASN1Object),nt.asn1.tsp.PKIFailureInfo=function(t){var e=Error,r=nt.asn1,i=r.DERBitString,s=r.tsp.PKIFailureInfo,n={badAlg:0,badRequest:2,badDataFormat:5,timeNotAvailable:14,unacceptedPolicy:15,unacceptedExtension:16,addInfoNotAvailable:17,systemFailure:25};s.superclass.constructor.call(this),this.params=null,this.getBinValue=function(){var t=this.params,r=0;if("number"==typeof t&&0<=t&&t<=25){for(var i=(r|=1<<t).toString(2),s="",o=i.length-1;o>=0;o--)s+=i[o];return s}if("string"==typeof t&&null!=n[t])return Ut([t],n);if("object"==typeof t&&null!=t.length)return Ut(t,n);throw new e("wrong params")},this.tohex=function(){this.params;var t=this.getBinValue();return new i({bin:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.tsp.PKIFailureInfo,nt.asn1.ASN1Object),nt.asn1.tsp.AbstractTSAAdapter=function(t){this.getTSTHex=function(t,e){throw"not implemented yet"}},nt.asn1.tsp.SimpleTSAAdapter=function(t){var e=nt,r=e.asn1.tsp,i=e.crypto.Util.hashHex;r.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(t,e){var s=i(t,e);this.params.econtent.content.messageImprint={alg:e,hash:s},this.params.econtent.content.serial={int:this.serial++};var n=Math.floor(1e9*Math.random());return this.params.econtent.content.nonce={int:n},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},Vt(nt.asn1.tsp.SimpleTSAAdapter,nt.asn1.tsp.AbstractTSAAdapter),nt.asn1.tsp.FixedTSAAdapter=function(t){var e=nt,r=e.asn1.tsp,i=e.crypto.Util.hashHex;r.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(t,e){var s=i(t,e);return this.params.econtent.content.messageImprint={alg:e,hash:s},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},Vt(nt.asn1.tsp.FixedTSAAdapter,nt.asn1.tsp.AbstractTSAAdapter),nt.asn1.tsp.TSPUtil=new function(){},nt.asn1.tsp.TSPUtil.newTimeStampToken=function(t){return new nt.asn1.tsp.TimeStampToken(t)},nt.asn1.tsp.TSPUtil.parseTimeStampReq=function(t){return(new nt.asn1.tsp.TSPParser).getTimeStampReq(t)},nt.asn1.tsp.TSPUtil.parseMessageImprint=function(t){return(new nt.asn1.tsp.TSPParser).getMessageImprint(t)},nt.asn1.tsp.TSPParser=function(){Error;var t=new $t,e=ht,r=e.getV,i=e.getTLV,s=e.getIdxbyList,n=(e.getTLVbyListEx,e.getChildIdx),o=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],a={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(t){var e=n(t,0);if(1==e.length)return this.getPKIStatusInfo(i(t,e[0]));if(e.length>1){var r=this.getPKIStatusInfo(i(t,e[0])),s=i(t,e[1]),o=this.getToken(s);return o.statusinfo=r,o}},this.getToken=function(t){var e=(new nt.asn1.cms.CMSParser).getCMSSignedData(t);return this.setTSTInfo(e),e},this.setTSTInfo=function(t){var e=t.econtent;if("tstinfo"==e.type){var r=e.content.hex,i=this.getTSTInfo(r);e.content=i}},this.getTSTInfo=function(e){var s={},o=n(e,0),a=r(e,o[1]);s.policy=Lt(a);var h=i(e,o[2]);s.messageImprint=this.getMessageImprint(h);var c=r(e,o[3]);s.serial={hex:c};var u=r(e,o[4]);s.genTime={str:mt(u)};var l=0;if(o.length>5&&"30"==e.substr(o[5],2)){var d=i(e,o[5]);s.accuracy=this.getAccuracy(d),l++}if(o.length>5+l&&"01"==e.substr(o[5+l],2)&&("ff"==r(e,o[5+l])&&(s.ordering=!0),l++),o.length>5+l&&"02"==e.substr(o[5+l],2)){var p=r(e,o[5+l]);s.nonce={hex:p},l++}if(o.length>5+l&&"a0"==e.substr(o[5+l],2)){var g=i(e,o[5+l]);g="30"+g.substr(2),pGeneralNames=t.getGeneralNames(g);var f=pGeneralNames[0].dn;s.tsa=f,l++}if(o.length>5+l&&"a1"==e.substr(o[5+l],2)){var m=i(e,o[5+l]);m="30"+m.substr(2);var y=t.getExtParamArray(m);s.ext=y,l++}return s},this.getAccuracy=function(t){for(var e={},i=n(t,0),s=0;s<i.length;s++){var o=t.substr(i[s],2),a=r(t,i[s]),h=parseInt(a,16);"02"==o?e.seconds=h:"80"==o?e.millis=h:"81"==o&&(e.micros=h)}return e},this.getMessageImprint=function(t){if("30"!=t.substr(0,2))throw new Error("head of messageImprint hex shall be x30");var i={},o=(n(t,0),s(t,0,[0,0])),a=r(t,o),h=e.hextooidstr(a),c=nt.asn1.x509.OID.oid2name(h);if(""==c)throw new Error("hashAlg name undefined: "+h);var u=c,l=s(t,0,[1]);return i.alg=u,i.hash=r(t,l),i},this.getPKIStatusInfo=function(t){var e={},s=n(t,0),a=0;try{var h=r(t,s[0]),c=parseInt(h,16);e.status=o[c]}catch(t){}if(s.length>1&&"30"==t.substr(s[1],2)){var u=i(t,s[1]);e.statusstr=this.getPKIFreeText(u),a++}if(s.length>a&&"03"==t.substr(s[1+a],2)){var l=i(t,s[1+a]);e.failinfo=this.getPKIFailureInfo(l)}return e},this.getPKIFreeText=function(t){for(var r=[],i=n(t,0),s=0;s<i.length;s++)r.push(e.getString(t,i[s]));return r},this.getPKIFailureInfo=function(t){var r=e.getInt(t,0);return null!=a[r]?a[r]:r},this.getTimeStampReq=function(t){var s={certreq:!1},o=n(t,0);if(o.length<2)throw new Error("TimeStampReq must have at least 2 items");var a=i(t,o[1]);s.messageImprint=nt.asn1.tsp.TSPUtil.parseMessageImprint(a);for(var h=2;h<o.length;h++){var c=o[h],u=t.substr(c,2);if("06"==u){var l=r(t,c);s.policy=e.hextooidstr(l)}"02"==u&&(s.nonce=r(t,c)),"01"==u&&(s.certreq=!0)}return s}},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.cades&&nt.asn1.cades||(nt.asn1.cades={}),nt.asn1.cades.SignaturePolicyIdentifier=function(t){var e=nt.asn1.cades,r=e.SignaturePolicyId;e.SignaturePolicyIdentifier.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.15",this.params=null,this.getValueArray=function(){return[new r(this.params)]},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.SignaturePolicyIdentifier,nt.asn1.cms.Attribute),nt.asn1.cades.SignaturePolicyId=function(t){var e=nt.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=(e.x509.AlgorithmIdentifier,e.cades),n=s.SignaturePolicyId,o=s.OtherHashAlgAndValue;n.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new i(t.oid)),e.push(new o(t)),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.SignaturePolicyId,nt.asn1.ASN1Object),nt.asn1.cades.OtherHashAlgAndValue=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DEROctetString,n=r.x509.AlgorithmIdentifier;r.cades.OtherHashAlgAndValue.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(null==t.alg)throw new e("property 'alg' not specified");if(null==t.hash&&null==t.cert)throw new e("property 'hash' nor 'cert' not specified");var r=null;if(null!=t.hash)r=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new e("cert not string");var o=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(o=xt(t.cert)),r=nt.crypto.Util.hashHex(o,t.alg)}var a=[];return a.push(new n({name:t.alg})),a.push(new s({hex:r})),new i({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.OtherHashAlgAndValue,nt.asn1.ASN1Object),nt.asn1.cades.OtherHashValue=function(t){nt.asn1.cades.OtherHashValue.superclass.constructor.call(this);var e=Error,r=nt,i=(r.lang.String.isHex,r.asn1.DEROctetString);r.crypto.Util.hashHex,this.params=null,this.tohex=function(){var t=this.params;if(null==t.hash&&null==t.cert)throw new e("hash or cert not specified");var r=null;if(null!=t.hash)r=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new e("cert not string");var s=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(s=xt(t.cert)),r=nt.crypto.Util.hashHex(s,"sha1")}return new i({hex:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.OtherHashValue,nt.asn1.ASN1Object),nt.asn1.cades.SignatureTimeStamp=function(t){var e=Error,r=nt,i=r.lang.String.isHex,s=r.asn1,n=s.ASN1Object;s.x509,s.cades.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var t=this.params;if(null!=t.tst){if(i(t.tst))return(r=new n).hTLV=t.tst,[r];if(t.tst instanceof n)return[t.tst];throw new e("params.tst has wrong value")}if(null!=t.res){var r,s=t.res;if(s instanceof n&&(s=s.tohex()),"string"!=typeof s||!i(s))throw new e("params.res has wrong value");return ht.getTLVbyList(s,0,[1]),(r=new n).hTLV=t.tst,[r]}},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.SignatureTimeStamp,nt.asn1.cms.Attribute),nt.asn1.cades.CompleteCertificateRefs=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERSequence,n=i.cades,o=n.OtherCertID,a=r.lang.String.isHex;n.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var t=this.params,r=[],i=0;i<t.array.length;i++){var n=t.array[i];if("string"==typeof n)if(-1!=n.indexOf("-----BEGIN"))n={cert:n};else{if(!a(n))throw new e("unsupported value: "+n);n={hash:n}}null!=t.alg&&null==n.alg&&(n.alg=t.alg),null!=t.hasis&&null==n.hasis&&(n.hasis=t.hasis);var h=new o(n);r.push(h)}return[new s({array:r})]},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.CompleteCertificateRefs,nt.asn1.cms.Attribute),nt.asn1.cades.OtherCertID=function(t){var e=nt.asn1,r=e.DERSequence,i=e.cms.IssuerSerial,s=e.cades,n=s.OtherHashValue,o=s.OtherHashAlgAndValue;s.OtherCertID.superclass.constructor.call(this),this.params=t,this.tohex=function(){var t=this.params;"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:_isHex(t)&&(t={hash:t}));var e,s=[];if(e=null!=t.alg?new o(t):new n(t),s.push(e),null!=t.cert&&1==t.hasis||null!=t.issuer&&null!=t.serial){var a=new i(t);s.push(a)}return new r({array:s}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.OtherCertID,nt.asn1.ASN1Object),nt.asn1.cades.OtherHash=function(t){Error;var e=nt,r=e.asn1,i=(r.cms,r.cades),s=i.OtherHashAlgAndValue,n=i.OtherHashValue,o=(e.crypto.Util.hashHex,e.lang.String.isHex);i.OtherHash.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;return"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:o(t)&&(t={hash:t})),(null!=t.alg?new s(t):new n(t)).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.cades.OtherHash,nt.asn1.ASN1Object),nt.asn1.cades.CAdESUtil=new function(){},nt.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned=function(t){return(new nt.asn1.cms.CMSParser).getCMSSignedData(t)},nt.asn1.cades.CAdESUtil.parseSignerInfoForAddingUnsigned=function(t,e,r){var i=ht,s=i.getChildIdx,n=i.getTLV,o=i.getV,a=nt.asn1,h=a.ASN1Object,c=a.cms,u=c.AttributeList,l=c.SignerInfo,d={},p=s(t,e);if(6!=p.length)throw"not supported items for SignerInfo (!=6)";var g=p.shift();d.version=n(t,g);var f=p.shift();d.si=n(t,f);var m=p.shift();d.digalg=n(t,m);var y=p.shift();d.sattrs=n(t,y);var v=p.shift();d.sigalg=n(t,v);var S=p.shift();d.sig=n(t,S),d.sigval=o(t,S);var E=null;return d.obj=new l,(E=new h).hTLV=d.version,d.obj.dCMSVersion=E,(E=new h).hTLV=d.si,d.obj.dSignerIdentifier=E,(E=new h).hTLV=d.digalg,d.obj.dDigestAlgorithm=E,(E=new h).hTLV=d.sattrs,d.obj.dSignedAttrs=E,(E=new h).hTLV=d.sigalg,d.obj.dSigAlg=E,(E=new h).hTLV=d.sig,d.obj.dSig=E,d.obj.dUnsignedAttrs=new u,d},void 0!==nt.asn1.csr&&nt.asn1.csr||(nt.asn1.csr={}),nt.asn1.csr.CertificationRequest=function(t){var e=nt.asn1,r=e.DERBitString,i=e.DERSequence,s=e.csr,n=(e.x509,s.CertificationRequestInfo);s.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.sign=function(){var t=new n(this.params).tohex(),e=new nt.crypto.Signature({alg:this.params.sigalg});e.init(this.params.sbjprvkey),e.updateHex(t);var r=e.sign();this.params.sighex=r},this.getPEM=function(){return Et(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var t=this.params,e=new nt.asn1.csr.CertificationRequestInfo(this.params),s=new nt.asn1.x509.AlgorithmIdentifier({name:t.sigalg});if(null==t.sighex&&null!=t.sbjprvkey&&this.sign(),null==t.sighex)throw new Error("sighex or sbjprvkey parameter not defined");var n=new r({hex:"00"+t.sighex});return new i({array:[e,s,n]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.csr.CertificationRequest,nt.asn1.ASN1Object),nt.asn1.csr.CertificationRequestInfo=function(t){var e=nt.asn1,r=(e.DERBitString,e.DERSequence),i=e.DERInteger,s=e.DERUTF8String,n=e.DERTaggedObject,o=e.ASN1Util.newObject,a=e.csr,h=e.x509,c=h.X500Name,u=h.Extensions,l=h.SubjectPublicKeyInfo;a.AttributeList,a.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(t){null!=t&&(this.params=t)},this.tohex=function(){var t=this.params,e=[];if(e.push(new i({int:0})),e.push(new c(t.subject)),e.push(new l(Mt.getKey(t.sbjpubkey))),null!=t.attrs){var a=function(t){for(var e=Error,r=nt.asn1.x509.Extensions,i=[],s=0;s<t.length;s++){var n=t[s],o=n.attr;if("extensionRequest"==o){var a={seq:[{oid:"1.2.840.113549.1.9.14"},{set:[new r(n.ext)]}]};i.push(a)}else if("unstructuredName"==o)a={seq:[{oid:"1.2.840.113549.1.9.2"},{set:n.names}]},i.push(a);else{if("challengePassword"!=o)throw new e("unknown CSR attribute");a={seq:[{oid:"1.2.840.113549.1.9.7"},{set:[{utf8str:n.password}]}]},i.push(a)}}return{set:i}}(t.attrs),h=o({tag:{tage:"a0",obj:a}});e.push(h)}else if(null!=t.extreq){var d=new u(t.extreq);h=o({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[d]}]}}}),e.push(h)}else e.push(new n({tag:"a0",explicit:!1,obj:new s({str:""})}));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Vt(nt.asn1.csr.CertificationRequestInfo,nt.asn1.ASN1Object),nt.asn1.csr.AttributeList=function(t){},Vt(nt.asn1.csr.AttributeList,nt.asn1.ASN1Object),nt.asn1.csr.CSRUtil=new function(){},nt.asn1.csr.CSRUtil.newCSRPEM=function(t){return new nt.asn1.csr.CertificationRequest(t).getPEM()},nt.asn1.csr.CSRUtil.getParam=function(t,e){var r=ht,i=r.getV,s=r.getIdxbyList,n=r.getTLVbyList,o=r.getTLVbyListEx,a=r.getVbyListEx,h={};if(-1==t.indexOf("-----BEGIN CERTIFICATE REQUEST"))throw new Error("argument is not PEM file");var c=xt(t,"CERTIFICATE REQUEST");e&&(h.tbs=n(c,0,[0]));try{var u=o(c,0,[0,1]);if("3000"==u)h.subject={};else{var l=new $t;h.subject=l.getX500Name(u)}}catch(t){}var d=o(c,0,[0,2]),p=Mt.getKey(d,null,"pkcs8pub");h.sbjpubkey=Mt.getPEM(p,"PKCS8PUB");var g=function(t){var e=s(t,0,[0,3,0,0],"06");return"2a864886f70d01090e"!=i(t,e)?null:n(t,0,[0,3,0,1,0],"30")}(c);l=new $t,null!=g&&(h.extreq=l.getExtParamArray(g));try{var f=o(c,0,[1],"30");l=new $t,h.sigalg=l.getAlgorithmIdentifierName(f)}catch(t){}try{var m=a(c,0,[2]);h.sighex=m}catch(t){}return h},nt.asn1.csr.CSRUtil.verifySignature=function(t){try{var e=null;if("string"==typeof t&&-1!=t.indexOf("-----BEGIN CERTIFICATE REQUEST")?e=nt.asn1.csr.CSRUtil.getParam(t,!0):"object"==typeof t&&null!=t.sbjpubkey&&null!=t.sigalg&&null!=t.sighex&&null!=t.tbs&&(e=t),null==e)return!1;var r=new nt.crypto.Signature({alg:e.sigalg});return r.init(e.sbjpubkey),r.updateHex(e.tbs),r.verify(e.sighex)}catch(t){return alert(t),!1}},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.ocsp&&nt.asn1.ocsp||(nt.asn1.ocsp={}),nt.asn1.ocsp.DEFAULT_HASH="sha1",nt.asn1.ocsp.OCSPResponse=function(t){nt.asn1.ocsp.OCSPResponse.superclass.constructor.call(this),nt.asn1.DEREnumerated;var e=nt.asn1.ASN1Util.newObject,r=nt.asn1.ocsp.ResponseBytes,i=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var t=this.params.resstatus;return"number"==typeof t?t:"string"!=typeof t?-1:i.indexOf(t)},this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,i=this._getStatusCode();if(-1==i)throw new Error("responseStatus not supported: "+t.resstatus);if(0!=i)return e({seq:[{enum:{int:i}}]}).tohex();var s=new r(t);return e({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:s}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.OCSPResponse,nt.asn1.ASN1Object),nt.asn1.ocsp.ResponseBytes=function(t){nt.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=e.DEROctetString,n=e.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if("ocspBasic"!=t.restype)throw new Error("not supported responseType: "+t.restype);var e=new n(t),o=[];return o.push(new i({name:"ocspBasic"})),o.push(new s({hex:e.tohex()})),new r({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.ResponseBytes,nt.asn1.ASN1Object),nt.asn1.ocsp.BasicOCSPResponse=function(t){nt.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var e=Error,r=nt.asn1,i=r.ASN1Object,s=r.DERSequence,n=(r.DERGeneralizedTime,r.DERTaggedObject),o=r.DERBitString,a=(r.x509.Extensions,r.x509.AlgorithmIdentifier),h=r.ocsp;h.ResponderID,_SingleResponseList=h.SingleResponseList,_ResponseData=h.ResponseData,this.params=null,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.tbsresp.tohex(),r=new nt.crypto.Signature({alg:t.sigalg});r.init(t.reskey),r.updateHex(e),t.sighex=r.sign()},this.tohex=function(){var t=this.params;null==t.tbsresp&&(t.tbsresp=new _ResponseData(t)),null==t.sighex&&null!=t.reskey&&this.sign();var r=[];if(r.push(t.tbsresp),r.push(new a({name:t.sigalg})),r.push(new o({hex:"00"+t.sighex})),null!=t.certs&&null!=t.certs.length){for(var h=[],c=0;c<t.certs.length;c++){var u=t.certs[c],l=null;if(ht.isASN1HEX(u))l=u;else{if(!u.match(/-----BEGIN/))throw new e("certs["+c+"] not hex or PEM");l=xt(u)}h.push(new i({tlv:l}))}var d=new s({array:h});r.push(new n({tag:"a0",explicit:!0,obj:d}))}return new s({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.BasicOCSPResponse,nt.asn1.ASN1Object),nt.asn1.ocsp.ResponseData=function(t){nt.asn1.ocsp.ResponseData.superclass.constructor.call(this);var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERGeneralizedTime,n=r.DERTaggedObject,o=r.x509.Extensions,a=r.ocsp,h=a.ResponderID;_SingleResponseList=a.SingleResponseList,this.params=null,this.tohex=function(){var t=this.params;null!=t.respid&&new e("respid not specified"),null!=t.prodat&&new e("prodat not specified"),null!=t.array&&new e("array not specified");var r=[];if(r.push(new h(t.respid)),r.push(new s(t.prodat)),r.push(new _SingleResponseList(t.array)),null!=t.ext){var a=new o(t.ext);r.push(new n({tag:"a1",explicit:!0,obj:a}))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.ResponseData,nt.asn1.ASN1Object),nt.asn1.ocsp.ResponderID=function(t){nt.asn1.ocsp.ResponderID.superclass.constructor.call(this);var e=nt,r=e.asn1,i=r.ASN1Util.newObject,s=r.x509.X500Name,n=e.lang.String.isHex,o=Error;this.params=null,this.tohex=function(){var t=this.params;if(null!=t.key){var e,r=null;if("string"==typeof t.key?(n(t.key)&&(r=t.key),t.key.match(/-----BEGIN CERTIFICATE/)&&null!=(e=new $t(t.key).getExtSubjectKeyIdentifier())&&(r=e.kid.hex)):t.key instanceof $t&&null!=(e=t.key.getExtSubjectKeyIdentifier())&&(r=e.kid.hex),null==r)throw new o("wrong key member value");return i({tag:{tag:"a2",explicit:!0,obj:{octstr:{hex:r}}}}).tohex()}if(null!=t.name){var a=null;if("string"==typeof t.name&&t.name.match(/-----BEGIN CERTIFICATE/)?a=new $t(t.name).getSubject():t.name instanceof $t?a=t.name.getSubject():"object"!=typeof t.name||null==t.name.array&&null==t.name.str||(a=t.name),null==a)throw new o("wrong name member value");return i({tag:{tag:"a1",explicit:!0,obj:new s(a)}}).tohex()}throw new o("key or name not specified")},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.ResponderID,nt.asn1.ASN1Object),nt.asn1.ocsp.SingleResponseList=function(t){nt.asn1.ocsp.SingleResponseList.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.ocsp.SingleResponse;this.params=null,this.tohex=function(){var t=this.params;if("object"!=typeof t||null==t.length)throw new Error("params not specified properly");for(var e=[],s=0;s<t.length;s++)e.push(new i(t[s]));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.SingleResponseList,nt.asn1.ASN1Object),nt.asn1.ocsp.SingleResponse=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERGeneralizedTime,n=r.DERTaggedObject,o=r.ocsp,a=o.CertID,h=o.CertStatus,c=r.x509.Extensions;o.SingleResponse.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,r=[];if(null==t.certid)throw new e("certid unspecified");if(null==t.status)throw new e("status unspecified");if(null==t.thisupdate)throw new e("thisupdate unspecified");if(r.push(new a(t.certid)),r.push(new h(t.status)),r.push(new s(t.thisupdate)),null!=t.nextupdate){var o=new s(t.nextupdate);r.push(new n({tag:"a0",explicit:!0,obj:o}))}if(null!=t.ext){var u=new c(t.ext);r.push(new n({tag:"a1",explicit:!0,obj:u}))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.SingleResponse,nt.asn1.ASN1Object),nt.asn1.ocsp.CertID=function(t){var e=nt,r=e.asn1,i=r.DEROctetString,s=r.DERInteger,n=r.DERSequence,o=r.x509.AlgorithmIdentifier,a=r.ocsp,h=(a.DEFAULT_HASH,e.crypto.Util.hashHex),c=$t,u=ht.getVbyList;a.CertID.superclass.constructor.call(this),this.DEFAULT_HASH="sha1",this.params=null,this.setByValue=function(t,e,r,i){null==i&&(i=this.DEFAULT_HASH),this.params={alg:i,issname:t,isskey:e,sbjsn:r}},this.setByCert=function(t,e,r){null==r&&(r=this.DEFAULT_HASH),this.params={alg:r,issuerCert:t,subjectCert:e}},this.getParamByCerts=function(t,e,r){null==r&&(r=this.DEFAULT_HASH);var i=new c(t),s=new c(e),n=h(i.getSubjectHex(),r),o=i.getPublicKeyHex();return{alg:r,issname:n,isskey:h(u(o,0,[1],"03",!0),r),sbjsn:s.getSerialNumberHex()}},this.tohex=function(){if("object"!=typeof this.params)throw new Error("params not set");var t,e,r,a,h=this.params;if(a=null==h.alg?this.DEFAULT_HASH:h.alg,null!=h.issuerCert&&null!=h.subjectCert){var c=this.getParamByCerts(h.issuerCert,h.subjectCert,a);t=c.issname,e=c.isskey,r=c.sbjsn}else{if(null==h.issname||null==h.isskey||null==h.sbjsn)throw new Error("required param members not defined");t=h.issname,e=h.isskey,r=h.sbjsn}var u=new o({name:a}),l=new i({hex:t}),d=new i({hex:e}),p=new s({hex:r}),g=new n({array:[u,l,d,p]});return this.hTLV=g.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.CertID,nt.asn1.ASN1Object),nt.asn1.ocsp.CertStatus=function(t){nt.asn1.ocsp.CertStatus.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("good"==t.status)return"8000";if("unknown"==t.status)return"8200";if("revoked"==t.status){var e=[{gentime:{str:t.time}}];null!=t.reason&&e.push({tag:{tag:"a0",explicit:!0,obj:{enum:{int:t.reason}}}});var r={tag:"a1",explicit:!1,obj:{seq:e}};return nt.asn1.ASN1Util.newObject({tag:r}).tohex()}throw new Error("bad status")},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Vt(nt.asn1.ocsp.CertStatus,nt.asn1.ASN1Object),nt.asn1.ocsp.Request=function(t){var e=nt.asn1,r=e.DERSequence,i=e.ocsp;if(i.Request.superclass.constructor.call(this),this.dReqCert=null,this.dExt=null,this.tohex=function(){var t=[];if(null===this.dReqCert)throw"reqCert not set";t.push(this.dReqCert);var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t){var s=new i.CertID(t);this.dReqCert=s}},Vt(nt.asn1.ocsp.Request,nt.asn1.ASN1Object),nt.asn1.ocsp.TBSRequest=function(t){var e=nt.asn1,r=e.DERSequence,i=e.ocsp;i.TBSRequest.superclass.constructor.call(this),this.version=0,this.dRequestorName=null,this.dRequestList=[],this.dRequestExt=null,this.setRequestListByParam=function(t){for(var e=[],r=0;r<t.length;r++){var s=new i.Request(t[0]);e.push(s)}this.dRequestList=e},this.tohex=function(){var t=[];if(0!==this.version)throw"not supported version: "+this.version;if(null!==this.dRequestorName)throw"requestorName not supported";var e=new r({array:this.dRequestList});if(t.push(e),null!==this.dRequestExt)throw"requestExtensions not supported";var i=new r({array:t});return this.hTLV=i.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList&&this.setRequestListByParam(t.reqList)},Vt(nt.asn1.ocsp.TBSRequest,nt.asn1.ASN1Object),nt.asn1.ocsp.OCSPRequest=function(t){var e=nt.asn1,r=e.DERSequence,i=e.ocsp;if(i.OCSPRequest.superclass.constructor.call(this),this.dTbsRequest=null,this.dOptionalSignature=null,this.tohex=function(){var t=[];if(null===this.dTbsRequest)throw"tbsRequest not set";if(t.push(this.dTbsRequest),null!==this.dOptionalSignature)throw"optionalSignature not supported";var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList){var s=new i.TBSRequest(t);this.dTbsRequest=s}},Vt(nt.asn1.ocsp.OCSPRequest,nt.asn1.ASN1Object),nt.asn1.ocsp.OCSPUtil={},nt.asn1.ocsp.OCSPUtil.getRequestHex=function(t,e,r){var i=nt.asn1.ocsp;void 0===r&&(r=i.DEFAULT_HASH);var s={alg:r,issuerCert:t,subjectCert:e};return new i.OCSPRequest({reqList:[s]}).tohex()},nt.asn1.ocsp.OCSPUtil.getOCSPResponseInfo=function(t){var e=ht,r=e.getVbyList,i=e.getVbyListEx,s=e.getIdxbyList,n=(e.getIdxbyListEx,e.getV),o={};try{var a=i(t,0,[0],"0a");o.responseStatus=parseInt(a,16)}catch(t){}if(0!==o.responseStatus)return o;try{var h=s(t,0,[1,0,1,0,0,2,0,1]);"80"===t.substr(h,2)?o.certStatus="good":"a1"===t.substr(h,2)?(o.certStatus="revoked",o.revocationTime=mt(r(t,h,[0]))):"82"===t.substr(h,2)&&(o.certStatus="unknown")}catch(t){}try{var c=s(t,0,[1,0,1,0,0,2,0,2]);o.thisUpdate=mt(n(t,c))}catch(t){}try{var u=s(t,0,[1,0,1,0,0,2,0,3]);"a0"===t.substr(u,2)&&(o.nextUpdate=mt(r(t,u,[0])))}catch(t){}return o},nt.asn1.ocsp.OCSPParser=function(){var t=Error,e=$t,r=new e,i=ht,s=i.getV,n=i.getTLV,o=i.getIdxbyList,a=i.getVbyList,h=i.getTLVbyList,c=i.getVbyListEx,u=i.getTLVbyListEx,l=i.getChildIdx;this.getOCSPRequest=function(e){var r=l(e,0);if(1!=r.length&&2!=r.length)throw new t("wrong number elements: "+r.length);return this.getTBSRequest(n(e,r[0]))},this.getTBSRequest=function(t){var e={},i=u(t,0,[0],"30");e.array=this.getRequestList(i);var s=u(t,0,["[2]",0],"30");return null!=s&&(e.ext=r.getExtParamArray(s)),e},this.getRequestList=function(t){for(var e=[],r=l(t,0),i=0;i<r.length;i++)t=n(t,r[i]),e.push(this.getRequest(t));return e},this.getRequest=function(e){var i=l(e,0);if(1!=i.length&&2!=i.length)throw new t("wrong number elements: "+i.length);var s=this.getCertID(n(e,i[0]));if(2==i.length){var a=o(e,0,[1,0]);s.ext=r.getExtParamArray(n(e,a))}return s},this.getCertID=function(r){var i=l(r,0);if(4!=i.length)throw new t("wrong number elements: "+i.length);var o=new e,a={};return a.alg=o.getAlgorithmIdentifierName(n(r,i[0])),a.issname=s(r,i[1]),a.isskey=s(r,i[2]),a.sbjsn=s(r,i[3]),a},this.getOCSPResponse=function(t){var e,r=l(t,0),i=s(t,r[0]),n=parseInt(i);if(1==r.length)return{resstatus:n};var o=h(t,0,[1,0]);return(e=this.getResponseBytes(o)).resstatus=n,e},this.getResponseBytes=function(t){var e,r=l(t,0),i=h(t,0,[1,0]);e=this.getBasicOCSPResponse(i);var n=s(t,r[0]);return e.restype=nt.asn1.x509.OID.oid2name(Lt(n)),e},this.getBasicOCSPResponse=function(t){var e,r=l(t,0);e=this.getResponseData(n(t,r[0]));var i=new $t;e.alg=i.getAlgorithmIdentifierName(n(t,r[1]));var o=s(t,r[2]);e.sighex=o.substr(2);var a=c(t,0,["[0]"]);if(null!=a){for(var h=l(a,0),u=[],d=0;d<h.length;d++){var p=n(a,h[d]);u.push(p)}e.certs=u}return e},this.getResponseData=function(t){var e=l(t,0),r=e.length,i={},o=0;"a0"==t.substr(e[0],2)&&o++,i.respid=this.getResponderID(n(t,e[o++]));var a=s(t,e[o++]);if(i.prodat=mt(a),i.array=this.getSingleResponseList(n(t,e[o++])),"a1"==t.substr(e[r-1],2)){var c=h(t,e[r-1],[0]),u=new $t;i.ext=u.getExtParamArray(c)}return i},this.getResponderID=function(t){var e={};if("a2"==t.substr(0,2)){var r=a(t,0,[0]);e.key=r}if("a1"==t.substr(0,2)){var i=h(t,0,[0]),s=new $t;e.name=s.getX500Name(i)}return e},this.getSingleResponseList=function(t){for(var e=l(t,0),r=[],i=0;i<e.length;i++){var s=this.getSingleResponse(n(t,e[i]));r.push(s)}return r},this.getSingleResponse=function(t){var e=l(t,0),r={},i=this.getCertID(n(t,e[0]));r.certid=i;var o=this.getCertStatus(n(t,e[1]));if(r.status=o,"18"==t.substr(e[2],2)){var c=s(t,e[2]);r.thisupdate=mt(c)}for(var u=3;u<e.length;u++){if("a0"==t.substr(e[u],2)){var d=a(t,e[u],[0],"18");r.nextupdate=mt(d)}if("a1"==t.substr(e[u],2)){var p=new $t,g=h(t,0,[u,0]);r.ext=p.getExtParamArray(g)}}return r},this.getCertStatus=function(t){var e={};if("8000"==t)return{status:"good"};if("8200"==t)return{status:"unknown"};if("a1"==t.substr(0,2)){e.status="revoked";var r=mt(a(t,0,[0]));e.time=r}return e}},void 0!==nt&&nt||(nt={}),void 0!==nt.lang&&nt.lang||(nt.lang={}),nt.lang.String=function(){},"function"==typeof Buffer?(ot=function(t){return lt(Buffer.from(t,"utf8").toString("base64"))},at=function(t){return Buffer.from(dt(t),"base64").toString("utf8")}):(ot=function(t){return pt(wt(Dt(t)))},at=function(t){return decodeURIComponent(At(gt(t)))}),nt.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},nt.lang.String.isHex=function(t){return Ot(t)},nt.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},nt.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=dt(t),nt.lang.String.isBase64(t))},nt.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},nt.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},nt.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},nt.lang.String.isMail=function(t){return null!==t.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var kt=function(t,e,r){return null==r&&(r="0"),t.length>=e?t:new Array(e-t.length+1).join(r)+t};function Ut(t,e){for(var r=0,i=0;i<t.length;i++)r|=1<<e[t[i]];var s=r.toString(2),n="";for(i=s.length-1;i>=0;i--)n+=s[i];return n}function jt(t,e,r){if("object"==typeof t){e=String(e).split(".");for(var i=0;i<e.length&&t;i++){var s=e[i];s.match(/^[0-9]+$/)&&(s=parseInt(s)),t=t[s]}return t||!1===t?t:r}}function Vt(t,e){var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e)}void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:f.algo.MD5,sha1:f.algo.SHA1,sha224:f.algo.SHA224,sha256:f.algo.SHA256,sha384:f.algo.SHA384,sha512:f.algo.SHA512,ripemd160:f.algo.RIPEMD160},this.getDigestInfoHex=function(t,e){if(void 0===this.DIGESTINFOHEAD[e])throw"alg not supported in Util.DIGESTINFOHEAD: "+e;return this.DIGESTINFOHEAD[e]+t},this.getPaddedDigestInfoHex=function(t,e,r){var i=this.getDigestInfoHex(t,e),s=r/4;if(i.length+22>s)throw"key is too short for SigAlg: keylen="+r+","+e;for(var n="00"+i,o="",a=s-4-n.length,h=0;h<a;h+=2)o+="ff";return"0001"+o+n},this.hashString=function(t,e){return new nt.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new nt.crypto.MessageDigest({alg:e}).digestHex(t)},this.sha1=function(t){return this.hashString(t,"sha1")},this.sha256=function(t){return this.hashString(t,"sha256")},this.sha256Hex=function(t){return this.hashHex(t,"sha256")},this.sha512=function(t){return this.hashString(t,"sha512")},this.sha512Hex=function(t){return this.hashHex(t,"sha512")},this.isKey=function(t){return t instanceof tt||t instanceof nt.crypto.DSA||t instanceof nt.crypto.ECDSA}},nt.crypto.Util.md5=function(t){return new nt.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},nt.crypto.Util.ripemd160=function(t){return new nt.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},nt.crypto.Util.SECURERANDOMGEN=new Q,nt.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return nt.crypto.Util.SECURERANDOMGEN.nextBytes(e),ct(e)},nt.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new E(nt.crypto.Util.getRandomHexOfNbytes(t),16)},nt.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,r=new Array((t-e)/8+1);return nt.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<e&255^255)&r[0],ct(r)},nt.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new E(nt.crypto.Util.getRandomHexOfNbits(t),16)},nt.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=nt.crypto.Util.getRandomBigIntegerOfNbits(e);if(t.compareTo(r)>=0)return r}},nt.crypto.Util.getRandomBigIntegerMinToMax=function(t,e){var r=t.compareTo(e);if(r>0)throw"biMin is greater than biMax";if(0==r)return t;var i=e.subtract(t);return nt.crypto.Util.getRandomBigIntegerZeroToMax(i).add(t)},nt.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=nt.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=nt.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=nt.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[t].create()}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=f.enc.Hex.parse(t);this.md.update(e)},this.digest=function(){return this.md.finalize().toString(f.enc.Hex)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}if(-1!=":sha256:".indexOf(t)&&"sjcl"==e){try{this.md=new sjcl.hash.sha256}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=sjcl.codec.hex.toBits(t);this.md.update(e)},this.digest=function(){var t=this.md.finalize();return sjcl.codec.hex.fromBits(t)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(t){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==t&&void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=nt.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},nt.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},nt.crypto.MessageDigest.getHashLength=function(t){var e=nt.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},nt.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},nt.crypto.Mac=function(t){this.setAlgAndProvider=function(t,e){if(null==(t=t.toLowerCase())&&(t="hmacsha1"),"hmac"!=(t=t.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+t;void 0===e&&(e=nt.crypto.Util.DEFAULTPROVIDER[t]),this.algProv=t+"/"+e;var r=t.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(r)&&"cryptojs"==e){try{var i=nt.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[r];this.mac=f.algo.HMAC.create(i,this.pass)}catch(t){throw"setAlgAndProvider hash alg set fail hashAlg="+r+"/"+t}this.updateString=function(t){this.mac.update(t)},this.updateHex=function(t){var e=f.enc.Hex.parse(t);this.mac.update(e)},this.doFinal=function(){return this.mac.finalize().toString(f.enc.Hex)},this.doFinalString=function(t){return this.updateString(t),this.doFinal()},this.doFinalHex=function(t){return this.updateHex(t),this.doFinal()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(t){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(t){if("string"==typeof t){var e=t;return t.length%2!=1&&t.match(/^[0-9A-Fa-f]+$/)||(e=St(t)),void(this.pass=f.enc.Hex.parse(e))}if("object"!=typeof t)throw"KJUR.crypto.Mac unsupported password type: "+t;if(e=null,void 0!==t.hex){if(t.hex.length%2!=0||!t.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+t.hex;e=t.hex}if(void 0!==t.utf8&&(e=ft(t.utf8)),void 0!==t.rstr&&(e=St(t.rstr)),void 0!==t.b64&&(e=S(t.b64)),void 0!==t.b64u&&(e=gt(t.b64u)),null==e)throw"KJUR.crypto.Mac unsupported password type: "+t;this.pass=f.enc.Hex.parse(e)},void 0!==t&&(void 0!==t.pass&&this.setPassword(t.pass),void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=nt.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},nt.crypto.Signature=function(t){var e=null;if(this._setAlgNames=function(){var t=this.algName.match(/^(.+)with(.+)$/);t&&(this.mdAlgName=t[1].toLowerCase(),this.pubkeyAlgName=t[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(t,e){for(var r="",i=e/4-t.length,s=0;s<i;s++)r+="0";return r+t},this.setAlgAndProvider=function(t,e){if(this._setAlgNames(),"cryptojs/jsrsa"!=e)throw new Error("provider not supported: "+e);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new nt.crypto.MessageDigest({alg:this.mdAlgName})}catch(t){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+t)}this.init=function(t,e){var r=null;try{r=void 0===e?Mt.getKey(t):Mt.getKey(t,e)}catch(t){throw"init failed:"+t}if(!0===r.isPrivate)this.prvKey=r,this.state="SIGN";else{if(!0!==r.isPublic)throw"init failed.:"+r;this.pubKey=r,this.state="VERIFY"}},this.updateString=function(t){this.md.updateString(t)},this.updateHex=function(t){this.md.updateHex(t)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==nt.crypto.ECDSA&&(this.prvKey=new nt.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof tt&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof tt&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof nt.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof nt.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(t){return this.updateString(t),this.sign()},this.signHex=function(t){return this.updateHex(t),this.sign()},this.verify=function(t){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==nt.crypto.ECDSA&&(this.pubKey=new nt.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof tt&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,t,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof tt&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==nt.crypto.ECDSA&&this.pubKey instanceof nt.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==nt.crypto.DSA&&this.pubKey instanceof nt.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(t,e){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(t){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(t){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(t){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(t){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=t,void 0!==t&&(void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov?this.provName=nt.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=t.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==t.psssaltlen&&(this.pssSaltLen=t.psssaltlen),void 0!==t.prvkeypem)){if(void 0!==t.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{e=Mt.getKey(t.prvkeypem),this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},nt.crypto.Cipher=function(t){},nt.crypto.Cipher.encrypt=function(t,e,r,i){if(null!=jt(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var s=e,n=t;null!=jt(i,"key")&&(s=i.key),null!=jt(i,"enc")&&(hEnc=i.enc);var o,a=f.enc.Hex.parse(s),h=f.enc.Hex.parse(n),c=f.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)o=f.TripleDES.encrypt(h,a,{iv:c});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);o=f.AES.encrypt(h,a,{iv:c})}return o+""}throw new Error("Cipher.encrypt: unsupported key or algorithm")},nt.crypto.Cipher.decrypt=function(t,e,r,i){if(null!=jt(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var s=e,n=t;null!=jt(i,"key")&&(s=i.key),null!=jt(i,"enc")&&(n=i.enc);var o,a=f.enc.Hex.parse(s),h=f.enc.Hex.parse(n),c=f.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)o=f.TripleDES.decrypt({ciphertext:h},a,{iv:c});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);o=f.AES.decrypt({ciphertext:h},a,{iv:c})}return f.enc.Hex.stringify(o)}throw new Error("Cipher.decrypt: unsupported key or algorithm")},nt.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040022":"secp384r1","2b81040023":"secp521r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}},void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.ECDSA=function(t){var e=Error,r=E,i=rt,s=nt.crypto.ECDSA,n=nt.crypto.ECParameterDB,o=s.getName,a=ht,h=a.getVbyListEx,c=a.isASN1HEX,u=new Q;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(t){return new r(t.bitLength(),u).mod(t.subtract(r.ONE)).add(r.ONE)},this.setNamedCurve=function(t){this.ecparams=n.getByName(t),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=t},this.setPrivateKeyHex=function(t){this.isPrivate=!0,this.prvKeyHex=t},this.setPublicKeyHex=function(t){this.isPublic=!0,this.pubKeyHex=t},this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if("04"!==t.substr(0,2))throw"this method supports uncompressed format(04) only";var e=this.ecparams.keycharlen;if(t.length!==2+2*e)throw"malformed public key hex length";var r={};return r.x=t.substr(2,e),r.y=t.substr(2+e),r},this.getShortNISTPCurveName=function(){var t=this.curveName;return"secp256r1"===t||"NIST P-256"===t||"P-256"===t||"prime256v1"===t?"P-256":"secp384r1"===t||"NIST P-384"===t||"P-384"===t?"P-384":"secp521r1"===t||"NIST P-521"===t||"P-521"===t?"P-521":null},this.generateKeyPairHex=function(){var t=this.ecparams.n,e=this.getBigRandom(t),r=this.ecparams.keycharlen,i=("0000000000"+e.toString(16)).slice(-r);return this.setPrivateKeyHex(i),{ecprvhex:i,ecpubhex:this.generatePublicKeyHex()}},this.generatePublicKeyHex=function(){var t=new r(this.prvKeyHex,16),e=this.ecparams.G.multiply(t),i=e.getX().toBigInteger(),s=e.getY().toBigInteger(),n=this.ecparams.keycharlen,o="04"+("0000000000"+i.toString(16)).slice(-n)+("0000000000"+s.toString(16)).slice(-n);return this.setPublicKeyHex(o),o},this.signWithMessageHash=function(t){return this.signHex(t,this.prvKeyHex)},this.signHex=function(t,e){var i=new r(e,16),n=this.ecparams.n,o=new r(t.substring(0,this.ecparams.keycharlen),16);do{var a=this.getBigRandom(n),h=this.ecparams.G.multiply(a).getX().toBigInteger().mod(n)}while(h.compareTo(r.ZERO)<=0);var c=a.modInverse(n).multiply(o.add(i.multiply(h))).mod(n);return s.biRSSigToASN1Sig(h,c)},this.sign=function(t,e){var i=e,s=this.ecparams.n,n=r.fromByteArrayUnsigned(t);do{var o=this.getBigRandom(s),a=this.ecparams.G.multiply(o).getX().toBigInteger().mod(s)}while(a.compareTo(E.ZERO)<=0);var h=o.modInverse(s).multiply(n.add(i.multiply(a))).mod(s);return this.serializeSig(a,h)},this.verifyWithMessageHash=function(t,e){return this.verifyHex(t,e,this.pubKeyHex)},this.verifyHex=function(t,e,n){try{var o,a,h=s.parseSigHex(e);o=h.r,a=h.s;var c=i.decodeFromHex(this.ecparams.curve,n),u=new r(t.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(u,o,a,c)}catch(t){return!1}},this.verify=function(t,e,s){var n,o,a;if(Bitcoin.Util.isArray(e)){var h=this.parseSig(e);n=h.r,o=h.s}else{if("object"!=typeof e||!e.r||!e.s)throw"Invalid value for signature";n=e.r,o=e.s}if(s instanceof rt)a=s;else{if(!Bitcoin.Util.isArray(s))throw"Invalid format for pubkey value, must be byte array or ECPointFp";a=i.decodeFrom(this.ecparams.curve,s)}var c=r.fromByteArrayUnsigned(t);return this.verifyRaw(c,n,o,a)},this.verifyRaw=function(t,e,i,s){var n=this.ecparams.n,o=this.ecparams.G;if(e.compareTo(r.ONE)<0||e.compareTo(n)>=0)return!1;if(i.compareTo(r.ONE)<0||i.compareTo(n)>=0)return!1;var a=i.modInverse(n),h=t.multiply(a).mod(n),c=e.multiply(a).mod(n);return o.multiply(h).add(s.multiply(c)).getX().toBigInteger().mod(n).equals(e)},this.serializeSig=function(t,e){var r=t.toByteArraySigned(),i=e.toByteArraySigned(),s=[];return s.push(2),s.push(r.length),(s=s.concat(r)).push(2),s.push(i.length),(s=s.concat(i)).unshift(s.length),s.unshift(48),s},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var s=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:r.fromByteArrayUnsigned(i),s:r.fromByteArrayUnsigned(s)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:r.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:r.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){if(!1===c(t))throw new Error("not ASN.1 hex string");var e,r,i;try{e=h(t,0,["[0]",0],"06"),r=h(t,0,[1],"04");try{i=h(t,0,["[1]",0],"03")}catch(t){}}catch(t){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=o(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){if(!1===c(t))throw new e("not ASN.1 hex string");var r,i,s;try{h(t,0,[1,0],"06"),r=h(t,0,[1,1],"06"),i=h(t,0,[2,0,1],"04");try{s=h(t,0,[2,0,"[1]",0],"03")}catch(t){}}catch(t){throw new e("malformed PKCS#8 plain ECC private key")}if(this.curveName=o(r),void 0===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(s),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===c(t))throw new e("not ASN.1 hex string");var r,i;try{h(t,0,[0,0],"06"),r=h(t,0,[0,1],"06"),i=h(t,0,[1],"03")}catch(t){throw new e("malformed PKCS#8 ECC public key")}if(this.curveName=o(r),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,r){if(!1===c(t))throw new e("not ASN.1 hex string");var i,s;try{i=h(t,0,[0,5,0,1],"06"),s=h(t,0,[0,5,1],"03")}catch(t){throw new e("malformed X.509 certificate ECC public key")}if(this.curveName=o(i),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(s)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},nt.crypto.ECDSA.parseSigHex=function(t){var e=nt.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new E(e.r,16),s:new E(e.s,16)}},nt.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=ht,r=e.getChildIdx,i=e.getV;if(e.checkStrictDER(t,0),"30"!=t.substr(0,2))throw new Error("signature is not a ASN.1 sequence");var s=r(t,0);if(2!=s.length)throw new Error("signature shall have two elements");var n=s[0],o=s[1];if("02"!=t.substr(n,2))throw new Error("1st item not ASN.1 integer");if("02"!=t.substr(o,2))throw new Error("2nd item not ASN.1 integer");return{r:i(t,n),s:i(t,o)}},nt.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=nt.crypto.ECDSA.parseSigHexInHexRS(t),r=e.r,i=e.s;if(r.length>=130&&r.length<=134){if(r.length%2!=0)throw Error("unknown ECDSA sig r length error");if(i.length%2!=0)throw Error("unknown ECDSA sig s length error");"00"==r.substr(0,2)&&(r=r.substr(2)),"00"==i.substr(0,2)&&(i=i.substr(2));var s=Math.max(r.length,i.length);return(r=("000000"+r).slice(-s))+("000000"+i).slice(-s)}if("00"==r.substr(0,2)&&r.length%32==2&&(r=r.substr(2)),"00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),r.length%32==30&&(r="00"+r),i.length%32==30&&(i="00"+i),r.length%32!=0)throw Error("unknown ECDSA sig r length error");if(i.length%32!=0)throw Error("unknown ECDSA sig s length error");return r+i},nt.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length%4!=0)throw Error("unknown ECDSA concatinated r-s sig length error");var e=t.substr(0,t.length/2),r=t.substr(t.length/2);return nt.crypto.ECDSA.hexRSSigToASN1Sig(e,r)},nt.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var r=new E(t,16),i=new E(e,16);return nt.crypto.ECDSA.biRSSigToASN1Sig(r,i)},nt.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var r=nt.asn1,i=new r.DERInteger({bigint:t}),s=new r.DERInteger({bigint:e});return new r.DERSequence({array:[i,s]}).tohex()},nt.crypto.ECDSA.getName=function(t){return"2b8104001f"===t?"secp192k1":"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040021"===t?"secp224r1":"2b81040022"===t?"secp384r1":"2b81040023"===t?"secp521r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp224r1|NIST P-224|P-224|".indexOf(t)?"secp224r1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":-1!=="|secp521r1|NIST P-521|P-521|".indexOf(t)?"secp521r1":null},void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.ECParameterDB=new function(){var t={},e={};function r(t){return new E(t,16)}this.getByName=function(r){var i=r;if(void 0!==e[i]&&(i=e[r]),void 0!==t[i])return t[i];throw"unregistered EC curve name: "+i},this.regist=function(i,s,n,o,a,h,c,u,l,d,p,g){t[i]={};var f=r(n),m=r(o),y=r(a),v=r(h),S=r(c),E=new it(f,m,y),x=E.decodePointHex("04"+u+l);t[i].name=i,t[i].keylen=s,t[i].keycharlen=2*Math.ceil(s/8),t[i].curve=E,t[i].G=x,t[i].n=v,t[i].h=S,t[i].oid=p,t[i].info=g;for(var w=0;w<d.length;w++)e[d[w]]=i}},nt.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),nt.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),nt.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),nt.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),nt.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),nt.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),nt.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),nt.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),nt.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),nt.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]),void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.DSA=function(){var t=ht,e=(t.getVbyList,t.getVbyListEx),r=t.isASN1HEX,i=E,s=E.ONE;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(t,e,r,i,s){this.isPrivate=!0,this.p=t,this.q=e,this.g=r,this.y=i,this.x=s},this.setPrivateHex=function(t,e,r,i,s){var n,o,a,h,c;n=new E(t,16),o=new E(e,16),a=new E(r,16),h="string"==typeof i&&i.length>1?new E(i,16):null,c=new E(s,16),this.setPrivate(n,o,a,h,c)},this.setPublic=function(t,e,r,i){!function(t,e,r,i){if(null==t||null==e||null==r||null==i)throw new Error("invalid DSA public key");if(s.compareTo(e)>=0||e.compareTo(t)>=0)throw new Error("invalid DSA public key");if(s.compareTo(r)>=0||r.compareTo(t)>=0)throw new Error("invalid DSA public key");if(s.compareTo(i)>=0||i.compareTo(t)>=0)throw new Error("invalid DSA public key");if(0!=r.modPow(e,t).compareTo(s))throw new Error("invalid DSA public key")}(t,e,r,i),this.isPublic=!0,this.p=t,this.q=e,this.g=r,this.y=i,this.x=null},this.setPublicHex=function(t,e,r,i){var s,n,o,a;s=new E(t,16),n=new E(e,16),o=new E(r,16),a=new E(i,16),this.setPublic(s,n,o,a)},this.signWithMessageHash=function(t){var e,r,i,s=this.p,n=this.q,o=this.g,a=(this.y,this.x),h=new E(t.substr(0,n.bitLength()/4),16);do{e=nt.crypto.Util.getRandomBigIntegerMinToMax(E.ONE.add(E.ONE),n.subtract(E.ONE)),r=o.modPow(e,s).mod(n),i=e.modInverse(n).multiply(h.add(a.multiply(r))).mod(n)}while(0==r.compareTo(E.ZERO)||0==i.compareTo(E.ZERO));return nt.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:r}},{int:{bigint:i}}]})},this.verifyWithMessageHash=function(t,e){var r=this.p,i=this.q,s=this.g,n=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],c=new E(t.substr(0,i.bitLength()/4),16);if(E.ZERO.compareTo(a)>0||a.compareTo(i)>0)throw"invalid DSA signature";if(E.ZERO.compareTo(h)>=0||h.compareTo(i)>0)throw"invalid DSA signature";var u=h.modInverse(i),l=c.multiply(u).mod(i),d=a.multiply(u).mod(i);return 0==s.modPow(l,r).multiply(n.modPow(d,r)).mod(r).mod(i).compareTo(a)},this.parseASN1Signature=function(t){try{return[new i(e(t,0,[0],"02"),16),new i(e(t,0,[1],"02"),16)]}catch(t){throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(t){var i,s,n,o,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1],"02"),s=e(t,0,[2],"02"),n=e(t,0,[3],"02"),o=e(t,0,[4],"02"),a=e(t,0,[5],"02")}catch(t){throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(i,s,n,o,a)},this.readPKCS8PrvKeyHex=function(t){var i,s,n,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1,1,0],"02"),s=e(t,0,[1,1,1],"02"),n=e(t,0,[1,1,2],"02"),o=e(t,0,[2,0],"02")}catch(t){throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(i,s,n,null,o)},this.readPKCS8PubKeyHex=function(t){var i,s,n,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[0,1,0],"02"),s=e(t,0,[0,1,1],"02"),n=e(t,0,[0,1,2],"02"),o=e(t,0,[1,0],"02")}catch(t){throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(i,s,n,o)},this.readCertPubKeyHex=function(t,i){var s,n,o,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{s=e(t,0,[0,5,0,1,0],"02"),n=e(t,0,[0,5,0,1,1],"02"),o=e(t,0,[0,5,0,1,2],"02"),a=e(t,0,[0,5,1,0],"02")}catch(t){throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(s,n,o,a)}};var Mt=function(){var t=function(t,r,i){return e(f.AES,t,r,i)},e=function(t,e,r,i){var s=f.enc.Hex.parse(e),n=f.enc.Hex.parse(r),o=f.enc.Hex.parse(i),a={};a.key=n,a.iv=o,a.ciphertext=s;var h=t.decrypt(a,n,{iv:o});return f.enc.Hex.stringify(h)},r=function(t,e,r){return i(f.AES,t,e,r)},i=function(t,e,r,i){var s=f.enc.Hex.parse(e),n=f.enc.Hex.parse(r),o=f.enc.Hex.parse(i),a=t.encrypt(s,n,{iv:o}),h=f.enc.Hex.parse(a.toString());return f.enc.Base64.stringify(h)},s={"AES-256-CBC":{proc:t,eproc:r,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:r,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:r,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,r,i){return e(f.TripleDES,t,r,i)},eproc:function(t,e,r){return i(f.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,r,i){return e(f.DES,t,r,i)},eproc:function(t,e,r){return i(f.DES,t,e,r)},keylen:8,ivlen:8}},n=function(t){var e={},r=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));r&&(e.cipher=r[1],e.ivsalt=r[2]);var i=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));i&&(e.type=i[1]);var s=-1,n=0;-1!=t.indexOf("\r\n\r\n")&&(s=t.indexOf("\r\n\r\n"),n=2),-1!=t.indexOf("\n\n")&&(s=t.indexOf("\n\n"),n=1);var o=t.indexOf("-----END");if(-1!=s&&-1!=o){var a=t.substring(s+2*n,o-n);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,r){for(var i=r.substring(0,16),n=f.enc.Hex.parse(i),o=f.enc.Utf8.parse(e),a=s[t].keylen+s[t].ivlen,h="",c=null;;){var u=f.algo.MD5.create();if(null!=c&&u.update(c),u.update(o),u.update(n),c=u.finalize(),(h+=f.enc.Hex.stringify(c)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*s[t].keylen),l.ivhex=h.substr(2*s[t].keylen,2*s[t].ivlen),l},a=function(t,e,r,i){var n=f.enc.Base64.parse(t),o=f.enc.Hex.stringify(n);return(0,s[e].proc)(o,r,i)};return{version:"1.0.0",parsePKCS5PEM:function(t){return n(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return o(t,e,r)},decryptKeyB64:function(t,e,r,i){return a(t,e,r,i)},getDecryptedKeyHex:function(t,e){var r=n(t),i=(r.type,r.cipher),s=r.ivsalt,h=r.data,c=o(i,e,s).keyhex;return a(h,i,c,s)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,i,n){var a="";if(void 0!==i&&null!=i||(i="AES-256-CBC"),void 0===s[i])throw new Error("KEYUTIL unsupported algorithm: "+i);if(void 0===n||null==n){var h=function(t){var e=f.lib.WordArray.random(t);return f.enc.Hex.stringify(e)}(s[i].ivlen);n=h.toUpperCase()}var c=function(t,e,r,i){return(0,s[e].eproc)(t,r,i)}(e,i,o(i,r,n).keyhex,n);return a="-----BEGIN "+t+" PRIVATE KEY-----\r\n",a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+i+","+n+"\r\n",a+="\r\n",(a+=c.replace(/(.{64})/g,"$1\r\n"))+"\r\n-----END "+t+" PRIVATE KEY-----\r\n"},getEncryptedPKCS8PEM:function(t,e,r){return Et(this.getEncryptedPKCS8Hex(t,e,r),"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(t,e,r){var i;(i=null==r||null==r?{}:JSON.parse(JSON.stringify(r))).plain=t,this.initPBES2Param(i),this.encryptPBES2Param(i,e);var s=this.generatePBES2ASN1Param(i);return nt.asn1.ASN1Util.newObject(s).tohex()},initPBES2Param:function(t){var e;null==jt(t,"encalg")&&(t.encalg="aes256-CBC"),null==jt(t,"iter")&&(t.iter=2048),null==jt(t,"prf")&&(t.prf="hmacWithSHA256"),null==jt(t,"salt")&&(t.salt=f.enc.Hex.stringify(f.lib.WordArray.random(8))),null==jt(t,"enciv")&&("des-EDE3-CBC"==t.encalg&&(e=8),"aes128-CBC"==t.encalg&&(e=16),"aes256-CBC"==t.encalg&&(e=16),t.enciv=f.enc.Hex.stringify(f.lib.WordArray.random(e)))},encryptPBES2Param:function(t,e){var r=Mt.getDKFromPBES2Param(t,e);try{var i=nt.crypto.Cipher.encrypt(t.plain,r,t.encalg,{iv:t.enciv})}catch(e){throw new Error("encrypt error: "+t.plain+" "+r+" "+t.encalg+" "+t.enciv)}t.enc=i},generatePBES2ASN1Param:function(t){var e={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:t.salt}},{int:{hex:Bt(t.iter)}}]}]},{seq:[{oid:t.encalg},{octstr:{hex:t.enciv}}]}]}]},{octstr:{hex:t.enc}}]};return"hmacWithSHA1"!=t.prf&&e.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:t.prf},{null:""}]}),e},parseHexOfEncryptedPKCS8:function(t){var e=ht,r=e.getChildIdx,i=e.getV,s={},n=r(t,0);if(2!=n.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+n.length);s.ciphertext=i(t,n[1]);var o=r(t,n[0]);if(2!=o.length)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+o.length);if("2a864886f70d01050d"!=i(t,o[0]))throw new Error("this only supports pkcs5PBES2");var a=r(t,o[1]);if(2!=o.length)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+a.length);var h=r(t,a[1]);if(2!=h.length)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length);if("2a864886f70d0307"!=i(t,h[0]))throw"this only supports TripleDES";s.encryptionSchemeAlg="TripleDES",s.encryptionSchemeIV=i(t,h[1]);var c=r(t,a[0]);if(2!=c.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+c.length);if("2a864886f70d01050c"!=i(t,c[0]))throw new Error("this only supports pkcs5PBKDF2");var u=r(t,c[1]);if(u.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+u.length);s.pbkdf2Salt=i(t,u[0]);var l=i(t,u[1]);try{s.pbkdf2Iter=parseInt(l,16)}catch(t){throw new Error("malformed format pbkdf2Iter: "+l)}return s},getPBKDF2KeyHexFromParam:function(t,e){var r=f.enc.Hex.parse(t.pbkdf2Salt),i=t.pbkdf2Iter,s=f.PBKDF2(e,r,{keySize:6,iterations:i});return f.enc.Hex.stringify(s)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=xt(t,"ENCRYPTED PRIVATE KEY"),i=this.parseHexOfEncryptedPKCS8(r),s=Mt.getPBKDF2KeyHexFromParam(i,e),n={};n.ciphertext=f.enc.Hex.parse(i.ciphertext);var o=f.enc.Hex.parse(s),a=f.enc.Hex.parse(i.encryptionSchemeIV),h=f.TripleDES.decrypt(n,o,{iv:a});return f.enc.Hex.stringify(h)},parsePBES2:function(t){var e=ht.parse(t);if("pkcs5PBES2"!=jt(e,"seq.0.seq.0.oid")||"pkcs5PBKDF2"!=jt(e,"seq.0.seq.1.seq.0.seq.0.oid"))throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var r=jt(e,"seq.0.seq.1.seq.0.seq.1.seq");if(null==r)throw new Error("PBKDF2 parameter not found");var i=jt(r,"0.octstr.hex"),s=jt(r,"1.int.hex"),n=jt(r,"2.seq.0.oid","hmacWithSHA1"),o=-1;try{o=parseInt(s,16)}catch(t){throw new Error("iter not proper value")}var a=jt(e,"seq.0.seq.1.seq.1.seq.0.oid"),h=jt(e,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),c=jt(e,"seq.1.octstr.hex");if(null==a||null==h||null==c)throw new Error("encalg, enciv or enc is undefined");return{salt:i,iter:o,prf:n,encalg:a,enciv:h,enc:c}},getDKFromPBES2Param:function(t,e){var r={hmacWithSHA1:f.algo.SHA1,hmacWithSHA224:f.algo.SHA224,hmacWithSHA256:f.algo.SHA256,hmacWithSHA384:f.algo.SHA384,hmacWithSHA512:f.algo.SHA512}[t.prf];if(null==r)throw new Error("unsupported prf");var i={"des-EDE3-CBC":6,"aes128-CBC":4,"aes256-CBC":8}[t.encalg];if(null==i)throw new Error("unsupported encalg");var s=f.enc.Hex.parse(t.salt),n=t.iter;try{var o=f.PBKDF2(e,s,{keySize:i,iterations:n,hasher:r});return f.enc.Hex.stringify(o)}catch(r){throw new Error("PBKDF2 error: "+r+" "+JSON.stringify(t)+" "+e)}},getPlainHexFromEncryptedPKCS8PEM:function(t,e){if(-1==t.indexOf("BEGIN ENCRYPTED PRIVATE KEY"))throw new Error("not Encrypted PKCS#8 PEM string");var r,i=xt(t);try{r=Mt.parsePBES2(i)}catch(t){throw new Error("malformed PBES2 format: "+t.message)}var s=Mt.getDKFromPBES2Param(r,e);return nt.crypto.Cipher.decrypt(r.enc,s,r.encalg,{iv:r.enciv})},getKeyFromEncryptedPKCS8PEM:function(t,e){var r=this.getPlainHexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(t){var e=ht,r=e.getChildIdx,i=e.getV,s={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var n=r(t,0);if(n.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(n[1],2))throw new Error("malformed PKCS8 private key(code:003)");var o=r(t,n[1]);if(2!=o.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(o[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(s.algoid=i(t,o[0]),"06"==t.substr(o[1],2)&&(s.algparam=i(t,o[1])),"04"!=t.substr(n[2],2))throw new Error("malformed PKCS8 private key(code:006)");return s.keyidx=e.getVidx(t,n[2]),s},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=xt(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,r=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==r.algoid)e=new tt;else if("2a8648ce380401"==r.algoid)e=new nt.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw new Error("unsupported private key algorithm");e=new nt.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=ht.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new tt;else if("2a8648ce380401"===r)e=new nt.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw new Error("unsupported PKCS#8 public key hex");e=new nt.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=ht,r=e.getChildIdx,i=e.getV,s={};if("30"!=t.substr(0,2))throw new Error("malformed RSA key(code:001)");var n=r(t,0);if(2!=n.length)throw new Error("malformed RSA key(code:002)");if("02"!=t.substr(n[0],2))throw new Error("malformed RSA key(code:003)");if(s.n=i(t,n[0]),"02"!=t.substr(n[1],2))throw new Error("malformed RSA key(code:004)");return s.e=i(t,n[1]),s},parsePublicPKCS8Hex:function(t){var e=ht,r=e.getChildIdx,i=e.getV,s={algparam:null},n=r(t,0);if(2!=n.length)throw new Error("outer DERSequence shall have 2 elements: "+n.length);var o=n[0];if("30"!=t.substr(o,2))throw new Error("malformed PKCS8 public key(code:001)");var a=r(t,o);if(2!=a.length)throw new Error("malformed PKCS8 public key(code:002)");if("06"!=t.substr(a[0],2))throw new Error("malformed PKCS8 public key(code:003)");if(s.algoid=i(t,a[0]),"06"==t.substr(a[1],2)?s.algparam=i(t,a[1]):"30"==t.substr(a[1],2)&&(s.algparam={},s.algparam.p=e.getVbyList(t,a[1],[0],"02"),s.algparam.q=e.getVbyList(t,a[1],[1],"02"),s.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(n[1],2))throw new Error("malformed PKCS8 public key(code:004)");return s.key=i(t,n[1]).substr(2),s}}}();function Kt(t,e){for(var r="",i=e/4-t.length,s=0;s<i;s++)r+="0";return r+t}function qt(t,e,r){for(var i="",s=0;i.length<e;)i+=vt(r(St(t+String.fromCharCode.apply(String,[(4278190080&s)>>24,(16711680&s)>>16,(65280&s)>>8,255&s])))),s+=1;return i}function Gt(t){for(var e in nt.crypto.Util.DIGESTINFOHEAD){var r=nt.crypto.Util.DIGESTINFOHEAD[e],i=r.length;if(t.substring(0,i)==r)return[e,t.substring(i)]}return[]}function $t(t){var e,r=ht,i=r.getChildIdx,s=r.getV,n=(r.dump,r.parse),o=r.getTLV,a=r.getVbyList,h=r.getVbyListEx,c=r.getTLVbyList,u=r.getTLVbyListEx,l=r.getIdxbyList,d=r.getIdxbyListEx,p=r.getVidx,g=r.getInt,f=r.oidname,m=r.hextooidstr,y=xt,v=Error;try{e=nt.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(t){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null===this.hex||0!==this.version)return this.version;var t=c(this.hex,0,[0,0]);if("a0"==t.substr(0,2)){var e=c(t,0,[0]),r=g(e,0);if(r<0||2<r)throw new Error("malformed version field");return this.version=r+1,this.version}return this.version=1,this.foffset=-1,1},this.getSerialNumberHex=function(){return h(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var t=u(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(t)},this.getAlgorithmIdentifierName=function(t){for(var r in e)if(t===e[r])return r;return f(h(t,0,[0],"06"))},this.getIssuer=function(t,e){return this.getX500Name(this.getIssuerHex(),t,e)},this.getIssuerHex=function(){return c(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(t,e){return this.getX500Name(this.getSubjectHex(),t,e)},this.getSubjectHex=function(){return c(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var t=a(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),decodeURIComponent(t)},this.getNotAfter=function(){var t=a(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),decodeURIComponent(t)},this.getPublicKeyHex=function(){return this.getSPKI()},this.getSPKI=function(){return c(this.hex,0,[0,6+this.foffset],"30")},this.getSPKIValue=function(){var t=this.getSPKI();return null==t?null:a(t,0,[1],"03",!0)},this.getPublicKeyIdx=function(){return l(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return l(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Mt.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=c(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(t)},this.getSignatureValueHex=function(){return a(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmField(),r=this.getSignatureValueHex(),i=c(this.hex,0,[0],"30"),s=new nt.crypto.Signature({alg:e});return s.init(t),s.updateHex(i),s.verify(r)},this.parseExt=function(t){var e,n,o;if(void 0===t){if(o=this.hex,3!==this.version)return-1;e=l(o,0,[0,7,0],"30"),n=i(o,e)}else{o=xt(t);var h=l(o,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=s(o,h))return void(this.aExtInfo=new Array);e=l(o,0,[0,3,0,1,0],"30"),n=i(o,e),this.hex=o}this.aExtInfo=new Array;for(var c=0;c<n.length;c++){var u={critical:!1},d=0;3===i(o,n[c]).length&&(u.critical=!0,d=1),u.oid=r.hextooidstr(a(o,n[c],[0],"06"));var g=l(o,n[c],[1+d]);u.vidx=p(o,g),this.aExtInfo.push(u)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(t.match(/^[0-9.]+$/)||(r=nt.asn1.x509.OID.name2oid(t)),""!==r)for(var i=0;i<e.length;i++)if(e[i].oid===r)return e[i]},this.getCriticalExtV=function(t,e,r){if(null!=e)return[e,r];var i=this.getExtInfo(t);return null==i?[null,null]:[o(this.hex,i.vidx),i.critical]},this.getExtBasicConstraints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("basicConstraints");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var i={extname:"basicConstraints"};if(e&&(i.critical=!0),"3000"===t)return i;if("30030101ff"===t)return i.cA=!0,i;if("30060101ff02"===t.substr(0,12)){var n=s(t,10),a=parseInt(n,16);return i.cA=!0,i.pathLen=a,i}throw new Error("hExtV parse error: "+t)},this.getExtNameConstraints=function(t,e){var r=this.getCriticalExtV("nameConstraints",t,e);if(t=r[0],e=r[1],null!=t){var s={extname:"nameConstraints"};e&&(s.critical=!0);for(var n=i(t,0),a=0;a<n.length;a++){for(var h=[],c=i(t,n[a]),u=0;u<c.length;u++){var l=o(t,c[u]),d=this.getGeneralSubtree(l);h.push(d)}var p=t.substr(n[a],2);"a0"==p?s.permit=h:"a1"==p&&(s.exclude=h)}return s}},this.getGeneralSubtree=function(t){var e=i(t,0),r=e.length;if(r<1||2<r)throw new Error("wrong num elements");for(var n=this.getGeneralName(o(t,e[0])),a=1;a<r;a++){var h=t.substr(e[a],2),c=s(t,e[a]),u=parseInt(c,16);"80"==h&&(n.min=u),"81"==h&&(n.max=u)}return n},this.getExtKeyUsage=function(t,e){var r=this.getCriticalExtV("keyUsage",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"keyUsage"};return e&&(i.critical=!0),i.names=this.getExtKeyUsageString(t).split(","),i}},this.getExtKeyUsageBin=function(t){if(void 0===t){var e=this.getExtInfo("keyUsage");if(void 0===e)return"";t=o(this.hex,e.vidx)}if(8!=t.length&&10!=t.length)throw new Error("malformed key usage value: "+t);var r="000000000000000"+parseInt(t.substr(6),16).toString(2);return 8==t.length&&(r=r.slice(-8)),10==t.length&&(r=r.slice(-16)),""==(r=r.replace(/0+$/,""))&&(r="0"),r},this.getExtKeyUsageString=function(t){for(var e=this.getExtKeyUsageBin(t),r=new Array,i=0;i<e.length;i++)"1"==e.substr(i,1)&&r.push($t.KEYUSAGE_NAME[i]);return r.join(",")},this.getExtSubjectKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectKeyIdentifier");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var i={extname:"subjectKeyIdentifier"};e&&(i.critical=!0);var n=s(t,0);return i.kid={hex:n},i},this.getExtAuthorityKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityKeyIdentifier");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var n={extname:"authorityKeyIdentifier"};e&&(n.critical=!0);for(var a=i(t,0),h=0;h<a.length;h++){var c=t.substr(a[h],2);if("80"===c&&(n.kid={hex:s(t,a[h])}),"a1"===c){var u=o(t,a[h]),l=this.getGeneralNames(u);n.issuer=l[0].dn}"82"===c&&(n.sn={hex:s(t,a[h])})}return n},this.getExtExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("extKeyUsage");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var n={extname:"extKeyUsage",array:[]};e&&(n.critical=!0);for(var a=i(t,0),h=0;h<a.length;h++)n.array.push(f(s(t,a[h])));return n},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var e=new Array,r=o(this.hex,t.vidx);if(""===r)return e;for(var n=i(r,0),a=0;a<n.length;a++)e.push(f(s(r,n[a])));return e},this.getExtSubjectAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectAltName");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var i={extname:"subjectAltName",array:[]};return e&&(i.critical=!0),i.array=this.getGeneralNames(t),i},this.getExtIssuerAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("issuerAltName");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var i={extname:"issuerAltName",array:[]};return e&&(i.critical=!0),i.array=this.getGeneralNames(t),i},this.getGeneralNames=function(t){for(var e=i(t,0),r=[],s=0;s<e.length;s++){var n=this.getGeneralName(o(t,e[s]));void 0!==n&&r.push(n)}return r},this.getGeneralName=function(t){var e=t.substr(0,2),r=s(t,0),i=vt(r);return"81"==e?{rfc822:i}:"82"==e?{dns:i}:"86"==e?{uri:i}:"87"==e?{ip:It(r)}:"a4"==e?{dn:this.getX500Name(r)}:"a0"==e?{other:this.getOtherName(t)}:void 0},this.getExtSubjectAltName2=function(){var t,e,r,n=this.getExtInfo("subjectAltName");if(void 0===n)return n;for(var a=new Array,h=o(this.hex,n.vidx),c=i(h,0),u=0;u<c.length;u++)r=h.substr(c[u],2),t=s(h,c[u]),"81"===r&&(e=mt(t),a.push(["MAIL",e])),"82"===r&&(e=mt(t),a.push(["DNS",e])),"84"===r&&(e=$t.hex2dn(t,0),a.push(["DN",e])),"86"===r&&(e=mt(t),a.push(["URI",e])),"87"===r&&(e=It(t),a.push(["IP",e]));return a},this.getExtCRLDistributionPoints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("cRLDistributionPoints");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var s={extname:"cRLDistributionPoints",array:[]};e&&(s.critical=!0);for(var n=i(t,0),a=0;a<n.length;a++){var h=o(t,n[a]);s.array.push(this.getDistributionPoint(h))}return s},this.getDistributionPoint=function(t){for(var e={},r=i(t,0),s=0;s<r.length;s++){var n=t.substr(r[s],2),a=o(t,r[s]);"a0"==n&&(e.dpname=this.getDistributionPointName(a))}return e},this.getDistributionPointName=function(t){for(var e={},r=i(t,0),s=0;s<r.length;s++){var n=t.substr(r[s],2),a=o(t,r[s]);"a0"==n&&(e.full=this.getGeneralNames(a))}return e},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtCRLDistributionPoints();if(null==t)return t;for(var e=t.array,r=[],i=0;i<e.length;i++)try{null!=e[i].dpname.full[0].uri&&r.push(e[i].dpname.full[0].uri)}catch(t){}return r},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var e={ocsp:[],caissuer:[]},r=i(this.hex,t.vidx),s=0;s<r.length;s++){var n=a(this.hex,r[s],[0],"06"),o=a(this.hex,r[s],[1],"86");"2b06010505073001"===n&&e.ocsp.push(mt(o)),"2b06010505073002"===n&&e.caissuer.push(mt(o))}return e},this.getExtAuthorityInfoAccess=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityInfoAccess");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var s={extname:"authorityInfoAccess",array:[]};e&&(s.critical=!0);for(var n=i(t,0),c=0;c<n.length;c++){var u=h(t,n[c],[0],"06"),l=mt(a(t,n[c],[1],"86"));if("2b06010505073001"==u)s.array.push({ocsp:l});else{if("2b06010505073002"!=u)throw new Error("unknown method: "+u);s.array.push({caissuer:l})}}return s},this.getExtCertificatePolicies=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("certificatePolicies");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var s={extname:"certificatePolicies",array:[]};e&&(s.critical=!0);for(var n=i(t,0),a=0;a<n.length;a++){var h=o(t,n[a]),c=this.getPolicyInformation(h);s.array.push(c)}return s},this.getPolicyInformation=function(t){var e={},r=a(t,0,[0],"06");e.policyoid=f(r);var s=d(t,0,[1],"30");if(-1!=s){e.array=[];for(var n=i(t,s),h=0;h<n.length;h++){var c=o(t,n[h]),u=this.getPolicyQualifierInfo(c);e.array.push(u)}}return e},this.getOtherName=function(t){var e={},r=i(t,0),s=a(t,r[0],[],"06"),o=a(t,r[1],[]);return e.oid=f(s),e.value=n(o),e},this.getPolicyQualifierInfo=function(t){var e={},r=a(t,0,[0],"06");if("2b06010505070201"===r){var i=h(t,0,[1],"16");e.cps=vt(i)}else if("2b06010505070202"===r){var s=c(t,0,[1],"30");e.unotice=this.getUserNotice(s)}return e},this.getUserNotice=function(t){var e=null;try{return e=r.parse(t),this._asn1ToUnotice(e)}catch(t){return}},this._asn1ToUnotice=function(t){try{for(var e={},r=jt(t,"seq"),i=0;i<r.length;i++){var s=this._asn1ToNoticeRef(r[i]);null!=s&&(e.noticeref=s);var n=this.asn1ToDisplayText(r[i]);null!=n&&(e.exptext=n)}return Object.keys(e).length>0?e:void 0}catch(t){return}},this._asn1ToNoticeRef=function(t){try{for(var e={},r=jt(t,"seq"),i=0;i<r.length;i++){var s=this._asn1ToNoticeNum(r[i]);null!=s&&(e.noticenum=s);var n=this.asn1ToDisplayText(r[i]);null!=n&&(e.org=n)}return Object.keys(e).length>0?e:void 0}catch(t){return}},this._asn1ToNoticeNum=function(t){try{for(var e=jt(t,"seq"),r=[],i=0;i<e.length;i++){var s=e[i];r.push(parseInt(jt(s,"int.hex"),16))}return r}catch(t){return}},this.getDisplayText=function(t){var e={};return e.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[t.substr(0,2)],e.str=vt(s(t,0)),e},this.asn1ToDisplayText=function(t){return null!=t.utf8str?{type:"utf8",str:t.utf8str.str}:null!=t.ia5str?{type:"ia5",str:t.ia5str.str}:null!=t.visstr?{type:"vis",str:t.visstr.str}:null!=t.bmpstr?{type:"bmp",str:t.bmpstr.str}:null!=t.prnstr?{type:"prn",str:t.prnstr.str}:void 0},this.getExtPolicyMappings=function(t,e){var r=this.getCriticalExtV("policyMappings",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"policyMappings"};e&&(i.critical=!0);try{for(var s=n(t).seq,o=[],a=0;a<s.length;a++){var h=s[a].seq;o.push([h[0].oid,h[1].oid])}i.array=o}catch(t){throw new v("malformed policyMappings")}return i}},this.getExtPolicyConstraints=function(t,e){var r=this.getCriticalExtV("policyConstraints",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"policyConstraints"};e&&(i.critical=!0);var s=n(t);try{for(var o=s.seq,a=0;a<o.length;a++){var h=o[a].tag;0==h.explicit&&("80"==h.tag&&(i.reqexp=parseInt(h.hex,16)),"81"==h.tag&&(i.inhibit=parseInt(h.hex,16)))}}catch(t){return new v("malformed policyConstraints value")}return i}},this.getExtInhibitAnyPolicy=function(t,e){var r=this.getCriticalExtV("inhibitAnyPolicy",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"inhibitAnyPolicy"};e&&(i.critical=!0);var s=g(t,0);return-1==s?new v("wrong value"):(i.skip=s,i)}},this.getExtCRLNumber=function(t,e){var r={extname:"cRLNumber"};if(e&&(r.critical=!0),"02"==t.substr(0,2))return r.num={hex:s(t,0)},r;throw new v("hExtV parse error: "+t)},this.getExtCRLReason=function(t,e){var r={extname:"cRLReason"};if(e&&(r.critical=!0),"0a"==t.substr(0,2))return r.code=parseInt(s(t,0),16),r;throw new Error("hExtV parse error: "+t)},this.getExtOcspNonce=function(t,e){var r={extname:"ocspNonce"};e&&(r.critical=!0);var i=s(t,0);return r.hex=i,r},this.getExtOcspNoCheck=function(t,e){var r={extname:"ocspNoCheck"};return e&&(r.critical=!0),r},this.getExtAdobeTimeStamp=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("adobeTimeStamp");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var s={extname:"adobeTimeStamp"};e&&(s.critical=!0);var n=i(t,0);if(n.length>1){var a=o(t,n[1]),h=this.getGeneralName(a);null!=h.uri&&(s.uri=h.uri)}if(n.length>2){var c=o(t,n[2]);"0101ff"==c&&(s.reqauth=!0),"010100"==c&&(s.reqauth=!1)}return s},this.getExtSubjectDirectoryAttributes=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectDirectoryAttributes");if(void 0===r)return;t=o(this.hex,r.vidx),e=r.critical}var i={extname:"subjectDirectoryAttributes"};e&&(i.critical=!0);try{for(var s=n(t),a=[],h=0;h<s.seq.length;h++){var c=s.seq[h],u=jt(c,"seq.0.oid"),l=jt(c,"seq.1.set");if(null==u||null==l)throw"error";a.push({attr:u,array:l})}return i.array=a,i}catch(t){throw new Error("malformed subjectDirectoryAttributes extension value")}};var S=function(t){var e={};try{var r=t.seq[0].oid,i=nt.asn1.x509.OID.name2oid(r);e.type=nt.asn1.x509.OID.oid2atype(i);var s=t.seq[1];if(null!=s.utf8str)e.ds="utf8",e.value=s.utf8str.str;else if(null!=s.numstr)e.ds="num",e.value=s.numstr.str;else if(null!=s.telstr)e.ds="tel",e.value=s.telstr.str;else if(null!=s.prnstr)e.ds="prn",e.value=s.prnstr.str;else if(null!=s.ia5str)e.ds="ia5",e.value=s.ia5str.str;else if(null!=s.visstr)e.ds="vis",e.value=s.visstr.str;else{if(null==s.bmpstr)throw"error";e.ds="bmp",e.value=s.bmpstr.str}return e}catch(t){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}},E=function(t){try{return t.set.map(function(t){return S(t)})}catch(t){throw new Error("improper ASN.1 parsed RDN: "+t)}};this.getX500NameRule=function(t){for(var e=null,r=[],i=0;i<t.length;i++)for(var s=t[i],n=0;n<s.length;n++)r.push(s[n]);for(i=0;i<r.length;i++){var o=r[i],a=o.ds,h=o.value,c=o.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=c)return"mixed";if(nt.lang.String.isMail(h))continue;return"mixed"}if("C"==c){if("prn"==a)continue;return"mixed"}if(null==e)e=a;else if(e!==a)return"mixed"}return null==e?"prn":e},this.getAttrTypeAndValue=function(t){var e=n(t);return S(e)},this.getRDN=function(t){var e=n(t);return E(e)},this.getX500NameArray=function(t){return function(t){try{return t.seq.map(function(t){return E(t)})}catch(t){throw new Error("improper ASN.1 parsed X500Name: "+t)}}(n(t))},this.getX500Name=function(t,e,r){var i=this.getX500NameArray(t),s={str:this.dnarraytostr(i)};return s.array=i,1==r&&(s.hex=t),1==e&&(s.canon=this.c14nRDNArray(i)),s},this.readCertPEM=function(t){this.readCertHex(y(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{l(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getParam=function(t){var e={};return null==t&&(t={}),e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(t.dncanon,t.dnhex),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(t.dncanon,t.dnhex),e.sbjpubkey=Et(this.getPublicKeyHex(),"PUBLIC KEY"),null!=this.aExtInfo&&this.aExtInfo.length>0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),1==t.tbshex&&(e.tbshex=c(this.hex,0,[0])),1==t.nodnarray&&(delete e.issuer.array,delete e.subject.array),e},this.getExtParamArray=function(t){null==t&&-1!=d(this.hex,0,[0,"[3]"])&&(t=u(this.hex,0,[0,"[3]",0],"30"));for(var e=[],r=i(t,0),s=0;s<r.length;s++){var n=o(t,r[s]),a=this.getExtParam(n);null!=a&&e.push(a)}return e},this.getExtParam=function(t){var e=i(t,0).length;if(2!=e&&3!=e)throw new Error("wrong number elements in Extension: "+e+" "+t);var r=m(a(t,0,[0],"06")),s=!1;3==e&&"0101ff"==c(t,0,[1])&&(s=!0);var o=c(t,0,[e-1,0]),h=void 0;if("2.5.29.14"==r?h=this.getExtSubjectKeyIdentifier(o,s):"2.5.29.15"==r?h=this.getExtKeyUsage(o,s):"2.5.29.17"==r?h=this.getExtSubjectAltName(o,s):"2.5.29.18"==r?h=this.getExtIssuerAltName(o,s):"2.5.29.19"==r?h=this.getExtBasicConstraints(o,s):"2.5.29.30"==r?h=this.getExtNameConstraints(o,s):"2.5.29.31"==r?h=this.getExtCRLDistributionPoints(o,s):"2.5.29.32"==r?h=this.getExtCertificatePolicies(o,s):"2.5.29.33"==r?h=this.getExtPolicyMappings(o,s):"2.5.29.35"==r?h=this.getExtAuthorityKeyIdentifier(o,s):"2.5.29.36"==r?h=this.getExtPolicyConstraints(o,s):"2.5.29.37"==r?h=this.getExtExtKeyUsage(o,s):"2.5.29.54"==r?h=this.getExtInhibitAnyPolicy(o,s):"1.3.6.1.5.5.7.1.1"==r?h=this.getExtAuthorityInfoAccess(o,s):"2.5.29.20"==r?h=this.getExtCRLNumber(o,s):"2.5.29.21"==r?h=this.getExtCRLReason(o,s):"2.5.29.9"==r?h=this.getExtSubjectDirectoryAttributes(o,s):"1.3.6.1.5.5.7.48.1.2"==r?h=this.getExtOcspNonce(o,s):"1.3.6.1.5.5.7.48.1.5"==r?h=this.getExtOcspNoCheck(o,s):"1.2.840.113583.1.1.9.1"==r?h=this.getExtAdobeTimeStamp(o,s):null!=$t.EXT_PARSER[r]&&(h=$t.EXT_PARSER[r](r,s,o)),null!=h)return h;var u={extname:r,extn:o};try{u.extn=n(o)}catch(t){}return s&&(u.critical=!0),u},this.findExt=function(t,e){for(var r=0;r<t.length;r++)if(t[r].extname==e)return t[r];return null},this.updateExtCDPFullURI=function(t,e){var r=this.findExt(t,"cRLDistributionPoints");if(null!=r&&null!=r.array)for(var i=r.array,s=0;s<i.length;s++)if(null!=i[s].dpname&&null!=i[s].dpname.full)for(var n=i[s].dpname.full,o=0;o<n.length;o++){var a=n[s];null!=a.uri&&(a.uri=e)}},this.updateExtAIAOCSP=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var i=r.array,s=0;s<i.length;s++)null!=i[s].ocsp&&(i[s].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var i=r.array,s=0;s<i.length;s++)null!=i[s].caissuer&&(i[s].caissuer=e)},this.dnarraytostr=function(t){return"/"+t.map(function(t){return function(t){return t.map(function(t){return function(t){return t.type+"="+t.value}(t).replace(/\+/,"\\+")}).join("+")}(t).replace(/\//,"\\/")}).join("/")},this.setCanonicalizedDN=function(t){var e;if(null!=t.str&&null==t.array){var r=new nt.asn1.x509.X500Name({str:t.str}).tohex();e=this.getX500NameArray(r)}else e=t.array;null==t.canon&&(t.canon=this.c14nRDNArray(e))},this.c14nRDNArray=function(t){for(var e=[],r=0;r<t.length;r++){for(var i=t[r],s=[],n=0;n<i.length;n++){var o=i[n],a=o.value;a=(a=(a=(a=a.replace(/^\s*/,"")).replace(/\s*$/,"")).replace(/\s+/g," ")).toLowerCase(),s.push(o.type.toLowerCase()+"="+a)}e.push(s.join("+"))}return"/"+e.join("/")},this.getInfo=function(){var t,e,r,i=function(t){for(var e="",r=" ",i="\n",s=t.array,n=0;n<s.length;n++){var o=s[n];null!=o.dn&&(e+=r+"dn: "+o.dn.str+i),null!=o.ip&&(e+=r+"ip: "+o.ip+i),null!=o.rfc822&&(e+=r+"rfc822: "+o.rfc822+i),null!=o.dns&&(e+=r+"dns: "+o.dns+i),null!=o.uri&&(e+=r+"uri: "+o.uri+i),null!=o.other&&(e+=r+"other: "+o.other.oid+"="+JSON.stringify(o.other.value).replace(/\"/g,"")+i)}return e.replace(/\n$/,"")},s=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var s=r[i];if(e+=" policy oid: "+s.policyoid+"\n",void 0!==s.array)for(var n=0;n<s.array.length;n++){var o=s.array[n];void 0!==o.cps&&(e+=" cps: "+o.cps+"\n")}}return e},n=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var s=r[i];try{void 0!==s.dpname.full[0].uri&&(e+=" "+s.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==s.dname.full[0].dn.hex&&(e+=" "+$t.hex2dn(s.dpname.full[0].dn.hex)+"\n")}catch(t){}}return e},o=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var s=r[i];void 0!==s.caissuer&&(e+=" caissuer: "+s.caissuer+"\n"),void 0!==s.ocsp&&(e+=" ocsp: "+s.ocsp+"\n")}return e};if(t="Basic Fields\n",t+=" serial number: "+this.getSerialNumberHex()+"\n",t+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",t+=" issuer: "+this.getIssuerString()+"\n",t+=" notBefore: "+this.getNotBefore()+"\n",t+=" notAfter: "+this.getNotAfter()+"\n",t+=" subject: "+this.getSubjectString()+"\n",t+=" subject public key info: \n",t+=" key algorithm: "+(e=this.getPublicKey()).type+"\n","RSA"===e.type&&(t+=" n="+_t(e.n.toString(16)).substr(0,16)+"...\n",t+=" e="+_t(e.e.toString(16))+"\n"),null!=(r=this.aExtInfo)){t+="X509v3 Extensions:\n";for(var a=0;a<r.length;a++){var h=r[a],c=nt.asn1.x509.OID.oid2name(h.oid);""===c&&(c=h.oid);var u="";if(!0===h.critical&&(u="CRITICAL"),t+=" "+c+" "+u+":\n","basicConstraints"===c){var l=this.getExtBasicConstraints();void 0===l.cA?t+=" {}\n":(t+=" cA=true",void 0!==l.pathLen&&(t+=", pathLen="+l.pathLen),t+="\n")}else{var d;if("policyMappings"==c)t+=" "+this.getExtPolicyMappings().array.map(function(t){var e=t;return e[0]+":"+e[1]}).join(", ")+"\n";else if("policyConstraints"==c)t+=" ",null!=(d=this.getExtPolicyConstraints()).reqexp&&(t+=" reqexp="+d.reqexp),null!=d.inhibit&&(t+=" inhibit="+d.inhibit),t+="\n";else if("inhibitAnyPolicy"==c)t+=" skip="+(d=this.getExtInhibitAnyPolicy()).skip+"\n";else if("keyUsage"==c)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"==c)t+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"==c){var p=this.getExtAuthorityKeyIdentifier();void 0!==p.kid&&(t+=" kid="+p.kid.hex+"\n")}else"extKeyUsage"==c?t+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n":"subjectAltName"==c?t+=i(this.getExtSubjectAltName())+"\n":"cRLDistributionPoints"==c?t+=n(this.getExtCRLDistributionPoints()):"authorityInfoAccess"==c?t+=o(this.getExtAuthorityInfoAccess()):"certificatePolicies"==c&&(t+=s(this.getExtCertificatePolicies()))}}}return(t+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n")+"signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?this.readCertPEM(t):nt.lang.String.isHex(t)&&this.readCertHex(t))}Mt.getKey=function(t,e,r){var i,s=(y=ht).getChildIdx,n=(y.getV,y.getVbyList),o=nt.crypto,a=o.ECDSA,h=o.DSA,c=tt,u=xt,l=Mt;if(void 0!==c&&t instanceof c)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==h&&t instanceof h)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new a({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new a({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(F=new c).setPublic(t.n,t.e),F;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(F=new c).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),F;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(F=new c).setPrivate(t.n,t.e,t.d),F;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(F=new h).setPublic(t.p,t.q,t.g,t.y),F;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(F=new h).setPrivate(t.p,t.q,t.g,t.y,t.x),F;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(F=new c).setPublic(gt(t.n),gt(t.e)),F;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(F=new c).setPrivateEx(gt(t.n),gt(t.e),gt(t.d),gt(t.p),gt(t.q),gt(t.dp),gt(t.dq),gt(t.qi)),F;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(F=new c).setPrivate(gt(t.n),gt(t.e),gt(t.d)),F;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var d=(R=new a({curve:t.crv})).ecparams.keycharlen,p="04"+("0000000000"+gt(t.x)).slice(-d)+("0000000000"+gt(t.y)).slice(-d);return R.setPublicKeyHex(p),R}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){d=(R=new a({curve:t.crv})).ecparams.keycharlen,p="04"+("0000000000"+gt(t.x)).slice(-d)+("0000000000"+gt(t.y)).slice(-d);var g=("0000000000"+gt(t.d)).slice(-d);return R.setPublicKeyHex(p),R.setPrivateKeyHex(g),R}if("pkcs5prv"===r){var f,m=t,y=ht;if(9===(f=s(m,0)).length)(F=new c).readPKCS5PrvKeyHex(m);else if(6===f.length)(F=new h).readPKCS5PrvKeyHex(m);else{if(!(f.length>2&&"04"===m.substr(f[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(F=new a).readPKCS5PrvKeyHex(m)}return F}if("pkcs8prv"===r)return l.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return l._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return $t.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return $t.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=xt(t,"PUBLIC KEY");return l._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=u(t,"RSA PRIVATE KEY");return l.getKey(S,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var x=n(i=u(t,"DSA PRIVATE KEY"),0,[1],"02"),w=n(i,0,[2],"02"),A=n(i,0,[3],"02"),b=n(i,0,[4],"02"),C=n(i,0,[5],"02");return(F=new h).setPrivate(new E(x,16),new E(w,16),new E(A,16),new E(b,16),new E(C,16)),F}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED"))return S=u(t,"EC PRIVATE KEY"),l.getKey(S,null,"pkcs5prv");if(-1!=t.indexOf("-END PRIVATE KEY-"))return l.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var I=l.getDecryptedKeyHex(t,e),T=new tt;return T.readPKCS5PrvKeyHex(I),T}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R,F=n(i=l.getDecryptedKeyHex(t,e),0,[1],"04"),P=n(i,0,[2,0],"06"),D=n(i,0,[3,0],"03").substr(2);if(void 0===nt.crypto.OID.oidhex2name[P])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+P);return(R=new a({curve:nt.crypto.OID.oidhex2name[P]})).setPublicKeyHex(D),R.setPrivateKeyHex(F),R.isPublic=!1,R}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED"))return x=n(i=l.getDecryptedKeyHex(t,e),0,[1],"02"),w=n(i,0,[2],"02"),A=n(i,0,[3],"02"),b=n(i,0,[4],"02"),C=n(i,0,[5],"02"),(F=new h).setPrivate(new E(x,16),new E(w,16),new E(A,16),new E(b,16),new E(C,16)),F;if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return l.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},Mt.generateKeypair=function(t,e){if("RSA"==t){var r=e;(o=new tt).generate(r,"10001"),o.isPrivate=!0,o.isPublic=!0;var i=new tt,s=o.n.toString(16),n=o.e.toString(16);return i.setPublic(s,n),i.isPrivate=!1,i.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=i,a}if("EC"==t){var o,a,h=e,c=new nt.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new nt.crypto.ECDSA({curve:h})).setPublicKeyHex(c.ecpubhex),o.setPrivateKeyHex(c.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(i=new nt.crypto.ECDSA({curve:h})).setPublicKeyHex(c.ecpubhex),i.isPrivate=!1,i.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=i,a}throw new Error("unknown algorithm: "+t)},Mt.getPEM=function(t,e,r,i,s,n){var o=nt,a=o.asn1,h=a.DERObjectIdentifier,c=a.DERInteger,u=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,d=o.crypto,p=d.DSA,g=d.ECDSA,f=tt;function m(t){return u({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function y(t){return u({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function v(t){return u({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==f&&t instanceof f||void 0!==p&&t instanceof p||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Et(w=new l(t).tohex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==f&&t instanceof f&&(void 0===r||null==r)&&1==t.isPrivate)return Et(w=m(t).tohex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===r||null==r)&&1==t.isPrivate){var S=new h({name:t.curveName}).tohex(),E=y(t).tohex(),x="";return(x+=Et(S,"EC PARAMETERS"))+Et(E,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===r||null==r)&&1==t.isPrivate)return Et(w=v(t).tohex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==f&&t instanceof f&&void 0!==r&&null!=r&&1==t.isPrivate){var w=m(t).tohex();return void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",w,r,i,n)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==r&&null!=r&&1==t.isPrivate)return w=y(t).tohex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",w,r,i,n);if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==r&&null!=r&&1==t.isPrivate)return w=v(t).tohex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",w,r,i,n);var A=function(t,e){if("string"==typeof e)return Mt.getEncryptedPKCS8PEM(t,e);if("object"==typeof e&&null!=jt(e,"passcode")){var r=JSON.parse(JSON.stringify(e)),i=r.passcode;return delete r.passcode,Mt.getEncryptedPKCS8PEM(t,i,r)}};if("PKCS8PRV"==e&&null!=f&&t instanceof f&&1==t.isPrivate){var b=m(t).tohex();return w=u({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(w,"PRIVATE KEY"):A(w,r)}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){var C={seq:[{int:1},{octstr:{hex:t.prvKeyHex}}]};return"string"==typeof t.pubKeyHex&&C.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}),b=new u(C).tohex(),w=u({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(w,"PRIVATE KEY"):A(w,r)}if("PKCS8PRV"==e&&void 0!==p&&t instanceof p&&1==t.isPrivate)return b=new c({bigint:t.x}).tohex(),w=u({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(w,"PRIVATE KEY"):A(w,r);throw new Error("unsupported object nor format")},Mt.getKeyFromCSRPEM=function(t){var e=xt(t,"CERTIFICATE REQUEST");return Mt.getKeyFromCSRHex(e)},Mt.getKeyFromCSRHex=function(t){var e=Mt.parseCSRHex(t);return Mt.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Mt.parseCSRHex=function(t){var e=ht,r=e.getChildIdx,i=e.getTLV,s={},n=t;if("30"!=n.substr(0,2))throw new Error("malformed CSR(code:001)");var o=r(n,0);if(o.length<1)throw new Error("malformed CSR(code:002)");if("30"!=n.substr(o[0],2))throw new Error("malformed CSR(code:003)");var a=r(n,o[0]);if(a.length<3)throw new Error("malformed CSR(code:004)");return s.p8pubkeyhex=i(n,a[2]),s},Mt.getKeyID=function(t){var e=Mt,r=ht;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var i=xt(e.getPEM(t)),s=r.getIdxbyList(i,0,[1]),n=r.getV(i,s).substring(2);return nt.crypto.Util.hashHex(n,"sha1")},Mt.getJWK=function(t,e,r,i,s){var n,o,a={},h=nt.crypto.Util.hashHex;if("string"==typeof t)n=Mt.getKey(t),-1!=t.indexOf("CERTIFICATE")&&(o=xt(t));else{if("object"!=typeof t)throw new Error("unsupported keyinfo type");t instanceof $t?(n=t.getPublicKey(),o=t.hex):n=t}if(n instanceof tt&&n.isPrivate)a.kty="RSA",a.n=pt(n.n.toString(16)),a.e=pt(n.e.toString(16)),a.d=pt(n.d.toString(16)),a.p=pt(n.p.toString(16)),a.q=pt(n.q.toString(16)),a.dp=pt(n.dmp1.toString(16)),a.dq=pt(n.dmq1.toString(16)),a.qi=pt(n.coeff.toString(16));else if(n instanceof tt&&n.isPublic)a.kty="RSA",a.n=pt(n.n.toString(16)),a.e=pt(n.e.toString(16));else if(n instanceof nt.crypto.ECDSA&&n.isPrivate){if("P-256"!==(u=n.getShortNISTPCurveName())&&"P-384"!==u&&"P-521"!==u)throw new Error("unsupported curve name for JWT: "+u);var c=n.getPublicKeyXYHex();a.kty="EC",a.crv=u,a.x=pt(c.x),a.y=pt(c.y),a.d=pt(n.prvKeyHex)}else if(n instanceof nt.crypto.ECDSA&&n.isPublic){var u;if("P-256"!==(u=n.getShortNISTPCurveName())&&"P-384"!==u&&"P-521"!==u)throw new Error("unsupported curve name for JWT: "+u);c=n.getPublicKeyXYHex(),a.kty="EC",a.crv=u,a.x=pt(c.x),a.y=pt(c.y)}if(null==a.kty)throw new Error("unsupported keyinfo");return n.isPrivate||1==e||(a.kid=nt.jws.JWS.getJWKthumbprint(a)),null!=o&&1!=r&&(a.x5c=[v(o)]),null!=o&&1!=i&&(a.x5t=lt(v(h(o,"sha1")))),null!=o&&1!=s&&(a["x5t#S256"]=lt(v(h(o,"sha256")))),a},Mt.getJWKFromKey=function(t){return Mt.getJWK(t,!0,!0,!0,!0)},tt.getPosArrayOfChildrenFromHex=function(t){return ht.getChildIdx(t,0)},tt.getHexValueArrayOfChildrenFromHex=function(t){var e,r=ht.getV,i=r(t,(e=tt.getPosArrayOfChildrenFromHex(t))[0]),s=r(t,e[1]),n=r(t,e[2]),o=r(t,e[3]),a=r(t,e[4]),h=r(t,e[5]),c=r(t,e[6]),u=r(t,e[7]),l=r(t,e[8]);return(e=new Array).push(i,s,n,o,a,h,c,u,l),e},tt.prototype.readPrivateKeyFromPEMString=function(t){var e=xt(t),r=tt.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])},tt.prototype.readPKCS5PrvKeyHex=function(t){var e=tt.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},tt.prototype.readPKCS8PrvKeyHex=function(t){var e,r,i,s,n,o,a,h,c=ht,u=c.getVbyListEx;if(!1===c.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=u(t,0,[2,0,1],"02"),r=u(t,0,[2,0,2],"02"),i=u(t,0,[2,0,3],"02"),s=u(t,0,[2,0,4],"02"),n=u(t,0,[2,0,5],"02"),o=u(t,0,[2,0,6],"02"),a=u(t,0,[2,0,7],"02"),h=u(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,i,s,n,o,a,h)},tt.prototype.readPKCS5PubKeyHex=function(t){var e=ht,r=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var i=e.getChildIdx(t,0);if(2!==i.length||"02"!==t.substr(i[0],2)||"02"!==t.substr(i[1],2))throw new Error("wrong hex for PKCS#5 public key");var s=r(t,i[0]),n=r(t,i[1]);this.setPublic(s,n)},tt.prototype.readPKCS8PubKeyHex=function(t){var e=ht;if(!1===e.isASN1HEX(t))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==e.getTLVbyListEx(t,0,[0,0]))throw new Error("not PKCS8 RSA public key");var r=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(r)},tt.prototype.readCertPubKeyHex=function(t,e){var r,i;(r=new $t).readCertHex(t),i=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(i)},tt.prototype.sign=function(t,e){var r=function(t){return nt.crypto.Util.hashString(t,e)}(t);return this.signWithMessageHash(r,e)},tt.prototype.signWithMessageHash=function(t,e){var r=Z(nt.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return Kt(this.doPrivate(r).toString(16),this.n.bitLength())},tt.prototype.signPSS=function(t,e,r){var i,s=(i=St(t),nt.crypto.Util.hashHex(i,e));return void 0===r&&(r=-1),this.signWithMessageHashPSS(s,e,r)},tt.prototype.signWithMessageHashPSS=function(t,e,r){var i,s=vt(t),n=s.length,o=this.n.bitLength()-1,a=Math.ceil(o/8),h=function(t){return nt.crypto.Util.hashHex(t,e)};if(-1===r||void 0===r)r=n;else if(-2===r)r=a-n-2;else if(r<-2)throw new Error("invalid salt length");if(a<n+r+2)throw new Error("data too long");var c="";r>0&&(c=new Array(r),(new Q).nextBytes(c),c=String.fromCharCode.apply(String,c));var u=vt(h(St("\0\0\0\0\0\0\0\0"+s+c))),l=[];for(i=0;i<a-r-n-2;i+=1)l[i]=0;var d=String.fromCharCode.apply(String,l)+""+c,p=qt(u,d.length,h),g=[];for(i=0;i<d.length;i+=1)g[i]=d.charCodeAt(i)^p.charCodeAt(i);var f=65280>>8*a-o&255;for(g[0]&=~f,i=0;i<n;i++)g.push(u.charCodeAt(i));return g.push(188),Kt(this.doPrivate(new E(g)).toString(16),this.n.bitLength())},tt.prototype.verify=function(t,e){if(null==(e=e.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var r=Z(e,16),i=this.n.bitLength();if(r.bitLength()>i)return!1;var s=this.doPublic(r).toString(16);if(s.length+3!=i/4)return!1;var n=Gt(s.replace(/^1f+00/,""));if(0==n.length)return!1;var o=n[0],a=n[1],h=function(t){return nt.crypto.Util.hashString(t,o)}(t);return a==h},tt.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=Z(e,16);if(r.bitLength()>this.n.bitLength())return 0;var i=Gt(this.doPublic(r).toString(16).replace(/^1f+00/,""));return 0!=i.length&&(i[0],i[1]==t)},tt.prototype.verifyPSS=function(t,e,r,i){var s,n=(s=St(t),nt.crypto.Util.hashHex(s,r));return void 0===i&&(i=-1),this.verifyWithMessageHashPSS(n,e,r,i)},tt.prototype.verifyWithMessageHashPSS=function(t,e,r,i){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var s,n=new E(e,16),o=function(t){return nt.crypto.Util.hashHex(t,r)},a=vt(t),h=a.length,c=this.n.bitLength()-1,u=Math.ceil(c/8);if(-1===i||void 0===i)i=h;else if(-2===i)i=u-h-2;else if(i<-2)throw new Error("invalid salt length");if(u<h+i+2)throw new Error("data too long");var l=this.doPublic(n).toByteArray();for(s=0;s<l.length;s+=1)l[s]&=255;for(;l.length<u;)l.unshift(0);if(188!==l[u-1])throw new Error("encoded message does not end in 0xbc");var d=(l=String.fromCharCode.apply(String,l)).substr(0,u-h-1),p=l.substr(d.length,h),g=65280>>8*u-c&255;if(0!==(d.charCodeAt(0)&g))throw new Error("bits beyond keysize not zero");var f=qt(p,d.length,o),m=[];for(s=0;s<d.length;s+=1)m[s]=d.charCodeAt(s)^f.charCodeAt(s);m[0]&=~g;var y=u-h-i-2;for(s=0;s<y;s+=1)if(0!==m[s])throw new Error("leftmost octets not zero");if(1!==m[y])throw new Error("0x01 marker not found");return p===vt(o(St("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,m.slice(-i)))))},tt.SALT_LEN_HLEN=-1,tt.SALT_LEN_MAX=-2,tt.SALT_LEN_RECOVER=-2,$t.EXT_PARSER={},$t.registExtParser=function(t,e){$t.EXT_PARSER[t]=e},$t.hex2dn=function(t,e){void 0===e&&(e=0);var r=new $t;return ht.getTLV(t,e),r.getX500Name(t).str},$t.hex2rdn=function(t,e){if(void 0===e&&(e=0),"31"!==t.substr(e,2))throw new Error("malformed RDN");for(var r=new Array,i=ht.getChildIdx(t,e),s=0;s<i.length;s++)r.push($t.hex2attrTypeValue(t,i[s]));return r=r.map(function(t){return t.replace("+","\\+")}),r.join("+")},$t.hex2attrTypeValue=function(t,e){var r=ht,i=r.getV;if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw new Error("malformed attribute type and value");var s=r.getChildIdx(t,e);2!==s.length||t.substr(s[0],2);var n=i(t,s[0]),o=nt.asn1.ASN1Util.oidHexToInt(n);return nt.asn1.x509.OID.oid2atype(o)+"="+vt(i(t,s[1]))},$t.getPublicKeyFromCertHex=function(t){var e=new $t;return e.readCertHex(t),e.getPublicKey()},$t.getPublicKeyFromCertPEM=function(t){var e=new $t;return e.readCertPEM(t),e.getPublicKey()},$t.getPublicKeyInfoPropOfCertPEM=function(t){var e,r,i=ht.getVbyList,s={algparam:null};return(e=new $t).readCertPEM(t),r=e.getPublicKeyHex(),s.keyhex=i(r,0,[1],"03").substr(2),s.algoid=i(r,0,[0,0],"06"),"2a8648ce3d0201"===s.algoid&&(s.algparam=i(r,0,[0,1],"06")),s},$t.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],void 0!==nt&&nt||(nt={}),void 0!==nt.jws&&nt.jws||(nt.jws={}),nt.jws.JWS=function(){var t=nt.jws.JWS.isSafeJSONString;this.parseJWS=function(e,r){if(void 0===this.parsedJWS||!r&&void 0===this.parsedJWS.sigvalH){var i=e.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==i)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var s=i[1],n=i[2],o=i[3],a=s+"."+n;if(this.parsedJWS={},this.parsedJWS.headB64U=s,this.parsedJWS.payloadB64U=n,this.parsedJWS.sigvalB64U=o,this.parsedJWS.si=a,!r){var h=gt(o),c=Z(h,16);this.parsedJWS.sigvalH=h,this.parsedJWS.sigvalBI=c}var u=at(s),l=at(n);if(this.parsedJWS.headS=u,this.parsedJWS.payloadS=l,!t(u,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+u}}},nt.jws.JWS.sign=function(t,e,r,i,s){var n,o,a,h=nt,c=h.jws.JWS,u=c.readSafeJSONString,l=c.isSafeJSONString,d=h.crypto,p=(d.ECDSA,d.Mac),g=d.Signature,f=JSON;if("string"!=typeof e&&"object"!=typeof e)throw"spHeader must be JSON string or object: "+e;if("object"==typeof e&&(o=e,n=f.stringify(o)),"string"==typeof e){if(!l(n=e))throw"JWS Head is not safe JSON string: "+n;o=u(n)}if(a=r,"object"==typeof r&&(a=f.stringify(r)),""!=t&&null!=t||void 0===o.alg||(t=o.alg),""!=t&&null!=t&&void 0===o.alg&&(o.alg=t,n=f.stringify(o)),t!==o.alg)throw"alg and sHeader.alg doesn't match: "+t+"!="+o.alg;var m=null;if(void 0===c.jwsalg2sigalg[t])throw"unsupported alg name: "+t;m=c.jwsalg2sigalg[t];var y=ot(n)+"."+ot(a),v="";if("Hmac"==m.substr(0,4)){if(void 0===i)throw"mac key shall be specified for HS* alg";var S=new p({alg:m,prov:"cryptojs",pass:i});S.updateString(y),v=S.doFinal()}else if(-1!=m.indexOf("withECDSA")){(x=new g({alg:m})).init(i,s),x.updateString(y);var E=x.sign();v=nt.crypto.ECDSA.asn1SigToConcatSig(E)}else{var x;"none"!=m&&((x=new g({alg:m})).init(i,s),x.updateString(y),v=x.sign())}return y+"."+pt(v)},nt.jws.JWS.verify=function(t,e,r){var i,s=nt,n=s.jws.JWS,o=n.readSafeJSONString,a=s.crypto,h=a.ECDSA,c=a.Mac,u=a.Signature;if(i=tt,!Nt(t))return!1;var l=t.split(".");if(3!==l.length)return!1;var d,p=l[0]+"."+l[1],g=gt(l[2]),f=o(at(l[0])),m=null;if(void 0===f.alg)throw"algorithm not specified in header";if(d=(m=f.alg).substr(0,2),null!=r&&"[object Array]"===Object.prototype.toString.call(r)&&r.length>0&&-1==(":"+r.join(":")+":").indexOf(":"+m+":"))throw"algorithm '"+m+"' not accepted in the list";if("none"!=m&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Mt.getKey(e)),!("RS"!=d&&"PS"!=d||e instanceof i))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==d&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var y=null;if(void 0===n.jwsalg2sigalg[f.alg])throw"unsupported alg name: "+m;if("none"==(y=n.jwsalg2sigalg[m]))throw"not supported";if("Hmac"==y.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var v=new c({alg:y,pass:e});return v.updateString(p),g==v.doFinal()}if(-1!=y.indexOf("withECDSA")){var S,E=null;try{E=h.concatSigToASN1Sig(g)}catch(t){return!1}return(S=new u({alg:y})).init(e),S.updateString(p),S.verify(E)}return(S=new u({alg:y})).init(e),S.updateString(p),S.verify(g)},nt.jws.JWS.parse=function(t){var e,r,i,s=t.split("."),n={};if(2!=s.length&&3!=s.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=s[0],r=s[1],3==s.length&&(i=s[2]),n.headerObj=nt.jws.JWS.readSafeJSONString(at(e)),n.payloadObj=nt.jws.JWS.readSafeJSONString(at(r)),n.headerPP=JSON.stringify(n.headerObj,null," "),null==n.payloadObj?n.payloadPP=at(r):n.payloadPP=JSON.stringify(n.payloadObj,null," "),void 0!==i&&(n.sigHex=gt(i)),n},nt.jws.JWS.verifyJWT=function(t,e,r){var i=nt.jws,s=i.JWS,n=s.readSafeJSONString,o=s.inArray,a=s.includedArray;if(!Nt(t))return!1;var h=t.split(".");if(3!=h.length)return!1;var c=h[0],u=h[1],l=(gt(h[2]),n(at(c))),d=n(at(u));if(void 0===l.alg)return!1;if(void 0===r.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,r.alg))return!1;if(void 0!==d.iss&&"object"==typeof r.iss&&!o(d.iss,r.iss))return!1;if(void 0!==d.sub&&"object"==typeof r.sub&&!o(d.sub,r.sub))return!1;if(void 0!==d.aud&&"object"==typeof r.aud)if("string"==typeof d.aud){if(!o(d.aud,r.aud))return!1}else if("object"==typeof d.aud&&!a(d.aud,r.aud))return!1;var p=i.IntDate.getNow();return void 0!==r.verifyAt&&"number"==typeof r.verifyAt&&(p=r.verifyAt),void 0!==r.gracePeriod&&"number"==typeof r.gracePeriod||(r.gracePeriod=0),!(void 0!==d.exp&&"number"==typeof d.exp&&d.exp+r.gracePeriod<p||void 0!==d.nbf&&"number"==typeof d.nbf&&p<d.nbf-r.gracePeriod||void 0!==d.iat&&"number"==typeof d.iat&&p<d.iat-r.gracePeriod||void 0!==d.jti&&void 0!==r.jti&&d.jti!==r.jti||!s.verify(t,e,r.alg))},nt.jws.JWS.includedArray=function(t,e){var r=nt.jws.JWS.inArray;if(null===t)return!1;if("object"!=typeof t)return!1;if("number"!=typeof t.length)return!1;for(var i=0;i<t.length;i++)if(!r(t[i],e))return!1;return!0},nt.jws.JWS.inArray=function(t,e){if(null===e)return!1;if("object"!=typeof e)return!1;if("number"!=typeof e.length)return!1;for(var r=0;r<e.length;r++)if(e[r]==t)return!0;return!1},nt.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",ES512:"SHA512withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},nt.jws.JWS.isSafeJSONString=function(t,e,r){var i=null;try{return"object"!=typeof(i=st(t))||i.constructor===Array?0:(e&&(e[r]=i),1)}catch(t){return 0}},nt.jws.JWS.readSafeJSONString=function(t){var e=null;try{return"object"!=typeof(e=st(t))||e.constructor===Array?null:e}catch(t){return null}},nt.jws.JWS.getEncodedSignatureValueFromJWS=function(t){var e=t.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(null==e)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return e[1]},nt.jws.JWS.getJWKthumbprint=function(t){if("RSA"!==t.kty&&"EC"!==t.kty&&"oct"!==t.kty)throw"unsupported algorithm for JWK Thumprint";var e="{";if("RSA"===t.kty){if("string"!=typeof t.n||"string"!=typeof t.e)throw"wrong n and e value for RSA key";e+='"e":"'+t.e+'",',e+='"kty":"'+t.kty+'",',e+='"n":"'+t.n+'"}'}else if("EC"===t.kty){if("string"!=typeof t.crv||"string"!=typeof t.x||"string"!=typeof t.y)throw"wrong crv, x and y value for EC key";e+='"crv":"'+t.crv+'",',e+='"kty":"'+t.kty+'",',e+='"x":"'+t.x+'",',e+='"y":"'+t.y+'"}'}else if("oct"===t.kty){if("string"!=typeof t.k)throw"wrong k value for oct(symmetric) key";e+='"kty":"'+t.kty+'",',e+='"k":"'+t.k+'"}'}var r=St(e);return pt(nt.crypto.Util.hashHex(r,"sha256"))},nt.jws.IntDate={},nt.jws.IntDate.get=function(t){var e=nt.jws.IntDate,r=e.getNow,i=e.getZulu;if("now"==t)return r();if("now + 1hour"==t)return r()+3600;if("now + 1day"==t)return r()+86400;if("now + 1month"==t)return r()+2592e3;if("now + 1year"==t)return r()+31536e3;if(t.match(/Z$/))return i(t);if(t.match(/^[0-9]+$/))return parseInt(t);throw"unsupported format: "+t},nt.jws.IntDate.getZulu=function(t){return function(t){return Math.round(function(t){var e,r,i,s,n,o,a,h,c,u;if(u=(t=function(t){return t.match(/^[0-9]{12}Z$/)||t.match(/^[0-9]{12}[.][0-9]*Z$/)?t.match(/^[0-4]/)?"20"+t:"19"+t:t}(t)).match(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return e=parseInt(u[1]),r=parseInt(u[2])-1,i=parseInt(u[3]),s=parseInt(u[4]),n=parseInt(u[5]),o=parseInt(u[6]),a=0,""!==(h=u[7])&&(c=(h.substr(1)+"00").substr(0,3),a=parseInt(c)),Date.UTC(e,r,i,s,n,o,a);throw new Error("unsupported zulu format: "+t)}(t)/1e3)}(t)},nt.jws.IntDate.getNow=function(){return~~(new Date/1e3)},nt.jws.IntDate.intDate2UTCString=function(t){return new Date(1e3*t).toUTCString()},nt.jws.IntDate.intDate2Zulu=function(t){var e=new Date(1e3*t);return("0000"+e.getUTCFullYear()).slice(-4)+("00"+(e.getUTCMonth()+1)).slice(-2)+("00"+e.getUTCDate()).slice(-2)+("00"+e.getUTCHours()).slice(-2)+("00"+e.getUTCMinutes()).slice(-2)+("00"+e.getUTCSeconds()).slice(-2)+"Z"},void 0!==nt&&nt||(nt={}),void 0!==nt.jws&&nt.jws||(nt.jws={}),nt.jws.JWSJS=function(){var t=nt.jws.JWS,e=t.readSafeJSONString;this.aHeader=[],this.sPayload="",this.aSignature=[],this.init=function(){this.aHeader=[],this.sPayload=void 0,this.aSignature=[]},this.initWithJWS=function(t){this.init();var e=t.split(".");if(3!=e.length)throw"malformed input JWS";this.aHeader.push(e[0]),this.sPayload=e[1],this.aSignature.push(e[2])},this.addSignature=function(t,e,r,i){if(void 0===this.sPayload||null===this.sPayload)throw"there's no JSON-JS signature to add.";var s=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var n=nt.jws.JWS.sign(t,e,this.sPayload,r,i).split(".");n[0],n[2],this.aHeader.push(n[0]),this.aSignature.push(n[2])}catch(t){throw this.aHeader.length>s&&this.aHeader.pop(),this.aSignature.length>s&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e<t.length;e++){var r=t[e];if(2!==r.length)return!1;if(!1===this.verifyNth(e,r[0],r[1]))return!1}return!0},this.verifyNth=function(e,r,i){if(this.aHeader.length<=e||this.aSignature.length<=e)return!1;var s=this.aHeader[e],n=this.aSignature[e],o=s+"."+this.sPayload+"."+n,a=!1;try{a=t.verify(o,r,i)}catch(t){return!1}return a},this.readJWSJS=function(t){if("string"==typeof t){var r=e(t);if(null==r)throw"argument is not safe JSON object string";this.aHeader=r.headers,this.sPayload=r.payload,this.aSignature=r.signatures}else try{if(!(t.headers.length>0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignature=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},nt.crypto.ECDSA,nt.crypto.DSA,nt.crypto.Signature,nt.crypto.MessageDigest,nt.crypto.Mac,e.ym=Mt,e.wV=pt,e.cV=at,e.pj=nt,nt.crypto,nt.asn1,nt.jws,nt.lang}},e={};function r(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={exports:{}};return t[i](n,n.exports,r),n.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=function(t){return t.light="light",t.dark="dark",t.system="system",t}({});class s{theme="default";themeMode=i.light;constructor(t){t&&(this.theme=t.theme??this.theme,this.themeMode=t.themeMode??this.themeMode)}isSystemMode(){return this.themeMode===i.system}toString(){return JSON.stringify(this)}}class n{static deepEqual(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if("object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!n.deepEqual(t[r],e[r]))return!1;return!0}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;for(const i of r)if(!(i in e)||!n.deepEqual(t[i],e[i]))return!1;return!0}return!1}return!1}static deepCopy(t){if("object"!=typeof t||null==t||"function"==typeof t)return t;if(n.hasCopyMethod(t))return t.copy();const e=n.copyBuiltInType(t);return null!==e?e:n.copyPlainObject(t)}static copyBuiltInType(t){return Array.isArray(t)?t.map(t=>n.deepCopy(t)):t instanceof Date?new Date(t.getTime()):t instanceof RegExp?new RegExp(t.source,t.flags):t instanceof Map?new Map(Array.from(t.entries()).map(([t,e])=>[n.deepCopy(t),n.deepCopy(e)])):t instanceof Set?new Set(Array.from(t.values()).map(t=>n.deepCopy(t))):null}static copyPlainObject(t){const e=Object.create(Object.getPrototypeOf(t));for(const r of Object.keys(t))e[r]=n.deepCopy(t[r]);return e}static hasCopyMethod(t){return"object"==typeof t&&null!==t&&Object.prototype.hasOwnProperty.call(t,"copy")&&"function"==typeof t.copy}static isNullOrUndefined=t=>null==t;static mergeWithDefaults(t,e){if("object"!=typeof t||null===t)return t;const r=n.deepCopy(t);return Object.keys(e).forEach(t=>{const i=r[t],s=e[t];n.isNullOrUndefined(i)?r[t]=n.deepCopy(s):n.canRecursivelyMerge(i,s)&&(r[t]=n.mergeWithDefaults(i,s))}),r}static canRecursivelyMerge(t,e){return"object"==typeof t&&null!==t&&"object"==typeof e&&null!==e&&!Array.isArray(t)&&!Array.isArray(e)}}const o={BYTES:1,KB:1024,MB:1048576,GB:1024**3,TB:1024**4,PB:1024**5},a=/^(\d+(?:\.\d+)?)\s*(bytes|KB|MB|GB|TB|PB)$/i,h=/^\d+$/;class u{static convertToBytes(t){if(null==t)return 0;if("number"==typeof t)return t;if(t=t.trim(),h.test(t))return Number.parseInt(t,10);const e=a.exec(t);if(!e)return 0;const r=Number.parseFloat(e[1]),i=e[2];return r*o[i.toUpperCase()]}static convertToHumanReadable(t){if(!t)return"0 bytes";if("string"==typeof t&&(t=t.trim()),a.test(String(t)))return String(t);if("string"==typeof t&&(t=Number.parseFloat(t)),Number.isNaN(t)||t<=0)return"0 bytes";const e=Object.keys(o).reverse();for(const r of e){const e=o[r];if(t>=e){const i=t/e;return`${Number.isInteger(i)?i:i.toFixed(2)} ${"BYTES"===r?"bytes":r}`}}return"0 bytes"}}class c{static getWindow(){return window}static getParentWindow(){return c.getWindow().parent}static getReferer(){let t="*";if(c.getDocument().referrer)try{const e=new URL(c.getDocument().referrer);e.origin&&(t=e.origin)}catch(t){console.warn(`Failed to parse document.referrer: ${c.getDocument().referrer}. Using default targetOrigin '*'`,t)}return t}static getDocument(){return c.getWindow().document}static getPluginRegistry(){return c.getWindow().PluginRegistry}static setPluginRegistry(t){this.getWindow().PluginRegistry=t}static getCrypto(){return c.getWindow().crypto}static reloadPage(){c.getWindow().location.reload()}static getLocationHref(){return c.getWindow().location.href}static setLocationHref(t){c.getWindow().location.href=t}static getLocationQueryParams(){return c.getWindow().location.search}static getLocationHash(){return c.getWindow().location.hash}static matchMedia(t){return c.getWindow().matchMedia(t)}static getLocationPathname(){return c.getWindow().location.pathname}static getLocationOrigin(){return c.getWindow().location.origin}static getBaseHref(){return c.getDocument().querySelector("base")?.getAttribute("href")??"/"}static openWindow(t,e,r){c.getWindow().open(t,e,r)}static navigateSingleSpa(t){c.getWindow().singleSpa.navigateToUrl(t)}}class l{static isDevMode(){return c.getWindow().wbDevMode}}class d{static ABS_URI_REGEX=/^<?(http|urn).*>?/;static GRAPHS_VISUALIZATIONS_URL="graphs-visualizations";static RESOURCE_URL="resource";static BASE_DOCUMENTATION_URL="https://graphdb.ontotext.com/documentation/";static LATEST_UNOFFICIAL_VERSION="master";static shortenIri(t){const e=document.createElement("a");e.href=t;let r=e.hostname;return d.containsIPV4(e.hostname)||(r=e.hostname.split(".")[0]),r+":"+e.port}static containsIPV4(t){const e=t.split(".");for(let t=0,r=0;t<e.length;t++)if(parseInt(e[t],10)>=0&&parseInt(e[t],10)<=255?r++:r=0,4===r)return!0;return!1}static createAutocompleteRedirect(t,e){return`${t}?uri=${encodeURIComponent(e)}`}static removeAngleBrackets(t){return t?.startsWith("<")&&t?.endsWith(">")?t.substring(1,t.length-1):t}static isValidUri(t){let e=!1;if(this.hasValidProtocol(t))if(t.indexOf("http")>=0){const r=t.indexOf("//");e=r>4&&t.substring(r+2).length>0}else t.indexOf("urn")>=0&&(e=t.substring(4).length>0);return e}static resolveDocumentationUrl(t,e){if(!t||!e)throw new Error("Product version and endpoint path are required for documentation URL resolution.");const r=t.includes("-"),i=l.isDevMode()||r?this.LATEST_UNOFFICIAL_VERSION:t;return`${this.BASE_DOCUMENTATION_URL}${i}/${e}`}static hasAngleBrackets(t){return t.startsWith("<")&&t.endsWith(">")}static hasNoAngleBrackets(t){return!t.startsWith("<")&&!t.endsWith(">")}static hasValidProtocol(t){return this.ABS_URI_REGEX.test(t)&&(this.hasNoAngleBrackets(t)||this.hasAngleBrackets(t))}}class p{fibo1=0;fibo2=1;next(){const t=this.fibo2;return this.fibo2=this.fibo1+this.fibo2,this.fibo1=t,t}reset=()=>{this.fibo1=0,this.fibo2=1}}function g(t){return e=>{e?.preventDefault&&e.preventDefault(),f(t)}}function f(t){let e=t;e.startsWith(".")&&(e=e.slice(1)),e.startsWith("/")&&!e.startsWith(x())&&(e=x().slice(0,-1)+e),c.navigateSingleSpa(e)}function m(t){c.openWindow(t,"_blank","noopener,noreferrer")}function y(){return"/"===S()}function v(){return"/login"===S()}function S(){return c.getLocationPathname().substring(x().length-1)}function E(){return`${c.getLocationOrigin()}${x()}`}function x(){return c.getBaseHref()}function w(){return S().substring(1)}function A(){return S()+c.getLocationQueryParams()}function b(t,e){if(Object.values(t).includes(e))return e;throw new Error(`Invalid enum value '${e}' for enum ${JSON.stringify(t)}`)}class I{static now(){return Date.now()}}class C{copy(){return n.deepCopy(this)}}class T extends C{constructor(t=[]){super(),this.items=t}size(){return this.items.length}getItems(){return this.items}getFirstItem(){return this.items[0]}sort(t){this.items.sort(t)}filter(t){return this.items.filter(t)}find(t){return this.items.find(t)}isEmpty(){return 0===this.items.length}addToStart(t){this.items.unshift(t)}addItems(t){this.items.push(...t)}remove(t){const e=this.items.indexOf(t);-1!==e&&this.items.splice(e,1)}removeAll(){this.items=[]}}class R extends T{constructor(t){super(t)}add(t){this.items.push(t)}addAll(t){this.items.push(...t)}unsubscribeAll(){this.items.forEach(t=>t()),this.items=[]}}class F extends C{constructor(t){super(),this.id=t.id||"",this.title=t.title||"",this.type=t.type,this.sesameType=t.sesameType,this.uri=t.uri||"",this.externalUrl=t.externalUrl||"",this.location=t.location||"",this.state=t.state,this.local=t.local,this.readable=t.readable,this.writable=t.writable,this.unsupported=t.unsupported,this.isNew=t.isNew}toRepositoryReference(){return{id:this.id,location:this.location}}isOntop(){return"graphdb:OntopRepository"===this.sesameType}isFedx(){return"graphdb:FedXRepository"===this.sesameType}}const P=(t,e)=>{const r=t.location.localeCompare(e.location);return 0!==r?r:t.id.localeCompare(e.id)};class D extends T{constructor(t){super(t)}findRepository(t,e,r=!1){return super.find(i=>i.id===t&&(r||i.location===e))}sortByLocationAndId(){super.sort(P)}filterByRepository(t){return super.filter(this.createIdLocationFilter(t))}createIdLocationFilter(t){return e=>t.some(t=>t.id!==e.id||t.location!==e.location)}}class O extends C{constructor(t){super(),this.inferred=t?.inferred||0,this.total=t?.total||0,this.explicit=t?.explicit||0}}let N=function(t){return t.INACTIVE="INACTIVE",t.STARTING="STARTING",t.RUNNING="RUNNING",t.RESTARTING="RESTARTING",t.STOPPING="STOPPING",t}({}),_=function(t){return t.GRAPH_DB="graphdb",t.ONTOP="ontop",t.FEDX="fedx",t.SYSTEM="system",t.OTHER="other",t}({});const B="repositoryId";class L extends C{constructor(t){super(),this.uri=t?.uri||"",this.label=t?.label||"",this.username=t?.username||"",this.password=t?.password||"",this.authType=t?.authType,this.locationType=t?.locationType,this.active=t?.active,this.local=t?.local,this.system=t?.system,this.errorMsg=t?.errorMsg||"",this.defaultRepository=t?.defaultRepository||""}}let H=function(t){return t.GDB="GDB",t.ONTOPIC="ONTOPIC",t.SPARQL="SPARQL",t}({});class k{constructor(t){this.namespaces=t}getByPrefix(t){return this.namespaces[t]||""}}class U{constructor(t,e){this.NAME=t,this.payload=e}}const j={NAVIGATION_END:"navigationEnd",NAVIGATION_START:"navigationStart",LOGIN:"login",LOGOUT:"logout",APP_DATA_LOADED:"applicationDataLoaded",APPLICATION_MOUNTED:"applicationMounted",APPLICATION_UNMOUNTED:"applicationUnmounted",APPLICATION_CHANGED:"applicationChanged",APPLICATION_BEFORE_CHANGE:"applicationBeforeChange"};class V extends U{constructor(t,e){super(j.NAVIGATION_END,{oldUrl:t,newUrl:e})}}class M{}class K extends U{constructor(t,e,r){super(j.NAVIGATION_START,{oldUrl:t,newUrl:e,cancelNavigation:r})}}class q extends U{constructor(){super(j.APPLICATION_MOUNTED)}}class G extends U{constructor(){super(j.APPLICATION_UNMOUNTED)}}class $ extends U{constructor(){super(j.APPLICATION_BEFORE_CHANGE)}}class W extends U{constructor(){super(j.APPLICATION_CHANGED)}}class z extends U{constructor(){super(j.LOGOUT)}}class Y extends U{constructor(){super(j.LOGIN)}}let X=function(t){return t.NONE="NONE",t.BASIC="BASIC",t.SIGNATURE="SIGNATURE",t}({}),J=function(t){return t.ROLE_ADMIN="ROLE_ADMIN",t.ROLE_USER="ROLE_USER",t.ROLE_MONITORING="ROLE_MONITORING",t.ROLE_REPO_MANAGER="ROLE_REPO_MANAGER",t.ROLE_CLUSTER="ROLE_CLUSTER",t.IS_AUTHENTICATED_FULLY="IS_AUTHENTICATED_FULLY",t.SYSTEM_REPO="SYSTEM",t.READ_REPO="READ_REPO",t.READ_REPO_PREFIX="READ_REPO_",t.WRITE_REPO="WRITE_REPO",t.GRAPHQL="GRAPHQL",t.WRITE_REPO_PREFIX="WRITE_REPO_",t.GRAPHQL_PREFIX="GRAPHQL_",t.SUFFIX_DELIMITER=":",t.CUSTOM_PREFIX="CUSTOM_",t}({});class Q{static getRepoFromAuthority(t){return t.startsWith(J.READ_REPO_PREFIX)?{prefix:J.READ_REPO_PREFIX,repo:t.substring(J.READ_REPO_PREFIX.length)}:t.startsWith(J.WRITE_REPO_PREFIX)?{prefix:J.WRITE_REPO_PREFIX,repo:t.substring(J.WRITE_REPO_PREFIX.length)}:t.startsWith(J.GRAPHQL_PREFIX)?{prefix:J.GRAPHQL_PREFIX,repo:t.substring(J.GRAPHQL_PREFIX.length)}:null}}const Z=t=>{const e=J.SUFFIX_DELIMITER+J.GRAPHQL,r=t.getItems();if(!r.length)return r;const i=[],s={};let n=!1,o=!1,a=!1;r.forEach(t=>{const e=Q.getRepoFromAuthority(t);if(e){const{prefix:t,repo:i}=e,h=(s[r=i]||(s[r]={read:!1,write:!1,graphql:!1}),s[r]);t===J.READ_REPO_PREFIX?(h.read=!0,"*"===i&&(n=!0)):t===J.WRITE_REPO_PREFIX?(h.write=!0,"*"===i&&(o=!0)):t===J.GRAPHQL_PREFIX&&(h.graphql=!0,"*"===i&&(a=!0))}else i.push(t);var r});const h=[];return Object.keys(s).forEach(t=>{const r=s[t];r.graphql||a?r.write||o?h.push(`${J.WRITE_REPO_PREFIX}${t}${e}`,`${J.READ_REPO_PREFIX}${t}${e}`):(r.read||n)&&h.push(`${J.READ_REPO_PREFIX}${t}${e}`):r.write?h.push(`${J.WRITE_REPO_PREFIX}${t}`,`${J.READ_REPO_PREFIX}${t}`):r.read&&h.push(`${J.READ_REPO_PREFIX}${t}`)}),[...i,...h]},tt=t=>{if(!t)return new rt;const e=[],r=(t instanceof rt?t.getItems():t)??[];for(const t of r)et(t,e)||e.includes(t)||e.push(t);return new rt(e)};function et(t,e){if(!t.includes(J.SUFFIX_DELIMITER))return!1;const[r,i]=t.split(J.SUFFIX_DELIMITER);if(!r.startsWith(J.READ_REPO_PREFIX)&&!r.startsWith(J.WRITE_REPO_PREFIX)||i!==J.GRAPHQL)return!1;const s=Q.getRepoFromAuthority(r);if(!s)return!1;const{repo:n}=s,o=J.GRAPHQL_PREFIX+n;return e.includes(r)||e.push(r),e.includes(o)||e.push(o),!0}class rt extends T{WILDCARD="*";GQL_WILDCARD="*:GRAPHQL";constructor(t){super(t)}hasAuthority(t){return this.items.includes(t)}hasWildcardAuthority(t,e){const r=e?this.GQL_WILDCARD:this.WILDCARD;let i=!1;for(const e of this.items){if(!e.endsWith(r))continue;const s=e.substring(0,e.length-r.length);if(t.startsWith(s)){i=!0;break}}return i}getCustomRoles(){return this.getItems().filter(t=>0===t.indexOf(J.CUSTOM_PREFIX)).map(t=>t.substring(J.CUSTOM_PREFIX.length))}toUIModel(){const t={[J.READ_REPO]:{},[J.WRITE_REPO]:{},[J.GRAPHQL]:{}};return tt(this.getItems()).getItems().forEach(e=>{if(e.startsWith(J.READ_REPO_PREFIX)||e.startsWith(J.WRITE_REPO_PREFIX)||e.startsWith(J.GRAPHQL_PREFIX)){const r=Q.getRepoFromAuthority(e);if(r){const{prefix:e,repo:i}=r;e===J.READ_REPO_PREFIX?t[J.READ_REPO][i]=!0:e===J.WRITE_REPO_PREFIX?t[J.WRITE_REPO][i]=!0:e===J.GRAPHQL_PREFIX&&(t[J.GRAPHQL][i]=!0)}}}),t}toGraphdbAuthoritiesModel(){return Z(this)}getRepositoriesPermissions(){const t={},e=this.getItems();for(const r of e){const e=Q.getRepoFromAuthority(r);if(e){const{prefix:r,repo:i}=e,s=t[i]??{read:!1,write:!1,graphql:!1};r===J.READ_REPO_PREFIX?s.read=!0:r===J.WRITE_REPO_PREFIX?s.write=!0:r===J.GRAPHQL_PREFIX&&(s.graphql=!0),t[i]=s}}return t}}class it{constructor(t){this.DEFAULT_VIS_GRAPH_SCHEMA=t?.DEFAULT_VIS_GRAPH_SCHEMA??!0,this.DEFAULT_INFERENCE=t?.DEFAULT_INFERENCE??!0,this.DEFAULT_SAMEAS=t?.DEFAULT_SAMEAS??!0,this.IGNORE_SHARED_QUERIES=t?.IGNORE_SHARED_QUERIES??!1,this.EXECUTE_COUNT=t?.EXECUTE_COUNT??!0,this.COOKIE_CONSENT=t?.COOKIE_CONSENT}toJSON(){return{DEFAULT_VIS_GRAPH_SCHEMA:this.DEFAULT_VIS_GRAPH_SCHEMA,DEFAULT_INFERENCE:this.DEFAULT_INFERENCE,DEFAULT_SAMEAS:this.DEFAULT_SAMEAS,IGNORE_SHARED_QUERIES:this.IGNORE_SHARED_QUERIES,EXECUTE_COUNT:this.EXECUTE_COUNT,COOKIE_CONSENT:this.COOKIE_CONSENT}}}let st=function(t){return t.ADMIN="admin",t.REPO_MANAGER="repoManager",t.USER="user",t}({});class nt extends C{constructor(t){super(),this.username=t?.username??"",this.password=t?.password,this.confirmPassword=t?.confirmPassword,this.authorities=t?.authorities??new rt,this.appSettings=t?.appSettings??new it,this.dateCreated=t?.dateCreated??null,this.gptThreads=t?.gptThreads??[],this.external=t?.external??!1}getUserType(){return this.authorities.hasAuthority(J.ROLE_ADMIN)?st.ADMIN:this.authorities.hasAuthority(J.ROLE_REPO_MANAGER)?st.REPO_MANAGER:st.USER}getUserTypeDescription(){const t=this.getUserType();return t===st.USER?"User":t===st.REPO_MANAGER?"Repository manager":t===st.ADMIN?"Administrator":"Unknown"}}class ot extends C{toUser(){return new nt({username:this.username,authorities:this.authorities,appSettings:this.appSettings,external:this.external})}static fromUser(t){return new ot({username:t.username,authorities:t.authorities,appSettings:t.appSettings,external:t.external})}constructor(t){super(),this.external=t?.external??!1,this.username=t?.username??"",this.password=t?.password??"",this.authorities=t?.authorities??new rt,this.grantedAuthoritiesUiModel=tt(t?.authorities??[]),this.appSettings=t?.appSettings??new it}getCookieConsent(){return this.appSettings.COOKIE_CONSENT}setAuthorities(t=new rt){return this.authorities=t,this.grantedAuthoritiesUiModel=tt(t.getItems()),this}setAppSettings(t=new it){return this.appSettings=t,this}}class at extends C{constructor(t){super(),t&&(this.clientId=t.clientId,this.issuer=t.issuer,this.tokenType=t.tokenType,this.tokenAudience=t.tokenAudience,this.tokenIssuer=t.tokenIssuer,this.oidcTokenEndpoint=t.oidcTokenEndpoint,this.oidcJwksUri=t.oidcJwksUri,this.oidcEndSessionEndpoint=t.oidcEndSessionEndpoint,this.oidcAuthorizationEndpoint=t.oidcAuthorizationEndpoint,this.oidcScopesSupported=t.oidcScopesSupported||[],this.oracleDomain=t.oracleDomain,this.proxyOidc=t.proxyOidc||!1,this.authFlow=t.authFlow,this.extraScopes=t.extraScopes,this.authorizeParameters=t.authorizeParameters,this.openIdTokenUrl=this.proxyOidc?"rest/openid/token":this.oidcTokenEndpoint,this.openIdKeysUri=this.proxyOidc?"rest/openid/jwks":this.oidcJwksUri,this.openIdEndSessionUrl=this.oidcEndSessionEndpoint,this.supportsOfflineAccess=this.oidcScopesSupported.includes("offline_access"))}}const ht=t=>new rt(t);class ut extends C{constructor(t){super(),this.appSettings=t.appSettings,t.authorities instanceof rt?this.authorities=t.authorities:this.authorities=ht(t.authorities??[]),this.enabled=t.enabled}}const ct=t=>{const e=new ut({});return e.appSettings=new it(t.appSettings),e.authorities=ht(t.authorities||[]),e.enabled=t.enabled,e};class lt extends C{constructor(t){super(),this.authImplementation=t.authImplementation,this.enabled=t.enabled,this.passwordLoginEnabled=t.passwordLoginEnabled,this.freeAccess=ct(t.freeAccess),this.overrideAuth=ct(t.overrideAuth),this.openIdEnabled=t.openIdEnabled,this.freeAccessActive=t.freeAccess?.enabled,this.hasExternalAuth=t.hasExternalAuth,t.methodSettings?.openid&&(this.openidSecurityConfig=new at(t.methodSettings?.openid))}isEnabled(){return this.enabled??!1}isFreeAccessEnabled(){return this.freeAccess.enabled??!1}getFreeAccessAuthSettings(){return this.freeAccess}hasOverrideAuth(){return this.overrideAuth?.enabled??!1}}class dt extends C{pages={};isRestricted(t){return this.pages[t]??!1}setPageRestriction(t,e=!0){return this.pages[t]=e,this}}let pt=function(t){return t.READ="READ",t.WRITE="WRITE",t}({});class gt extends C{constructor(t){super(),this.expiryDate=t?.expiryDate,this.latestPublicationDate=t?.latestPublicationDate,this.licensee=t?.licensee||"",this.maxCpuCores=t?.maxCpuCores,this.product=t?.product,this.productType=t?.productType,this.licenseCapabilities=t?.licenseCapabilities,this.version=t?.version||"",this.installationId=t?.installationId||"",this.valid=t?.valid,this.typeOfUse=t?.typeOfUse||"",this.message=t?.message||"",this.present=t?.present||!1,this.usageRestriction=t?.usageRestriction||""}}class ft extends T{constructor(t){super(t)}}class mt{constructor(t){this.workbench=t.workbench,this.productType=t.productType,this.productVersion=t.productVersion,this.sesame=t.sesame,this.connectors=t.connectors,this.shortVersion=this.resolveShortVersion(t),this.ontop=t.ontop}resolveShortVersion(t){const e=t.productVersion;if(!e)return"";const r=/^(\d+\.\d+)/.exec(e),i=r?.[1]??e,s=/(-[^-]+)/.exec(e);return i+(s?.[1]??"")}}let yt=function(t){return t.CONSOLE="console",t}({}),vt=function(t){return t.DEBUG="DEBUG",t.INFO="INFO",t.WARN="WARN",t.ERROR="ERROR",t}({});const St=t=>Et[t],Et={[vt.DEBUG]:0,[vt.INFO]:1,[vt.WARN]:2,[vt.ERROR]:3};class xt{static SERVICE_INSTANCES=new Map;static get(t){if(!xt.SERVICE_INSTANCES.has(t.name)){const e=new t;xt.implementsLifecycleHooks(e)&&e.onCreated?.(),xt.SERVICE_INSTANCES.set(t.name,e)}return this.SERVICE_INSTANCES.get(t.name)}static implementsLifecycleHooks(t){return"object"==typeof t&&"function"==typeof t.onCreated}static getAllBySuperType(t){return Array.from(xt.SERVICE_INSTANCES.values()).filter(e=>e instanceof t)}}function wt(t){return xt.get(t)}const At=new Map([[yt.CONSOLE,wt(class{log(t,e,r){switch(t){case vt.DEBUG:console.debug(e,...r);break;case vt.INFO:console.info(e,...r);break;case vt.WARN:console.warn(e,...r);break;case vt.ERROR:console.error(e,...r);break;default:console.debug(e,...r)}}})]]);class bt{callbackFunctions=[];beforeChangeValidationPromises=[];afterValueChangeCallbackFunctions=[];setValue(t){n.deepEqual(this.value,t)||(this.value=this.getCopy(t),this.callbackFunctions.forEach(t=>t(this.getValue())),this.afterValueChangeCallbackFunctions.forEach(t=>t(this.getValue())))}getValue(){return this.getCopy(this.value)}subscribe(t,e,r){return this.callbackFunctions.push(t),e&&this.beforeChangeValidationPromises.push(e),r&&this.afterValueChangeCallbackFunctions.push(r),()=>{this.callbackFunctions=this.callbackFunctions.filter(e=>e!==t),this.beforeChangeValidationPromises=this.beforeChangeValidationPromises.filter(t=>t!==e),this.afterValueChangeCallbackFunctions=this.afterValueChangeCallbackFunctions.filter(t=>t!==r)}}async canUpdate(t){if(0===this.beforeChangeValidationPromises.length)return!0;const e=this.beforeChangeValidationPromises.map(e=>e(t));try{return(await Promise.all(e)).every(t=>t)}catch{return!1}}getCopy(t){if(null!=t)return n.hasCopyMethod(t)?t.copy():n.deepCopy(t)}}class It{subscribers=[];unsubFns=new R;subscribeToService(t){const e=this.subscribers.map(e=>t.subscribeAll(e.callback,e.beforeChangeValidationPromise,e.afterChangeCallback));return this.unsubFns.addAll(e),()=>e.forEach(t=>t())}subscribeToAllRegisteredContexts(t,e,r){const i=xt.getAllBySuperType(Ct).filter(t=>t.canSubscribeAll);for(const s of i)this.unsubFns.add(s.subscribeAll(t,e,r));const s={callback:t,beforeChangeValidationPromise:e,afterChangeCallback:r};this.subscribers.push(s);let n=!1;return()=>{if(n)return;n=!0,this.unsubFns.unsubscribeAll();const t=this.subscribers.indexOf(s);t>=0&&this.subscribers.splice(t,1)}}}class Ct{context=new Map;_canSubscribeAll=!1;onCreated(){this._canSubscribeAll=!0,xt.get(It).subscribeToService(this)}updateContextProperty(t,e){this.getOrCreateValueContext(t).setValue(e)}validatePropertyChange(t,e){return this.getOrCreateValueContext(t).canUpdate(e)}getContextPropertyValue(t){const e=this.context.get(t);return e?e.getValue():void 0}subscribe(t,e,r,i,s=!1){return!s&&e&&e(this.getContextPropertyValue(t)),i&&i(this.getContextPropertyValue(t)),this.getOrCreateValueContext(t).subscribe(e,r,i)}getDeserializedContext(){}deserializeProperty(t,e){const r=this.getDeserializedContext()?.[t];return r?r(e):e}subscribeAll(t,e,r,i=!1){const s=new R;for(const n of this.getContextFields())s.add(this.subscribe(n,t,e,r,i));return()=>s.unsubscribeAll()}getContextFields(){return Object.values(this).filter(t=>"string"==typeof t)}getOrCreateValueContext(t){let e=this.context.get(t);return e||(e=new bt,this.context.set(t,e)),e}canHandle(t){for(const e in this)if(this[e]===t)return!0;return!1}get canSubscribeAll(){return this._canSubscribeAll}}class Tt extends Ct{APPLICATION_CONFIGURATION="applicationConfiguration";updateApplicationConfiguration(t){this.updateContextProperty(this.APPLICATION_CONFIGURATION,t)}getApplicationConfiguration(){return this.getContextPropertyValue(this.APPLICATION_CONFIGURATION)}getApplicationLogoPath(t){const e=this.getApplicationConfiguration(),r=e.applicationLogoPaths,s=t===i.dark?i.light:i.dark;return r&&r[s]?r[s]:e.applicationLogoPath}}class Rt{loggers=At;constructor(t){this.module=t}debug(t,...e){this.log(vt.DEBUG,t,e)}error(t,...e){this.log(vt.ERROR,t,e)}info(t,...e){this.log(vt.INFO,t,e)}warn(t,...e){this.log(vt.WARN,t,e)}log(t,e,r){const i=this.loadConfiguration();i?.loggers.forEach(s=>{const n=this.loggers.get(s);if(!n)throw new Error(`Logger '${s}' not found`);if(St(i.minLogLevel)<=St(t)){const i=this.getFormattedMessage(t,e);n.log(t,i,r)}})}getFormattedMessage(t,e){return`[${t}] [${this.module}] [${(new Date).toLocaleString()}] ${e}`}loadConfiguration(){const t=wt(Tt).getApplicationConfiguration();return t?.loggerConfig}}class Ft{static loggerInstances=new Map;static getLoggerInstance(t){return this.loggerInstances.has(t)||this.loggerInstances.set(t,new Rt(t)),this.loggerInstances.get(t)}}class Pt{static get logger(){return Ft.getLoggerInstance("API")}}class Dt{logger=Pt.logger;constructor(t){this.value=t}getValue(){return this.value}isDefined(){return!n.isNullOrUndefined(this.value)}getValueOrDefault(t){return this.value||t}getAsJson(){if(null===this.value)return null;try{return JSON.parse(this.value)}catch(t){return this.logger.error("Error parsing JSON",t),null}}}class Ot{static GLOBAL_NAMESPACE="ontotext.gdb"}class Nt{constructor(t=[]){this.languages=t}getLanguageCodes(){return this.languages?.map(t=>t.key)}}const _t=["en","fr"];class Bt extends C{constructor(t){super(),this.defaultLanguage=t.defaultLanguage||"en",this.availableLanguages=t.availableLanguages||new Nt}}class Lt{constructor(t){this.policyAccepted=t?.policyAccepted,this.statistic=t?.statistic,this.thirdParty=t?.thirdParty,this.updatedAt=t?.updatedAt}hasChanged(){return void 0!==this.policyAccepted}static NOT_ACCEPTED_WITH_TRACKING(){return new Lt({policyAccepted:void 0,statistic:!0,thirdParty:!0})}static ACCEPTED_NO_TRACKING(){return new Lt({policyAccepted:!0,statistic:!1,thirdParty:!1})}static fromJSON(t){return new Lt({policyAccepted:t?.policyAccepted,statistic:t?.statistic,thirdParty:t?.thirdParty,updatedAt:t?.updatedAt})}}let Ht=function(t){return t.INFORMATION="INFORMATION",t.WARNING="WARNING",t.CRITICAL="CRITICAL",t}({});const kt={[Ht.INFORMATION]:0,[Ht.WARNING]:1,[Ht.CRITICAL]:2};class Ut extends C{constructor(t){super(),this.id=`${t.group}-${t.status}-${t.totalOperations}`,this.group=t.group,this.totalOperations=t.totalOperations,this.status=t.status}}class jt extends T{constructor(t){super(t)}}class Vt extends C{constructor(t){super(),this.status=t.status,this.allRunningOperations=t.allRunningOperations}toOperationsGroupSummary(){const t=new Map;return this.allRunningOperations.getItems().forEach(e=>{t.has(e.group)||t.set(e.group,new Ut({group:e.group,totalOperations:0,status:Ht.INFORMATION}));const r=t.get(e.group);r.totalOperations+=e.count,kt[e.status]>kt[r.status]&&(r.status=e.status)}),Array.from(t.values())}toOperationGroupSummaryList(){return new jt(this.toOperationsGroupSummary())}}class Mt extends T{constructor(t){super(t)}}let Kt=function(t){return t.UPDATES="updates",t.QUERIES="queries",t.IMPORT="imports",t.BACKUP_AND_RESTORE="backupAndRestore",t.CLUSTER_HEALTH="clusterHealth",t}({}),qt=function(t){return t.QUERY="QUERY",t.BACKUP="BACKUP",t.CLUSTER="CLUSTER",t.IMPORT="IMPORT",t}({});const Gt=[Kt.QUERIES,Kt.UPDATES,Kt.IMPORT],$t={[Kt.UPDATES]:"monitor/queries",[Kt.QUERIES]:"monitor/queries",[Kt.BACKUP_AND_RESTORE]:"monitor/backup-and-restore",[Kt.IMPORT]:"import",[Kt.CLUSTER_HEALTH]:"cluster"},Wt={[Kt.QUERIES]:qt.QUERY,[Kt.UPDATES]:qt.QUERY,[Kt.BACKUP_AND_RESTORE]:qt.BACKUP,[Kt.IMPORT]:qt.IMPORT,[Kt.CLUSTER_HEALTH]:qt.CLUSTER};class zt extends C{constructor(t){super(),this.value=t.value,this.status=t.status,this.type=t.type,this.id=`${t.status}-${t.type}-${t.value}`,this.count=this.getCount(this.type,this.value),this.group=Wt[this.type],this.href=$t[this.type],this.labelKey=this.getLabelKey(this.type,this.value)}getCount(t,e){return Gt.includes(t)?parseInt(e,10):0}getLabelKey(t,e){return Gt.includes(t)?t:e}}let Yt=function(t){return t.BOTTOM_RIGHT="bottom-right",t.BOTTOM_LEFT="bottom-left",t}({});class Xt{constructor(t){this.timeout=t?.timeout||5e3,this.onClick=t?.onClick,this.removeOnClick=t?.removeOnClick||!1,this.title=t?.title,this.translationParams=t?.translationParams}}class Jt extends Xt{constructor(t){super(),this.timeout=t.timeout,this.position=t.position}static getDefaultConfig(){return this.instance||(this.instance=new Jt({timeout:5e3,position:Yt.BOTTOM_RIGHT})),this.instance}}let Qt=function(t){return t.ERROR="error",t.INFO="info",t.SUCCESS="success",t.WARNING="warning",t}({});class Zt{static uuid(){const t=16;let e=(new Date).getTime(),r=1e3*(performance?.now()??0);return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let s=Math.random()*t;return e>0?(s=(e+s)%t|0,e=Math.floor(e/t)):(s=(r+s)%t|0,r=Math.floor(r/t)),("x"===i?s:3&s|8).toString(t)})}static generateRandomString(t){const e=new Uint32Array(t);return c.getCrypto().getRandomValues(e),Array.from(e,t=>("0"+t.toString(16)).substr(-2)).join("")}static hashCode(t){let e=0;for(let r=0,i=t.length;r<i;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}}class te extends C{constructor(){super(),this.id=Zt.uuid()}}class ee extends te{constructor(t,e,r){super(),this.type=t,this.message=e,this.config=r}}const re="create-toast-event";class ie extends T{constructor(t){super(t)}}let se=function(t){return t.CANCEL="cancel",t.EXIT="exit",t.DONT_SHOW_AGAIN="dontShowAgain",t}({});const ne="confirm-cancel-event";class oe{constructor(t,e){this.hasDontShowAgain=t,this.onClose=e}}class ae extends T{constructor(t){super(t)}}class he extends C{constructor(t){super(),this.setRadio(t.isRadio),this.setButtons(new ae(t.buttons))}getButtons(){return this.buttons}setButtons(t){this.buttons=t}isRadio(){return this.radio}setRadio(t){this.radio=t}selectButton(t){return this.isRadio()&&!t.selected&&(this.deselectAll(),t.selected=!0,t.callback()),this.copy()}deselectAll(){this.buttons.getItems().forEach(t=>t.selected=!1)}}class ue extends C{constructor(t){super(),this.id=t.id,this.label=t.label,this.selected=t.selected,this.callback=t.callback}}class ce extends T{constructor(t){super(t)}findSuggestionByValue(t){return this.items.find(e=>e.getValue()===t)}findHoveredSuggestion(){return this.items.find(t=>t.isHovered())}getHoveredSuggestionIndex(){return this.items.findIndex(t=>t.isHovered())}setHoveredStateAtIndex(t,e){const r=this.items[t];r&&r.setHovered(e)}unhoverAllSuggestions(){this.items.forEach(t=>t.setHovered(!1))}deselectAllSuggestions(){this.items.forEach(t=>t.setSelected(!1))}}class le extends C{constructor(t){super(),this.suggestions=t}hoverFirstSuggestion(){const t=this.suggestions.getFirstItem();if(t)return this.hoverSuggestion(t)}hoverSuggestion(t){return t&&(this.clearHoveredState(),t.setHovered(!0)),this.copy()}selectSuggestion(t){return t&&(this.clearSelectedState(),t.setSelected(!0)),this.copy()}getHoveredSuggestion(){return this.suggestions.findHoveredSuggestion()}hoverPreviousSuggestion(){const t=this.suggestions.getHoveredSuggestionIndex();return t>0&&(this.clearHoveredState(),this.suggestions.setHoveredStateAtIndex(t-1,!0)),this.copy()}hoverNextSuggestion(){const t=this.suggestions.getHoveredSuggestionIndex();return t<this.suggestions.size()-1&&(this.clearHoveredState(),this.suggestions.setHoveredStateAtIndex(t+1,!0)),this.copy()}clearSuggestions(){return this.suggestions=new ce,this.copy()}getByValue(t){return this.suggestions.findSuggestionByValue(t)}clearSelectedState(){this.suggestions.deselectAllSuggestions()}clearHoveredState(){this.suggestions.unhoverAllSuggestions()}}class de extends C{overrideToVisual=!1;constructor(t){super(),this.setId(t.id),this.setType(t.type),this.setValue(t.value),this.setDescription(t.description)}getId(){return this._id}setId(t){this._id=t}getType(){return this._type}setType(t){this._type=t}getValue(){return this._value}setValue(t){this._value=t}getDescription(){return this._description}setDescription(t){this._description=t}isHovered(){return this._hovered}setHovered(t){this._hovered=t}isSelected(){return this._selected}setSelected(t){this._selected=t}getOverrideToVisual(){return this.overrideToVisual}setOverrideToVisual(t){this.overrideToVisual=t}}let pe=function(t){return t.URI="uri",t.PREFIX="prefix",t}({});class ge{constructor(t,e){this.setSuggestion(t),this.setContext(e)}getSuggestion(){return this.suggestion}getContext(){return this.context}setContext(t){this.context=t}setSuggestion(t){this.suggestion=t}}let fe=function(t){return t.DATA_LOADED="DATA_LOADED",t}({});class me{constructor(t,e){this.entry=t,this.name=e}}class ye extends C{constructor(t){super(),this._pluginDefinitions=t}getPluginDefinitions(){return this._pluginDefinitions}}class ve extends T{}class Se{plugins=new ve;removePluginByFieldIdName(t){const e=this.fieldIdName;if(!e)return;const r=this.plugins.find(r=>r[e]===t[e]);r&&this.plugins.remove(r)}addPlugin(t){this.plugins.addItems([t])}getPlugins(){return this.plugins.getItems()}removePlugin(t){this.plugins.remove(t)}removeAllPlugins(){this.plugins.removeAll()}sort(t){this.plugins.sort(t)}}class Ee extends T{constructor(t){super(t)}}class xe extends C{_disabled=!1;constructor(t={}){super(),this._disabled=t.disabled??!1}get disabled(){return this._disabled}set disabled(t){this._disabled=t}}class we extends xe{constructor(t){super(),this._items=t.items||[]}get items(){return this._items}set items(t){this._items=t||[]}}class Ae{_order=0;_priority=0;constructor(t){this._label=t.label??"",this._labelKey=t.labelKey??"",this._href=t.href??"",this._documentationHref=t.documentationHref,this._order=t.order??this._order,this._priority=t.priority??this._priority,this._children=t.children,this._icon=t.icon,this._guideSelector=t.guideSelector,this._editions=t.editions,this._role=t.role,this._parent=t.parent,this._hrefFun=t.hrefFun,this._shouldShow=t.shouldShow,this._testSelector=t.testSelector}get label(){return this._label}set label(t){this._label=t}get labelKey(){return this._labelKey}set labelKey(t){this._labelKey=t}get href(){return this._href}set href(t){this._href=t}get documentationHref(){return this._documentationHref}set documentationHref(t){this._documentationHref=t}get children(){return this._children}set children(t){this._children=t}get icon(){return this._icon}set icon(t){this._icon=t}get guideSelector(){return this._guideSelector}set guideSelector(t){this._guideSelector=t}get editions(){return this._editions}set editions(t){this._editions=t}get role(){return this._role}set role(t){this._role=t}get parent(){return this._parent}set parent(t){this._parent=t}get hrefFun(){return this._hrefFun}set hrefFun(t){this._hrefFun=t}get shouldShow(){return this._shouldShow}set shouldShow(t){this._shouldShow=t}get testSelector(){return this._testSelector}set testSelector(t){this._testSelector=t}get order(){return this._order}set order(t){this._order=t}get priority(){return this._priority}set priority(t){this._priority=t}}class be extends xe{constructor(t){super(),this._url=t.url??"",this._module=t.module??"",this._path=t.path??"",this._chunk=t.chunk??"",this._controller=t.controller??"",this._templateUrl=t.templateUrl??"",this._title=t.title,this._reloadOnSearch=t.reloadOnSearch,this._helpInfo=t.helpInfo,this._documentationUrl=t.documentationUrl,this._allowAuthorities=t.allowAuthorities}get url(){return this._url}set url(t){this._url=t}get module(){return this._module}set module(t){this._module=t}get path(){return this._path}set path(t){this._path=t}get chunk(){return this._chunk}set chunk(t){this._chunk=t}get controller(){return this._controller}set controller(t){this._controller=t}get templateUrl(){return this._templateUrl}set templateUrl(t){this._templateUrl=t}get title(){return this._title}set title(t){this._title=t}get reloadOnSearch(){return this._reloadOnSearch}set reloadOnSearch(t){this._reloadOnSearch=t}get helpInfo(){return this._helpInfo}set helpInfo(t){this._helpInfo=t}get documentationUrl(){return this._documentationUrl}set documentationUrl(t){this._documentationUrl=t}get allowAuthorities(){return this._allowAuthorities}set allowAuthorities(t){this._allowAuthorities=t}}class Ie extends xe{constructor(t){super(t),this.guideBlockName=t.guideBlockName||"",this.getStep=t.getStep,this.getSteps=t.getSteps}}class Ce extends Se{static NAME="main.menu";name=Ce.NAME}class Te extends Se{static NAME="route";name=Te.NAME}class Re extends Se{static NAME="guide.step";name=Re.NAME;fieldIdName="guideBlockName"}class Fe extends Se{static NAME="themes";name=Fe.NAME}class Pe extends Error{constructor(t){super(`Guide step "${t}" is not correctly implemented. You need to implement either getStep or getSteps method in the GuidePlugin.`)}}class De extends C{constructor(t){super(),this.guideId=t.guideId?String(t.guideId):"",this.guideName=t.guideName||"",this.guideDescription=t.guideDescription||"",this.options=t.options??{},this.steps=t.steps??[],this.guideLevel=t.guideLevel,this.guideOrder=t.guideOrder}getId(){return this.guideId}getName(){return this.guideName}getDescription(){return this.guideDescription}getSteps(){return this.steps}getOptions(){return this.options}getTranslatedGuideName(){return this.options.translatedGuideName}setTranslatedGuideName(t){return this.options.translatedGuideName=t,this}getTranslatedGuideDescription(){return this.options.translatedGuideDescription}setTranslatedGuideDescription(t){return this.options.translatedGuideDescription=t,this}getRepositoryId(){return this.options.repositoryId}setRepositoryId(t){return this.options.repositoryId=t,this}getRepositoryIdBase(){return this.options.repositoryIdBase}setGuideLevelLabel(t){return this.guideLevelLabel=t,this}getGuideLevelLabel(){return this.guideLevelLabel}toStepsDescriptions(t,e){return this.getSteps().flatMap(r=>this._getSteps(r,this.getOptions(),t,e))}_getSteps(t,e,r,i){if(Array.isArray(t))return t.flatMap(t=>this._getSteps(t,{...e},r,i));const s=r.find(e=>e.guideBlockName===t.guideBlockName);if(!s)return[];const o={...s.options??{},...t.options,...e};let a=[];if(s.getSteps)a=a.concat(this._getSteps(n.deepCopy(s.getSteps(o,i)),e,r,i));else{if(!s.getStep)throw new Pe(s.guideBlockName);a.push(n.deepCopy(s.getStep(o,i)))}return a.forEach((t,e)=>{t.stepN=e,t.stepsTotalN=a.length}),a}}let Oe=function(t){return t.ERROR="error",t.INFO="info",t.SUCCESS="success",t.WARNING="warning",t}({});class Ne extends te{constructor(t){super(),this.code=t}withTitle(t){return this.title=t,this}withType(t){return this.type=t,this}withParameters(t){return this.parameters=t,this}static info(t){return new Ne(t).withType(Oe.INFO)}static error(t){return new Ne(t).withType(Oe.ERROR)}static warning(t){return new Ne(t).withType(Oe.WARNING)}static success(t){return new Ne(t).withType(Oe.SUCCESS)}}let _e=function(t){return t.SHOULD_TOAST="shouldToast",t}({});class Be{priority=0}class Le extends T{constructor(t){super(t)}}class He{constructor(t){this.url=t.url,this.method=t.method,this.headers={...t.headers},this.body=t.body}}class ke{constructor(t){this.status=t.status,this.statusText=t.statusText,this.headers=t.headers,this.config=t.config,this.originalResponse=t.originalResponse}}class Ue extends ke{constructor(t){super(t),this.data=t.data}}class je extends ke{constructor(t){super(t),this.data=t.data??null,this.status>=200&&this.status<300?this.message=`Http failure during parsing for ${t.config.url||"(unknown url)"}`:this.message=`Http failure response for ${t.config.url||"(unknown url)"}: ${t.status} ${t.statusText}`}get isClientError(){return this.status>=400&&this.status<500}get isServerError(){return this.status>=500&&this.status<600}}class Ve extends T{constructor(t=[]){super(t)}getFirstQuery(){return this.getFirstItem()}}class Me{constructor(t){this.queryName=t.queryName??"",this.query=t.query??"",this.owner=t.owner??"",this.isPublic=t.isPublic??!1,this.readonly=t.readonly??!1}}let Ke=function(t){return t.CENTER="center",t.START="start",t}({});class qe{constructor(t,e,r,i,s,n){this.status=t,this.command=e,this.messageLabelKey=r,this.parameters=i,this.message=s,this.iri=n}}const Ge={ERROR:"error",SUCCESS:"success"};let $e=function(t){return t.CREATE="create",t.REPAIR="repair",t.DROP="drop",t}({});class We extends C{constructor(t){super(),this.id=t.id,this.name=t.name,this.description=t.description,this.owner=t.owner,this.repositoryId=t.repositoryId,this.hint=t.hint,this.shared=t.shared,this.startMode=t.startMode,this.startIRI=t.startIRI,this.startIRILabel=t.startIRILabel,this.startQueryIncludeInferred=t.startQueryIncludeInferred,this.startQuerySameAs=t.startQuerySameAs,this.startGraphQuery=t.startGraphQuery,this.expandQuery=t.expandQuery,this.predicateLabelQuery=t.predicateLabelQuery,this.resourcePropertiesQuery=t.resourcePropertiesQuery,this.resourceQuery=t.resourceQuery}}class ze extends T{constructor(t){super(t)}getByStartMode(t){return this.items.filter(e=>e.startMode===t)}}let Ye=function(t){return t.SEARCH="search",t.NODE="node",t.QUERY="query",t}({}),Xe=function(t){return t.RETURN_URL="r",t.NO_ACCESS="noaccess",t.EXPIRED="expired",t}({});class Je{getStorage(){return localStorage}get(t,e=!0){const r=this.getStorage().getItem(e?this.getPrefixedKey(t):t);return new Dt(r)}getAsJson(t){const e=this.getStorage().getItem(t);if(e)try{return JSON.parse(e)}catch(e){return console.error(`Error parsing JSON from localStorage for key ${t}:`,e),null}return null}storeValue(t,e){this.getStorage().setItem(this.getPrefixedKey(t),e)}remove(t,e=!0){this.getStorage().removeItem(e?this.getPrefixedKey(t):t)}getPrefixedKey(t){const e=`${Ot.GLOBAL_NAMESPACE}.${this.NAMESPACE}.`,r=`${this.NAMESPACE}.`;return t.startsWith(e)?t:t.startsWith(r)?`${Ot.GLOBAL_NAMESPACE}.${t}`:`${e}${t}`}}class Qe{logger=Pt.logger;handleStorageChange(t){const e=t.key?.substring(Ot.GLOBAL_NAMESPACE.length+1);let r="",i="";e&&(r=e.substring(0,e.indexOf(".")),i=e.substring(r.length+1));const s=this.resolveHandler(r,i);if(s){let e;null!==t.newValue&&(e=s.deserializeProperty(i,t.newValue)),s.updateContextProperty(i,e)}}resolveHandler(t,e){if(!t)return void this.logger.warn("Namespace is required to resolve a context property change handler.");const r=xt.getAllBySuperType(Ct).find(t=>t.canHandle(e));if(r)return r;this.logger.warn(`No context property change handler found for namespace: ${t} and property: ${e}`)}}class Ze extends Je{NAMESPACE="application";SETTINGS="settings";logger=Pt.logger;OLD_SETTINGS_KEY="ls.workbench-settings";migrate(){if(this.get(this.SETTINGS).getValue())return;const t=this.getAsJson(this.OLD_SETTINGS_KEY);if(!t)return;this.logger.info("Begin migrating legacy application settings to new format...");const e=new s;e.theme=t.theme,t.mode&&t.mode===i.dark?e.themeMode=i.dark:e.themeMode=i.light,this.setApplicationSettings(e),this.getStorage().removeItem(this.OLD_SETTINGS_KEY),this.logger.info("Migration of legacy application settings completed. Old settings key removed.")}set(t,e){this.storeValue(t,e)}setApplicationSettings(t){this.set(this.SETTINGS,JSON.stringify(t))}getApplicationSettings(){const t=this.get(this.SETTINGS).getAsJson();return t?new s(t):new s}getThemeMode(){return this.getApplicationSettings().themeMode}getThemeModeRaw(){const t=this.get(this.SETTINGS).getAsJson();return t?.themeMode}isThemeModePresent(){const t=this.get(this.SETTINGS).getAsJson();return!!t&&void 0!==t.themeMode}}class tr extends Ct{RUNTIME_CONFIGURATION="runtimeConfiguration";THEME_MODE="themeMode";SYSTEM_THEME_MODE="systemThemeMode";updateRuntimeConfiguration(t){const e={...this.getRuntimeConfiguration()??{},...t};this.updateContextProperty(this.RUNTIME_CONFIGURATION,e)}onRuntimeConfigurationChanged(t){return this.subscribe(this.RUNTIME_CONFIGURATION,t)}getRuntimeConfiguration(){return this.getContextPropertyValue(this.RUNTIME_CONFIGURATION)}updateThemeMode(t){this.updateContextProperty(this.THEME_MODE,t)}onThemeModeChanged(t,e=!1){return this.subscribe(this.THEME_MODE,t,void 0,void 0,e)}updateSystemThemeMode(t){this.updateContextProperty(this.SYSTEM_THEME_MODE,t)}onSystemThemeChanged(t,e=!1){return this.subscribe(this.SYSTEM_THEME_MODE,t,void 0,void 0,e)}}class er{applicationSettingsStorageService=wt(Ze);runtimeConfigurationContextService=wt(tr);rootSelector=":root";darkClass=i.dark;static CODE_EDITOR_DARK_THEME="moxer";applyDarkModeIfEnabled(){const t=this.isDarkModeEnabledInSettings()?i.dark:i.light;this.setThemeMode(t)}getCurrentThemeMode(){return this.applicationSettingsStorageService.getThemeModeRaw()??this.getPreferredScheme()}setThemeMode(t){const e=this.getRootElement();if(!e)return;const r=t===i.dark;e.classList.toggle(this.darkClass,r),this.runtimeConfigurationContextService.updateThemeMode(r?i.dark:i.light)}applyColorScheme(){this.isSystemThemeMode()||!this.isThemeModeSet()?this.setThemeMode(this.getPreferredScheme()):this.applyDarkModeIfEnabled()}applyNewColorScheme(t){this.runtimeConfigurationContextService.updateSystemThemeMode(t),!this.isSystemThemeMode()&&this.isThemeModeSet()||this.setThemeMode(t)}getThemeModeOrSystem(){return this.isThemeModeSet()?this.getCurrentThemeMode():i.system}isSystemThemeMode(){return this.getCurrentThemeMode()===i.system}isDarkModeApplied(){const t=this.getRootElement();if(!t)return!1;const e=i.dark;return t.classList.contains(e)}isDarkModeEnabledInSettings(){const t=this.applicationSettingsStorageService.getApplicationSettings();return t?.themeMode===i.dark}isThemeModeSet(){return this.applicationSettingsStorageService.isThemeModePresent()}getCodeEditorThemeName(){return this.isDarkModeApplied()?er.CODE_EDITOR_DARK_THEME:void 0}getPreferredScheme(){return c.matchMedia("(prefers-color-scheme: dark)").matches?i.dark:i.light}getRootElement(){return document.querySelector(this.rootSelector)??null}}class rr{preProcessors=new T;postProcessors=new T;async preProcess(t){let e=t;for(const t of this.preProcessors.getItems())t.shouldProcess(e)&&(e=await t.process(e));return e}async postProcess(t){let e=t;for(const t of this.postProcessors.getItems())t.shouldProcess(e)&&(e=await t.process(e));return e}registerRequestInterceptors(t){this.preProcessors.addItems(t.getItems()),this.sortInterceptors(this.preProcessors)}registerResponseInterceptors(t){this.postProcessors.addItems(t.getItems()),this.sortInterceptors(this.postProcessors)}sortInterceptors(t){t.sort((t,e)=>e.priority-t.priority)}}class ir{emit(t){const e=new CustomEvent(t.NAME,{detail:t.payload});return this.getHostElement().dispatchEvent(e),e}subscribe(t,e){const r=t=>{t instanceof CustomEvent&&e(t.detail)};return this.getHostElement().addEventListener(t,r),()=>this.getHostElement().removeEventListener(t,r)}getHostElement(){return document.body}}const sr="http-request-done-event";class nr{interceptorService=xt.get(rr);eventEmitter=new ir;get(t,e){const{params:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"GET",{params:r,headers:i},"response"):this.request(t,"GET",{params:r,headers:i},"body")}post(t,e){const{body:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"POST",{body:r,headers:i},"response"):this.request(t,"POST",{body:r,headers:i},"body")}put(t,e){const{body:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"PUT",{body:r,headers:i},"response"):this.request(t,"PUT",{body:r,headers:i},"body")}patch(t,e){const{body:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"PATCH",{body:r,headers:i},"response"):this.request(t,"PATCH",{body:r,headers:i},"body")}delete(t,e){const{headers:r,responseType:i="body"}=e??{};return"response"===i?this.request(t,"DELETE",{headers:r},"response"):this.request(t,"DELETE",{headers:r},"body")}uploadFile(t,e,r="file",i,s){const n=new FormData;n.append(r,e,e instanceof File?e.name:void 0),s&&Object.entries(s).forEach(([t,e])=>{n.append(t,e)});const o={...i};return delete o["Content-Type"],this.post(t,{body:n,headers:o,responseType:"response"})}encodeURIComponentStrict(t){return encodeURIComponent(t).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16)})}request(t,e,r={},i="response"){const{fullUrl:s,headers:n}=this.getRequestConfig(t,r),o=new He({url:s,method:e,headers:n,body:r.body});let a;return this.executeRequest(o).then(async t=>{if(a=t,!t.ok){const e=await this.getDataFromResponse(i,t),r=new je({status:t.status,statusText:t.statusText,headers:this.extractHeaders(t),config:o,originalResponse:t,data:e});return Promise.reject(r)}const e=await this.getDataFromResponse(i,t);return"body"===i?e:new Ue({status:t.status,statusText:t.statusText,headers:this.extractHeaders(t),config:o,originalResponse:t,data:e})}).catch(t=>{if(t instanceof je)return Promise.reject(t);a??=t;const e=new je({status:a.status,statusText:a.statusText,headers:this.extractHeaders(a),config:o,originalResponse:a,data:null});return t?.message&&(e.message=t.message),Promise.reject(e)}).finally(()=>this.eventEmitter.emit({NAME:sr,payload:void 0}))}async getDataFromResponse(t,e){let r=null;if(r=await e.text(),!t||"body"===t||"response"===t)try{r=JSON.parse(r)}catch{}return r}getRequestConfig(t,e){const r=this.buildQueryParams(e.params),i=`${t}${r?`?${r}`:""}`,s=e.body instanceof FormData,n={Accept:"application/json, text/plain, */*",...e.headers};return s||(n["Content-Type"]=e.headers?.["Content-Type"]??"application/json"),{fullUrl:i,headers:n}}formatBody(t,e){return e?e instanceof FormData?e:t["Content-Type"]?.includes("application/json")?JSON.stringify(e):(t["Content-Type"]?.includes("application/x-www-form-urlencoded"),e):null}executeRequest(t){return this.interceptorService.preProcess(t).then(t=>{const e=this.formatBody(t.headers,t.body);return fetch(t.url,{method:t.method,headers:t.headers,body:e})}).then(t=>this.interceptorService.postProcess(t))}extractHeaders(t){const e={};return t.headers.forEach((t,r)=>{e[r]=t}),e}buildQueryParams(t={}){return new URLSearchParams(t).toString()}}class or extends nr{I18N_ENDPOINT="assets/i18n";getLanguage(t){return this.get(`${this.I18N_ENDPOINT}/${t}.json`)}getLanguageConfiguration(){return this.get(`${this.I18N_ENDPOINT}/language-config.json`)}}class ar extends Je{NAMESPACE="i18n";set(t,e){this.storeValue(t,e)}}class hr extends Ct{LANGUAGE_CONFIG="languageConfig";SELECTED_LANGUAGE="selectedLanguage";LANGUAGE_BUNDLE="languageBundle";DEFAULT_BUNDLE="defaultBundle";updateSelectedLanguage(t){this.validatePropertyChange(this.SELECTED_LANGUAGE,t).then(e=>{if(e){const e=t||xt.get(lr).getDefaultLanguage();xt.get(ar).set(this.SELECTED_LANGUAGE,e),this.updateContextProperty(this.SELECTED_LANGUAGE,t)}})}onSelectedLanguageChanged(t,e,r=!1){return this.subscribe(this.SELECTED_LANGUAGE,t,e,void 0,r)}updateLanguageBundle(t){this.updateContextProperty(this.LANGUAGE_BUNDLE,t)}onLanguageBundleChanged(t){return this.subscribe(this.LANGUAGE_BUNDLE,t)}getLanguageBundle(){return this.getContextPropertyValue(this.LANGUAGE_BUNDLE)}updateDefaultBundle(t){this.updateContextProperty(this.DEFAULT_BUNDLE,t)}getDefaultBundle(){return this.getContextPropertyValue(this.DEFAULT_BUNDLE)}getLanguageConfig(){return this.getContextPropertyValue(this.LANGUAGE_CONFIG)}setLanguageConfig(t){this.updateContextProperty(this.LANGUAGE_CONFIG,t)}getSelectedLanguage(){return this.getContextPropertyValue(this.SELECTED_LANGUAGE)}getDefaultLanguage(){return this.getLanguageConfig().defaultLanguage}}class ur extends C{constructor(t,e){super(),this.key=t,this.name=e}}function cr(t){const e=t.map(t=>new ur(t.key,t.name));return new Nt(e)}class lr{languageRestService=xt.get(or);languageContextService=xt.get(hr);getSupportedLanguages(){const t=this.languageContextService.getLanguageConfig();return t?t.availableLanguages.getLanguageCodes():_t}getLanguage(t){return this.languageRestService.getLanguage(t)}getLanguageConfiguration(){return this.languageRestService.getLanguageConfiguration().then(t=>{return new Bt({defaultLanguage:(e=t).defaultLanguage,availableLanguages:cr(e.availableLanguages)});var e})}getDefaultLanguage(){const t=this.languageContextService.getLanguageConfig();return t?t.defaultLanguage:"en"}}class dr extends nr{static REPOSITORIES_ENDPOINT="rest/repositories";getRepositories(){return this.get(`${dr.REPOSITORIES_ENDPOINT}/all`)}getRepositorySizeInfo(t){return this.get(`${dr.REPOSITORIES_ENDPOINT}/${t.id}/size?location=${encodeURIComponent(t.location)}`)}}const pr=t=>{if(!t||"object"!=typeof t)return new D;const e=[];return Object.entries(t).forEach(([,t])=>{Array.isArray(t)&&t.forEach(t=>{const r=new F({id:t.id,title:t.title,type:b(_,t.type),sesameType:t.sesameType,uri:t.uri,externalUrl:t.externalUrl,location:t.location,state:b(N,t.state),local:t.local,readable:t.readable,writable:t.writable,unsupported:t.unsupported});e.push(r)})}),new D(e)};class gr{constructor(){this.repositoryRestService=wt(dr)}async getRepositories(){const t=await this.repositoryRestService.getRepositories();return pr(t)}async getRepositorySizeInfo(t){return e=await this.repositoryRestService.getRepositorySizeInfo(t),new O(e);var e}}class fr extends Je{NAMESPACE="repository";logger=Pt.logger;SELECTED_REPOSITORY="selectedRepository";set(t,e){e?this.storeValue(t,e):this.remove(t)}setRepositoryReference(t){this.set(this.SELECTED_REPOSITORY,this.serializeRepositoryReference(t))}getRepositoryReference(){return this.deserializeRepositoryReference(this.get(this.SELECTED_REPOSITORY).getValueOrDefault('{"id": "", "location": ""}'))}removeRepositoryReference(){this.remove(this.SELECTED_REPOSITORY)}getActiveRepositoryId(){const t=this.getRepositoryReference();return t?.id}serializeRepositoryReference(t){return JSON.stringify(t)}deserializeRepositoryReference(t){if("string"==typeof t)try{return JSON.parse(t)}catch(t){this.logger.error("Error parsing repository reference",t)}}}class mr extends Ct{SELECTED_REPOSITORY="selectedRepository";REPOSITORY_LIST="repositoryList";updateSelectedRepository(t){const e=wt(fr),r=this.findRepository(t);return this.validatePropertyChange(this.SELECTED_REPOSITORY,r).then(i=>{i&&(r?e.setRepositoryReference(r.toRepositoryReference()):t||e.removeRepositoryReference(),this.updateContextProperty(this.SELECTED_REPOSITORY,r))})}getSelectedRepository(){return this.getContextPropertyValue(this.SELECTED_REPOSITORY)}onSelectedRepositoryChanged(t,e){return this.subscribe(this.SELECTED_REPOSITORY,t,e)}updateRepositoryList(t){return this.updateContextProperty(this.REPOSITORY_LIST,t)}getRepositoryList(){return this.getContextPropertyValue(this.REPOSITORY_LIST)||new D([])}onRepositoryListChanged(t){return this.subscribe(this.REPOSITORY_LIST,t)}getDeserializedContext(){return{[this.SELECTED_REPOSITORY]:this.deserializeRepository}}deserializeRepository=t=>new F(JSON.parse(t));findRepository(t,e=!1){if(t)return this.getRepositoryList().findRepository(t.id,t.location,e)}repositoryExists(t,e=!1){return void 0!==this.findRepository(t,e)}isActiveRepoOntopType(){return this.getSelectedRepository()?.isOntop()??!1}}class yr{GRAPHQL_REPO_AUTHORITY="GRAPHQL";SYSTEM_REPOSITORY_ID="SYSTEM";isSystemRepository(t){return t.id===this.SYSTEM_REPOSITORY_ID}getCurrentGqlRepoAuthority(t,e){return`${this.getCurrentRepoAuthority(t,e)}:${this.GRAPHQL_REPO_AUTHORITY}`}getOverallGqlRepoAuthority(t){return`${this.getOverallRepoAuthority(t)}:${this.GRAPHQL_REPO_AUTHORITY}`}getLocationSpecificId(t){return t.location?`${t.id}@${t.location}`:t.id}getCurrentRepoAuthority(t,e){return`${t}_REPO_${e}`}getOverallRepoAuthority(t){return`${t}_REPO_*`}}class vr extends nr{getActiveRepositoryLocation(){return this.get("rest/locations/active")}}const Sr=t=>new L({uri:t.uri,label:t.label,username:t.username??void 0,password:t.password??void 0,authType:t.authType?b(X,t.authType):void 0,locationType:t.locationType?b(H,t.locationType):void 0,active:t.active,local:t.local,system:t.system,errorMsg:t.errorMsg??"",defaultRepository:t.defaultRepository??void 0});class Er{constructor(){this.locationRestService=xt.get(vr)}getActiveRepositoryLocation(){return this.locationRestService.getActiveRepositoryLocation().then(Sr)}}class xr extends Ct{ACTIVE_REPOSITORY_LOCATION="activeRepositoryLocation";IS_LOADING="isLoading";updateActiveRepositoryLocation(t){this.updateContextProperty(this.ACTIVE_REPOSITORY_LOCATION,t)}onActiveLocationChanged(t){return this.subscribe(this.ACTIVE_REPOSITORY_LOCATION,t)}updateIsLoading(t){this.updateContextProperty(this.IS_LOADING,t)}onIsLoadingChanged(t){return this.subscribe(this.IS_LOADING,t)}}class wr extends nr{LICENSE_ENDPOINT="rest/graphdb-settings/license";LICENSE_INFO_ENDPOINT="rest/info/license";getLicense(){return this.get(this.LICENSE_ENDPOINT)}getIsLicenseHardcoded(){return this.get(`${this.LICENSE_ENDPOINT}/hardcoded`)}registerLicense(t){const e=new Uint8Array(t.length);for(let r=0;r<e.length;r++)e[r]=t.charCodeAt(r);return this.post(this.LICENSE_ENDPOINT,{body:e,headers:{"Content-Type":"application/octet-stream"}})}unregisterLicense(){return this.delete(this.LICENSE_ENDPOINT)}extractFromLicenseFile(t){return this.uploadFile(`${this.LICENSE_INFO_ENDPOINT}/to-base-64`,t,void 0,{Accept:"text/plain"}).then(t=>t.data)}validateLicense(t){return this.post(`${this.LICENSE_INFO_ENDPOINT}/validate`,{body:t,headers:{"Content-Type":"text/plain"}})}}let Ar=function(t){return t.GRAPHDB_LITE="GRAPHDB_LITE",t.GRAPHDB_SE="GRAPHDB_SE",t.GRAPHDB_ENTERPRISE="GRAPHDB_ENTERPRISE",t.GRAPHDB_SANDBOX="GRAPHDB_SANDBOX",t}({}),br=function(t){return t.FREE="free",t.STANDARD="standard",t.ENTERPRISE="enterprise",t.SANDBOX="sandbox",t}({});function Ir(t){return Object.values(br).find(e=>e===t)}const Cr=t=>{return new gt({expiryDate:t?.expiryDate?new Date(t.expiryDate):void 0,latestPublicationDate:t?.latestPublicationDate?new Date(t.latestPublicationDate):void 0,licensee:t?.licensee||"",maxCpuCores:t?.maxCpuCores,product:(e=t?.product,Object.values(Ar).find(t=>t===e)),productType:Ir(t?.productType),licenseCapabilities:Tr(t?.licenseCapabilities),version:t?.version||"",installationId:t?.installationId||"",valid:t?.valid,typeOfUse:t?.typeOfUse||"",message:t?.message||"",present:t?.present||!1,usageRestriction:t?.usageRestriction||""});var e};function Tr(t){const e=(t??[]).filter(t=>t?.trim());return new ft(e)}class Rr extends Ct{GRAPHDB_LICENSE="graphDbLicense";IS_LICENSE_HARDCODED="isLicenseHardcoded";updateGraphdbLicense(t){this.updateContextProperty(this.GRAPHDB_LICENSE,t)}onLicenseChanged(t){return this.subscribe(this.GRAPHDB_LICENSE,t)}getLicenseSnapshot(){return this.getContextPropertyValue(this.GRAPHDB_LICENSE)}updateIsLicenseHardcoded(t){this.updateContextProperty(this.IS_LICENSE_HARDCODED,!!t)}onIsLicenseHardcodedChanged(t){return this.subscribe(this.IS_LICENSE_HARDCODED,t)}isLicenseHardcodedSnapshot(){return this.getContextPropertyValue(this.IS_LICENSE_HARDCODED)}}class Fr{licenseRestService=wt(wr);licenseContextService=wt(Rr);trackableProductTypes=[br.FREE,br.SANDBOX];trackableTypesOfUse=["evaluation","this is an evaluation license"];async updateLicenseStatus(){const t=await this.getIsLicenseHardcoded();this.licenseContextService.updateIsLicenseHardcoded(t);const e=await this.getLicense();return this.licenseContextService.updateGraphdbLicense(e),e}async getLicense(){const t=await this.licenseRestService.getLicense();return Cr(t)}registerLicense(t){return this.licenseRestService.registerLicense(t).then(t=>Cr(t))}unregisterLicense(){return this.licenseRestService.unregisterLicense()}extractFromLicenseFile(t){return this.licenseRestService.extractFromLicenseFile(t)}getIsLicenseHardcoded(){return this.licenseRestService.getIsLicenseHardcoded()}validateLicense(t){return this.licenseRestService.validateLicense(t).then(t=>Cr(t))}isTrackableLicense(){const t=this.licenseContextService.getLicenseSnapshot(),e=t?.typeOfUse?.toLowerCase()||"",r=t?.productType;return!t?.present||this.trackableProductTypes.some(t=>t===r)||this.trackableTypesOfUse.includes(e)}}class Pr extends Ct{PRODUCT_INFO="productInfo";updateProductInfo(t){this.updateContextProperty(this.PRODUCT_INFO,t)}onProductInfoChanged(t){return this.subscribe(this.PRODUCT_INFO,t)}getProductInfo(){return this.getContextPropertyValue(this.PRODUCT_INFO)}}class Dr extends nr{VERSION_URL="rest/info/version";getProductInfoLocal(){return this.get(`${this.VERSION_URL}?local=1`)}}class Or{productInfoRestService=wt(Dr);async getProductInfoLocal(){const t=await this.productInfoRestService.getProductInfoLocal();return new mt({workbench:(e=t).Workbench||"",productType:e.productType||"",productVersion:e.productVersion||"",sesame:e.sesame||"",connectors:e.connectors||"",ontop:e.Ontop||""});var e}}class Nr extends Ct{RESTRICTED_PAGES="restrictedPages";SECURITY_CONFIG="securityConfig";AUTHENTICATED_USER="authenticatedUser";JSON_WEB_KEYS_SET="jsonWebKeysSet";IS_LOGGED_IN="isLoggedIn";getRestrictedPages(){return this.getContextPropertyValue(this.RESTRICTED_PAGES)||new dt}updateRestrictedPages(t){this.updateContextProperty(this.RESTRICTED_PAGES,t)}onRestrictedPagesChanged(t){return this.subscribe(this.RESTRICTED_PAGES,t)}updateSecurityConfig(t){this.updateContextProperty(this.SECURITY_CONFIG,t)}onSecurityConfigChanged(t){return this.subscribe(this.SECURITY_CONFIG,t)}getSecurityConfig(){return this.getContextPropertyValue(this.SECURITY_CONFIG)}updateAuthenticatedUser(t){this.updateContextProperty(this.AUTHENTICATED_USER,t)}onAuthenticatedUserChanged(t){return this.subscribe(this.AUTHENTICATED_USER,t)}getAuthenticatedUser(){return this.getContextPropertyValue(this.AUTHENTICATED_USER)}updateJsonWebKeysSet(t){this.updateContextProperty(this.JSON_WEB_KEYS_SET,t)}getJsonWebKeysSet(){return this.getContextPropertyValue(this.JSON_WEB_KEYS_SET)}updateIsLoggedIn(t){this.updateContextProperty(this.IS_LOGGED_IN,t)}getIsLoggedIn(){return this.getContextPropertyValue(this.IS_LOGGED_IN)}onUserLoginStatusChanged(t){return this.subscribe(this.IS_LOGGED_IN,t)}}class _r extends Je{accessToken="access_token";idToken="id_token";refreshToken="refresh_token";tokenType="token_type";pkceState="pkce_state";pkceCodeVerifier="pkce_code_verifier";nonce="nonce";returnUrl="return_url";NAMESPACE="auth.openid";set(t,e){this.storeValue(t,e)}setAccessToken(t){this.set(this.accessToken,t)}getAccessToken(){return this.get(this.accessToken)}clearAccessToken(){this.remove(this.accessToken)}setIdToken(t){this.set(this.idToken,t)}getIdToken(){return this.get(this.idToken)}clearIdToken(){this.remove(this.idToken)}setRefreshToken(t){this.set(this.refreshToken,t)}getRefreshToken(){return this.get(this.refreshToken)}clearRefreshToken(){this.remove(this.refreshToken)}setTokenType(t){this.set(this.tokenType,t)}getTokenType(){return this.get(this.tokenType)}clearTokenType(){this.remove(this.tokenType)}setPkceState(t){this.set(this.pkceState,t)}getPkceState(){return this.get(this.pkceState)}clearPkceState(){this.remove(this.pkceState)}setPkceCodeVerifier(t){this.set(this.pkceCodeVerifier,t)}getPkceCodeVerifier(){return this.get(this.pkceCodeVerifier)}clearPkceCodeVerifier(){this.remove(this.pkceCodeVerifier)}setNonce(t){this.set(this.nonce,t)}getNonce(){return this.get(this.nonce)}clearNonce(){this.remove(this.nonce)}setReturnUrl(t){this.set(this.returnUrl,t)}getReturnUrl(){return this.get(this.returnUrl)}clearReturnUrl(){this.remove(this.returnUrl)}clearTokens(){this.clearAccessToken(),this.clearIdToken(),this.clearRefreshToken()}}var Br=r(355);class Lr extends Error{constructor(t){super(),this.text=t}get message(){return`${this.constructor.name}: ${this.text}`}}class Hr extends Lr{}class kr extends Hr{constructor(){super("Invalid JWT token")}}let Ur=function(t){return t.ACCESS="access",t.ID="id",t.REFRESH="refresh",t}({});class jr{logger=Pt.logger;openidStorageService=wt(_r);securityContextService=wt(Nr);REFRESH_TOKEN_TOLERANCE=5e3;hasValidIdToken(t){return this.getTokenByType(Ur.ID)?this.verifyToken(Ur.ID,t)?(this.logger.debug("OpenID: valid id token found"),!0):(this.logger.debug("OpenID: stale id token"),!1):(this.logger.debug("OpenID: no id token"),!1)}hasValidRefreshToken(){const t=this.getTokenByType(Ur.REFRESH);if(!t)return this.logger.debug("OpenID: no refresh token"),!1;let e;try{e=this.getTokenPayload(t)}catch{return!0}return!(e.nbf&&1e3*e.nbf-Date.now()>this.REFRESH_TOKEN_TOLERANCE||e.exp&&Date.now()-1e3*e.exp>this.REFRESH_TOKEN_TOLERANCE||!e.iat)}saveTokens(t,e){t.refresh_token?this.openidStorageService.setRefreshToken(t.refresh_token):this.openidStorageService.clearRefreshToken(),t.access_token?this.openidStorageService.setAccessToken(t.access_token):this.openidStorageService.clearAccessToken(),t.id_token?this.openidStorageService.setIdToken(t.id_token):this.openidStorageService.clearIdToken(),this.openidStorageService.setTokenType(e.tokenType),this.logger.debug("OpenID: saved tokens"),this.openidStorageService.clearPkceState(),this.openidStorageService.clearPkceCodeVerifier()}authHeaderGraphDB(){return this.openidStorageService.getTokenType().getValue()===Ur.ID?"Bearer "+this.getTokenByType(Ur.ID):"Bearer "+this.getTokenByType(Ur.ACCESS)}getTokenHeader(t){try{const e=Br.pj.jws.JWS.readSafeJSONString((0,Br.cV)(t.split(".")[0]));if(e)return e}catch(t){throw this.logger.error("OpenID: token header decode failed",t),new kr}}getTokenPayload(t){try{const e=Br.pj.jws.JWS.readSafeJSONString((0,Br.cV)(t.split(".")[1]));if(e)return e}catch(t){throw this.logger.debug("Token payload decode error",t),new kr}}verifyToken(t,e){const r=this.getTokenByType(t);if(!r)return!1;let i;try{i=this.getTokenHeader(r)}catch{return!1}if(!i.kid)return t!==Ur.ID?i.error?(this.logger.debug(`OpenID: token ${t} is not a JWT token (token considered valid)`),!0):(this.logger.debug(`OpenID: invalid token ${t} (token is empty)`),!1):(this.logger.debug("OpenID: invalid token id (not a JWT token)"),!1);const s=this.securityContextService.getJsonWebKeysSet()?.[i.kid];if(!s)return this.logger.debug("OpenID: no key to verify JWT token (token considered invalid)"),!1;const n=Br.ym.getKey(s),o={alg:[i.alg],iss:[e.issuer]};return"id"===t?(o.aud=[e.clientId,e.issuer],o.nonce=[this.openidStorageService.getNonce().getValue()||""]):"access"===t&&(o.aud=[e.tokenAudience],o.iss=[e.tokenIssuer]),Br.pj.jws.JWS.verifyJWT(r,n,o)}clearTokens(){this.openidStorageService.clearTokens()}getTokenByType(t){return t===Ur.ID?this.openidStorageService.getIdToken().getValue():t===Ur.ACCESS?this.openidStorageService.getAccessToken().getValue():t===Ur.REFRESH?this.openidStorageService.getRefreshToken().getValue():null}}class Vr{static pkceChallengeFromVerifier(t){const e=new Br.pj.crypto.MessageDigest({alg:"sha256",prov:"cryptojs"});return(0,Br.wV)(e.digestString(t))}static parseQueryString(t){const e={access_token:null,code:null,id_token:null,state:null};let r;if(t){const t=c.getLocationHash().substring(1);r=new URLSearchParams(t)}else r=new URLSearchParams(c.getLocationQueryParams());return 0===r.size||Object.keys(e).forEach(t=>{const i=r.get(t);i&&(e[t]=decodeURIComponent(i))}),e}}class Mr extends Hr{constructor(t){super(`Invalid OpenID authentication flow: ${t}`)}}class Kr extends Hr{constructor(){super("Missing authorization code")}}let qr=function(t){return t.CODE="code",t.CODE_NO_PKCE="code_no_pkce",t.IMPLICIT="implicit",t}({}),Gr=function(t){return t.CODE="code",t.TOKEN="token id_token",t}({});class $r{items=[];enqueue(t){this.items.push(t)}dequeue(){return this.items.shift()}dequeueAll(){const t=[...this.items];return this.items=[],t}peek(){return this.items[0]}peekAll(){return[...this.items]}isEmpty(){return 0===this.items.length}size(){return this.items.length}}class Wr{notificationAddedCallbackFunctions=[];notifications=new $r;addNotification(t){this.notifications.enqueue(t),this.notifyAllNotificationAdded(t)}removeAllNotifications(){return this.notifications.dequeueAll()}onNotificationAdded(t){return t&&!this.notifications.isEmpty()&&this.notifyNotificationAdded(t),this.notificationAddedCallbackFunctions.push(t),()=>{this.notificationAddedCallbackFunctions=this.notificationAddedCallbackFunctions.filter(e=>e!==t)}}notifyNotificationAdded(t){this.notifications.peekAll().forEach(e=>t(e))}notifyAllNotificationAdded(t){for(const e of this.notificationAddedCallbackFunctions)e(t)}}function zr(t){wt(Wr).addNotification(t)}class Yr{logger=Pt.logger;tokenUtils=wt(jr);openidStorageService=wt(_r);async handleAuthorizationCode(t,e,r){if(!e.code)throw this.logger.error("OpenID: Missing authorization code"),new Kr;const i=`${E()}`;if(t.authFlow===qr.CODE)await this.handlePkceFlow(e,i,r);else{if(t.authFlow!==qr.CODE_NO_PKCE)throw this.logger.error("OpenID: Invalid OpenID authentication flow"),new Mr(t.authFlow);await this.handleCodeNoPkceFlow(e.code,i,r)}return!0}async handleImplicitFlow(t,e){this.tokenUtils.saveTokens(e,t)}checkExistingAuthentication(t){const e=this.tokenUtils.hasValidIdToken(t),r=this.tokenUtils.hasValidRefreshToken();return e||r}storeCodeFlowData(t){this.openidStorageService.setPkceState(t),this.openidStorageService.setPkceCodeVerifier(Zt.generateRandomString(28))}getCodeChallengeForCodeFlow(){const t=this.openidStorageService.getPkceCodeVerifier().getValue();if(!t)throw new Hr("Missing PKCE code verifier");return Vr.pkceChallengeFromVerifier(t)}async handlePkceFlow(t,e,r){const i=this.openidStorageService.getPkceState().getValue();if(i!==t.state)throw this.logger.debug(`OpenID: PKCE state mismatch ${i} != ${t.state}`),zr(Ne.error("openid.errors.invalid_pkce_state").withTitle("openid.errors.title").withParameters({[_e.SHOULD_TOAST]:!0})),new Hr(`PKCE state mismatch ${i} != ${t.state}`);if(!t.code)throw new Kr;const s=this.openidStorageService.getPkceCodeVerifier().getValue();await r(t.code,e,s)}async handleCodeNoPkceFlow(t,e,r){await r(t,e)}}class Xr extends Hr{constructor(){super("OpenID security configuration is not available")}}class Jr extends nr{securityContextService=wt(Nr);OAUTH_IDENTITY_DOMAIN_NAME_HEADER="X-OAuth-Identity-Domain-Name";getJSONWebKeySet(){return this.get(this.getJWKSEndpoint(),{headers:this.getDomainHeaders()})}refreshToken(t){const e={grant_type:"refresh_token",client_id:this.getClientId(),refresh_token:t},r={...this.getDomainHeaders(),"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},i=this.transformURLEncodedRequest(e);return this.post(this.getTokensEndpoint(),{body:i,headers:r})}getTokens(t,e,r){const i={grant_type:"authorization_code",client_id:this.getClientId(),redirect_uri:t,code:e};r&&(i.code_verifier=r);const s={...this.getDomainHeaders(),"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},n=this.transformURLEncodedRequest(i);return this.post(this.getTokensEndpoint(),{body:n,headers:s})}transformURLEncodedRequest(t){const e=new URLSearchParams;return Object.entries(t).forEach(([t,r])=>{e.append(t,r)}),e}getClientId(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.clientId;throw new Xr}getJWKSEndpoint(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.openIdKeysUri;throw new Xr}getTokensEndpoint(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.openIdTokenUrl;throw new Xr}getDomainHeaders(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;return t?.oracleDomain?{[this.OAUTH_IDENTITY_DOMAIN_NAME_HEADER]:t.oracleDomain}:{}}}class Qr{securityContextService=wt(Nr);buildLoginUrl(t,e,r){const i=this.getResponseType(),s=[...this.buildBaseParameters(i,r),...this.buildFlowSpecificParameters(t,e),...this.buildAdditionalParameters()];return`${this.getOpenIdConfig().oidcAuthorizationEndpoint}?${s.join("&")}`}buildLogoutUrl(t){const e=this.getOpenIdConfig(),r=e.clientId;return`${e.openIdEndSessionUrl}?client_id=${encodeURIComponent(r)}&post_logout_redirect_uri=${encodeURIComponent(t)}`}getOpenIdConfig(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(!t)throw new Xr;return t}getResponseType(){const t=this.getOpenIdConfig().authFlow;if(t===qr.CODE||t===qr.CODE_NO_PKCE)return Gr.CODE;if(t===qr.IMPLICIT)return Gr.TOKEN;throw new Mr(t)}buildBaseParameters(t,e){return[`response_type=${encodeURIComponent(t)}`,`scope=${encodeURIComponent(this.getScope())}`,`client_id=${encodeURIComponent(this.getOpenIdConfig().clientId)}`,`redirect_uri=${encodeURIComponent(e)}`]}buildFlowSpecificParameters(t,e){const r=this.getOpenIdConfig().authFlow,i=[];return r===qr.CODE?i.push(`state=${encodeURIComponent(t)}`,`code_challenge=${encodeURIComponent(e)}`,"code_challenge_method=S256"):r===qr.IMPLICIT&&i.push(`nonce=${encodeURIComponent(t)}`),i}buildAdditionalParameters(){const t=this.getOpenIdConfig(),e=[];return t.oracleDomain&&e.push(`domain=${encodeURIComponent(t.oracleDomain)}`),t.authorizeParameters&&e.push(t.authorizeParameters),e}getScope(){const t=["openid"];this.getOpenIdConfig().supportsOfflineAccess&&t.push("offline_access");const e=this.getOpenIdConfig().extraScopes;return e&&t.push(e),t.join(" ")}}class Zr{DEFAULT_REFRESH_CONFIGURATION={refreshAheadMs:6e4,minDelayMs:1e3};logger=Pt.logger;tokenUtils=wt(jr);openidStorageService=wt(_r);async setupTokensRefresh(t){const e=this.openidStorageService.getRefreshToken().getValue();if(!e||!this.shouldSetupRefresh(e))return this.clearRefreshTimer(),void this.logger.debug("OpenID: no valid refresh token");const r=this.openidStorageService.getAccessToken().getValue(),i=this.calculateRefreshDelay(r);i<this.DEFAULT_REFRESH_CONFIGURATION.minDelayMs?(this.logger.debug("OpenID: tokens need refresh now, "+i),await this.executeImmediateRefresh(e,t)):(this.logger.debug("OpenID: scheduling token refresh in",i/1e3,"seconds"),this.scheduleTokenRefresh(e,i,t))}clearRefreshTimer(){this.refreshTokensTimer&&(c.getWindow().clearTimeout(this.refreshTokensTimer),delete this.refreshTokensTimer)}shouldSetupRefresh(t){return!(!t||!this.tokenUtils.hasValidRefreshToken())}calculateRefreshDelay(t){let e;try{e=this.tokenUtils.getTokenPayload(t)}catch{return 0}return!e.exp||e.exp<=0?0:1e3*e.exp-Date.now()-this.DEFAULT_REFRESH_CONFIGURATION.refreshAheadMs}async executeImmediateRefresh(t,e){this.clearRefreshTimer(),this.logger.debug("OpenID: tokens will refresh now"),await e(t)}scheduleTokenRefresh(t,e,r){this.clearRefreshTimer(),this.refreshTokensTimer=c.getWindow().setTimeout(async()=>{this.logger.debug("OpenID: tokens will refresh now, "+e),await r(t)},e)}}class ti extends Je{jwtKey="jwt";authenticatedKey="authenticated";NAMESPACE="auth";set(t,e){this.storeValue(t,e)}getAuthToken(){return this.get(this.jwtKey)}setAuthenticated(t){this.storeValue(this.authenticatedKey,t?.toString()||"")}isAuthenticated(){return"true"===this.get(this.authenticatedKey).getValue()}setAuthToken(t){this.setAuthenticated(!0),this.set(this.jwtKey,t)}clearAuthToken(){this.remove(this.jwtKey)}isGDBorOpenIDToken(){const t=this.getAuthToken().getValue();return!(!t||!t.startsWith("GDB")&&!t.startsWith("Bearer"))}}class ei{constructor(t){this.notify=t}}class ri{eventSubscribers=new Map;emit(t){const e=this.eventSubscribers.get(t.NAME);e&&e.forEach(e=>{e.notify(n.deepCopy(t.payload))})}subscribe(t,e){const r=new ei(e),i=this.eventSubscribers.get(t);return i?i.push(r):this.eventSubscribers.set(t,[r]),()=>this.unsubscribe(t,r)}unsubscribe(t,e){const r=this.eventSubscribers.get(t);if(r){const i=r.indexOf(e);-1!==i&&r.splice(i,1),0===r.length&&this.eventSubscribers.delete(t)}}}class ii{logger=Pt.logger;openIdRestService=wt(Jr);openidStorageService=wt(_r);securityContextService=wt(Nr);tokenUtils=wt(jr);authenticationStorageService=wt(ti);authFlowHandler=wt(Yr);tokenRefreshManager=wt(Zr);openIdUrlBuilder=wt(Qr);getJSONWebKeySet(){return this.openIdRestService.getJSONWebKeySet()}getTokens(t,e,r){return this.openIdRestService.getTokens(t,e,r)}async refreshTokens(t){const e=this.getOpenIdConfig();try{const r=await this.openIdRestService.refreshToken(t);this.logger.debug("OpenID: refreshed tokens"),this.tokenUtils.saveTokens(r,e),this.authenticationStorageService.setAuthToken(this.tokenUtils.authHeaderGraphDB()),await this.setupTokensRefresh()}catch(t){this.logger.debug("OpenID: could not refresh tokens",t);let e="unknown error";t instanceof je&&(e=t.data?.error_description??"unknown error"),zr(Ne.error("openid.errors.cannot_refresh_token").withTitle("openid.errors.title").withParameters({error:e,[_e.SHOULD_TOAST]:!0})),this.softLogout(),wt(ri).emit(new z)}}async initializeOpenId(){const t=this.getOpenIdConfig();return await this.initializeJsonWebKeySet(),this.authFlowHandler.checkExistingAuthentication(t)?(await this.setupTokensRefresh(),!0):this.handleAuthenticationFlow()}async initializeJsonWebKeySet(){const t=await this.getJSONWebKeySet(),e=this.buildKeySet(t.keys);this.securityContextService.updateJsonWebKeysSet(e)}setupCodeFlow(t,e){this.authFlowHandler.storeCodeFlowData(t);const r=this.authFlowHandler.getCodeChallengeForCodeFlow(),i=this.getLoginUrl(t,r,e);this.redirectToUrl(i)}setupCodeNoPkceFlow(t,e){this.openidStorageService.clearPkceCodeVerifier();const r=this.getLoginUrl(t,"",e);this.redirectToUrl(r)}setupImplicitFlow(t,e){this.openidStorageService.setNonce(t);const r=this.getLoginUrl(t,"",e);this.redirectToUrl(r)}async setupTokensRefresh(){await this.tokenRefreshManager.setupTokensRefresh(this.refreshTokens.bind(this))}clearAuthentication(){this.authenticationStorageService.clearAuthToken(),this.tokenUtils.clearTokens(),this.tokenRefreshManager.clearRefreshTimer()}logout(t=!1){t?this.hardLogout(E()):this.softLogout()}getOpenIdConfig(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(!t)throw new Xr;return t}buildKeySet(t){const e={};return t.forEach(t=>{e[t.kid]=t}),e}async handleAuthenticationFlow(){const t=this.getOpenIdConfig();this.clearAuthentication();const e=t.authFlow===qr.IMPLICIT,r=Vr.parseQueryString(e);return r.code?this.authFlowHandler.handleAuthorizationCode(t,r,this.exchangeTokensForCode.bind(this)):!!r.id_token&&(await this.authFlowHandler.handleImplicitFlow(t,r),await this.setupTokensRefresh(),!0)}async exchangeTokensForCode(t,e,r){const i=this.getOpenIdConfig();try{const s=await this.getTokens(e,t,r);this.logger.debug("OpenID: successfully retrieved tokens"),this.tokenUtils.saveTokens(s,i),await this.setupTokensRefresh()}catch(t){throw this.logger.error("OpenID: Cannot retrieve token after login",{error:t}),zr(Ne.error("openid.errors.cannot_retrieve_token").withTitle("openid.errors.title").withParameters({error:t instanceof Error?t.message:String(t),[_e.SHOULD_TOAST]:!0})),new Hr("Cannot retrieve token after login")}}softLogout(){this.clearAuthentication()}hardLogout(t){this.softLogout();const e=this.getLogoutUrl(t);this.redirectToUrl(e)}redirectToUrl(t){c.setLocationHref(t)}getLoginUrl(t,e,r){return this.openIdUrlBuilder.buildLoginUrl(t,e,r)}getLogoutUrl(t){return this.openIdUrlBuilder.buildLogoutUrl(t)}}let si=function(t){return t.GDB_TOKEN="GDB_TOKEN",t.OPENID="OPENID",t.EXTERNAL="EXTERNAL",t.NO_SECURITY="NO_SECURITY",t}({});class ni{logger=Pt.logger;securityService=wt(mi);securityContextService=wt(Nr);type=si.NO_SECURITY;initialize(){return this.fetchAuthenticatedUser().then(t=>(this.securityContextService.updateAuthenticatedUser(t),!0)).catch(t=>(this.logger.error("Could not load authenticated user",t),!1))}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedAdminUser()}login(){return this.fetchAuthenticatedUser()}logout(){return Promise.resolve()}isAuthenticated(){return!!this.securityContextService.getAuthenticatedUser()}isExternal(){return!1}}class oi extends Hr{constructor(){super("OpenID user has no access rights")}}class ai{logger=Pt.logger;securityService=wt(mi);authenticationStorageService=wt(ti);authenticationService=wt(Ti);securityContextService=wt(Nr);openIdService=wt(ii);openidStorageService=wt(_r);tokenUtils=wt(jr);type=si.OPENID;constructor(){this.setupConfigurationListener()}async initialize(){this.loadSecurityConfiguration(),this.validateConfiguration();try{const t=await this.openIdService.initializeOpenId();t&&await this.handleSuccessfulAuthentication();const e=this.openidStorageService.getReturnUrl().getValue();return this.openidStorageService.clearReturnUrl(),t&&e&&f(e),t}catch(t){return this.handleAuthenticationError(t),!1}}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}login(){this.validateConfiguration();const t=this.getReturnUrl(),e=Zt.generateRandomString(28),r=this.openIdSecurityConfig.authFlow;return this.executeAuthFlow(r,e,t),new Promise(()=>{})}logout(){return this.openIdService.logout(),Promise.resolve()}isAuthenticated(){const t=this.authenticationStorageService.getAuthToken().getValue();return!this.authenticationService.isSecurityEnabled()||null!==t}isExternal(){return!1}setupConfigurationListener(){this.securityContextService.onSecurityConfigChanged(t=>{t&&(this.openIdSecurityConfig=t.openidSecurityConfig)})}loadSecurityConfiguration(){this.openIdSecurityConfig=this.securityContextService.getSecurityConfig()?.openidSecurityConfig}validateConfiguration(){if(!this.openIdSecurityConfig)throw new Xr}async handleSuccessfulAuthentication(){this.logger.debug("OpenID: authentication initialized"),this.authenticationStorageService.setAuthToken(this.tokenUtils.authHeaderGraphDB());try{await this.loadAndSetAuthenticatedUser()}catch(t){throw this.logger.debug("Could not load authenticated user",t),zr(Ne.error("openid.errors.user_no_access").withTitle("openid.errors.title").withParameters({[_e.SHOULD_TOAST]:!0})),new oi}}async loadAndSetAuthenticatedUser(){const t=await this.fetchAuthenticatedUser();t&&this.securityContextService.updateAuthenticatedUser(t)}handleAuthenticationError(t){this.authenticationStorageService.clearAuthToken(),this.logger.debug("OpenID: not logged or login error"),this.logger.error("Could not initialize OpenID authentication",t),this.openIdService.clearAuthentication()}getReturnUrl(){return`${E()}`}executeAuthFlow(t,e,r){switch(t){case qr.CODE:this.openIdService.setupCodeFlow(e,r);break;case qr.CODE_NO_PKCE:this.openIdService.setupCodeNoPkceFlow(e,r);break;case qr.IMPLICIT:this.openIdService.setupImplicitFlow(e,r);break;default:throw this.logger.debug(`OpenID: Invalid OpenID authentication flow: ${t}`),zr(Ne.error("openid.errors.unknown_flow").withTitle("openid.errors.title").withParameters({authFlow:t,[_e.SHOULD_TOAST]:!0})),new Mr(t)}}}class hi extends Lr{constructor(){super("Missing token in authentication header")}}const ui=t=>new ot({username:t.username,password:t.password,authorities:new rt(t.authorities),appSettings:new it(t.appSettings),external:t.external});class ci extends nr{SECURITY_ENDPOINT="rest/security";LOGIN_ENDPOINT="rest/login";SECURITY_USER_ENDPOINT=`${this.SECURITY_ENDPOINT}/users`;SECURITY_FREE_ACCESS_ENDPOINT=`${this.SECURITY_ENDPOINT}/free-access`;loginGdbToken(t,e){return this.post(this.LOGIN_ENDPOINT,{body:{username:t,password:e},responseType:"response"})}getSecurityConfig(){return this.get(`${this.SECURITY_ENDPOINT}/all`)}getAuthenticatedUser(){return this.get(`${this.SECURITY_ENDPOINT}/authenticated-user`)}getAdminUser(){return this.get(`${this.SECURITY_USER_ENDPOINT}/admin`)}getFreeAccess(){return this.get(this.SECURITY_FREE_ACCESS_ENDPOINT)}setFreeAccess(t){return this.post(this.SECURITY_FREE_ACCESS_ENDPOINT,{body:t})}}class li extends nr{SECURITY_ENDPOINT="rest/security";SECURITY_USER_ENDPOINT=`${this.SECURITY_ENDPOINT}/users`;getUser(t){return this.get(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`)}getUsers(){return this.get(`${this.SECURITY_USER_ENDPOINT}`)}createUser(t,e){return this.post(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`,{body:e})}updateUser(t,e){return this.put(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`,{body:e})}updateCurrentUser(t,e){return this.patch(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`,{body:e})}deleteUser(t){return this.delete(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`)}}class di{constructor(t){this.password=t?.password,this.grantedAuthorities=t?.grantedAuthorities??[],this.appSettings=t?.appSettings??{DEFAULT_SAMEAS:!0,DEFAULT_INFERENCE:!0,EXECUTE_COUNT:!0,IGNORE_SHARED_QUERIES:!1,DEFAULT_VIS_GRAPH_SCHEMA:!0}}}const pi=t=>new di({password:t.password,grantedAuthorities:t.authorities.toGraphdbAuthoritiesModel(),appSettings:t.appSettings.toJSON()}),gi=t=>new nt({username:t.username,authorities:new rt(t.grantedAuthorities),appSettings:new it({EXECUTE_COUNT:t.appSettings.EXECUTE_COUNT,DEFAULT_INFERENCE:t.appSettings.DEFAULT_INFERENCE,DEFAULT_SAMEAS:t.appSettings.DEFAULT_SAMEAS,DEFAULT_VIS_GRAPH_SCHEMA:t.appSettings.DEFAULT_VIS_GRAPH_SCHEMA,IGNORE_SHARED_QUERIES:t.appSettings.IGNORE_SHARED_QUERIES,COOKIE_CONSENT:t.appSettings.COOKIE_CONSENT?new Lt(t.appSettings.COOKIE_CONSENT):void 0}),dateCreated:new Date(t.dateCreated),gptThreads:t.gptThreads,external:t.external});class fi{static ADMIN_USERNAME="admin";usersRestService=wt(li);getUser(t){return this.usersRestService.getUser(t).then(t=>gi(t))}getUsers(){return this.usersRestService.getUsers().then(t=>t.map(t=>gi(t)))}getAdminUser(){return this.usersRestService.getUser(fi.ADMIN_USERNAME).then(t=>gi(t))}createUser(t){const e=pi(t);return this.usersRestService.createUser(t.username,e)}updateUser(t){const e=pi(t);return this.usersRestService.updateUser(t.username,e)}deleteUser(t){return this.usersRestService.deleteUser(t)}updateCurrentUser(t){const e=pi(t);return this.usersRestService.updateCurrentUser(t.username,e)}}class mi{securityRestService=wt(ci);securityContextService=wt(Nr);usersService=wt(fi);updateAuthenticatedUser(t){return this.usersService.updateCurrentUser(t)}getSecurityConfig(){return this.securityRestService.getSecurityConfig().then(t=>new lt(t))}getFreeAccess(){return this.securityRestService.getFreeAccess().then(function(t){return ct(t)})}setFreeAccess(t,e){const r={enabled:t};if(t){if(!e)throw new Error("Free access settings must be provided when enabling free access");r.authorities=Z(e?.authorities),r.appSettings={...e?.appSettings}}return this.securityRestService.setFreeAccess(r).then(()=>this.getSecurityConfig()).then(t=>{this.securityContextService.updateSecurityConfig(t)})}getAuthenticatedUser(){return this.securityRestService.getAuthenticatedUser().then(t=>ui(t))}getAuthenticatedAdminUser(){return this.usersService.getAdminUser().then(t=>ot.fromUser(t))}isPasswordLoginEnabled(){return this.securityContextService.getSecurityConfig()?.passwordLoginEnabled??!1}isOpenIDEnabled(){return this.securityContextService.getSecurityConfig()?.openIdEnabled??!1}loginGdbToken(t,e){return this.securityRestService.loginGdbToken(t,e)}}class yi{securityService=wt(mi);logger=Pt.logger;authStorageService=wt(ti);fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}async login(t){const{username:e,password:r}=t,i=await this.securityService.loginGdbToken(e,r),s=this.getAuthenticationHeader(i),n=ui(i.data);if(!s)throw new hi;return this.authStorageService.setAuthToken(s),n}getAuthenticationHeader(t){return t.headers.authorization}}class vi extends yi{securityContextService=wt(Nr);type=si.GDB_TOKEN;initialize(){const t=!!this.authStorageService.getAuthToken().getValue();return t?this.isCurrentRouteLogin()?Promise.resolve(t):Promise.resolve(!!this.securityContextService.getAuthenticatedUser()):Promise.resolve(!1)}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}logout(){return this.authStorageService.clearAuthToken(),Promise.resolve()}isAuthenticated(){return null!==this.authStorageService.getAuthToken().getValue()}isExternal(){return!1}isCurrentRouteLogin(){return"login"===w()}}class Si extends Lr{constructor(){super()}}class Ei extends yi{securityContextService=wt(Nr);type=si.EXTERNAL;initialize(){return Promise.resolve(!0)}isAuthenticated(){return!!this.securityContextService.getAuthenticatedUser()}logout(){throw new Si}isExternal(){return!0}}class xi{securityContextService=wt(Nr);authStorageService=wt(ti);resolveStrategy(t){return this.authStrategy=this._resolveStrategy(t),this.authStrategy}getAuthStrategy(){return this.authStrategy}_resolveStrategy(t){return t.isEnabled()?t.openIdEnabled?new ai:this.securityContextService.getAuthenticatedUser()&&!this.authStorageService.isGDBorOpenIDToken()?new Ei:new vi:new ni}}class wi{constructor(t,e){this.setRegex(t),this.setRouteParams(e)}getRegex(){return this.regex}setRegex(t){return this.regex=t,this}getRouteParams(){return this.routeParams}setRouteParams(t){return this.routeParams=t,this}}class Ai{routePlugins=c.getPluginRegistry().get(Te.NAME);getActiveRoute(t){const e=this.routePlugins.find(e=>this.routeToRegex(e.url).getRegex().test(t));return e?new be(e):void 0}routeToRegex(t){const e=[],r=t.replace(/([().])/g,"\\$1").replace(/(\/)?:(\w+)(\*\?|[?*])?/g,function(t,r,i,s){const n="?"===s||"*?"===s,o="*"===s||"*?"===s;return e.push(i),r=r||"",(n?"(?:"+r:r+"(?:")+(o?"(.+?)":"([^/]+)")+(n?"?)?":")")}).replace(/([/$*])/g,"\\$1");return new wi(new RegExp("^"+r+"(?:[?#]|$)"),new T(e))}}class bi{securityContextService=wt(Nr);repositoryStorageService=wt(fr);repositoryContextService=wt(mr);repositoryAuthorityService=wt(yr);hasFreeAccess(){const t=this.getSecurityConfig();return!(!t?.isEnabled()||!t?.freeAccess?.enabled)}initializeFreeAccess(){const t=this.getSecurityConfig();if(t?.isEnabled()&&t?.isFreeAccessEnabled()){const e=(new ot).setAuthorities(t.freeAccess.authorities).setAppSettings(t.freeAccess.appSettings);this.securityContextService.updateAuthenticatedUser(e)}}initializeOverrideAuth(){const t=this.getSecurityConfig();if(!t?.isEnabled()&&t?.hasOverrideAuth()){const e=new ot;e.username="overrideauth",e.setAuthorities(t.overrideAuth.authorities),e.setAppSettings(t.overrideAuth.appSettings),this.securityContextService.updateAuthenticatedUser(e)}}isAdmin(){return this.hasRole(J.ROLE_ADMIN)}isRepoManager(){return this.hasRole(J.ROLE_REPO_MANAGER)}hasRole(t){const e=this.getSecurityConfig(),r=this.getAuthenticatedUser();if(!t||!e?.isEnabled()&&!e?.hasOverrideAuth())return!0;if(!(Object.keys(r||{}).length>0))return!1;const i=J.IS_AUTHENTICATED_FULLY===t,s=!!r?.authorities.hasAuthority(t);return i||s}canReadRepo(t){if(!t||""===t.id)return!1;const e=this.getSecurityConfig(),r=this.getAuthenticatedUser();return!e?.isEnabled()||!!r&&(!!this.isAdminOrRepoManager()||!this.repositoryAuthorityService.isSystemRepository(t)&&this.hasBaseRights(pt.READ,t))}canWriteRepo(t){if(!t||""===t.id)return!1;const e=this.getSecurityConfig(),r=this.getAuthenticatedUser();return!e?.isEnabled()&&!e?.hasOverrideAuth()||!!r&&(!!this.isAdminOrRepoManager()||!this.repositoryAuthorityService.isSystemRepository(t)&&this.hasBaseRights(pt.WRITE,t))}canReadGqlRepo(t){return!(!t||""===t.id)&&this.hasGraphqlAuthority(pt.READ,t)}canWriteGqlRepo(t){return!(!t||""===t.id)&&this.hasGraphqlAuthority(pt.WRITE,t)}hasGqlRights(t){return this.canReadGqlRepo(t)||this.canWriteGqlRepo(t)}hasGraphqlRightsOverCurrentRepo(){const t=this.repositoryStorageService.getRepositoryReference(),e=this.repositoryContextService.findRepository(t);return this.canReadGqlRepo(e)||this.canWriteGqlRepo(e)}hasAuthority(){if(this.isAdminOrRepoManager())return!0;const t=wt(Ai).getActiveRoute(S());if(!t)return!1;if(!t.allowAuthorities)return!0;if(!wt(fr).getRepositoryReference()?.id)return!0;const e=this.getAuthenticatedUser();if(!e)return!0;if(t.allowAuthorities.length){const r=this.resolveAuthorities(t.allowAuthorities);return r.some(t=>e.authorities.hasAuthority(t))||r.some(t=>e.authorities.hasWildcardAuthority(t))}return!0}updatePermissions(){const t=this.securityContextService.getRestrictedPages(),e=this.securityContextService.getAuthenticatedUser(),r=this.isAdmin(),i=c.getWindow().PluginRegistry.get(Te.NAME),s=c.getWindow().PluginRegistry.get(Ce.NAME);i.forEach(i=>{const n=s.flatMap(t=>t.items).filter(t=>t.role?.startsWith("ROLE_")).find(t=>i.url.includes(t.href));if(!n)return;const o=!r&&!e?.authorities.hasAuthority(n.role??"");t.setPageRestriction(i.url,o)}),this.securityContextService.updateRestrictedPages(t)}resolveAuthorities(t){if(!t)return[];const e=wt(fr).getRepositoryReference();return e?.id?[...t.map(t=>t.replace("{repoId}",e.id)),...t.map(t=>t.replace("{repoId}","*"))]:t}getSecurityConfig(){return wt(Nr).getSecurityConfig()}getAuthenticatedUser(){return wt(Nr).getAuthenticatedUser()}hasBaseRights(t,e){const r=this.repositoryAuthorityService.getLocationSpecificId(e),i=this.repositoryAuthorityService.getCurrentRepoAuthority(t,r),s=this.repositoryAuthorityService.getOverallRepoAuthority(t),n=this.getAuthenticatedUser();return!!(n?.authorities.hasAuthority(i)||n?.authorities.hasAuthority(s)||n?.authorities.hasWildcardAuthority(i))}hasGraphqlAuthority(t,e){const r=this.securityContextService.getAuthenticatedUser();if(!r)return!1;const i=this.repositoryAuthorityService.getLocationSpecificId(e),s=this.repositoryAuthorityService.getCurrentGqlRepoAuthority(t,i),n=this.repositoryAuthorityService.getOverallGqlRepoAuthority(t);return r.authorities.hasAuthority(s)||r.authorities.hasAuthority(n)||r.authorities.hasWildcardAuthority(s,!0)}isAdminOrRepoManager(){return this.hasRole(J.ROLE_ADMIN)||this.hasRole(J.ROLE_REPO_MANAGER)}}class Ii extends Lr{constructor(){super("Authentication strategy not set")}}class Ci extends Ct{PREVIOUS_ROUTE="previousRoute";RETURN_URL="returnUrl";updatePreviousRoute(t){this.updateContextProperty(this.PREVIOUS_ROUTE,t)}getPreviousRoute(){let t=this.getContextPropertyValue(this.PREVIOUS_ROUTE);return t?.endsWith("#")&&(t=t.slice(0,-1)),t}updateReturnUrl(t){this.updateContextProperty(this.RETURN_URL,t)}getReturnUrl(){return this.getContextPropertyValue(this.RETURN_URL)}clearReturnUrl(){this.updateContextProperty(this.RETURN_URL,void 0)}}class Ti{eventService=wt(ri);authStrategyResolver=wt(xi);authorizationService=wt(bi);securityContextService=wt(Nr);authenticationStorageService=wt(ti);navigationContextService=wt(Ci);isAuthenticationStrategySet(){return!!this.authStrategyResolver.getAuthStrategy()}getCurrentUser(){return this.getAuthenticationStrategy().fetchAuthenticatedUser()}login(t,e){return this.getAuthenticationStrategy().login({username:t,password:e}).then(t=>{this.securityContextService.updateIsLoggedIn(!0),this.securityContextService.updateAuthenticatedUser(t),this.updateStrategy(),this.eventService.emit(new Y)})}logout(){const t=this.getAuthenticationStrategy();this.authenticationStorageService.setAuthenticated(!1);const e=S();return t.logout().then(()=>{v()||this.navigationContextService.updateReturnUrl(e),this.securityContextService.updateIsLoggedIn(!1),this.authorizationService.hasFreeAccess()?(this.authorizationService.initializeFreeAccess(),this.eventService.emit(new Y)):(f("login"),this.eventService.emit(new z))})}isLoggedIn(){const t=this.securityContextService.getIsLoggedIn()??!1,e=wt(Nr).getAuthenticatedUser();return this.isSecurityEnabled()&&t&&!!e}isAuthenticated(){return this.getAuthenticationStrategy().isAuthenticated()}isExternalUser(){return this.getAuthenticationStrategy().isExternal()}isSecurityEnabled(){return!!this.getSecurityConfig()?.isEnabled()}getSecurityConfig(){return wt(Nr).getSecurityConfig()}updateStrategy(){const t=this.getSecurityConfig();t&&this.authStrategyResolver.resolveStrategy(t)}getAuthenticationStrategy(){const t=this.authStrategyResolver.getAuthStrategy();if(!t)throw new Ii;return t}}class Ri extends Lr{constructor(t){super(t)}}class Fi{static DEFAULT_PATH="/";static MILLISECONDS_PER_DAY=864e5;path=Fi.DEFAULT_PATH;constructor(t,e,r={}){this.key=encodeURIComponent(t),this.value=encodeURIComponent(e),this.setOptions(r)}setOptions(t){const{expiration:e,path:r,domain:i,secure:s,httpOnly:n,sameSite:o}=t;return e&&this.setExpiration(e),this.setPath(r),i&&this.setDomain(i),s&&this.setSecure(),n&&this.setHttpOnly(),o&&this.setSameSite(o),this}setExpiration(t){if(!Number.isFinite(t))throw new Ri(`Invalid expiration value: ${t}`);const e=new Date(I.now()+t*Fi.MILLISECONDS_PER_DAY);return this.expires=e.toUTCString(),this}setPath(t){return this.path=t||Fi.DEFAULT_PATH,this}setDomain(t){return this.domain=t,this}setSecure(){return this.secure=!0,this}setHttpOnly(){return this.httpOnly=!0,this}setSameSite(t){return this.sameSite=t,this}build(){let t=`${this.key}=${this.value}`;return this.expires&&(t+=`; expires=${this.expires}`),t+=`; path=${this.path}`,this.domain&&(t+=`; domain=${this.domain}`),this.secure&&(t+="; secure"),this.httpOnly&&(t+="; HttpOnly"),this.sameSite&&(t+=`; SameSite=${this.sameSite}`),t}}class Pi{read(){return c.getDocument().cookie}write(t){c.getDocument().cookie=t}}class Di{constructor(t){this.store=t??new Pi}get(t){return this.parseCookies()[t]}set(t,e,r={}){this.store.write(new Fi(t,e,r).build())}remove(t){this.store.write(new Fi(t,"",{expiration:-1}).build())}getAll(){return this.parseCookies()}parseCookies(){const t={},e=this.store.read().split("; ");for(const r of e){const[e,i]=r.split("=");e&&i&&(t[decodeURIComponent(e)]=decodeURIComponent(i))}return t}}class Oi extends Je{NAMESPACE="tracking";COOKIE_CONSENT="cookieConsent";LEGACY_COOKIE_CONSENT="cookie-consent";logger=Pt.logger;set(t,e){this.storeValue(t,e)}setCookieConsent(t){this.set(this.COOKIE_CONSENT,JSON.stringify(t))}getCookieConsent(){this.migrateLegacyCookieConsent();const t=this.get(this.COOKIE_CONSENT).getAsJson();return t?new Lt(t):null}migrateLegacyCookieConsent(){const t=this.getAsJson(this.LEGACY_COOKIE_CONSENT);t&&(this.logger.info("Legacy cookie consent data found. Migrating to new key.",{legacyData:t}),this.setCookieConsent(t),this.remove(this.LEGACY_COOKIE_CONSENT,!1))}}const Ni="_wb";class _i{cookieService=wt(Di);timeProvider=I;get(){return this.cookieService.get(Ni)}set(t){const e=`WB1.${t}.${this.timeProvider.now()}`;this.cookieService.set(Ni,e,{expiration:400,sameSite:"Lax"})}setIfAbsent(t){this.get()||this.set(t)}remove(){this.cookieService.remove(Ni)}}class Bi{cookieService=wt(Di);isSettingUp=!1;setIfAbsent(){if(!this.isSettingUp&&!this.gtmScriptExists()&&(this.isSettingUp=!0,!this.gtmScriptExists())){c.getWindow().dataLayer&&(c.getWindow().dataLayer=[]);const t=c.getDocument().createElement("script");t.text="(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'}); var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:''; j.async=true; j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl; f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-WBP6C6Z4');",c.getDocument().getElementsByTagName("head")[0].appendChild(t)}}remove(){this.isSettingUp=!1,this.gtmScriptExists()&&this.removeGoogleAnalyticsScripts(),this.removeGoogleAnalyticsCookies()}removeGoogleAnalyticsCookies(){const t=this.cookieService.getAll();for(const[e]of Object.entries(t))e.startsWith("_ga")&&this.cookieService.remove(e)}removeGoogleAnalyticsScripts(){c.getWindow().dataLayer&&(c.getWindow().dataLayer=[]);const t=c.getDocument().getElementsByTagName("script"),e=/googletagmanager/i;for(let r=t.length-1;r>=0;r--)(t[r].src&&e.test(t[r].src)||e.test(t[r].text))&&t[r].remove();c.getWindow().google_tag_manager&&delete c.getWindow().google_tag_manager,c.getWindow().google_tag_data&&delete c.getWindow().google_tag_data}gtmScriptExists(){const t=c.getDocument().getElementsByTagName("script");return Array.from(t).some(t=>t.src?.includes("googletagmanager"))}}const Li="cookie-consent-changed-event";class Hi{securityService=wt(mi);securityContextService=wt(Nr);authenticationService=wt(Ti);authorizationService=wt(bi);trackingStorageService=wt(Oi);licenseService=wt(Fr);licenseContextService=wt(Rr);installationCookieService=wt(_i);googleAnalyticsCookieService=wt(Bi);eventEmitter=new ir;isTrackingAllowed(){return this.licenseService.isTrackableLicense()&&!c.getWindow().wbDevMode}acceptCookiePolicy(){const t=this.securityContextService.getAuthenticatedUser();if(t){this.updateUserCookieConsent(t),this.securityContextService.updateAuthenticatedUser(t);const e=this.securityContextService.getIsLoggedIn(),r=this.securityContextService.getSecurityConfig()?.isEnabled();if(r&&!e){const e=t.getCookieConsent();return e&&this.trackingStorageService.setCookieConsent(e),Promise.resolve().finally(()=>this.applyTrackingConsent())}return this.securityService.updateAuthenticatedUser(t.toUser()).then(()=>{this.eventEmitter.emit({NAME:Li,payload:t.appSettings.COOKIE_CONSENT})}).finally(()=>this.applyTrackingConsent())}return Promise.reject(new Error("No authenticated user found"))}getCookieConsent(){const t=this.securityContextService.getAuthenticatedUser();return t?.username?t.appSettings?.COOKIE_CONSENT?Lt.fromJSON(t.appSettings.COOKIE_CONSENT):Lt.NOT_ACCEPTED_WITH_TRACKING():this.authorizationService.hasFreeAccess()?this.trackingStorageService.getCookieConsent()||Lt.NOT_ACCEPTED_WITH_TRACKING():Lt.ACCEPTED_NO_TRACKING()}applyTrackingConsent(){if(!this.isTrackingAllowed())return this.cleanUpTracking(),Promise.resolve();{const t=this.getCookieConsent();if(t.hasChanged()&&!t.policyAccepted)return void this.cleanUpTracking();if(t.statistic){const t=this.licenseContextService.getLicenseSnapshot()?.installationId||"";this.installationCookieService.setIfAbsent(t)}else this.installationCookieService.remove();t.thirdParty?this.googleAnalyticsCookieService.setIfAbsent():this.googleAnalyticsCookieService.remove()}}cleanUpTracking(){this.installationCookieService.remove(),this.googleAnalyticsCookieService.remove()}updateUserCookieConsent(t){let e;e=t.appSettings?.COOKIE_CONSENT?new Lt(t.appSettings.COOKIE_CONSENT):new Lt({thirdParty:!0,statistic:!0}),e.policyAccepted=!0,e.updatedAt=Date.now(),t.appSettings.COOKIE_CONSENT=e}}class ki extends nr{MONITORING_ENDPOINT="rest/monitor";getOperations(t){return this.get(`${this.MONITORING_ENDPOINT}/repository/${t}/operations`)}deleteQuery(t,e){return this.delete(`${this.MONITORING_ENDPOINT}/repository/${e}/query?query=${encodeURIComponent(t)}`)}}const Ui={[Kt.CLUSTER_HEALTH]:0,[Kt.BACKUP_AND_RESTORE]:1,[Kt.IMPORT]:2,[Kt.QUERIES]:3,[Kt.UPDATES]:4},ji=t=>{if(!t?.status||!t.allRunningOperations)return new Vt({status:Ht.INFORMATION,allRunningOperations:new Mt([])});const e=t.allRunningOperations.map(t=>new zt({value:t.value||"",status:b(Ht,t.status),type:b(Kt,t.type)})),r=new Mt(e);return r.sort((t,e)=>Ui[t.type]-Ui[e.type]),new Vt({status:b(Ht,t.status),allRunningOperations:r})};class Vi{monitoringRestService=wt(ki);async getOperations(t){const e=await this.monitoringRestService.getOperations(t);return ji(e)}deleteQuery(t,e){return this.monitoringRestService.deleteQuery(t,e)}}class Mi extends Lr{constructor(){super("Class is not initializable")}}const Ki={[Oe.ERROR]:Qt.ERROR,[Oe.SUCCESS]:Qt.SUCCESS,[Oe.WARNING]:Qt.WARNING,[Oe.INFO]:Qt.INFO};class qi{constructor(){throw new Mi}static fromNotification(t){const e=this.notificationTypeToToastType(t.type);return new ee(e,t.code,{title:t.title,translationParams:this.toTranslationParams(t.parameters)})}static notificationTypeToToastType(t){return t?Ki[t]:Qt.INFO}static toTranslationParams(t){return t?Object.entries(t).map(([t,e])=>({key:t,value:String(e)})):[]}}class Gi{eventEmitter=new ir;notificationService=wt(Wr);constructor(){this.subscribeToNotificationEvents()}error(t,e){this.createToastElement(t,Qt.ERROR,e)}info(t,e){this.createToastElement(t,Qt.INFO,e)}success(t,e){this.createToastElement(t,Qt.SUCCESS,e)}warning(t,e){this.createToastElement(t,Qt.WARNING,e)}createToastElement(t,e,r){this.eventEmitter.emit({NAME:re,payload:new ee(e,t,r)})}subscribeToNotificationEvents(){this.notificationService.onNotificationAdded(t=>{if(t.parameters?.[_e.SHOULD_TOAST]){const e=qi.fromNotification(t);this.createToastElement(e.message,e.type,e.config)}})}}class $i extends nr{autocompleteRestPrefix="rest/autocomplete";search(t){return this.get(`${this.autocompleteRestPrefix}/query?q=${t}`)}enabled(){return this.get(`${this.autocompleteRestPrefix}/enabled`)}}class Wi{search(t){return xt.get($i).search(t).then(t=>(t=>{const e=t.suggestions.map(t=>new de({id:Zt.hashCode(`${t.type}-${t.value}-${t.description}`),type:b(pe,t.type),value:t.value,description:t.description}));return new le(new ce(e))})(t))}isAutocompleteEnabled(){return xt.get($i).enabled()}}class zi extends Je{ENABLED_KEY="enabled";NAMESPACE="autocomplete";set(t,e){this.storeValue(t,e)}isEnabled(){return"true"===this.get(this.ENABLED_KEY).value}setEnabled(t){this.set(this.ENABLED_KEY,t.toString())}}class Yi extends Ct{AUTOCOMPLETE_ENABLED="isAutocompleteEnabled";updateAutocompleteEnabled(t){this.updateContextProperty(this.AUTOCOMPLETE_ENABLED,t),xt.get(zi).setEnabled(t)}onAutocompleteEnabledChanged(t){return this.subscribe(this.AUTOCOMPLETE_ENABLED,t)}}const Xi=t=>{const e=(t?.results.bindings||[]).reduce((t,e)=>(t[e.prefix.value]=e.namespace.value,t),{});return new k(e)};class Ji extends nr{REPOSITORIES_ENDPOINT="repositories";getStatementsEndpoint(t){return`${this.REPOSITORIES_ENDPOINT}/${t}/statements`}getSparqlEndpoint(t){return`${this.REPOSITORIES_ENDPOINT}/${t}`}getNamespaces(t){return this.get(`${this.REPOSITORIES_ENDPOINT}/${t}/namespaces`)}}class Qi{rdf4jRestService=wt(Ji);getStatementsEndpoint(t){return this.rdf4jRestService.getStatementsEndpoint(t)}getSparqlEndpoint(t){return this.rdf4jRestService.getSparqlEndpoint(t)}}class Zi{rdf4jRestService=wt(Ji);async getNamespaces(t){const e=await this.rdf4jRestService.getNamespaces(t);return Xi(e)}}class ts extends Ct{NAMESPACES="namespaces";updateNamespaces(t){this.updateContextProperty(this.NAMESPACES,t)}onNamespacesChanged(t){return this.subscribe(this.NAMESPACES,t)}}class es extends Je{SELECTED_VIEW_KEY="selectedView";INPUT_KEY="input";LAST_SELECTED_KEY="lastSelected";NAMESPACE="resourceSearch";LEGACY_LAST_SELECTED_KEY="ls.rdf-search.resource-description";LEGACY_INPUT_KEY="ls.rdf-search.search-input";LEGACY_SELECTED_VIEW_KEY="ls.rdf-search.search-type";set(t,e){this.storeValue(t,e)}setSelectedView(t){this.set(this.SELECTED_VIEW_KEY,t),localStorage.setItem(this.LEGACY_SELECTED_VIEW_KEY,t)}getSelectedView(){return this.get(this.SELECTED_VIEW_KEY).getValue()||""}setInputValue(t){this.set(this.INPUT_KEY,t),localStorage.setItem(this.LEGACY_INPUT_KEY,t)}getInputValue(){return this.get(this.INPUT_KEY).getValue()||""}setLastSelected(t){this.set(this.LAST_SELECTED_KEY,t.getValue()),localStorage.setItem(this.LEGACY_LAST_SELECTED_KEY,t.getDescription()||"")}getLastSelectedValue(){return this.get(this.LAST_SELECTED_KEY).getValue()||""}clearStoredSearch(){this.remove(this.INPUT_KEY),this.remove(this.LAST_SELECTED_KEY),localStorage.removeItem(this.LEGACY_INPUT_KEY),localStorage.removeItem(this.LEGACY_LAST_SELECTED_KEY)}}class rs extends Ct{APPLICATION_DATA_STATE="applicationDataLoaded";APPLICATION_STATE_CHANGE="applicationStateChange";APPLICATION_STATE_BEFORE_CHANGE="applicationStateBeforeChange";updateApplicationDataState(t){this.updateContextProperty(this.APPLICATION_DATA_STATE,t)}onApplicationDataStateChanged(t){return this.subscribe(this.APPLICATION_DATA_STATE,t)}getApplicationDataState(){return this.getContextPropertyValue(this.APPLICATION_DATA_STATE)}updateApplicationStateChange(t){this.updateContextProperty(this.APPLICATION_STATE_CHANGE,t)}onApplicationStateChange(t){return this.subscribe(this.APPLICATION_STATE_CHANGE,t)}updateApplicationStateBeforeChange(t){this.updateContextProperty(this.APPLICATION_STATE_BEFORE_CHANGE,t)}onApplicationStateBeforeChange(t){return this.subscribe(this.APPLICATION_STATE_BEFORE_CHANGE,t)}}class is extends nr{configurationContextService=wt(Tt);logger=Pt.logger;getPluginsManifest(){const t=this.configurationContextService.getApplicationConfiguration();return this.get(t.pluginsManifestPath)}async loadPlugins(t){return await Promise.all(t.getPluginDefinitions().getItems().map(async t=>{try{const e=t.entry.startsWith("http")?t.entry:`${E()}${t.entry}`;return await import(e)}catch(e){this.logger.warn(`Failed to load plugin ${t.name}:`,e)}}))}}class ss{logger=Pt.logger;constructor(){this.pluginsRestService=xt.get(is)}async getPluginsManifest(){return(t=>{const e=t.plugins.map(t=>new me(t.entry,t.name));return new ye(new Ee(e))})(await this.pluginsRestService.getPluginsManifest())}async loadPlugins(){let t;try{t=await this.getPluginsManifest()}catch(t){this.logger.warn("Failed to load plugins manifest. Continue with the built-in plugins only.",t)}t&&(await this.pluginsRestService.loadPlugins(t)).filter(t=>void 0!==t).forEach(t=>{void 0!==t.register?t.register(c.getPluginRegistry()):this.logger.warn("Plugin module is missing the register method. Skipping registration.",t)})}}class ns extends Se{}class os extends Lr{constructor(t){super(`Extension point "${t.name}" is already registered.`)}}class as extends Lr{constructor(t){super(`Extension point "${t}" does not exist.`)}}class hs extends Lr{constructor(t,e,r){super(`There is already a plugin with the same order and priority. Extension point "${t.name}", order "${e}", priority "${r}".`)}}class us{extensionPoints={};constructor(t={}){this.extensionPoints=t}registerExtensionPoint(t){if(this.extensionPoints[t.name])throw new os(t);this.extensionPoints[t.name]=t}add(t,e){if(!e)return;const r=this.getExtensionPoint(t);(Array.isArray(e)?e:[e]).forEach(t=>this.registerPlugin(r,t))}get(t){return this.getExtensionPoint(t).getPlugins()}findPlugin(t,e){return this.get(t).find(e)}getExtensionPoints(){return this.extensionPoints}clear(t){this.getExtensionPoint(t).removeAllPlugins()}clearAll(){Object.values(this.extensionPoints).forEach(t=>t.removeAllPlugins())}getExtensionPoint(t){const e=this.extensionPoints[t];if(!e)throw new as(t);return e}registerPlugin(t,e){e.disabled||(t.removePluginByFieldIdName(e),t instanceof ns?this.processOrderedPlugin(e,t):t.addPlugin(e))}processOrderedPlugin(t,e){const r=e.getPlugins().find(e=>e.order===t.order);if(r){if(r.priority===t.priority)throw new hs(e,t.order,t.priority);t.priority>r.priority&&(e.removePlugin(r),e.addPlugin(t),e.sort((t,e)=>t.order-e.order))}else e.addPlugin(t),e.sort((t,e)=>t.order-e.order)}}const cs=JSON.parse('{"configUrl":"assets/configuration.default.json"}');class ls extends Lr{}class ds extends nr{async getConfiguration(){let t,e=cs;try{e=await this.get("assets/env.json")}catch{console.warn('No downloadable "env.json" was found. Fallback to default:',e)}try{if(t=await this.get(e.configUrl),t)return console.info(`Configuration file ${e.configUrl} was downloaded`,t),t}catch{throw new ls(`Failed to download configuration from "${e.configUrl}". Ensure that there is a\n "configuration.default.json" JSON file in the assets folder or provide an "env.json" file pointing to another\n configuration file.`)}}}class ps{configurationRestService=wt(ds);configurationContextService=wt(Tt);async getConfiguration(){const t=await this.configurationRestService.getConfiguration();return t&&this.configurationContextService.updateApplicationConfiguration(t),t}}const gs=t=>{if(!t)return{items:[]};const e=wt(mr).getSelectedRepository();let r="";return e&&(r=`${B}=${e.id}&`),{items:t.map(t=>({id:t,href:`sparql-template/create?${r}templateID=${encodeURIComponent(t)}`}))}};class fs extends nr{static SPARQL_ENDPOINT="rest/sparql";getSavedQuery(t,e){const r={name:t};return e&&(r.owner=e),this.get(`${fs.SPARQL_ENDPOINT}/saved-queries`,{params:r})}}const ms=t=>{if(!t||!Array.isArray(t))return new Ve;const e=wt(Nr),r=e.getAuthenticatedUser()?.username,i=t.map(t=>{const e=r!==t.owner;return new Me({queryName:t.name,query:t.body,owner:t.owner,isPublic:t.shared,readonly:e})});return new Ve(i)};class ys{sparqlRestService=wt(fs);async getSavedQuery(t,e){const r=await this.sparqlRestService.getSavedQuery(t,e);return ms(r)}}class vs extends Je{NAMESPACE="sparqlEditor";logger=Pt.logger;LAST_USED_REPOSITORY="lastUsedRepository";LEGACY_LAST_USED_REPOSITORY_KEY="ls.sparql-last-repo";set(t,e){this.storeValue(t,e)}setLastUsedRepository(t){this.set(this.LAST_USED_REPOSITORY,t)}getLastUsedRepository(){return this.migrateLastUsedRepositoryKey(),this.get(this.LAST_USED_REPOSITORY).getValue()}migrateLastUsedRepositoryKey(){const t=this.get(this.LEGACY_LAST_USED_REPOSITORY_KEY,!1).getValue();t&&(this.logger.info("Legacy last used repository data found. Migrating to new key.",{legacyData:t}),this.setLastUsedRepository(t),this.remove(this.LEGACY_LAST_USED_REPOSITORY_KEY,!1))}}class Ss{postMessage(t,e="*"){c.getParentWindow().postMessage(t,e)}}var Es=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===xs}(t)}(t)},xs="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function ws(t,e){return!1!==e.clone&&e.isMergeableObject(t)?Cs((r=t,Array.isArray(r)?[]:{}),t,e):t;var r}function As(t,e,r){return t.concat(e).map(function(t){return ws(t,r)})}function bs(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[]}(t))}function Is(t,e){try{return e in t}catch(t){return!1}}function Cs(t,e,r){(r=r||{}).arrayMerge=r.arrayMerge||As,r.isMergeableObject=r.isMergeableObject||Es,r.cloneUnlessOtherwiseSpecified=ws;var i=Array.isArray(e);return i===Array.isArray(t)?i?r.arrayMerge(t,e,r):function(t,e,r){var i={};return r.isMergeableObject(t)&&bs(t).forEach(function(e){i[e]=ws(t[e],r)}),bs(e).forEach(function(s){(function(t,e){return Is(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,s)||(Is(t,s)&&r.isMergeableObject(e[s])?i[s]=function(t,e){if(!e.customMerge)return Cs;var r=e.customMerge(t);return"function"==typeof r?r:Cs}(s,r)(t[s],e[s],r):i[s]=ws(e[s],r))}),i}(t,e,r):ws(e,r)}Cs.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,r){return Cs(t,r,e)},{})};var Ts=Cs;function Rs(t){return t instanceof HTMLElement}function Fs(t){return"function"==typeof t}function Ps(t){return"string"==typeof t}function Ds(t){return void 0===t}class Os{on(t,e,r,i=!1){return Ds(this.bindings)&&(this.bindings={}),Ds(this.bindings[t])&&(this.bindings[t]=[]),this.bindings[t].push({handler:e,ctx:r,once:i}),this}once(t,e,r){return this.on(t,e,r,!0)}off(t,e){return Ds(this.bindings)||Ds(this.bindings[t])||(Ds(e)?delete this.bindings[t]:this.bindings[t].forEach((r,i)=>{r.handler===e&&this.bindings[t].splice(i,1)})),this}trigger(t,...e){return!Ds(this.bindings)&&this.bindings[t]&&this.bindings[t].forEach((r,i)=>{const{ctx:s,handler:n,once:o}=r,a=s||this;n.apply(a,e),o&&this.bindings[t].splice(i,1)}),this}}function Ns(t){const e=Object.getOwnPropertyNames(t.constructor.prototype);for(let r=0;r<e.length;r++){const i=e[r],s=t[i];"constructor"!==i&&"function"==typeof s&&(t[i]=s.bind(t))}return t}function _s(t){return Ps(t)&&""!==t?"-"!==t.charAt(t.length-1)?`${t}-`:t:""}function Bs(t){return null==t||!t.element||!t.on}function Ls(){let t=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:3&r|8).toString(16)})}function Hs(){return Hs=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Hs.apply(this,arguments)}function ks(t,e){if(null==t)return{};var r,i,s={},n=Object.keys(t);for(i=0;i<n.length;i++)r=n[i],e.indexOf(r)>=0||(s[r]=t[r]);return s}const Us=Math.min,js=Math.max,Vs=Math.round,Ms=Math.floor,Ks=t=>({x:t,y:t}),qs={left:"right",right:"left",bottom:"top",top:"bottom"},Gs={start:"end",end:"start"};function $s(t,e,r){return js(t,Us(e,r))}function Ws(t,e){return"function"==typeof t?t(e):t}function zs(t){return t.split("-")[0]}function Ys(t){return t.split("-")[1]}function Xs(t){return"x"===t?"y":"x"}function Js(t){return"y"===t?"height":"width"}function Qs(t){return["top","bottom"].includes(zs(t))?"y":"x"}function Zs(t){return Xs(Qs(t))}function tn(t){return t.replace(/start|end/g,t=>Gs[t])}function en(t){return t.replace(/left|right|bottom|top/g,t=>qs[t])}function rn(t){return"number"!=typeof t?function(t){return Hs({top:0,right:0,bottom:0,left:0},t)}(t):{top:t,right:t,bottom:t,left:t}}function sn(t){return Hs({},t,{top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height})}const nn=["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"],on=["mainAxis","crossAxis","limiter"];function an(t,e,r){let{reference:i,floating:s}=t;const n=Qs(e),o=Zs(e),a=Js(o),h=zs(e),c="y"===n,u=i.x+i.width/2-s.width/2,l=i.y+i.height/2-s.height/2,d=i[a]/2-s[a]/2;let p;switch(h){case"top":p={x:u,y:i.y-s.height};break;case"bottom":p={x:u,y:i.y+i.height};break;case"right":p={x:i.x+i.width,y:l};break;case"left":p={x:i.x-s.width,y:l};break;default:p={x:i.x,y:i.y}}switch(Ys(e)){case"start":p[o]-=d*(r&&c?-1:1);break;case"end":p[o]+=d*(r&&c?-1:1)}return p}async function hn(t,e){var r;void 0===e&&(e={});const{x:i,y:s,platform:n,rects:o,elements:a,strategy:h}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:l="floating",altBoundary:d=!1,padding:p=0}=Ws(e,t),g=rn(p),f=a[d?"floating"===l?"reference":"floating":l],m=sn(await n.getClippingRect({element:null==(r=await(null==n.isElement?void 0:n.isElement(f)))||r?f:f.contextElement||await(null==n.getDocumentElement?void 0:n.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:h})),y="floating"===l?Hs({},o.floating,{x:i,y:s}):o.reference,v=await(null==n.getOffsetParent?void 0:n.getOffsetParent(a.floating)),S=await(null==n.isElement?void 0:n.isElement(v))&&await(null==n.getScale?void 0:n.getScale(v))||{x:1,y:1},E=sn(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({rect:y,offsetParent:v,strategy:h}):y);return{top:(m.top-E.top+g.top)/S.y,bottom:(E.bottom-m.bottom+g.bottom)/S.y,left:(m.left-E.left+g.left)/S.x,right:(E.right-m.right+g.right)/S.x}}const un=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:r,y:i,placement:s,rects:n,middlewareData:o}=e,{offset:a=0,mainAxis:h=!0,crossAxis:c=!0}=Ws(t,e),u={x:r,y:i},l=Qs(s),d=Xs(l);let p=u[d],g=u[l];const f=Ws(a,e),m="number"==typeof f?{mainAxis:f,crossAxis:0}:Hs({mainAxis:0,crossAxis:0},f);if(h){const t="y"===d?"height":"width",e=n.reference[d]-n.floating[t]+m.mainAxis,r=n.reference[d]+n.reference[t]-m.mainAxis;p<e?p=e:p>r&&(p=r)}if(c){var y,v;const t="y"===d?"width":"height",e=["top","left"].includes(zs(s)),r=n.reference[l]-n.floating[t]+(e&&(null==(y=o.offset)?void 0:y[l])||0)+(e?0:m.crossAxis),i=n.reference[l]+n.reference[t]+(e?0:(null==(v=o.offset)?void 0:v[l])||0)-(e?m.crossAxis:0);g<r?g=r:g>i&&(g=i)}return{[d]:p,[l]:g}}}};function cn(t){return pn(t)?(t.nodeName||"").toLowerCase():"#document"}function ln(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function dn(t){var e;return null==(e=(pn(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function pn(t){return t instanceof Node||t instanceof ln(t).Node}function gn(t){return t instanceof Element||t instanceof ln(t).Element}function fn(t){return t instanceof HTMLElement||t instanceof ln(t).HTMLElement}function mn(t){return"undefined"!=typeof ShadowRoot&&(t instanceof ShadowRoot||t instanceof ln(t).ShadowRoot)}function yn(t){const{overflow:e,overflowX:r,overflowY:i,display:s}=wn(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+r)&&!["inline","contents"].includes(s)}function vn(t){return["table","td","th"].includes(cn(t))}function Sn(t){const e=En(),r=wn(t);return"none"!==r.transform||"none"!==r.perspective||!!r.containerType&&"normal"!==r.containerType||!e&&!!r.backdropFilter&&"none"!==r.backdropFilter||!e&&!!r.filter&&"none"!==r.filter||["transform","perspective","filter"].some(t=>(r.willChange||"").includes(t))||["paint","layout","strict","content"].some(t=>(r.contain||"").includes(t))}function En(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function xn(t){return["html","body","#document"].includes(cn(t))}function wn(t){return ln(t).getComputedStyle(t)}function An(t){return gn(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function bn(t){if("html"===cn(t))return t;const e=t.assignedSlot||t.parentNode||mn(t)&&t.host||dn(t);return mn(e)?e.host:e}function In(t){const e=bn(t);return xn(e)?t.ownerDocument?t.ownerDocument.body:t.body:fn(e)&&yn(e)?e:In(e)}function Cn(t,e){var r;void 0===e&&(e=[]);const i=In(t),s=i===(null==(r=t.ownerDocument)?void 0:r.body),n=ln(i);return s?e.concat(n,n.visualViewport||[],yn(i)?i:[]):e.concat(i,Cn(i))}function Tn(t){const e=wn(t);let r=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const s=fn(t),n=s?t.offsetWidth:r,o=s?t.offsetHeight:i,a=Vs(r)!==n||Vs(i)!==o;return a&&(r=n,i=o),{width:r,height:i,$:a}}function Rn(t){return gn(t)?t:t.contextElement}function Fn(t){const e=Rn(t);if(!fn(e))return Ks(1);const r=e.getBoundingClientRect(),{width:i,height:s,$:n}=Tn(e);let o=(n?Vs(r.width):r.width)/i,a=(n?Vs(r.height):r.height)/s;return o&&Number.isFinite(o)||(o=1),a&&Number.isFinite(a)||(a=1),{x:o,y:a}}const Pn=Ks(0);function Dn(t){const e=ln(t);return En()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:Pn}function On(t,e,r,i){void 0===e&&(e=!1),void 0===r&&(r=!1);const s=t.getBoundingClientRect(),n=Rn(t);let o=Ks(1);e&&(i?gn(i)&&(o=Fn(i)):o=Fn(t));const a=function(t,e,r){return void 0===e&&(e=!1),!(!r||e&&r!==ln(t))&&e}(n,r,i)?Dn(n):Ks(0);let h=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,u=s.width/o.x,l=s.height/o.y;if(n){const t=ln(n),e=i&&gn(i)?ln(i):i;let r=t.frameElement;for(;r&&i&&e!==t;){const t=Fn(r),e=r.getBoundingClientRect(),i=wn(r),s=e.left+(r.clientLeft+parseFloat(i.paddingLeft))*t.x,n=e.top+(r.clientTop+parseFloat(i.paddingTop))*t.y;h*=t.x,c*=t.y,u*=t.x,l*=t.y,h+=s,c+=n,r=ln(r).frameElement}}return sn({width:u,height:l,x:h,y:c})}function Nn(t){return On(dn(t)).left+An(t).scrollLeft}function _n(t,e,r){let i;if("viewport"===e)i=function(t,e){const r=ln(t),i=dn(t),s=r.visualViewport;let n=i.clientWidth,o=i.clientHeight,a=0,h=0;if(s){n=s.width,o=s.height;const t=En();(!t||t&&"fixed"===e)&&(a=s.offsetLeft,h=s.offsetTop)}return{width:n,height:o,x:a,y:h}}(t,r);else if("document"===e)i=function(t){const e=dn(t),r=An(t),i=t.ownerDocument.body,s=js(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),n=js(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let o=-r.scrollLeft+Nn(t);const a=-r.scrollTop;return"rtl"===wn(i).direction&&(o+=js(e.clientWidth,i.clientWidth)-s),{width:s,height:n,x:o,y:a}}(dn(t));else if(gn(e))i=function(t,e){const r=On(t,!0,"fixed"===e),i=r.top+t.clientTop,s=r.left+t.clientLeft,n=fn(t)?Fn(t):Ks(1);return{width:t.clientWidth*n.x,height:t.clientHeight*n.y,x:s*n.x,y:i*n.y}}(e,r);else{const r=Dn(t);i=Hs({},e,{x:e.x-r.x,y:e.y-r.y})}return sn(i)}function Bn(t,e){const r=bn(t);return!(r===e||!gn(r)||xn(r))&&("fixed"===wn(r).position||Bn(r,e))}function Ln(t,e,r){const i=fn(e),s=dn(e),n="fixed"===r,o=On(t,!0,n,e);let a={scrollLeft:0,scrollTop:0};const h=Ks(0);if(i||!i&&!n)if(("body"!==cn(e)||yn(s))&&(a=An(e)),i){const t=On(e,!0,n,e);h.x=t.x+e.clientLeft,h.y=t.y+e.clientTop}else s&&(h.x=Nn(s));return{x:o.left+a.scrollLeft-h.x,y:o.top+a.scrollTop-h.y,width:o.width,height:o.height}}function Hn(t,e){return fn(t)&&"fixed"!==wn(t).position?e?e(t):t.offsetParent:null}function kn(t,e){const r=ln(t);if(!fn(t))return r;let i=Hn(t,e);for(;i&&vn(i)&&"static"===wn(i).position;)i=Hn(i,e);return i&&("html"===cn(i)||"body"===cn(i)&&"static"===wn(i).position&&!Sn(i))?r:i||function(t){let e=bn(t);for(;fn(e)&&!xn(e);){if(Sn(e))return e;e=bn(e)}return null}(t)||r}const Un={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:r,strategy:i}=t;const s=fn(r),n=dn(r);if(r===n)return e;let o={scrollLeft:0,scrollTop:0},a=Ks(1);const h=Ks(0);if((s||!s&&"fixed"!==i)&&(("body"!==cn(r)||yn(n))&&(o=An(r)),fn(r))){const t=On(r);a=Fn(r),h.x=t.x+r.clientLeft,h.y=t.y+r.clientTop}return{width:e.width*a.x,height:e.height*a.y,x:e.x*a.x-o.scrollLeft*a.x+h.x,y:e.y*a.y-o.scrollTop*a.y+h.y}},getDocumentElement:dn,getClippingRect:function(t){let{element:e,boundary:r,rootBoundary:i,strategy:s}=t;const n=[..."clippingAncestors"===r?function(t,e){const r=e.get(t);if(r)return r;let i=Cn(t).filter(t=>gn(t)&&"body"!==cn(t)),s=null;const n="fixed"===wn(t).position;let o=n?bn(t):t;for(;gn(o)&&!xn(o);){const e=wn(o),r=Sn(o);r||"fixed"!==e.position||(s=null),(n?!r&&!s:!r&&"static"===e.position&&s&&["absolute","fixed"].includes(s.position)||yn(o)&&!r&&Bn(t,o))?i=i.filter(t=>t!==o):s=e,o=bn(o)}return e.set(t,i),i}(e,this._c):[].concat(r),i],o=n[0],a=n.reduce((t,r)=>{const i=_n(e,r,s);return t.top=js(i.top,t.top),t.right=Us(i.right,t.right),t.bottom=Us(i.bottom,t.bottom),t.left=js(i.left,t.left),t},_n(e,o,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:kn,getElementRects:async function(t){let{reference:e,floating:r,strategy:i}=t;const s=this.getOffsetParent||kn,n=this.getDimensions;return{reference:Ln(e,await s(r),i),floating:Hs({x:0,y:0},await n(r))}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){return Tn(t)},getScale:Fn,isElement:gn,isRTL:function(t){return"rtl"===wn(t).direction}};function jn(t){t.cleanup&&t.cleanup();const e=t._getResolvedAttachToOptions();let r=e.element;const i=function(t,e){const r={strategy:"absolute",middleware:[]},i=function(t){return!(!t.options.arrow||!t.el)&&t.el.querySelector(".shepherd-arrow")}(e);return Bs(t)||(r.middleware.push(function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var r;const{placement:i,middlewareData:s,rects:n,initialPlacement:o,platform:a,elements:h}=e,c=Ws(t,e),{mainAxis:u=!0,crossAxis:l=!0,fallbackPlacements:d,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:f=!0}=c,m=ks(c,nn),y=zs(i),v=zs(o)===o,S=await(null==a.isRTL?void 0:a.isRTL(h.floating)),E=d||(v||!f?[en(o)]:function(t){const e=en(t);return[tn(t),e,tn(e)]}(o));d||"none"===g||E.push(...function(t,e,r,i){const s=Ys(t);let n=function(t,e,r){const i=["left","right"],s=["right","left"],n=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return r?e?s:i:e?i:s;case"left":case"right":return e?n:o;default:return[]}}(zs(t),"start"===r,i);return s&&(n=n.map(t=>t+"-"+s),e&&(n=n.concat(n.map(tn)))),n}(o,f,g,S));const x=[o,...E],w=await hn(e,m),A=[];let b=(null==(r=s.flip)?void 0:r.overflows)||[];if(u&&A.push(w[y]),l){const t=function(t,e,r){void 0===r&&(r=!1);const i=Ys(t),s=Zs(t),n=Js(s);let o="x"===s?i===(r?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[n]>e.floating[n]&&(o=en(o)),[o,en(o)]}(i,n,S);A.push(w[t[0]],w[t[1]])}if(b=[...b,{placement:i,overflows:A}],!A.every(t=>t<=0)){var C,I;const t=((null==(C=s.flip)?void 0:C.index)||0)+1,e=x[t];if(e)return{data:{index:t,overflows:b},reset:{placement:e}};let r=null==(I=b.filter(t=>t.overflows[0]<=0).sort((t,e)=>t.overflows[1]-e.overflows[1])[0])?void 0:I.placement;if(!r)switch(p){case"bestFit":{var T;const t=null==(T=b.map(t=>[t.placement,t.overflows.filter(t=>t>0).reduce((t,e)=>t+e,0)]).sort((t,e)=>t[1]-e[1])[0])?void 0:T[0];t&&(r=t);break}case"initialPlacement":r=o}if(i!==r)return{reset:{placement:r}}}return{}}}}(),function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:r,y:i,placement:s}=e,n=Ws(t,e),{mainAxis:o=!0,crossAxis:a=!1,limiter:h={fn:t=>{let{x:e,y:r}=t;return{x:e,y:r}}}}=n,c=ks(n,on),u={x:r,y:i},l=await hn(e,c),d=Qs(zs(s)),p=Xs(d);let g=u[p],f=u[d];if(o){const t="y"===p?"bottom":"right";g=$s(g+l["y"===p?"top":"left"],g,g-l[t])}if(a){const t="y"===d?"bottom":"right";f=$s(f+l["y"===d?"top":"left"],f,f-l[t])}const m=h.fn(Hs({},e,{[p]:g,[d]:f}));return Hs({},m,{data:{x:m.x-r,y:m.y-i}})}}}({limiter:un(),crossAxis:!0})),i&&r.middleware.push((t=>({name:"arrow",options:t,async fn(e){const{x:r,y:i,placement:s,rects:n,platform:o,elements:a}=e,{element:h,padding:c=0}=Ws(t,e)||{};if(null==h)return{};const u=rn(c),l={x:r,y:i},d=Zs(s),p=Js(d),g=await o.getDimensions(h),f="y"===d,m=f?"top":"left",y=f?"bottom":"right",v=f?"clientHeight":"clientWidth",S=n.reference[p]+n.reference[d]-l[d]-n.floating[p],E=l[d]-n.reference[d],x=await(null==o.getOffsetParent?void 0:o.getOffsetParent(h));let w=x?x[v]:0;w&&await(null==o.isElement?void 0:o.isElement(x))||(w=a.floating[v]||n.floating[p]);const A=S/2-E/2,b=w/2-g[p]/2-1,C=Us(u[m],b),I=Us(u[y],b),T=C,R=w-g[p]-I,F=w/2-g[p]/2+A,P=$s(T,F,R),D=null!=Ys(s)&&F!=P&&n.reference[p]/2-(F<T?C:I)-g[p]/2<0?F<T?T-F:R-F:0;return{[d]:l[d]-D,data:{[d]:P,centerOffset:F-P+D}}}}))({element:i})),r.placement=t.on),Ts(e.options.floatingUIOptions||{},r)}(e,t),s=Bs(e);return s&&(r=document.body,t.shepherdElementComponent.getElement().classList.add("shepherd-centered")),t.cleanup=function(t,e,r,i){void 0===i&&(i={});const{ancestorScroll:s=!0,ancestorResize:n=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:h=!1}=i,c=Rn(t),u=s||n?[...c?Cn(c):[],...Cn(e)]:[];u.forEach(t=>{s&&t.addEventListener("scroll",r,{passive:!0}),n&&t.addEventListener("resize",r)});const l=c&&a?function(t,e){let r,i=null;const s=dn(t);function n(){clearTimeout(r),i&&i.disconnect(),i=null}return function o(a,h){void 0===a&&(a=!1),void 0===h&&(h=1),n();const{left:c,top:u,width:l,height:d}=t.getBoundingClientRect();if(a||e(),!l||!d)return;const p={rootMargin:-Ms(u)+"px "+-Ms(s.clientWidth-(c+l))+"px "+-Ms(s.clientHeight-(u+d))+"px "+-Ms(c)+"px",threshold:js(0,Us(1,h))||1};let g=!0;function f(t){const e=t[0].intersectionRatio;if(e!==h){if(!g)return o();e?o(!1,e):r=setTimeout(()=>{o(!1,1e-7)},100)}g=!1}try{i=new IntersectionObserver(f,Hs({},p,{root:s.ownerDocument}))}catch(t){i=new IntersectionObserver(f,p)}i.observe(t)}(!0),n}(c,r):null;let d,p=-1,g=null;o&&(g=new ResizeObserver(t=>{let[i]=t;i&&i.target===c&&g&&(g.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{g&&g.observe(e)})),r()}),c&&!h&&g.observe(c),g.observe(e));let f=h?On(t):null;return h&&function e(){const i=On(t);!f||i.x===f.x&&i.y===f.y&&i.width===f.width&&i.height===f.height||r(),f=i,d=requestAnimationFrame(e)}(),r(),()=>{u.forEach(t=>{s&&t.removeEventListener("scroll",r),n&&t.removeEventListener("resize",r)}),l&&l(),g&&g.disconnect(),g=null,h&&cancelAnimationFrame(d)}}(r,t.el,()=>{t.el?function(t,e,r,i){((t,e,r)=>{const i=new Map,s=Hs({platform:Un},r),n=Hs({},s.platform,{_c:i});return(async(t,e,r)=>{const{placement:i="bottom",strategy:s="absolute",middleware:n=[],platform:o}=r,a=n.filter(Boolean),h=await(null==o.isRTL?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:l}=an(c,i,h),d=i,p={},g=0;for(let r=0;r<a.length;r++){const{name:n,fn:f}=a[r],{x:m,y,data:v,reset:S}=await f({x:u,y:l,initialPlacement:i,placement:d,strategy:s,middlewareData:p,rects:c,platform:o,elements:{reference:t,floating:e}});u=null!=m?m:u,l=null!=y?y:l,p=Hs({},p,{[n]:Hs({},p[n],v)}),S&&g<=50&&(g++,"object"==typeof S&&(S.placement&&(d=S.placement),S.rects&&(c=!0===S.rects?await o.getElementRects({reference:t,floating:e,strategy:s}):S.rects),({x:u,y:l}=an(c,d,h))),r=-1)}return{x:u,y:l,placement:d,strategy:s,middlewareData:p}})(t,e,Hs({},s,{platform:n}))})(t,e.el,r).then(function(t,e){return({x:r,y:i,placement:s,middlewareData:n})=>t.el?(e?Object.assign(t.el.style,{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)"}):Object.assign(t.el.style,{position:"absolute",left:`${r}px`,top:`${i}px`}),t.el.dataset.popperPlacement=s,function(t,e){const r=t.querySelector(".shepherd-arrow");if(r&&e.arrow){const{x:t,y:i}=e.arrow;Object.assign(r.style,{left:null!=t?`${t}px`:"",top:null!=i?`${i}px`:""})}}(t.el,n),t):t}(e,i)).then(t=>new Promise(e=>{setTimeout(()=>e(t),300)})).then(t=>{t&&t.el&&t.el.focus({preventScroll:!0})})}(r,t,i,s):t.cleanup()}),t.target=e.element,i}function Vn(){}function Mn(t,e){for(const r in e)t[r]=e[r];return t}function Kn(t){return t()}function qn(){return Object.create(null)}function Gn(t){t.forEach(Kn)}function $n(t){return"function"==typeof t}function Wn(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function zn(t,e){t.appendChild(e)}function Yn(t,e,r){t.insertBefore(e,r||null)}function Xn(t){t.parentNode&&t.parentNode.removeChild(t)}function Jn(t){return document.createElement(t)}function Qn(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Zn(t){return document.createTextNode(t)}function to(){return Zn(" ")}function eo(t,e,r,i){return t.addEventListener(e,r,i),()=>t.removeEventListener(e,r,i)}function ro(t,e,r){null==r?t.removeAttribute(e):t.getAttribute(e)!==r&&t.setAttribute(e,r)}const io=["width","height"];function so(t,e){const r=Object.getOwnPropertyDescriptors(t.__proto__);for(const i in e)null==e[i]?t.removeAttribute(i):"style"===i?t.style.cssText=e[i]:"__value"===i?t.value=t[i]=e[i]:r[i]&&r[i].set&&-1===io.indexOf(i)?t[i]=e[i]:ro(t,i,e[i])}function no(t,e,r){t.classList[r?"add":"remove"](e)}let oo;function ao(t){oo=t}function ho(){if(!oo)throw new Error("Function called outside component initialization");return oo}function uo(t){ho().$$.after_update.push(t)}const co=[],lo=[];let po=[];const go=[],fo=Promise.resolve();let mo=!1;function yo(t){po.push(t)}const vo=new Set;let So=0;function Eo(){if(0!==So)return;const t=oo;do{try{for(;So<co.length;){const t=co[So];So++,ao(t),xo(t.$$)}}catch(t){throw co.length=0,So=0,t}for(ao(null),co.length=0,So=0;lo.length;)lo.pop()();for(let t=0;t<po.length;t+=1){const e=po[t];vo.has(e)||(vo.add(e),e())}po.length=0}while(co.length);for(;go.length;)go.pop()();mo=!1,vo.clear(),ao(t)}function xo(t){if(null!==t.fragment){t.update(),Gn(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(yo)}}const wo=new Set;let Ao;function bo(){Ao={r:0,c:[],p:Ao}}function Io(){Ao.r||Gn(Ao.c),Ao=Ao.p}function Co(t,e){t&&t.i&&(wo.delete(t),t.i(e))}function To(t,e,r,i){if(t&&t.o){if(wo.has(t))return;wo.add(t),Ao.c.push(()=>{wo.delete(t),i&&(r&&t.d(1),i())}),t.o(e)}else i&&i()}function Ro(t){t&&t.c()}function Fo(t,e,r,i){const{fragment:s,after_update:n}=t.$$;s&&s.m(e,r),i||yo(()=>{const e=t.$$.on_mount.map(Kn).filter($n);t.$$.on_destroy?t.$$.on_destroy.push(...e):Gn(e),t.$$.on_mount=[]}),n.forEach(yo)}function Po(t,e){const r=t.$$;null!==r.fragment&&(function(t){const e=[],r=[];po.forEach(i=>-1===t.indexOf(i)?e.push(i):r.push(i)),r.forEach(t=>t()),po=e}(r.after_update),Gn(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function Do(t,e,r,i,s,n,o,a=[-1]){const h=oo;ao(t);const c=t.$$={fragment:null,ctx:[],props:n,update:Vn,not_equal:s,bound:qn(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(h?h.$$.context:[])),callbacks:qn(),dirty:a,skip_bound:!1,root:e.target||h.$$.root};o&&o(c.root);let u=!1;if(c.ctx=r?r(t,e.props||{},(e,r,...i)=>{const n=i.length?i[0]:r;return c.ctx&&s(c.ctx[e],c.ctx[e]=n)&&(!c.skip_bound&&c.bound[e]&&c.bound[e](n),u&&function(t,e){-1===t.$$.dirty[0]&&(co.push(t),mo||(mo=!0,fo.then(Eo)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}(t,e)),r}):[],c.update(),u=!0,Gn(c.before_update),c.fragment=!!i&&i(c.ctx),e.target){if(e.hydrate){const t=(l=e.target,Array.from(l.childNodes));c.fragment&&c.fragment.l(t),t.forEach(Xn)}else c.fragment&&c.fragment.c();e.intro&&Co(t.$$.fragment),Fo(t,e.target,e.anchor,e.customElement),Eo()}var l;ao(h)}class Oo{$destroy(){Po(this,1),this.$destroy=Vn}$on(t,e){if(!$n(e))return Vn;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(e),()=>{const t=r.indexOf(e);-1!==t&&r.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function No(t){let e,r,i,s,n;return{c(){e=Jn("button"),ro(e,"aria-label",r=t[3]?t[3]:null),ro(e,"class",i=`${t[1]||""} shepherd-button ${t[4]?"shepherd-button-secondary":""}`),e.disabled=t[2],ro(e,"tabindex","0")},m(r,i){Yn(r,e,i),e.innerHTML=t[5],s||(n=eo(e,"click",function(){$n(t[0])&&t[0].apply(this,arguments)}),s=!0)},p(s,[n]){t=s,32&n&&(e.innerHTML=t[5]),8&n&&r!==(r=t[3]?t[3]:null)&&ro(e,"aria-label",r),18&n&&i!==(i=`${t[1]||""} shepherd-button ${t[4]?"shepherd-button-secondary":""}`)&&ro(e,"class",i),4&n&&(e.disabled=t[2])},i:Vn,o:Vn,d(t){t&&Xn(e),s=!1,n()}}}function _o(t,e,r){let i,s,n,o,a,h,{config:c,step:u}=e;function l(t){return Fs(t)?t.call(u):t}return t.$$set=t=>{"config"in t&&r(6,c=t.config),"step"in t&&r(7,u=t.step)},t.$$.update=()=>{192&t.$$.dirty&&(r(0,i=c.action?c.action.bind(u.tour):null),r(1,s=c.classes),r(2,n=!!c.disabled&&l(c.disabled)),r(3,o=c.label?l(c.label):null),r(4,a=c.secondary),r(5,h=c.text?l(c.text):null))},[i,s,n,o,a,h,c,u]}class Bo extends Oo{constructor(t){super(),Do(this,t,_o,No,Wn,{config:6,step:7})}}function Lo(t,e,r){const i=t.slice();return i[2]=e[r],i}function Ho(t){let e,r,i=t[1],s=[];for(let e=0;e<i.length;e+=1)s[e]=ko(Lo(t,i,e));const n=t=>To(s[t],1,1,()=>{s[t]=null});return{c(){for(let t=0;t<s.length;t+=1)s[t].c();e=Zn("")},m(t,i){for(let e=0;e<s.length;e+=1)s[e]&&s[e].m(t,i);Yn(t,e,i),r=!0},p(t,r){if(3&r){let o;for(i=t[1],o=0;o<i.length;o+=1){const n=Lo(t,i,o);s[o]?(s[o].p(n,r),Co(s[o],1)):(s[o]=ko(n),s[o].c(),Co(s[o],1),s[o].m(e.parentNode,e))}for(bo(),o=i.length;o<s.length;o+=1)n(o);Io()}},i(t){if(!r){for(let t=0;t<i.length;t+=1)Co(s[t]);r=!0}},o(t){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)To(s[t]);r=!1},d(t){!function(t,e){for(let r=0;r<t.length;r+=1)t[r]&&t[r].d(e)}(s,t),t&&Xn(e)}}}function ko(t){let e,r;return e=new Bo({props:{config:t[2],step:t[0]}}),{c(){Ro(e.$$.fragment)},m(t,i){Fo(e,t,i),r=!0},p(t,r){const i={};2&r&&(i.config=t[2]),1&r&&(i.step=t[0]),e.$set(i)},i(t){r||(Co(e.$$.fragment,t),r=!0)},o(t){To(e.$$.fragment,t),r=!1},d(t){Po(e,t)}}}function Uo(t){let e,r,i=t[1]&&Ho(t);return{c(){e=Jn("footer"),i&&i.c(),ro(e,"class","shepherd-footer")},m(t,s){Yn(t,e,s),i&&i.m(e,null),r=!0},p(t,[r]){t[1]?i?(i.p(t,r),2&r&&Co(i,1)):(i=Ho(t),i.c(),Co(i,1),i.m(e,null)):i&&(bo(),To(i,1,1,()=>{i=null}),Io())},i(t){r||(Co(i),r=!0)},o(t){To(i),r=!1},d(t){t&&Xn(e),i&&i.d()}}}function jo(t,e,r){let i,{step:s}=e;return t.$$set=t=>{"step"in t&&r(0,s=t.step)},t.$$.update=()=>{1&t.$$.dirty&&r(1,i=s.options.buttons)},[s,i]}class Vo extends Oo{constructor(t){super(),Do(this,t,jo,Uo,Wn,{step:0})}}function Mo(t){let e,r,i,s,n;return{c(){e=Jn("button"),r=Jn("span"),r.textContent="×",ro(r,"aria-hidden","true"),ro(e,"aria-label",i=t[0].label?t[0].label:"Close Tour"),ro(e,"class","shepherd-cancel-icon"),ro(e,"type","button")},m(i,o){Yn(i,e,o),zn(e,r),s||(n=eo(e,"click",t[1]),s=!0)},p(t,[r]){1&r&&i!==(i=t[0].label?t[0].label:"Close Tour")&&ro(e,"aria-label",i)},i:Vn,o:Vn,d(t){t&&Xn(e),s=!1,n()}}}function Ko(t,e,r){let{cancelIcon:i,step:s}=e;return t.$$set=t=>{"cancelIcon"in t&&r(0,i=t.cancelIcon),"step"in t&&r(2,s=t.step)},[i,t=>{t.preventDefault(),s.cancel()},s]}class qo extends Oo{constructor(t){super(),Do(this,t,Ko,Mo,Wn,{cancelIcon:0,step:2})}}function Go(t){let e;return{c(){e=Jn("h3"),ro(e,"id",t[1]),ro(e,"class","shepherd-title")},m(r,i){Yn(r,e,i),t[3](e)},p(t,[r]){2&r&&ro(e,"id",t[1])},i:Vn,o:Vn,d(r){r&&Xn(e),t[3](null)}}}function $o(t,e,r){let{labelId:i,element:s,title:n}=e;return uo(()=>{Fs(n)&&r(2,n=n()),r(0,s.innerHTML=n,s)}),t.$$set=t=>{"labelId"in t&&r(1,i=t.labelId),"element"in t&&r(0,s=t.element),"title"in t&&r(2,n=t.title)},[s,i,n,function(t){lo[t?"unshift":"push"](()=>{s=t,r(0,s)})}]}class Wo extends Oo{constructor(t){super(),Do(this,t,$o,Go,Wn,{labelId:1,element:0,title:2})}}function zo(t){let e,r;return e=new Wo({props:{labelId:t[0],title:t[2]}}),{c(){Ro(e.$$.fragment)},m(t,i){Fo(e,t,i),r=!0},p(t,r){const i={};1&r&&(i.labelId=t[0]),4&r&&(i.title=t[2]),e.$set(i)},i(t){r||(Co(e.$$.fragment,t),r=!0)},o(t){To(e.$$.fragment,t),r=!1},d(t){Po(e,t)}}}function Yo(t){let e,r;return e=new qo({props:{cancelIcon:t[3],step:t[1]}}),{c(){Ro(e.$$.fragment)},m(t,i){Fo(e,t,i),r=!0},p(t,r){const i={};8&r&&(i.cancelIcon=t[3]),2&r&&(i.step=t[1]),e.$set(i)},i(t){r||(Co(e.$$.fragment,t),r=!0)},o(t){To(e.$$.fragment,t),r=!1},d(t){Po(e,t)}}}function Xo(t){let e,r,i,s=t[2]&&zo(t),n=t[3]&&t[3].enabled&&Yo(t);return{c(){e=Jn("header"),s&&s.c(),r=to(),n&&n.c(),ro(e,"class","shepherd-header")},m(t,o){Yn(t,e,o),s&&s.m(e,null),zn(e,r),n&&n.m(e,null),i=!0},p(t,[i]){t[2]?s?(s.p(t,i),4&i&&Co(s,1)):(s=zo(t),s.c(),Co(s,1),s.m(e,r)):s&&(bo(),To(s,1,1,()=>{s=null}),Io()),t[3]&&t[3].enabled?n?(n.p(t,i),8&i&&Co(n,1)):(n=Yo(t),n.c(),Co(n,1),n.m(e,null)):n&&(bo(),To(n,1,1,()=>{n=null}),Io())},i(t){i||(Co(s),Co(n),i=!0)},o(t){To(s),To(n),i=!1},d(t){t&&Xn(e),s&&s.d(),n&&n.d()}}}function Jo(t,e,r){let i,s,{labelId:n,step:o}=e;return t.$$set=t=>{"labelId"in t&&r(0,n=t.labelId),"step"in t&&r(1,o=t.step)},t.$$.update=()=>{2&t.$$.dirty&&(r(2,i=o.options.title),r(3,s=o.options.cancelIcon))},[n,o,i,s]}class Qo extends Oo{constructor(t){super(),Do(this,t,Jo,Xo,Wn,{labelId:0,step:1})}}function Zo(t){let e;return{c(){e=Jn("div"),ro(e,"class","shepherd-text"),ro(e,"id",t[1])},m(r,i){Yn(r,e,i),t[3](e)},p(t,[r]){2&r&&ro(e,"id",t[1])},i:Vn,o:Vn,d(r){r&&Xn(e),t[3](null)}}}function ta(t,e,r){let{descriptionId:i,element:s,step:n}=e;return uo(()=>{let{text:t}=n.options;Fs(t)&&(t=t.call(n)),Rs(t)?s.appendChild(t):r(0,s.innerHTML=t,s)}),t.$$set=t=>{"descriptionId"in t&&r(1,i=t.descriptionId),"element"in t&&r(0,s=t.element),"step"in t&&r(2,n=t.step)},[s,i,n,function(t){lo[t?"unshift":"push"](()=>{s=t,r(0,s)})}]}class ea extends Oo{constructor(t){super(),Do(this,t,ta,Zo,Wn,{descriptionId:1,element:0,step:2})}}function ra(t){let e,r;return e=new Qo({props:{labelId:t[1],step:t[2]}}),{c(){Ro(e.$$.fragment)},m(t,i){Fo(e,t,i),r=!0},p(t,r){const i={};2&r&&(i.labelId=t[1]),4&r&&(i.step=t[2]),e.$set(i)},i(t){r||(Co(e.$$.fragment,t),r=!0)},o(t){To(e.$$.fragment,t),r=!1},d(t){Po(e,t)}}}function ia(t){let e,r;return e=new ea({props:{descriptionId:t[0],step:t[2]}}),{c(){Ro(e.$$.fragment)},m(t,i){Fo(e,t,i),r=!0},p(t,r){const i={};1&r&&(i.descriptionId=t[0]),4&r&&(i.step=t[2]),e.$set(i)},i(t){r||(Co(e.$$.fragment,t),r=!0)},o(t){To(e.$$.fragment,t),r=!1},d(t){Po(e,t)}}}function sa(t){let e,r;return e=new Vo({props:{step:t[2]}}),{c(){Ro(e.$$.fragment)},m(t,i){Fo(e,t,i),r=!0},p(t,r){const i={};4&r&&(i.step=t[2]),e.$set(i)},i(t){r||(Co(e.$$.fragment,t),r=!0)},o(t){To(e.$$.fragment,t),r=!1},d(t){Po(e,t)}}}function na(t){let e,r,i,s,n=!Ds(t[2].options.title)||t[2].options.cancelIcon&&t[2].options.cancelIcon.enabled,o=!Ds(t[2].options.text),a=Array.isArray(t[2].options.buttons)&&t[2].options.buttons.length,h=n&&ra(t),c=o&&ia(t),u=a&&sa(t);return{c(){e=Jn("div"),h&&h.c(),r=to(),c&&c.c(),i=to(),u&&u.c(),ro(e,"class","shepherd-content")},m(t,n){Yn(t,e,n),h&&h.m(e,null),zn(e,r),c&&c.m(e,null),zn(e,i),u&&u.m(e,null),s=!0},p(t,[s]){4&s&&(n=!Ds(t[2].options.title)||t[2].options.cancelIcon&&t[2].options.cancelIcon.enabled),n?h?(h.p(t,s),4&s&&Co(h,1)):(h=ra(t),h.c(),Co(h,1),h.m(e,r)):h&&(bo(),To(h,1,1,()=>{h=null}),Io()),4&s&&(o=!Ds(t[2].options.text)),o?c?(c.p(t,s),4&s&&Co(c,1)):(c=ia(t),c.c(),Co(c,1),c.m(e,i)):c&&(bo(),To(c,1,1,()=>{c=null}),Io()),4&s&&(a=Array.isArray(t[2].options.buttons)&&t[2].options.buttons.length),a?u?(u.p(t,s),4&s&&Co(u,1)):(u=sa(t),u.c(),Co(u,1),u.m(e,null)):u&&(bo(),To(u,1,1,()=>{u=null}),Io())},i(t){s||(Co(h),Co(c),Co(u),s=!0)},o(t){To(h),To(c),To(u),s=!1},d(t){t&&Xn(e),h&&h.d(),c&&c.d(),u&&u.d()}}}function oa(t,e,r){let{descriptionId:i,labelId:s,step:n}=e;return t.$$set=t=>{"descriptionId"in t&&r(0,i=t.descriptionId),"labelId"in t&&r(1,s=t.labelId),"step"in t&&r(2,n=t.step)},[i,s,n]}class aa extends Oo{constructor(t){super(),Do(this,t,oa,na,Wn,{descriptionId:0,labelId:1,step:2})}}function ha(t){let e;return{c(){e=Jn("div"),ro(e,"class","shepherd-arrow"),ro(e,"data-popper-arrow","")},m(t,r){Yn(t,e,r)},d(t){t&&Xn(e)}}}function ua(t){let e,r,i,s,n,o,a,h,c=t[4].options.arrow&&t[4].options.attachTo&&t[4].options.attachTo.element&&t[4].options.attachTo.on&&ha();i=new aa({props:{descriptionId:t[2],labelId:t[3],step:t[4]}});let u=[{"aria-describedby":s=Ds(t[4].options.text)?null:t[2]},{"aria-labelledby":n=t[4].options.title?t[3]:null},t[1],{role:"dialog"},{tabindex:"0"}],l={};for(let t=0;t<u.length;t+=1)l=Mn(l,u[t]);return{c(){e=Jn("div"),c&&c.c(),r=to(),Ro(i.$$.fragment),so(e,l),no(e,"shepherd-has-cancel-icon",t[5]),no(e,"shepherd-has-title",t[6]),no(e,"shepherd-element",!0)},m(s,n){Yn(s,e,n),c&&c.m(e,null),zn(e,r),Fo(i,e,null),t[13](e),o=!0,a||(h=eo(e,"keydown",t[7]),a=!0)},p(t,[a]){t[4].options.arrow&&t[4].options.attachTo&&t[4].options.attachTo.element&&t[4].options.attachTo.on?c||(c=ha(),c.c(),c.m(e,r)):c&&(c.d(1),c=null);const h={};4&a&&(h.descriptionId=t[2]),8&a&&(h.labelId=t[3]),16&a&&(h.step=t[4]),i.$set(h),so(e,l=function(t,e){const r={},i={},s={$$scope:1};let n=t.length;for(;n--;){const o=t[n],a=e[n];if(a){for(const t in o)t in a||(i[t]=1);for(const t in a)s[t]||(r[t]=a[t],s[t]=1);t[n]=a}else for(const t in o)s[t]=1}for(const t in i)t in r||(r[t]=void 0);return r}(u,[(!o||20&a&&s!==(s=Ds(t[4].options.text)?null:t[2]))&&{"aria-describedby":s},(!o||24&a&&n!==(n=t[4].options.title?t[3]:null))&&{"aria-labelledby":n},2&a&&t[1],{role:"dialog"},{tabindex:"0"}])),no(e,"shepherd-has-cancel-icon",t[5]),no(e,"shepherd-has-title",t[6]),no(e,"shepherd-element",!0)},i(t){o||(Co(i.$$.fragment,t),o=!0)},o(t){To(i.$$.fragment,t),o=!1},d(r){r&&Xn(e),c&&c.d(),Po(i),t[13](null),a=!1,h()}}}function ca(t){return t.split(" ").filter(t=>!!t.length)}function la(t,e,r){let i,s,n,{classPrefix:o,element:a,descriptionId:h,firstFocusableElement:c,focusableElements:u,labelId:l,lastFocusableElement:d,step:p,dataStepId:g}=e;var f;return f=()=>{r(1,g={[`data-${o}shepherd-step-id`]:p.id}),r(9,u=a.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]')),r(8,c=u[0]),r(10,d=u[u.length-1])},ho().$$.on_mount.push(f),uo(()=>{n!==p.options.classes&&(function(t){if(Ps(t)){const e=ca(t);e.length&&a.classList.remove(...e)}}(n),n=p.options.classes,function(t){if(Ps(t)){const e=ca(t);e.length&&a.classList.add(...e)}}(n))}),t.$$set=t=>{"classPrefix"in t&&r(11,o=t.classPrefix),"element"in t&&r(0,a=t.element),"descriptionId"in t&&r(2,h=t.descriptionId),"firstFocusableElement"in t&&r(8,c=t.firstFocusableElement),"focusableElements"in t&&r(9,u=t.focusableElements),"labelId"in t&&r(3,l=t.labelId),"lastFocusableElement"in t&&r(10,d=t.lastFocusableElement),"step"in t&&r(4,p=t.step),"dataStepId"in t&&r(1,g=t.dataStepId)},t.$$.update=()=>{16&t.$$.dirty&&(r(5,i=p.options&&p.options.cancelIcon&&p.options.cancelIcon.enabled),r(6,s=p.options&&p.options.title))},[a,g,h,l,p,i,s,t=>{const{tour:e}=p;switch(t.keyCode){case 9:if(0===u.length){t.preventDefault();break}t.shiftKey?(document.activeElement===c||document.activeElement.classList.contains("shepherd-element"))&&(t.preventDefault(),d.focus()):document.activeElement===d&&(t.preventDefault(),c.focus());break;case 27:e.options.exitOnEsc&&(t.stopPropagation(),p.cancel());break;case 37:e.options.keyboardNavigation&&(t.stopPropagation(),e.back());break;case 39:e.options.keyboardNavigation&&(t.stopPropagation(),e.next())}},c,u,d,o,()=>a,function(t){lo[t?"unshift":"push"](()=>{a=t,r(0,a)})}]}class da extends Oo{constructor(t){super(),Do(this,t,la,ua,Wn,{classPrefix:11,element:0,descriptionId:2,firstFocusableElement:8,focusableElements:9,labelId:3,lastFocusableElement:10,step:4,dataStepId:1,getElement:12})}get getElement(){return this.$$.ctx[12]}}class pa extends Os{constructor(t,e={}){return super(t,e),this.tour=t,this.classPrefix=this.tour.options?_s(this.tour.options.classPrefix):"",this.styles=t.styles,this._resolvedAttachTo=null,Ns(this),this._setOptions(e),this}cancel(){this.tour.cancel(),this.trigger("cancel")}complete(){this.tour.complete(),this.trigger("complete")}destroy(){this.cleanup&&this.cleanup(),this.cleanup=null,Rs(this.el)&&(this.el.remove(),this.el=null),this._updateStepTargetOnHide(),this.trigger("destroy")}getTour(){return this.tour}hide(){this.tour.modal.hide(),this.trigger("before-hide"),this.el&&(this.el.hidden=!0),this._updateStepTargetOnHide(),this.trigger("hide")}_resolveAttachToOptions(){return this._resolvedAttachTo=function(t){const e=t.options.attachTo||{},r=Object.assign({},e);if(Fs(r.element)&&(r.element=r.element.call(t)),Ps(r.element)){try{r.element=document.querySelector(r.element)}catch(t){}r.element||console.error(`The element for this Shepherd step was not found ${e.element}`)}return r}(this),this._resolvedAttachTo}_getResolvedAttachToOptions(){return null===this._resolvedAttachTo?this._resolveAttachToOptions():this._resolvedAttachTo}isOpen(){return Boolean(this.el&&!this.el.hidden)}show(){return Fs(this.options.beforeShowPromise)?Promise.resolve(this.options.beforeShowPromise()).then(()=>this._show()):Promise.resolve(this._show())}updateStepOptions(t){Object.assign(this.options,t),this.shepherdElementComponent&&this.shepherdElementComponent.$set({step:this})}getElement(){return this.el}getTarget(){return this.target}_createTooltipContent(){const t=`${this.id}-description`,e=`${this.id}-label`;return this.shepherdElementComponent=new da({target:this.tour.options.stepsContainer||document.body,props:{classPrefix:this.classPrefix,descriptionId:t,labelId:e,step:this,styles:this.styles}}),this.shepherdElementComponent.getElement()}_scrollTo(t){const{element:e}=this._getResolvedAttachToOptions();Fs(this.options.scrollToHandler)?this.options.scrollToHandler(e):e instanceof Element&&"function"==typeof e.scrollIntoView&&e.scrollIntoView(t)}_getClassOptions(t){const e=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions,r=t.classes?t.classes:"",i=e&&e.classes?e.classes:"",s=[...r.split(" "),...i.split(" ")],n=new Set(s);return Array.from(n).join(" ").trim()}_setOptions(t={}){let e=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions;e=Ts({},e||{}),this.options=Object.assign({arrow:!0},e,t,function(t,e){return{floatingUIOptions:Ts(t.floatingUIOptions||{},e.floatingUIOptions||{})}}(e,t));const{when:r}=this.options;this.options.classes=this._getClassOptions(t),this.destroy(),this.id=this.options.id||`step-${Ls()}`,r&&Object.keys(r).forEach(t=>{this.on(t,r[t],this)})}_setupElements(){Ds(this.el)||this.destroy(),this.el=this._createTooltipContent(),this.options.advanceOn&&function(t){const{event:e,selector:r}=t.options.advanceOn||{};if(!e)return console.error("advanceOn was defined, but no event name was passed.");{const i=function(t,e){return r=>{if(e.isOpen()){const i=e.el&&r.currentTarget===e.el;(!Ds(t)&&r.currentTarget.matches(t)||i)&&e.tour.next()}}}(r,t);let s;try{s=document.querySelector(r)}catch(t){}if(!Ds(r)&&!s)return console.error(`No element was found for the selector supplied to advanceOn: ${r}`);s?(s.addEventListener(e,i),t.on("destroy",()=>s.removeEventListener(e,i))):(document.body.addEventListener(e,i,!0),t.on("destroy",()=>document.body.removeEventListener(e,i,!0)))}}(this),jn(this)}_show(){this.trigger("before-show"),this._resolveAttachToOptions(),this._setupElements(),this.tour.modal||this.tour._setupModal(),this.tour.modal.setupForStep(this),this._styleTargetElementForStep(this),this.el.hidden=!1,this.options.scrollTo&&setTimeout(()=>{this._scrollTo(this.options.scrollTo)}),this.el.hidden=!1;const t=this.shepherdElementComponent.getElement(),e=this.target||document.body;e.classList.add(`${this.classPrefix}shepherd-enabled`),e.classList.add(`${this.classPrefix}shepherd-target`),t.classList.add("shepherd-enabled"),this.trigger("show")}_styleTargetElementForStep(t){const e=t.target;e&&(t.options.highlightClass&&e.classList.add(t.options.highlightClass),e.classList.remove("shepherd-target-click-disabled"),!1===t.options.canClickTarget&&e.classList.add("shepherd-target-click-disabled"))}_updateStepTargetOnHide(){const t=this.target||document.body;this.options.highlightClass&&t.classList.remove(this.options.highlightClass),t.classList.remove("shepherd-target-click-disabled",`${this.classPrefix}shepherd-enabled`,`${this.classPrefix}shepherd-target`)}}function ga(t){let e,r,i,s,n;return{c(){e=Qn("svg"),r=Qn("path"),ro(r,"d",t[2]),ro(e,"class",i=(t[1]?"shepherd-modal-is-visible":"")+" shepherd-modal-overlay-container")},m(i,o){Yn(i,e,o),zn(e,r),t[11](e),s||(n=eo(e,"touchmove",t[3]),s=!0)},p(t,[s]){4&s&&ro(r,"d",t[2]),2&s&&i!==(i=(t[1]?"shepherd-modal-is-visible":"")+" shepherd-modal-overlay-container")&&ro(e,"class",i)},i:Vn,o:Vn,d(r){r&&Xn(e),t[11](null),s=!1,n()}}}function fa(t){if(!t)return null;const e=t instanceof HTMLElement&&window.getComputedStyle(t).overflowY;return"hidden"!==e&&"visible"!==e&&t.scrollHeight>=t.clientHeight?t:fa(t.parentElement)}function ma(t,e,r){let{element:i,openingProperties:s}=e;Ls();let n,o,a=!1;function h(){r(4,s={width:0,height:0,x:0,y:0,r:0})}function c(){r(1,a=!1),p()}function u(t=0,e=0,i,n){if(n){const{y:o,height:a}=function(t,e){const r=t.getBoundingClientRect();let i=r.y||r.top,s=r.bottom||i+r.height;if(e){const t=e.getBoundingClientRect(),r=t.y||t.top,n=t.bottom||r+t.height;i=Math.max(i,r),s=Math.min(s,n)}return{y:i,height:Math.max(s-i,0)}}(n,i),{x:h,width:c,left:u}=n.getBoundingClientRect();r(4,s={width:c+2*t,height:a+2*t,x:(h||u)-t,y:o-t,r:e})}else h()}function l(){r(1,a=!0)}h();const d=t=>{t.preventDefault()};function p(){n&&(cancelAnimationFrame(n),n=void 0),window.removeEventListener("touchmove",d,{passive:!1})}return t.$$set=t=>{"element"in t&&r(0,i=t.element),"openingProperties"in t&&r(4,s=t.openingProperties)},t.$$.update=()=>{16&t.$$.dirty&&r(2,o=function({width:t,height:e,x:r=0,y:i=0,r:s=0}){const{innerWidth:n,innerHeight:o}=window,{topLeft:a=0,topRight:h=0,bottomRight:c=0,bottomLeft:u=0}="number"==typeof s?{topLeft:s,topRight:s,bottomRight:s,bottomLeft:s}:s;return`M${n},${o}H0V0H${n}V${o}ZM${r+a},${i}a${a},${a},0,0,0-${a},${a}V${e+i-u}a${u},${u},0,0,0,${u},${u}H${t+r-c}a${c},${c},0,0,0,${c}-${c}V${i+h}a${h},${h},0,0,0-${h}-${h}Z`}(s))},[i,a,o,t=>{t.stopPropagation()},s,()=>i,h,c,u,function(t){p(),t.tour.options.useModalOverlay?(function(t){const{modalOverlayOpeningPadding:e,modalOverlayOpeningRadius:r}=t.options,i=fa(t.target),s=()=>{n=void 0,u(e,r,i,t.target),n=requestAnimationFrame(s)};s(),window.addEventListener("touchmove",d,{passive:!1})}(t),l()):c()},l,function(t){lo[t?"unshift":"push"](()=>{i=t,r(0,i)})}]}class ya extends Oo{constructor(t){super(),Do(this,t,ma,ga,Wn,{element:0,openingProperties:4,getElement:5,closeModalOpening:6,hide:7,positionModal:8,setupForStep:9,show:10})}get getElement(){return this.$$.ctx[5]}get closeModalOpening(){return this.$$.ctx[6]}get hide(){return this.$$.ctx[7]}get positionModal(){return this.$$.ctx[8]}get setupForStep(){return this.$$.ctx[9]}get show(){return this.$$.ctx[10]}}const va=new Os,Sa="undefined"==typeof window;class Ea{constructor(){}}Sa?Object.assign(va,{Tour:Ea,Step:Ea}):Object.assign(va,{Tour:class extends Os{constructor(t={}){return super(t),Ns(this),this.options=Object.assign({},{exitOnEsc:!0,keyboardNavigation:!0},t),this.classPrefix=_s(this.options.classPrefix),this.steps=[],this.addSteps(this.options.steps),["active","cancel","complete","inactive","show","start"].map(t=>{(t=>{this.on(t,e=>{(e=e||{}).tour=this,va.trigger(t,e)})})(t)}),this._setTourID(),this}addStep(t,e){let r=t;return r instanceof pa?r.tour=this:r=new pa(this,r),Ds(e)?this.steps.push(r):this.steps.splice(e,0,r),r}addSteps(t){return Array.isArray(t)&&t.forEach(t=>{this.addStep(t)}),this}back(){const t=this.steps.indexOf(this.currentStep);this.show(t-1,!1)}async cancel(){if(this.options.confirmCancel){const t="function"==typeof this.options.confirmCancel,e=this.options.confirmCancelMessage||"Are you sure you want to stop the tour?";(t?await this.options.confirmCancel():window.confirm(e))&&this._done("cancel")}else this._done("cancel")}complete(){this._done("complete")}getById(t){return this.steps.find(e=>e.id===t)}getCurrentStep(){return this.currentStep}hide(){const t=this.getCurrentStep();if(t)return t.hide()}isActive(){return va.activeTour===this}next(){const t=this.steps.indexOf(this.currentStep);t===this.steps.length-1?this.complete():this.show(t+1,!0)}removeStep(t){const e=this.getCurrentStep();this.steps.some((e,r)=>{if(e.id===t)return e.isOpen()&&e.hide(),e.destroy(),this.steps.splice(r,1),!0}),e&&e.id===t&&(this.currentStep=void 0,this.steps.length?this.show(0):this.cancel())}show(t=0,e=!0){const r=Ps(t)?this.getById(t):this.steps[t];r&&(this._updateStateBeforeShow(),Fs(r.options.showOn)&&!r.options.showOn()?this._skipStep(r,e):(this.trigger("show",{step:r,previous:this.currentStep}),this.currentStep=r,r.show()))}start(){this.trigger("start"),this.focusedElBeforeOpen=document.activeElement,this.currentStep=null,this._setupModal(),this._setupActiveTour(),this.next()}_done(t){const e=this.steps.indexOf(this.currentStep);if(Array.isArray(this.steps)&&this.steps.forEach(t=>t.destroy()),function(t){if(t){const{steps:e}=t;e.forEach(t=>{t.options&&!1===t.options.canClickTarget&&t.options.attachTo&&t.target instanceof HTMLElement&&t.target.classList.remove("shepherd-target-click-disabled")})}}(this),this.trigger(t,{index:e}),va.activeTour=null,this.trigger("inactive",{tour:this}),this.modal&&this.modal.hide(),("cancel"===t||"complete"===t)&&this.modal){const t=document.querySelector(".shepherd-modal-overlay-container");t&&t.remove()}Rs(this.focusedElBeforeOpen)&&this.focusedElBeforeOpen.focus()}_setupActiveTour(){this.trigger("active",{tour:this}),va.activeTour=this}_setupModal(){this.modal=new ya({target:this.options.modalContainer||document.body,props:{classPrefix:this.classPrefix,styles:this.styles}})}_skipStep(t,e){const r=this.steps.indexOf(t);if(r===this.steps.length-1)this.complete();else{const t=e?r+1:r-1;this.show(t,e)}}_updateStateBeforeShow(){this.currentStep&&this.currentStep.hide(),this.isActive()||this._setupActiveTour()}_setTourID(){const t=this.options.tourName||"tour";this.id=`${t}--${Ls()}`}},Step:pa});class xa{logger=Pt.logger;languageContextService=wt(hr);translate(t,e,r={}){if(e&&"object"==typeof e){const t=this.languageContextService.getSelectedLanguage()??this.languageContextService.getDefaultLanguage(),i=e[t];return i?this.sanitize(this.applyParameters(i,r)):(this.logger.warn(`Missing translation for language [${t}] in message object`),"")}t??=this.languageContextService.getLanguageBundle();let i=t?.[e];return i||(t=this.languageContextService.getDefaultBundle(),i=t?.[e]),i?this.sanitize(this.applyParameters(i,r)):(this.logger.warn(`Missing translation for [${e}] key`),e)}sanitize(t){return(new DOMParser).parseFromString(t,"text/html").body.innerText}applyParameters(t,e={}){return Object.entries(e).reduce((t,[e,r])=>this.replaceAll(t,e,r),t)}replaceAll(t,e,r){return t.split(`{{${e}}}`).join(r)}waitFor(t,e=1,r=!0){const i=this.resolveSelector(t);return new Promise((t,s)=>{let n=1e3*e;const o=setInterval(()=>{try{const e=document.querySelector(i);e?!r||this.isElementVisible(e)?(clearInterval(o),t(e)):(n-=100,n<0&&(clearInterval(o),this.logger.warn("Element is not visible: "+i),s(new Error("Element is not visible: "+i)))):(n-=100,n<0&&(clearInterval(o),this.logger.warn("Element is not found: "+i),s(new Error("Element is not found: "+i))))}catch(t){clearInterval(o),this.logger.error("Error when processing selector: "+i),this.logger.error(String(t)),s(t)}},100)})}getOrWaitFor(t,e=1,r=!0){const i=this.resolveSelector(t),s=document.querySelector(i);return!s||r&&!this.isElementVisible(s)?this.waitFor(t,e,r):Promise.resolve(s)}scrollToOffset(t){const e=("string"==typeof t?xa.SCROLL_OFFSET_MAP[t]:void 0)??t;c.getWindow().scrollTo({top:e,behavior:"smooth"})}isElementVisible(t){const e=c.getWindow().getComputedStyle(t),r=t.getBoundingClientRect();return"none"!==e.display&&"hidden"!==e.visibility&&"0"!==e.opacity&&0!==r.width&&0!==r.height}resolveSelector(t){return"function"==typeof t?t():t}static SCROLL_OFFSET_MAP={start:0,center:c.getWindow().innerHeight/2}}class wa extends Je{NAMESPACE="guides";GUIDE_ID="guide_id";CURRENT_STEP_ID="guide.current.step.id";STEP_HISTORY="guide.step.history";PAUSE="guide.pause";AUTOSTART="guides.autostart";set(t,e){this.storeValue(t,e)}getGuideId(){return this.get(this.GUIDE_ID).getValue()}setGuideId(t){this.set(this.GUIDE_ID,t)}getCurrentStepId(){return this.get(this.CURRENT_STEP_ID).getValue()}setCurrentStepId(t){this.set(this.CURRENT_STEP_ID,t)}getHistory(){const t=this.get(this.STEP_HISTORY).getAsJson();return Array.isArray(t)?t:[]}addStepToHistory(t){const e=this.getHistory();e.push(t),this.set(this.STEP_HISTORY,JSON.stringify(e))}removeLastStepFromHistory(){const t=this.getHistory();t.pop(),this.set(this.STEP_HISTORY,JSON.stringify(t))}getPreviousStepIdFromHistory(t){const e=this.getHistory();if(t){const r=e.indexOf(t);return r>0?e[r-1]:void 0}return e.length>1?e.at(-2):void 0}clearHistory(){this.remove(this.STEP_HISTORY)}isPaused(){return"true"===this.get(this.PAUSE).getValue()}setPaused(){this.set(this.PAUSE,"true")}clearPaused(){this.remove(this.PAUSE)}saveStep(t,e){this.setGuideId(t),this.setCurrentStepId(e)}isAutostartDisabled(t){const e=this.get(this.AUTOSTART).getAsJson();return!!e?.[t]?.disabled}disableAutostart(t){const e=this.get(this.AUTOSTART).getAsJson()||{};e[t]={disabled:!0},this.set(this.AUTOSTART,JSON.stringify(e))}clearAll(){this.remove(this.GUIDE_ID),this.remove(this.PAUSE),this.remove(this.CURRENT_STEP_ID),this.remove(this.STEP_HISTORY)}}class Aa{eventEmitter=new ir;confirmCancel(t){return new Promise(e=>{this.eventEmitter.emit({NAME:ne,payload:new oe(t,t=>e(t))})})}}const ba="nearest";class Ia{logger=Pt.logger;toastrService=wt(Gi);guideApi=wt(xa);guideStorage=wt(wa);guideAutostarted=null;onPause=()=>{};onCancel=()=>{};startGuide(t,e,r,i=!1,s=!0){if(i&&this.guideStorage.isAutostartDisabled(t))return;if(this.guideAutostarted=i,s&&this.guideStorage.clearHistory(),!e)return;const n=this.createGuide(t);this.addGuideSteps(n,e),this.doStartGuide(n,r)}resumeGuide(t,e,r){this.guideStorage.clearPaused(),this.startGuide(t,e,r,!1,!1)}isActive(){return!!va.activeTour&&!this.isPaused()}isPaused(){return this.guideStorage.isPaused()}getGuideId(){return this.guideStorage.getGuideId()}getCurrentStepId(){return this.guideStorage.getCurrentStepId()}isScrollingAllowed(){const t=va.activeTour?.getCurrentStep()?.options?.allowScroll;return!this.isActive()||!!t}subscribeToGuideCancel(t){"function"==typeof t&&(this.onCancel=t)}subscribeToGuidePause(t){"function"==typeof t&&(this.onPause=t)}getPreviousStepFromHistory(t){const e=this.guideStorage.getPreviousStepIdFromHistory(t);return va.activeTour?.steps.find(t=>t.id===e)}createGuide(t){return this.subscribeToGuideCanceled(),new va.Tour({tourName:t,useModalOverlay:!0,confirmCancel:()=>this.confirmGuideCancel(),defaultStepOptions:{classes:"shadow-md bg-purple-dark",scrollTo:{behavior:"smooth",block:ba,inline:ba}}})}addGuideSteps(t,e){if(e.length>0&&t.addStep(this.getFirstStep(t,e)),e.length>2)for(let r=1;r<e.length-1;r++)t.addStep(this.getMiddleStep(t,e,r));e.length>1&&t.addStep(this.getLastStep(t,e.at(-1)))}doStartGuide(t,e){this.guideStorage.clearPaused();let r=t.steps.findIndex(t=>t.options.id===e);r<0&&(r=0);const i=t.steps[r].options,s=i.url;s&&s!==S()&&f(s);const n=i.attachTo;if(n?.element){const e=i.maxWaitTime;this.guideApi.getOrWaitFor(n.element,e).then(()=>t.show(r)).catch(t=>{this.logger.error(String(t)),this.toastrService.error(this.guideApi.translate(void 0,"guide.start.unexpected.error.message"))})}else t.show(r)}subscribeToGuideCanceled(){const t=({tour:t})=>{this.guideStorage.clearAll();const e=t.getCurrentStep();e&&"function"==typeof e.hide&&e.hide(),this.guideAutostarted=null,this.onCancel&&this.onCancel()};this.guideCancelSubscription||(this.guideCancelSubscription=va.on("cancel",t)),this.guideCompleteSubscription||(this.guideCompleteSubscription=va.on("complete",t))}getFirstStep(t,e){const r=e.length>1?e[1]:void 0;return this.toGuideStep(t,void 0,e[0],r)}getMiddleStep(t,e,r){const i=e[r];return i.lastStep?this.getLastStep(t,i):this.toGuideStep(t,e[r-1],i,e[r+1])}getLastStep(t,e){const r=this.toGuideStep(t,void 0,e);return r.buttons.push(this.getBackToGuidesButton(t),this.getCancelButton(t)),r}toGuideStep(t,e,r,i){const s=this.toBaseGuideStep(t,r,()=>this.updateLocalStorage()),n=[];return r.skipPoint&&n.push(this.getSkipButton(t,r.skipButtonLabel)),!this.isDisablePreviousFlow(r)&&e&&n.push(this.getPreviousButton(t)),!this.isDisableNextFlow(r)&&i&&n.push(this.getNextButton(t,r,i)),s.buttons=n,s}toBaseGuideStep(t,e,r){let i;e.elementSelector&&(i={element:e.elementSelector,on:e.placement});const s=this.guideApi.sanitize(this.guideApi.translate(void 0,e.title||""));let n="";if(e.stepsTotalN&&e.stepsTotalN>1){const t=document.createElement("span");t.setAttribute("gdb-tooltip",this.guideApi.translate(void 0,"guide.block.progress.tooltip",e)),t.setAttribute("tooltip-placement","bottom"),t.innerText=this.guideApi.translate(void 0,"guide.block.progress",{n:String((e.stepN||0)+1),nn:String(e.stepsTotalN)}),n="&nbsp;&mdash;&nbsp;"+t.outerHTML}const o="readonly"!==e.type,a=e.extraPadding||0,h={id:String(e.id),title:s+n,text:()=>{const t=this.toParagraph(this.guideApi.translate(void 0,e.content||""));let r="";return e.extraContent&&(r=this.toParagraph(this.guideApi.translate(void 0,e.extraContent,e),e.extraContentClass)),t+r},url:e.url,maxWaitTime:e.maxWaitTime,cancelIcon:{enabled:!0},attachTo:i,modalOverlayOpeningPadding:a,modalOverlayOpeningRadius:0,canBePaused:e.canBePaused,advanceOn:e.advanceOn,showOn:e.showOn,scrollToHandler:e.scrollToHandler,classes:`guide-dialog ${e.class||""}-guide-dialog`,beforeShowPromise:this.getBeforeShowPromise(t,e),canClickTarget:o,keyboardNavigation:!1,skipPoint:e.skipPoint,skipButtonLabel:e.skipButtonLabel,skipFromHistory:e.skipFromHistory,onPreviousClick:e.onPreviousClick,initPreviousStep:e.initPreviousStep,forceReload:e.forceReload,isLastStep:!!e.lastStep,allowScroll:e.allowScroll,when:{show:this.getShowFunction(t,e,r)}};return"function"==typeof e.hide&&h.when&&(h.when.hide=e.hide(t,e)),h}getBeforeShowPromise(t,e){if("function"==typeof e.beforeShowPromise)return()=>e.beforeShowPromise(t,e)}getShowFunction(t,e,r){return"function"==typeof e.show?()=>{e.show(t,e)(),r(),this.whenStepShow(e)}:()=>{r(),this.whenStepShow(e)}}whenStepShow(t){const e=va.activeTour?.getCurrentStep();if(!e)return;const r=e.getElement();r&&(this.addTotalProgress(e,r),this.addTypeIcon(r,t))}getBackToGuidesButton(t){return this.getButton(this.guideApi.translate(void 0,"guide.back.to.guides.btn"),()=>this.backToGuides(t),!0)}getCancelButton(t){const e=this.getButton(this.guideApi.translate(void 0,"guide.common.close"),()=>this.completeGuide(t),!0);return e.classes+=" shepherd-cancel-button",e}getSkipButton(t,e){const r=this.guideApi.translate(void 0,e||"");return this.getButton(r,()=>this.skipSteps(t),!0)}getPreviousButton(t){const e=this.guideApi.translate(void 0,"guide.previous.btn"),r=this.getPreviousButtonAction(t),i=this.getButton(e,r);return i.classes+=" shepherd-prev-button",i}getNextButton(t,e,r){const i=this.guideApi.translate(void 0,"guide.next.btn"),s=this.getNextButtonAction(t,e,r),n=this.getButton(i,s);return n.classes+=" shepherd-next-button",n}getButton(t,e,r=!1){return{text:t,classes:r?"onto-btn onto-btn-secondary":"onto-btn onto-btn-primary",action:()=>{e()}}}getPreviousButtonAction(t){return()=>{const e=this.guideStorage.getPreviousStepIdFromHistory();let r;r=e?t.steps.find(t=>t.options.id===e):t.steps[0];const i=t.getCurrentStep();if(!i||!r)return;i.hide();const s=i.options.initPreviousStep;("function"==typeof s?s({GuideUtils:this.guideApi,ShepherdService:this},i.options.id):Promise.resolve()).then(()=>{const e=i.options.onPreviousClick;if("function"==typeof e)return void e(t).then(e=>{e||(i.hide(),t.show(r.id))}).catch(e=>{this.logger.error(String(e)),this.abortGuide(t)});const s=r.options;if(s.forceReload||s.url&&s.url!==i.options.url){const t=s.url;t&&S()!==t&&f(t)}i.hide(),t.show(r.id)}).catch(e=>{this.logger.error(String(e)),this.abortGuide(t)})}}getNextButtonAction(t,e,r){return()=>{e.onNextValidate&&e.onNextValidate(e).then(i=>{if(i)if("function"==typeof e.onNextClick){const r=e.onNextClick(t,e);r instanceof Promise&&r.catch(()=>this.abortGuide(t))}else r.url&&(r.forceReload||r.url!==e.url)&&f(r.url),t.next()})}}backToGuides(t){f("guides"),this.completeGuide(t)}async confirmGuideCancel(){const t=va.activeTour,e=t.steps.at(-1),r=t.getCurrentStep();if(e&&e.id===r?.id)return this.completeGuide(t),!0;t.hide();const i=await wt(Aa).confirmCancel(this.guideAutostarted??!1);if(i===se.CANCEL)return r&&t.show(r.id),!1;if(i===se.DONT_SHOW_AGAIN){const e=t.options.tourName;e&&this.guideStorage.disableAutostart(e)}return!0}completeGuide(t){if(this.guideAutostarted){const e=t.options.tourName;e&&this.guideStorage.disableAutostart(e)}t.complete()}abortGuide(t){this.toastrService.error(this.guideApi.translate(void 0,"guide.unexpected.error.message")),t.options.confirmCancel=!1,t.cancel()}pauseGuide(t){t.hide();const e=t.getCurrentStep();if(!e)return;const r=this.getStepWhichCanBePaused(t.steps,e.id);if(r){const e=t?.options?.tourName;e&&this.guideStorage.saveStep(e,r.options.id)}if(this.guideStorage.setPaused(),r){let t=!1;for(;!t;){const e=this.guideStorage.getHistory();e.length>0&&e.at(-1)!==r.options.id?this.guideStorage.removeLastStepFromHistory():t=!0}}this.onPause()}skipSteps(t){const e=t.getCurrentStep();if(!e)return;const r=t.steps.findIndex(t=>e.id===t.id);this.doStartGuide(t,this.getNextSkipPointId(t.steps,r))}getNextSkipPointId(t,e){for(let r=e+1;r<t.length;r++){const e=t[r];if(e.options.skipPoint)return e.id}return t.at(-1)?.id}getStepWhichCanBePaused(t,e){const r=t.findIndex(t=>t.id===e),i=t[r];return i.options.canBePaused?i:r>0?this.getStepWhichCanBePaused(t,t[r-1].id):void 0}updateLocalStorage(){const t=va.activeTour;if(!t)return;const e=t.getCurrentStep();if(!e)return;if(e.options.skipFromHistory)return void this.logger.info("Current step skipped from history",e.options.id);const r=t.steps.findIndex(t=>t.id===e.id),i=this.getCurrentStepId(),s=t.steps.findIndex(t=>t.id===i);r>s?this.guideStorage.addStepToHistory(e.options.id):s>r&&this.guideStorage.removeLastStepFromHistory();const n=t.options.tourName||"";this.guideStorage.saveStep(n,e.options.id)}toParagraph(t,e){if(t){const r=document.createElement("p");return e&&(r.className=e),r.innerHTML=t,r.outerHTML}return""}addTotalProgress(t,e){const r=va.activeTour?.steps;if(!r)return;const i=e.querySelector(".shepherd-content");if(!i)return;const s=document.createElement("div");s.className="shepherd-progress";const n=document.createElement("span");n.className="text-muted",n.innerText=this.guideApi.translate(void 0,"guide.total.progress",{n:String(r.indexOf(t)+1),nn:String(r.length)}),n.setAttribute("gdb-tooltip",this.guideApi.translate(void 0,"guide.total.progress.tooltip")),n.setAttribute("tooltip-placement","left"),s.appendChild(n),i.appendChild(s)}addTypeIcon(t,e){let r,i;switch(e.type){case"clickable":r="focus",i="mouse";break;case"input":r="edit",i="input";break;default:r="info",i="info"}const s=document.createElement("span");s.className="shepherd-step-type icon-"+r+" icon-1-25x",s.setAttribute("gdb-tooltip",this.guideApi.translate(void 0,"guide.step-type."+i)),s.setAttribute("tooltip-placement","bottom-right");const n=t.querySelector(".shepherd-header");n&&n.insertBefore(s,n.firstChild)}isDisablePreviousFlow(t){return t.disablePreviousFlow??!1}isDisableNextFlow(t){return t.disableNextFlow??!1}}class Ca extends Ct{PAUSED="isPaused";updatePaused(t){this.updateContextProperty(this.PAUSED,t)}isPaused(){return this.getContextPropertyValue(this.PAUSED)}}class Ta extends nr{GUIDES_ENDPOINT="rest/guides";getGuides(){return this.get(this.GUIDES_ENDPOINT)}}class Ra{shepherdService=wt(Ia);toastrService=wt(Gi);repositoryContextService=wt(mr);guideApi=wt(xa);guideContextService=wt(Ca);guidesRestService=wt(Ta);startGuide(t,e,r,i=!1){const s=wt(hr).getLanguageBundle();if(!t)return void this.toastrService.error(this.guideApi.translate(s,"guides.error.guide-not-found"));const n=t.getRepositoryIdBase();if(n){const e=this.repositoryContextService.getRepositoryList();t.setRepositoryId(n);const r=1e3;for(let i=2;i<=r&&e.findRepository(t.getRepositoryId(),"",!0);i++)t.setRepositoryId(n+i)}t.setTranslatedGuideName(this.guideApi.translate(s,t.getName())),t.setTranslatedGuideDescription(this.guideApi.translate(s,t.getDescription()));const o=c.getPluginRegistry().get(Re.NAME),a=t.toStepsDescriptions(o,e);a.forEach((t,e)=>{t.id=e,t.scrollOffset&&(t.scrollToHandler=()=>this.guideApi.scrollToOffset(t.scrollOffset))}),r?this.shepherdService.resumeGuide(t.getId(),a,r):this.shepherdService.startGuide(t.getId(),a,r,i),this.guideContextService.updatePaused(!1)}async getGuides(){return((t=[])=>t.map((t,e)=>{const r=void 0===t.guideId?String(Date.now()+e):String(t.guideId);return new De({guideId:r,guideName:t.guideName,guideDescription:t.guideDescription,options:t.options,steps:t.steps,guideOrder:t.guideOrder,guideLevel:t.guideLevel})}))(await this.guidesRestService.getGuides())}autoStartGuide(t,e){if(!t)return;const r=String(t);this.getGuides().then(t=>{const i=t.find(t=>t.getId()===r);i&&this.startGuide(i,e,void 0,!0)})}isScrollingAllowed(){return this.shepherdService.isScrollingAllowed()}isActive(){return this.shepherdService.isActive()}}class Fa extends nr{CONNECTORS_ENDPOINT="rest/connectors";checkConnector(t){return this.post(`${this.CONNECTORS_ENDPOINT}/check`,{body:t,headers:{"Content-Type":"text/plain"}})}}class Pa extends Error{constructor(t){super(`Unknown connector command: ${t}`)}}class Da{connectorsRestService=wt(Fa);async checkConnector(t){return(t=>{let e;if(t.command)if(t.hasSupport)if($e.CREATE===t.command)e=(t=>{const e=[{name:t.name}];return new qe(Ge.SUCCESS,t.command,"created.connector",e)})(t);else if($e.REPAIR===t.command)e=(t=>{const e=[{name:t.name}];return new qe(Ge.SUCCESS,t.command,"query.editor.repaired.connector",e)})(t);else{if($e.DROP!==t.command)throw new Pa(t.command);e=(t=>{const e=[{name:t.name}];return new qe(Ge.SUCCESS,t.command,"externalsync.delete.success.msg",e)})(t)}else e=(t=>{const e=[{connectorName:t.connectorName},{pluginName:t.pluginName}];return new qe(Ge.ERROR,t.command,"query.editor.inactive.plugin.warning.msg",e)})(t);else e=(t=>new qe(Ge.SUCCESS,t.command))(t);return e.iri=t.iri,e})(await this.connectorsRestService.checkConnector(t))}}class Oa extends nr{static EXPLORE_GRAPH_ENDPOINT="rest/explore-graph";getGraphConfigs(){return this.get(`${Oa.EXPLORE_GRAPH_ENDPOINT}/config`)}}const Na=t=>new We({id:t.id,name:t.name,description:t.description,owner:t.owner,repositoryId:t.repositoryId,hint:t.hint,shared:t.shared??!1,startMode:t.startMode??Ye.SEARCH,startIRI:t.startIRI,startIRILabel:t.startIRILabel,startQueryIncludeInferred:t.startQueryIncludeInferred??!0,startQuerySameAs:t.startQuerySameAs??!0,startGraphQuery:t.startGraphQuery,expandQuery:t.expandQuery,predicateLabelQuery:t.predicateLabelQuery,resourcePropertiesQuery:t.resourcePropertiesQuery,resourceQuery:t.resourceQuery});class _a{graphConfigRestService=wt(Oa);async getGraphConfigs(){return t=await this.graphConfigRestService.getGraphConfigs(),Array.isArray(t)?new ze(t.map(Na)):new ze;var t}}class Ba extends Be{authStorage=xt.get(ti);repositoryStorageService=xt.get(fr);securityContextService=xt.get(Nr);process(t){return t.headers=t.headers||{},this.populateHeaders(t.headers),Promise.resolve(t)}shouldProcess(t){return!this.isOpenIdUrl(t.url)}populateHeaders(t){t["X-Requested-With"]="XMLHttpRequest";const e=this.authStorage.getAuthToken().getValue();if(e&&(t.Authorization=e),!t["X-GraphDB-Repository"]){const e=this.repositoryStorageService.getRepositoryReference();e?.id&&(t["X-GraphDB-Repository"]=e.id),e?.location&&(t["X-GraphDB-Repository-Location"]=e.location)}}isOpenIdUrl(t){const e=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;return!!e&&[e?.openIdKeysUri,e?.openIdTokenUrl].some(e=>e&&t.indexOf(e)>-1)}}class La extends Be{authenticationStorageService=wt(ti);authenticationService=wt(Ti);shouldProcess(t){return 401===t.status}process(t){return this.shouldRedirectToLogin(t.url)?(this.authenticationStorageService.clearAuthToken(),v()||(f("login"),c.getWindow().location.reload()),Promise.reject(t)):Promise.resolve(t)}shouldRedirectToLogin(t){let e;try{e=this.authenticationService.isExternalUser()}catch(t){e=!1}return!t.includes("rest/security/authenticated-user")&&!e}}class Ha extends Be{securityContextService=wt(Nr);authenticationService=wt(Ti);logger=Pt.logger;shouldProcess(t){return 403===t.status}process(t){const e=S();return this.logger.warn("Permission to page denied. Some errors in the console are normal"),this.updateRestrictionsForPage(e),this.shouldRedirectToLogin()&&f("login"),Promise.reject(t)}updateRestrictionsForPage(t){const e=this.securityContextService.getRestrictedPages();e&&!e.isRestricted(t)&&(e.setPageRestriction(t),this.securityContextService.updateRestrictedPages(e))}shouldRedirectToLogin(){return!this.authenticationService.isAuthenticated()}}export{it as AppSettings,$ as ApplicationBeforeChange,W as ApplicationChanged,rs as ApplicationLifecycleContextService,q as ApplicationMounted,s as ApplicationSettings,Ze as ApplicationSettingsStorageService,G as ApplicationUnmounted,Ba as AuthRequestInterceptor,ut as AuthSettings,xi as AuthStrategyResolver,ot as AuthenticatedUser,Ti as AuthenticationService,ti as AuthenticationStorageService,X as AuthenticationType,J as Authority,rt as AuthorityList,bi as AuthorizationService,Yi as AutocompleteContextService,le as AutocompleteSearchResult,Wi as AutocompleteService,zi as AutocompleteStorageService,Nt as AvailableLanguagesList,qe as BeforeUpdateQueryResult,Ge as BeforeUpdateQueryResultStatus,Pi as BrowserCookieStore,l as BuildUtil,u as ByteUtils,ne as CONFIRM_CANCEL_EVENT,Li as COOKIE_CONSENT_CHANGED_EVENT,re as CREATE_TOAST_EVENT,se as CancelDialogAction,ft as CapabilityList,Tt as ConfigurationContextService,ds as ConfigurationRestService,ps as ConfigurationService,oe as ConfirmCancelPayload,$e as ConnectorCommand,Fa as ConnectorsRestService,Da as ConnectorsService,Ct as ContextService,It as ContextSubscriptionManager,Fi as CookieBuilder,Lt as CookieConsent,Di as CookieService,I as DateUtil,Aa as DialogService,Lr as ErrorBase,U as Event,ir as EventEmitter,j as EventName,ri as EventService,Se as ExtensionPoint,p as FibonacciGenerator,Bi as GoogleAnalyticsCookieService,We as GraphConfig,ze as GraphConfigList,_a as GraphConfigService,xa as GuideApi,Ca as GuideContextService,Ie as GuidePlugin,wa as GuideStorageService,Ta as GuidesRestService,Ra as GuidesService,sr as HTTP_REQUEST_DONE_EVENT,je as HttpErrorResponse,Be as HttpInterceptor,Le as HttpInterceptorList,He as HttpRequest,Ue as HttpResponse,ke as HttpResponseBase,_i as InstallationCookieService,De as InteractiveGuide,Re as InteractiveGuideExtensionPoint,rr as InterceptorService,Bt as LanguageConfig,hr as LanguageContextService,or as LanguageRestService,lr as LanguageService,ar as LanguageStorageService,gt as License,Rr as LicenseContextService,Fr as LicenseService,fe as LifecycleState,Je as LocalStorageService,Qe as LocalStorageSubscriptionHandlerService,Rt as LoggerService,Ft as Loggers,Y as Login,z as Logout,Ce as MainMenuExtensionPoint,Ae as MainMenuItem,we as MainMenuPlugin,C as Model,T as ModelList,ki as MonitoringRestService,Vi as MonitoringService,k as NamespaceMap,ts as NamespacesContextService,Zi as NamespacesService,Ci as NavigationContextService,V as NavigationEnd,M as NavigationEndPayload,K as NavigationStart,Ne as Notification,_e as NotificationParam,Wr as NotificationService,Oe as NotificationType,n as ObjectUtil,Gi as OntoToastrService,Yr as OpenIdAuthFlowHandler,Jr as OpenIdRestService,ii as OpenIdService,Zr as OpenIdTokenRefreshManager,Qr as OpenIdUrlBuilder,Vr as OpenIdUtils,at as OpenidSecurityConfig,_r as OpenidStorageService,zt as Operation,qt as OperationGroup,Ut as OperationGroupSummary,jt as OperationGroupSummaryList,Mt as OperationList,Ht as OperationStatus,Vt as OperationStatusSummary,Kt as OperationType,Ss as ParentWindowMessageService,xe as Plugin,me as PluginDefinition,Ee as PluginDefinitionList,us as PluginRegistry,ye as PluginsManifest,is as PluginsRestService,ss as PluginsService,mt as ProductInfo,Pr as ProductInfoContextService,Or as ProductInfoService,B as REPOSITORY_ID_PARAM,Qi as Rdf4jRepositoryService,Ji as Rdf4jRestService,F as Repository,yr as RepositoryAuthorityService,mr as RepositoryContextService,D as RepositoryList,L as RepositoryLocation,xr as RepositoryLocationContextService,Er as RepositoryLocationService,H as RepositoryLocationType,dr as RepositoryRestService,gr as RepositoryService,O as RepositorySizeInfo,N as RepositoryState,fr as RepositoryStorageService,_ as RepositoryType,es as ResourceSearchStorageService,dt as RestrictedPages,pt as Rights,Te as RouteExtensionPoint,be as RoutePlugin,tr as RuntimeConfigurationContextService,kt as STATUS_ORDER,Me as SavedQuery,Ve as SavedQueryList,Ke as ScrollLocation,ue as SearchButton,he as SearchButtonConfig,ae as SearchButtonList,lt as SecurityConfig,Nr as SecurityContextService,mi as SecurityService,xt as ServiceProvider,Ia as ShepherdService,fs as SparqlRestService,ys as SparqlService,vs as SparqlStorageService,Ye as StartMode,Dt as StorageData,Ot as StorageKey,R as SubscriptionList,de as Suggestion,ce as SuggestionList,ge as SuggestionSelectedPayload,pe as SuggestionType,i as ThemeMode,er as ThemeService,Fe as ThemesExtensionPoint,ee as ToastMessage,ie as ToastMessageList,Qt as ToastType,Jt as ToastrConfig,Yt as ToastrPosition,Hi as TrackingService,Oi as TrackingStorageService,La as UnauthenticatedInterceptor,Ha as UnauthorizedInterceptor,d as UriUtil,Xe as UrlPathParams,nt as User,st as UserType,fi as UsersService,c as WindowService,x as getBasePath,w as getCurrentRoute,A as getLocationPathWithQueryParams,E as getOrigin,S as getPathName,y as isHomePage,v as isLoginPage,ct as mapAuthSettingsResponseToModel,ui as mapAuthenticatedUserResponseToModel,tt as mapGrantedAuthoritiesResponseToModel,Xi as mapNamespaceResponseToModel,ji as mapOperationSummaryResponseToModel,pr as mapRepositoryListResponseToModel,ms as mapSavedQueryListResponseToModel,gs as mapSparqlTemplatesResponseToModel,pi as mapUserModelToRequest,gi as mapUserResponseToModel,f as navigate,g as navigateTo,zr as notify,m as openInNewTab,wt as service,b as toEnum};