graphdb-workbench 4.0.0-TR2 → 4.0.0-TR3

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 (121) hide show
  1. package/dist/{30575.19fdf3b549db571bb535.bundle.js → 30575.184c5f6f13b5bff89fec.bundle.js} +2 -2
  2. package/dist/30575.184c5f6f13b5bff89fec.bundle.js.map +1 -0
  3. package/dist/32401.e87fc66be912718fffc3.bundle.js +2 -0
  4. package/dist/32401.e87fc66be912718fffc3.bundle.js.map +1 -0
  5. package/dist/44906.42387d9a889a05ef93ae.bundle.js +2 -0
  6. package/dist/44906.42387d9a889a05ef93ae.bundle.js.map +1 -0
  7. package/dist/{64700.a10c20a33a6c92f01733.bundle.js → 64700.847995c53301ff65bccd.bundle.js} +2 -2
  8. package/dist/64700.847995c53301ff65bccd.bundle.js.map +1 -0
  9. package/dist/{64709.dfde8159d07e957a12b0.bundle.js → 64709.d0144177c2b8d83b494f.bundle.js} +2 -2
  10. package/dist/{64709.dfde8159d07e957a12b0.bundle.js.map → 64709.d0144177c2b8d83b494f.bundle.js.map} +1 -1
  11. package/dist/{65677.4ed21f2097d86718611c.bundle.js → 65677.9e40e2d5fe66932a18ab.bundle.js} +2 -2
  12. package/dist/{65677.4ed21f2097d86718611c.bundle.js.map → 65677.9e40e2d5fe66932a18ab.bundle.js.map} +1 -1
  13. package/dist/{75384.cc7de25be91251aa6aa4.bundle.js → 75384.94d3d9790b82fe24ba69.bundle.js} +2 -2
  14. package/dist/75384.94d3d9790b82fe24ba69.bundle.js.map +1 -0
  15. package/dist/79796.9e99cce3ecaefe7b75fc.bundle.js +2 -0
  16. package/dist/79796.9e99cce3ecaefe7b75fc.bundle.js.map +1 -0
  17. package/dist/{80933.19f69bc85c52a8b19311.bundle.js → 80933.d5c0bca925e9cb27ac57.bundle.js} +2 -2
  18. package/dist/{80933.19f69bc85c52a8b19311.bundle.js.map → 80933.d5c0bca925e9cb27ac57.bundle.js.map} +1 -1
  19. package/dist/{82917.c68c153aaca95c11341f.bundle.js → 82917.9da9f14ffe9dc7768d10.bundle.js} +2 -2
  20. package/dist/{82917.c68c153aaca95c11341f.bundle.js.map → 82917.9da9f14ffe9dc7768d10.bundle.js.map} +1 -1
  21. package/dist/{86099.ab0bf43b346e9cfb20d8.bundle.js → 86099.33c740b4d5684dde18c7.bundle.js} +2 -2
  22. package/dist/{86099.ab0bf43b346e9cfb20d8.bundle.js.map → 86099.33c740b4d5684dde18c7.bundle.js.map} +1 -1
  23. package/dist/api/models/broadcast/broadcast-message.d.ts +11 -0
  24. package/dist/api/models/broadcast/index.d.ts +3 -0
  25. package/dist/api/models/broadcast/message-handler.d.ts +5 -0
  26. package/dist/api/models/broadcast/message-type.d.ts +3 -0
  27. package/dist/api/ontotext-workbench-api.d.ts +2 -0
  28. package/dist/api/ontotext-workbench-api.js +1 -1
  29. package/dist/api/ontotext-workbench-api.js.map +1 -1
  30. package/dist/api/services/broadcast/broadcast.service.d.ts +24 -0
  31. package/dist/api/services/broadcast/index.d.ts +1 -0
  32. package/dist/api/services/broadcast/test/broadcast.service.spec.d.ts +1 -0
  33. package/dist/assets/i18n/language-config.json +1 -1
  34. package/dist/css/user.css +1 -1
  35. package/dist/i18n/locale-en.json +1 -0
  36. package/dist/i18n/locale-fr.json +1 -0
  37. package/dist/index.html +8 -8
  38. package/dist/js/angular/clustermanagement/templates/cluster-configuration/cluster-configuration.html +1 -1
  39. package/dist/js/angular/clustermanagement/templates/cluster-configuration/multi-region.html +1 -1
  40. package/dist/js/angular/clustermanagement/templates/cluster-nodes-configuration.html +1 -1
  41. package/dist/js/angular/core/directives/autocomplete/templates/autocomplete.html +1 -1
  42. package/dist/js/angular/core/directives/dynamic-form/templates/dynamic-form.html +1 -1
  43. package/dist/js/angular/core/directives/operations-statuses-monitor/templates/operations-statuses-monitor.html +1 -1
  44. package/dist/js/angular/core/directives/rdfresourcesearch/templates/rdfResourceSearchTemplate.html +1 -1
  45. package/dist/js/angular/core/directives/shuttle-multiselect/templates/shuttle-multiselect.html +1 -1
  46. package/dist/js/angular/core/directives/yasgui-component/templates/yasgui-component.html +2 -2
  47. package/dist/js/angular/core/templates/cookie-policy/cookie-consent.html +1 -1
  48. package/dist/js/angular/core/templates/cookie-policy/cookie-policy.html +1 -1
  49. package/dist/js/angular/core/templates/editable-content/editable-content.html +1 -1
  50. package/dist/js/angular/core/templates/markdown-content/markdown-content.html +1 -1
  51. package/dist/js/angular/core/templates/search-resource-input.html +1 -1
  52. package/dist/js/angular/graphql/templates/create-graphql-endpoint.html +2 -2
  53. package/dist/js/angular/graphql/templates/graphql-endpoint-management.html +1 -1
  54. package/dist/js/angular/graphql/templates/graphql-playground.html +2 -2
  55. package/dist/js/angular/graphql/templates/modal/endpoint-configuration-modal.html +1 -1
  56. package/dist/js/angular/graphql/templates/modal/endpoint-generation-failure-result-modal.html +1 -1
  57. package/dist/js/angular/graphql/templates/modal/import-endpoint-definition-modal.html +1 -1
  58. package/dist/js/angular/security/templates/user.html +8 -5
  59. package/dist/js/angular/security/templates/users.html +1 -1
  60. package/dist/js/angular/ttyg/templates/agent-list.html +1 -1
  61. package/dist/js/angular/ttyg/templates/agent-select-menu.html +1 -1
  62. package/dist/js/angular/ttyg/templates/chat-item-detail.html +1 -1
  63. package/dist/js/angular/ttyg/templates/chat-list.html +1 -1
  64. package/dist/js/angular/ttyg/templates/chat-panel.html +1 -1
  65. package/dist/js/angular/ttyg/templates/modal/agent-instructions-explain-modal.html +1 -1
  66. package/dist/js/angular/ttyg/templates/modal/agent-settings-modal.html +3 -3
  67. package/dist/js/angular/ttyg/templates/modal/external-integration-configuration-modal.html +1 -1
  68. package/dist/js/angular/ttyg/templates/no-agents-view.html +1 -1
  69. package/dist/js/angular/ttyg/templates/ttyg.html +1 -1
  70. package/dist/legacyWorkbench.5ba16dfe45d478531c81.js +3 -0
  71. package/dist/{legacyWorkbench.d546b7e4a3f1505b1746.js.map → legacyWorkbench.5ba16dfe45d478531c81.js.map} +1 -1
  72. package/dist/pages/aclmanagement.html +1 -1
  73. package/dist/pages/autocomplete.html +1 -1
  74. package/dist/pages/choose-repository-type.html +1 -1
  75. package/dist/pages/cluster-management/clusterInfo.html +2 -2
  76. package/dist/pages/create-index.html +1 -1
  77. package/dist/pages/dependencies.html +1 -1
  78. package/dist/pages/domainRangeInfo.html +2 -2
  79. package/dist/pages/edit.html +1 -1
  80. package/dist/pages/explore.html +1 -1
  81. package/dist/pages/export.html +1 -1
  82. package/dist/pages/find.html +1 -1
  83. package/dist/pages/graph-config/saveGraphConfig.html +8 -8
  84. package/dist/pages/graphs-visualizations.html +7 -7
  85. package/dist/pages/guides.html +1 -1
  86. package/dist/pages/home.html +1 -1
  87. package/dist/pages/import.html +2 -2
  88. package/dist/pages/jdbc-create.html +1 -1
  89. package/dist/pages/jdbc.html +1 -1
  90. package/dist/pages/monitor/backup-and-restore.html +1 -1
  91. package/dist/pages/monitor/queries.html +1 -1
  92. package/dist/pages/monitor/resources.html +1 -1
  93. package/dist/pages/namespaces.html +2 -2
  94. package/dist/pages/plugins.html +1 -1
  95. package/dist/pages/rdfClassHierarchyInfo.html +7 -7
  96. package/dist/pages/rdfrank.html +2 -2
  97. package/dist/pages/repositories.html +1 -1
  98. package/dist/pages/repository.html +1 -1
  99. package/dist/pages/similarity-indexes.html +1 -1
  100. package/dist/pages/sparql-editor.html +1 -1
  101. package/dist/pages/sparql-template-create.html +1 -1
  102. package/dist/pages/sparql-templates.html +1 -1
  103. package/dist/pages/ux-test1.html +2 -2
  104. package/dist/pages/webapi.html +2 -2
  105. package/dist/plugins/plugins-bundle.js +1 -1
  106. package/dist/plugins/plugins-bundle.js.map +1 -1
  107. package/dist/plugins.js +1 -1
  108. package/dist/res/swagger5/index.html +11 -11
  109. package/dist/shared-components/collection/pages/js/main.js +1 -1
  110. package/package.json +2 -2
  111. package/dist/30575.19fdf3b549db571bb535.bundle.js.map +0 -1
  112. package/dist/32401.023d0082b98ee532b4d3.bundle.js +0 -2
  113. package/dist/32401.023d0082b98ee532b4d3.bundle.js.map +0 -1
  114. package/dist/44906.6d83b4aafb42ccc2f46c.bundle.js +0 -2
  115. package/dist/44906.6d83b4aafb42ccc2f46c.bundle.js.map +0 -1
  116. package/dist/64700.a10c20a33a6c92f01733.bundle.js.map +0 -1
  117. package/dist/75384.cc7de25be91251aa6aa4.bundle.js.map +0 -1
  118. package/dist/79796.c484b55f1aa1581ac64c.bundle.js +0 -2
  119. package/dist/79796.c484b55f1aa1581ac64c.bundle.js.map +0 -1
  120. package/dist/legacyWorkbench.d546b7e4a3f1505b1746.js +0 -3
  121. /package/dist/{legacyWorkbench.d546b7e4a3f1505b1746.js.LICENSE.txt → legacyWorkbench.5ba16dfe45d478531c81.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,n,s,o,a,c,u,h,l,p,d={userAgent:!1},g={},f=f||(r=Math,n=(i={}).lib={},s=n.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=n.WordArray=s.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,n=t.sigBytes;if(this.clamp(),i%4)for(var s=0;s<n;s++){var o=r[s>>>2]>>>24-s%4*8&255;e[i+s>>>2]|=o<<24-(i+s)%4*8}else for(s=0;s<n;s+=4)e[i+s>>>2]=r[s>>>2];return this.sigBytes+=n,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=s.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=[],n=0;n<r;n++){var s=e[n>>>2]>>>24-n%4*8&255;i.push((s>>>4).toString(16)),i.push((15&s).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)}},u=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n<r;n++){var s=e[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(s))}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)}},h=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},l=n.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,s=this.blockSize,a=n/(4*s),c=(a=t?r.ceil(a):r.max((0|a)-this._minBufferSize,0))*s,u=r.min(4*c,n);if(c){for(var h=0;h<c;h+=s)this._doProcessBlock(i,h);var l=i.splice(0,c);e.sigBytes-=u}return new o.init(l,u)},clone:function(){var t=s.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),n.Hasher=l.extend({cfg:s.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=[],n=0;n<e;n++){var s=t[n];r.push(s.high),r.push(s.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,n=0;n<i;n++)e[n]=e[n].clone();return t}})}(),f.lib.Cipher||function(){var t=(p=f).lib,e=t.Base,r=t.WordArray,i=t.BufferedBlockAlgorithm,n=p.enc.Base64,s=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 n=0;n<r;n++)t[e+n]^=i[n]},u=(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();u.Encryptor=u.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)}}),u.Decryptor=u.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,n=t.slice(e,e+i);r.decryptBlock(t,e),c.call(this,t,e,i),this._prevBlock=n}}),a=a.CBC=u,u=(p.pad={}).Pkcs7={pad:function(t,e){for(var i,n=(i=(i=4*e)-t.sigBytes%i)<<24|i<<16|i<<8|i,s=[],o=0;o<i;o+=4)s.push(n);i=r.create(s,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:u}),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 h=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(n)},parse:function(t){var e=(t=n.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 h.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 n=t.createEncryptor(r,i);return e=n.finalize(e),n=n.cfg,h.create({ciphertext:e,key:r,iv:n.iv,algorithm:t,mode:n.mode,padding:n.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,n){return n||(n=r.random(8)),t=s.create({keySize:e+i}).compute(t,n),i=r.create(t.words.slice(e),4*i),t.sigBytes=4*e,h.create({key:t,iv:i,salt:n})}},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=[],n=[],s=[],o=[],a=[],c=[],u=[],h=[],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 S=(S=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&S^99;i[m]=S,n[S]=m;var v=d[m],E=d[v],x=d[E],A=257*d[S]^16843008*S;s[m]=A<<24|A>>>8,o[m]=A<<16|A>>>16,a[m]=A<<8|A>>>24,c[m]=A,A=16843009*x^65537*E^257*v^16843008*m,u[S]=A<<24|A>>>8,h[S]=A<<16|A>>>16,l[S]=A<<8|A>>>24,p[S]=A,m?(m=v^d[d[d[x^v]]],y^=d[d[y]]):m=y=1}var w=[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),n=this._keySchedule=[],s=0;s<r;s++)if(s<e)n[s]=t[s];else{var o=n[s-1];s%e?6<e&&4==s%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^=w[s/e|0]<<24),n[s]=n[s-e]^o}for(t=this._invKeySchedule=[],e=0;e<r;e++)s=r-e,o=e%4?n[s]:n[s-4],t[e]=4>e||4>=s?o:u[i[o>>>24]]^h[i[o>>>16&255]]^l[i[o>>>8&255]]^p[i[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,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,u,h,l,p,n),r=t[e+1],t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,i,n,s,o,a){for(var c=this._nRounds,u=t[e]^r[0],h=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[u>>>24]^n[h>>>16&255]^s[l>>>8&255]^o[255&p]^r[d++],m=i[h>>>24]^n[l>>>16&255]^s[p>>>8&255]^o[255&u]^r[d++],y=i[l>>>24]^n[p>>>16&255]^s[u>>>8&255]^o[255&h]^r[d++];p=i[p>>>24]^n[u>>>16&255]^s[h>>>8&255]^o[255&l]^r[d++],u=f,h=m,l=y}f=(a[u>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^r[d++],m=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&u])^r[d++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[u>>>8&255]<<8|a[255&h])^r[d++],p=(a[p>>>24]<<24|a[u>>>16&255]<<16|a[h>>>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=(n=r.lib).WordArray,n=n.BlockCipher,s=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],u=[{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}],h=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],l=s.DES=n.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 n=t[i]=[],s=c[i];for(r=0;24>r;r++)n[r/6|0]|=e[(a[r]-1+s)%28]<<31-r%6,n[4+(r/6|0)]|=e[28+(a[r+24]-1+s)%28]<<31-r%6;for(n[0]=n[0]<<1|n[0]>>>31,r=1;7>r;r++)n[r]>>>=4*(r-1)+3;n[7]=n[7]<<5|n[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,n){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 s=0;16>s;s++){for(var o=n[s],a=this._lBlock,c=this._rBlock,l=0,p=0;8>p;p++)l|=u[p][((c^o[p])&h[p])>>>0];this._lBlock=c,this._rBlock=a^l}n=this._lBlock,this._lBlock=this._rBlock,this._rBlock=n,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=n._createHelper(l),s=s.TripleDES=n.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=n._createHelper(s)}(),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 n=0;n<r;n+=3)for(var s=(e[n>>>2]>>>24-n%4*8&255)<<16|(e[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|e[n+2>>>2]>>>24-(n+2)%4*8&255,o=0;4>o&&n+.75*o<r;o++)t.push(i.charAt(s>>>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;(n=i.charAt(64))&&-1!=(n=t.indexOf(n))&&(r=n);for(var n=[],s=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;n[s>>>2]|=(a|c)<<24-s%4*8,s++}return e.create(n,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,r,i,n,s,o){return((t=t+(e&r|~e&i)+n+o)<<s|t>>>32-s)+e}function r(t,e,r,i,n,s,o){return((t=t+(e&i|r&~i)+n+o)<<s|t>>>32-s)+e}function i(t,e,r,i,n,s,o){return((t=t+(e^r^i)+n+o)<<s|t>>>32-s)+e}function n(t,e,r,i,n,s,o){return((t=t+(r^(e|~i))+n+o)<<s|t>>>32-s)+e}for(var s=f,o=(c=s.lib).WordArray,a=c.Hasher,c=s.algo,u=[],h=0;64>h;h++)u[h]=4294967296*t.abs(t.sin(h+1))|0;c=c.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[c=s+o];t[c]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var c=t[s+0],h=(a=t[s+1],t[s+2]),l=t[s+3],p=t[s+4],d=t[s+5],g=t[s+6],f=t[s+7],m=t[s+8],y=t[s+9],S=t[s+10],v=t[s+11],E=t[s+12],x=t[s+13],A=t[s+14],w=t[s+15],b=e(b=o[0],R=o[1],I=o[2],T=o[3],c,7,u[0]),T=e(T,b,R,I,a,12,u[1]),I=e(I,T,b,R,h,17,u[2]),R=e(R,I,T,b,l,22,u[3]);b=e(b,R,I,T,p,7,u[4]),T=e(T,b,R,I,d,12,u[5]),I=e(I,T,b,R,g,17,u[6]),R=e(R,I,T,b,f,22,u[7]),b=e(b,R,I,T,m,7,u[8]),T=e(T,b,R,I,y,12,u[9]),I=e(I,T,b,R,S,17,u[10]),R=e(R,I,T,b,v,22,u[11]),b=e(b,R,I,T,E,7,u[12]),T=e(T,b,R,I,x,12,u[13]),I=e(I,T,b,R,A,17,u[14]),b=r(b,R=e(R,I,T,b,w,22,u[15]),I,T,a,5,u[16]),T=r(T,b,R,I,g,9,u[17]),I=r(I,T,b,R,v,14,u[18]),R=r(R,I,T,b,c,20,u[19]),b=r(b,R,I,T,d,5,u[20]),T=r(T,b,R,I,S,9,u[21]),I=r(I,T,b,R,w,14,u[22]),R=r(R,I,T,b,p,20,u[23]),b=r(b,R,I,T,y,5,u[24]),T=r(T,b,R,I,A,9,u[25]),I=r(I,T,b,R,l,14,u[26]),R=r(R,I,T,b,m,20,u[27]),b=r(b,R,I,T,x,5,u[28]),T=r(T,b,R,I,h,9,u[29]),I=r(I,T,b,R,f,14,u[30]),b=i(b,R=r(R,I,T,b,E,20,u[31]),I,T,d,4,u[32]),T=i(T,b,R,I,m,11,u[33]),I=i(I,T,b,R,v,16,u[34]),R=i(R,I,T,b,A,23,u[35]),b=i(b,R,I,T,a,4,u[36]),T=i(T,b,R,I,p,11,u[37]),I=i(I,T,b,R,f,16,u[38]),R=i(R,I,T,b,S,23,u[39]),b=i(b,R,I,T,x,4,u[40]),T=i(T,b,R,I,c,11,u[41]),I=i(I,T,b,R,l,16,u[42]),R=i(R,I,T,b,g,23,u[43]),b=i(b,R,I,T,y,4,u[44]),T=i(T,b,R,I,E,11,u[45]),I=i(I,T,b,R,w,16,u[46]),b=n(b,R=i(R,I,T,b,h,23,u[47]),I,T,c,6,u[48]),T=n(T,b,R,I,f,10,u[49]),I=n(I,T,b,R,A,15,u[50]),R=n(R,I,T,b,d,21,u[51]),b=n(b,R,I,T,E,6,u[52]),T=n(T,b,R,I,l,10,u[53]),I=n(I,T,b,R,S,15,u[54]),R=n(R,I,T,b,a,21,u[55]),b=n(b,R,I,T,m,6,u[56]),T=n(T,b,R,I,w,10,u[57]),I=n(I,T,b,R,g,15,u[58]),R=n(R,I,T,b,x,21,u[59]),b=n(b,R,I,T,p,6,u[60]),T=n(T,b,R,I,v,10,u[61]),I=n(I,T,b,R,h,15,u[62]),R=n(R,I,T,b,y,21,u[63]),o[0]=o[0]+b|0,o[1]=o[1]+R|0,o[2]=o[2]+I|0,o[3]=o[3]+T|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;r[n>>>5]|=128<<24-n%32;var s=t.floor(i/4294967296);for(r[15+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),r[14+(n+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++)n=r[i],r[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(c),s.HmacMD5=a._createHmacHelper(c)}(Math),function(){var t=f,e=(n=t.lib).WordArray,r=n.Hasher,i=[],n=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,n=r[0],s=r[1],o=r[2],a=r[3],c=r[4],u=0;80>u;u++){if(16>u)i[u]=0|t[e+u];else{var h=i[u-3]^i[u-8]^i[u-14]^i[u-16];i[u]=h<<1|h>>>31}h=(n<<5|n>>>27)+c+i[u],h=20>u?h+(1518500249+(s&o|~s&a)):40>u?h+(1859775393+(s^o^a)):60>u?h+((s&o|s&a|o&a)-1894007588):h+((s^o^a)-899497514),c=a,a=o,o=s<<30|s>>>2,s=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+s|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(n),t.HmacSHA1=r._createHmacHelper(n)}(),function(t){for(var e=f,r=(n=e.lib).WordArray,i=n.Hasher,n=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},c=2,u=0;64>u;){var h;t:{h=c;for(var l=t.sqrt(h),p=2;p<=l;p++)if(!(h%p)){h=!1;break t}h=!0}h&&(8>u&&(s[u]=a(t.pow(c,.5))),o[u]=a(t.pow(c,1/3)),u++),c++}var d=[];n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(s.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],n=r[1],s=r[2],a=r[3],c=r[4],u=r[5],h=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&u^~c&h)+o[p]+d[p],f=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&n^i&s^n&s),l=h,h=u,u=c,c=a+g|0,a=s,s=n,n=i,i=g+f|0}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0,r[5]=r[5]+u|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;return r[n>>>5]|=128<<24-n%32,r[14+(n+64>>>9<<4)]=t.floor(i/4294967296),r[15+(n+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(n),e.HmacSHA256=i._createHmacHelper(n)}(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=(s=e.x64).Word,n=s.WordArray,s=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();s=s.SHA512=r.extend({_doReset:function(){this._hash=new n.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],n=l[2],s=l[3],c=l[4],u=l[5],h=l[6],l=l[7],p=r.high,d=r.low,g=i.high,f=i.low,m=n.high,y=n.low,S=s.high,v=s.low,E=c.high,x=c.low,A=u.high,w=u.low,b=h.high,T=h.low,I=l.high,R=l.low,C=p,P=d,F=g,N=f,O=m,D=y,_=S,L=v,B=E,H=x,k=A,U=w,j=b,M=T,V=I,K=R,G=0;80>G;G++){var q=a[G];if(16>G)var $=q.high=0|t[e+2*G],W=q.low=0|t[e+2*G+1];else{$=((W=($=a[G-15]).high)>>>1|(z=$.low)<<31)^(W>>>8|z<<24)^W>>>7;var z=(z>>>1|W<<31)^(z>>>8|W<<24)^(z>>>7|W<<25),Y=((W=(Y=a[G-2]).high)>>>19|(X=Y.low)<<13)^(W<<3|X>>>29)^W>>>6,X=(X>>>19|W<<13)^(X<<3|W>>>29)^(X>>>6|W<<26),J=(W=a[G-7]).high,Q=(Z=a[G-16]).high,Z=Z.low;$=($=($=$+J+((W=z+W.low)>>>0<z>>>0?1:0))+Y+((W+=X)>>>0<X>>>0?1:0))+Q+((W+=Z)>>>0<Z>>>0?1:0),q.high=$,q.low=W}J=B&k^~B&j,Z=H&U^~H&M,q=C&F^C&O^F&O;var tt=P&N^P&D^N&D,et=(z=(C>>>28|P<<4)^(C<<30|P>>>2)^(C<<25|P>>>7),Y=(P>>>28|C<<4)^(P<<30|C>>>2)^(P<<25|C>>>7),(X=o[G]).high),rt=X.low;Q=V+((B>>>14|H<<18)^(B>>>18|H<<14)^(B<<23|H>>>9))+((X=K+((H>>>14|B<<18)^(H>>>18|B<<14)^(H<<23|B>>>9)))>>>0<K>>>0?1:0),V=j,K=M,j=k,M=U,k=B,U=H,B=_+(Q=(Q=(Q=Q+J+((X+=Z)>>>0<Z>>>0?1:0))+et+((X+=rt)>>>0<rt>>>0?1:0))+$+((X+=W)>>>0<W>>>0?1:0))+((H=L+X|0)>>>0<L>>>0?1:0)|0,_=O,L=D,O=F,D=N,F=C,N=P,C=Q+(q=z+q+((W=Y+tt)>>>0<Y>>>0?1:0))+((P=X+W|0)>>>0<X>>>0?1:0)|0}d=r.low=d+P,r.high=p+C+(d>>>0<P>>>0?1:0),f=i.low=f+N,i.high=g+F+(f>>>0<N>>>0?1:0),y=n.low=y+D,n.high=m+O+(y>>>0<D>>>0?1:0),v=s.low=v+L,s.high=S+_+(v>>>0<L>>>0?1:0),x=c.low=x+H,c.high=E+B+(x>>>0<H>>>0?1:0),w=u.low=w+U,u.high=A+k+(w>>>0<U>>>0?1:0),T=h.low=T+M,h.high=b+j+(T>>>0<M>>>0?1:0),R=l.low=R+K,l.high=I+V+(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(s),e.HmacSHA512=r._createHmacHelper(s)}(),function(){var t=f,e=(n=t.x64).Word,r=n.WordArray,i=(n=t.algo).SHA512,n=n.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(n),t.HmacSHA384=i._createHmacHelper(n)}(),function(){var t=f,e=(i=t.lib).WordArray,r=i.Hasher,i=t.algo,n=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]),s=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]),u=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 h,l,p,d,g,f,m,y,S,v,E,x=this._hash.words,A=(i=c.words,u.words),w=n.words,b=s.words,T=o.words,I=a.words;for(f=h=x[0],m=l=x[1],y=p=x[2],S=d=x[3],v=g=x[4],r=0;80>r;r+=1)E=h+t[e+w[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)<<T[r]|E>>>32-T[r])+g|0,h=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|~S))+A[0]):32>r?E+((m&S|y&~S)+A[1]):48>r?E+(((m|~y)^S)+A[2]):64>r?E+((m&y|~m&S)+A[3]):E+((m^y^S)+A[4]),E=(E=(E|=0)<<I[r]|E>>>32-I[r])+v|0,f=v,v=S,S=y<<10|y>>>22,y=m,m=E;E=x[1]+p+S|0,x[1]=x[2]+d+v|0,x[2]=x[3]+g+f|0,x[3]=x[4]+h+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,n=4*i;r.sigBytes>n&&(r=t.finalize(r)),r.clamp();for(var s=this._oKey=r.clone(),o=this._iKey=r.clone(),a=s.words,c=o.words,u=0;u<i;u++)a[u]^=1549556828,c[u]^=909522486;s.sigBytes=o.sigBytes=n,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,n=(t=e.algo).HMAC,s=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,s=n.create(r.hasher,t),o=i.create(),a=i.create([1]),c=o.words,u=a.words,h=r.keySize;for(r=r.iterations;c.length<h;){var l=s.update(e).finalize(a);s.reset();for(var p=l.words,d=p.length,g=l,f=1;f<r;f++){g=s.finalize(g),s.reset();for(var m=g.words,y=0;y<d;y++)p[y]^=m[y]}o.concat(l),u[0]++}return o.sigBytes=4*h,o}});e.PBKDF2=function(t,e,r){return s.create(r).compute(t,e)}}();var m,y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function S(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 v(t){var e,r,i,n="",s=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e)(i=y.indexOf(t.charAt(e)))<0||(0==s?(n+=T(i>>2),r=3&i,s=1):1==s?(n+=T(r<<2|i>>4),r=15&i,s=2):2==s?(n+=T(r),n+=T(i>>2),r=3&i,s=3):(n+=T(r<<2|i>>4),n+=T(15&i),s=0));return 1==s&&(n+=T(r<<2)),n}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,n,s){for(var o=32767&e,a=e>>15;--s>=0;){var c=32767&this[t],u=this[t++]>>15,h=a*c+u*o;n=((c=o*c+((32767&h)<<15)+r[i]+(1073741823&n))>>>30)+(h>>>15)+a*u+(n>>>30),r[i++]=1073741823&c}return n},m=30):"Netscape"!=d.appName?(E.prototype.am=function(t,e,r,i,n,s){for(;--s>=0;){var o=e*this[t++]+r[i]+n;n=Math.floor(o/67108864),r[i++]=67108863&o}return n},m=26):(E.prototype.am=function(t,e,r,i,n,s){for(var o=16383&e,a=e>>14;--s>=0;){var c=16383&this[t],u=this[t++]>>14,h=a*c+u*o;n=((c=o*c+((16383&h)<<14)+r[i]+n)>>28)+(h>>14)+a*u,r[i++]=268435455&c}return n},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 A,w,b=new Array;for(A="0".charCodeAt(0),w=0;w<=9;++w)b[A++]=w;for(A="a".charCodeAt(0),w=10;w<36;++w)b[A++]=w;for(A="A".charCodeAt(0),w=10;w<36;++w)b[A++]=w;function T(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 C(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 P(t){this.m=t}function F(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 N(t,e){return t&e}function O(t,e){return t|e}function D(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}P.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},P.prototype.revert=function(t){return t},P.prototype.reduce=function(t){t.divRemTo(this.m,null,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)},F.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},F.prototype.revert=function(t){var e=x();return t.copyTo(e),this.reduce(e),e},F.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)},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)},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,n=!1,s=0;--i>=0;){var o=8==r?255&t[i]:I(t,i);o<0?"-"==t.charAt(i)&&(n=!0):(n=!1,0==s?this[this.t++]=o:s+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=r)>=this.DB&&(s-=this.DB))}8==r&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),n&&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,n=this.DB-i,s=(1<<n)-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]>>n|a,a=(this[r]&s)<<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,n=this.DB-i,s=(1<<i)-1;e[0]=this[r]>>i;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&s)<<n,e[o-r]=this[o]>>i;i>0&&(e[this.t-r-1]|=(this.s&s)<<n),e.t=this.t-r,e.clamp()}},E.prototype.subTo=function(t,e){for(var r=0,i=0,n=Math.min(t.t,this.t);r<n;)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(),n=r.t;for(e.t=n+i.t;--n>=0;)e[n]=0;for(n=0;n<i.t;++n)e[n+r.t]=r.am(0,i[n],e,n,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 n=this.abs();if(n.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=x());var s=x(),o=this.s,a=t.s,c=this.DB-C(i[i.t-1]);c>0?(i.lShiftTo(c,s),n.lShiftTo(c,r)):(i.copyTo(s),n.copyTo(r));var u=s.t,h=s[u-1];if(0!=h){var l=h*(1<<this.F1)+(u>1?s[u-2]>>this.F2:0),p=this.FV/l,d=(1<<this.F1)/l,g=1<<this.F2,f=r.t,m=f-u,y=null==e?x():e;for(s.dlShiftTo(m,y),r.compareTo(y)>=0&&(r[r.t++]=1,r.subTo(y,r)),E.ONE.dlShiftTo(u,y),y.subTo(s,s);s.t<u;)s[s.t++]=0;for(;--m>=0;){var S=r[--f]==h?this.DM:Math.floor(r[f]*p+(r[f-1]+g)*d);if((r[f]+=s.am(0,S,r,m,0,u))<S)for(s.dlShiftTo(m,y),r.subTo(y,r);r[f]<--S;)r.subTo(y,r)}null!=e&&(r.drShiftTo(u,e),o!=a&&E.ZERO.subTo(e,e)),r.t=u,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(),n=e.convert(this),s=C(t)-1;for(n.copyTo(r);--s>=0;)if(e.sqrTo(r,i),(t&1<<s)>0)e.mulTo(i,n,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,n=!1,s="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(n=!0,s=T(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&&(n=!0),n&&(s+=T(r));return n?s:"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)+C(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 P(e):new F(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,M,V,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],G=(1<<26)/K[K.length-1];function q(){this.i=0,this.j=0,this.S=new Array}function $(){!function(t){M[V++]^=255&t,M[V++]^=t>>8&255,M[V++]^=t>>16&255,M[V++]^=t>>24&255,V>=256&&(V-=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),n=x(),s=x(),o="";for(this.divRemTo(i,n,s);n.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,n.divRemTo(i,n,s);return s.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),n=!1,s=0,o=0,a=0;a<t.length;++a){var c=I(t,a);c<0?"-"==t.charAt(a)&&0==this.signum()&&(n=!0):(o=e*o+c,++s>=r&&(this.dMultiply(i),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),n&&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,n=7&t;i.length=1+(t>>3),e.nextBytes(i),n>0?i[0]&=(1<<n)-1:i[0]=0,this.fromString(i,256)}},E.prototype.bitwiseTo=function(t,e,r){var i,n,s=Math.min(t.t,this.t);for(i=0;i<s;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(n=t.s&this.DM,i=s;i<this.t;++i)r[i]=e(this[i],n);r.t=this.t}else{for(n=this.s&this.DM,i=s;i<t.t;++i)r[i]=e(n,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,n=Math.min(t.t,this.t);r<n;)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,n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(i=r.t-this.t;n<i;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t[n],r,n,0,e-n);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 n=x(),s=0;s<t;++s){n.fromInt(K[Math.floor(Math.random()*K.length)]);var o=n.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,n=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[n++]=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==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(e[n++]=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,N,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,D,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,D)},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,n=t.bitLength(),s=R(1);if(n<=0)return s;r=n<18?1:n<48?3:n<144?4:n<768?5:6,i=n<8?new P(e):e.isEven()?new U(e):new F(e);var o=new Array,a=3,c=r-1,u=(1<<r)-1;if(o[1]=i.convert(this),r>1){var h=x();for(i.sqrTo(o[1],h);a<=u;)o[a]=x(),i.mulTo(h,o[a-2],o[a]),a+=2}var l,p,d=t.t-1,g=!0,f=x();for(n=C(t[d])-1;d>=0;){for(n>=c?l=t[d]>>n-c&u:(l=(t[d]&(1<<n+1)-1)<<c-n,d>0&&(l|=t[d-1]>>this.DB+n-c)),a=r;!(1&l);)l>>=1,--a;if((n-=a)<0&&(n+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)i.sqrTo(s,f),i.sqrTo(f,s),a-=2;a>0?i.sqrTo(s,f):(p=s,s=f,f=p),i.mulTo(f,o[l],s)}for(;d>=0&&!(t[d]&1<<n);)i.sqrTo(s,f),p=s,s=f,f=p,--n<0&&(n=this.DB-1,--d)}return i.revert(s)},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(),n=R(1),s=R(0),o=R(0),a=R(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(n.isEven()&&s.isEven()||(n.addTo(this,n),s.subTo(t,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);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&&n.subTo(o,n),s.subTo(a,s)):(i.subTo(r,i),e&&o.subTo(n,o),a.subTo(s,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 n=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(n<s&&(s=n),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,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],n=e+1;n<K.length&&i<G;)i*=K[n++];for(i=r.modInt(i);e<n;)if(i%K[e++]==0)return!1}return r.millerRabin(t)},E.prototype.square=function(){var t=x();return this.squareTo(t),t},q.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},q.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==M){var W;if(M=new Array,V=0,void 0!==g&&(void 0!==g.crypto||void 0!==g.msCrypto)){var z=g.crypto||g.msCrypto;if(z.getRandomValues){var Y=new Uint8Array(32);for(z.getRandomValues(Y),W=0;W<32;++W)M[V++]=Y[W]}else if("Netscape"==d.appName&&d.appVersion<"5"){var X=g.crypto.random(32);for(W=0;W<X.length;++W)M[V++]=255&X.charCodeAt(W)}}for(;V<256;)W=Math.floor(65536*Math.random()),M[V++]=W>>>8,M[V++]=255&W;V=0,$()}function J(){if(null==j){for($(),(j=new q).init(M),V=0;V<M.length;++V)M[V]=0;V=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]=J()},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,n,s,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(n,16),this.dmp1=Z(s,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 n=new E(e,16),s=t/2-100,o=E.ONE.shiftLeft(s);;){for(;this.p=new E(t-i,1,r),0!=this.p.subtract(E.ONE).gcd(n).compareTo(E.ONE)||!this.p.isProbablePrime(10););for(;this.q=new E(i,1,r),0!=this.q.subtract(E.ONE).gcd(n).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()<s||c.compareTo(o)<=0)){var u=this.p.subtract(E.ONE),h=this.q.subtract(E.ONE),l=u.multiply(h);if(0==l.gcd(n).compareTo(E.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=n.modInverse(l),this.dmp1=this.d.mod(u),this.dmq1=this.d.mod(h),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"),n=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),r.square()),a=o.multiply(r),c=n.multiply(o),u=e.square().multiply(this.z),h=u.subtract(c.shiftLeft(1)).multiply(t.z).subtract(a).multiply(r).mod(this.curve.q),l=c.multiply(i).multiply(e).subtract(s.multiply(a)).subtract(u.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(h),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),n=i.multiply(r).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);E.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(i).mod(this.curve.q),c=o.multiply(t).multiply(e).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(o.square().multiply(o)).mod(this.curve.q),u=i.square().multiply(i).shiftLeft(3).mod(this.curve.q);return new rt(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(c),u)},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")),n=this.negate(),s=this,o=this.curve.q.subtract(t),a=o.multiply(new E("3")),c=new rt(this.curve,this.x,this.y),u=c.negate();for(e=i.bitLength()-2;e>0;--e){s=s.twice();var h=i.testBit(e);h!=r.testBit(e)&&(s=s.add(h?this:n))}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:u))}return s},rt.prototype.multiplyTwo=function(t,e,r){var i;i=t.bitLength()>r.bitLength()?t.bitLength()-1:r.bitLength()-1;for(var n=this.curve.getInfinity(),s=this.add(e);i>=0;)n=n.twice(),t.testBit(i)?n=r.testBit(i)?n.add(s):n.add(this):r.testBit(i)&&(n=n.add(e)),--i;return n},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(),n=this.getB(),s=r.square().add(i).multiply(r).add(n).sqrt();return"03"==e&&(s=s.negate()),new rt(this,r,s);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(),n=e(r,32);return t?i.isEven()?n.unshift(2):n.unshift(3):(n.unshift(4),n=n.concat(e(i,32))),n},rt.decodeFrom=function(t,e){e[0];var r=e.length-1,i=e.slice(1,1+r/2),n=e.slice(1+r/2,1+r);i.unshift(0),n.unshift(0);var s=new E(i),o=new E(n);return new rt(t,t.fromBigInteger(s),t.fromBigInteger(o))},rt.decodeFromHex=function(t,e){e.substr(0,2);var r=e.length-2,i=e.substr(2,r/2),n=e.substr(2+r/2,r/2),s=new E(i,16),o=new E(n,16);return new rt(t,t.fromBigInteger(s),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),n=r.multiply(this.x.subtract(i)).subtract(this.y);return new rt(this.curve,i,n)},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)),n=r.multiply(this.x.subtract(i)).subtract(this.y);return new rt(this.curve,i,n)},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")),n=this.negate(),s=this;for(e=i.bitLength()-2;e>0;--e){s=s.twice();var o=i.testBit(e);o!=r.testBit(e)&&(s=s.add2D(o?this:n))}return s},rt.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),i=this.curve.getB().toBigInteger(),n=this.curve.getQ(),s=e.multiply(e).mod(n),o=t.multiply(t).multiply(t).add(r.multiply(t)).add(i).mod(n);return s.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 nt=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 n=new String(""),s=Object.hasOwnProperty;return function(r,o){var a,c,u=r.match(t),h=u[0],l=!1;"{"===h?a={}:"["===h?a=[]:(a=[],l=!0);for(var p=[a],d=1-l,g=u.length;d<g;++d){var f;switch((h=u[d]).charCodeAt(0)){default:(f=p[0])[c||f.length]=+h,c=void 0;break;case 34:if(-1!==(h=h.substring(1,h.length-1)).indexOf("\\")&&(h=h.replace(e,i)),f=p[0],!c){if(!(f instanceof Array)){c=h||n;break}c=f.length}f[c]=h,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 n in r)if(s.call(r,n)&&r!==t){var a=m(r,n);void 0!==a?r[n]=a:(i||(i=[]),i.push(n))}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!==st&&st||(st={}),void 0!==st.asn1&&st.asn1||(st.asn1={}),st.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=st.asn1,r=e.ASN1Object,i=e.DERBoolean,n=e.DERInteger,s=e.DERBitString,o=e.DEROctetString,a=e.DERNull,c=e.DERObjectIdentifier,u=e.DEREnumerated,h=e.DERUTF8String,l=e.DERNumericString,p=e.DERPrintableString,d=e.DERTeletexString,g=e.DERIA5String,f=e.DERUTCTime,m=e.DERGeneralizedTime,y=e.DERVisibleString,S=e.DERBMPString,v=e.DERSequence,E=e.DERSet,x=e.DERTaggedObject,A=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var w=Object.keys(t);if(1!=w.length)throw new Error("key of param shall be only one.");var b=w[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 n(t[b]);if("bitstr"==b)return new s(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 u(t[b]);if("utf8str"==b)return new h(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 S(t[b]);if("asn1"==b)return new r(t[b]);if("seq"==b){for(var T=t[b],I=[],R=0;R<T.length;R++){var C=A(T[R]);I.push(C)}return new v({array:I})}if("set"==b){for(T=t[b],I=[],R=0;R<T.length;R++)C=A(T[R]),I.push(C);return new E({array:I})}if("tag"==b){var P=t[b];if("[object Array]"===Object.prototype.toString.call(P)&&3==P.length){var F=A(P[2]);return new x({tag:P[0],explicit:P[1],obj:F})}return new x(P)}},this.jsonToASN1HEX=function(t){return this.newObject(t).tohex()}},st.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),i=(e=Math.floor(r/40)+"."+r%40,""),n=2;n<t.length;n+=2){var s=("00000000"+parseInt(t.substr(n,2),16).toString(2)).slice(-8);i+=s.substr(1,7),"0"==s.substr(0,1)&&(e=e+"."+new E(i,2).toString(10),i="")}return e},st.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),n=7-i.length%7;7==n&&(n=0);for(var s="",o=0;o<n;o++)s+="0";for(i=s+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="",n=t.split("."),s=40*parseInt(n[0])+parseInt(n[1]);i+=e(s),n.splice(0,2);for(var o=0;o<n.length;o++)i+=r(n[o]);return i},st.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)},st.asn1.DERAbstractString=function(t){st.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))},Mt(st.asn1.DERAbstractString,st.asn1.ASN1Object),st.asn1.DERAbstractTime=function(t){st.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,n=this.localDateToUTC(t),s=String(n.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+i(String(n.getMonth()+1),2)+i(String(n.getDate()),2)+i(String(n.getHours()),2)+i(String(n.getMinutes()),2)+i(String(n.getSeconds()),2);if(!0===r){var a=n.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,n,s){var o=new Date(Date.UTC(t,e-1,r,i,n,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},Mt(st.asn1.DERAbstractTime,st.asn1.ASN1Object),st.asn1.DERAbstractStructured=function(t){st.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)},Mt(st.asn1.DERAbstractStructured,st.asn1.ASN1Object),st.asn1.DERBoolean=function(t){st.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},Mt(st.asn1.DERBoolean,st.asn1.ASN1Object),st.asn1.DERInteger=function(t){st.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)},Mt(st.asn1.DERInteger,st.asn1.ASN1Object),st.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=st.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.tohex()}st.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 n=t.substr(i,8),s=parseInt(n,2).toString(16);1==s.length&&(s="0"+s),r+=s}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))},Mt(st.asn1.DERBitString,st.asn1.ASN1Object),st.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=st.asn1.ASN1Util.newObject(t.obj);t.hex=e.tohex()}st.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Mt(st.asn1.DEROctetString,st.asn1.DERAbstractString),st.asn1.DERNull=function(){st.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Mt(st.asn1.DERNull,st.asn1.ASN1Object),st.asn1.DERObjectIdentifier=function(t){st.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),n=7-i.length%7;7==n&&(n=0);for(var s="",o=0;o<n;o++)s+="0";for(i=s+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="",n=t.split("."),s=40*parseInt(n[0],10)+parseInt(n[1],10);i+=e(s),n.splice(0,2);for(var o=0;o<n.length;o++)i+=r(n[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=st.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)},Mt(st.asn1.DERObjectIdentifier,st.asn1.ASN1Object),st.asn1.DEREnumerated=function(t){st.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))},Mt(st.asn1.DEREnumerated,st.asn1.ASN1Object),st.asn1.DERUTF8String=function(t){st.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Mt(st.asn1.DERUTF8String,st.asn1.DERAbstractString),st.asn1.DERNumericString=function(t){st.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Mt(st.asn1.DERNumericString,st.asn1.DERAbstractString),st.asn1.DERPrintableString=function(t){st.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Mt(st.asn1.DERPrintableString,st.asn1.DERAbstractString),st.asn1.DERTeletexString=function(t){st.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Mt(st.asn1.DERTeletexString,st.asn1.DERAbstractString),st.asn1.DERIA5String=function(t){st.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Mt(st.asn1.DERIA5String,st.asn1.DERAbstractString),st.asn1.DERVisibleString=function(t){st.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},Mt(st.asn1.DERVisibleString,st.asn1.DERAbstractString),st.asn1.DERBMPString=function(t){st.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},Mt(st.asn1.DERBMPString,st.asn1.DERAbstractString),st.asn1.DERUTCTime=function(t){st.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=ht(t)}else if(null!=t.str)this.hV=ht(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ht(this.formatDate(e,"utc",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ht(this.formatDate(t.date,"utc",r))}else t instanceof Date&&(this.hV=ht(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)},Mt(st.asn1.DERUTCTime,st.asn1.DERAbstractTime),st.asn1.DERGeneralizedTime=function(t){st.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=ht(t)}else if(null!=t.str)this.hV=ht(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ht(this.formatDate(e,"gen",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ht(this.formatDate(t.date,"gen",r))}else t instanceof Date&&(this.hV=ht(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)},Mt(st.asn1.DERGeneralizedTime,st.asn1.DERAbstractTime),st.asn1.DERSequence=function(t){st.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}},Mt(st.asn1.DERSequence,st.asn1.DERAbstractStructured),st.asn1.DERSet=function(t){st.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)},Mt(st.asn1.DERSet,st.asn1.DERAbstractStructured),st.asn1.DERTaggedObject=function(t){st.asn1.DERTaggedObject.superclass.constructor.call(this);var e=st.asn1,r=ct,i=r.getV,n=(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=n(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)},Mt(st.asn1.DERTaggedObject,st.asn1.ASN1Object);var st,ot,at,ct=new function(){};function ut(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 ht(t){return ut(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(S(t))}function gt(t){return v(pt(t))}function ft(t){return At(Nt(t)).toLowerCase()}function mt(t){try{return decodeURIComponent(wt(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 n=parseInt(e[i],16);161<=n&&n<=191?(r.push("c2"),r.push(e[i])):192<=n&&n<=255?(r.push("c3"),r.push((n-64).toString(16))):r.push(e[i])}return r.join("")}(t))}function St(t){for(var e="",r=0;r<t.length-1;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e}function vt(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 S(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 v(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 At(t){return t.replace(/%/g,"")}function wt(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),n=(t=t.replace("::",i)).split(":");if(8!=n.length)throw e;for(var s=0;s<8;s++)n[s]=("0000"+n[s]).slice(-4);return n.join("")}function Tt(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 Tt(t);if(64!=t.length)return t;try{return Tt(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 Ct(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 Ct((r=t.split("/"))[0])+Pt(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])+Pt(parseInt(r[1]),128);throw e}var i=t.split(".");if(4!==i.length)throw e;var n="";try{for(var s=0;s<4;s++)n+=("0"+parseInt(i[s]).toString(16)).slice(-2);return n}catch(t){throw e}}function Pt(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 Ft(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 n=128|63&r;return mt((224|(240&e)>>4).toString(16)+i.toString(16)+n.toString(16))});return e.join("")}function Nt(t){for(var e=encodeURIComponent(t),r="",i=0;i<e.length;i++)"%"==e[i]?(r+=e.substr(i,3),i+=2):r=r+"%"+ht(e[i]);return r}function Ot(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))}function Dt(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 n=t.substr(2),s=[],o=0;o<n.length/2;o++)s.push(parseInt(n.substr(2*o,2),16));var a=[],c="";for(o=0;o<s.length;o++)128&s[o]?c+=kt((127&s[o]).toString(2),7):(c+=kt((127&s[o]).toString(2),7),a.push(new String(parseInt(c,2))),c="");var u=e.join(".");return a.length>0&&(u=u+"."+a.join(".")),u}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="",n=0;n<r;n++)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,n,s=ct,o=[];r=s.getVidx(t,e),i=2*s.getVblen(t,e),"03"==t.substr(e,2)&&(r+=2,i-=2),n=0;for(var a=r;n<=i;){var c=s.getTLVblen(t,a);if((n+=c)<=i&&o.push(a),a+=c,n>=i)break}return o},ct.getNthChildIdx=function(t,e,r){return ct.getChildIdx(t,e)[r]},ct.getIdxbyList=function(t,e,r,i){var n,s,o=ct;return 0==r.length?void 0!==i&&t.substr(e,2)!==i?-1:e:(n=r.shift())>=(s=o.getChildIdx(t,e)).length?-1:o.getIdxbyList(t,s[n],r,i)},ct.getIdxbyListEx=function(t,e,r,i){var n,s,o=ct;if(0==r.length)return void 0!==i&&t.substr(e,2)!==i?-1:e;n=r.shift(),s=o.getChildIdx(t,e);for(var a=0,c=0;c<s.length;c++){var u=t.substr(s[c],2);if("number"==typeof n&&!o.isContextTag(u)&&a==n||"string"==typeof n&&o.isContextTag(u,n))return o.getIdxbyListEx(t,s[c],r,i);o.isContextTag(u)||a++}return-1},ct.getTLVbyList=function(t,e,r,i){var n=ct,s=n.getIdxbyList(t,e,r,i);return-1==s||s>=t.length?null:n.getTLV(t,s)},ct.getTLVbyListEx=function(t,e,r,i){var n=ct,s=n.getIdxbyListEx(t,e,r,i);return-1==s?null:n.getTLV(t,s)},ct.getVbyList=function(t,e,r,i,n){var s,o,a=ct;return-1==(s=a.getIdxbyList(t,e,r,i))||s>=t.length?null:(o=a.getV(t,s),!0===n&&(o=o.substr(2)),o)},ct.getVbyListEx=function(t,e,r,i,n){var s,o,a=ct;return-1==(s=a.getIdxbyListEx(t,e,r,i))?null:(o=a.getV(t,s),"03"==t.substr(s,2)&&!1!==n&&(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 n=ct.getV(t,e);return"02"==i?parseInt(n,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),n=parseInt(i,16).toString(2);"0"==n&&(n="00000000"),n=n.slice(0,0-r);var s=parseInt(n,2);return NaN==s?-1:s}catch(t){return-1}}(n)}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 n=st.asn1.x509.OID.oid2name(i);return""==n?i:n}catch(t){return r}},ct.getString=function(t,e,r){null==r&&(r=null);try{return St(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),n=parseInt(i,16);r[0]=new String(Math.floor(n/40)),r[1]=new String(n%40);for(var s=t.substr(2),o=[],a=0;a<s.length/2;a++)o.push(parseInt(s.substr(2*a,2),16));var c=[],u="";for(a=0;a<o.length;a++)128&o[a]?u+=e((127&o[a]).toString(2),7):(u+=e((127&o[a]).toString(2),7),c.push(new String(parseInt(u,2))),u="");var h=r.join(".");return c.length>0&&(h=h+"."+c.join(".")),h},ct.dump=function(t,e,r,i){var n=ct,s=n.getV,o=n.dump,a=n.getChildIdx,c=t;t instanceof st.asn1.ASN1Object&&(c=t.tohex());var u=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 h,l=e.ommit_long_octet;if("01"==(h=c.substr(r,2)))return"00"==(p=s(c,r))?i+"BOOLEAN FALSE\n":i+"BOOLEAN TRUE\n";if("02"==h)return i+"INTEGER "+u(p=s(c,r),l)+"\n";if("03"==h){var p=s(c,r);return n.isASN1HEX(p.substr(2))?(x=i+"BITSTRING, encapsulates\n")+o(p.substr(2),e,0,i+" "):i+"BITSTRING "+u(p,l)+"\n"}if("04"==h)return p=s(c,r),n.isASN1HEX(p)?(x=i+"OCTETSTRING, encapsulates\n")+o(p,e,0,i+" "):i+"OCTETSTRING "+u(p,l)+"\n";if("05"==h)return i+"NULL\n";if("06"==h){var d=s(c,r),g=st.asn1.ASN1Util.oidHexToInt(d),f=st.asn1.x509.OID.oid2name(g),m=g.replace(/\./g," ");return""!=f?i+"ObjectIdentifier "+f+" ("+m+")\n":i+"ObjectIdentifier ("+m+")\n"}if("0a"==h)return i+"ENUMERATED "+parseInt(s(c,r))+"\n";if("0c"==h)return i+"UTF8String '"+mt(s(c,r))+"'\n";if("13"==h)return i+"PrintableString '"+mt(s(c,r))+"'\n";if("14"==h)return i+"TeletexString '"+mt(s(c,r))+"'\n";if("16"==h)return i+"IA5String '"+mt(s(c,r))+"'\n";if("17"==h)return i+"UTCTime "+mt(s(c,r))+"\n";if("18"==h)return i+"GeneralizedTime "+mt(s(c,r))+"\n";if("1a"==h)return i+"VisualString '"+mt(s(c,r))+"'\n";if("1e"==h)return i+"BMPString '"+Ft(s(c,r))+"'\n";if("30"==h){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=n.oidname(s(c,E[0]));var S=JSON.parse(JSON.stringify(e));S.x509ExtName=f,y=S}for(var v=0;v<E.length;v++)x+=o(c,y,E[v],i+" ");return x}if("31"==h){x=i+"SET\n";var E=a(c,r);for(v=0;v<E.length;v++)x+=o(c,e,E[v],i+" ");return x}if(128&(h=parseInt(h,16))){var x,A=31&h;if(32&h){for(x=i+"["+A+"]\n",E=a(c,r),v=0;v<E.length;v++)x+=o(c,e,E[v],i+" ");return x}return p=s(c,r),ct.isASN1HEX(p)?(x=i+"["+A+"]\n")+o(p,e,0,i+" "):(("68747470"==p.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==A)&&(p=mt(p)),i+"["+A+"] "+p+"\n")}return i+"UNKNOWN("+h+") "+s(c,r)+"\n"},ct.parse=function(t){var e=ct,r=e.parse,i=e.isASN1HEX,n=e.getV,s=e.getTLV,o=e.getChildIdx,a=st.asn1,c=a.ASN1Util.oidHexToInt,u=a.x509.OID.oid2name,h=mt,l=Ft,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=n(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 S=null;return m.length<=10&&(S=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="",n=0;n<r.length;n+=2){var s=r.substr(n,2),o=parseInt(s,16).toString(2);i+=o=("0000000"+o).slice(-8)}return i.substr(0,i.length-e)}catch(t){return null}}(m)),null==S?{bitstr:{hex:m}}:{bitstr:{bin:S}}}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 v=c(m),E=u(v);return""==E?{oid:v}:{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),n=0;n<i.length;n++){var a=i[n],c=s(t,a),u=r(c);e.push(u)}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=h(m),f[d[g]]={str:x},f;if(g.match(/^8[0-9]$/))return null==(x=h(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 A=new st.asn1.ASN1Object;return A.hV=m,{asn1:{tlv:g+A.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),n=e.getL(t,0);return t.length-i.length-n.length==2*r},ct.checkStrictDER=function(t,e,r,i,n){var s=ct;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!st.lang.String.isHex(t))throw new Error("not hex string");r=t.length,n=(i=t.length/2)<128?1:Math.ceil(i.toString(16))+1}if(s.getL(t,e).length>2*n)throw new Error("L of TLV too long: idx="+e);var o=s.getVblen(t,e);if(o>i)throw new Error("value of L too long than hex: idx="+e);var a=s.getTLV(t,e),c=a.length-2-s.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 u=t.substr(e,2);if("02"===u){var h=s.getVidx(t,e);if("00"==t.substr(h,2)&&t.charCodeAt(h+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(u,16)){for(var l=s.getVblen(t,e),p=0,d=s.getChildIdx(t,e),g=0;g<d.length;g++)p+=s.getTLV(t,d[g]).length,s.checkStrictDER(t,d[g],r,i,n);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=st.asn1;st.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var r=e.x509.OID.oid2name(t);return""===r&&(r=t),r},void 0!==st&&st||(st={}),void 0!==st.asn1&&st.asn1||(st.asn1={}),void 0!==st.asn1.x509&&st.asn1.x509||(st.asn1.x509={}),st.asn1.x509.Certificate=function(t){st.asn1.x509.Certificate.superclass.constructor.call(this);var e=st.asn1,r=e.DERBitString,i=e.DERSequence,n=e.x509,s=n.TBSCertificate,o=n.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 st.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 s(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)},Mt(st.asn1.x509.Certificate,st.asn1.ASN1Object),st.asn1.x509.TBSCertificate=function(t){st.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=st.asn1,r=e.x509,i=e.DERTaggedObject,n=e.DERInteger,s=e.DERSequence,o=r.AlgorithmIdentifier,a=r.Time,c=r.X500Name,u=r.Extensions,h=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 n({int:r})});t.push(l)}return t.push(new n(e.serial)),t.push(new o({name:e.sigalg})),t.push(new c(e.issuer)),t.push(new s({array:[new a(e.notbefore),new a(e.notafter)]})),t.push(new c(e.subject)),t.push(new h(Vt.getKey(e.sbjpubkey))),void 0!==e.ext&&e.ext.length>0&&t.push(new i({tag:"a3",obj:new u(e.ext)})),new st.asn1.DERSequence({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.TBSCertificate,st.asn1.ASN1Object),st.asn1.x509.Extensions=function(t){st.asn1.x509.Extensions.superclass.constructor.call(this);var e=st.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 n=this.aParam[e],s=n.extname,o=null;if(null!=n.extn)o=new i.PrivateExtension(n);else if("subjectKeyIdentifier"==s)o=new i.SubjectKeyIdentifier(n);else if("keyUsage"==s)o=new i.KeyUsage(n);else if("subjectAltName"==s)o=new i.SubjectAltName(n);else if("issuerAltName"==s)o=new i.IssuerAltName(n);else if("basicConstraints"==s)o=new i.BasicConstraints(n);else if("nameConstraints"==s)o=new i.NameConstraints(n);else if("cRLDistributionPoints"==s)o=new i.CRLDistributionPoints(n);else if("certificatePolicies"==s)o=new i.CertificatePolicies(n);else if("policyMappings"==s)o=new i.PolicyMappings(n);else if("policyConstraints"==s)o=new i.PolicyConstraints(n);else if("inhibitAnyPolicy"==s)o=new i.InhibitAnyPolicy(n);else if("authorityKeyIdentifier"==s)o=new i.AuthorityKeyIdentifier(n);else if("extKeyUsage"==s)o=new i.ExtKeyUsage(n);else if("authorityInfoAccess"==s)o=new i.AuthorityInfoAccess(n);else if("cRLNumber"==s)o=new i.CRLNumber(n);else if("cRLReason"==s)o=new i.CRLReason(n);else if("ocspNonce"==s)o=new i.OCSPNonce(n);else if("ocspNoCheck"==s)o=new i.OCSPNoCheck(n);else if("adobeTimeStamp"==s)o=new i.AdobeTimeStamp(n);else{if("subjectDirectoryAttributes"!=s)throw new Error("extension not supported:"+JSON.stringify(n));o=new i.SubjectDirectoryAttributes(n)}null!=o&&t.push(o)}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.x509.Extensions,st.asn1.ASN1Object),st.asn1.x509.Extension=function(t){st.asn1.x509.Extension.superclass.constructor.call(this);var e=st.asn1,r=e.DERObjectIdentifier,i=e.DEROctetString,n=(e.DERBitString,e.DERBoolean),s=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 n),o.push(e),new s({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},Mt(st.asn1.x509.Extension,st.asn1.ASN1Object),st.asn1.x509.KeyUsage=function(t){st.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 st.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)},Mt(st.asn1.x509.KeyUsage,st.asn1.x509.Extension),st.asn1.x509.BasicConstraints=function(t){st.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=st.asn1,r=e.DERBoolean,i=e.DERInteger,n=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 n({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))},Mt(st.asn1.x509.BasicConstraints,st.asn1.x509.Extension),st.asn1.x509.CRLDistributionPoints=function(t){st.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=st.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(t){for(var i=[],n=0;n<t.length;n++)if(t[n]instanceof st.asn1.ASN1Object)i.push(t[n]);else{var s=new r.DistributionPoint(t[n]);i.push(s)}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))},Mt(st.asn1.x509.CRLDistributionPoints,st.asn1.x509.Extension),st.asn1.x509.DistributionPoint=function(t){st.asn1.x509.DistributionPoint.superclass.constructor.call(this);var e=st.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}]})))},Mt(st.asn1.x509.DistributionPoint,st.asn1.ASN1Object),st.asn1.x509.DistributionPointName=function(t){st.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=st.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)}},Mt(st.asn1.x509.DistributionPointName,st.asn1.ASN1Object),st.asn1.x509.CertificatePolicies=function(t){st.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=st.asn1,r=e.x509,i=e.DERSequence,n=r.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new n(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)},Mt(st.asn1.x509.CertificatePolicies,st.asn1.x509.Extension),st.asn1.x509.PolicyInformation=function(t){st.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=st.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,n=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=[],s=0;s<this.params.array.length;s++)e.push(new n(this.params.array[s]));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)},Mt(st.asn1.x509.PolicyInformation,st.asn1.ASN1Object),st.asn1.x509.PolicyQualifierInfo=function(t){st.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=st.asn1,r=e.DERSequence,i=e.DERIA5String,n=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.tohex=function(){return void 0!==this.params.cps?new r({array:[new n({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 n({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).tohex():void 0},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Mt(st.asn1.x509.PolicyQualifierInfo,st.asn1.ASN1Object),st.asn1.x509.UserNotice=function(t){st.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=st.asn1.DERSequence,r=(st.asn1.DERInteger,st.asn1.x509.DisplayText),i=st.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)},Mt(st.asn1.x509.UserNotice,st.asn1.ASN1Object),st.asn1.x509.NoticeReference=function(t){st.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=st.asn1.DERSequence,r=st.asn1.DERInteger,i=st.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 n=[],s=this.params.noticenum,o=0;o<s.length;o++)n.push(new r(s[o]));t.push(new e({array:n}))}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)},Mt(st.asn1.x509.NoticeReference,st.asn1.ASN1Object),st.asn1.x509.DisplayText=function(t){st.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"))},Mt(st.asn1.x509.DisplayText,st.asn1.DERAbstractString),st.asn1.x509.PolicyMappings=function(t){st.asn1.x509.PolicyMappings.superclass.constructor.call(this,t);var e=st.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 n=t.array[i];e.push({seq:[{oid:n[0]},{oid:n[1]}]})}return this.asn1ExtnValue=r({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.33",void 0!==t&&(this.params=t)},Mt(st.asn1.x509.PolicyMappings,st.asn1.x509.Extension),st.asn1.x509.PolicyConstraints=function(t){st.asn1.x509.PolicyConstraints.superclass.constructor.call(this,t);var e=st.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)},Mt(st.asn1.x509.PolicyConstraints,st.asn1.x509.Extension),st.asn1.x509.InhibitAnyPolicy=function(t){st.asn1.x509.InhibitAnyPolicy.superclass.constructor.call(this,t);var e=st.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)},Mt(st.asn1.x509.InhibitAnyPolicy,st.asn1.x509.Extension),st.asn1.x509.NameConstraints=function(t){st.asn1.x509.NameConstraints.superclass.constructor.call(this,t);var e=st.asn1,r=e.x509,i=e.ASN1Util.newObject,n=r.GeneralSubtree;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];if(null!=t.permit&&null!=t.permit.length){for(var r=[],s=0;s<t.permit.length;s++)r.push(new n(t.permit[s]));e.push({tag:{tagi:"a0",obj:{seq:r}}})}if(null!=t.exclude&&null!=t.exclude.length){var o=[];for(s=0;s<t.exclude.length;s++)o.push(new n(t.exclude[s]));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)},Mt(st.asn1.x509.NameConstraints,st.asn1.x509.Extension),st.asn1.x509.GeneralSubtree=function(t){st.asn1.x509.GeneralSubtree.superclass.constructor.call(this);var e=st.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)},Mt(st.asn1.x509.GeneralSubtree,st.asn1.ASN1Object),st.asn1.x509.ExtKeyUsage=function(t){st.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=st.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)},Mt(st.asn1.x509.ExtKeyUsage,st.asn1.x509.Extension),st.asn1.x509.AuthorityKeyIdentifier=function(t){st.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=st,r=e.asn1,i=r.DERTaggedObject,n=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 n([{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 st.asn1.DEROctetString(t);else if("object"==typeof t&&st.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN ")){var e=t;"string"==typeof t&&(e=Vt.getKey(t));var r=Vt.getKeyID(e);this.asn1KID=new st.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 st.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new st.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 st.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 st.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)))},Mt(st.asn1.x509.AuthorityKeyIdentifier,st.asn1.x509.Extension),st.asn1.x509.SubjectKeyIdentifier=function(t){st.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var e=st.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&&st.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN")){var r=t;"string"==typeof t&&(r=Vt.getKey(t));var i=Vt.getKeyID(r);this.asn1KID=new st.asn1.DEROctetString({hex:i})}},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},Mt(st.asn1.x509.SubjectKeyIdentifier,st.asn1.x509.Extension),st.asn1.x509.AuthorityInfoAccess=function(t){st.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,r=st.asn1,i=r.DERSequence,n=r.DERObjectIdentifier,s=r.x509.GeneralName,o=0;o<t.length;o++){var a,c=t[o];if(void 0!==c.ocsp)a=new i({array:[new n({oid:"1.3.6.1.5.5.7.48.1"}),new s({uri:c.ocsp})]});else{if(void 0===c.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(c));a=new i({array:[new n({oid:"1.3.6.1.5.5.7.48.2"}),new s({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)},Mt(st.asn1.x509.AuthorityInfoAccess,st.asn1.x509.Extension),st.asn1.x509.SubjectAltName=function(t){st.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new st.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)},Mt(st.asn1.x509.SubjectAltName,st.asn1.x509.Extension),st.asn1.x509.IssuerAltName=function(t){st.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new st.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)},Mt(st.asn1.x509.IssuerAltName,st.asn1.x509.Extension),st.asn1.x509.SubjectDirectoryAttributes=function(t){st.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=st.asn1,r=e.DERSequence,i=e.ASN1Util.newObject,n=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var s=this.params.array[e];if(null==s.attr||null==s.array){var o={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==s.attr)o.seq[0].oid=n(s.attr),o.seq[1].set[0]={gentime:s.str};else if("placeOfBirth"==s.attr)o.seq[0].oid=n(s.attr),o.seq[1].set[0]={utf8str:s.str};else if("gender"==s.attr)o.seq[0].oid=n(s.attr),o.seq[1].set[0]={prnstr:s.str};else if("countryOfCitizenship"==s.attr)o.seq[0].oid=n(s.attr),o.seq[1].set[0]={prnstr:s.str};else{if("countryOfResidence"!=s.attr)throw new Error("unsupported attribute: "+s.attr);o.seq[0].oid=n(s.attr),o.seq[1].set[0]={prnstr:s.str}}t.push(new i(o))}else{var a={seq:[{oid:s.attr},{set:s.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)},Mt(st.asn1.x509.SubjectDirectoryAttributes,st.asn1.x509.Extension),st.asn1.x509.PrivateExtension=function(t){st.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=st,r=e.lang.String.isHex,i=e.asn1,n=i.x509.OID.name2oid,s=i.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=n(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 s(t).tohex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},Mt(st.asn1.x509.PrivateExtension,st.asn1.x509.Extension),st.asn1.x509.CRL=function(t){st.asn1.x509.CRL.superclass.constructor.call(this);var e=st.asn1,r=e.DERSequence,i=e.DERBitString,n=e.x509,s=n.AlgorithmIdentifier,o=n.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new o(this.params).tohex(),e=new st.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 s({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)},Mt(st.asn1.x509.CRL,st.asn1.ASN1Object),st.asn1.x509.TBSCertList=function(t){st.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=st.asn1,r=e.DERInteger,i=e.DERSequence,n=e.DERTaggedObject,s=(e.DERObjectIdentifier,e.x509),o=s.AlgorithmIdentifier,a=s.Time,c=s.Extensions,u=s.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,n=0;n<e.length;n++){var s=[new r(e[n].sn),new a(e[n].date)];null!=e[n].ext&&s.push(new c(e[n].ext)),t.push(new i({array:s}))}return new i({array:t})},this.tohex=function(){var t=[],e=this.params;if(null!=e.version){var s=e.version-1,h=new r({int:s});t.push(h)}if(t.push(new o({name:e.sigalg})),t.push(new u(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 n({tag:"a0",explicit:!0,obj:l}))}return new i({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.TBSCertList,st.asn1.ASN1Object),st.asn1.x509.CRLEntry=function(t){st.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=st.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))},Mt(st.asn1.x509.CRLEntry,st.asn1.ASN1Object),st.asn1.x509.CRLNumber=function(t){st.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new st.asn1.DERInteger(this.params.num),this.asn1ExtnValue.tohex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},Mt(st.asn1.x509.CRLNumber,st.asn1.x509.Extension),st.asn1.x509.CRLReason=function(t){st.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new st.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.tohex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},Mt(st.asn1.x509.CRLReason,st.asn1.x509.Extension),st.asn1.x509.OCSPNonce=function(t){st.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new st.asn1.DEROctetString(this.params),this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},Mt(st.asn1.x509.OCSPNonce,st.asn1.x509.Extension),st.asn1.x509.OCSPNoCheck=function(t){st.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new st.asn1.DERNull,this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},Mt(st.asn1.x509.OCSPNoCheck,st.asn1.x509.Extension),st.asn1.x509.AdobeTimeStamp=function(t){st.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=st.asn1,r=e.DERInteger,i=e.DERBoolean,n=e.DERSequence,s=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new r(1)];return e.push(new s({uri:t.uri})),null!=t.reqauth&&e.push(new i(t.reqauth)),this.asn1ExtnValue=new n({array:e}),this.asn1ExtnValue.tohex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.AdobeTimeStamp,st.asn1.x509.Extension),st.asn1.x509.X500Name=function(t){st.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=st.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 n=[],s=0;s<r.length;s++)if(r[s].match(/^[^=]+=.+$/))n.push(r[s]);else{var o=n.length-1;n[o]=n[o]+"/"+r[s]}for(s=0;s<n.length;s++)this.asn1Array.push(new i({str:n[s],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 n=new i({str:r+"="+t[r],rule:this.sRule});this.asn1Array?this.asn1Array.push(n):this.asn1Array=[n]}},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 n=new i(r);this.asn1Array.push(n)}var s=new e.DERSequence({array:this.asn1Array});return this.hTLV=s.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.X500Name,st.asn1.ASN1Object),st.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(",")},st.asn1.x509.X500Name.onelineToLDAP=function(t){return st.asn1.x509.X500Name.compatToLDAP(t)},st.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),r=!1,i=[],n=0;e.length>0;n++){var s=e.shift();if(!0===r){var o=(i.pop()+","+s).replace(/\\,/g,",");i.push(o),r=!1}else i.push(s);"\\"===s.substr(-1,1)&&(r=!0)}return i=i.map(function(t){return t.replace("/","\\/")}),i.reverse(),"/"+i.join("/")},st.asn1.x509.X500Name.ldapToOneline=function(t){return st.asn1.x509.X500Name.ldapToCompat(t)},st.asn1.x509.RDN=function(t){st.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=st.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 st.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=st.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 n=new st.asn1.DERSet({array:this.asn1Array});return this.TLV=n.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.RDN,st.asn1.ASN1Object),st.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),r=!1,i=[],n=0;e.length>0;n++){var s=e.shift();if(!0===r){var o=(i.pop()+"+"+s).replace(/\\\+/g,"+");i.push(o),r=!1}else i.push(s);"\\"===s.substr(-1,1)&&(r=!0)}var a=!1,c=[];for(n=0;i.length>0;n++){if(s=i.shift(),!0===a){var u=c.pop();s.match(/"$/)?(o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2"),c.push(o),a=!1):c.push(u+"+"+s)}else c.push(s);s.match(/^[^=]+="/)&&(a=!0)}return c},st.asn1.x509.AttributeTypeAndValue=function(t){st.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=st,r=e.asn1,i=r.DERSequence,n=r.DERUTF8String,s=r.DERPrintableString,o=r.DERTeletexString,a=r.DERIA5String,c=r.DERVisibleString,u=r.DERBMPString,h=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&&h(e)?"ia5":l(e)?"prn":"utf8":"utf8"===r?"CN"==t&&h(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 n({str:e});if("prn"==t)return new s({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 u({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=st.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)},Mt(st.asn1.x509.AttributeTypeAndValue,st.asn1.ASN1Object),st.asn1.x509.SubjectPublicKeyInfo=function(t){st.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=st,r=e.asn1,i=r.DERInteger,n=r.DERBitString,s=r.DERObjectIdentifier,o=r.DERSequence,a=r.ASN1Util.newObject,c=r.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.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 n({hex:"00"+e})}}catch(t){}try{if(t instanceof st.crypto.ECDSA){var r=new s({name:t.curveName});this.asn1AlgId=new c({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new n({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof st.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 n({hex:"00"+o.tohex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},Mt(st.asn1.x509.SubjectPublicKeyInfo,st.asn1.ASN1Object),st.asn1.x509.Time=function(t){st.asn1.x509.Time.superclass.constructor.call(this);var e=st.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)},st.asn1.x509.Time_bak=function(t){st.asn1.x509.Time_bak.superclass.constructor.call(this);var e=st.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)},Mt(st.asn1.x509.Time,st.asn1.ASN1Object),st.asn1.x509.AlgorithmIdentifier=function(t){st.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=st.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 n=[this.asn1Alg];null!==this.asn1Params&&n.push(this.asn1Params);var s=new e.DERSequence({array:n});return this.hTLV=s.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)}},Mt(st.asn1.x509.AlgorithmIdentifier,st.asn1.ASN1Object),st.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},st.asn1.x509.GeneralName=function(t){st.asn1.x509.GeneralName.superclass.constructor.call(this);var e=st.asn1,r=e.x509,i=r.X500Name,n=r.OtherName,s=e.DERIA5String,o=(e.DERPrintableString,e.DEROctetString),a=e.DERTaggedObject,c=e.ASN1Object,u=Error;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e,r=this.params,h=!1;if(void 0!==r.other)t="a0",e=new n(r.other);else if(void 0!==r.rfc822)t="81",e=new s({str:r.rfc822});else if(void 0!==r.dns)t="82",e=new s({str:r.dns});else if(void 0!==r.dn)t="a4",h=!0,e="string"==typeof r.dn?new i({str:r.dn}):r.dn instanceof st.asn1.x509.X500Name?r.dn:new i(r.dn);else if(void 0!==r.ldapdn)t="a4",h=!0,e=new i({ldapstr:r.ldapdn});else if(void 0!==r.certissuer||void 0!==r.certsubj){var l,p;t="a4",h=!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 s({str:r.uri});else{if(void 0===r.ip)throw new u("improper params");var m;t="87";var y=r.ip;try{if(y.match(/^[0-9a-f]+$/)){var S=y.length;if(8!=S&&16!=S&&32!=S&&64!=S)throw"err";m=y}else m=Ct(y)}catch(t){throw new u("malformed IP address: "+r.ip+":"+t.message)}e=new o({hex:m})}return new a({tag:t,explicit:h,obj:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.GeneralName,st.asn1.ASN1Object),st.asn1.x509.GeneralNames=function(t){st.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=st.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)},Mt(st.asn1.x509.GeneralNames,st.asn1.ASN1Object),st.asn1.x509.OtherName=function(t){st.asn1.x509.OtherName.superclass.constructor.call(this);var e=st.asn1,r=e.DERObjectIdentifier,i=e.DERSequence,n=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}),s=n({tag:{tag:"a0",explicit:!0,obj:t.value}});return new i({array:[e,s]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.OtherName,st.asn1.ASN1Object),st.asn1.x509.OID=new function(){var t=st.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}}},st.asn1.x509.OID.oid2name=function(t){var e=st.asn1.x509.OID.name2oidList;for(var r in e)if(e[r]==t)return r;return""},st.asn1.x509.OID.oid2atype=function(t){var e=st.asn1.x509.OID.atype2oidList;for(var r in e)if(e[r]==t)return r;return t},st.asn1.x509.OID.name2oid=function(t){if(t.match(/^[0-9.]+$/))return t;var e=st.asn1.x509.OID.name2oidList;return void 0===e[t]?"":e[t]},st.asn1.x509.X509Util={},st.asn1.x509.X509Util.newCertPEM=function(t){var e=st.asn1.x509;return e.TBSCertificate,new(0,e.Certificate)(t).getPEM()},void 0!==st&&st||(st={}),void 0!==st.asn1&&st.asn1||(st.asn1={}),void 0!==st.asn1.cms&&st.asn1.cms||(st.asn1.cms={}),st.asn1.cms.Attribute=function(t){var e=Error,r=st.asn1,i=r.DERSequence,n=r.DERSet,s=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 s({oid:this.typeOid}),e=new n({array:this.getValueArray()});return new i({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()}},Mt(st.asn1.cms.Attribute,st.asn1.ASN1Object),st.asn1.cms.ContentType=function(t){var e=st.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)},Mt(st.asn1.cms.ContentType,st.asn1.cms.Attribute),st.asn1.cms.MessageDigest=function(t){var e=st.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)},Mt(st.asn1.cms.MessageDigest,st.asn1.cms.Attribute),st.asn1.cms.SigningTime=function(t){var e=st.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)},Mt(st.asn1.cms.SigningTime,st.asn1.cms.Attribute),st.asn1.cms.SigningCertificate=function(t){var e=Error,r=st,i=r.asn1,n=i.DERSequence,s=i.cms,o=s.ESSCertID;r.crypto,s.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=[],s=0;s<r.length;s++){var a=r[s];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 n({array:i});return[new n({array:[c]})]},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.SigningCertificate,st.asn1.cms.Attribute),st.asn1.cms.ESSCertID=function(t){st.asn1.cms.ESSCertID.superclass.constructor.call(this);var e=Error,r=st,i=r.asn1,n=i.DEROctetString,s=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 n,s,o;if("string"==typeof t)n=t;else{if(null==t.cert)throw new e("hash nor cert unspecified");n=t.cert}if(s=-1!=n.indexOf("-----BEGIN")?xt(n):n,"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?s=xt(t):ct.isASN1HEX(t)&&(s=t)),null!=t.alg)o=t.alg;else{if(null==i)throw new e("hash alg unspecified");o=i}return r.crypto.Util.hashHex(s,o)},this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha1"),r=[];return r.push(new n({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 s({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.ESSCertID,st.asn1.ASN1Object),st.asn1.cms.SigningCertificateV2=function(t){var e=Error,r=st,i=r.asn1,n=i.DERSequence,s=(i.x509,i.cms),o=s.ESSCertIDv2;r.crypto,s.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=[],s=0;s<r.length;s++){var a=r[s];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 n({array:i});return[new n({array:[c]})]},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.SigningCertificateV2,st.asn1.cms.Attribute),st.asn1.cms.ESSCertIDv2=function(t){st.asn1.cms.ESSCertIDv2.superclass.constructor.call(this),Error;var e=st.asn1,r=e.DEROctetString,i=e.DERSequence,n=e.cms.IssuerSerial,s=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 s({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 n(t)),new i({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.ESSCertIDv2,st.asn1.cms.ESSCertID),st.asn1.cms.IssuerSerial=function(t){var e=Error,r=st.asn1,i=r.DERInteger,n=r.DERSequence,s=r.cms,o=r.x509.GeneralNames,a=$t;s.IssuerSerial.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.tohex=function(){var t,r,s=this.params;if("string"==typeof s&&-1!=s.indexOf("-----BEGIN")||null!=s.cert){var c;c=null!=s.cert?s.cert:s;var u=new a;u.readCertPEM(c),t=u.getIssuer(),r={hex:u.getSerialNumberHex()}}else{if(null==s.issuer||!s.serial)throw new e("cert or issuer and serial parameter not specified");t=s.issuer,r=s.serial}var h=new o([{dn:t}]),l=new i(r);return new n({array:[h,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.IssuerSerial,st.asn1.ASN1Object),st.asn1.cms.SignerIdentifier=function(t){var e=st.asn1,r=(e.DERInteger,e.DERSequence,e.cms),i=r.IssuerAndSerialNumber,n=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 n(t).tohex();throw new Error("wrong property for isssn or skid")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.SignerIdentifier,st.asn1.ASN1Object),st.asn1.cms.IssuerAndSerialNumber=function(t){var e=st.asn1,r=e.DERInteger,i=e.DERSequence,n=e.cms,s=e.x509.X500Name,o=$t,a=Error;n.IssuerAndSerialNumber.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e,n=this.params;if("string"==typeof n&&-1!=n.indexOf("-----BEGIN")||null!=n.cert){var c;c=null!=n.cert?n.cert:n;var u=new o;u.readCertPEM(c),t=u.getIssuer(),e={hex:u.getSerialNumberHex()}}else{if(null==n.issuer||!n.serial)throw new a("cert or issuer and serial parameter not specified");t=n.issuer,e=n.serial}var h=new s(t),l=new r(e);return new i({array:[h,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.IssuerAndSerialNumber,st.asn1.ASN1Object),st.asn1.cms.SubjectKeyIdentifier=function(t){var e=st.asn1,r=(e.DERInteger,e.DERSequence,e.ASN1Util.newObject),i=e.cms,n=(i.IssuerAndSerialName,i.SubjectKeyIdentifier,e.x509.X500Name,$t),s=Error;i.SubjectKeyIdentifier.superclass.constructor.call(this),this.tohex=function(){var t,e=this.params;if(null==e.cert&&null==e.skid)throw new s("property cert nor skid undefined");return null!=e.cert?t=new n(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)},Mt(st.asn1.cms.SubjectKeyIdentifier,st.asn1.ASN1Object),st.asn1.cms.AttributeList=function(t){var e=Error,r=st.asn1,i=r.DERSet,n=r.cms;n.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 s=t.array,o=[],a=0;a<s.length;a++){var c=s[a],u=c.attr;if("contentType"==u)o.push(new n.ContentType(c));else if("messageDigest"==u)o.push(new n.MessageDigest(c));else if("signingTime"==u)o.push(new n.SigningTime(c));else if("signingCertificate"==u)o.push(new n.SigningCertificate(c));else if("signingCertificateV2"==u)o.push(new n.SigningCertificateV2(c));else if("signaturePolicyIdentifier"==u)o.push(new st.asn1.cades.SignaturePolicyIdentifier(c));else{if("signatureTimeStamp"!=u&&"timeStampToken"!=u)throw new e("unknown attr: "+u);o.push(new st.asn1.cades.SignatureTimeStamp(c))}}var h=new i({array:o,sortflag:r});return this.hTLV=h.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.AttributeList,st.asn1.ASN1Object),st.asn1.cms.SignerInfo=function(t){var e=Error,r=st,i=r.asn1,n=i.DERInteger,s=i.DEROctetString,o=i.DERSequence,a=i.DERTaggedObject,c=i.cms,u=c.SignerIdentifier,h=c.AttributeList,l=(c.ContentType,c.EncapsulatedContentInfo,c.MessageDigest,c.SignedData,i.x509.AlgorithmIdentifier),p=r.crypto,d=Vt;c.SignerInfo.superclass.constructor.call(this),this.params=null,this.sign=function(){var t=this.params,e=t.sigalg,r=new h(t.sattrs).tohex(),i=d.getKey(t.signkey),n=new p.Signature({alg:e});n.init(i),n.updateHex(r);var s=n.sign();t.sighex=s},this.tohex=function(){var t=this.params,r=[];if(r.push(new n({int:t.version})),r.push(new u(t.id)),r.push(new l({name:t.hashalg})),null!=t.sattrs){var i=new h(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 s({hex:t.sighex})),null!=t.uattrs){i=new h(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)},Mt(st.asn1.cms.SignerInfo,st.asn1.ASN1Object),st.asn1.cms.EncapsulatedContentInfo=function(t){var e=st.asn1,r=e.DERTaggedObject,i=e.DERSequence,n=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];if(e.push(new n(t.type)),null!=t.content&&(null!=t.content.hex||null!=t.content.str)&&1!=t.isDetached){var o=new s(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)},Mt(st.asn1.cms.EncapsulatedContentInfo,st.asn1.ASN1Object),st.asn1.cms.ContentInfo=function(t){var e=st.asn1,r=e.DERTaggedObject,i=e.DERSequence,n=e.DERObjectIdentifier;e.x509.OID.name2obj,st.asn1.cms.ContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];e.push(new n(t.type));var s=new r({tag:"a0",explicit:!0,obj:t.obj});return e.push(s),new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.ContentInfo,st.asn1.ASN1Object),st.asn1.cms.SignedData=function(t){Error;var e=st.asn1,r=(e.ASN1Object,e.DERInteger),i=e.DERSet,n=e.DERSequence,s=(e.DERTaggedObject,e.cms),o=s.EncapsulatedContentInfo,a=s.SignerInfo,c=s.ContentInfo,u=s.CertificateSet,h=s.RevocationInfoChoices,l=e.x509.AlgorithmIdentifier;st.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 n=r[i];this._getAttrParamByName(n,"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=vt(e.content.str));for(var i=t.sinfos,n=0;n<i.length;n++){var s=i[n],o=s.hashalg,a=this._getAttrParamByName(s,"messageDigest"),c=st.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],n=1;"skid"==i.id.type&&(n=3),i.version=n}},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 s=[],c=0;c<t.hashalgs.length;c++){var p=t.hashalgs[c];s.push(new l({name:p}))}e.push(new i({array:s})),e.push(new o(t.econtent)),null!=t.certs&&e.push(new u(t.certs)),null!=t.revinfos&&e.push(new h(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 n({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)},Mt(st.asn1.cms.SignedData,st.asn1.ASN1Object),st.asn1.cms.CertificateSet=function(t){st.asn1.cms.CertificateSet.superclass.constructor.call(this);var e=Error,r=st.asn1,i=r.DERTaggedObject,n=r.DERSet,s=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]),u=new s;u.hTLV=c,o.push(u)}var h={array:o};0==r.sortflag&&(h.sortflag=!1);var l=new n(h);return new i({tag:"a0",explicit:!1,obj:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.CertificateSet,st.asn1.ASN1Object),st.asn1.cms.RevocationInfoChoices=function(t){st.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 st.asn1.cms.RevocationInfoChoice(t[r]));return st.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:{set:e}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.RevocationInfoChoices,st.asn1.ASN1Object),st.asn1.cms.RevocationInfoChoice=function(t){st.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 st.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:new st.asn1.cms.OtherRevocationFormat(t)}}).tohex();throw new Error("property crl or ocsp undefined")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.RevocationInfoChoice,st.asn1.ASN1Object),st.asn1.cms.OtherRevocationFormat=function(t){st.asn1.cms.OtherRevocationFormat.superclass.constructor.call(this);var e=Error,r=st,i=r.asn1.ASN1Util.newObject,n=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(!n(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)},Mt(st.asn1.cms.OtherRevocationFormat,st.asn1.ASN1Object),st.asn1.cms.CMSUtil=new function(){},st.asn1.cms.CMSUtil.newSignedData=function(t){return new st.asn1.cms.SignedData(t)},st.asn1.cms.CMSUtil.verifySignedData=function(t){var e=st,r=e.asn1,i=r.cms,n=(i.SignerInfo,i.SignedData,i.SigningTime,i.SigningCertificate,i.SigningCertificateV2,r.cades.SignaturePolicyIdentifier,e.lang.String.isHex),s=ct,o=s.getVbyList,a=s.getTLVbyList,c=s.getIdxbyList,u=s.getChildIdx,h=s.getTLV,l=s.oidname,p=e.crypto.Util.hashHex;void 0===t.cms&&n(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 n=u(t,r).length;if(n<6)throw"malformed SignerInfo";e.sigalg=l(o(t,r,[n-2,0],"06")),e.sigval=o(t,r,[n-1],"04")},f=function(t,e,r){var i=u(t,r);e.signedAttrIdxList=i;for(var n=0;n<i.length;n++){var s,a=i[n],c=o(t,a,[0],"06");"2a864886f70d010905"===c?(s=mt(o(t,a,[1,0])),e.saSigningTime=s):"2a864886f70d010904"===c&&(s=o(t,a,[1,0],"04"),e.saMessageDigest=s)}},m=function(t,e,r,i){r.verifyDetail={};var n=r.verifyDetail,s=e.parse.econtent,o=r.hashalg,a=r.saMessageDigest;n.validMessageDigest=!1,p(s,o)===a&&(n.validMessageDigest=!0),function(t,e,r){var i,n=e.parse.certsIdx;if(void 0===e.certs){i=[],e.certkeys=[];for(var s=u(t,n),o=0;o<s.length;o++){var a=h(t,s[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=s.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),n.validSignatureValue=!1;var c=r.sigalg,l="31"+h(t,r.idxSignedAttrs).substr(2);r.signedattrshex=l;var d=e.certs[r.certkey_idx].getPublicKey(),g=new st.crypto.Signature({alg:c});g.init(d),g.updateHex(l);var f=g.verify(r.sigval);n.validSignatureValue_isValid=f,!0===f&&(n.validSignatureValue=!0),r.isValid=!1,n.validMessageDigest&&n.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 n=t.substr(r,2);"a0"===n&&(e.certsIdx=r),"a1"===n&&(e.revinfosIdx=r),"31"===n&&(e.signerinfosIdx=r)}}(t,e),e.signerInfos=[],function(t,e){var r=e.signerinfosIdx;if(void 0!==r){var i=u(t,r);e.signerInfoIdxList=i;for(var n=0;n<i.length;n++){var s={idx:i[n]};g(t,s),e.signerInfos.push(s)}}}(t,e)}(d,y.parse),function(t,e){for(var r=e.parse.signerInfos,i=r.length,n=!0,s=0;s<i;s++){var o=r[s];m(t,e,o),o.isValid||(n=!1)}e.isValid=n}(d,y),y},st.asn1.cms.CMSParser=function(){var t=Error,e=$t,r=new e,i=ct,n=i.getV,s=i.getTLV,o=(i.getIdxbyList,i.getTLVbyList),a=i.getTLVbyListEx,c=i.getVbyList,u=i.getVbyListEx,h=i.getChildIdx;this.getCMSSignedData=function(t){var e=o(t,0,[1,0]);return this.getSignedData(e)},this.getSignedData=function(t){var e=h(t,0),r={},i=n(t,e[0]),o=parseInt(i,16);r.version=o;var c=s(t,e[1]);r.hashalgs=this.getHashAlgArray(c);var u=s(t,e[2]);r.econtent=this.getEContent(u);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=h(t,0),i=new e,n=[],o=0;o<r.length;o++){var a=s(t,r[o]),c=i.getAlgorithmIdentifierName(a);n.push(c)}return n},this.getEContent=function(t){var e={},r=c(t,0,[0]),i=c(t,0,[1,0]);return e.type=st.asn1.x509.OID.oid2name(ct.hextooidstr(r)),e.content={hex:i},e},this.getSignerInfos=function(t){for(var e=[],r=h(t,0),i=0;i<r.length;i++){var n=s(t,r[i]),o=this.getSignerInfo(n);e.push(o)}return e},this.getSignerInfo=function(t){var e={},n=h(t,0),o=i.getInt(t,n[0],-1);-1!=o&&(e.version=o);var c=s(t,n[1]),l=this.getIssuerAndSerialNumber(c);e.id=l;var p=s(t,n[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 S=u(t,0,[4]);e.sighex=S;var v=a(t,0,["[1]"]);if(null!=v){var E=this.getAttributeList(v);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=h(t,0),o=s(t,i[0]);e.issuer=r.getX500Name(o);var a=n(t,i[1]);return e.serial={hex:a},e},this.getAttributeList=function(t){for(var e=[],r=h(t,0),i=0;i<r.length;i++){var n=s(t,r[i]),o=this.getAttribute(n);e.push(o)}return{array:e}},this.getAttribute=function(t){var e={},r=h(t,0),n=i.getOID(t,r[0]),o=st.asn1.x509.OID.oid2name(n);e.attr=o;var a=s(t,r[1]),c=h(a,0);if(1==c.length)e.valhex=s(a,c[0]);else{for(var u=[],l=0;l<c.length;l++)u.push(s(a,c[l]));e.valhex=u}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(n(t.valhex,0));t.str=e,delete t.valhex},this.setMessageDigest=function(t){var e=n(t.valhex,0);t.hex=e,delete t.valhex},this.setSigningCertificate=function(t){var e=h(t.valhex,0);if(e.length>0){for(var r=s(t.valhex,e[0]),i=h(r,0),n=[],o=0;o<i.length;o++){var a=s(r,i[o]),c=this.getESSCertID(a);n.push(c)}t.array=n}if(e.length>1){var u=s(t.valhex,e[1]);t.polhex=u}delete t.valhex},this.setSignaturePolicyIdentifier=function(t){var r=h(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=h(t.valhex,r[1]),u=s(t.valhex,c[0]),l=a.getAlgorithmIdentifierName(u);t.alg=l;var p=n(t.valhex,c[1]);t.hash=p}delete t.valhex},this.setSigningCertificateV2=function(t){var e=h(t.valhex,0);if(e.length>0){for(var r=s(t.valhex,e[0]),i=h(r,0),n=[],o=0;o<i.length;o++){var a=s(r,i[o]),c=this.getESSCertIDv2(a);n.push(c)}t.array=n}if(e.length>1){var u=s(t.valhex,e[1]);t.polhex=u}delete t.valhex},this.getESSCertID=function(t){var e={},r=h(t,0);if(r.length>0){var i=n(t,r[0]);e.hash=i}if(r.length>1){var o=s(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=h(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=s(e,o[0]);i.alg=r.getAlgorithmIdentifierName(c),a++}else i.alg="sha256";var u=n(e,o[a]);if(i.hash=u,o.length>a+1){var l=s(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=h(t,0),o=s(t,i[0]),a=r.getGeneralNames(o)[0].dn;e.issuer=a;var c=n(t,i[1]);return e.serial={hex:c},e},this.getCertificateSet=function(t){for(var e=h(t,0),r=[],i=0;i<e.length;i++){var n=s(t,e[i]);if("30"==n.substr(0,2)){var o=Et(n,"CERTIFICATE");r.push(o)}}return{array:r,sortflag:!1}}},void 0!==st&&st||(st={}),void 0!==st.asn1&&st.asn1||(st.asn1={}),void 0!==st.asn1.tsp&&st.asn1.tsp||(st.asn1.tsp={}),st.asn1.tsp.TimeStampToken=function(t){var e=st.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)},Mt(st.asn1.tsp.TimeStampToken,st.asn1.cms.SignedData),st.asn1.tsp.TSTInfo=function(t){Error;var e=st.asn1,r=e.DERSequence,i=e.DERInteger,n=e.DERBoolean,s=e.DERGeneralizedTime,o=e.DERObjectIdentifier,a=e.DERTaggedObject,c=e.tsp,u=c.MessageImprint,h=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 u(t.messageImprint)),void 0!==t.serial&&(this.dSerial=new i(t.serial)),void 0!==t.genTime&&(this.dGenTime=new s(t.genTime)),void 0!==t.accuracy&&(this.dAccuracy=new h(t.accuracy)),void 0!==t.ordering&&1==t.ordering&&(this.dOrdering=new n),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})}))}},Mt(st.asn1.tsp.TSTInfo,st.asn1.ASN1Object),st.asn1.tsp.Accuracy=function(t){var e=st.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)},Mt(st.asn1.tsp.Accuracy,st.asn1.ASN1Object),st.asn1.tsp.MessageImprint=function(t){var e=st.asn1,r=e.DERSequence,i=e.DEROctetString,n=e.x509.AlgorithmIdentifier;e.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=new n({name:t.alg}),s=new i({hex:t.hash});return new r({array:[e,s]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.tsp.MessageImprint,st.asn1.ASN1Object),st.asn1.tsp.TimeStampReq=function(t){var e=st.asn1,r=e.DERSequence,i=e.DERInteger,n=e.DERBoolean,s=(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 st.asn1.ASN1Object?e.push(t.messageImprint):e.push(new a(t.messageImprint)),null!=t.policy&&e.push(new s(t.policy)),null!=t.nonce&&e.push(new i(t.nonce)),1==t.certreq&&e.push(new n),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.tsp.TimeStampReq,st.asn1.ASN1Object),st.asn1.tsp.TimeStampResp=function(t){var e=st.asn1,r=e.DERSequence,i=(e.ASN1Object,e.tsp),n=i.PKIStatusInfo;i.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,s=[];if(null!=t.econtent||null!=t.tst)if(null!=t.statusinfo?s.push(new n(t.statusinfo)):s.push(new n("granted")),null!=t.econtent)s.push(new i.TimeStampToken(t).getContentInfo());else{if(!(t.tst instanceof e.ASN1Object))throw new Error("improper member tst value");s.push(t.tst)}else{if(null==t.statusinfo)throw new Error("parameter for token nor statusinfo not specified");s.push(new n(t.statusinfo))}return new r({array:s}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.tsp.TimeStampResp,st.asn1.ASN1Object),st.asn1.tsp.PKIStatusInfo=function(t){var e=Error,r=st.asn1,i=r.DERSequence,n=r.tsp,s=n.PKIStatus,o=n.PKIFreeText,a=n.PKIFailureInfo;n.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,r=[];if("string"==typeof t)r.push(new s(t));else{if(null==t.status)throw new e("property 'status' unspecified");r.push(new s(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)},Mt(st.asn1.tsp.PKIStatusInfo,st.asn1.ASN1Object),st.asn1.tsp.PKIStatus=function(t){var e=Error,r=st.asn1,i=r.DERInteger;r.tsp.PKIStatus.superclass.constructor.call(this);var n={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=n[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)},Mt(st.asn1.tsp.PKIStatus,st.asn1.ASN1Object),st.asn1.tsp.PKIFreeText=function(t){var e=Error,r=st.asn1,i=r.DERSequence,n=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=[],s=0;s<t.length;s++)r.push(new n({str:t[s]}));return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.tsp.PKIFreeText,st.asn1.ASN1Object),st.asn1.tsp.PKIFailureInfo=function(t){var e=Error,r=st.asn1,i=r.DERBitString,n=r.tsp.PKIFailureInfo,s={badAlg:0,badRequest:2,badDataFormat:5,timeNotAvailable:14,unacceptedPolicy:15,unacceptedExtension:16,addInfoNotAvailable:17,systemFailure:25};n.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),n="",o=i.length-1;o>=0;o--)n+=i[o];return n}if("string"==typeof t&&null!=s[t])return Ut([t],s);if("object"==typeof t&&null!=t.length)return Ut(t,s);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)},Mt(st.asn1.tsp.PKIFailureInfo,st.asn1.ASN1Object),st.asn1.tsp.AbstractTSAAdapter=function(t){this.getTSTHex=function(t,e){throw"not implemented yet"}},st.asn1.tsp.SimpleTSAAdapter=function(t){var e=st,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 n=i(t,e);this.params.econtent.content.messageImprint={alg:e,hash:n},this.params.econtent.content.serial={int:this.serial++};var s=Math.floor(1e9*Math.random());return this.params.econtent.content.nonce={int:s},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},Mt(st.asn1.tsp.SimpleTSAAdapter,st.asn1.tsp.AbstractTSAAdapter),st.asn1.tsp.FixedTSAAdapter=function(t){var e=st,r=e.asn1.tsp,i=e.crypto.Util.hashHex;r.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(t,e){var n=i(t,e);return this.params.econtent.content.messageImprint={alg:e,hash:n},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},Mt(st.asn1.tsp.FixedTSAAdapter,st.asn1.tsp.AbstractTSAAdapter),st.asn1.tsp.TSPUtil=new function(){},st.asn1.tsp.TSPUtil.newTimeStampToken=function(t){return new st.asn1.tsp.TimeStampToken(t)},st.asn1.tsp.TSPUtil.parseTimeStampReq=function(t){return(new st.asn1.tsp.TSPParser).getTimeStampReq(t)},st.asn1.tsp.TSPUtil.parseMessageImprint=function(t){return(new st.asn1.tsp.TSPParser).getMessageImprint(t)},st.asn1.tsp.TSPParser=function(){Error;var t=new $t,e=ct,r=e.getV,i=e.getTLV,n=e.getIdxbyList,s=(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=s(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])),n=i(t,e[1]),o=this.getToken(n);return o.statusinfo=r,o}},this.getToken=function(t){var e=(new st.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 n={},o=s(e,0),a=r(e,o[1]);n.policy=Lt(a);var c=i(e,o[2]);n.messageImprint=this.getMessageImprint(c);var u=r(e,o[3]);n.serial={hex:u};var h=r(e,o[4]);n.genTime={str:mt(h)};var l=0;if(o.length>5&&"30"==e.substr(o[5],2)){var p=i(e,o[5]);n.accuracy=this.getAccuracy(p),l++}if(o.length>5+l&&"01"==e.substr(o[5+l],2)&&("ff"==r(e,o[5+l])&&(n.ordering=!0),l++),o.length>5+l&&"02"==e.substr(o[5+l],2)){var d=r(e,o[5+l]);n.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;n.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);n.ext=y,l++}return n},this.getAccuracy=function(t){for(var e={},i=s(t,0),n=0;n<i.length;n++){var o=t.substr(i[n],2),a=r(t,i[n]),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=(s(t,0),n(t,0,[0,0])),a=r(t,o),c=e.hextooidstr(a),u=st.asn1.x509.OID.oid2name(c);if(""==u)throw new Error("hashAlg name undefined: "+c);var h=u,l=n(t,0,[1]);return i.alg=h,i.hash=r(t,l),i},this.getPKIStatusInfo=function(t){var e={},n=s(t,0),a=0;try{var c=r(t,n[0]),u=parseInt(c,16);e.status=o[u]}catch(t){}if(n.length>1&&"30"==t.substr(n[1],2)){var h=i(t,n[1]);e.statusstr=this.getPKIFreeText(h),a++}if(n.length>a&&"03"==t.substr(n[1+a],2)){var l=i(t,n[1+a]);e.failinfo=this.getPKIFailureInfo(l)}return e},this.getPKIFreeText=function(t){for(var r=[],i=s(t,0),n=0;n<i.length;n++)r.push(e.getString(t,i[n]));return r},this.getPKIFailureInfo=function(t){var r=e.getInt(t,0);return null!=a[r]?a[r]:r},this.getTimeStampReq=function(t){var n={certreq:!1},o=s(t,0);if(o.length<2)throw new Error("TimeStampReq must have at least 2 items");var a=i(t,o[1]);n.messageImprint=st.asn1.tsp.TSPUtil.parseMessageImprint(a);for(var c=2;c<o.length;c++){var u=o[c],h=t.substr(u,2);if("06"==h){var l=r(t,u);n.policy=e.hextooidstr(l)}"02"==h&&(n.nonce=r(t,u)),"01"==h&&(n.certreq=!0)}return n}},void 0!==st&&st||(st={}),void 0!==st.asn1&&st.asn1||(st.asn1={}),void 0!==st.asn1.cades&&st.asn1.cades||(st.asn1.cades={}),st.asn1.cades.SignaturePolicyIdentifier=function(t){var e=st.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)},Mt(st.asn1.cades.SignaturePolicyIdentifier,st.asn1.cms.Attribute),st.asn1.cades.SignaturePolicyId=function(t){var e=st.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,n=(e.x509.AlgorithmIdentifier,e.cades),s=n.SignaturePolicyId,o=n.OtherHashAlgAndValue;s.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)},Mt(st.asn1.cades.SignaturePolicyId,st.asn1.ASN1Object),st.asn1.cades.OtherHashAlgAndValue=function(t){var e=Error,r=st.asn1,i=r.DERSequence,n=r.DEROctetString,s=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=st.crypto.Util.hashHex(o,t.alg)}var a=[];return a.push(new s({name:t.alg})),a.push(new n({hex:r})),new i({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cades.OtherHashAlgAndValue,st.asn1.ASN1Object),st.asn1.cades.OtherHashValue=function(t){st.asn1.cades.OtherHashValue.superclass.constructor.call(this);var e=Error,r=st,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 n=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(n=xt(t.cert)),r=st.crypto.Util.hashHex(n,"sha1")}return new i({hex:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cades.OtherHashValue,st.asn1.ASN1Object),st.asn1.cades.SignatureTimeStamp=function(t){var e=Error,r=st,i=r.lang.String.isHex,n=r.asn1,s=n.ASN1Object;n.x509,n.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 s).hTLV=t.tst,[r];if(t.tst instanceof s)return[t.tst];throw new e("params.tst has wrong value")}if(null!=t.res){var r,n=t.res;if(n instanceof s&&(n=n.tohex()),"string"!=typeof n||!i(n))throw new e("params.res has wrong value");return ct.getTLVbyList(n,0,[1]),(r=new s).hTLV=t.tst,[r]}},null!=t&&this.setByParam(t)},Mt(st.asn1.cades.SignatureTimeStamp,st.asn1.cms.Attribute),st.asn1.cades.CompleteCertificateRefs=function(t){var e=Error,r=st,i=r.asn1,n=i.DERSequence,s=i.cades,o=s.OtherCertID,a=r.lang.String.isHex;s.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 s=t.array[i];if("string"==typeof s)if(-1!=s.indexOf("-----BEGIN"))s={cert:s};else{if(!a(s))throw new e("unsupported value: "+s);s={hash:s}}null!=t.alg&&null==s.alg&&(s.alg=t.alg),null!=t.hasis&&null==s.hasis&&(s.hasis=t.hasis);var c=new o(s);r.push(c)}return[new n({array:r})]},null!=t&&this.setByParam(t)},Mt(st.asn1.cades.CompleteCertificateRefs,st.asn1.cms.Attribute),st.asn1.cades.OtherCertID=function(t){var e=st.asn1,r=e.DERSequence,i=e.cms.IssuerSerial,n=e.cades,s=n.OtherHashValue,o=n.OtherHashAlgAndValue;n.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,n=[];if(e=null!=t.alg?new o(t):new s(t),n.push(e),null!=t.cert&&1==t.hasis||null!=t.issuer&&null!=t.serial){var a=new i(t);n.push(a)}return new r({array:n}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cades.OtherCertID,st.asn1.ASN1Object),st.asn1.cades.OtherHash=function(t){Error;var e=st,r=e.asn1,i=(r.cms,r.cades),n=i.OtherHashAlgAndValue,s=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 n(t):new s(t)).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cades.OtherHash,st.asn1.ASN1Object),st.asn1.cades.CAdESUtil=new function(){},st.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned=function(t){return(new st.asn1.cms.CMSParser).getCMSSignedData(t)},st.asn1.cades.CAdESUtil.parseSignerInfoForAddingUnsigned=function(t,e,r){var i=ct,n=i.getChildIdx,s=i.getTLV,o=i.getV,a=st.asn1,c=a.ASN1Object,u=a.cms,h=u.AttributeList,l=u.SignerInfo,p={},d=n(t,e);if(6!=d.length)throw"not supported items for SignerInfo (!=6)";var g=d.shift();p.version=s(t,g);var f=d.shift();p.si=s(t,f);var m=d.shift();p.digalg=s(t,m);var y=d.shift();p.sattrs=s(t,y);var S=d.shift();p.sigalg=s(t,S);var v=d.shift();p.sig=s(t,v),p.sigval=o(t,v);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 h,p},void 0!==st.asn1.csr&&st.asn1.csr||(st.asn1.csr={}),st.asn1.csr.CertificationRequest=function(t){var e=st.asn1,r=e.DERBitString,i=e.DERSequence,n=e.csr,s=(e.x509,n.CertificationRequestInfo);n.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.sign=function(){var t=new s(this.params).tohex(),e=new st.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 st.asn1.csr.CertificationRequestInfo(this.params),n=new st.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 s=new r({hex:"00"+t.sighex});return new i({array:[e,n,s]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.csr.CertificationRequest,st.asn1.ASN1Object),st.asn1.csr.CertificationRequestInfo=function(t){var e=st.asn1,r=(e.DERBitString,e.DERSequence),i=e.DERInteger,n=e.DERUTF8String,s=e.DERTaggedObject,o=e.ASN1Util.newObject,a=e.csr,c=e.x509,u=c.X500Name,h=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 u(t.subject)),e.push(new l(Vt.getKey(t.sbjpubkey))),null!=t.attrs){var a=function(t){for(var e=Error,r=st.asn1.x509.Extensions,i=[],n=0;n<t.length;n++){var s=t[n],o=s.attr;if("extensionRequest"==o){var a={seq:[{oid:"1.2.840.113549.1.9.14"},{set:[new r(s.ext)]}]};i.push(a)}else if("unstructuredName"==o)a={seq:[{oid:"1.2.840.113549.1.9.2"},{set:s.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:s.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 h(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 s({tag:"a0",explicit:!1,obj:new n({str:""})}));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.csr.CertificationRequestInfo,st.asn1.ASN1Object),st.asn1.csr.AttributeList=function(t){},Mt(st.asn1.csr.AttributeList,st.asn1.ASN1Object),st.asn1.csr.CSRUtil=new function(){},st.asn1.csr.CSRUtil.newCSRPEM=function(t){return new st.asn1.csr.CertificationRequest(t).getPEM()},st.asn1.csr.CSRUtil.getParam=function(t,e){var r=ct,i=r.getV,n=r.getIdxbyList,s=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 u=xt(t,"CERTIFICATE REQUEST");e&&(c.tbs=s(u,0,[0]));try{var h=o(u,0,[0,1]);if("3000"==h)c.subject={};else{var l=new $t;c.subject=l.getX500Name(h)}}catch(t){}var p=o(u,0,[0,2]),d=Vt.getKey(p,null,"pkcs8pub");c.sbjpubkey=Vt.getPEM(d,"PKCS8PUB");var g=function(t){var e=n(t,0,[0,3,0,0],"06");return"2a864886f70d01090e"!=i(t,e)?null:s(t,0,[0,3,0,1,0],"30")}(u);l=new $t,null!=g&&(c.extreq=l.getExtParamArray(g));try{var f=o(u,0,[1],"30");l=new $t,c.sigalg=l.getAlgorithmIdentifierName(f)}catch(t){}try{var m=a(u,0,[2]);c.sighex=m}catch(t){}return c},st.asn1.csr.CSRUtil.verifySignature=function(t){try{var e=null;if("string"==typeof t&&-1!=t.indexOf("-----BEGIN CERTIFICATE REQUEST")?e=st.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 st.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!==st&&st||(st={}),void 0!==st.asn1&&st.asn1||(st.asn1={}),void 0!==st.asn1.ocsp&&st.asn1.ocsp||(st.asn1.ocsp={}),st.asn1.ocsp.DEFAULT_HASH="sha1",st.asn1.ocsp.OCSPResponse=function(t){st.asn1.ocsp.OCSPResponse.superclass.constructor.call(this),st.asn1.DEREnumerated;var e=st.asn1.ASN1Util.newObject,r=st.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 n=new r(t);return e({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:n}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.ocsp.OCSPResponse,st.asn1.ASN1Object),st.asn1.ocsp.ResponseBytes=function(t){st.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var e=st.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,n=e.DEROctetString,s=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 s(t),o=[];return o.push(new i({name:"ocspBasic"})),o.push(new n({hex:e.tohex()})),new r({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.ocsp.ResponseBytes,st.asn1.ASN1Object),st.asn1.ocsp.BasicOCSPResponse=function(t){st.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var e=Error,r=st.asn1,i=r.ASN1Object,n=r.DERSequence,s=(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 st.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=[],u=0;u<t.certs.length;u++){var h=t.certs[u],l=null;if(ct.isASN1HEX(h))l=h;else{if(!h.match(/-----BEGIN/))throw new e("certs["+u+"] not hex or PEM");l=xt(h)}c.push(new i({tlv:l}))}var p=new n({array:c});r.push(new s({tag:"a0",explicit:!0,obj:p}))}return new n({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.ocsp.BasicOCSPResponse,st.asn1.ASN1Object),st.asn1.ocsp.ResponseData=function(t){st.asn1.ocsp.ResponseData.superclass.constructor.call(this);var e=Error,r=st.asn1,i=r.DERSequence,n=r.DERGeneralizedTime,s=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 n(t.prodat)),r.push(new _SingleResponseList(t.array)),null!=t.ext){var a=new o(t.ext);r.push(new s({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)},Mt(st.asn1.ocsp.ResponseData,st.asn1.ASN1Object),st.asn1.ocsp.ResponderID=function(t){st.asn1.ocsp.ResponderID.superclass.constructor.call(this);var e=st,r=e.asn1,i=r.ASN1Util.newObject,n=r.x509.X500Name,s=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?(s(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 n(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)},Mt(st.asn1.ocsp.ResponderID,st.asn1.ASN1Object),st.asn1.ocsp.SingleResponseList=function(t){st.asn1.ocsp.SingleResponseList.superclass.constructor.call(this);var e=st.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=[],n=0;n<t.length;n++)e.push(new i(t[n]));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)},Mt(st.asn1.ocsp.SingleResponseList,st.asn1.ASN1Object),st.asn1.ocsp.SingleResponse=function(t){var e=Error,r=st.asn1,i=r.DERSequence,n=r.DERGeneralizedTime,s=r.DERTaggedObject,o=r.ocsp,a=o.CertID,c=o.CertStatus,u=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 n(t.thisupdate)),null!=t.nextupdate){var o=new n(t.nextupdate);r.push(new s({tag:"a0",explicit:!0,obj:o}))}if(null!=t.ext){var h=new u(t.ext);r.push(new s({tag:"a1",explicit:!0,obj:h}))}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)},Mt(st.asn1.ocsp.SingleResponse,st.asn1.ASN1Object),st.asn1.ocsp.CertID=function(t){var e=st,r=e.asn1,i=r.DEROctetString,n=r.DERInteger,s=r.DERSequence,o=r.x509.AlgorithmIdentifier,a=r.ocsp,c=(a.DEFAULT_HASH,e.crypto.Util.hashHex),u=$t,h=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 u(t),n=new u(e),s=c(i.getSubjectHex(),r),o=i.getPublicKeyHex();return{alg:r,issname:s,isskey:c(h(o,0,[1],"03",!0),r),sbjsn:n.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 u=this.getParamByCerts(c.issuerCert,c.subjectCert,a);t=u.issname,e=u.isskey,r=u.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 h=new o({name:a}),l=new i({hex:t}),p=new i({hex:e}),d=new n({hex:r}),g=new s({array:[h,l,p,d]});return this.hTLV=g.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.ocsp.CertID,st.asn1.ASN1Object),st.asn1.ocsp.CertStatus=function(t){st.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 st.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)},Mt(st.asn1.ocsp.CertStatus,st.asn1.ASN1Object),st.asn1.ocsp.Request=function(t){var e=st.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 n=new i.CertID(t);this.dReqCert=n}},Mt(st.asn1.ocsp.Request,st.asn1.ASN1Object),st.asn1.ocsp.TBSRequest=function(t){var e=st.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 n=new i.Request(t[0]);e.push(n)}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)},Mt(st.asn1.ocsp.TBSRequest,st.asn1.ASN1Object),st.asn1.ocsp.OCSPRequest=function(t){var e=st.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 n=new i.TBSRequest(t);this.dTbsRequest=n}},Mt(st.asn1.ocsp.OCSPRequest,st.asn1.ASN1Object),st.asn1.ocsp.OCSPUtil={},st.asn1.ocsp.OCSPUtil.getRequestHex=function(t,e,r){var i=st.asn1.ocsp;void 0===r&&(r=i.DEFAULT_HASH);var n={alg:r,issuerCert:t,subjectCert:e};return new i.OCSPRequest({reqList:[n]}).tohex()},st.asn1.ocsp.OCSPUtil.getOCSPResponseInfo=function(t){var e=ct,r=e.getVbyList,i=e.getVbyListEx,n=e.getIdxbyList,s=(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=n(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 u=n(t,0,[1,0,1,0,0,2,0,2]);o.thisUpdate=mt(s(t,u))}catch(t){}try{var h=n(t,0,[1,0,1,0,0,2,0,3]);"a0"===t.substr(h,2)&&(o.nextUpdate=mt(r(t,h,[0])))}catch(t){}return o},st.asn1.ocsp.OCSPParser=function(){var t=Error,e=$t,r=new e,i=ct,n=i.getV,s=i.getTLV,o=i.getIdxbyList,a=i.getVbyList,c=i.getTLVbyList,u=i.getVbyListEx,h=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(s(e,r[0]))},this.getTBSRequest=function(t){var e={},i=h(t,0,[0],"30");e.array=this.getRequestList(i);var n=h(t,0,["[2]",0],"30");return null!=n&&(e.ext=r.getExtParamArray(n)),e},this.getRequestList=function(t){for(var e=[],r=l(t,0),i=0;i<r.length;i++)t=s(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 n=this.getCertID(s(e,i[0]));if(2==i.length){var a=o(e,0,[1,0]);n.ext=r.getExtParamArray(s(e,a))}return n},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(s(r,i[0])),a.issname=n(r,i[1]),a.isskey=n(r,i[2]),a.sbjsn=n(r,i[3]),a},this.getOCSPResponse=function(t){var e,r=l(t,0),i=n(t,r[0]),s=parseInt(i);if(1==r.length)return{resstatus:s};var o=c(t,0,[1,0]);return(e=this.getResponseBytes(o)).resstatus=s,e},this.getResponseBytes=function(t){var e,r=l(t,0),i=c(t,0,[1,0]);e=this.getBasicOCSPResponse(i);var s=n(t,r[0]);return e.restype=st.asn1.x509.OID.oid2name(Lt(s)),e},this.getBasicOCSPResponse=function(t){var e,r=l(t,0);e=this.getResponseData(s(t,r[0]));var i=new $t;e.alg=i.getAlgorithmIdentifierName(s(t,r[1]));var o=n(t,r[2]);e.sighex=o.substr(2);var a=u(t,0,["[0]"]);if(null!=a){for(var c=l(a,0),h=[],p=0;p<c.length;p++){var d=s(a,c[p]);h.push(d)}e.certs=h}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(s(t,e[o++]));var a=n(t,e[o++]);if(i.prodat=mt(a),i.array=this.getSingleResponseList(s(t,e[o++])),"a1"==t.substr(e[r-1],2)){var u=c(t,e[r-1],[0]),h=new $t;i.ext=h.getExtParamArray(u)}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]),n=new $t;e.name=n.getX500Name(i)}return e},this.getSingleResponseList=function(t){for(var e=l(t,0),r=[],i=0;i<e.length;i++){var n=this.getSingleResponse(s(t,e[i]));r.push(n)}return r},this.getSingleResponse=function(t){var e=l(t,0),r={},i=this.getCertID(s(t,e[0]));r.certid=i;var o=this.getCertStatus(s(t,e[1]));if(r.status=o,"18"==t.substr(e[2],2)){var u=n(t,e[2]);r.thisupdate=mt(u)}for(var h=3;h<e.length;h++){if("a0"==t.substr(e[h],2)){var p=a(t,e[h],[0],"18");r.nextupdate=mt(p)}if("a1"==t.substr(e[h],2)){var d=new $t,g=c(t,0,[h,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!==st&&st||(st={}),void 0!==st.lang&&st.lang||(st.lang={}),st.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(At(Nt(t)))},at=function(t){return decodeURIComponent(wt(gt(t)))}),st.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},st.lang.String.isHex=function(t){return Ot(t)},st.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},st.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=pt(t),st.lang.String.isBase64(t))},st.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},st.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},st.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},st.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 n=r.toString(2),s="";for(i=n.length-1;i>=0;i--)s+=n[i];return s}function jt(t,e,r){if("object"==typeof t){e=String(e).split(".");for(var i=0;i<e.length&&t;i++){var n=e[i];n.match(/^[0-9]+$/)&&(n=parseInt(n)),t=t[n]}return t||!1===t?t:r}}function Mt(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!==st&&st||(st={}),void 0!==st.crypto&&st.crypto||(st.crypto={}),st.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),n=r/4;if(i.length+22>n)throw"key is too short for SigAlg: keylen="+r+","+e;for(var s="00"+i,o="",a=n-4-s.length,c=0;c<a;c+=2)o+="ff";return"0001"+o+s},this.hashString=function(t,e){return new st.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new st.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 st.crypto.DSA||t instanceof st.crypto.ECDSA}},st.crypto.Util.md5=function(t){return new st.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},st.crypto.Util.ripemd160=function(t){return new st.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},st.crypto.Util.SECURERANDOMGEN=new Q,st.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return st.crypto.Util.SECURERANDOMGEN.nextBytes(e),ut(e)},st.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new E(st.crypto.Util.getRandomHexOfNbytes(t),16)},st.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,r=new Array((t-e)/8+1);return st.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<e&255^255)&r[0],ut(r)},st.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new E(st.crypto.Util.getRandomHexOfNbits(t),16)},st.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=st.crypto.Util.getRandomBigIntegerOfNbits(e);if(t.compareTo(r)>=0)return r}},st.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 st.crypto.Util.getRandomBigIntegerZeroToMax(i).add(t)},st.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=st.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=st.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=st.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=st.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},st.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},st.crypto.MessageDigest.getHashLength=function(t){var e=st.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},st.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},st.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=st.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=st.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=vt(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=vt(t.rstr)),void 0!==t.b64&&(e=v(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=st.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},st.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,n=0;n<i;n++)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 st.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?Vt.getKey(t):Vt.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!==st.crypto.ECDSA&&(this.prvKey=new st.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 st.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof st.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!==st.crypto.ECDSA&&(this.pubKey=new st.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!==st.crypto.ECDSA&&this.pubKey instanceof st.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==st.crypto.DSA&&this.pubKey instanceof st.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=st.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=Vt.getKey(t.prvkeypem),this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},st.crypto.Cipher=function(t){},st.crypto.Cipher.encrypt=function(t,e,r,i){if(null!=jt(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var n=e,s=t;null!=jt(i,"key")&&(n=i.key),null!=jt(i,"enc")&&(hEnc=i.enc);var o,a=f.enc.Hex.parse(n),c=f.enc.Hex.parse(s),u=f.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)o=f.TripleDES.encrypt(c,a,{iv:u});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);o=f.AES.encrypt(c,a,{iv:u})}return o+""}throw new Error("Cipher.encrypt: unsupported key or algorithm")},st.crypto.Cipher.decrypt=function(t,e,r,i){if(null!=jt(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var n=e,s=t;null!=jt(i,"key")&&(n=i.key),null!=jt(i,"enc")&&(s=i.enc);var o,a=f.enc.Hex.parse(n),c=f.enc.Hex.parse(s),u=f.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)o=f.TripleDES.decrypt({ciphertext:c},a,{iv:u});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);o=f.AES.decrypt({ciphertext:c},a,{iv:u})}return f.enc.Hex.stringify(o)}throw new Error("Cipher.decrypt: unsupported key or algorithm")},st.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!==st&&st||(st={}),void 0!==st.crypto&&st.crypto||(st.crypto={}),st.crypto.ECDSA=function(t){var e=Error,r=E,i=rt,n=st.crypto.ECDSA,s=st.crypto.ECParameterDB,o=n.getName,a=ct,c=a.getVbyListEx,u=a.isASN1HEX,h=new Q;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(t){return new r(t.bitLength(),h).mod(t.subtract(r.ONE)).add(r.ONE)},this.setNamedCurve=function(t){this.ecparams=s.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(),n=e.getY().toBigInteger(),s=this.ecparams.keycharlen,o="04"+("0000000000"+i.toString(16)).slice(-s)+("0000000000"+n.toString(16)).slice(-s);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),s=this.ecparams.n,o=new r(t.substring(0,this.ecparams.keycharlen),16);do{var a=this.getBigRandom(s),c=this.ecparams.G.multiply(a).getX().toBigInteger().mod(s)}while(c.compareTo(r.ZERO)<=0);var u=a.modInverse(s).multiply(o.add(i.multiply(c))).mod(s);return n.biRSSigToASN1Sig(c,u)},this.sign=function(t,e){var i=e,n=this.ecparams.n,s=r.fromByteArrayUnsigned(t);do{var o=this.getBigRandom(n),a=this.ecparams.G.multiply(o).getX().toBigInteger().mod(n)}while(a.compareTo(E.ZERO)<=0);var c=o.modInverse(n).multiply(s.add(i.multiply(a))).mod(n);return this.serializeSig(a,c)},this.verifyWithMessageHash=function(t,e){return this.verifyHex(t,e,this.pubKeyHex)},this.verifyHex=function(t,e,s){try{var o,a,c=n.parseSigHex(e);o=c.r,a=c.s;var u=i.decodeFromHex(this.ecparams.curve,s),h=new r(t.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(h,o,a,u)}catch(t){return!1}},this.verify=function(t,e,n){var s,o,a;if(Bitcoin.Util.isArray(e)){var c=this.parseSig(e);s=c.r,o=c.s}else{if("object"!=typeof e||!e.r||!e.s)throw"Invalid value for signature";s=e.r,o=e.s}if(n instanceof rt)a=n;else{if(!Bitcoin.Util.isArray(n))throw"Invalid format for pubkey value, must be byte array or ECPointFp";a=i.decodeFrom(this.ecparams.curve,n)}var u=r.fromByteArrayUnsigned(t);return this.verifyRaw(u,s,o,a)},this.verifyRaw=function(t,e,i,n){var s=this.ecparams.n,o=this.ecparams.G;if(e.compareTo(r.ONE)<0||e.compareTo(s)>=0)return!1;if(i.compareTo(r.ONE)<0||i.compareTo(s)>=0)return!1;var a=i.modInverse(s),c=t.multiply(a).mod(s),u=e.multiply(a).mod(s);return o.multiply(c).add(n.multiply(u)).getX().toBigInteger().mod(s).equals(e)},this.serializeSig=function(t,e){var r=t.toByteArraySigned(),i=e.toByteArraySigned(),n=[];return n.push(2),n.push(r.length),(n=n.concat(r)).push(2),n.push(i.length),(n=n.concat(i)).unshift(n.length),n.unshift(48),n},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 n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:r.fromByteArrayUnsigned(i),s:r.fromByteArrayUnsigned(n)}},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===u(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===u(t))throw new e("not ASN.1 hex string");var r,i,n;try{c(t,0,[1,0],"06"),r=c(t,0,[1,1],"06"),i=c(t,0,[2,0,1],"04");try{n=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(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===u(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===u(t))throw new e("not ASN.1 hex string");var i,n;try{i=c(t,0,[0,5,0,1],"06"),n=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(n)},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))},st.crypto.ECDSA.parseSigHex=function(t){var e=st.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new E(e.r,16),s:new E(e.s,16)}},st.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 n=r(t,0);if(2!=n.length)throw new Error("signature shall have two elements");var s=n[0],o=n[1];if("02"!=t.substr(s,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,s),s:i(t,o)}},st.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=st.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 n=Math.max(r.length,i.length);return(r=("000000"+r).slice(-n))+("000000"+i).slice(-n)}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},st.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 st.crypto.ECDSA.hexRSSigToASN1Sig(e,r)},st.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var r=new E(t,16),i=new E(e,16);return st.crypto.ECDSA.biRSSigToASN1Sig(r,i)},st.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var r=st.asn1,i=new r.DERInteger({bigint:t}),n=new r.DERInteger({bigint:e});return new r.DERSequence({array:[i,n]}).tohex()},st.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!==st&&st||(st={}),void 0!==st.crypto&&st.crypto||(st.crypto={}),st.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,n,s,o,a,c,u,h,l,p,d,g){t[i]={};var f=r(s),m=r(o),y=r(a),S=r(c),v=r(u),E=new it(f,m,y),x=E.decodePointHex("04"+h+l);t[i].name=i,t[i].keylen=n,t[i].keycharlen=2*Math.ceil(n/8),t[i].curve=E,t[i].G=x,t[i].n=S,t[i].h=v,t[i].oid=d,t[i].info=g;for(var A=0;A<p.length;A++)e[p[A]]=i}},st.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),st.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),st.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),st.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),st.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),st.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),st.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),st.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),st.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),st.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]),void 0!==st&&st||(st={}),void 0!==st.crypto&&st.crypto||(st.crypto={}),st.crypto.DSA=function(){var t=ct,e=(t.getVbyList,t.getVbyListEx),r=t.isASN1HEX,i=E,n=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,n){this.isPrivate=!0,this.p=t,this.q=e,this.g=r,this.y=i,this.x=n},this.setPrivateHex=function(t,e,r,i,n){var s,o,a,c,u;s=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,u=new E(n,16),this.setPrivate(s,o,a,c,u)},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(n.compareTo(e)>=0||e.compareTo(t)>=0)throw new Error("invalid DSA public key");if(n.compareTo(r)>=0||r.compareTo(t)>=0)throw new Error("invalid DSA public key");if(n.compareTo(i)>=0||i.compareTo(t)>=0)throw new Error("invalid DSA public key");if(0!=r.modPow(e,t).compareTo(n))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 n,s,o,a;n=new E(t,16),s=new E(e,16),o=new E(r,16),a=new E(i,16),this.setPublic(n,s,o,a)},this.signWithMessageHash=function(t){var e,r,i,n=this.p,s=this.q,o=this.g,a=(this.y,this.x),c=new E(t.substr(0,s.bitLength()/4),16);do{e=st.crypto.Util.getRandomBigIntegerMinToMax(E.ONE.add(E.ONE),s.subtract(E.ONE)),r=o.modPow(e,n).mod(s),i=e.modInverse(s).multiply(c.add(a.multiply(r))).mod(s)}while(0==r.compareTo(E.ZERO)||0==i.compareTo(E.ZERO));return st.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:r}},{int:{bigint:i}}]})},this.verifyWithMessageHash=function(t,e){var r=this.p,i=this.q,n=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],c=o[1],u=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 h=c.modInverse(i),l=u.multiply(h).mod(i),p=a.multiply(h).mod(i);return 0==n.modPow(l,r).multiply(s.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,n,s,o,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1],"02"),n=e(t,0,[2],"02"),s=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,n,s,o,a)},this.readPKCS8PrvKeyHex=function(t){var i,n,s,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1,1,0],"02"),n=e(t,0,[1,1,1],"02"),s=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,n,s,null,o)},this.readPKCS8PubKeyHex=function(t){var i,n,s,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[0,1,0],"02"),n=e(t,0,[0,1,1],"02"),s=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,n,s,o)},this.readCertPubKeyHex=function(t,i){var n,s,o,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{n=e(t,0,[0,5,0,1,0],"02"),s=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(n,s,o,a)}};var Vt=function(){var t=function(t,r,i){return e(f.AES,t,r,i)},e=function(t,e,r,i){var n=f.enc.Hex.parse(e),s=f.enc.Hex.parse(r),o=f.enc.Hex.parse(i),a={};a.key=s,a.iv=o,a.ciphertext=n;var c=t.decrypt(a,s,{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 n=f.enc.Hex.parse(e),s=f.enc.Hex.parse(r),o=f.enc.Hex.parse(i),a=t.encrypt(n,s,{iv:o}),c=f.enc.Hex.parse(a.toString());return f.enc.Base64.stringify(c)},n={"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}},s=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 n=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(n=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(n=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=n&&-1!=o){var a=t.substring(n+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,r){for(var i=r.substring(0,16),s=f.enc.Hex.parse(i),o=f.enc.Utf8.parse(e),a=n[t].keylen+n[t].ivlen,c="",u=null;;){var h=f.algo.MD5.create();if(null!=u&&h.update(u),h.update(o),h.update(s),u=h.finalize(),(c+=f.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=c.substr(0,2*n[t].keylen),l.ivhex=c.substr(2*n[t].keylen,2*n[t].ivlen),l},a=function(t,e,r,i){var s=f.enc.Base64.parse(t),o=f.enc.Hex.stringify(s);return(0,n[e].proc)(o,r,i)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(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=s(t),i=(r.type,r.cipher),n=r.ivsalt,c=r.data,u=o(i,e,n).keyhex;return a(c,i,u,n)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,i,s){var a="";if(void 0!==i&&null!=i||(i="AES-256-CBC"),void 0===n[i])throw new Error("KEYUTIL unsupported algorithm: "+i);if(void 0===s||null==s){var c=function(t){var e=f.lib.WordArray.random(t);return f.enc.Hex.stringify(e)}(n[i].ivlen);s=c.toUpperCase()}var u=function(t,e,r,i){return(0,n[e].eproc)(t,r,i)}(e,i,o(i,r,s).keyhex,s);return a="-----BEGIN "+t+" PRIVATE KEY-----\r\n",a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+i+","+s+"\r\n",a+="\r\n",(a+=u.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 n=this.generatePBES2ASN1Param(i);return st.asn1.ASN1Util.newObject(n).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=Vt.getDKFromPBES2Param(t,e);try{var i=st.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,n={},s=r(t,0);if(2!=s.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+s.length);n.ciphertext=i(t,s[1]);var o=r(t,s[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";n.encryptionSchemeAlg="TripleDES",n.encryptionSchemeIV=i(t,c[1]);var u=r(t,a[0]);if(2!=u.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length);if("2a864886f70d01050c"!=i(t,u[0]))throw new Error("this only supports pkcs5PBKDF2");var h=r(t,u[1]);if(h.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+h.length);n.pbkdf2Salt=i(t,h[0]);var l=i(t,h[1]);try{n.pbkdf2Iter=parseInt(l,16)}catch(t){throw new Error("malformed format pbkdf2Iter: "+l)}return n},getPBKDF2KeyHexFromParam:function(t,e){var r=f.enc.Hex.parse(t.pbkdf2Salt),i=t.pbkdf2Iter,n=f.PBKDF2(e,r,{keySize:6,iterations:i});return f.enc.Hex.stringify(n)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=xt(t,"ENCRYPTED PRIVATE KEY"),i=this.parseHexOfEncryptedPKCS8(r),n=Vt.getPBKDF2KeyHexFromParam(i,e),s={};s.ciphertext=f.enc.Hex.parse(i.ciphertext);var o=f.enc.Hex.parse(n),a=f.enc.Hex.parse(i.encryptionSchemeIV),c=f.TripleDES.decrypt(s,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"),n=jt(r,"1.int.hex"),s=jt(r,"2.seq.0.oid","hmacWithSHA1"),o=-1;try{o=parseInt(n,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"),u=jt(e,"seq.1.octstr.hex");if(null==a||null==c||null==u)throw new Error("encalg, enciv or enc is undefined");return{salt:i,iter:o,prf:s,encalg:a,enciv:c,enc:u}},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 n=f.enc.Hex.parse(t.salt),s=t.iter;try{var o=f.PBKDF2(e,n,{keySize:i,iterations:s,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=Vt.parsePBES2(i)}catch(t){throw new Error("malformed PBES2 format: "+t.message)}var n=Vt.getDKFromPBES2Param(r,e);return st.crypto.Cipher.decrypt(r.enc,n,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,n={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=r(t,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");var o=r(t,s[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(n.algoid=i(t,o[0]),"06"==t.substr(o[1],2)&&(n.algparam=i(t,o[1])),"04"!=t.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return n.keyidx=e.getVidx(t,s[2]),n},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 st.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw new Error("unsupported private key algorithm");e=new st.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 st.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw new Error("unsupported PKCS#8 public key hex");e=new st.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=ct,r=e.getChildIdx,i=e.getV,n={};if("30"!=t.substr(0,2))throw new Error("malformed RSA key(code:001)");var s=r(t,0);if(2!=s.length)throw new Error("malformed RSA key(code:002)");if("02"!=t.substr(s[0],2))throw new Error("malformed RSA key(code:003)");if(n.n=i(t,s[0]),"02"!=t.substr(s[1],2))throw new Error("malformed RSA key(code:004)");return n.e=i(t,s[1]),n},parsePublicPKCS8Hex:function(t){var e=ct,r=e.getChildIdx,i=e.getV,n={algparam:null},s=r(t,0);if(2!=s.length)throw new Error("outer DERSequence shall have 2 elements: "+s.length);var o=s[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(n.algoid=i(t,a[0]),"06"==t.substr(a[1],2)?n.algparam=i(t,a[1]):"30"==t.substr(a[1],2)&&(n.algparam={},n.algparam.p=e.getVbyList(t,a[1],[0],"02"),n.algparam.q=e.getVbyList(t,a[1],[1],"02"),n.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw new Error("malformed PKCS8 public key(code:004)");return n.key=i(t,s[1]).substr(2),n}}}();function Kt(t,e){for(var r="",i=e/4-t.length,n=0;n<i;n++)r+="0";return r+t}function Gt(t,e,r){for(var i="",n=0;i.length<e;)i+=St(r(vt(t+String.fromCharCode.apply(String,[(4278190080&n)>>24,(16711680&n)>>16,(65280&n)>>8,255&n])))),n+=1;return i}function qt(t){for(var e in st.crypto.Util.DIGESTINFOHEAD){var r=st.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,n=r.getV,s=(r.dump,r.parse),o=r.getTLV,a=r.getVbyList,c=r.getVbyListEx,u=r.getTLVbyList,h=r.getTLVbyListEx,l=r.getIdxbyList,p=r.getIdxbyListEx,d=r.getVidx,g=r.getInt,f=r.oidname,m=r.hextooidstr,y=xt,S=Error;try{e=st.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=u(this.hex,0,[0,0]);if("a0"==t.substr(0,2)){var e=u(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=h(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 u(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 u(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 u(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 Vt.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=u(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=u(this.hex,0,[0],"30"),n=new st.crypto.Signature({alg:e});return n.init(t),n.updateHex(i),n.verify(r)},this.parseExt=function(t){var e,s,o;if(void 0===t){if(o=this.hex,3!==this.version)return-1;e=l(o,0,[0,7,0],"30"),s=i(o,e)}else{o=xt(t);var c=l(o,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=n(o,c))return void(this.aExtInfo=new Array);e=l(o,0,[0,3,0,1,0],"30"),s=i(o,e),this.hex=o}this.aExtInfo=new Array;for(var u=0;u<s.length;u++){var h={critical:!1},p=0;3===i(o,s[u]).length&&(h.critical=!0,p=1),h.oid=r.hextooidstr(a(o,s[u],[0],"06"));var g=l(o,s[u],[1+p]);h.vidx=d(o,g),this.aExtInfo.push(h)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(t.match(/^[0-9.]+$/)||(r=st.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 s=n(t,10),a=parseInt(s,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 n={extname:"nameConstraints"};e&&(n.critical=!0);for(var s=i(t,0),a=0;a<s.length;a++){for(var c=[],u=i(t,s[a]),h=0;h<u.length;h++){var l=o(t,u[h]),p=this.getGeneralSubtree(l);c.push(p)}var d=t.substr(s[a],2);"a0"==d?n.permit=c:"a1"==d&&(n.exclude=c)}return n}},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 s=this.getGeneralName(o(t,e[0])),a=1;a<r;a++){var c=t.substr(e[a],2),u=n(t,e[a]),h=parseInt(u,16);"80"==c&&(s.min=h),"81"==c&&(s.max=h)}return s},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 s=n(t,0);return i.kid={hex:s},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 s={extname:"authorityKeyIdentifier"};e&&(s.critical=!0);for(var a=i(t,0),c=0;c<a.length;c++){var u=t.substr(a[c],2);if("80"===u&&(s.kid={hex:n(t,a[c])}),"a1"===u){var h=o(t,a[c]),l=this.getGeneralNames(h);s.issuer=l[0].dn}"82"===u&&(s.sn={hex:n(t,a[c])})}return s},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 s={extname:"extKeyUsage",array:[]};e&&(s.critical=!0);for(var a=i(t,0),c=0;c<a.length;c++)s.array.push(f(n(t,a[c])));return s},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 s=i(r,0),a=0;a<s.length;a++)e.push(f(n(r,s[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=[],n=0;n<e.length;n++){var s=this.getGeneralName(o(t,e[n]));void 0!==s&&r.push(s)}return r},this.getGeneralName=function(t){var e=t.substr(0,2),r=n(t,0),i=St(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,s=this.getExtInfo("subjectAltName");if(void 0===s)return s;for(var a=new Array,c=o(this.hex,s.vidx),u=i(c,0),h=0;h<u.length;h++)r=c.substr(u[h],2),t=n(c,u[h]),"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 n={extname:"cRLDistributionPoints",array:[]};e&&(n.critical=!0);for(var s=i(t,0),a=0;a<s.length;a++){var c=o(t,s[a]);n.array.push(this.getDistributionPoint(c))}return n},this.getDistributionPoint=function(t){for(var e={},r=i(t,0),n=0;n<r.length;n++){var s=t.substr(r[n],2),a=o(t,r[n]);"a0"==s&&(e.dpname=this.getDistributionPointName(a))}return e},this.getDistributionPointName=function(t){for(var e={},r=i(t,0),n=0;n<r.length;n++){var s=t.substr(r[n],2),a=o(t,r[n]);"a0"==s&&(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),n=0;n<r.length;n++){var s=a(this.hex,r[n],[0],"06"),o=a(this.hex,r[n],[1],"86");"2b06010505073001"===s&&e.ocsp.push(mt(o)),"2b06010505073002"===s&&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 n={extname:"authorityInfoAccess",array:[]};e&&(n.critical=!0);for(var s=i(t,0),u=0;u<s.length;u++){var h=c(t,s[u],[0],"06"),l=mt(a(t,s[u],[1],"86"));if("2b06010505073001"==h)n.array.push({ocsp:l});else{if("2b06010505073002"!=h)throw new Error("unknown method: "+h);n.array.push({caissuer:l})}}return n},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 n={extname:"certificatePolicies",array:[]};e&&(n.critical=!0);for(var s=i(t,0),a=0;a<s.length;a++){var c=o(t,s[a]),u=this.getPolicyInformation(c);n.array.push(u)}return n},this.getPolicyInformation=function(t){var e={},r=a(t,0,[0],"06");e.policyoid=f(r);var n=p(t,0,[1],"30");if(-1!=n){e.array=[];for(var s=i(t,n),c=0;c<s.length;c++){var u=o(t,s[c]),h=this.getPolicyQualifierInfo(u);e.array.push(h)}}return e},this.getOtherName=function(t){var e={},r=i(t,0),n=a(t,r[0],[],"06"),o=a(t,r[1],[]);return e.oid=f(n),e.value=s(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=St(i)}else if("2b06010505070202"===r){var n=u(t,0,[1],"30");e.unotice=this.getUserNotice(n)}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 n=this._asn1ToNoticeRef(r[i]);null!=n&&(e.noticeref=n);var s=this.asn1ToDisplayText(r[i]);null!=s&&(e.exptext=s)}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 n=this._asn1ToNoticeNum(r[i]);null!=n&&(e.noticenum=n);var s=this.asn1ToDisplayText(r[i]);null!=s&&(e.org=s)}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 n=e[i];r.push(parseInt(jt(n,"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=St(n(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 n=s(t).seq,o=[],a=0;a<n.length;a++){var c=n[a].seq;o.push([c[0].oid,c[1].oid])}i.array=o}catch(t){throw new S("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 n=s(t);try{for(var o=n.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 S("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 n=g(t,0);return-1==n?new S("wrong value"):(i.skip=n,i)}},this.getExtCRLNumber=function(t,e){var r={extname:"cRLNumber"};if(e&&(r.critical=!0),"02"==t.substr(0,2))return r.num={hex:n(t,0)},r;throw new S("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(n(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=n(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 n={extname:"adobeTimeStamp"};e&&(n.critical=!0);var s=i(t,0);if(s.length>1){var a=o(t,s[1]),c=this.getGeneralName(a);null!=c.uri&&(n.uri=c.uri)}if(s.length>2){var u=o(t,s[2]);"0101ff"==u&&(n.reqauth=!0),"010100"==u&&(n.reqauth=!1)}return n},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 n=s(t),a=[],c=0;c<n.seq.length;c++){var u=n.seq[c],h=jt(u,"seq.0.oid"),l=jt(u,"seq.1.set");if(null==h||null==l)throw"error";a.push({attr:h,array:l})}return i.array=a,i}catch(t){throw new Error("malformed subjectDirectoryAttributes extension value")}};var v=function(t){var e={};try{var r=t.seq[0].oid,i=st.asn1.x509.OID.name2oid(r);e.type=st.asn1.x509.OID.oid2atype(i);var n=t.seq[1];if(null!=n.utf8str)e.ds="utf8",e.value=n.utf8str.str;else if(null!=n.numstr)e.ds="num",e.value=n.numstr.str;else if(null!=n.telstr)e.ds="tel",e.value=n.telstr.str;else if(null!=n.prnstr)e.ds="prn",e.value=n.prnstr.str;else if(null!=n.ia5str)e.ds="ia5",e.value=n.ia5str.str;else if(null!=n.visstr)e.ds="vis",e.value=n.visstr.str;else{if(null==n.bmpstr)throw"error";e.ds="bmp",e.value=n.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 v(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 n=t[i],s=0;s<n.length;s++)r.push(n[s]);for(i=0;i<r.length;i++){var o=r[i],a=o.ds,c=o.value,u=o.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=u)return"mixed";if(st.lang.String.isMail(c))continue;return"mixed"}if("C"==u){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=s(t);return v(e)},this.getRDN=function(t){var e=s(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)}}(s(t))},this.getX500Name=function(t,e,r){var i=this.getX500NameArray(t),n={str:this.dnarraytostr(i)};return n.array=i,1==r&&(n.hex=t),1==e&&(n.canon=this.c14nRDNArray(i)),n},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=u(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=h(this.hex,0,[0,"[3]",0],"30"));for(var e=[],r=i(t,0),n=0;n<r.length;n++){var s=o(t,r[n]),a=this.getExtParam(s);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")),n=!1;3==e&&"0101ff"==u(t,0,[1])&&(n=!0);var o=u(t,0,[e-1,0]),c=void 0;if("2.5.29.14"==r?c=this.getExtSubjectKeyIdentifier(o,n):"2.5.29.15"==r?c=this.getExtKeyUsage(o,n):"2.5.29.17"==r?c=this.getExtSubjectAltName(o,n):"2.5.29.18"==r?c=this.getExtIssuerAltName(o,n):"2.5.29.19"==r?c=this.getExtBasicConstraints(o,n):"2.5.29.30"==r?c=this.getExtNameConstraints(o,n):"2.5.29.31"==r?c=this.getExtCRLDistributionPoints(o,n):"2.5.29.32"==r?c=this.getExtCertificatePolicies(o,n):"2.5.29.33"==r?c=this.getExtPolicyMappings(o,n):"2.5.29.35"==r?c=this.getExtAuthorityKeyIdentifier(o,n):"2.5.29.36"==r?c=this.getExtPolicyConstraints(o,n):"2.5.29.37"==r?c=this.getExtExtKeyUsage(o,n):"2.5.29.54"==r?c=this.getExtInhibitAnyPolicy(o,n):"1.3.6.1.5.5.7.1.1"==r?c=this.getExtAuthorityInfoAccess(o,n):"2.5.29.20"==r?c=this.getExtCRLNumber(o,n):"2.5.29.21"==r?c=this.getExtCRLReason(o,n):"2.5.29.9"==r?c=this.getExtSubjectDirectoryAttributes(o,n):"1.3.6.1.5.5.7.48.1.2"==r?c=this.getExtOcspNonce(o,n):"1.3.6.1.5.5.7.48.1.5"==r?c=this.getExtOcspNoCheck(o,n):"1.2.840.113583.1.1.9.1"==r?c=this.getExtAdobeTimeStamp(o,n):null!=$t.EXT_PARSER[r]&&(c=$t.EXT_PARSER[r](r,n,o)),null!=c)return c;var h={extname:r,extn:o};try{h.extn=s(o)}catch(t){}return n&&(h.critical=!0),h},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,n=0;n<i.length;n++)if(null!=i[n].dpname&&null!=i[n].dpname.full)for(var s=i[n].dpname.full,o=0;o<s.length;o++){var a=s[n];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,n=0;n<i.length;n++)null!=i[n].ocsp&&(i[n].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var i=r.array,n=0;n<i.length;n++)null!=i[n].caissuer&&(i[n].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 st.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],n=[],s=0;s<i.length;s++){var o=i[s],a=o.value;a=(a=(a=(a=a.replace(/^\s*/,"")).replace(/\s*$/,"")).replace(/\s+/g," ")).toLowerCase(),n.push(o.type.toLowerCase()+"="+a)}e.push(n.join("+"))}return"/"+e.join("/")},this.getInfo=function(){var t,e,r,i=function(t){for(var e="",r=" ",i="\n",n=t.array,s=0;s<n.length;s++){var o=n[s];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$/,"")},n=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var n=r[i];if(e+=" policy oid: "+n.policyoid+"\n",void 0!==n.array)for(var s=0;s<n.array.length;s++){var o=n.array[s];void 0!==o.cps&&(e+=" cps: "+o.cps+"\n")}}return e},s=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var n=r[i];try{void 0!==n.dpname.full[0].uri&&(e+=" "+n.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==n.dname.full[0].dn.hex&&(e+=" "+$t.hex2dn(n.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 n=r[i];void 0!==n.caissuer&&(e+=" caissuer: "+n.caissuer+"\n"),void 0!==n.ocsp&&(e+=" ocsp: "+n.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],u=st.asn1.x509.OID.oid2name(c.oid);""===u&&(u=c.oid);var h="";if(!0===c.critical&&(h="CRITICAL"),t+=" "+u+" "+h+":\n","basicConstraints"===u){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"==u)t+=" "+this.getExtPolicyMappings().array.map(function(t){var e=t;return e[0]+":"+e[1]}).join(", ")+"\n";else if("policyConstraints"==u)t+=" ",null!=(p=this.getExtPolicyConstraints()).reqexp&&(t+=" reqexp="+p.reqexp),null!=p.inhibit&&(t+=" inhibit="+p.inhibit),t+="\n";else if("inhibitAnyPolicy"==u)t+=" skip="+(p=this.getExtInhibitAnyPolicy()).skip+"\n";else if("keyUsage"==u)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"==u)t+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"==u){var d=this.getExtAuthorityKeyIdentifier();void 0!==d.kid&&(t+=" kid="+d.kid.hex+"\n")}else"extKeyUsage"==u?t+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n":"subjectAltName"==u?t+=i(this.getExtSubjectAltName())+"\n":"cRLDistributionPoints"==u?t+=s(this.getExtCRLDistributionPoints()):"authorityInfoAccess"==u?t+=o(this.getExtAuthorityInfoAccess()):"certificatePolicies"==u&&(t+=n(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):st.lang.String.isHex(t)&&this.readCertHex(t))}Vt.getKey=function(t,e,r){var i,n=(y=ct).getChildIdx,s=(y.getV,y.getVbyList),o=st.crypto,a=o.ECDSA,c=o.DSA,u=tt,h=xt,l=Vt;if(void 0!==u&&t instanceof u)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(P=new u).setPublic(t.n,t.e),P;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(P=new u).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),P;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(P=new u).setPrivate(t.n,t.e,t.d),P;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(P=new c).setPublic(t.p,t.q,t.g,t.y),P;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(P=new c).setPrivate(t.p,t.q,t.g,t.y,t.x),P;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(P=new u).setPublic(gt(t.n),gt(t.e)),P;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(P=new u).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)),P;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(P=new u).setPrivate(gt(t.n),gt(t.e),gt(t.d)),P;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var p=(C=new a({curve:t.crv})).ecparams.keycharlen,d="04"+("0000000000"+gt(t.x)).slice(-p)+("0000000000"+gt(t.y)).slice(-p);return C.setPublicKeyHex(d),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){p=(C=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 C.setPublicKeyHex(d),C.setPrivateKeyHex(g),C}if("pkcs5prv"===r){var f,m=t,y=ct;if(9===(f=n(m,0)).length)(P=new u).readPKCS5PrvKeyHex(m);else if(6===f.length)(P=new c).readPKCS5PrvKeyHex(m);else{if(!(f.length>2&&"04"===m.substr(f[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(P=new a).readPKCS5PrvKeyHex(m)}return P}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 S=xt(t,"PUBLIC KEY");return l._getKeyFromPublicPKCS8Hex(S)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var v=h(t,"RSA PRIVATE KEY");return l.getKey(v,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var x=s(i=h(t,"DSA PRIVATE KEY"),0,[1],"02"),A=s(i,0,[2],"02"),w=s(i,0,[3],"02"),b=s(i,0,[4],"02"),T=s(i,0,[5],"02");return(P=new c).setPrivate(new E(x,16),new E(A,16),new E(w,16),new E(b,16),new E(T,16)),P}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED"))return v=h(t,"EC PRIVATE KEY"),l.getKey(v,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 C,P=s(i=l.getDecryptedKeyHex(t,e),0,[1],"04"),F=s(i,0,[2,0],"06"),N=s(i,0,[3,0],"03").substr(2);if(void 0===st.crypto.OID.oidhex2name[F])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+F);return(C=new a({curve:st.crypto.OID.oidhex2name[F]})).setPublicKeyHex(N),C.setPrivateKeyHex(P),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED"))return x=s(i=l.getDecryptedKeyHex(t,e),0,[1],"02"),A=s(i,0,[2],"02"),w=s(i,0,[3],"02"),b=s(i,0,[4],"02"),T=s(i,0,[5],"02"),(P=new c).setPrivate(new E(x,16),new E(A,16),new E(w,16),new E(b,16),new E(T,16)),P;if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return l.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},Vt.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,n=o.n.toString(16),s=o.e.toString(16);return i.setPublic(n,s),i.isPrivate=!1,i.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=i,a}if("EC"==t){var o,a,c=e,u=new st.crypto.ECDSA({curve:c}).generateKeyPairHex();return(o=new st.crypto.ECDSA({curve:c})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(i=new st.crypto.ECDSA({curve:c})).setPublicKeyHex(u.ecpubhex),i.isPrivate=!1,i.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=i,a}throw new Error("unknown algorithm: "+t)},Vt.getPEM=function(t,e,r,i,n,s){var o=st,a=o.asn1,c=a.DERObjectIdentifier,u=a.DERInteger,h=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,p=o.crypto,d=p.DSA,g=p.ECDSA,f=tt;function m(t){return h({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 h({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return h({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(A=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(A=m(t).tohex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===r||null==r)&&1==t.isPrivate){var v=new c({name:t.curveName}).tohex(),E=y(t).tohex(),x="";return(x+=Et(v,"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(A=S(t).tohex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==f&&t instanceof f&&void 0!==r&&null!=r&&1==t.isPrivate){var A=m(t).tohex();return void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",A,r,i,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==r&&null!=r&&1==t.isPrivate)return A=y(t).tohex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",A,r,i,s);if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==r&&null!=r&&1==t.isPrivate)return A=S(t).tohex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",A,r,i,s);var w=function(t,e){if("string"==typeof e)return Vt.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,Vt.getEncryptedPKCS8PEM(t,i,r)}};if("PKCS8PRV"==e&&null!=f&&t instanceof f&&1==t.isPrivate){var b=m(t).tohex();return A=h({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(A,"PRIVATE KEY"):w(A,r)}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){var T={seq:[{int:1},{octstr:{hex:t.prvKeyHex}}]};return"string"==typeof t.pubKeyHex&&T.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}),b=new h(T).tohex(),A=h({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(A,"PRIVATE KEY"):w(A,r)}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate)return b=new u({bigint:t.x}).tohex(),A=h({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(A,"PRIVATE KEY"):w(A,r);throw new Error("unsupported object nor format")},Vt.getKeyFromCSRPEM=function(t){var e=xt(t,"CERTIFICATE REQUEST");return Vt.getKeyFromCSRHex(e)},Vt.getKeyFromCSRHex=function(t){var e=Vt.parseCSRHex(t);return Vt.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Vt.parseCSRHex=function(t){var e=ct,r=e.getChildIdx,i=e.getTLV,n={},s=t;if("30"!=s.substr(0,2))throw new Error("malformed CSR(code:001)");var o=r(s,0);if(o.length<1)throw new Error("malformed CSR(code:002)");if("30"!=s.substr(o[0],2))throw new Error("malformed CSR(code:003)");var a=r(s,o[0]);if(a.length<3)throw new Error("malformed CSR(code:004)");return n.p8pubkeyhex=i(s,a[2]),n},Vt.getKeyID=function(t){var e=Vt,r=ct;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var i=xt(e.getPEM(t)),n=r.getIdxbyList(i,0,[1]),s=r.getV(i,n).substring(2);return st.crypto.Util.hashHex(s,"sha1")},Vt.getJWK=function(t,e,r,i,n){var s,o,a={},c=st.crypto.Util.hashHex;if("string"==typeof t)s=Vt.getKey(t),-1!=t.indexOf("CERTIFICATE")&&(o=xt(t));else{if("object"!=typeof t)throw new Error("unsupported keyinfo type");t instanceof $t?(s=t.getPublicKey(),o=t.hex):s=t}if(s instanceof tt&&s.isPrivate)a.kty="RSA",a.n=dt(s.n.toString(16)),a.e=dt(s.e.toString(16)),a.d=dt(s.d.toString(16)),a.p=dt(s.p.toString(16)),a.q=dt(s.q.toString(16)),a.dp=dt(s.dmp1.toString(16)),a.dq=dt(s.dmq1.toString(16)),a.qi=dt(s.coeff.toString(16));else if(s instanceof tt&&s.isPublic)a.kty="RSA",a.n=dt(s.n.toString(16)),a.e=dt(s.e.toString(16));else if(s instanceof st.crypto.ECDSA&&s.isPrivate){if("P-256"!==(h=s.getShortNISTPCurveName())&&"P-384"!==h&&"P-521"!==h)throw new Error("unsupported curve name for JWT: "+h);var u=s.getPublicKeyXYHex();a.kty="EC",a.crv=h,a.x=dt(u.x),a.y=dt(u.y),a.d=dt(s.prvKeyHex)}else if(s instanceof st.crypto.ECDSA&&s.isPublic){var h;if("P-256"!==(h=s.getShortNISTPCurveName())&&"P-384"!==h&&"P-521"!==h)throw new Error("unsupported curve name for JWT: "+h);u=s.getPublicKeyXYHex(),a.kty="EC",a.crv=h,a.x=dt(u.x),a.y=dt(u.y)}if(null==a.kty)throw new Error("unsupported keyinfo");return s.isPrivate||1==e||(a.kid=st.jws.JWS.getJWKthumbprint(a)),null!=o&&1!=r&&(a.x5c=[S(o)]),null!=o&&1!=i&&(a.x5t=lt(S(c(o,"sha1")))),null!=o&&1!=n&&(a["x5t#S256"]=lt(S(c(o,"sha256")))),a},Vt.getJWKFromKey=function(t){return Vt.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]),n=r(t,e[1]),s=r(t,e[2]),o=r(t,e[3]),a=r(t,e[4]),c=r(t,e[5]),u=r(t,e[6]),h=r(t,e[7]),l=r(t,e[8]);return(e=new Array).push(i,n,s,o,a,c,u,h,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,n,s,o,a,c,u=ct,h=u.getVbyListEx;if(!1===u.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=h(t,0,[2,0,1],"02"),r=h(t,0,[2,0,2],"02"),i=h(t,0,[2,0,3],"02"),n=h(t,0,[2,0,4],"02"),s=h(t,0,[2,0,5],"02"),o=h(t,0,[2,0,6],"02"),a=h(t,0,[2,0,7],"02"),c=h(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,i,n,s,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 n=r(t,i[0]),s=r(t,i[1]);this.setPublic(n,s)},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 st.crypto.Util.hashString(t,e)}(t);return this.signWithMessageHash(r,e)},tt.prototype.signWithMessageHash=function(t,e){var r=Z(st.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,n=(i=vt(t),st.crypto.Util.hashHex(i,e));return void 0===r&&(r=-1),this.signWithMessageHashPSS(n,e,r)},tt.prototype.signWithMessageHashPSS=function(t,e,r){var i,n=St(t),s=n.length,o=this.n.bitLength()-1,a=Math.ceil(o/8),c=function(t){return st.crypto.Util.hashHex(t,e)};if(-1===r||void 0===r)r=s;else if(-2===r)r=a-s-2;else if(r<-2)throw new Error("invalid salt length");if(a<s+r+2)throw new Error("data too long");var u="";r>0&&(u=new Array(r),(new Q).nextBytes(u),u=String.fromCharCode.apply(String,u));var h=St(c(vt("\0\0\0\0\0\0\0\0"+n+u))),l=[];for(i=0;i<a-r-s-2;i+=1)l[i]=0;var p=String.fromCharCode.apply(String,l)+""+u,d=Gt(h,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<s;i++)g.push(h.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 n=this.doPublic(r).toString(16);if(n.length+3!=i/4)return!1;var s=qt(n.replace(/^1f+00/,""));if(0==s.length)return!1;var o=s[0],a=s[1],c=function(t){return st.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=qt(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 n,s=(n=vt(t),st.crypto.Util.hashHex(n,r));return void 0===i&&(i=-1),this.verifyWithMessageHashPSS(s,e,r,i)},tt.prototype.verifyWithMessageHashPSS=function(t,e,r,i){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var n,s=new E(e,16),o=function(t){return st.crypto.Util.hashHex(t,r)},a=St(t),c=a.length,u=this.n.bitLength()-1,h=Math.ceil(u/8);if(-1===i||void 0===i)i=c;else if(-2===i)i=h-c-2;else if(i<-2)throw new Error("invalid salt length");if(h<c+i+2)throw new Error("data too long");var l=this.doPublic(s).toByteArray();for(n=0;n<l.length;n+=1)l[n]&=255;for(;l.length<h;)l.unshift(0);if(188!==l[h-1])throw new Error("encoded message does not end in 0xbc");var p=(l=String.fromCharCode.apply(String,l)).substr(0,h-c-1),d=l.substr(p.length,c),g=65280>>8*h-u&255;if(0!==(p.charCodeAt(0)&g))throw new Error("bits beyond keysize not zero");var f=Gt(d,p.length,o),m=[];for(n=0;n<p.length;n+=1)m[n]=p.charCodeAt(n)^f.charCodeAt(n);m[0]&=~g;var y=h-c-i-2;for(n=0;n<y;n+=1)if(0!==m[n])throw new Error("leftmost octets not zero");if(1!==m[y])throw new Error("0x01 marker not found");return d===St(o(vt("\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),n=0;n<i.length;n++)r.push($t.hex2attrTypeValue(t,i[n]));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 n=r.getChildIdx(t,e);2!==n.length||t.substr(n[0],2);var s=i(t,n[0]),o=st.asn1.ASN1Util.oidHexToInt(s);return st.asn1.x509.OID.oid2atype(o)+"="+St(i(t,n[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,n={algparam:null};return(e=new $t).readCertPEM(t),r=e.getPublicKeyHex(),n.keyhex=i(r,0,[1],"03").substr(2),n.algoid=i(r,0,[0,0],"06"),"2a8648ce3d0201"===n.algoid&&(n.algparam=i(r,0,[0,1],"06")),n},$t.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],void 0!==st&&st||(st={}),void 0!==st.jws&&st.jws||(st.jws={}),st.jws.JWS=function(){var t=st.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 n=i[1],s=i[2],o=i[3],a=n+"."+s;if(this.parsedJWS={},this.parsedJWS.headB64U=n,this.parsedJWS.payloadB64U=s,this.parsedJWS.sigvalB64U=o,this.parsedJWS.si=a,!r){var c=gt(o),u=Z(c,16);this.parsedJWS.sigvalH=c,this.parsedJWS.sigvalBI=u}var h=at(n),l=at(s);if(this.parsedJWS.headS=h,this.parsedJWS.payloadS=l,!t(h,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+h}}},st.jws.JWS.sign=function(t,e,r,i,n){var s,o,a,c=st,u=c.jws.JWS,h=u.readSafeJSONString,l=u.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,s=f.stringify(o)),"string"==typeof e){if(!l(s=e))throw"JWS Head is not safe JSON string: "+s;o=h(s)}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,s=f.stringify(o)),t!==o.alg)throw"alg and sHeader.alg doesn't match: "+t+"!="+o.alg;var m=null;if(void 0===u.jwsalg2sigalg[t])throw"unsupported alg name: "+t;m=u.jwsalg2sigalg[t];var y=ot(s)+"."+ot(a),S="";if("Hmac"==m.substr(0,4)){if(void 0===i)throw"mac key shall be specified for HS* alg";var v=new d({alg:m,prov:"cryptojs",pass:i});v.updateString(y),S=v.doFinal()}else if(-1!=m.indexOf("withECDSA")){(x=new g({alg:m})).init(i,n),x.updateString(y);var E=x.sign();S=st.crypto.ECDSA.asn1SigToConcatSig(E)}else{var x;"none"!=m&&((x=new g({alg:m})).init(i,n),x.updateString(y),S=x.sign())}return y+"."+dt(S)},st.jws.JWS.verify=function(t,e,r){var i,n=st,s=n.jws.JWS,o=s.readSafeJSONString,a=n.crypto,c=a.ECDSA,u=a.Mac,h=a.Signature;if(i=tt,!Dt(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=Vt.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===s.jwsalg2sigalg[f.alg])throw"unsupported alg name: "+m;if("none"==(y=s.jwsalg2sigalg[m]))throw"not supported";if("Hmac"==y.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var S=new u({alg:y,pass:e});return S.updateString(d),g==S.doFinal()}if(-1!=y.indexOf("withECDSA")){var v,E=null;try{E=c.concatSigToASN1Sig(g)}catch(t){return!1}return(v=new h({alg:y})).init(e),v.updateString(d),v.verify(E)}return(v=new h({alg:y})).init(e),v.updateString(d),v.verify(g)},st.jws.JWS.parse=function(t){var e,r,i,n=t.split("."),s={};if(2!=n.length&&3!=n.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=n[0],r=n[1],3==n.length&&(i=n[2]),s.headerObj=st.jws.JWS.readSafeJSONString(at(e)),s.payloadObj=st.jws.JWS.readSafeJSONString(at(r)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=at(r):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==i&&(s.sigHex=gt(i)),s},st.jws.JWS.verifyJWT=function(t,e,r){var i=st.jws,n=i.JWS,s=n.readSafeJSONString,o=n.inArray,a=n.includedArray;if(!Dt(t))return!1;var c=t.split(".");if(3!=c.length)return!1;var u=c[0],h=c[1],l=(gt(c[2]),s(at(u))),p=s(at(h));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||!n.verify(t,e,r.alg))},st.jws.JWS.includedArray=function(t,e){var r=st.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},st.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},st.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"},st.jws.JWS.isSafeJSONString=function(t,e,r){var i=null;try{return"object"!=typeof(i=nt(t))||i.constructor===Array?0:(e&&(e[r]=i),1)}catch(t){return 0}},st.jws.JWS.readSafeJSONString=function(t){var e=null;try{return"object"!=typeof(e=nt(t))||e.constructor===Array?null:e}catch(t){return null}},st.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]},st.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=vt(e);return dt(st.crypto.Util.hashHex(r,"sha256"))},st.jws.IntDate={},st.jws.IntDate.get=function(t){var e=st.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},st.jws.IntDate.getZulu=function(t){return function(t){return Math.round(function(t){var e,r,i,n,s,o,a,c,u,h;if(h=(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(h[1]),r=parseInt(h[2])-1,i=parseInt(h[3]),n=parseInt(h[4]),s=parseInt(h[5]),o=parseInt(h[6]),a=0,""!==(c=h[7])&&(u=(c.substr(1)+"00").substr(0,3),a=parseInt(u)),Date.UTC(e,r,i,n,s,o,a);throw new Error("unsupported zulu format: "+t)}(t)/1e3)}(t)},st.jws.IntDate.getNow=function(){return~~(new Date/1e3)},st.jws.IntDate.intDate2UTCString=function(t){return new Date(1e3*t).toUTCString()},st.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!==st&&st||(st={}),void 0!==st.jws&&st.jws||(st.jws={}),st.jws.JWSJS=function(){var t=st.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 n=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var s=st.jws.JWS.sign(t,e,this.sPayload,r,i).split(".");s[0],s[2],this.aHeader.push(s[0]),this.aSignature.push(s[2])}catch(t){throw this.aHeader.length>n&&this.aHeader.pop(),this.aSignature.length>n&&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 n=this.aHeader[e],s=this.aSignature[e],o=n+"."+this.sPayload+"."+s,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}},st.crypto.ECDSA,st.crypto.DSA,st.crypto.Signature,st.crypto.MessageDigest,st.crypto.Mac,e.ym=Vt,e.wV=dt,e.cV=at,e.pj=st,st.crypto,st.asn1,st.jws,st.lang}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var s=e[i]={exports:{}};return t[i](s,s.exports,r),s.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 n{theme="default";themeMode=i.light;constructor(t){t&&(this.theme=t.theme??this.theme,this.themeMode=t.themeMode??this.themeMode,this.jsonLdExportSettings=t.jsonLdExportSettings??this.jsonLdExportSettings)}isSystemMode(){return this.themeMode===i.system}toString(){return JSON.stringify(this)}}const s=t=>t.location?`${t.id}@${t.location}`:t.id;class o{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(!o.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)||!o.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(o.hasCopyMethod(t))return t.copy();const e=o.copyBuiltInType(t);return null!==e?e:o.copyPlainObject(t)}static copyBuiltInType(t){return Array.isArray(t)?t.map(t=>o.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])=>[o.deepCopy(t),o.deepCopy(e)])):t instanceof Set?new Set(Array.from(t.values()).map(t=>o.deepCopy(t))):null}static copyPlainObject(t){const e=Object.create(Object.getPrototypeOf(t));for(const r of Object.keys(t))e[r]=o.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=o.deepCopy(t);return Object.keys(e).forEach(t=>{const i=r[t],n=e[t];o.isNullOrUndefined(i)?r[t]=o.deepCopy(n):o.canRecursivelyMerge(i,n)&&(r[t]=o.mergeWithDefaults(i,n))}),r}static canRecursivelyMerge(t,e){return"object"==typeof t&&null!==t&&"object"==typeof e&&null!==e&&!Array.isArray(t)&&!Array.isArray(e)}}const a={BYTES:1,KB:1024,MB:1048576,GB:1024**3,TB:1024**4,PB:1024**5},c=/^(\d+(?:\.\d+)?)\s*(bytes|KB|MB|GB|TB|PB)$/i,u=/^\d+$/;class h{static convertToBytes(t){if(null==t)return 0;if("number"==typeof t)return t;if(t=t.trim(),u.test(t))return Number.parseInt(t,10);const e=c.exec(t);if(!e)return 0;const r=Number.parseFloat(e[1]),i=e[2];return r*a[i.toUpperCase()]}static convertToHumanReadable(t){if(!t)return"0 bytes";if("string"==typeof t&&(t=t.trim()),c.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(a).reverse();for(const r of e){const e=a[r];if(t>=e){const i=t/e;return`${Number.isInteger(i)?i:i.toFixed(2)} ${"BYTES"===r?"bytes":r}`}}return"0 bytes"}}class l{static getWindow(){return window}static getParentWindow(){return l.getWindow().parent}static getReferer(){let t="*";if(l.getDocument().referrer)try{const e=new URL(l.getDocument().referrer);e.origin&&(t=e.origin)}catch(t){console.warn(`Failed to parse document.referrer: ${l.getDocument().referrer}. Using default targetOrigin '*'`,t)}return t}static getDocument(){return l.getWindow().document}static getPluginRegistry(){return l.getWindow().PluginRegistry}static setPluginRegistry(t){this.getWindow().PluginRegistry=t}static getCrypto(){return l.getWindow().crypto}static reloadPage(){l.getWindow().location.reload()}static getLocationHref(){return l.getWindow().location.href}static setLocationHref(t){l.getWindow().location.href=t}static getLocationQueryParams(){return l.getWindow().location.search}static getLocationHash(){return l.getWindow().location.hash}static matchMedia(t){return l.getWindow().matchMedia(t)}static getLocationPathname(){return l.getWindow().location.pathname}static getLocationOrigin(){return l.getWindow().location.origin}static getBaseHref(){return l.getDocument().querySelector("base")?.getAttribute("href")??"/"}static openWindow(t,e,r){l.getWindow().open(t,e,r)}static navigateSingleSpa(t){l.getWindow().singleSpa.navigateToUrl(t)}}class p{static isDevMode(){return l.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=p.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 g{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 f(t){return e=>{e?.preventDefault&&e.preventDefault(),m(t)}}function m(t){let e=t;e.startsWith(".")&&(e=e.slice(1)),e.startsWith("/")&&!e.startsWith(A())&&(e=A().slice(0,-1)+e),l.navigateSingleSpa(e)}function y(t){l.openWindow(t,"_blank","noopener,noreferrer")}function S(){return"/"===E()}function v(){return"/login"===E()}function E(){return l.getLocationPathname().substring(A().length-1)}function x(){return`${l.getLocationOrigin()}${A()}`}function A(){return l.getBaseHref()}function b(){return E().substring(1)}function w(){return E()+l.getLocationQueryParams()}function I(t,e){if(Object.values(t).includes(e))return e;throw new Error(`Invalid enum value '${e}' for enum ${JSON.stringify(t)}`)}class T{static now(){return Date.now()}static formatDuration(t){if(!t||t<=0)return"-";const e=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);let n="";return e&&(n+=e+"d "),(e||r)&&(n+=r+"h "),(e||r||i)&&(n+=i+"m "),n+=Math.round(t%60)+"s",n.replace(/( 0[a-z])+$/,"")}}function R(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function C(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var i,n,s,o,a=[],c=!0,u=!1;try{if(s=(r=r.call(t)).next,0===e);else for(;!(c=(i=s.call(r)).done)&&(a.push(i.value),a.length!==e);c=!0);}catch(t){u=!0,n=t}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw n}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return R(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?R(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const P=Object.entries,F=Object.setPrototypeOf,N=Object.isFrozen,D=Object.getPrototypeOf,O=Object.getOwnPropertyDescriptor;let _=Object.freeze,L=Object.seal,B=Object.create,k="undefined"!=typeof Reflect&&Reflect,H=k.apply,U=k.construct;_||(_=function(t){return t}),L||(L=function(t){return t}),H||(H=function(t,e){for(var r=arguments.length,i=new Array(r>2?r-2:0),n=2;n<r;n++)i[n-2]=arguments[n];return t.apply(e,i)}),U||(U=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return new t(...r)});const M=at(Array.prototype.forEach),j=at(Array.prototype.lastIndexOf),V=at(Array.prototype.pop),K=at(Array.prototype.push),G=at(Array.prototype.splice),q=Array.isArray,$=at(String.prototype.toLowerCase),W=at(String.prototype.toString),z=at(String.prototype.match),Y=at(String.prototype.replace),X=at(String.prototype.indexOf),J=at(String.prototype.trim),Q=at(Number.prototype.toString),Z=at(Boolean.prototype.toString),tt="undefined"==typeof BigInt?null:at(BigInt.prototype.toString),et="undefined"==typeof Symbol?null:at(Symbol.prototype.toString),rt=at(Object.prototype.hasOwnProperty),it=at(Object.prototype.toString),nt=at(RegExp.prototype.test),st=(ot=TypeError,function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return U(ot,e)});var ot;function at(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];return H(t,e,i)}}function ct(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$;if(F&&F(t,null),!q(e))return t;let i=e.length;for(;i--;){let n=e[i];if("string"==typeof n){const t=r(n);t!==n&&(N(e)||(e[i]=t),n=t)}t[n]=!0}return t}function ut(t){for(let e=0;e<t.length;e++)rt(t,e)||(t[e]=null);return t}function ht(t){const e=B(null);for(const i of P(t)){var r=C(i,2);const n=r[0],s=r[1];rt(t,n)&&(q(s)?e[n]=ut(s):s&&"object"==typeof s&&s.constructor===Object?e[n]=ht(s):e[n]=s)}return e}function lt(t,e){for(;null!==t;){const r=O(t,e);if(r){if(r.get)return at(r.get);if("function"==typeof r.value)return at(r.value)}t=D(t)}return function(){return null}}const pt=_(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),dt=_(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),gt=_(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ft=_(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),mt=_(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),yt=_(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),St=_(["#text"]),vt=_(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Et=_(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),xt=_(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),At=_(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),bt=L(/{{[\w\W]*|^[\w\W]*}}/g),wt=L(/<%[\w\W]*|^[\w\W]*%>/g),It=L(/\${[\w\W]*/g),Tt=L(/^data-[\-\w.\u00B7-\uFFFF]+$/),Rt=L(/^aria-[\-\w]+$/),Ct=L(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Pt=L(/^(?:\w+script|data):/i),Ft=L(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Nt=L(/^html$/i),Dt=L(/^[a-z][.\w]*(-[.\w]+)+$/i),Ot=L(/<[/\w!]/g),_t=L(/<[/\w]/g),Lt=L(/<\/no(script|embed|frames)/i),Bt=L(/\/>/i),kt=function(){return"undefined"==typeof window?null:window},Ht=function(t,e,r,i){return rt(t,e)&&q(t[e])?ct(i.base?ht(i.base):{},t[e],i.transform):r};var Ut=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:kt();const r=e=>t(e);if(r.version="3.4.12",r.removed=[],!e||!e.document||9!==e.document.nodeType||!e.Element)return r.isSupported=!1,r;let i=e.document;const n=i,s=n.currentScript;e.DocumentFragment;const o=e.HTMLTemplateElement,a=e.Node,c=e.Element,u=e.NodeFilter;void 0===e.NamedNodeMap&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const h=e.DOMParser,l=e.trustedTypes,p=c.prototype,d=lt(p,"cloneNode"),g=lt(p,"remove"),f=lt(p,"nextSibling"),m=lt(p,"childNodes"),y=lt(p,"parentNode"),S=lt(p,"shadowRoot"),v=lt(p,"attributes"),E=a&&a.prototype?lt(a.prototype,"nodeType"):null,x=a&&a.prototype?lt(a.prototype,"nodeName"):null;if("function"==typeof o){const t=i.createElement("template");t.content&&t.content.ownerDocument&&(i=t.content.ownerDocument)}let A,w,b="",T=!1,I=0;const R=function(){if(I>0)throw st('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},C=function(t){R(),I++;try{return A.createHTML(t)}finally{I--}},F=i,N=F.implementation,O=F.createNodeIterator,D=F.createDocumentFragment,H=F.getElementsByTagName,k=n.importNode;let U={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};r.isSupported="function"==typeof P&&"function"==typeof y&&N&&void 0!==N.createHTMLDocument;const ot=bt,at=wt,ut=It,Ut=Tt,jt=Rt,Mt=Pt,Vt=Ft,Kt=Dt;let Gt=Ct,qt=null;const $t=ct({},[...pt,...dt,...gt,...mt,...St]);let Wt=null;const zt=ct({},[...vt,...Et,...xt,...At]);let Yt=Object.seal(B(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Xt=null,Jt=null;const Qt=Object.seal(B(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Zt=!0,te=!0,ee=!1,re=!0,ie=!1,ne=!0,se=!1,oe=!1,ae=null,ce=null,ue=!1,he=!1,le=!1,pe=!1,de=!0,ge=!1;const fe="user-content-";let me=!0,ye=!1,Se={},ve=null;const Ee=ct({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let xe=null;const Ae=ct({},["audio","video","img","source","image","track"]);let we=null;const be=ct({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Te="http://www.w3.org/1998/Math/MathML",Ie="http://www.w3.org/2000/svg",Re="http://www.w3.org/1999/xhtml";let Ce=Re,Pe=!1,Fe=null;const Ne=ct({},[Te,Ie,Re],W),Oe=_(["mi","mo","mn","ms","mtext"]);let De=ct({},Oe);const _e=_(["annotation-xml"]);let Le=ct({},_e);const Be=ct({},["title","style","font","a","script"]);let He=null;const ke=["application/xhtml+xml","text/html"];let Ue=null,je=null;const Me=i.createElement("form"),Ve=function(t){return t instanceof RegExp||t instanceof Function},Ke=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(je&&je===t)return;t&&"object"==typeof t||(t={}),t=ht(t),He=-1===ke.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,Ue="application/xhtml+xml"===He?W:$,qt=Ht(t,"ALLOWED_TAGS",$t,{transform:Ue}),Wt=Ht(t,"ALLOWED_ATTR",zt,{transform:Ue}),Fe=Ht(t,"ALLOWED_NAMESPACES",Ne,{transform:W}),we=Ht(t,"ADD_URI_SAFE_ATTR",be,{transform:Ue,base:be}),xe=Ht(t,"ADD_DATA_URI_TAGS",Ae,{transform:Ue,base:Ae}),ve=Ht(t,"FORBID_CONTENTS",Ee,{transform:Ue}),Xt=Ht(t,"FORBID_TAGS",ht({}),{transform:Ue}),Jt=Ht(t,"FORBID_ATTR",ht({}),{transform:Ue}),Se=!!rt(t,"USE_PROFILES")&&(t.USE_PROFILES&&"object"==typeof t.USE_PROFILES?ht(t.USE_PROFILES):t.USE_PROFILES),Zt=!1!==t.ALLOW_ARIA_ATTR,te=!1!==t.ALLOW_DATA_ATTR,ee=t.ALLOW_UNKNOWN_PROTOCOLS||!1,re=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,ie=t.SAFE_FOR_TEMPLATES||!1,ne=!1!==t.SAFE_FOR_XML,se=t.WHOLE_DOCUMENT||!1,he=t.RETURN_DOM||!1,le=t.RETURN_DOM_FRAGMENT||!1,pe=t.RETURN_TRUSTED_TYPE||!1,ue=t.FORCE_BODY||!1,de=!1!==t.SANITIZE_DOM,ge=t.SANITIZE_NAMED_PROPS||!1,me=!1!==t.KEEP_CONTENT,ye=t.IN_PLACE||!1,Gt=function(t){try{return nt(t,""),!0}catch(t){return!1}}(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:Ct,Ce="string"==typeof t.NAMESPACE?t.NAMESPACE:Re,De=rt(t,"MATHML_TEXT_INTEGRATION_POINTS")&&t.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof t.MATHML_TEXT_INTEGRATION_POINTS?ht(t.MATHML_TEXT_INTEGRATION_POINTS):ct({},Oe),Le=rt(t,"HTML_INTEGRATION_POINTS")&&t.HTML_INTEGRATION_POINTS&&"object"==typeof t.HTML_INTEGRATION_POINTS?ht(t.HTML_INTEGRATION_POINTS):ct({},_e);const e=rt(t,"CUSTOM_ELEMENT_HANDLING")&&t.CUSTOM_ELEMENT_HANDLING&&"object"==typeof t.CUSTOM_ELEMENT_HANDLING?ht(t.CUSTOM_ELEMENT_HANDLING):B(null);if(Yt=B(null),rt(e,"tagNameCheck")&&Ve(e.tagNameCheck)&&(Yt.tagNameCheck=e.tagNameCheck),rt(e,"attributeNameCheck")&&Ve(e.attributeNameCheck)&&(Yt.attributeNameCheck=e.attributeNameCheck),rt(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(Yt.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),L(Yt),ie&&(te=!1),le&&(he=!0),Se&&(qt=ct({},St),Wt=B(null),!0===Se.html&&(ct(qt,pt),ct(Wt,vt)),!0===Se.svg&&(ct(qt,dt),ct(Wt,Et),ct(Wt,At)),!0===Se.svgFilters&&(ct(qt,gt),ct(Wt,Et),ct(Wt,At)),!0===Se.mathMl&&(ct(qt,mt),ct(Wt,xt),ct(Wt,At))),Qt.tagCheck=null,Qt.attributeCheck=null,rt(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?Qt.tagCheck=t.ADD_TAGS:q(t.ADD_TAGS)&&(qt===$t&&(qt=ht(qt)),ct(qt,t.ADD_TAGS,Ue))),rt(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?Qt.attributeCheck=t.ADD_ATTR:q(t.ADD_ATTR)&&(Wt===zt&&(Wt=ht(Wt)),ct(Wt,t.ADD_ATTR,Ue))),rt(t,"ADD_URI_SAFE_ATTR")&&q(t.ADD_URI_SAFE_ATTR)&&ct(we,t.ADD_URI_SAFE_ATTR,Ue),rt(t,"FORBID_CONTENTS")&&q(t.FORBID_CONTENTS)&&(ve===Ee&&(ve=ht(ve)),ct(ve,t.FORBID_CONTENTS,Ue)),rt(t,"ADD_FORBID_CONTENTS")&&q(t.ADD_FORBID_CONTENTS)&&(ve===Ee&&(ve=ht(ve)),ct(ve,t.ADD_FORBID_CONTENTS,Ue)),me&&(qt["#text"]=!0),se&&ct(qt,["html","head","body"]),qt.table&&(ct(qt,["tbody"]),delete Xt.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw st('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw st('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const e=A;A=t.TRUSTED_TYPES_POLICY;try{b=C("")}catch(t){throw A=e,t}}else null===t.TRUSTED_TYPES_POLICY?(A=void 0,b=""):(void 0===A&&(T||(w=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let r=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(r=e.getAttribute(i));const n="dompurify"+(r?"#"+r:"");try{return t.createPolicy(n,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+n+" could not be created."),null}}(l,s),T=!0),A=w),A&&"string"==typeof b&&(b=C("")));_&&_(t),je=t},Ge=ct({},[...dt,...gt,...ft]),qe=ct({},[...mt,...yt]),$e=function(t){K(r.removed,{element:t});try{y(t).removeChild(t)}catch(e){if(g(t),!y(t))throw st("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},We=function(t){Xe(t);const e=m(t);if(e){const t=[];M(e,e=>{K(t,e)}),M(t,t=>{try{g(t)}catch(t){}})}const r=v(t);if(r)for(let e=r.length-1;e>=0;--e){const i=r[e],n=i&&i.name;if("string"==typeof n)try{t.removeAttribute(n)}catch(t){}}},ze=function(t,e){try{K(r.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){K(r.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(he||le)try{$e(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Ye=function(t){const e=v(t);if(e)for(let r=e.length-1;r>=0;--r){const i=e[r],n=i&&i.name;if("string"==typeof n&&!Wt[Ue(n)])try{t.removeAttribute(n)}catch(t){}}},Xe=function(t){const e=[t];for(;e.length>0;){const t=e.pop();1===(E?E(t):t.nodeType)&&Ye(t);const r=m(t);if(r)for(let t=r.length-1;t>=0;--t)e.push(r[t])}},Je=function(t){let e=null,r=null;if(ue)t="<remove></remove>"+t;else{const e=z(t,/^[\r\n\t ]+/);r=e&&e[0]}"application/xhtml+xml"===He&&Ce===Re&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const n=A?C(t):t;if(Ce===Re)try{e=(new h).parseFromString(n,He)}catch(t){}if(!e||!e.documentElement){e=N.createDocument(Ce,"template",null);try{e.documentElement.innerHTML=Pe?b:n}catch(t){}}const s=e.body||e.documentElement;return t&&r&&s.insertBefore(i.createTextNode(r),s.childNodes[0]||null),Ce===Re?H.call(e,se?"html":"body")[0]:se?e.documentElement:s},Qe=function(t){return O.call(t.ownerDocument||t,t,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ze=function(t){return t=Y(t,ot," "),t=Y(t,at," "),Y(t,ut," ")},tr=function(t){var e;t.normalize();const r=O.call(t.ownerDocument||t,t,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let i=r.nextNode();for(;i;)i.data=Ze(i.data),i=r.nextNode();const n=null===(e=t.querySelectorAll)||void 0===e?void 0:e.call(t,"template");n&&M(n,t=>{rr(t.content)&&tr(t.content)})},er=function(t){const e=x?x(t):null;return"string"==typeof e&&"form"===Ue(e)&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||t.attributes!==v(t)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes||t.nodeType!==E(t)||t.childNodes!==m(t))},rr=function(t){if(!E||"object"!=typeof t||null===t)return!1;try{return 11===E(t)}catch(t){return!1}},ir=function(t){if(!E||"object"!=typeof t||null===t)return!1;try{return"number"==typeof E(t)}catch(t){return!1}};function nr(t,e,i){0!==t.length&&M(t,t=>{t.call(r,e,i,je)})}const sr=function(t,e){if(nr(U.beforeSanitizeElements,t,null),t!==e&&null===y(t))return!0;if(er(t))return $e(t),!0;const i=Ue(x?x(t):t.nodeName);if(nr(U.uponSanitizeElement,t,{tagName:i,allowedTags:qt}),t!==e&&null===y(t))return!0;if(function(t,e){return!!(ne&&t.hasChildNodes()&&!ir(t.firstElementChild)&&nt(Ot,t.textContent)&&nt(Ot,t.innerHTML))||!(!ne||t.namespaceURI!==Re||"style"!==e||!ir(t.firstElementChild))||7===t.nodeType||!(!ne||8!==t.nodeType||!nt(_t,t.data))}(t,i))return $e(t),!0;if(Xt[i]||!(Qt.tagCheck instanceof Function&&Qt.tagCheck(i))&&!qt[i]){const e=function(t,e){if(!Xt[e]&&cr(e)){if(Yt.tagNameCheck instanceof RegExp&&nt(Yt.tagNameCheck,e))return!1;if(Yt.tagNameCheck instanceof Function&&Yt.tagNameCheck(e))return!1}if(me&&!ve[e]){const e=y(t),r=m(t);if(r&&e)for(let i=r.length-1;i>=0;--i){const n=ye?r[i]:d(r[i],!0);e.insertBefore(n,f(t))}}return $e(t),!0}(t,i);return!1===e&&nr(U.afterSanitizeElements,t,null),e}if(1===(E?E(t):t.nodeType)&&!function(t){let e=y(t);e&&e.tagName||(e={namespaceURI:Ce,tagName:"template"});const r=$(t.tagName),i=$(e.tagName);return!!Fe[t.namespaceURI]&&(t.namespaceURI===Ie?function(t,e,r){return e.namespaceURI===Re?"svg"===t:e.namespaceURI===Te?"svg"===t&&("annotation-xml"===r||De[r]):Boolean(Ge[t])}(r,e,i):t.namespaceURI===Te?function(t,e,r){return e.namespaceURI===Re?"math"===t:e.namespaceURI===Ie?"math"===t&&Le[r]:Boolean(qe[t])}(r,e,i):t.namespaceURI===Re?function(t,e,r){return!(e.namespaceURI===Ie&&!Le[r])&&!(e.namespaceURI===Te&&!De[r])&&!qe[t]&&(Be[t]||!Ge[t])}(r,e,i):!("application/xhtml+xml"!==He||!Fe[t.namespaceURI]))}(t))return $e(t),!0;if(("noscript"===i||"noembed"===i||"noframes"===i)&&nt(Lt,t.innerHTML))return $e(t),!0;if(ie&&3===t.nodeType){const e=Ze(t.textContent);t.textContent!==e&&(K(r.removed,{element:t.cloneNode()}),t.textContent=e)}return nr(U.afterSanitizeElements,t,null),!1},or=function(t,e,r){if(Jt[e])return!1;if(ne&&"patchsrc"===e)return!1;if(ne&&"for"===e&&"label"!==t&&"output"!==t)return!1;if(de&&("id"===e||"name"===e)&&(r in i||r in Me))return!1;const n=Wt[e]||Qt.attributeCheck instanceof Function&&Qt.attributeCheck(e,t);if(te&&nt(Ut,e));else if(Zt&&nt(jt,e));else if(n){if(we[e]);else if(nt(Gt,Y(r,Vt,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==X(r,"data:")||!xe[t])if(ee&&!nt(Mt,Y(r,Vt,"")));else if(r)return!1}else if(!(cr(t)&&(Yt.tagNameCheck instanceof RegExp&&nt(Yt.tagNameCheck,t)||Yt.tagNameCheck instanceof Function&&Yt.tagNameCheck(t))&&(Yt.attributeNameCheck instanceof RegExp&&nt(Yt.attributeNameCheck,e)||Yt.attributeNameCheck instanceof Function&&Yt.attributeNameCheck(e,t))||"is"===e&&Yt.allowCustomizedBuiltInElements&&(Yt.tagNameCheck instanceof RegExp&&nt(Yt.tagNameCheck,r)||Yt.tagNameCheck instanceof Function&&Yt.tagNameCheck(r))))return!1;return!0},ar=ct({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),cr=function(t){return!ar[$(t)]&&nt(Kt,t)},ur=function(t,e,r,i){if(A&&"object"==typeof l&&"function"==typeof l.getAttributeType&&!r)switch(l.getAttributeType(t,e)){case"TrustedHTML":return C(i);case"TrustedScriptURL":return function(t){R(),I++;try{return A.createScriptURL(t)}finally{I--}}(i)}return i},hr=function(t,e,i,n){try{i?t.setAttributeNS(i,e,n):t.setAttribute(e,n),er(t)?$e(t):V(r.removed)}catch(r){ze(e,t)}},lr=function(t){nr(U.beforeSanitizeAttributes,t,null);const e=t.attributes;if(!e||er(t))return;const r={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Wt,forceKeepAttr:void 0};let i=e.length;const n=Ue(t.nodeName);for(;i--;){const s=e[i],o=s.name,a=s.namespaceURI,c=s.value,u=Ue(o),h=c;let l="value"===o?h:J(h);r.attrName=u,r.attrValue=l,r.keepAttr=!0,r.forceKeepAttr=void 0,nr(U.uponSanitizeAttribute,t,r),l=r.attrValue,!ge||"id"!==u&&"name"!==u||0===X(l,fe)||(ze(o,t),l=fe+l),ne&&nt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,l)||"attributename"===u&&z(l,"href")?ze(o,t):r.forceKeepAttr||(!r.keepAttr||!re&&nt(Bt,l)?ze(o,t):(ie&&(l=Ze(l)),or(n,u,l)?(l=ur(n,u,a,l),l!==h&&hr(t,o,a,l)):ze(o,t)))}nr(U.afterSanitizeAttributes,t,null)},pr=function(t){let e=null;const r=Qe(t);for(nr(U.beforeSanitizeShadowDOM,t,null);e=r.nextNode();)if(nr(U.uponSanitizeShadowNode,e,null),sr(e,t),lr(e),rr(e.content)&&pr(e.content),1===(E?E(e):e.nodeType)){const t=S(e);rr(t)&&(dr(t),pr(t))}nr(U.afterSanitizeShadowDOM,t,null)},dr=function(t){const e=[{node:t,shadow:null}];for(;e.length>0;){const t=e.pop();if(t.shadow){pr(t.shadow);continue}const r=t.node,i=1===(E?E(r):r.nodeType),n=m(r);if(n)for(let t=n.length-1;t>=0;--t)e.push({node:n[t],shadow:null});if(i){const t=x?x(r):null;if("string"==typeof t&&"template"===Ue(t)){const t=r.content;rr(t)&&e.push({node:t,shadow:null})}}if(i){const t=S(r);rr(t)&&e.push({node:null,shadow:t},{node:t,shadow:null})}}};return r.sanitize=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,s=null,o=null,a=null;if(Pe=!t,Pe&&(t="\x3c!--\x3e"),"string"!=typeof t&&!ir(t)&&"string"!=typeof(t=function(t){switch(typeof t){case"string":return t;case"number":return Q(t);case"boolean":return Z(t);case"bigint":return tt?tt(t):"0";case"symbol":return et?et(t):"Symbol()";case"undefined":default:return it(t);case"function":case"object":{if(null===t)return it(t);const e=t,r=lt(e,"toString");if("function"==typeof r){const t=r(e);return"string"==typeof t?t:it(t)}return it(t)}}}(t)))throw st("dirty is not a string, aborting");if(!r.isSupported)return t;oe?(qt=ae,Wt=ce):Ke(e),(U.uponSanitizeElement.length>0||U.uponSanitizeAttribute.length>0)&&(qt=ht(qt)),U.uponSanitizeAttribute.length>0&&(Wt=ht(Wt)),r.removed=[];const c=ye&&"string"!=typeof t&&ir(t);if(c){!function(t){if(!ne)return;const e=[t];for(;e.length>0;){const r=e.pop(),i=E?E(r):r.nodeType;if(7===i||8===i&&nt(_t,r.data)){try{g(r)}catch(t){}continue}if(1===i){const e=r,i=Ue(x?x(r):r.nodeName);try{e.hasAttribute&&e.hasAttribute("patchsrc")&&e.removeAttribute("patchsrc"),e.hasAttribute&&e.hasAttribute("for")&&"label"!==i&&"output"!==i&&e.removeAttribute("for")}catch(t){}}const n=m(r);if(n)for(let t=n.length-1;t>=0;--t)e.push(n[t])}}(t);const r=x?x(t):t.nodeName;if("string"==typeof r){const e=Ue(r);if(!qt[e]||Xt[e])throw We(t),st("root node is forbidden and cannot be sanitized in-place")}if(er(t))throw We(t),st("root node is clobbered and cannot be sanitized in-place");try{dr(t)}catch(e){throw We(t),e}}else if(ir(t))i=Je("\x3c!----\x3e"),s=i.ownerDocument.importNode(t,!0),1===s.nodeType&&"BODY"===s.nodeName||"HTML"===s.nodeName?i=s:i.appendChild(s),dr(s);else{if(!he&&!ie&&!se&&-1===t.indexOf("<"))return A&&pe?C(t):t;if(i=Je(t),!i)return he?null:pe?b:""}i&&ue&&$e(i.firstChild);const u=c?t:i,h=Qe(u);try{for(;o=h.nextNode();)sr(o,u),lr(o),rr(o.content)&&pr(o.content)}catch(e){throw c&&(We(t),M(r.removed,t=>{t.element&&Xe(t.element)})),e}if(c)return M(r.removed,t=>{t.element&&Xe(t.element)}),ie&&tr(t),t;if(he){if(ie&&tr(i),le)for(a=D.call(i.ownerDocument);i.firstChild;)a.appendChild(i.firstChild);else a=i;return(Wt.shadowroot||Wt.shadowrootmode)&&(a=k.call(n,a,!0)),a}let l=se?i.outerHTML:i.innerHTML;return se&&qt["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&nt(Nt,i.ownerDocument.doctype.name)&&(l="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+l),ie&&(l=Ze(l)),A&&pe?C(l):l},r.setConfig=function(){Ke(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),oe=!0,ae=qt,ce=Wt},r.clearConfig=function(){je=null,oe=!1,ae=null,ce=null,A=w,b=""},r.isValidAttribute=function(t,e,r){je||Ke({});const i=Ue(t),n=Ue(e);return or(i,n,r)},r.addHook=function(t,e){"function"==typeof e&&rt(U,t)&&K(U[t],e)},r.removeHook=function(t,e){if(rt(U,t)){if(void 0!==e){const r=j(U[t],e);return-1===r?void 0:G(U[t],r,1)[0]}return V(U[t])}},r.removeHooks=function(t){rt(U,t)&&(U[t]=[])},r.removeAllHooks=function(){U={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},r}();const Mt=Ut(globalThis),jt={ADD_ATTR:["target","rel"]};Mt.addHook("afterSanitizeAttributes",t=>{"_blank"===t.getAttribute("target")?t.setAttribute("rel","noopener noreferrer"):t.hasAttribute("target")||!t.hasAttribute("xlink:href")&&!t.hasAttribute("href")||t.setAttribute("xlink:show","new")});class Vt{static sanitize(t,e={}){const r={...jt,...e};return Mt.sanitize(t,r)}}class Kt{copy(){return o.deepCopy(this)}}class Gt extends Kt{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 qt extends Gt{constructor(t){super(t)}add(t){this.items.push(t)}remove(t){this.items=this.items.filter(e=>e!==t)}addAll(t){this.items.push(...t)}unsubscribeAll(){this.items.forEach(t=>t()),this.items=[]}}class $t extends Kt{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 Wt=(t,e)=>{const r=t.location.localeCompare(e.location);return 0!==r?r:t.id.localeCompare(e.id)};class zt extends Gt{constructor(t){super(t)}findRepository(t,e,r=!1){return super.find(i=>i.id===t&&(r||i.location===e))}sortByLocationAndId(){super.sort(Wt)}filterByRepository(t){return super.filter(this.createIdLocationFilter(t))}createIdLocationFilter(t){return e=>t.some(t=>t.id!==e.id||t.location!==e.location)}}class Yt extends Kt{constructor(t){super(),this.inferred=t?.inferred||0,this.total=t?.total||0,this.explicit=t?.explicit||0}}let Xt=function(t){return t.INACTIVE="INACTIVE",t.STARTING="STARTING",t.RUNNING="RUNNING",t.RESTARTING="RESTARTING",t.STOPPING="STOPPING",t}({}),Jt=function(t){return t.GRAPH_DB="graphdb",t.ONTOP="ontop",t.FEDX="fedx",t.SYSTEM="system",t.OTHER="other",t}({});const Qt="repositoryId";let Zt=function(t){return t.NONE="NONE",t.READ="READ",t.WRITE="WRITE",t.MAINTAIN="MAINTAIN",t.GRAPHQL_READ="GRAPHQL_READ",t.GRAPHQL_WRITE="GRAPHQL_WRITE",t}({});class te extends Kt{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 ee=function(t){return t.GDB="GDB",t.ONTOPIC="ONTOPIC",t.SPARQL="SPARQL",t}({});class re{constructor(t){this.namespaces=t}getByPrefix(t){return this.namespaces[t]||""}}class ie{constructor(t,e){this.NAME=t,this.payload=e}}const ne={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",BEFORE_MOUNT_ROUTING_EVENT:"beforeMountRoutingEvent"};class se extends ie{constructor(t,e){super(ne.NAVIGATION_END,{oldUrl:t,newUrl:e})}}class oe{}class ae extends ie{constructor(t,e,r){super(ne.NAVIGATION_START,{oldUrl:t,newUrl:e,cancelNavigation:r})}}class ce extends ie{constructor(){super(ne.APPLICATION_MOUNTED)}}class ue extends ie{constructor(){super(ne.APPLICATION_UNMOUNTED)}}class he extends ie{constructor(){super(ne.APPLICATION_BEFORE_CHANGE)}}class le extends ie{constructor(){super(ne.APPLICATION_CHANGED)}}class pe extends ie{constructor(t){super(ne.BEFORE_MOUNT_ROUTING_EVENT,t)}}class de extends ie{constructor(){super(ne.LOGOUT)}}class ge extends ie{constructor(){super(ne.LOGIN)}}let fe=function(t){return t.NONE="NONE",t.BASIC="BASIC",t.SIGNATURE="SIGNATURE",t}({}),me=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_REPO_MAINTAINER="ROLE_REPO_MAINTAINER",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.MAINTAIN_REPO="MAINTAIN_REPO",t.GRAPHQL="GRAPHQL",t.WRITE_REPO_PREFIX="WRITE_REPO_",t.MAINTAIN_REPO_PREFIX="MAINTAIN_REPO_",t.GRAPHQL_PREFIX="GRAPHQL_",t.SUFFIX_DELIMITER=":",t.CUSTOM_PREFIX="CUSTOM_",t}({});class ye{static getRepoFromAuthority(t){return t.startsWith(me.READ_REPO_PREFIX)?{prefix:me.READ_REPO_PREFIX,repo:t.substring(me.READ_REPO_PREFIX.length)}:t.startsWith(me.WRITE_REPO_PREFIX)?{prefix:me.WRITE_REPO_PREFIX,repo:t.substring(me.WRITE_REPO_PREFIX.length)}:t.startsWith(me.MAINTAIN_REPO_PREFIX)?{prefix:me.MAINTAIN_REPO_PREFIX,repo:t.substring(me.MAINTAIN_REPO_PREFIX.length)}:t.startsWith(me.GRAPHQL_PREFIX)?{prefix:me.GRAPHQL_PREFIX,repo:t.substring(me.GRAPHQL_PREFIX.length)}:null}}const Se=t=>{const e=me.SUFFIX_DELIMITER+me.GRAPHQL,r=t.getItems();if(!r.length)return r;const i=[],n={};let s=!1,o=!1,a=!1;r.forEach(t=>{const e=ye.getRepoFromAuthority(t);if(!e)return void i.push(t);const{prefix:r,repo:c}=e,u=(n[h=c]||(n[h]={read:!1,write:!1,maintain:!1,graphql:!1}),n[h]);var h;r===me.READ_REPO_PREFIX?(u.read=!0,"*"===c&&(s=!0)):r===me.WRITE_REPO_PREFIX?(u.write=!0,"*"===c&&(o=!0)):r===me.MAINTAIN_REPO_PREFIX?u.maintain=!0:r===me.GRAPHQL_PREFIX&&(u.graphql=!0,"*"===c&&(a=!0))});const c=[];return Object.keys(n).forEach(t=>{const r=n[t];r.maintain?c.push(`${me.MAINTAIN_REPO_PREFIX}${t}`,`${me.WRITE_REPO_PREFIX}${t}`,`${me.READ_REPO_PREFIX}${t}`):r.graphql||a?r.write||o?c.push(`${me.WRITE_REPO_PREFIX}${t}${e}`,`${me.READ_REPO_PREFIX}${t}${e}`):(r.read||s)&&c.push(`${me.READ_REPO_PREFIX}${t}${e}`):r.write?c.push(`${me.WRITE_REPO_PREFIX}${t}`,`${me.READ_REPO_PREFIX}${t}`):r.read&&c.push(`${me.READ_REPO_PREFIX}${t}`)}),[...i,...c]},ve=t=>{if(!t)return new xe;const e=[],r=(t instanceof xe?t.getItems():t)??[];for(const t of r)Ee(t,e)||e.includes(t)||e.push(t);return new xe(e)};function Ee(t,e){if(!t.includes(me.SUFFIX_DELIMITER))return!1;const[r,i]=t.split(me.SUFFIX_DELIMITER);if(!r.startsWith(me.READ_REPO_PREFIX)&&!r.startsWith(me.WRITE_REPO_PREFIX)||i!==me.GRAPHQL)return!1;const n=ye.getRepoFromAuthority(r);if(!n)return!1;const{repo:s}=n,o=me.GRAPHQL_PREFIX+s;return e.includes(r)||e.push(r),e.includes(o)||e.push(o),!0}class xe extends Gt{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 n=e.substring(0,e.length-r.length);if(t.startsWith(n)){i=!0;break}}return i}getCustomRoles(){return this.getItems().filter(t=>0===t.indexOf(me.CUSTOM_PREFIX)).map(t=>t.substring(me.CUSTOM_PREFIX.length))}toUIModel(){const t={[me.READ_REPO]:{},[me.WRITE_REPO]:{},[me.MAINTAIN_REPO]:{},[me.GRAPHQL]:{}};return ve(this.getItems()).getItems().forEach(e=>{if(e.startsWith(me.READ_REPO_PREFIX)||e.startsWith(me.WRITE_REPO_PREFIX)||e.startsWith(me.MAINTAIN_REPO_PREFIX)||e.startsWith(me.GRAPHQL_PREFIX)){const r=ye.getRepoFromAuthority(e);if(r){const{prefix:e,repo:i}=r;e===me.MAINTAIN_REPO_PREFIX?t[me.MAINTAIN_REPO][i]=!0:e===me.READ_REPO_PREFIX?t[me.READ_REPO][i]=!0:e===me.WRITE_REPO_PREFIX?t[me.WRITE_REPO][i]=!0:e===me.GRAPHQL_PREFIX&&(t[me.GRAPHQL][i]=!0)}}}),t}toGraphdbAuthoritiesModel(){return Se(this)}getRepositoriesPermissions(){const t={},e=this.getItems();for(const r of e){const e=ye.getRepoFromAuthority(r);if(e){const{prefix:r,repo:i}=e,n=t[i]??{read:!1,write:!1,maintain:!1,graphql:!1};r===me.READ_REPO_PREFIX?n.read=!0:r===me.WRITE_REPO_PREFIX?n.write=!0:r===me.MAINTAIN_REPO_PREFIX&&(n.maintain=!0),i.split(":")[1]!==me.GRAPHQL||n.maintain||(n.graphql=!0),t[i]=n}}return t}}class Ae{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 be=function(t){return t.ADMIN="admin",t.REPO_MANAGER="repoManager",t.USER="user",t}({});class we extends Kt{constructor(t){super(),this.username=t?.username??"",this.password=t?.password,this.confirmPassword=t?.confirmPassword,this.authorities=t?.authorities??new xe,this.appSettings=t?.appSettings??new Ae,this.dateCreated=t?.dateCreated??null,this.gptThreads=t?.gptThreads??[],this.hasExternalLogin=t?.hasExternalLogin??!1}getUserType(){return this.authorities.hasAuthority(me.ROLE_ADMIN)?be.ADMIN:this.authorities.hasAuthority(me.ROLE_REPO_MANAGER)?be.REPO_MANAGER:be.USER}getUserTypeDescription(){const t=this.getUserType();return t===be.USER?"User":t===be.REPO_MANAGER?"Repository manager":t===be.ADMIN?"Administrator":"Unknown"}}class Ie extends Kt{toUser(){return new we({username:this.username,authorities:this.authorities,appSettings:this.appSettings})}static fromUser(t){return new Ie({username:t.username,authorities:t.authorities,appSettings:t.appSettings})}constructor(t){super(),this.external=t?.external??!1,this.username=t?.username??"",this.password=t?.password??"",this.authorities=t?.authorities??new xe,this.grantedAuthoritiesUiModel=ve(t?.authorities??[]),this.appSettings=t?.appSettings??new Ae}getCookieConsent(){return this.appSettings.COOKIE_CONSENT}setAuthorities(t=new xe){return this.authorities=t,this.grantedAuthoritiesUiModel=ve(t.getItems()),this}setAppSettings(t=new Ae){return this.appSettings=t,this}}class Te extends Kt{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 Re=t=>new xe(t);class Ce extends Kt{constructor(t){super(),this.appSettings=t.appSettings,t.authorities instanceof xe?this.authorities=t.authorities:this.authorities=Re(t.authorities??[]),this.enabled=t.enabled}}const Pe=t=>{const e=new Ce({});return e.appSettings=new Ae(t.appSettings),e.authorities=Re(t.authorities||[]),e.enabled=t.enabled,e};let Fe=function(t){return t.LOCAL="Local",t.LDAP="LDAP",t.OAUTH="OAuth",t}({});class Ne extends Kt{constructor(t){super(),this.authImplementation=I(Fe,t.authImplementation??Fe.LOCAL),this.enabled=t.enabled,this.passwordLoginEnabled=t.passwordLoginEnabled,this.freeAccess=Pe(t.freeAccess),this.overrideAuth=Pe(t.overrideAuth),this.openIdEnabled=t.openIdEnabled??!1,this.freeAccessActive=t.freeAccess?.enabled,this.hasExternalAuth=t.hasExternalAuth,this.allowSecurityToggle=t.allowSecurityToggle,t.methodSettings?.openid&&(this.openidSecurityConfig=new Te(t.methodSettings?.openid)),this.additionalAuthSources=(t.additionalAuthSources??[]).map(t=>I(Fe,t))}isEnabled(){return this.enabled??!1}isFreeAccessEnabled(){return this.freeAccess.enabled??!1}getFreeAccessAuthSettings(){return this.freeAccess}hasOverrideAuth(){return this.overrideAuth?.enabled??!1}isSecurityToggleAllowed(){return this.allowSecurityToggle??!0}hasAdditionalAuthSource(){return!!this.additionalAuthSources.length}getAuthSourceType(){return this.authImplementation}isOpenIdEnabled(){return this.openIdEnabled}isPasswordLoginEnabled(){return this.passwordLoginEnabled??!1}hasLocalAdditionalAuthSources(){return this.additionalAuthSources.includes(Fe.LOCAL)}}class De extends Kt{pages={};isRestricted(t){return this.pages[t]??!1}setPageRestriction(t,e=!0){return this.pages[t]=e,this}}class Oe extends Kt{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 _e extends Gt{constructor(t){super(t)}}class Le{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?.trim();if(!e)return"";const r=/^(\d+\.\d+)/.exec(e);if(r){const t=/(-[^-]+)/.exec(e),i=t?.[1]??"";return r[1]+i}return e}}let Be=function(t){return t.CONSOLE="console",t}({}),ke=function(t){return t.DEBUG="DEBUG",t.INFO="INFO",t.WARN="WARN",t.ERROR="ERROR",t}({});const He=t=>Ue[t],Ue={[ke.DEBUG]:0,[ke.INFO]:1,[ke.WARN]:2,[ke.ERROR]:3};class Me{static SERVICE_INSTANCES=new Map;static get(t){if(!Me.SERVICE_INSTANCES.has(t.name)){const e=new t;Me.implementsLifecycleHooks(e)&&e.onCreated?.(),Me.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(Me.SERVICE_INSTANCES.values()).filter(e=>e instanceof t)}}function je(t){return Me.get(t)}const Ve=new Map([[Be.CONSOLE,je(class{log(t,e,r){switch(t){case ke.DEBUG:console.debug(e,...r);break;case ke.INFO:console.info(e,...r);break;case ke.WARN:console.warn(e,...r);break;case ke.ERROR:console.error(e,...r);break;default:console.debug(e,...r)}}})]]);class Ke{callbackFunctions=[];beforeChangeValidationPromises=[];afterValueChangeCallbackFunctions=[];setValue(t){o.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 o.hasCopyMethod(t)?t.copy():o.deepCopy(t)}}class Ge{subscribers=[];unsubFns=new qt;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=Me.getAllBySuperType(qe).filter(t=>t.canSubscribeAll);for(const n of i)this.unsubFns.add(n.subscribeAll(t,e,r));const n={callback:t,beforeChangeValidationPromise:e,afterChangeCallback:r};this.subscribers.push(n);let s=!1;return()=>{if(s)return;s=!0,this.unsubFns.unsubscribeAll();const t=this.subscribers.indexOf(n);t>=0&&this.subscribers.splice(t,1)}}}class qe{context=new Map;_canSubscribeAll=!1;onCreated(){this._canSubscribeAll=!0,Me.get(Ge).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,n=!1){return!n&&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 n=new qt;for(const s of this.getContextFields())n.add(this.subscribe(s,t,e,r,i));return()=>n.unsubscribeAll()}getContextFields(){return Object.values(this).filter(t=>"string"==typeof t)}getOrCreateValueContext(t){let e=this.context.get(t);return e||(e=new Ke,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 $e extends qe{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,n=t===i.dark?i.light:i.dark;return r&&r[n]?r[n]:e.applicationLogoPath}}class We{loggers=Ve;constructor(t){this.module=t}debug(t,...e){this.log(ke.DEBUG,t,e)}error(t,...e){this.log(ke.ERROR,t,e)}info(t,...e){this.log(ke.INFO,t,e)}warn(t,...e){this.log(ke.WARN,t,e)}log(t,e,r){const i=this.loadConfiguration();i?.loggers.forEach(n=>{const s=this.loggers.get(n);if(!s)throw new Error(`Logger '${n}' not found`);if(He(i.minLogLevel)<=He(t)){const i=this.getFormattedMessage(t,e);s.log(t,i,r)}})}getFormattedMessage(t,e){return`[${t}] [${this.module}] [${(new Date).toLocaleString()}] ${e}`}loadConfiguration(){const t=je($e).getApplicationConfiguration();return t?.loggerConfig}}class ze{static loggerInstances=new Map;static getLoggerInstance(t){return this.loggerInstances.has(t)||this.loggerInstances.set(t,new We(t)),this.loggerInstances.get(t)}}class Ye{static get logger(){return ze.getLoggerInstance("API")}}class Xe{logger=Ye.logger;constructor(t){this.value=t}getValue(){return this.value}isDefined(){return!o.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 Je{static GLOBAL_NAMESPACE="ontotext.gdb"}class Qe{constructor(t=[]){this.languages=t}getLanguageCodes(){return this.languages?.map(t=>t.key)}}const Ze=["en","fr"];class tr extends Kt{constructor(t){super(),this.defaultLanguage=t.defaultLanguage||"en",this.availableLanguages=t.availableLanguages||new Qe,this.languageBundleVersion=t.languageBundleVersion||""}}class er{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 er({policyAccepted:void 0,statistic:!0,thirdParty:!0})}static ACCEPTED_NO_TRACKING(){return new er({policyAccepted:!0,statistic:!1,thirdParty:!1})}static fromJSON(t){return new er({policyAccepted:t?.policyAccepted,statistic:t?.statistic,thirdParty:t?.thirdParty,updatedAt:t?.updatedAt})}}let rr=function(t){return t.INFORMATION="INFORMATION",t.WARNING="WARNING",t.CRITICAL="CRITICAL",t}({});const ir={[rr.INFORMATION]:0,[rr.WARNING]:1,[rr.CRITICAL]:2};class nr extends Kt{constructor(t){super(),this.id=`${t.group}-${t.status}-${t.totalOperations}`,this.group=t.group,this.totalOperations=t.totalOperations,this.status=t.status}}class sr extends Gt{constructor(t){super(t)}}class or extends Kt{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 nr({group:e.group,totalOperations:0,status:rr.INFORMATION}));const r=t.get(e.group);r.totalOperations+=e.count,ir[e.status]>ir[r.status]&&(r.status=e.status)}),Array.from(t.values())}toOperationGroupSummaryList(){return new sr(this.toOperationsGroupSummary())}}class ar extends Gt{constructor(t){super(t)}}let cr=function(t){return t.UPDATES="updates",t.QUERIES="queries",t.IMPORT="imports",t.BACKUP_AND_RESTORE="backupAndRestore",t.CLUSTER_HEALTH="clusterHealth",t}({}),ur=function(t){return t.QUERY="QUERY",t.BACKUP="BACKUP",t.CLUSTER="CLUSTER",t.IMPORT="IMPORT",t}({});const hr=[cr.QUERIES,cr.UPDATES,cr.IMPORT],lr={[cr.UPDATES]:"monitor/queries",[cr.QUERIES]:"monitor/queries",[cr.BACKUP_AND_RESTORE]:"monitor/backup-and-restore",[cr.IMPORT]:"import",[cr.CLUSTER_HEALTH]:"cluster"},pr={[cr.QUERIES]:ur.QUERY,[cr.UPDATES]:ur.QUERY,[cr.BACKUP_AND_RESTORE]:ur.BACKUP,[cr.IMPORT]:ur.IMPORT,[cr.CLUSTER_HEALTH]:ur.CLUSTER};class dr extends Kt{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=pr[this.type],this.href=lr[this.type],this.labelKey=this.getLabelKey(this.type,this.value)}getCount(t,e){return hr.includes(t)?parseInt(e,10):0}getLabelKey(t,e){return hr.includes(t)?t:e}}let gr=function(t){return t.BOTTOM_RIGHT="bottom-right",t.BOTTOM_LEFT="bottom-left",t}({});class fr{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 mr extends fr{constructor(t){super(),this.timeout=t.timeout,this.position=t.position}static getDefaultConfig(){return this.instance||(this.instance=new mr({timeout:5e3,position:gr.BOTTOM_RIGHT})),this.instance}}let yr=function(t){return t.ERROR="error",t.INFO="info",t.SUCCESS="success",t.WARNING="warning",t}({});class Sr{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 n=Math.random()*t;return e>0?(n=(e+n)%t|0,e=Math.floor(e/t)):(n=(r+n)%t|0,r=Math.floor(r/t)),("x"===i?n:3&n|8).toString(t)})}static generateRandomString(t){const e=new Uint32Array(t);return l.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 vr extends Kt{constructor(){super(),this.id=Sr.uuid()}}class Er extends vr{constructor(t,e,r){super(),this.type=t,this.message=e,this.config=r}}const xr="create-toast-event";class Ar extends Gt{constructor(t){super(t)}}let br=function(t){return t.CANCEL="cancel",t.EXIT="exit",t.DONT_SHOW_AGAIN="dontShowAgain",t}({});const wr="confirm-cancel-event";class Ir{constructor(t,e){this.hasDontShowAgain=t,this.onClose=e}}class Tr extends Gt{constructor(t){super(t)}}class Rr extends Kt{constructor(t){super(),this.setRadio(t.isRadio),this.setButtons(new Tr(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 Cr extends Kt{constructor(t){super(),this.id=t.id,this.label=t.label,this.selected=t.selected,this.callback=t.callback}}class Pr extends Gt{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 Fr extends Kt{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 Pr,this.copy()}getByValue(t){return this.suggestions.findSuggestionByValue(t)}clearSelectedState(){this.suggestions.deselectAllSuggestions()}clearHoveredState(){this.suggestions.unhoverAllSuggestions()}}class Nr extends Kt{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 Dr=function(t){return t.URI="uri",t.PREFIX="prefix",t}({});class Or{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 _r=function(t){return t.DATA_LOADED="DATA_LOADED",t}({}),Lr=function(t){return t.MOUNTED="MOUNTED",t.UNMOUNTED="UNMOUNTED",t}({}),Br=function(t){return t.LEGACY_ANGULAR="@ontotext/legacy-workbench",t.NEW_ANGULAR="@ontotext/workbench",t}({});class kr{constructor(t){this.applicationsState=t}isLegacyAngularLoaded(){return this.applicationsState[Br.LEGACY_ANGULAR]===Lr.MOUNTED}isNewAngularLoaded(){return this.applicationsState[Br.NEW_ANGULAR]===Lr.MOUNTED}equals(t){if(!t)return!1;const e=Object.keys(this.applicationsState),r=Object.keys(t.applicationsState);if(e.length!==r.length)return!1;for(const r of e)if(this.applicationsState[r]!==t.applicationsState[r])return!1;return!0}}class Hr{constructor(t,e){this.entry=t,this.name=e}}class Ur extends Kt{constructor(t){super(),this._pluginDefinitions=t}getPluginDefinitions(){return this._pluginDefinitions}}class Mr extends Gt{}class jr{plugins=new Mr;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 Vr extends Gt{constructor(t){super(t)}}class Kr extends Kt{_disabled=!1;constructor(t={}){super(),this._disabled=t.disabled??!1}get disabled(){return this._disabled}set disabled(t){this._disabled=t}}class Gr extends Kr{constructor(t){super(),this._items=t.items||[]}get items(){return this._items}set items(t){this._items=t||[]}}class qr{_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 $r extends Kr{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 Wr extends Kr{constructor(t){super(t),this.guideBlockName=t.guideBlockName||"",this.getStep=t.getStep,this.getSteps=t.getSteps}}class zr extends jr{static NAME="main.menu";name=zr.NAME}class Yr extends jr{static NAME="route";name=Yr.NAME}class Xr extends jr{static NAME="guide.step";name=Xr.NAME;fieldIdName="guideBlockName"}class Jr extends jr{static NAME="themes";name=Jr.NAME}class Qr 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 Zr extends Kt{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 n=r.find(e=>e.guideBlockName===t.guideBlockName);if(!n)return[];const s={...n.options??{},...t.options,...e};let a=[];if(n.getSteps)a=a.concat(this._getSteps(o.deepCopy(n.getSteps(s,i)),e,r,i));else{if(!n.getStep)throw new Qr(n.guideBlockName);a.push(o.deepCopy(n.getStep(s,i)))}return a.forEach((t,e)=>{t.stepN=e,t.stepsTotalN=a.length}),a}}let ti=function(t){return t.ERROR="error",t.INFO="info",t.SUCCESS="success",t.WARNING="warning",t}({});class ei extends vr{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 ei(t).withType(ti.INFO)}static error(t){return new ei(t).withType(ti.ERROR)}static warning(t){return new ei(t).withType(ti.WARNING)}static success(t){return new ei(t).withType(ti.SUCCESS)}}let ri=function(t){return t.SHOULD_TOAST="shouldToast",t}({});class ii{priority=0}class ni extends Gt{constructor(t){super(t)}}class si{constructor(t){this.url=t.url,this.method=t.method,this.headers={...t.headers},this.body=t.body,this.signal=t.signal}}class oi{constructor(t){this.status=t.status,this.statusText=t.statusText,this.headers=t.headers,this.config=t.config,this.originalResponse=t.originalResponse}}class ai extends oi{constructor(t){super(t),this.data=t.data}}class ci extends oi{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 ui extends Gt{constructor(t=[]){super(t)}getFirstQuery(){return this.getFirstItem()}}class hi{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 li=function(t){return t.CENTER="center",t.START="start",t}({});class pi{constructor(t,e,r,i,n,s,o){this.status=t,this.command=e,this.messageLabelKey=r,this.parameters=i,this.message=n,this.iri=s,this.name=o}}const di={ERROR:"error",SUCCESS:"success"};class gi extends Kt{constructor(t="",e=0,r=0,i=0,n=0,s=0,o=!1){super(),this.status=t,this.processedEntities=e,this.estimatedEntities=r,this.indexedEntities=i,this.entitiesPerSecond=n,this.etaSeconds=s,this.repair=o}get isBuilt(){return"BUILT"===this.status}get percentDone(){return this.estimatedEntities?Number.parseFloat((100*this.processedEntities/this.estimatedEntities).toFixed(0)):0}}let fi=function(t){return t.CREATE="create",t.REPAIR="repair",t.DROP="drop",t}({});class mi extends Kt{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 yi extends Gt{constructor(t){super(t)}getByStartMode(t){return this.items.filter(e=>e.startMode===t)}}let Si=function(t){return t.SEARCH="search",t.NODE="node",t.QUERY="query",t}({}),vi=function(t){return t.RETURN_URL="r",t.NO_ACCESS="noaccess",t.EXPIRED="expired",t}({});class Ei{getStorage(){return localStorage}get(t,e=!0){const r=this.getStorage().getItem(e?this.getPrefixedKey(t):t);return new Xe(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=`${Je.GLOBAL_NAMESPACE}.${this.NAMESPACE}.`,r=`${this.NAMESPACE}.`;return t.startsWith(e)?t:t.startsWith(r)?`${Je.GLOBAL_NAMESPACE}.${t}`:`${e}${t}`}}class xi{logger=Ye.logger;handleStorageChange(t){const e=t.key?.substring(Je.GLOBAL_NAMESPACE.length+1);let r="",i="";e&&(r=e.substring(0,e.indexOf(".")),i=e.substring(r.length+1));const n=this.resolveHandler(r,i);if(n){let e;null!==t.newValue&&(e=n.deserializeProperty(i,t.newValue)),n.updateContextProperty(i,e)}}resolveHandler(t,e){if(!t)return void this.logger.debug("Namespace is required to resolve a context property change handler.");const r=Me.getAllBySuperType(qe).find(t=>t.canHandle(e));if(r)return r;this.logger.debug(`No context property change handler found for namespace: ${t} and property: ${e}`)}}class Ai extends Ei{NAMESPACE="application";SETTINGS="settings";logger=Ye.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 n;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 n(t):new n}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}getJsonLDExportSettings(){return this.getApplicationSettings().jsonLdExportSettings}setJsonLDExportSettings(t){const e=this.getApplicationSettings();e.jsonLdExportSettings=t,this.setApplicationSettings(e)}}class bi extends qe{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 wi{applicationSettingsStorageService=je(Ai);runtimeConfigurationContextService=je(bi);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()?wi.CODE_EDITOR_DARK_THEME:void 0}getPreferredScheme(){return l.matchMedia("(prefers-color-scheme: dark)").matches?i.dark:i.light}getRootElement(){return document.querySelector(this.rootSelector)??null}}class Ii{preProcessors=new Gt;postProcessors=new Gt;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 Ti{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 Ri="http-request-done-event";class Ci{interceptorService=Me.get(Ii);eventEmitter=new Ti;get(t,e){const{params:r,headers:i,responseType:n="body"}=e??{};return"response"===n?this.request(t,"GET",{params:r,headers:i},"response"):"blob"===n?this.request(t,"GET",{params:r,headers:i},"blob"):this.request(t,"GET",{params:r,headers:i},"body")}post(t,e){const{body:r,headers:i,responseType:n="body"}=e??{};return"response"===n?this.request(t,"POST",{body:r,headers:i},"response"):"blob"===n?this.request(t,"POST",{body:r,headers:i},"blob"):this.request(t,"POST",{body:r,headers:i},"body")}put(t,e){const{params:r,body:i,headers:n,responseType:s="body"}=e??{};return"response"===s?this.request(t,"PUT",{params:r,body:i,headers:n},"response"):this.request(t,"PUT",{params:r,body:i,headers:n},"body")}patch(t,e){const{params:r,body:i,headers:n,responseType:s="body"}=e??{};return"response"===s?this.request(t,"PATCH",{params:r,body:i,headers:n},"response"):this.request(t,"PATCH",{params:r,body:i,headers:n},"body")}delete(t,e){const{params:r,headers:i,responseType:n="body"}=e??{};return"response"===n?this.request(t,"DELETE",{params:r,headers:i},"response"):this.request(t,"DELETE",{params:r,headers:i},"body")}uploadFile(t,e,r="file",i,n){const s=new FormData;s.append(r,e,e instanceof File?e.name:void 0),n&&Object.entries(n).forEach(([t,e])=>{s.append(t,e)});const o={...i};return delete o["Content-Type"],this.post(t,{body:s,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:n,headers:s}=this.getRequestConfig(t,r),o=new si({url:n,method:e,headers:s,body:r.body});let a;return this.executeRequest(o).then(async t=>{a=t;const e=t.clone();if(!t.ok){const r=await this.getDataFromResponse(i,e),n=new ci({status:t.status,statusText:t.statusText,headers:this.extractHeaders(t),config:o,originalResponse:t,data:r});return Promise.reject(n)}const r=await this.getDataFromResponse(i,e);return"body"===i?r:new ai({status:t.status,statusText:t.statusText,headers:this.extractHeaders(t),config:o,originalResponse:t,data:r})}).catch(t=>{if(t instanceof ci)return Promise.reject(t);if("AbortError"===t?.name)throw t;a??=t;const e=new ci({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:Ri,payload:void 0}))}async getDataFromResponse(t,e){if("blob"===t)return e.blob();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}`:""}`,n=e.body instanceof FormData,s={Accept:"application/json, text/plain, */*",...e.headers};return n||(s["Content-Type"]=e.headers?.["Content-Type"]??"application/json"),{fullUrl:i,headers:s,signal:e.signal}}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,signal:t.signal})}).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 Pi extends Ci{I18N_ENDPOINT="assets/i18n";getLanguage(t,e){return this.get(`${this.I18N_ENDPOINT}/${t}.json`,e?{params:{version:e}}:void 0)}getLanguageConfiguration(){return this.get(`${this.I18N_ENDPOINT}/language-config.json`)}}class Fi extends Ei{NAMESPACE="i18n";set(t,e){this.storeValue(t,e)}}class Ni extends qe{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||Me.get(_i).getDefaultLanguage();Me.get(Fi).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 Di extends Kt{constructor(t,e){super(),this.key=t,this.name=e}}function Oi(t){const e=t.map(t=>new Di(t.key,t.name));return new Qe(e)}class _i{languageRestService=Me.get(Pi);languageContextService=Me.get(Ni);getSupportedLanguages(){const t=this.languageContextService.getLanguageConfig();return t?t.availableLanguages.getLanguageCodes():Ze}getLanguage(t){return this.languageRestService.getLanguage(t,this.languageContextService.getLanguageConfig()?.languageBundleVersion)}getLanguageConfiguration(){return this.languageRestService.getLanguageConfiguration().then(t=>{return new tr({defaultLanguage:(e=t).defaultLanguage,availableLanguages:Oi(e.availableLanguages),languageBundleVersion:e.languageBundleVersion});var e})}getDefaultLanguage(){const t=this.languageContextService.getLanguageConfig();return t?t.defaultLanguage:"en"}}class Li extends Ci{static REPOSITORIES_ENDPOINT="rest/repositories";getRepositories(){return this.get(`${Li.REPOSITORIES_ENDPOINT}/all`)}getRepositorySizeInfo(t){return this.get(`${Li.REPOSITORIES_ENDPOINT}/${t.id}/size?location=${encodeURIComponent(t.location)}`)}}const Bi=t=>{if(!t||"object"!=typeof t)return new zt;const e=[];return Object.entries(t).forEach(([,t])=>{Array.isArray(t)&&t.forEach(t=>{const r=new $t({id:t.id,title:t.title,type:I(Jt,t.type),sesameType:t.sesameType,uri:t.uri,externalUrl:t.externalUrl,location:t.location,state:I(Xt,t.state),local:t.local,readable:t.readable,writable:t.writable,unsupported:t.unsupported});e.push(r)})}),new zt(e)};class ki{constructor(){this.repositoryRestService=je(Li)}async getRepositories(){const t=await this.repositoryRestService.getRepositories();return Bi(t)}async getRepositorySizeInfo(t){return e=await this.repositoryRestService.getRepositorySizeInfo(t),new Yt(e);var e}}class Hi extends Ei{NAMESPACE="repository";logger=Ye.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 Ui extends qe{SELECTED_REPOSITORY="selectedRepository";REPOSITORY_LIST="repositoryList";logger=Ye.logger;updateSelectedRepository(t){const e=je(Hi),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 zt([])}onRepositoryListChanged(t){return this.subscribe(this.REPOSITORY_LIST,t)}getDeserializedContext(){return{[this.SELECTED_REPOSITORY]:this.deserializeRepository}}deserializeRepository=t=>{try{return this.findRepository(JSON.parse(t))}catch(e){return void this.logger.error(`Failed to deserialize repository from: "${t}"`,e)}};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 Mi{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 ji extends Ci{getActiveRepositoryLocation(){return this.get("rest/locations/active")}}const Vi=t=>new te({uri:t.uri,label:t.label,username:t.username??void 0,password:t.password??void 0,authType:t.authType?I(fe,t.authType):void 0,locationType:t.locationType?I(ee,t.locationType):void 0,active:t.active,local:t.local,system:t.system,errorMsg:t.errorMsg??"",defaultRepository:t.defaultRepository??void 0});class Ki{constructor(){this.locationRestService=Me.get(ji)}getActiveRepositoryLocation(){return this.locationRestService.getActiveRepositoryLocation().then(Vi)}}class Gi extends qe{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 qi extends Ci{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 $i=function(t){return t.GRAPHDB_LITE="GRAPHDB_LITE",t.GRAPHDB_SE="GRAPHDB_SE",t.GRAPHDB_ENTERPRISE="GRAPHDB_ENTERPRISE",t.GRAPHDB_SANDBOX="GRAPHDB_SANDBOX",t}({}),Wi=function(t){return t.FREE="free",t.STANDARD="standard",t.ENTERPRISE="enterprise",t.SANDBOX="sandbox",t}({});function zi(t){return Object.values(Wi).find(e=>e===t)}const Yi=t=>{return new Oe({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($i).find(t=>t===e)),productType:zi(t?.productType),licenseCapabilities:Xi(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 Xi(t){const e=(t??[]).filter(t=>t?.trim());return new _e(e)}class Ji extends qe{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 Qi{licenseRestService=je(qi);licenseContextService=je(Ji);trackableProductTypes=[Wi.FREE,Wi.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 Yi(t)}registerLicense(t){return this.licenseRestService.registerLicense(t).then(t=>Yi(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=>Yi(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 Zi extends qe{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 tn extends Ci{VERSION_URL="rest/info/version";getProductInfoLocal(){return this.get(`${this.VERSION_URL}?local=1`)}}class en{productInfoRestService=je(tn);async getProductInfoLocal(){const t=await this.productInfoRestService.getProductInfoLocal();return new Le({workbench:(e=t).Workbench||"",productType:e.productType||"",productVersion:e.productVersion||"",sesame:e.sesame||"",connectors:e.connectors||"",ontop:e.Ontop||""});var e}}class rn extends qe{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 De}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 nn extends Ei{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 sn=r(355);class on extends Error{constructor(t){super(),this.text=t}get message(){return`${this.constructor.name}: ${this.text}`}}class an extends on{}class cn extends an{constructor(){super("Invalid JWT token")}}let un=function(t){return t.ACCESS="access",t.ID="id",t.REFRESH="refresh",t}({});class hn{logger=Ye.logger;openidStorageService=je(nn);securityContextService=je(rn);REFRESH_TOKEN_TOLERANCE=5e3;hasValidIdToken(t){return this.getTokenByType(un.ID)?this.verifyToken(un.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(un.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()===un.ID?"Bearer "+this.getTokenByType(un.ID):"Bearer "+this.getTokenByType(un.ACCESS)}getTokenHeader(t){try{const e=sn.pj.jws.JWS.readSafeJSONString((0,sn.cV)(t.split(".")[0]));if(e)return e}catch(t){throw this.logger.error("OpenID: token header decode failed",t),new cn}}getTokenPayload(t){try{const e=sn.pj.jws.JWS.readSafeJSONString((0,sn.cV)(t.split(".")[1]));if(e)return e}catch(t){throw this.logger.debug("Token payload decode error",t),new cn}}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!==un.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 n=this.securityContextService.getJsonWebKeysSet()?.[i.kid];if(!n)return this.logger.debug("OpenID: no key to verify JWT token (token considered invalid)"),!1;const s=sn.ym.getKey(n),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]),sn.pj.jws.JWS.verifyJWT(r,s,o)}clearTokens(){this.openidStorageService.clearTokens()}getTokenByType(t){return t===un.ID?this.openidStorageService.getIdToken().getValue():t===un.ACCESS?this.openidStorageService.getAccessToken().getValue():t===un.REFRESH?this.openidStorageService.getRefreshToken().getValue():null}}class ln{static pkceChallengeFromVerifier(t){const e=new sn.pj.crypto.MessageDigest({alg:"sha256",prov:"cryptojs"});return(0,sn.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=l.getLocationHash().substring(1);r=new URLSearchParams(t)}else r=new URLSearchParams(l.getLocationQueryParams());return 0===r.size||Object.keys(e).forEach(t=>{const i=r.get(t);i&&(e[t]=decodeURIComponent(i))}),e}}class pn extends an{constructor(t){super(`Invalid OpenID authentication flow: ${t}`)}}class dn extends an{constructor(){super("Missing authorization code")}}let gn=function(t){return t.CODE="code",t.CODE_NO_PKCE="code_no_pkce",t.IMPLICIT="implicit",t}({}),fn=function(t){return t.CODE="code",t.TOKEN="token id_token",t}({});class mn{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 yn{notificationAddedCallbackFunctions=[];notifications=new mn;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 Sn(t){je(yn).addNotification(t)}class vn{logger=Ye.logger;tokenUtils=je(hn);openidStorageService=je(nn);async handleAuthorizationCode(t,e,r){if(!e.code)throw this.logger.error("OpenID: Missing authorization code"),new dn;const i=`${x()}`;if(t.authFlow===gn.CODE)await this.handlePkceFlow(e,i,r);else{if(t.authFlow!==gn.CODE_NO_PKCE)throw this.logger.error("OpenID: Invalid OpenID authentication flow"),new pn(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(Sr.generateRandomString(28))}getCodeChallengeForCodeFlow(){const t=this.openidStorageService.getPkceCodeVerifier().getValue();if(!t)throw new an("Missing PKCE code verifier");return ln.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}`),Sn(ei.error("openid.errors.invalid_pkce_state").withTitle("openid.errors.title").withParameters({[ri.SHOULD_TOAST]:!0})),new an(`PKCE state mismatch ${i} != ${t.state}`);if(!t.code)throw new dn;const n=this.openidStorageService.getPkceCodeVerifier().getValue();await r(t.code,e,n)}async handleCodeNoPkceFlow(t,e,r){await r(t,e)}}class En extends an{constructor(){super("OpenID security configuration is not available")}}class xn extends Ci{securityContextService=je(rn);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 n={...this.getDomainHeaders(),"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},s=this.transformURLEncodedRequest(i);return this.post(this.getTokensEndpoint(),{body:s,headers:n})}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 En}getJWKSEndpoint(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.openIdKeysUri;throw new En}getTokensEndpoint(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.openIdTokenUrl;throw new En}getDomainHeaders(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;return t?.oracleDomain?{[this.OAUTH_IDENTITY_DOMAIN_NAME_HEADER]:t.oracleDomain}:{}}}class An{securityContextService=je(rn);buildLoginUrl(t,e,r){const i=this.getResponseType(),n=[...this.buildBaseParameters(i,r),...this.buildFlowSpecificParameters(t,e),...this.buildAdditionalParameters()];return`${this.getOpenIdConfig().oidcAuthorizationEndpoint}?${n.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 En;return t}getResponseType(){const t=this.getOpenIdConfig().authFlow;if(t===gn.CODE||t===gn.CODE_NO_PKCE)return fn.CODE;if(t===gn.IMPLICIT)return fn.TOKEN;throw new pn(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===gn.CODE?i.push(`state=${encodeURIComponent(t)}`,`code_challenge=${encodeURIComponent(e)}`,"code_challenge_method=S256"):r===gn.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 bn{DEFAULT_REFRESH_CONFIGURATION={refreshAheadMs:6e4,minDelayMs:1e3};logger=Ye.logger;tokenUtils=je(hn);openidStorageService=je(nn);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&&(l.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=l.getWindow().setTimeout(async()=>{this.logger.debug("OpenID: tokens will refresh now, "+e),await r(t)},e)}}class wn extends Ei{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(){return this.isGDBToken()||this.isOpenIDToken()}isGDBToken(){const t=this.getAuthToken().getValue();return!!t?.startsWith("GDB")}isOpenIDToken(){const t=this.getAuthToken().getValue();return!!t?.startsWith("Bearer")}}class In{constructor(t){this.notify=t}}class Tn{eventSubscribers=new Map;emit(t){const e=this.eventSubscribers.get(t.NAME);e&&e.forEach(e=>{e.notify(o.deepCopy(t.payload))})}subscribe(t,e){const r=new In(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 Rn{logger=Ye.logger;openIdRestService=je(xn);openidStorageService=je(nn);securityContextService=je(rn);tokenUtils=je(hn);authenticationStorageService=je(wn);authFlowHandler=je(vn);tokenRefreshManager=je(bn);openIdUrlBuilder=je(An);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 ci&&(e=t.data?.error_description??"unknown error"),Sn(ei.error("openid.errors.cannot_refresh_token").withTitle("openid.errors.title").withParameters({error:e,[ri.SHOULD_TOAST]:!0})),this.softLogout(),je(Tn).emit(new de)}}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(x()):this.softLogout()}getOpenIdConfig(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(!t)throw new En;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===gn.IMPLICIT,r=ln.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 n=await this.getTokens(e,t,r);this.logger.debug("OpenID: successfully retrieved tokens"),this.tokenUtils.saveTokens(n,i),await this.setupTokensRefresh()}catch(t){throw this.logger.error("OpenID: Cannot retrieve token after login",{error:t}),Sn(ei.error("openid.errors.cannot_retrieve_token").withTitle("openid.errors.title").withParameters({error:t instanceof Error?t.message:String(t),[ri.SHOULD_TOAST]:!0})),new an("Cannot retrieve token after login")}}softLogout(){this.clearAuthentication()}hardLogout(t){this.softLogout();const e=this.getLogoutUrl(t);this.redirectToUrl(e)}redirectToUrl(t){l.setLocationHref(t)}getLoginUrl(t,e,r){return this.openIdUrlBuilder.buildLoginUrl(t,e,r)}getLogoutUrl(t){return this.openIdUrlBuilder.buildLogoutUrl(t)}}let Cn=function(t){return t.GDB_TOKEN="GDB_TOKEN",t.OPENID="OPENID",t.EXTERNAL="EXTERNAL",t.NO_SECURITY="NO_SECURITY",t}({});class Pn{logger=Ye.logger;securityService=je(Gn);securityContextService=je(rn);type=Cn.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 Fn extends an{constructor(){super("OpenID user has no access rights")}}class Nn{logger=Ye.logger;securityService=je(Gn);authenticationStorageService=je(wn);authenticationService=je(Qn);securityContextService=je(rn);openIdService=je(Rn);openidStorageService=je(nn);tokenUtils=je(hn);type=Cn.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&&m(e),t}catch(t){return this.handleAuthenticationError(t),!1}}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}login(){this.validateConfiguration();const t=this.getReturnUrl(),e=Sr.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 En}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),Sn(ei.error("openid.errors.user_no_access").withTitle("openid.errors.title").withParameters({[ri.SHOULD_TOAST]:!0})),new Fn}}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`${x()}`}executeAuthFlow(t,e,r){switch(t){case gn.CODE:this.openIdService.setupCodeFlow(e,r);break;case gn.CODE_NO_PKCE:this.openIdService.setupCodeNoPkceFlow(e,r);break;case gn.IMPLICIT:this.openIdService.setupImplicitFlow(e,r);break;default:throw this.logger.debug(`OpenID: Invalid OpenID authentication flow: ${t}`),Sn(ei.error("openid.errors.unknown_flow").withTitle("openid.errors.title").withParameters({authFlow:t,[ri.SHOULD_TOAST]:!0})),new pn(t)}}}class Dn extends on{constructor(){super("Missing token in authentication header")}}class On extends on{constructor(){super("Invalid login data. Expected an object of type LoginData.")}}class _n{securityService=je(Gn);authStorageService=je(wn);securityContextService=je(rn);type=Cn.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()}async login(t){this.assertIsLoginData(t);const{username:e,password:r}=t,i=await this.securityService.loginGdbToken(e,r),n=this.getAuthenticationHeader(i),s=Vn(i.data);if(!n)throw new Dn;return this.authStorageService.setAuthToken(n),s}assertIsLoginData(t){if("object"!=typeof t||null===t||!("username"in t)||!("password"in t))throw new On}getAuthenticationHeader(t){return t.headers.authorization}logout(){return this.authStorageService.clearAuthToken(),Promise.resolve()}isAuthenticated(){return null!==this.authStorageService.getAuthToken().getValue()}isExternal(){return!1}isCurrentRouteLogin(){return"login"===b()}}class Ln extends on{constructor(){super()}}class Bn extends Ci{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 kn extends Ci{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 Hn{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 Un=t=>new Hn({password:t.password,grantedAuthorities:t.authorities.toGraphdbAuthoritiesModel(),appSettings:t.appSettings.toJSON()}),Mn=t=>new we({username:t.username,authorities:new xe(t.grantedAuthorities),appSettings:new Ae({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 er(t.appSettings.COOKIE_CONSENT):void 0}),dateCreated:new Date(t.dateCreated),gptThreads:t.gptThreads,hasExternalLogin:t.hasExternalLogin});class jn{static ADMIN_USERNAME="admin";usersRestService=je(kn);getUser(t){return this.usersRestService.getUser(t).then(t=>Mn(t))}getUsers(){return this.usersRestService.getUsers().then(t=>t.map(t=>Mn(t)))}getAdminUser(){return this.usersRestService.getUser(jn.ADMIN_USERNAME).then(t=>Mn(t))}createUser(t){const e=Un(t);return this.usersRestService.createUser(t.username,e)}updateUser(t){const e=Un(t);return this.usersRestService.updateUser(t.username,e)}deleteUser(t){return this.usersRestService.deleteUser(t)}updateCurrentUser(t){const e=Un(t);return this.usersRestService.updateCurrentUser(t.username,e)}}const Vn=t=>new Ie({username:t.username,password:t.password,authorities:new xe(Kn(t.authorities)),appSettings:new Ae(t.appSettings),external:t.external}),Kn=t=>{if(!t)return[];const e=[...t];return e.some(t=>t===me.ROLE_REPO_MANAGER||t.startsWith(me.MAINTAIN_REPO_PREFIX))&&e.push(me.ROLE_REPO_MAINTAINER),e};class Gn{securityRestService=je(Bn);securityContextService=je(rn);usersService=je(jn);updateAuthenticatedUser(t){return this.usersService.updateCurrentUser(t)}getSecurityConfig(){return this.securityRestService.getSecurityConfig().then(t=>new Ne(t))}getFreeAccess(){return this.securityRestService.getFreeAccess().then(function(t){return Pe(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=Se(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=>Vn(t))}getAuthenticatedAdminUser(){return this.usersService.getAdminUser().then(t=>Ie.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 qn{securityService=je(Gn);securityContextService=je(rn);type=Cn.EXTERNAL;initialize(){return Promise.resolve(!0)}isAuthenticated(){return!!this.securityContextService.getAuthenticatedUser()}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}login(){throw new Ln}logout(){throw new Ln}isExternal(){return!0}}class $n{securityContextService=je(rn);authStorageService=je(wn);resolveStrategy(t){const e=this._resolveStrategy(t);return this.setStrategy(e),e}setStrategy(t){this.authStrategy=t}getAuthStrategy(){return this.authStrategy}_resolveStrategy(t){return t.isEnabled()?this.securityContextService.getAuthenticatedUser()?this.authStorageService.isGDBToken()?new _n:this.authStorageService.isOpenIDToken()?new Nn:new qn:t.openIdEnabled?new Nn:new _n:new Pn}}class Wn{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 zn{routePlugins=l.getPluginRegistry().get(Yr.NAME);getActiveRoute(t){const e=this.routePlugins.find(e=>this.routeToRegex(e.url).getRegex().test(t));return e?new $r(e):void 0}routeToRegex(t){const e=[],r=t.replace(/([().])/g,"\\$1").replace(/(\/)?:(\w+)(\*\?|[?*])?/g,function(t,r,i,n){const s="?"===n||"*?"===n,o="*"===n||"*?"===n;return e.push(i),r=r||"",(s?"(?:"+r:r+"(?:")+(o?"(.+?)":"([^/]+)")+(s?"?)?":")")}).replace(/([/$*])/g,"\\$1");return new Wn(new RegExp("^"+r+"(?:[?#]|$)"),new Gt(e))}}class Yn{securityContextService=je(rn);repositoryStorageService=je(Hi);repositoryContextService=je(Ui);repositoryAuthorityService=je(Mi);constructor(){this.permissionResolvers=this.initPermissionResolvers()}hasFreeAccess(){const t=this.getSecurityConfig();return!(!t?.isEnabled()||!t?.freeAccess?.enabled)}initializeFreeAccess(){const t=this.getSecurityConfig();if(t?.isEnabled()&&t?.isFreeAccessEnabled()){const e=(new Ie).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 Ie;e.username="overrideauth",e.setAuthorities(t.overrideAuth.authorities),e.setAppSettings(t.overrideAuth.appSettings),this.securityContextService.updateAuthenticatedUser(e)}}isAdmin(){return this.hasRole(me.ROLE_ADMIN)}isRepoManager(){return this.hasRole(me.ROLE_REPO_MANAGER)}isRepoMaintainer(){return this.hasRole(me.ROLE_REPO_MAINTAINER)}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=me.IS_AUTHENTICATED_FULLY===t,n=!!r?.authorities.hasAuthority(t);return i||n}canReadRepo(t){return this.hasRepoPermission(Zt.READ,t)}canWriteRepo(t){return this.hasRepoPermission(Zt.WRITE,t)}canMaintainRepo(t){return this.hasRepoPermission(Zt.MAINTAIN,t)}canReadGqlRepo(t){return this.hasGraphqlPermissions(Zt.GRAPHQL_READ,t)}canWriteGqlRepo(t){return this.hasGraphqlPermissions(Zt.GRAPHQL_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)}getRepositoryPermission(t){return this.permissionResolvers.find(e=>e.matches(t))?.permission??Zt.NONE}hasAuthority(){if(this.isAdminOrRepoManager())return!0;const t=je(zn).getActiveRoute(E());if(!t)return!1;if(!t.allowAuthorities)return!0;if(!je(Hi).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=l.getWindow().PluginRegistry.get(Yr.NAME),n=l.getWindow().PluginRegistry.get(zr.NAME);i.forEach(i=>{const s=n.flatMap(t=>t.items).filter(t=>t.role?.startsWith("ROLE_")).find(t=>i.url.includes(t.href));if(!s)return;const o=!r&&!e?.authorities.hasAuthority(s.role??"");t.setPageRestriction(i.url,o)}),this.securityContextService.updateRestrictedPages(t)}isAdminOrRepoManager(){return this.hasRole(me.ROLE_ADMIN)||this.hasRole(me.ROLE_REPO_MANAGER)}canExtendExternalUsers(){const t=this.getSecurityConfig();return!!t&&t.hasAdditionalAuthSource()&&t.hasLocalAdditionalAuthSources()}resolveAuthorities(t){if(!t)return[];const e=je(Hi).getRepositoryReference();return e?.id?[...t.map(t=>t.replace("{repoId}",s(e))),...t.map(t=>t.replace("{repoId}","*"))]:t}getSecurityConfig(){return je(rn).getSecurityConfig()}getAuthenticatedUser(){return je(rn).getAuthenticatedUser()}hasRepoPermission(t,e){if(!e||""===e.id)return!1;const r=this.getSecurityConfig(),i=this.getAuthenticatedUser();return!r?.isEnabled()&&!r?.hasOverrideAuth()||!!i&&(!!this.isAdminOrRepoManager()||!this.repositoryAuthorityService.isSystemRepository(e)&&(Zt.GRAPHQL_WRITE===t||Zt.GRAPHQL_READ===t?this.hasGraphqlPermissions(t,e):this.hasBasePermissions(t,e)))}hasBasePermissions(t,e){const r=this.repositoryAuthorityService.getLocationSpecificId(e),i=this.repositoryAuthorityService.getCurrentRepoAuthority(t,r),n=this.repositoryAuthorityService.getOverallRepoAuthority(t),s=this.getAuthenticatedUser();return!!(s?.authorities.hasAuthority(i)||s?.authorities.hasAuthority(n)||s?.authorities.hasWildcardAuthority(i))}hasGraphqlPermissions(t,e){if(!e||""===e.id)return!1;const r=t===Zt.GRAPHQL_WRITE?"WRITE":"READ",i=this.securityContextService.getAuthenticatedUser();if(!i)return!1;const n=this.repositoryAuthorityService.getLocationSpecificId(e),s=this.repositoryAuthorityService.getCurrentGqlRepoAuthority(r,n),o=this.repositoryAuthorityService.getOverallGqlRepoAuthority(r);return i.authorities.hasAuthority(s)||i.authorities.hasAuthority(o)||i.authorities.hasWildcardAuthority(s,!0)}initPermissionResolvers(){return[{priority:100,permission:Zt.MAINTAIN,matches:t=>this.isAdminOrRepoManager()||this.canMaintainRepo(t)},{priority:90,permission:Zt.GRAPHQL_WRITE,matches:t=>this.canWriteGqlRepo(t)},{priority:80,permission:Zt.GRAPHQL_READ,matches:t=>this.canReadGqlRepo(t)},{priority:70,permission:Zt.WRITE,matches:t=>this.canWriteRepo(t)},{priority:60,permission:Zt.READ,matches:t=>this.canReadRepo(t)}].sort((t,e)=>e.priority-t.priority)}}class Xn extends on{constructor(){super("Authentication strategy not set")}}class Jn extends qe{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 Qn{eventService=je(Tn);authStrategyResolver=je($n);authorizationService=je(Yn);securityContextService=je(rn);authenticationStorageService=je(wn);navigationContextService=je(Jn);isAuthenticationStrategySet(){return!!this.authStrategyResolver.getAuthStrategy()}getCurrentUser(){return this.getAuthenticationStrategy().fetchAuthenticatedUser()}async login(t){t?this.authStrategyResolver.setStrategy(new _n):this.authStrategyResolver.setStrategy(new Nn);const e=this.getAuthenticationStrategy(),r=await e.login(t);this.securityContextService.updateIsLoggedIn(!0),this.securityContextService.updateAuthenticatedUser(r),this.eventService.emit(new ge)}logout(){const t=this.getAuthenticationStrategy();this.authenticationStorageService.setAuthenticated(!1);const e=E();return t.logout().then(()=>{v()||this.navigationContextService.updateReturnUrl(e),this.securityContextService.updateIsLoggedIn(!1),this.authorizationService.hasFreeAccess()?(this.authorizationService.initializeFreeAccess(),this.eventService.emit(new ge)):(m("login"),this.eventService.emit(new de))})}isLoggedIn(){const t=this.securityContextService.getIsLoggedIn()??!1,e=je(rn).getAuthenticatedUser();return this.isSecurityEnabled()&&t&&!!e}isAuthenticated(){return this.getAuthenticationStrategy().isAuthenticated()}isExternalUser(){return this.getAuthenticationStrategy().isExternal()}isSecurityEnabled(){return!!this.getSecurityConfig()?.isEnabled()}getSecurityConfig(){return je(rn).getSecurityConfig()}getAuthenticationStrategy(){const t=this.authStrategyResolver.getAuthStrategy();if(!t)throw new Xn;return t}}class Zn extends on{constructor(t){super(t)}}class ts{static DEFAULT_PATH="/";static MILLISECONDS_PER_DAY=864e5;path=ts.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:n,httpOnly:s,sameSite:o}=t;return e&&this.setExpiration(e),this.setPath(r),i&&this.setDomain(i),n&&this.setSecure(),s&&this.setHttpOnly(),o&&this.setSameSite(o),this}setExpiration(t){if(!Number.isFinite(t))throw new Zn(`Invalid expiration value: ${t}`);const e=new Date(T.now()+t*ts.MILLISECONDS_PER_DAY);return this.expires=e.toUTCString(),this}setPath(t){return this.path=t||ts.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 es{read(){return l.getDocument().cookie}write(t){l.getDocument().cookie=t}}class rs{constructor(t){this.store=t??new es}get(t){return this.parseCookies()[t]}set(t,e,r={}){this.store.write(new ts(t,e,r).build())}remove(t){this.store.write(new ts(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 is extends Ei{NAMESPACE="tracking";COOKIE_CONSENT="cookieConsent";LEGACY_COOKIE_CONSENT="cookie-consent";logger=Ye.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 er(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 ns="_wb";class ss{cookieService=je(rs);timeProvider=T;get(){return this.cookieService.get(ns)}set(t){const e=`WB1.${t}.${this.timeProvider.now()}`;this.cookieService.set(ns,e,{expiration:400,sameSite:"Lax"})}setIfAbsent(t){this.get()||this.set(t)}remove(){this.cookieService.remove(ns)}}class os{cookieService=je(rs);isSettingUp=!1;setIfAbsent(){if(!this.isSettingUp&&!this.gtmScriptExists()&&(this.isSettingUp=!0,!this.gtmScriptExists())){l.getWindow().dataLayer&&(l.getWindow().dataLayer=[]);const t=l.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');",l.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(){l.getWindow().dataLayer&&(l.getWindow().dataLayer=[]);const t=l.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();l.getWindow().google_tag_manager&&delete l.getWindow().google_tag_manager,l.getWindow().google_tag_data&&delete l.getWindow().google_tag_data}gtmScriptExists(){const t=l.getDocument().getElementsByTagName("script");return Array.from(t).some(t=>t.src?.includes("googletagmanager"))}}const as="cookie-consent-changed-event";class cs{securityService=je(Gn);securityContextService=je(rn);authenticationService=je(Qn);authorizationService=je(Yn);trackingStorageService=je(is);licenseService=je(Qi);licenseContextService=je(Ji);installationCookieService=je(ss);googleAnalyticsCookieService=je(os);eventEmitter=new Ti;isTrackingAllowed(){return this.licenseService.isTrackableLicense()&&!l.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:as,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?er.fromJSON(t.appSettings.COOKIE_CONSENT):er.NOT_ACCEPTED_WITH_TRACKING():this.authorizationService.hasFreeAccess()?this.trackingStorageService.getCookieConsent()||er.NOT_ACCEPTED_WITH_TRACKING():er.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 er(t.appSettings.COOKIE_CONSENT):new er({thirdParty:!0,statistic:!0}),e.policyAccepted=!0,e.updatedAt=Date.now(),t.appSettings.COOKIE_CONSENT=e}}class us extends Ci{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 hs={[cr.CLUSTER_HEALTH]:0,[cr.BACKUP_AND_RESTORE]:1,[cr.IMPORT]:2,[cr.QUERIES]:3,[cr.UPDATES]:4},ls=t=>{if(!t?.status||!t.allRunningOperations)return new or({status:rr.INFORMATION,allRunningOperations:new ar([])});const e=t.allRunningOperations.map(t=>new dr({value:t.value||"",status:I(rr,t.status),type:I(cr,t.type)})),r=new ar(e);return r.sort((t,e)=>hs[t.type]-hs[e.type]),new or({status:I(rr,t.status),allRunningOperations:r})};class ps{monitoringRestService=je(us);async getOperations(t){const e=await this.monitoringRestService.getOperations(t);return ls(e)}deleteQuery(t,e){return this.monitoringRestService.deleteQuery(t,e)}}class ds extends on{constructor(){super("Class is not initializable")}}const gs={[ti.ERROR]:yr.ERROR,[ti.SUCCESS]:yr.SUCCESS,[ti.WARNING]:yr.WARNING,[ti.INFO]:yr.INFO};class fs{constructor(){throw new ds}static fromNotification(t){const e=this.notificationTypeToToastType(t.type);return new Er(e,t.code,{title:t.title,translationParams:this.toTranslationParams(t.parameters)})}static notificationTypeToToastType(t){return t?gs[t]:yr.INFO}static toTranslationParams(t){return t?Object.entries(t).map(([t,e])=>({key:t,value:String(e)})):[]}}class ms{eventEmitter=new Ti;notificationService=je(yn);constructor(){this.subscribeToNotificationEvents()}error(t,e){this.createToastElement(t,yr.ERROR,e)}info(t,e){this.createToastElement(t,yr.INFO,e)}success(t,e){this.createToastElement(t,yr.SUCCESS,e)}warning(t,e){this.createToastElement(t,yr.WARNING,e)}createToastElement(t,e,r){this.eventEmitter.emit({NAME:xr,payload:new Er(e,t,r)})}subscribeToNotificationEvents(){this.notificationService.onNotificationAdded(t=>{if(t.parameters?.[ri.SHOULD_TOAST]){const e=fs.fromNotification(t);this.createToastElement(e.message,e.type,e.config)}})}}class ys extends Ci{autocompleteRestPrefix="rest/autocomplete";search(t,e){return this.get(`${this.autocompleteRestPrefix}/query`,{params:{q:t},signal:e})}enabled(){return this.get(`${this.autocompleteRestPrefix}/enabled`)}}class Ss{autocompleteRestService=je(ys);async search(t,e){return(t=>{const e=t?.suggestions.map(t=>new Nr({id:Sr.hashCode(`${t.type}-${t.value}-${t.description}`),type:I(Dr,t.type),value:t.value,description:t.description}));return new Fr(new Pr(e||[]))})(await this.autocompleteRestService.search(t,e))}isAutocompleteEnabled(){return this.autocompleteRestService.enabled()}}class vs extends Ei{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 Es extends qe{AUTOCOMPLETE_ENABLED="isAutocompleteEnabled";updateAutocompleteEnabled(t){this.updateContextProperty(this.AUTOCOMPLETE_ENABLED,t),Me.get(vs).setEnabled(t)}onAutocompleteEnabledChanged(t){return this.subscribe(this.AUTOCOMPLETE_ENABLED,t)}}const xs=t=>{const e=(t?.results.bindings||[]).reduce((t,e)=>(t[e.prefix.value]=e.namespace.value,t),{});return new re(e)};class As extends Ci{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`)}downloadResultsAsFile(t,e,r,i){const n=Object.entries(e).filter(([,t])=>void 0!==t).map(([t,e])=>`${t}=${encodeURIComponent(e)}`).join("&");return this.post(`${this.REPOSITORIES_ENDPOINT}/${t}`,{responseType:"blob",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=utf-8",Accept:r,Link:i},body:n})}getRepositorySize(t){return this.get(`${this.REPOSITORIES_ENDPOINT}/${t}/size`)}executeSparqlQuery(t,e){return this.post(`${this.REPOSITORIES_ENDPOINT}/${t}`,{body:new URLSearchParams({query:e}),headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/sparql-results+json","X-GraphDB-Local-Consistency":"updating"}})}}class bs extends on{constructor(t){super(`Unexpected repository size value: "${t}"`)}}class ws{rdf4jRestService=je(As);getStatementsEndpoint(t){return this.rdf4jRestService.getStatementsEndpoint(t)}getSparqlEndpoint(t){return this.rdf4jRestService.getSparqlEndpoint(t)}async getRepositorySize(t){const e=await this.rdf4jRestService.getRepositorySize(t),r=Number(e);if(!Number.isFinite(r))throw new bs(e);return r}async downloadResultsAsFile(t,e,r,i){const n=await this.rdf4jRestService.downloadResultsAsFile(t,e,r,i);return await this.extractFileFromResponse(n)}executeSparqlQuery(t,e){return this.rdf4jRestService.executeSparqlQuery(t,e)}async extractFileFromResponse(t,e="download"){const r=t.headers["content-disposition"];return r?.includes("filename=")&&(e=r.split("filename=")[1].replace(/['"]/g,"")),{data:t.data,filename:e}}}class Is{rdf4jRestService=je(As);async getNamespaces(t){const e=await this.rdf4jRestService.getNamespaces(t);return xs(e)}}class Ts extends qe{NAMESPACES="namespaces";updateNamespaces(t){this.updateContextProperty(this.NAMESPACES,t)}onNamespacesChanged(t){return this.subscribe(this.NAMESPACES,t)}}class Rs extends Ei{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 Cs extends qe{APPLICATION_DATA_STATE="applicationDataLoaded";APPLICATIONS_STATE="applicationsState";APPLICATIONS_STATE_BEFORE_CHANGE="applicationsStateBeforeChange";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)}updateApplicationsState(t){this.updateContextProperty(this.APPLICATIONS_STATE,t)}onApplicationsStateChanged(t){return this.subscribe(this.APPLICATIONS_STATE,t)}getApplicationsState(){return this.getContextPropertyValue(this.APPLICATIONS_STATE)}updateApplicationsStateBeforeChange(t){this.updateContextProperty(this.APPLICATIONS_STATE_BEFORE_CHANGE,t)}onApplicationsStateBeforeChange(t){return this.subscribe(this.APPLICATIONS_STATE_BEFORE_CHANGE,t)}}class Ps extends Ci{configurationContextService=je($e);logger=Ye.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:`${x()}${t.entry}`;return await import(e)}catch(e){this.logger.warn(`Failed to load plugin ${t.name}:`,e)}}))}}class Fs{logger=Ye.logger;constructor(){this.pluginsRestService=Me.get(Ps)}async getPluginsManifest(){return(t=>{const e=t.plugins.map(t=>new Hr(t.entry,t.name));return new Ur(new Vr(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(l.getPluginRegistry()):this.logger.warn("Plugin module is missing the register method. Skipping registration.",t)})}}class Ns extends jr{}class Ds extends on{constructor(t){super(`Extension point "${t.name}" is already registered.`)}}class Os extends on{constructor(t){super(`Extension point "${t}" does not exist.`)}}class _s extends on{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 Ls{extensionPoints={};constructor(t={}){this.extensionPoints=t}registerExtensionPoint(t){if(this.extensionPoints[t.name])throw new Ds(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 Os(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 _s(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 Bs=JSON.parse('{"configUrl":"assets/configuration.default.json"}');class ks extends on{}class Hs extends Ci{async getConfiguration(){let t,e=Bs;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 ks(`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 Us{configurationRestService=je(Hs);configurationContextService=je($e);async getConfiguration(){const t=await this.configurationRestService.getConfiguration();return t&&this.configurationContextService.updateApplicationConfiguration(t),t}}const Ms=t=>{if(!t)return{items:[]};const e=je(Ui).getSelectedRepository();let r="";return e&&(r=`${Qt}=${e.id}&`),{items:t.map(t=>({id:t,href:`sparql-template/create?${r}templateID=${encodeURIComponent(t)}`}))}};class js extends Ci{static SPARQL_ENDPOINT="rest/sparql";static SAVED_QUERIES_ENDPOINT=`${js.SPARQL_ENDPOINT}/saved-queries`;getSavedQuery(t,e){const r={name:t};return e&&(r.owner=e),this.get(js.SAVED_QUERIES_ENDPOINT,{params:r})}async getSavedQueries(){return this.get(js.SAVED_QUERIES_ENDPOINT)}saveQuery(t){return this.post(js.SAVED_QUERIES_ENDPOINT,{body:t})}updateQuery(t,e){return this.put(js.SAVED_QUERIES_ENDPOINT,{params:{oldQueryName:t},body:e})}deleteQuery(t){return this.delete(js.SAVED_QUERIES_ENDPOINT,{params:{name:t}})}addKnownPrefixes(t){return this.post(`${js.SPARQL_ENDPOINT}/add-known-prefixes`,{body:t})}}const Vs=t=>{if(!t||!Array.isArray(t))return new ui;const e=je(rn),r=e.getAuthenticatedUser()?.username,i=t.map(t=>{const e=r!==t.owner;return new hi({queryName:t.name,query:t.body,owner:t.owner,isPublic:t.shared,readonly:e})});return new ui(i)};class Ks{sparqlRestService=je(js);async getSavedQuery(t,e){const r=await this.sparqlRestService.getSavedQuery(t,e);return Vs(r)}async getSavedQueries(){const t=await this.sparqlRestService.getSavedQueries();return Vs(t)}saveQuery(t){return this.sparqlRestService.saveQuery(t)}updateQuery(t,e){return this.sparqlRestService.updateQuery(t,e)}deleteQuery(t){return this.sparqlRestService.deleteQuery(t)}addKnownPrefixes(t){return this.sparqlRestService.addKnownPrefixes(t)}}class Gs extends Ei{NAMESPACE="sparqlEditor";logger=Ye.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 qs{postMessage(t,e="*"){l.getParentWindow().postMessage(t,e)}}class $s{static CURRENT_VERSION=1;preferences={};constructor(t){this.version=t?.version??$s.CURRENT_VERSION,this.preferences=t?.preferences??{}}getUserPreferences(t){return this.preferences[t]}setUserPreferences(t,e){this.preferences[t]=e}toString(){return JSON.stringify(this)}}class Ws extends Ei{NAMESPACE="userPreferences";USER_PREFERENCES="preferences";set(t,e){this.storeValue(t,e)}setUsersPreferences(t){this.set(this.USER_PREFERENCES,t.toString())}getPreferences(){const t=this.get(this.USER_PREFERENCES).getValue();if(!t)return new $s;try{return new $s(JSON.parse(t))}catch{return new $s}}}class zs extends qe{USER_PREFERENCES="userPreferences";getUserPreferences(){return this.getContextPropertyValue(this.USER_PREFERENCES)}updateUserPreferences(t){this.updateContextProperty(this.USER_PREFERENCES,t)}onUserPreferencesChanged(t){return this.subscribe(this.USER_PREFERENCES,t)}}class Ys{isSolrDeprecationBannerDismissed=!1;constructor(t={}){this.isSolrDeprecationBannerDismissed=t.isSolrDeprecationBannerDismissed??!1}}class Xs{static ANONYMOUS_USER="anonymous";userPreferencesStorageService=je(Ws);userPreferencesContextService=je(zs);securityContextService=je(rn);authenticationService=je(Qn);dismissSolrDeprecationBanner(){const t=this.getCurrentUserPreferences();t.isSolrDeprecationBannerDismissed=!0,this.userPreferencesContextService.updateUserPreferences(t),this.persistCurrentUserPreferences(t)}isSolrDeprecationBannerDismissed(){return this.userPreferencesContextService.getUserPreferences()?.isSolrDeprecationBannerDismissed??!1}loadUserPreferences(){const t=this.getCurrentUsername();if(!t)return;const e=this.loadCurrentUserPreferences(t)??new Ys;this.userPreferencesContextService.updateUserPreferences(e)}getCurrentUsername(){return this.authenticationService.isLoggedIn()?this.securityContextService.getAuthenticatedUser()?.toUser().username:Xs.ANONYMOUS_USER}loadCurrentUserPreferences(t){return this.userPreferencesStorageService.getPreferences().getUserPreferences(t)}getCurrentUserPreferences(){return this.userPreferencesContextService.getUserPreferences()??new Ys}persistCurrentUserPreferences(t){const e=this.getCurrentUsername();if(!e)return;const r=this.userPreferencesStorageService.getPreferences();r.setUserPreferences(e,t),this.userPreferencesStorageService.setUsersPreferences(r)}}var Js=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===Qs}(t)}(t)},Qs="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function Zs(t,e){return!1!==e.clone&&e.isMergeableObject(t)?io((r=t,Array.isArray(r)?[]:{}),t,e):t;var r}function to(t,e,r){return t.concat(e).map(function(t){return Zs(t,r)})}function eo(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 ro(t,e){try{return e in t}catch(t){return!1}}function io(t,e,r){(r=r||{}).arrayMerge=r.arrayMerge||to,r.isMergeableObject=r.isMergeableObject||Js,r.cloneUnlessOtherwiseSpecified=Zs;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)&&eo(t).forEach(function(e){i[e]=Zs(t[e],r)}),eo(e).forEach(function(n){(function(t,e){return ro(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,n)||(ro(t,n)&&r.isMergeableObject(e[n])?i[n]=function(t,e){if(!e.customMerge)return io;var r=e.customMerge(t);return"function"==typeof r?r:io}(n,r)(t[n],e[n],r):i[n]=Zs(e[n],r))}),i}(t,e,r):Zs(e,r)}io.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,r){return io(t,r,e)},{})};var no=io;function so(t){return t instanceof HTMLElement}function oo(t){return"function"==typeof t}function ao(t){return"string"==typeof t}function co(t){return void 0===t}class uo{on(t,e,r,i=!1){return co(this.bindings)&&(this.bindings={}),co(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 co(this.bindings)||co(this.bindings[t])||(co(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!co(this.bindings)&&this.bindings[t]&&this.bindings[t].forEach((r,i)=>{const{ctx:n,handler:s,once:o}=r,a=n||this;s.apply(a,e),o&&this.bindings[t].splice(i,1)}),this}}function ho(t){const e=Object.getOwnPropertyNames(t.constructor.prototype);for(let r=0;r<e.length;r++){const i=e[r],n=t[i];"constructor"!==i&&"function"==typeof n&&(t[i]=n.bind(t))}return t}function lo(t){return ao(t)&&""!==t?"-"!==t.charAt(t.length-1)?`${t}-`:t:""}function po(t){return null==t||!t.element||!t.on}function go(){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 fo(){return fo=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},fo.apply(this,arguments)}function mo(t,e){if(null==t)return{};var r,i,n={},s=Object.keys(t);for(i=0;i<s.length;i++)r=s[i],e.indexOf(r)>=0||(n[r]=t[r]);return n}const yo=Math.min,So=Math.max,vo=Math.round,Eo=Math.floor,xo=t=>({x:t,y:t}),Ao={left:"right",right:"left",bottom:"top",top:"bottom"},bo={start:"end",end:"start"};function wo(t,e,r){return So(t,yo(e,r))}function Io(t,e){return"function"==typeof t?t(e):t}function To(t){return t.split("-")[0]}function Ro(t){return t.split("-")[1]}function Co(t){return"x"===t?"y":"x"}function Po(t){return"y"===t?"height":"width"}function Fo(t){return["top","bottom"].includes(To(t))?"y":"x"}function No(t){return Co(Fo(t))}function Do(t){return t.replace(/start|end/g,t=>bo[t])}function Oo(t){return t.replace(/left|right|bottom|top/g,t=>Ao[t])}function _o(t){return"number"!=typeof t?function(t){return fo({top:0,right:0,bottom:0,left:0},t)}(t):{top:t,right:t,bottom:t,left:t}}function Lo(t){return fo({},t,{top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height})}const Bo=["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"],ko=["mainAxis","crossAxis","limiter"];function Ho(t,e,r){let{reference:i,floating:n}=t;const s=Fo(e),o=No(e),a=Po(o),c=To(e),u="y"===s,h=i.x+i.width/2-n.width/2,l=i.y+i.height/2-n.height/2,p=i[a]/2-n[a]/2;let d;switch(c){case"top":d={x:h,y:i.y-n.height};break;case"bottom":d={x:h,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:l};break;case"left":d={x:i.x-n.width,y:l};break;default:d={x:i.x,y:i.y}}switch(Ro(e)){case"start":d[o]-=p*(r&&u?-1:1);break;case"end":d[o]+=p*(r&&u?-1:1)}return d}async function Uo(t,e){var r;void 0===e&&(e={});const{x:i,y:n,platform:s,rects:o,elements:a,strategy:c}=t,{boundary:u="clippingAncestors",rootBoundary:h="viewport",elementContext:l="floating",altBoundary:p=!1,padding:d=0}=Io(e,t),g=_o(d),f=a[p?"floating"===l?"reference":"floating":l],m=Lo(await s.getClippingRect({element:null==(r=await(null==s.isElement?void 0:s.isElement(f)))||r?f:f.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:h,strategy:c})),y="floating"===l?fo({},o.floating,{x:i,y:n}):o.reference,S=await(null==s.getOffsetParent?void 0:s.getOffsetParent(a.floating)),v=await(null==s.isElement?void 0:s.isElement(S))&&await(null==s.getScale?void 0:s.getScale(S))||{x:1,y:1},E=Lo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({rect:y,offsetParent:S,strategy:c}):y);return{top:(m.top-E.top+g.top)/v.y,bottom:(E.bottom-m.bottom+g.bottom)/v.y,left:(m.left-E.left+g.left)/v.x,right:(E.right-m.right+g.right)/v.x}}const Mo=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:r,y:i,placement:n,rects:s,middlewareData:o}=e,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=Io(t,e),h={x:r,y:i},l=Fo(n),p=Co(l);let d=h[p],g=h[l];const f=Io(a,e),m="number"==typeof f?{mainAxis:f,crossAxis:0}:fo({mainAxis:0,crossAxis:0},f);if(c){const t="y"===p?"height":"width",e=s.reference[p]-s.floating[t]+m.mainAxis,r=s.reference[p]+s.reference[t]-m.mainAxis;d<e?d=e:d>r&&(d=r)}if(u){var y,S;const t="y"===p?"width":"height",e=["top","left"].includes(To(n)),r=s.reference[l]-s.floating[t]+(e&&(null==(y=o.offset)?void 0:y[l])||0)+(e?0:m.crossAxis),i=s.reference[l]+s.reference[t]+(e?0:(null==(S=o.offset)?void 0:S[l])||0)-(e?m.crossAxis:0);g<r?g=r:g>i&&(g=i)}return{[p]:d,[l]:g}}}};function jo(t){return Go(t)?(t.nodeName||"").toLowerCase():"#document"}function Vo(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function Ko(t){var e;return null==(e=(Go(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function Go(t){return t instanceof Node||t instanceof Vo(t).Node}function qo(t){return t instanceof Element||t instanceof Vo(t).Element}function $o(t){return t instanceof HTMLElement||t instanceof Vo(t).HTMLElement}function Wo(t){return"undefined"!=typeof ShadowRoot&&(t instanceof ShadowRoot||t instanceof Vo(t).ShadowRoot)}function zo(t){const{overflow:e,overflowX:r,overflowY:i,display:n}=Zo(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+r)&&!["inline","contents"].includes(n)}function Yo(t){return["table","td","th"].includes(jo(t))}function Xo(t){const e=Jo(),r=Zo(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 Jo(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function Qo(t){return["html","body","#document"].includes(jo(t))}function Zo(t){return Vo(t).getComputedStyle(t)}function ta(t){return qo(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function ea(t){if("html"===jo(t))return t;const e=t.assignedSlot||t.parentNode||Wo(t)&&t.host||Ko(t);return Wo(e)?e.host:e}function ra(t){const e=ea(t);return Qo(e)?t.ownerDocument?t.ownerDocument.body:t.body:$o(e)&&zo(e)?e:ra(e)}function ia(t,e){var r;void 0===e&&(e=[]);const i=ra(t),n=i===(null==(r=t.ownerDocument)?void 0:r.body),s=Vo(i);return n?e.concat(s,s.visualViewport||[],zo(i)?i:[]):e.concat(i,ia(i))}function na(t){const e=Zo(t);let r=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const n=$o(t),s=n?t.offsetWidth:r,o=n?t.offsetHeight:i,a=vo(r)!==s||vo(i)!==o;return a&&(r=s,i=o),{width:r,height:i,$:a}}function sa(t){return qo(t)?t:t.contextElement}function oa(t){const e=sa(t);if(!$o(e))return xo(1);const r=e.getBoundingClientRect(),{width:i,height:n,$:s}=na(e);let o=(s?vo(r.width):r.width)/i,a=(s?vo(r.height):r.height)/n;return o&&Number.isFinite(o)||(o=1),a&&Number.isFinite(a)||(a=1),{x:o,y:a}}const aa=xo(0);function ca(t){const e=Vo(t);return Jo()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:aa}function ua(t,e,r,i){void 0===e&&(e=!1),void 0===r&&(r=!1);const n=t.getBoundingClientRect(),s=sa(t);let o=xo(1);e&&(i?qo(i)&&(o=oa(i)):o=oa(t));const a=function(t,e,r){return void 0===e&&(e=!1),!(!r||e&&r!==Vo(t))&&e}(s,r,i)?ca(s):xo(0);let c=(n.left+a.x)/o.x,u=(n.top+a.y)/o.y,h=n.width/o.x,l=n.height/o.y;if(s){const t=Vo(s),e=i&&qo(i)?Vo(i):i;let r=t.frameElement;for(;r&&i&&e!==t;){const t=oa(r),e=r.getBoundingClientRect(),i=Zo(r),n=e.left+(r.clientLeft+parseFloat(i.paddingLeft))*t.x,s=e.top+(r.clientTop+parseFloat(i.paddingTop))*t.y;c*=t.x,u*=t.y,h*=t.x,l*=t.y,c+=n,u+=s,r=Vo(r).frameElement}}return Lo({width:h,height:l,x:c,y:u})}function ha(t){return ua(Ko(t)).left+ta(t).scrollLeft}function la(t,e,r){let i;if("viewport"===e)i=function(t,e){const r=Vo(t),i=Ko(t),n=r.visualViewport;let s=i.clientWidth,o=i.clientHeight,a=0,c=0;if(n){s=n.width,o=n.height;const t=Jo();(!t||t&&"fixed"===e)&&(a=n.offsetLeft,c=n.offsetTop)}return{width:s,height:o,x:a,y:c}}(t,r);else if("document"===e)i=function(t){const e=Ko(t),r=ta(t),i=t.ownerDocument.body,n=So(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=So(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let o=-r.scrollLeft+ha(t);const a=-r.scrollTop;return"rtl"===Zo(i).direction&&(o+=So(e.clientWidth,i.clientWidth)-n),{width:n,height:s,x:o,y:a}}(Ko(t));else if(qo(e))i=function(t,e){const r=ua(t,!0,"fixed"===e),i=r.top+t.clientTop,n=r.left+t.clientLeft,s=$o(t)?oa(t):xo(1);return{width:t.clientWidth*s.x,height:t.clientHeight*s.y,x:n*s.x,y:i*s.y}}(e,r);else{const r=ca(t);i=fo({},e,{x:e.x-r.x,y:e.y-r.y})}return Lo(i)}function pa(t,e){const r=ea(t);return!(r===e||!qo(r)||Qo(r))&&("fixed"===Zo(r).position||pa(r,e))}function da(t,e,r){const i=$o(e),n=Ko(e),s="fixed"===r,o=ua(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const c=xo(0);if(i||!i&&!s)if(("body"!==jo(e)||zo(n))&&(a=ta(e)),i){const t=ua(e,!0,s,e);c.x=t.x+e.clientLeft,c.y=t.y+e.clientTop}else n&&(c.x=ha(n));return{x:o.left+a.scrollLeft-c.x,y:o.top+a.scrollTop-c.y,width:o.width,height:o.height}}function ga(t,e){return $o(t)&&"fixed"!==Zo(t).position?e?e(t):t.offsetParent:null}function fa(t,e){const r=Vo(t);if(!$o(t))return r;let i=ga(t,e);for(;i&&Yo(i)&&"static"===Zo(i).position;)i=ga(i,e);return i&&("html"===jo(i)||"body"===jo(i)&&"static"===Zo(i).position&&!Xo(i))?r:i||function(t){let e=ea(t);for(;$o(e)&&!Qo(e);){if(Xo(e))return e;e=ea(e)}return null}(t)||r}const ma={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:r,strategy:i}=t;const n=$o(r),s=Ko(r);if(r===s)return e;let o={scrollLeft:0,scrollTop:0},a=xo(1);const c=xo(0);if((n||!n&&"fixed"!==i)&&(("body"!==jo(r)||zo(s))&&(o=ta(r)),$o(r))){const t=ua(r);a=oa(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:Ko,getClippingRect:function(t){let{element:e,boundary:r,rootBoundary:i,strategy:n}=t;const s=[..."clippingAncestors"===r?function(t,e){const r=e.get(t);if(r)return r;let i=ia(t).filter(t=>qo(t)&&"body"!==jo(t)),n=null;const s="fixed"===Zo(t).position;let o=s?ea(t):t;for(;qo(o)&&!Qo(o);){const e=Zo(o),r=Xo(o);r||"fixed"!==e.position||(n=null),(s?!r&&!n:!r&&"static"===e.position&&n&&["absolute","fixed"].includes(n.position)||zo(o)&&!r&&pa(t,o))?i=i.filter(t=>t!==o):n=e,o=ea(o)}return e.set(t,i),i}(e,this._c):[].concat(r),i],o=s[0],a=s.reduce((t,r)=>{const i=la(e,r,n);return t.top=So(i.top,t.top),t.right=yo(i.right,t.right),t.bottom=yo(i.bottom,t.bottom),t.left=So(i.left,t.left),t},la(e,o,n));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:fa,getElementRects:async function(t){let{reference:e,floating:r,strategy:i}=t;const n=this.getOffsetParent||fa,s=this.getDimensions;return{reference:da(e,await n(r),i),floating:fo({x:0,y:0},await s(r))}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){return na(t)},getScale:oa,isElement:qo,isRTL:function(t){return"rtl"===Zo(t).direction}};function ya(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 po(t)||(r.middleware.push(function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var r;const{placement:i,middlewareData:n,rects:s,initialPlacement:o,platform:a,elements:c}=e,u=Io(t,e),{mainAxis:h=!0,crossAxis:l=!0,fallbackPlacements:p,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:f=!0}=u,m=mo(u,Bo),y=To(i),S=To(o)===o,v=await(null==a.isRTL?void 0:a.isRTL(c.floating)),E=p||(S||!f?[Oo(o)]:function(t){const e=Oo(t);return[Do(t),e,Do(e)]}(o));p||"none"===g||E.push(...function(t,e,r,i){const n=Ro(t);let s=function(t,e,r){const i=["left","right"],n=["right","left"],s=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return r?e?n:i:e?i:n;case"left":case"right":return e?s:o;default:return[]}}(To(t),"start"===r,i);return n&&(s=s.map(t=>t+"-"+n),e&&(s=s.concat(s.map(Do)))),s}(o,f,g,v));const x=[o,...E],A=await Uo(e,m),w=[];let b=(null==(r=n.flip)?void 0:r.overflows)||[];if(h&&w.push(A[y]),l){const t=function(t,e,r){void 0===r&&(r=!1);const i=Ro(t),n=No(t),s=Po(n);let o="x"===n?i===(r?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Oo(o)),[o,Oo(o)]}(i,s,v);w.push(A[t[0]],A[t[1]])}if(b=[...b,{placement:i,overflows:w}],!w.every(t=>t<=0)){var T,I;const t=((null==(T=n.flip)?void 0:T.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:n}=e,s=Io(t,e),{mainAxis:o=!0,crossAxis:a=!1,limiter:c={fn:t=>{let{x:e,y:r}=t;return{x:e,y:r}}}}=s,u=mo(s,ko),h={x:r,y:i},l=await Uo(e,u),p=Fo(To(n)),d=Co(p);let g=h[d],f=h[p];if(o){const t="y"===d?"bottom":"right";g=wo(g+l["y"===d?"top":"left"],g,g-l[t])}if(a){const t="y"===p?"bottom":"right";f=wo(f+l["y"===p?"top":"left"],f,f-l[t])}const m=c.fn(fo({},e,{[d]:g,[p]:f}));return fo({},m,{data:{x:m.x-r,y:m.y-i}})}}}({limiter:Mo(),crossAxis:!0})),i&&r.middleware.push((t=>({name:"arrow",options:t,async fn(e){const{x:r,y:i,placement:n,rects:s,platform:o,elements:a}=e,{element:c,padding:u=0}=Io(t,e)||{};if(null==c)return{};const h=_o(u),l={x:r,y:i},p=No(n),d=Po(p),g=await o.getDimensions(c),f="y"===p,m=f?"top":"left",y=f?"bottom":"right",S=f?"clientHeight":"clientWidth",v=s.reference[d]+s.reference[p]-l[p]-s.floating[d],E=l[p]-s.reference[p],x=await(null==o.getOffsetParent?void 0:o.getOffsetParent(c));let A=x?x[S]:0;A&&await(null==o.isElement?void 0:o.isElement(x))||(A=a.floating[S]||s.floating[d]);const w=v/2-E/2,b=A/2-g[d]/2-1,T=yo(h[m],b),I=yo(h[y],b),R=T,C=A-g[d]-I,P=A/2-g[d]/2+w,F=wo(R,P,C),N=null!=Ro(n)&&P!=F&&s.reference[d]/2-(P<R?T:I)-g[d]/2<0?P<R?R-P:C-P:0;return{[p]:l[p]-N,data:{[p]:F,centerOffset:P-F+N}}}}))({element:i})),r.placement=t.on),no(e.options.floatingUIOptions||{},r)}(e,t),n=po(e);return n&&(r=document.body,t.shepherdElementComponent.getElement().classList.add("shepherd-centered")),t.cleanup=function(t,e,r,i){void 0===i&&(i={});const{ancestorScroll:n=!0,ancestorResize:s=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:c=!1}=i,u=sa(t),h=n||s?[...u?ia(u):[],...ia(e)]:[];h.forEach(t=>{n&&t.addEventListener("scroll",r,{passive:!0}),s&&t.addEventListener("resize",r)});const l=u&&a?function(t,e){let r,i=null;const n=Ko(t);function s(){clearTimeout(r),i&&i.disconnect(),i=null}return function o(a,c){void 0===a&&(a=!1),void 0===c&&(c=1),s();const{left:u,top:h,width:l,height:p}=t.getBoundingClientRect();if(a||e(),!l||!p)return;const d={rootMargin:-Eo(h)+"px "+-Eo(n.clientWidth-(u+l))+"px "+-Eo(n.clientHeight-(h+p))+"px "+-Eo(u)+"px",threshold:So(0,yo(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,fo({},d,{root:n.ownerDocument}))}catch(t){i=new IntersectionObserver(f,d)}i.observe(t)}(!0),s}(u,r):null;let p,d=-1,g=null;o&&(g=new ResizeObserver(t=>{let[i]=t;i&&i.target===u&&g&&(g.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{g&&g.observe(e)})),r()}),u&&!c&&g.observe(u),g.observe(e));let f=c?ua(t):null;return c&&function e(){const i=ua(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(),()=>{h.forEach(t=>{n&&t.removeEventListener("scroll",r),s&&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,n=fo({platform:ma},r),s=fo({},n.platform,{_c:i});return(async(t,e,r)=>{const{placement:i="bottom",strategy:n="absolute",middleware:s=[],platform:o}=r,a=s.filter(Boolean),c=await(null==o.isRTL?void 0:o.isRTL(e));let u=await o.getElementRects({reference:t,floating:e,strategy:n}),{x:h,y:l}=Ho(u,i,c),p=i,d={},g=0;for(let r=0;r<a.length;r++){const{name:s,fn:f}=a[r],{x:m,y,data:S,reset:v}=await f({x:h,y:l,initialPlacement:i,placement:p,strategy:n,middlewareData:d,rects:u,platform:o,elements:{reference:t,floating:e}});h=null!=m?m:h,l=null!=y?y:l,d=fo({},d,{[s]:fo({},d[s],S)}),v&&g<=50&&(g++,"object"==typeof v&&(v.placement&&(p=v.placement),v.rects&&(u=!0===v.rects?await o.getElementRects({reference:t,floating:e,strategy:n}):v.rects),({x:h,y:l}=Ho(u,p,c))),r=-1)}return{x:h,y:l,placement:p,strategy:n,middlewareData:d}})(t,e,fo({},n,{platform:s}))})(t,e.el,r).then(function(t,e){return({x:r,y:i,placement:n,middlewareData:s})=>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=n,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,s),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,n):t.cleanup()}),t.target=e.element,i}function Sa(){}function va(t,e){for(const r in e)t[r]=e[r];return t}function Ea(t){return t()}function xa(){return Object.create(null)}function Aa(t){t.forEach(Ea)}function ba(t){return"function"==typeof t}function wa(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function Ia(t,e){t.appendChild(e)}function Ta(t,e,r){t.insertBefore(e,r||null)}function Ra(t){t.parentNode&&t.parentNode.removeChild(t)}function Ca(t){return document.createElement(t)}function Pa(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Fa(t){return document.createTextNode(t)}function Na(){return Fa(" ")}function Da(t,e,r,i){return t.addEventListener(e,r,i),()=>t.removeEventListener(e,r,i)}function Oa(t,e,r){null==r?t.removeAttribute(e):t.getAttribute(e)!==r&&t.setAttribute(e,r)}const _a=["width","height"];function La(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===_a.indexOf(i)?t[i]=e[i]:Oa(t,i,e[i])}function Ba(t,e,r){t.classList[r?"add":"remove"](e)}let ka;function Ha(t){ka=t}function Ua(){if(!ka)throw new Error("Function called outside component initialization");return ka}function Ma(t){Ua().$$.after_update.push(t)}const ja=[],Va=[];let Ka=[];const Ga=[],qa=Promise.resolve();let $a=!1;function Wa(t){Ka.push(t)}const za=new Set;let Ya=0;function Xa(){if(0!==Ya)return;const t=ka;do{try{for(;Ya<ja.length;){const t=ja[Ya];Ya++,Ha(t),Ja(t.$$)}}catch(t){throw ja.length=0,Ya=0,t}for(Ha(null),ja.length=0,Ya=0;Va.length;)Va.pop()();for(let t=0;t<Ka.length;t+=1){const e=Ka[t];za.has(e)||(za.add(e),e())}Ka.length=0}while(ja.length);for(;Ga.length;)Ga.pop()();$a=!1,za.clear(),Ha(t)}function Ja(t){if(null!==t.fragment){t.update(),Aa(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(Wa)}}const Qa=new Set;let Za;function tc(){Za={r:0,c:[],p:Za}}function ec(){Za.r||Aa(Za.c),Za=Za.p}function rc(t,e){t&&t.i&&(Qa.delete(t),t.i(e))}function ic(t,e,r,i){if(t&&t.o){if(Qa.has(t))return;Qa.add(t),Za.c.push(()=>{Qa.delete(t),i&&(r&&t.d(1),i())}),t.o(e)}else i&&i()}function nc(t){t&&t.c()}function sc(t,e,r,i){const{fragment:n,after_update:s}=t.$$;n&&n.m(e,r),i||Wa(()=>{const e=t.$$.on_mount.map(Ea).filter(ba);t.$$.on_destroy?t.$$.on_destroy.push(...e):Aa(e),t.$$.on_mount=[]}),s.forEach(Wa)}function oc(t,e){const r=t.$$;null!==r.fragment&&(function(t){const e=[],r=[];Ka.forEach(i=>-1===t.indexOf(i)?e.push(i):r.push(i)),r.forEach(t=>t()),Ka=e}(r.after_update),Aa(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function ac(t,e,r,i,n,s,o,a=[-1]){const c=ka;Ha(t);const u=t.$$={fragment:null,ctx:[],props:s,update:Sa,not_equal:n,bound:xa(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:xa(),dirty:a,skip_bound:!1,root:e.target||c.$$.root};o&&o(u.root);let h=!1;if(u.ctx=r?r(t,e.props||{},(e,r,...i)=>{const s=i.length?i[0]:r;return u.ctx&&n(u.ctx[e],u.ctx[e]=s)&&(!u.skip_bound&&u.bound[e]&&u.bound[e](s),h&&function(t,e){-1===t.$$.dirty[0]&&(ja.push(t),$a||($a=!0,qa.then(Xa)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}(t,e)),r}):[],u.update(),h=!0,Aa(u.before_update),u.fragment=!!i&&i(u.ctx),e.target){if(e.hydrate){const t=(l=e.target,Array.from(l.childNodes));u.fragment&&u.fragment.l(t),t.forEach(Ra)}else u.fragment&&u.fragment.c();e.intro&&rc(t.$$.fragment),sc(t,e.target,e.anchor,e.customElement),Xa()}var l;Ha(c)}class cc{$destroy(){oc(this,1),this.$destroy=Sa}$on(t,e){if(!ba(e))return Sa;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 uc(t){let e,r,i,n,s;return{c(){e=Ca("button"),Oa(e,"aria-label",r=t[3]?t[3]:null),Oa(e,"class",i=`${t[1]||""} shepherd-button ${t[4]?"shepherd-button-secondary":""}`),e.disabled=t[2],Oa(e,"tabindex","0")},m(r,i){Ta(r,e,i),e.innerHTML=t[5],n||(s=Da(e,"click",function(){ba(t[0])&&t[0].apply(this,arguments)}),n=!0)},p(n,[s]){t=n,32&s&&(e.innerHTML=t[5]),8&s&&r!==(r=t[3]?t[3]:null)&&Oa(e,"aria-label",r),18&s&&i!==(i=`${t[1]||""} shepherd-button ${t[4]?"shepherd-button-secondary":""}`)&&Oa(e,"class",i),4&s&&(e.disabled=t[2])},i:Sa,o:Sa,d(t){t&&Ra(e),n=!1,s()}}}function hc(t,e,r){let i,n,s,o,a,c,{config:u,step:h}=e;function l(t){return oo(t)?t.call(h):t}return t.$$set=t=>{"config"in t&&r(6,u=t.config),"step"in t&&r(7,h=t.step)},t.$$.update=()=>{192&t.$$.dirty&&(r(0,i=u.action?u.action.bind(h.tour):null),r(1,n=u.classes),r(2,s=!!u.disabled&&l(u.disabled)),r(3,o=u.label?l(u.label):null),r(4,a=u.secondary),r(5,c=u.text?l(u.text):null))},[i,n,s,o,a,c,u,h]}class lc extends cc{constructor(t){super(),ac(this,t,hc,uc,wa,{config:6,step:7})}}function pc(t,e,r){const i=t.slice();return i[2]=e[r],i}function dc(t){let e,r,i=t[1],n=[];for(let e=0;e<i.length;e+=1)n[e]=gc(pc(t,i,e));const s=t=>ic(n[t],1,1,()=>{n[t]=null});return{c(){for(let t=0;t<n.length;t+=1)n[t].c();e=Fa("")},m(t,i){for(let e=0;e<n.length;e+=1)n[e]&&n[e].m(t,i);Ta(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 s=pc(t,i,o);n[o]?(n[o].p(s,r),rc(n[o],1)):(n[o]=gc(s),n[o].c(),rc(n[o],1),n[o].m(e.parentNode,e))}for(tc(),o=i.length;o<n.length;o+=1)s(o);ec()}},i(t){if(!r){for(let t=0;t<i.length;t+=1)rc(n[t]);r=!0}},o(t){n=n.filter(Boolean);for(let t=0;t<n.length;t+=1)ic(n[t]);r=!1},d(t){!function(t,e){for(let r=0;r<t.length;r+=1)t[r]&&t[r].d(e)}(n,t),t&&Ra(e)}}}function gc(t){let e,r;return e=new lc({props:{config:t[2],step:t[0]}}),{c(){nc(e.$$.fragment)},m(t,i){sc(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||(rc(e.$$.fragment,t),r=!0)},o(t){ic(e.$$.fragment,t),r=!1},d(t){oc(e,t)}}}function fc(t){let e,r,i=t[1]&&dc(t);return{c(){e=Ca("footer"),i&&i.c(),Oa(e,"class","shepherd-footer")},m(t,n){Ta(t,e,n),i&&i.m(e,null),r=!0},p(t,[r]){t[1]?i?(i.p(t,r),2&r&&rc(i,1)):(i=dc(t),i.c(),rc(i,1),i.m(e,null)):i&&(tc(),ic(i,1,1,()=>{i=null}),ec())},i(t){r||(rc(i),r=!0)},o(t){ic(i),r=!1},d(t){t&&Ra(e),i&&i.d()}}}function mc(t,e,r){let i,{step:n}=e;return t.$$set=t=>{"step"in t&&r(0,n=t.step)},t.$$.update=()=>{1&t.$$.dirty&&r(1,i=n.options.buttons)},[n,i]}class yc extends cc{constructor(t){super(),ac(this,t,mc,fc,wa,{step:0})}}function Sc(t){let e,r,i,n,s;return{c(){e=Ca("button"),r=Ca("span"),r.textContent="×",Oa(r,"aria-hidden","true"),Oa(e,"aria-label",i=t[0].label?t[0].label:"Close Tour"),Oa(e,"class","shepherd-cancel-icon"),Oa(e,"type","button")},m(i,o){Ta(i,e,o),Ia(e,r),n||(s=Da(e,"click",t[1]),n=!0)},p(t,[r]){1&r&&i!==(i=t[0].label?t[0].label:"Close Tour")&&Oa(e,"aria-label",i)},i:Sa,o:Sa,d(t){t&&Ra(e),n=!1,s()}}}function vc(t,e,r){let{cancelIcon:i,step:n}=e;return t.$$set=t=>{"cancelIcon"in t&&r(0,i=t.cancelIcon),"step"in t&&r(2,n=t.step)},[i,t=>{t.preventDefault(),n.cancel()},n]}class Ec extends cc{constructor(t){super(),ac(this,t,vc,Sc,wa,{cancelIcon:0,step:2})}}function xc(t){let e;return{c(){e=Ca("h3"),Oa(e,"id",t[1]),Oa(e,"class","shepherd-title")},m(r,i){Ta(r,e,i),t[3](e)},p(t,[r]){2&r&&Oa(e,"id",t[1])},i:Sa,o:Sa,d(r){r&&Ra(e),t[3](null)}}}function Ac(t,e,r){let{labelId:i,element:n,title:s}=e;return Ma(()=>{oo(s)&&r(2,s=s()),r(0,n.innerHTML=s,n)}),t.$$set=t=>{"labelId"in t&&r(1,i=t.labelId),"element"in t&&r(0,n=t.element),"title"in t&&r(2,s=t.title)},[n,i,s,function(t){Va[t?"unshift":"push"](()=>{n=t,r(0,n)})}]}class bc extends cc{constructor(t){super(),ac(this,t,Ac,xc,wa,{labelId:1,element:0,title:2})}}function wc(t){let e,r;return e=new bc({props:{labelId:t[0],title:t[2]}}),{c(){nc(e.$$.fragment)},m(t,i){sc(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||(rc(e.$$.fragment,t),r=!0)},o(t){ic(e.$$.fragment,t),r=!1},d(t){oc(e,t)}}}function Ic(t){let e,r;return e=new Ec({props:{cancelIcon:t[3],step:t[1]}}),{c(){nc(e.$$.fragment)},m(t,i){sc(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||(rc(e.$$.fragment,t),r=!0)},o(t){ic(e.$$.fragment,t),r=!1},d(t){oc(e,t)}}}function Tc(t){let e,r,i,n=t[2]&&wc(t),s=t[3]&&t[3].enabled&&Ic(t);return{c(){e=Ca("header"),n&&n.c(),r=Na(),s&&s.c(),Oa(e,"class","shepherd-header")},m(t,o){Ta(t,e,o),n&&n.m(e,null),Ia(e,r),s&&s.m(e,null),i=!0},p(t,[i]){t[2]?n?(n.p(t,i),4&i&&rc(n,1)):(n=wc(t),n.c(),rc(n,1),n.m(e,r)):n&&(tc(),ic(n,1,1,()=>{n=null}),ec()),t[3]&&t[3].enabled?s?(s.p(t,i),8&i&&rc(s,1)):(s=Ic(t),s.c(),rc(s,1),s.m(e,null)):s&&(tc(),ic(s,1,1,()=>{s=null}),ec())},i(t){i||(rc(n),rc(s),i=!0)},o(t){ic(n),ic(s),i=!1},d(t){t&&Ra(e),n&&n.d(),s&&s.d()}}}function Rc(t,e,r){let i,n,{labelId:s,step:o}=e;return t.$$set=t=>{"labelId"in t&&r(0,s=t.labelId),"step"in t&&r(1,o=t.step)},t.$$.update=()=>{2&t.$$.dirty&&(r(2,i=o.options.title),r(3,n=o.options.cancelIcon))},[s,o,i,n]}class Cc extends cc{constructor(t){super(),ac(this,t,Rc,Tc,wa,{labelId:0,step:1})}}function Pc(t){let e;return{c(){e=Ca("div"),Oa(e,"class","shepherd-text"),Oa(e,"id",t[1])},m(r,i){Ta(r,e,i),t[3](e)},p(t,[r]){2&r&&Oa(e,"id",t[1])},i:Sa,o:Sa,d(r){r&&Ra(e),t[3](null)}}}function Fc(t,e,r){let{descriptionId:i,element:n,step:s}=e;return Ma(()=>{let{text:t}=s.options;oo(t)&&(t=t.call(s)),so(t)?n.appendChild(t):r(0,n.innerHTML=t,n)}),t.$$set=t=>{"descriptionId"in t&&r(1,i=t.descriptionId),"element"in t&&r(0,n=t.element),"step"in t&&r(2,s=t.step)},[n,i,s,function(t){Va[t?"unshift":"push"](()=>{n=t,r(0,n)})}]}class Nc extends cc{constructor(t){super(),ac(this,t,Fc,Pc,wa,{descriptionId:1,element:0,step:2})}}function Dc(t){let e,r;return e=new Cc({props:{labelId:t[1],step:t[2]}}),{c(){nc(e.$$.fragment)},m(t,i){sc(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||(rc(e.$$.fragment,t),r=!0)},o(t){ic(e.$$.fragment,t),r=!1},d(t){oc(e,t)}}}function Oc(t){let e,r;return e=new Nc({props:{descriptionId:t[0],step:t[2]}}),{c(){nc(e.$$.fragment)},m(t,i){sc(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||(rc(e.$$.fragment,t),r=!0)},o(t){ic(e.$$.fragment,t),r=!1},d(t){oc(e,t)}}}function _c(t){let e,r;return e=new yc({props:{step:t[2]}}),{c(){nc(e.$$.fragment)},m(t,i){sc(e,t,i),r=!0},p(t,r){const i={};4&r&&(i.step=t[2]),e.$set(i)},i(t){r||(rc(e.$$.fragment,t),r=!0)},o(t){ic(e.$$.fragment,t),r=!1},d(t){oc(e,t)}}}function Lc(t){let e,r,i,n,s=!co(t[2].options.title)||t[2].options.cancelIcon&&t[2].options.cancelIcon.enabled,o=!co(t[2].options.text),a=Array.isArray(t[2].options.buttons)&&t[2].options.buttons.length,c=s&&Dc(t),u=o&&Oc(t),h=a&&_c(t);return{c(){e=Ca("div"),c&&c.c(),r=Na(),u&&u.c(),i=Na(),h&&h.c(),Oa(e,"class","shepherd-content")},m(t,s){Ta(t,e,s),c&&c.m(e,null),Ia(e,r),u&&u.m(e,null),Ia(e,i),h&&h.m(e,null),n=!0},p(t,[n]){4&n&&(s=!co(t[2].options.title)||t[2].options.cancelIcon&&t[2].options.cancelIcon.enabled),s?c?(c.p(t,n),4&n&&rc(c,1)):(c=Dc(t),c.c(),rc(c,1),c.m(e,r)):c&&(tc(),ic(c,1,1,()=>{c=null}),ec()),4&n&&(o=!co(t[2].options.text)),o?u?(u.p(t,n),4&n&&rc(u,1)):(u=Oc(t),u.c(),rc(u,1),u.m(e,i)):u&&(tc(),ic(u,1,1,()=>{u=null}),ec()),4&n&&(a=Array.isArray(t[2].options.buttons)&&t[2].options.buttons.length),a?h?(h.p(t,n),4&n&&rc(h,1)):(h=_c(t),h.c(),rc(h,1),h.m(e,null)):h&&(tc(),ic(h,1,1,()=>{h=null}),ec())},i(t){n||(rc(c),rc(u),rc(h),n=!0)},o(t){ic(c),ic(u),ic(h),n=!1},d(t){t&&Ra(e),c&&c.d(),u&&u.d(),h&&h.d()}}}function Bc(t,e,r){let{descriptionId:i,labelId:n,step:s}=e;return t.$$set=t=>{"descriptionId"in t&&r(0,i=t.descriptionId),"labelId"in t&&r(1,n=t.labelId),"step"in t&&r(2,s=t.step)},[i,n,s]}class kc extends cc{constructor(t){super(),ac(this,t,Bc,Lc,wa,{descriptionId:0,labelId:1,step:2})}}function Hc(t){let e;return{c(){e=Ca("div"),Oa(e,"class","shepherd-arrow"),Oa(e,"data-popper-arrow","")},m(t,r){Ta(t,e,r)},d(t){t&&Ra(e)}}}function Uc(t){let e,r,i,n,s,o,a,c,u=t[4].options.arrow&&t[4].options.attachTo&&t[4].options.attachTo.element&&t[4].options.attachTo.on&&Hc();i=new kc({props:{descriptionId:t[2],labelId:t[3],step:t[4]}});let h=[{"aria-describedby":n=co(t[4].options.text)?null:t[2]},{"aria-labelledby":s=t[4].options.title?t[3]:null},t[1],{role:"dialog"},{tabindex:"0"}],l={};for(let t=0;t<h.length;t+=1)l=va(l,h[t]);return{c(){e=Ca("div"),u&&u.c(),r=Na(),nc(i.$$.fragment),La(e,l),Ba(e,"shepherd-has-cancel-icon",t[5]),Ba(e,"shepherd-has-title",t[6]),Ba(e,"shepherd-element",!0)},m(n,s){Ta(n,e,s),u&&u.m(e,null),Ia(e,r),sc(i,e,null),t[13](e),o=!0,a||(c=Da(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?u||(u=Hc(),u.c(),u.m(e,r)):u&&(u.d(1),u=null);const c={};4&a&&(c.descriptionId=t[2]),8&a&&(c.labelId=t[3]),16&a&&(c.step=t[4]),i.$set(c),La(e,l=function(t,e){const r={},i={},n={$$scope:1};let s=t.length;for(;s--;){const o=t[s],a=e[s];if(a){for(const t in o)t in a||(i[t]=1);for(const t in a)n[t]||(r[t]=a[t],n[t]=1);t[s]=a}else for(const t in o)n[t]=1}for(const t in i)t in r||(r[t]=void 0);return r}(h,[(!o||20&a&&n!==(n=co(t[4].options.text)?null:t[2]))&&{"aria-describedby":n},(!o||24&a&&s!==(s=t[4].options.title?t[3]:null))&&{"aria-labelledby":s},2&a&&t[1],{role:"dialog"},{tabindex:"0"}])),Ba(e,"shepherd-has-cancel-icon",t[5]),Ba(e,"shepherd-has-title",t[6]),Ba(e,"shepherd-element",!0)},i(t){o||(rc(i.$$.fragment,t),o=!0)},o(t){ic(i.$$.fragment,t),o=!1},d(r){r&&Ra(e),u&&u.d(),oc(i),t[13](null),a=!1,c()}}}function Mc(t){return t.split(" ").filter(t=>!!t.length)}function jc(t,e,r){let i,n,s,{classPrefix:o,element:a,descriptionId:c,firstFocusableElement:u,focusableElements:h,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,h=a.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]')),r(8,u=h[0]),r(10,p=h[h.length-1])},Ua().$$.on_mount.push(f),Ma(()=>{s!==d.options.classes&&(function(t){if(ao(t)){const e=Mc(t);e.length&&a.classList.remove(...e)}}(s),s=d.options.classes,function(t){if(ao(t)){const e=Mc(t);e.length&&a.classList.add(...e)}}(s))}),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,u=t.firstFocusableElement),"focusableElements"in t&&r(9,h=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,n=d.options&&d.options.title))},[a,g,c,l,d,i,n,t=>{const{tour:e}=d;switch(t.keyCode){case 9:if(0===h.length){t.preventDefault();break}t.shiftKey?(document.activeElement===u||document.activeElement.classList.contains("shepherd-element"))&&(t.preventDefault(),p.focus()):document.activeElement===p&&(t.preventDefault(),u.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())}},u,h,p,o,()=>a,function(t){Va[t?"unshift":"push"](()=>{a=t,r(0,a)})}]}class Vc extends cc{constructor(t){super(),ac(this,t,jc,Uc,wa,{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 Kc extends uo{constructor(t,e={}){return super(t,e),this.tour=t,this.classPrefix=this.tour.options?lo(this.tour.options.classPrefix):"",this.styles=t.styles,this._resolvedAttachTo=null,ho(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,so(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(oo(r.element)&&(r.element=r.element.call(t)),ao(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 oo(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 Vc({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();oo(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:"",n=[...r.split(" "),...i.split(" ")],s=new Set(n);return Array.from(s).join(" ").trim()}_setOptions(t={}){let e=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions;e=no({},e||{}),this.options=Object.assign({arrow:!0},e,t,function(t,e){return{floatingUIOptions:no(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-${go()}`,r&&Object.keys(r).forEach(t=>{this.on(t,r[t],this)})}_setupElements(){co(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;(!co(t)&&r.currentTarget.matches(t)||i)&&e.tour.next()}}}(r,t);let n;try{n=document.querySelector(r)}catch(t){}if(!co(r)&&!n)return console.error(`No element was found for the selector supplied to advanceOn: ${r}`);n?(n.addEventListener(e,i),t.on("destroy",()=>n.removeEventListener(e,i))):(document.body.addEventListener(e,i,!0),t.on("destroy",()=>document.body.removeEventListener(e,i,!0)))}}(this),ya(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 Gc(t){let e,r,i,n,s;return{c(){e=Pa("svg"),r=Pa("path"),Oa(r,"d",t[2]),Oa(e,"class",i=(t[1]?"shepherd-modal-is-visible":"")+" shepherd-modal-overlay-container")},m(i,o){Ta(i,e,o),Ia(e,r),t[11](e),n||(s=Da(e,"touchmove",t[3]),n=!0)},p(t,[n]){4&n&&Oa(r,"d",t[2]),2&n&&i!==(i=(t[1]?"shepherd-modal-is-visible":"")+" shepherd-modal-overlay-container")&&Oa(e,"class",i)},i:Sa,o:Sa,d(r){r&&Ra(e),t[11](null),n=!1,s()}}}function qc(t){if(!t)return null;const e=t instanceof HTMLElement&&window.getComputedStyle(t).overflowY;return"hidden"!==e&&"visible"!==e&&t.scrollHeight>=t.clientHeight?t:qc(t.parentElement)}function $c(t,e,r){let{element:i,openingProperties:n}=e;go();let s,o,a=!1;function c(){r(4,n={width:0,height:0,x:0,y:0,r:0})}function u(){r(1,a=!1),d()}function h(t=0,e=0,i,s){if(s){const{y:o,height:a}=function(t,e){const r=t.getBoundingClientRect();let i=r.y||r.top,n=r.bottom||i+r.height;if(e){const t=e.getBoundingClientRect(),r=t.y||t.top,s=t.bottom||r+t.height;i=Math.max(i,r),n=Math.min(n,s)}return{y:i,height:Math.max(n-i,0)}}(s,i),{x:c,width:u,left:h}=s.getBoundingClientRect();r(4,n={width:u+2*t,height:a+2*t,x:(c||h)-t,y:o-t,r:e})}else c()}function l(){r(1,a=!0)}c();const p=t=>{t.preventDefault()};function d(){s&&(cancelAnimationFrame(s),s=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,n=t.openingProperties)},t.$$.update=()=>{16&t.$$.dirty&&r(2,o=function({width:t,height:e,x:r=0,y:i=0,r:n=0}){const{innerWidth:s,innerHeight:o}=window,{topLeft:a=0,topRight:c=0,bottomRight:u=0,bottomLeft:h=0}="number"==typeof n?{topLeft:n,topRight:n,bottomRight:n,bottomLeft:n}:n;return`M${s},${o}H0V0H${s}V${o}ZM${r+a},${i}a${a},${a},0,0,0-${a},${a}V${e+i-h}a${h},${h},0,0,0,${h},${h}H${t+r-u}a${u},${u},0,0,0,${u}-${u}V${i+c}a${c},${c},0,0,0-${c}-${c}Z`}(n))},[i,a,o,t=>{t.stopPropagation()},n,()=>i,c,u,h,function(t){d(),t.tour.options.useModalOverlay?(function(t){const{modalOverlayOpeningPadding:e,modalOverlayOpeningRadius:r}=t.options,i=qc(t.target),n=()=>{s=void 0,h(e,r,i,t.target),s=requestAnimationFrame(n)};n(),window.addEventListener("touchmove",p,{passive:!1})}(t),l()):u()},l,function(t){Va[t?"unshift":"push"](()=>{i=t,r(0,i)})}]}class Wc extends cc{constructor(t){super(),ac(this,t,$c,Gc,wa,{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 zc=new uo,Yc="undefined"==typeof window;class Xc{constructor(){}}Yc?Object.assign(zc,{Tour:Xc,Step:Xc}):Object.assign(zc,{Tour:class extends uo{constructor(t={}){return super(t),ho(this),this.options=Object.assign({},{exitOnEsc:!0,keyboardNavigation:!0},t),this.classPrefix=lo(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,zc.trigger(t,e)})})(t)}),this._setTourID(),this}addStep(t,e){let r=t;return r instanceof Kc?r.tour=this:r=new Kc(this,r),co(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 zc.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=ao(t)?this.getById(t):this.steps[t];r&&(this._updateStateBeforeShow(),oo(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}),zc.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()}so(this.focusedElBeforeOpen)&&this.focusedElBeforeOpen.focus()}_setupActiveTour(){this.trigger("active",{tour:this}),zc.activeTour=this}_setupModal(){this.modal=new Wc({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}--${go()}`}},Step:Kc});class Jc{logger=Ye.logger;languageContextService=je(Ni);productInfoContextService=je(Zi);RoutingUtil=this.getRoutingUtil();resolveDocumentationUrl=this._resolveDocumentationUrl.bind(this);translate=this._translate.bind(this);_translate(t,e,r={}){const i=this.languageContextService.getSelectedLanguage()??this.languageContextService.getDefaultLanguage();if("object"==typeof e){const t=e[i]??e[this.languageContextService.getDefaultLanguage()];return t?Vt.sanitize(this.applyParameters(t,r)):(this.logger.warn(`Missing translation for language [${i}] in message object`),"")}let n;if(t){const e=t[i];n=("object"==typeof e?e:void 0)??t}else n=this.languageContextService.getLanguageBundle()??this.languageContextService.getDefaultBundle();if(!n)return this.logger.warn("Translation bundle is not provided for translation key: "+JSON.stringify(e)),e?.toString()??"";let s=n[e];return!s&&t&&(s=(this.languageContextService.getLanguageBundle()??this.languageContextService.getDefaultBundle())?.[e]),s?Vt.sanitize(this.applyParameters(s,r)):(this.logger.warn(`Missing translation for [${e}] key`),e?.toString())}_resolveDocumentationUrl(t){const e=this.productInfoContextService.getProductInfo();return d.resolveDocumentationUrl(e?.shortVersion,t)}getRoutingUtil(){return{navigate:m,getCurrentRoute:b}}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,n)=>{let s=1e3*e;const o=setInterval(()=>{try{const e=document.querySelector(i);e?!r||this.isElementVisible(e)?(clearInterval(o),t(e)):(s-=100,s<0&&(clearInterval(o),this.logger.warn("Element is not visible: "+i),n(new Error("Element is not visible: "+i)))):(s-=100,s<0&&(clearInterval(o),this.logger.warn("Element is not found: "+i),n(new Error("Element is not found: "+i))))}catch(t){clearInterval(o),this.logger.error("Error when processing selector: "+i),this.logger.error(String(t)),n(t)}},100)})}getOrWaitFor(t,e=1,r=!0){const i=this.resolveSelector(t),n=document.querySelector(i);return!n||r&&!this.isElementVisible(n)?this.waitFor(t,e,r):Promise.resolve(n)}scrollToOffset(t){const e=("string"==typeof t?Jc.SCROLL_OFFSET_MAP[t]:void 0)??t;l.getWindow().scrollTo({top:e,behavior:"smooth"})}isElementVisible(t){const e=l.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:l.getWindow().innerHeight/2}}class Qc extends Ei{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 Zc{eventEmitter=new Ti;confirmCancel(t){return new Promise(e=>{this.eventEmitter.emit({NAME:wr,payload:new Ir(t,t=>e(t))})})}}const tu="nearest";class eu{logger=Ye.logger;toastrService=je(ms);guideApi=je(Jc);guideStorage=je(Qc);guideAutostarted=null;waitForApplicationMount=!1;beforeShowResolver=void 0;constructor(){je(Cs).onApplicationsStateChanged(()=>{this.waitForApplicationMount=!1,this.resolveBeforeShowPromise()}),je(Cs).onApplicationsStateBeforeChange(()=>{this.waitForApplicationMount=!0})}resolveBeforeShowPromise(){this.beforeShowResolver&&(this.beforeShowResolver(),delete this.beforeShowResolver)}onPause=()=>{};endSubscribers=[];startGuide(t,e,r,i=!1,n=!0){if(i&&this.guideStorage.isAutostartDisabled(t))return;if(this.guideAutostarted=i,n&&this.guideStorage.clearHistory(),!e)return;const s=this.createGuide(t);this.addGuideSteps(s,e),this.doStartGuide(s,r)}resumeGuide(t,e,r){this.guideStorage.clearPaused(),this.startGuide(t,e,r,!1,!1)}isActive(){return!!zc.activeTour&&!this.isPaused()}isPaused(){return this.guideStorage.isPaused()}getGuideId(){return this.guideStorage.getGuideId()}getCurrentStepId(){return this.guideStorage.getCurrentStepId()}isScrollingAllowed(){const t=zc.activeTour?.getCurrentStep()?.options?.allowScroll;return!this.isActive()||!!t}subscribeOnGuideEnd(t){return this.endSubscribers.push(t),()=>{const e=this.endSubscribers.indexOf(t);-1!==e&&this.endSubscribers.splice(e,1)}}subscribeToGuidePause(t){"function"==typeof t&&(this.onPause=t)}getPreviousStepFromHistory(t){const e=this.guideStorage.getPreviousStepIdFromHistory(t);return zc.activeTour?.steps.find(t=>t.id===e)}createGuide(t){return this.subscribeToGuideCanceled(),new zc.Tour({tourName:t,useModalOverlay:!0,confirmCancel:()=>this.confirmGuideCancel(),defaultStepOptions:{classes:"shadow-md bg-purple-dark",scrollTo:{behavior:"smooth",block:tu,inline:tu}}})}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,n=i.url;n&&n!==E()&&m(n);const s=i.attachTo;if(s?.element){const e=i.maxWaitTime;this.guideApi.getOrWaitFor(s.element,e).then(()=>t.show(r)).catch(e=>{this.logger.error(String(e)),this.toastrService.error(this.guideApi.translate(void 0,"guide.start.unexpected.error.message")),t.complete()})}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.endSubscribers.forEach(t=>t())};this.guideCancelSubscription||(this.guideCancelSubscription=zc.on("cancel",t)),this.guideCompleteSubscription||(this.guideCompleteSubscription=zc.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 n=this.toBaseGuideStep(t,r,()=>this.updateLocalStorage()),s=[];return r.skipPoint&&s.push(this.getSkipButton(t,r.skipButtonLabel)),!this.isDisablePreviousFlow(r)&&e&&s.push(this.getPreviousButton(t)),!this.isDisableNextFlow(r)&&i&&s.push(this.getNextButton(t,r,i)),n.buttons=s,n}toBaseGuideStep(t,e,r){let i;e.elementSelector&&(i={element:e.elementSelector,on:e.placement});const n=this.getTranslatedString(e.title??"");let s="";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)}),s="&nbsp;&mdash;&nbsp;"+t.outerHTML}const o="readonly"!==e.type,a=e.extraPadding||0,c={id:String(e.id),title:n+s,text:()=>{const t=this.toParagraph(this.getTranslatedString(e.content??""));let r="";if(e.extraContent){const t=this.getTranslatedString(e.extraContent,e);r=this.toParagraph(t,e.extraContentClass)}return 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){return async()=>{try{await new Promise(t=>{setTimeout(()=>{this.waitForApplicationMount&&!this.beforeShowResolver?this.beforeShowResolver=t:this.waitForApplicationMount||t()})})}catch(e){throw t.complete(),e}if("function"==typeof e.beforeShowPromise)try{return await e.beforeShowPromise(t,e)}catch(e){throw t.complete(),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=zc.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.getTranslatedString(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"),n=this.getNextButtonAction(t,e,r),s=this.getButton(i,n);return s.classes+=" shepherd-next-button",s}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 n=i.options.initPreviousStep;("function"==typeof n?n({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 n=r.options;if(n.forceReload||n.url&&n.url!==i.options.url){const t=n.url;t&&E()!==t&&m(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)&&m(r.url),t.next()})}}backToGuides(t){m("guides"),this.completeGuide(t)}async confirmGuideCancel(){const t=zc.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 je(Zc).confirmCancel(this.guideAutostarted??!1);if(i===br.CANCEL)return r&&t.show(r.id),!1;if(i===br.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=zc.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(),n=t.steps.findIndex(t=>t.id===i);r>n?this.guideStorage.addStepToHistory(e.options.id):n>r&&this.guideStorage.removeLastStepFromHistory();const s=t.options.tourName||"";this.guideStorage.saveStep(s,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=zc.activeTour?.steps;if(!r)return;const i=e.querySelector(".shepherd-content");if(!i)return;const n=document.createElement("div");n.className="shepherd-progress";const s=document.createElement("span");s.className="text-muted",s.innerText=this.guideApi.translate(void 0,"guide.total.progress",{n:String(r.indexOf(t)+1),nn:String(r.length)}),s.setAttribute("gdb-tooltip",this.guideApi.translate(void 0,"guide.total.progress.tooltip")),s.setAttribute("tooltip-placement","left"),n.appendChild(s),i.appendChild(n)}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 n=document.createElement("span");n.className="shepherd-step-type icon-"+r+" icon-1-25x",n.setAttribute("gdb-tooltip",this.guideApi.translate(void 0,"guide.step-type."+i)),n.setAttribute("tooltip-placement","bottom-right");const s=t.querySelector(".shepherd-header");s&&s.insertBefore(n,s.firstChild)}isDisablePreviousFlow(t){return t.disablePreviousFlow??!1}isDisableNextFlow(t){return t.disableNextFlow??!1}getTranslatedString(t,e){return"object"==typeof t?this.guideApi.translate(void 0,t,e):t??""}}class ru extends qe{PAUSED="isPaused";HAS_RUNNING_GUIDE="hasRunningGuide";updatePaused(t){this.updateContextProperty(this.PAUSED,t)}isPaused(){return this.getContextPropertyValue(this.PAUSED)}hasRunningGuide(){return this.getContextPropertyValue(this.HAS_RUNNING_GUIDE)??!1}updateHasRunningGuide(t){this.updateContextProperty(this.HAS_RUNNING_GUIDE,t)}onHasRunningGuideChanged(t){return this.subscribe(this.HAS_RUNNING_GUIDE,t)}}class iu extends Ci{GUIDES_ENDPOINT="rest/guides";getGuides(){return this.get(this.GUIDES_ENDPOINT)}}class nu{shepherdService=je(eu);toastrService=je(ms);repositoryContextService=je(Ui);guideApi=je(Jc);guideContextService=je(ru);guidesRestService=je(iu);startGuide(t,e,r,i=!1){const n=je(Ni).getLanguageBundle();if(!t)return void this.toastrService.error(this.guideApi.translate(n,"guides.error.guide-not-found"));const s=t.getRepositoryIdBase();if(s){const e=this.repositoryContextService.getRepositoryList();t.setRepositoryId(s);const r=1e3;for(let i=2;i<=r&&e.findRepository(t.getRepositoryId(),"",!0);i++)t.setRepositoryId(s+i)}t.setTranslatedGuideName(this.guideApi.translate(n,t.getName())),t.setTranslatedGuideDescription(this.guideApi.translate(n,t.getDescription()));const o=l.getPluginRegistry().get(Xr.NAME),a=t.toStepsDescriptions(o,e);a.forEach((t,e)=>{t.id=e,t.scrollOffset&&(t.scrollToHandler=()=>this.guideApi.scrollToOffset(t.scrollOffset))}),this.guideContextService.updateHasRunningGuide(!0);const c=this.shepherdService.subscribeOnGuideEnd(()=>{this.guideContextService.updateHasRunningGuide(!1),c()});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 Zr({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 su extends Ci{CONNECTORS_ENDPOINT="rest/connectors";checkConnector(t){return this.post(`${this.CONNECTORS_ENDPOINT}/check`,{body:t,headers:{"Content-Type":"text/plain"}})}}class ou extends Error{constructor(t){super(`Unknown connector command: ${t}`)}}class au{connectorsRestService=je(su);rdf4jRepositoryService=je(ws);async checkConnector(t){return(t=>{let e;if(t.command)if(t.hasSupport)if(fi.CREATE===t.command)e=(t=>{const e=[{name:t.name}];return new pi(di.SUCCESS,t.command,"created.connector",e)})(t);else if(fi.REPAIR===t.command)e=(t=>{const e=[{name:t.name}];return new pi(di.SUCCESS,t.command,"query.editor.repaired.connector",e)})(t);else{if(fi.DROP!==t.command)throw new ou(t.command);e=(t=>{const e=[{name:t.name}];return new pi(di.SUCCESS,t.command,"externalsync.delete.success.msg",e)})(t)}else e=(t=>{const e=[{connectorName:t.connectorName},{pluginName:t.pluginName}];return new pi(di.ERROR,t.command,"query.editor.inactive.plugin.warning.msg",e)})(t);else e=(t=>new pi(di.SUCCESS,t.command))(t);return e.iri=t.iri,e.name=t.name,e})(await this.connectorsRestService.checkConnector(t))}async getConnectorBuildStatus(t,e){const r=this.createConnectorStatusQuery(t);return(t=>{const e=t?.results?.bindings?.[0]?.status?.value;if(!e)return null;try{const t=JSON.parse(e);return new gi(t.status,t.processedEntities,t.estimatedEntities,t.indexedEntities,t.entitiesPerSecond,t.etaSeconds,t.repair)}catch{return null}})(await this.rdf4jRepositoryService.executeSparqlQuery(e,r))}createConnectorStatusQuery(t){const e=t.replace(/\/instance#.+$/,"#connectorStatus");return`SELECT ?status {\n\t<${t}> <${e}> ?status\n}`}}class cu extends Ci{static EXPLORE_GRAPH_ENDPOINT="rest/explore-graph";getGraphConfigs(){return this.get(`${cu.EXPLORE_GRAPH_ENDPOINT}/config`)}}const uu=t=>new mi({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??Si.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 hu{graphConfigRestService=je(cu);async getGraphConfigs(){return t=await this.graphConfigRestService.getGraphConfigs(),Array.isArray(t)?new yi(t.map(uu)):new yi;var t}}class lu extends ii{authStorage=Me.get(wn);repositoryStorageService=Me.get(Hi);securityContextService=Me.get(rn);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 pu extends ii{authenticationStorageService=je(wn);authenticationService=je(Qn);shouldProcess(t){return 401===t.status}process(t){return this.shouldRedirectToLogin(t.url)?(this.authenticationStorageService.clearAuthToken(),v()||(m("login"),l.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 du extends ii{securityContextService=je(rn);authenticationService=je(Qn);logger=Ye.logger;shouldProcess(t){return 403===t.status}process(t){const e=E();return this.logger.warn("Permission to page denied. Some errors in the console are normal"),this.updateRestrictionsForPage(e),this.shouldRedirectToLogin()&&m("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{Ae as AppSettings,he as ApplicationBeforeChange,le as ApplicationChanged,Cs as ApplicationLifecycleContextService,Lr as ApplicationMountState,ce as ApplicationMounted,Br as ApplicationNames,n as ApplicationSettings,Ai as ApplicationSettingsStorageService,ue as ApplicationUnmounted,kr as ApplicationsState,lu as AuthRequestInterceptor,Ce as AuthSettings,Fe as AuthSourceType,$n as AuthStrategyResolver,Ie as AuthenticatedUser,Qn as AuthenticationService,wn as AuthenticationStorageService,fe as AuthenticationType,me as Authority,xe as AuthorityList,Yn as AuthorizationService,Es as AutocompleteContextService,Fr as AutocompleteSearchResult,Ss as AutocompleteService,vs as AutocompleteStorageService,Qe as AvailableLanguagesList,pe as BeforeMountRouting,pi as BeforeUpdateQueryResult,di as BeforeUpdateQueryResultStatus,es as BrowserCookieStore,p as BuildUtil,h as ByteUtils,wr as CONFIRM_CANCEL_EVENT,as as COOKIE_CONSENT_CHANGED_EVENT,xr as CREATE_TOAST_EVENT,br as CancelDialogAction,_e as CapabilityList,$e as ConfigurationContextService,Hs as ConfigurationRestService,Us as ConfigurationService,Ir as ConfirmCancelPayload,gi as ConnectorBuildStatus,fi as ConnectorCommand,su as ConnectorsRestService,au as ConnectorsService,qe as ContextService,Ge as ContextSubscriptionManager,ts as CookieBuilder,er as CookieConsent,rs as CookieService,T as DateUtil,Zc as DialogService,on as ErrorBase,ie as Event,Ti as EventEmitter,ne as EventName,Tn as EventService,jr as ExtensionPoint,g as FibonacciGenerator,os as GoogleAnalyticsCookieService,mi as GraphConfig,yi as GraphConfigList,hu as GraphConfigService,Jc as GuideApi,ru as GuideContextService,Wr as GuidePlugin,Qc as GuideStorageService,iu as GuidesRestService,nu as GuidesService,Ri as HTTP_REQUEST_DONE_EVENT,Vt as HtmlUtil,ci as HttpErrorResponse,ii as HttpInterceptor,ni as HttpInterceptorList,si as HttpRequest,ai as HttpResponse,oi as HttpResponseBase,ss as InstallationCookieService,Zr as InteractiveGuide,Xr as InteractiveGuideExtensionPoint,Ii as InterceptorService,tr as LanguageConfig,Ni as LanguageContextService,Pi as LanguageRestService,_i as LanguageService,Fi as LanguageStorageService,Oe as License,Ji as LicenseContextService,Qi as LicenseService,_r as LifecycleState,Ei as LocalStorageService,xi as LocalStorageSubscriptionHandlerService,We as LoggerService,ze as Loggers,ge as Login,de as Logout,zr as MainMenuExtensionPoint,qr as MainMenuItem,Gr as MainMenuPlugin,Kt as Model,Gt as ModelList,us as MonitoringRestService,ps as MonitoringService,re as NamespaceMap,Ts as NamespacesContextService,Is as NamespacesService,Jn as NavigationContextService,se as NavigationEnd,oe as NavigationEndPayload,ae as NavigationStart,ei as Notification,ri as NotificationParam,yn as NotificationService,ti as NotificationType,o as ObjectUtil,ms as OntoToastrService,vn as OpenIdAuthFlowHandler,xn as OpenIdRestService,Rn as OpenIdService,bn as OpenIdTokenRefreshManager,An as OpenIdUrlBuilder,ln as OpenIdUtils,Te as OpenidSecurityConfig,nn as OpenidStorageService,dr as Operation,ur as OperationGroup,nr as OperationGroupSummary,sr as OperationGroupSummaryList,ar as OperationList,rr as OperationStatus,or as OperationStatusSummary,cr as OperationType,qs as ParentWindowMessageService,Kr as Plugin,Hr as PluginDefinition,Vr as PluginDefinitionList,Ls as PluginRegistry,Ur as PluginsManifest,Ps as PluginsRestService,Fs as PluginsService,Le as ProductInfo,Zi as ProductInfoContextService,en as ProductInfoService,Qt as REPOSITORY_ID_PARAM,ws as Rdf4jRepositoryService,As as Rdf4jRestService,$t as Repository,Mi as RepositoryAuthorityService,Ui as RepositoryContextService,zt as RepositoryList,te as RepositoryLocation,Gi as RepositoryLocationContextService,Ki as RepositoryLocationService,ee as RepositoryLocationType,Zt as RepositoryPermissionType,Li as RepositoryRestService,ki as RepositoryService,Yt as RepositorySizeInfo,Xt as RepositoryState,Hi as RepositoryStorageService,Jt as RepositoryType,Rs as ResourceSearchStorageService,De as RestrictedPages,Yr as RouteExtensionPoint,$r as RoutePlugin,bi as RuntimeConfigurationContextService,ir as STATUS_ORDER,hi as SavedQuery,ui as SavedQueryList,li as ScrollLocation,Cr as SearchButton,Rr as SearchButtonConfig,Tr as SearchButtonList,Ne as SecurityConfig,rn as SecurityContextService,Gn as SecurityService,Me as ServiceProvider,eu as ShepherdService,js as SparqlRestService,Ks as SparqlService,Gs as SparqlStorageService,Si as StartMode,Xe as StorageData,Je as StorageKey,qt as SubscriptionList,Nr as Suggestion,Pr as SuggestionList,Or as SuggestionSelectedPayload,Dr as SuggestionType,i as ThemeMode,wi as ThemeService,Jr as ThemesExtensionPoint,Er as ToastMessage,Ar as ToastMessageList,yr as ToastType,mr as ToastrConfig,gr as ToastrPosition,cs as TrackingService,is as TrackingStorageService,pu as UnauthenticatedInterceptor,du as UnauthorizedInterceptor,d as UriUtil,vi as UrlPathParams,we as User,zs as UserPreferencesContextService,Xs as UserPreferencesService,be as UserType,jn as UsersService,l as WindowService,A as getBasePath,b as getCurrentRoute,w as getLocationPathWithQueryParams,x as getOrigin,E as getPathName,s as getRepositoryIdWithLocation,S as isHomePage,v as isLoginPage,Pe as mapAuthSettingsResponseToModel,Vn as mapAuthenticatedUserResponseToModel,ve as mapGrantedAuthoritiesResponseToModel,xs as mapNamespaceResponseToModel,ls as mapOperationSummaryResponseToModel,Bi as mapRepositoryListResponseToModel,Vs as mapSavedQueryListResponseToModel,Ms as mapSparqlTemplatesResponseToModel,Un as mapUserModelToRequest,Mn as mapUserResponseToModel,m as navigate,f as navigateTo,Sn as notify,y as openInNewTab,je as service,I as toEnum};
2
+ var t={355(t,e){var r,i,n,s,o,a,c,u,h,l,p,d={userAgent:!1},g={},f=f||(r=Math,n=(i={}).lib={},s=n.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=n.WordArray=s.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,n=t.sigBytes;if(this.clamp(),i%4)for(var s=0;s<n;s++){var o=r[s>>>2]>>>24-s%4*8&255;e[i+s>>>2]|=o<<24-(i+s)%4*8}else for(s=0;s<n;s+=4)e[i+s>>>2]=r[s>>>2];return this.sigBytes+=n,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=s.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=[],n=0;n<r;n++){var s=e[n>>>2]>>>24-n%4*8&255;i.push((s>>>4).toString(16)),i.push((15&s).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)}},u=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n<r;n++){var s=e[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(s))}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)}},h=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},l=n.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,s=this.blockSize,a=n/(4*s),c=(a=t?r.ceil(a):r.max((0|a)-this._minBufferSize,0))*s,u=r.min(4*c,n);if(c){for(var h=0;h<c;h+=s)this._doProcessBlock(i,h);var l=i.splice(0,c);e.sigBytes-=u}return new o.init(l,u)},clone:function(){var t=s.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),n.Hasher=l.extend({cfg:s.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=[],n=0;n<e;n++){var s=t[n];r.push(s.high),r.push(s.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,n=0;n<i;n++)e[n]=e[n].clone();return t}})}(),f.lib.Cipher||function(){var t=(p=f).lib,e=t.Base,r=t.WordArray,i=t.BufferedBlockAlgorithm,n=p.enc.Base64,s=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 n=0;n<r;n++)t[e+n]^=i[n]},u=(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();u.Encryptor=u.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)}}),u.Decryptor=u.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,n=t.slice(e,e+i);r.decryptBlock(t,e),c.call(this,t,e,i),this._prevBlock=n}}),a=a.CBC=u,u=(p.pad={}).Pkcs7={pad:function(t,e){for(var i,n=(i=(i=4*e)-t.sigBytes%i)<<24|i<<16|i<<8|i,s=[],o=0;o<i;o+=4)s.push(n);i=r.create(s,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:u}),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 h=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(n)},parse:function(t){var e=(t=n.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 h.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 n=t.createEncryptor(r,i);return e=n.finalize(e),n=n.cfg,h.create({ciphertext:e,key:r,iv:n.iv,algorithm:t,mode:n.mode,padding:n.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,n){return n||(n=r.random(8)),t=s.create({keySize:e+i}).compute(t,n),i=r.create(t.words.slice(e),4*i),t.sigBytes=4*e,h.create({key:t,iv:i,salt:n})}},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=[],n=[],s=[],o=[],a=[],c=[],u=[],h=[],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 S=(S=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&S^99;i[m]=S,n[S]=m;var v=d[m],E=d[v],x=d[E],A=257*d[S]^16843008*S;s[m]=A<<24|A>>>8,o[m]=A<<16|A>>>16,a[m]=A<<8|A>>>24,c[m]=A,A=16843009*x^65537*E^257*v^16843008*m,u[S]=A<<24|A>>>8,h[S]=A<<16|A>>>16,l[S]=A<<8|A>>>24,p[S]=A,m?(m=v^d[d[d[x^v]]],y^=d[d[y]]):m=y=1}var b=[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),n=this._keySchedule=[],s=0;s<r;s++)if(s<e)n[s]=t[s];else{var o=n[s-1];s%e?6<e&&4==s%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^=b[s/e|0]<<24),n[s]=n[s-e]^o}for(t=this._invKeySchedule=[],e=0;e<r;e++)s=r-e,o=e%4?n[s]:n[s-4],t[e]=4>e||4>=s?o:u[i[o>>>24]]^h[i[o>>>16&255]]^l[i[o>>>8&255]]^p[i[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,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,u,h,l,p,n),r=t[e+1],t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,i,n,s,o,a){for(var c=this._nRounds,u=t[e]^r[0],h=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[u>>>24]^n[h>>>16&255]^s[l>>>8&255]^o[255&p]^r[d++],m=i[h>>>24]^n[l>>>16&255]^s[p>>>8&255]^o[255&u]^r[d++],y=i[l>>>24]^n[p>>>16&255]^s[u>>>8&255]^o[255&h]^r[d++];p=i[p>>>24]^n[u>>>16&255]^s[h>>>8&255]^o[255&l]^r[d++],u=f,h=m,l=y}f=(a[u>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^r[d++],m=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&u])^r[d++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[u>>>8&255]<<8|a[255&h])^r[d++],p=(a[p>>>24]<<24|a[u>>>16&255]<<16|a[h>>>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=(n=r.lib).WordArray,n=n.BlockCipher,s=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],u=[{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}],h=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],l=s.DES=n.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 n=t[i]=[],s=c[i];for(r=0;24>r;r++)n[r/6|0]|=e[(a[r]-1+s)%28]<<31-r%6,n[4+(r/6|0)]|=e[28+(a[r+24]-1+s)%28]<<31-r%6;for(n[0]=n[0]<<1|n[0]>>>31,r=1;7>r;r++)n[r]>>>=4*(r-1)+3;n[7]=n[7]<<5|n[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,n){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 s=0;16>s;s++){for(var o=n[s],a=this._lBlock,c=this._rBlock,l=0,p=0;8>p;p++)l|=u[p][((c^o[p])&h[p])>>>0];this._lBlock=c,this._rBlock=a^l}n=this._lBlock,this._lBlock=this._rBlock,this._rBlock=n,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=n._createHelper(l),s=s.TripleDES=n.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=n._createHelper(s)}(),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 n=0;n<r;n+=3)for(var s=(e[n>>>2]>>>24-n%4*8&255)<<16|(e[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|e[n+2>>>2]>>>24-(n+2)%4*8&255,o=0;4>o&&n+.75*o<r;o++)t.push(i.charAt(s>>>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;(n=i.charAt(64))&&-1!=(n=t.indexOf(n))&&(r=n);for(var n=[],s=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;n[s>>>2]|=(a|c)<<24-s%4*8,s++}return e.create(n,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,r,i,n,s,o){return((t=t+(e&r|~e&i)+n+o)<<s|t>>>32-s)+e}function r(t,e,r,i,n,s,o){return((t=t+(e&i|r&~i)+n+o)<<s|t>>>32-s)+e}function i(t,e,r,i,n,s,o){return((t=t+(e^r^i)+n+o)<<s|t>>>32-s)+e}function n(t,e,r,i,n,s,o){return((t=t+(r^(e|~i))+n+o)<<s|t>>>32-s)+e}for(var s=f,o=(c=s.lib).WordArray,a=c.Hasher,c=s.algo,u=[],h=0;64>h;h++)u[h]=4294967296*t.abs(t.sin(h+1))|0;c=c.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[c=s+o];t[c]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var c=t[s+0],h=(a=t[s+1],t[s+2]),l=t[s+3],p=t[s+4],d=t[s+5],g=t[s+6],f=t[s+7],m=t[s+8],y=t[s+9],S=t[s+10],v=t[s+11],E=t[s+12],x=t[s+13],A=t[s+14],b=t[s+15],w=e(w=o[0],R=o[1],I=o[2],T=o[3],c,7,u[0]),T=e(T,w,R,I,a,12,u[1]),I=e(I,T,w,R,h,17,u[2]),R=e(R,I,T,w,l,22,u[3]);w=e(w,R,I,T,p,7,u[4]),T=e(T,w,R,I,d,12,u[5]),I=e(I,T,w,R,g,17,u[6]),R=e(R,I,T,w,f,22,u[7]),w=e(w,R,I,T,m,7,u[8]),T=e(T,w,R,I,y,12,u[9]),I=e(I,T,w,R,S,17,u[10]),R=e(R,I,T,w,v,22,u[11]),w=e(w,R,I,T,E,7,u[12]),T=e(T,w,R,I,x,12,u[13]),I=e(I,T,w,R,A,17,u[14]),w=r(w,R=e(R,I,T,w,b,22,u[15]),I,T,a,5,u[16]),T=r(T,w,R,I,g,9,u[17]),I=r(I,T,w,R,v,14,u[18]),R=r(R,I,T,w,c,20,u[19]),w=r(w,R,I,T,d,5,u[20]),T=r(T,w,R,I,S,9,u[21]),I=r(I,T,w,R,b,14,u[22]),R=r(R,I,T,w,p,20,u[23]),w=r(w,R,I,T,y,5,u[24]),T=r(T,w,R,I,A,9,u[25]),I=r(I,T,w,R,l,14,u[26]),R=r(R,I,T,w,m,20,u[27]),w=r(w,R,I,T,x,5,u[28]),T=r(T,w,R,I,h,9,u[29]),I=r(I,T,w,R,f,14,u[30]),w=i(w,R=r(R,I,T,w,E,20,u[31]),I,T,d,4,u[32]),T=i(T,w,R,I,m,11,u[33]),I=i(I,T,w,R,v,16,u[34]),R=i(R,I,T,w,A,23,u[35]),w=i(w,R,I,T,a,4,u[36]),T=i(T,w,R,I,p,11,u[37]),I=i(I,T,w,R,f,16,u[38]),R=i(R,I,T,w,S,23,u[39]),w=i(w,R,I,T,x,4,u[40]),T=i(T,w,R,I,c,11,u[41]),I=i(I,T,w,R,l,16,u[42]),R=i(R,I,T,w,g,23,u[43]),w=i(w,R,I,T,y,4,u[44]),T=i(T,w,R,I,E,11,u[45]),I=i(I,T,w,R,b,16,u[46]),w=n(w,R=i(R,I,T,w,h,23,u[47]),I,T,c,6,u[48]),T=n(T,w,R,I,f,10,u[49]),I=n(I,T,w,R,A,15,u[50]),R=n(R,I,T,w,d,21,u[51]),w=n(w,R,I,T,E,6,u[52]),T=n(T,w,R,I,l,10,u[53]),I=n(I,T,w,R,S,15,u[54]),R=n(R,I,T,w,a,21,u[55]),w=n(w,R,I,T,m,6,u[56]),T=n(T,w,R,I,b,10,u[57]),I=n(I,T,w,R,g,15,u[58]),R=n(R,I,T,w,x,21,u[59]),w=n(w,R,I,T,p,6,u[60]),T=n(T,w,R,I,v,10,u[61]),I=n(I,T,w,R,h,15,u[62]),R=n(R,I,T,w,y,21,u[63]),o[0]=o[0]+w|0,o[1]=o[1]+R|0,o[2]=o[2]+I|0,o[3]=o[3]+T|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;r[n>>>5]|=128<<24-n%32;var s=t.floor(i/4294967296);for(r[15+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),r[14+(n+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++)n=r[i],r[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(c),s.HmacMD5=a._createHmacHelper(c)}(Math),function(){var t=f,e=(n=t.lib).WordArray,r=n.Hasher,i=[],n=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,n=r[0],s=r[1],o=r[2],a=r[3],c=r[4],u=0;80>u;u++){if(16>u)i[u]=0|t[e+u];else{var h=i[u-3]^i[u-8]^i[u-14]^i[u-16];i[u]=h<<1|h>>>31}h=(n<<5|n>>>27)+c+i[u],h=20>u?h+(1518500249+(s&o|~s&a)):40>u?h+(1859775393+(s^o^a)):60>u?h+((s&o|s&a|o&a)-1894007588):h+((s^o^a)-899497514),c=a,a=o,o=s<<30|s>>>2,s=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+s|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(n),t.HmacSHA1=r._createHmacHelper(n)}(),function(t){for(var e=f,r=(n=e.lib).WordArray,i=n.Hasher,n=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},c=2,u=0;64>u;){var h;t:{h=c;for(var l=t.sqrt(h),p=2;p<=l;p++)if(!(h%p)){h=!1;break t}h=!0}h&&(8>u&&(s[u]=a(t.pow(c,.5))),o[u]=a(t.pow(c,1/3)),u++),c++}var d=[];n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(s.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],n=r[1],s=r[2],a=r[3],c=r[4],u=r[5],h=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&u^~c&h)+o[p]+d[p],f=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&n^i&s^n&s),l=h,h=u,u=c,c=a+g|0,a=s,s=n,n=i,i=g+f|0}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0,r[5]=r[5]+u|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;return r[n>>>5]|=128<<24-n%32,r[14+(n+64>>>9<<4)]=t.floor(i/4294967296),r[15+(n+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(n),e.HmacSHA256=i._createHmacHelper(n)}(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=(s=e.x64).Word,n=s.WordArray,s=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();s=s.SHA512=r.extend({_doReset:function(){this._hash=new n.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],n=l[2],s=l[3],c=l[4],u=l[5],h=l[6],l=l[7],p=r.high,d=r.low,g=i.high,f=i.low,m=n.high,y=n.low,S=s.high,v=s.low,E=c.high,x=c.low,A=u.high,b=u.low,w=h.high,T=h.low,I=l.high,R=l.low,C=p,P=d,F=g,N=f,D=m,O=y,_=S,L=v,B=E,k=x,H=A,U=b,j=w,M=T,V=I,K=R,G=0;80>G;G++){var q=a[G];if(16>G)var $=q.high=0|t[e+2*G],W=q.low=0|t[e+2*G+1];else{$=((W=($=a[G-15]).high)>>>1|(z=$.low)<<31)^(W>>>8|z<<24)^W>>>7;var z=(z>>>1|W<<31)^(z>>>8|W<<24)^(z>>>7|W<<25),Y=((W=(Y=a[G-2]).high)>>>19|(X=Y.low)<<13)^(W<<3|X>>>29)^W>>>6,X=(X>>>19|W<<13)^(X<<3|W>>>29)^(X>>>6|W<<26),J=(W=a[G-7]).high,Q=(Z=a[G-16]).high,Z=Z.low;$=($=($=$+J+((W=z+W.low)>>>0<z>>>0?1:0))+Y+((W+=X)>>>0<X>>>0?1:0))+Q+((W+=Z)>>>0<Z>>>0?1:0),q.high=$,q.low=W}J=B&H^~B&j,Z=k&U^~k&M,q=C&F^C&D^F&D;var tt=P&N^P&O^N&O,et=(z=(C>>>28|P<<4)^(C<<30|P>>>2)^(C<<25|P>>>7),Y=(P>>>28|C<<4)^(P<<30|C>>>2)^(P<<25|C>>>7),(X=o[G]).high),rt=X.low;Q=V+((B>>>14|k<<18)^(B>>>18|k<<14)^(B<<23|k>>>9))+((X=K+((k>>>14|B<<18)^(k>>>18|B<<14)^(k<<23|B>>>9)))>>>0<K>>>0?1:0),V=j,K=M,j=H,M=U,H=B,U=k,B=_+(Q=(Q=(Q=Q+J+((X+=Z)>>>0<Z>>>0?1:0))+et+((X+=rt)>>>0<rt>>>0?1:0))+$+((X+=W)>>>0<W>>>0?1:0))+((k=L+X|0)>>>0<L>>>0?1:0)|0,_=D,L=O,D=F,O=N,F=C,N=P,C=Q+(q=z+q+((W=Y+tt)>>>0<Y>>>0?1:0))+((P=X+W|0)>>>0<X>>>0?1:0)|0}d=r.low=d+P,r.high=p+C+(d>>>0<P>>>0?1:0),f=i.low=f+N,i.high=g+F+(f>>>0<N>>>0?1:0),y=n.low=y+O,n.high=m+D+(y>>>0<O>>>0?1:0),v=s.low=v+L,s.high=S+_+(v>>>0<L>>>0?1:0),x=c.low=x+k,c.high=E+B+(x>>>0<k>>>0?1:0),b=u.low=b+U,u.high=A+H+(b>>>0<U>>>0?1:0),T=h.low=T+M,h.high=w+j+(T>>>0<M>>>0?1:0),R=l.low=R+K,l.high=I+V+(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(s),e.HmacSHA512=r._createHmacHelper(s)}(),function(){var t=f,e=(n=t.x64).Word,r=n.WordArray,i=(n=t.algo).SHA512,n=n.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(n),t.HmacSHA384=i._createHmacHelper(n)}(),function(){var t=f,e=(i=t.lib).WordArray,r=i.Hasher,i=t.algo,n=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]),s=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]),u=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 h,l,p,d,g,f,m,y,S,v,E,x=this._hash.words,A=(i=c.words,u.words),b=n.words,w=s.words,T=o.words,I=a.words;for(f=h=x[0],m=l=x[1],y=p=x[2],S=d=x[3],v=g=x[4],r=0;80>r;r+=1)E=h+t[e+b[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)<<T[r]|E>>>32-T[r])+g|0,h=g,g=d,d=p<<10|p>>>22,p=l,l=E,E=f+t[e+w[r]]|0,E=16>r?E+((m^(y|~S))+A[0]):32>r?E+((m&S|y&~S)+A[1]):48>r?E+(((m|~y)^S)+A[2]):64>r?E+((m&y|~m&S)+A[3]):E+((m^y^S)+A[4]),E=(E=(E|=0)<<I[r]|E>>>32-I[r])+v|0,f=v,v=S,S=y<<10|y>>>22,y=m,m=E;E=x[1]+p+S|0,x[1]=x[2]+d+v|0,x[2]=x[3]+g+f|0,x[3]=x[4]+h+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,n=4*i;r.sigBytes>n&&(r=t.finalize(r)),r.clamp();for(var s=this._oKey=r.clone(),o=this._iKey=r.clone(),a=s.words,c=o.words,u=0;u<i;u++)a[u]^=1549556828,c[u]^=909522486;s.sigBytes=o.sigBytes=n,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,n=(t=e.algo).HMAC,s=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,s=n.create(r.hasher,t),o=i.create(),a=i.create([1]),c=o.words,u=a.words,h=r.keySize;for(r=r.iterations;c.length<h;){var l=s.update(e).finalize(a);s.reset();for(var p=l.words,d=p.length,g=l,f=1;f<r;f++){g=s.finalize(g),s.reset();for(var m=g.words,y=0;y<d;y++)p[y]^=m[y]}o.concat(l),u[0]++}return o.sigBytes=4*h,o}});e.PBKDF2=function(t,e,r){return s.create(r).compute(t,e)}}();var m,y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function S(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 v(t){var e,r,i,n="",s=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e)(i=y.indexOf(t.charAt(e)))<0||(0==s?(n+=T(i>>2),r=3&i,s=1):1==s?(n+=T(r<<2|i>>4),r=15&i,s=2):2==s?(n+=T(r),n+=T(i>>2),r=3&i,s=3):(n+=T(r<<2|i>>4),n+=T(15&i),s=0));return 1==s&&(n+=T(r<<2)),n}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,n,s){for(var o=32767&e,a=e>>15;--s>=0;){var c=32767&this[t],u=this[t++]>>15,h=a*c+u*o;n=((c=o*c+((32767&h)<<15)+r[i]+(1073741823&n))>>>30)+(h>>>15)+a*u+(n>>>30),r[i++]=1073741823&c}return n},m=30):"Netscape"!=d.appName?(E.prototype.am=function(t,e,r,i,n,s){for(;--s>=0;){var o=e*this[t++]+r[i]+n;n=Math.floor(o/67108864),r[i++]=67108863&o}return n},m=26):(E.prototype.am=function(t,e,r,i,n,s){for(var o=16383&e,a=e>>14;--s>=0;){var c=16383&this[t],u=this[t++]>>14,h=a*c+u*o;n=((c=o*c+((16383&h)<<14)+r[i]+n)>>28)+(h>>14)+a*u,r[i++]=268435455&c}return n},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 A,b,w=new Array;for(A="0".charCodeAt(0),b=0;b<=9;++b)w[A++]=b;for(A="a".charCodeAt(0),b=10;b<36;++b)w[A++]=b;for(A="A".charCodeAt(0),b=10;b<36;++b)w[A++]=b;function T(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function I(t,e){var r=w[t.charCodeAt(e)];return null==r?-1:r}function R(t){var e=x();return e.fromInt(t),e}function C(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 P(t){this.m=t}function F(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 N(t,e){return t&e}function D(t,e){return t|e}function O(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 k(){}function H(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}P.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},P.prototype.revert=function(t){return t},P.prototype.reduce=function(t){t.divRemTo(this.m,null,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)},F.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},F.prototype.revert=function(t){var e=x();return t.copyTo(e),this.reduce(e),e},F.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)},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)},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,n=!1,s=0;--i>=0;){var o=8==r?255&t[i]:I(t,i);o<0?"-"==t.charAt(i)&&(n=!0):(n=!1,0==s?this[this.t++]=o:s+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=r)>=this.DB&&(s-=this.DB))}8==r&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),n&&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,n=this.DB-i,s=(1<<n)-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]>>n|a,a=(this[r]&s)<<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,n=this.DB-i,s=(1<<i)-1;e[0]=this[r]>>i;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&s)<<n,e[o-r]=this[o]>>i;i>0&&(e[this.t-r-1]|=(this.s&s)<<n),e.t=this.t-r,e.clamp()}},E.prototype.subTo=function(t,e){for(var r=0,i=0,n=Math.min(t.t,this.t);r<n;)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(),n=r.t;for(e.t=n+i.t;--n>=0;)e[n]=0;for(n=0;n<i.t;++n)e[n+r.t]=r.am(0,i[n],e,n,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 n=this.abs();if(n.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=x());var s=x(),o=this.s,a=t.s,c=this.DB-C(i[i.t-1]);c>0?(i.lShiftTo(c,s),n.lShiftTo(c,r)):(i.copyTo(s),n.copyTo(r));var u=s.t,h=s[u-1];if(0!=h){var l=h*(1<<this.F1)+(u>1?s[u-2]>>this.F2:0),p=this.FV/l,d=(1<<this.F1)/l,g=1<<this.F2,f=r.t,m=f-u,y=null==e?x():e;for(s.dlShiftTo(m,y),r.compareTo(y)>=0&&(r[r.t++]=1,r.subTo(y,r)),E.ONE.dlShiftTo(u,y),y.subTo(s,s);s.t<u;)s[s.t++]=0;for(;--m>=0;){var S=r[--f]==h?this.DM:Math.floor(r[f]*p+(r[f-1]+g)*d);if((r[f]+=s.am(0,S,r,m,0,u))<S)for(s.dlShiftTo(m,y),r.subTo(y,r);r[f]<--S;)r.subTo(y,r)}null!=e&&(r.drShiftTo(u,e),o!=a&&E.ZERO.subTo(e,e)),r.t=u,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(),n=e.convert(this),s=C(t)-1;for(n.copyTo(r);--s>=0;)if(e.sqrTo(r,i),(t&1<<s)>0)e.mulTo(i,n,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,n=!1,s="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(n=!0,s=T(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&&(n=!0),n&&(s+=T(r));return n?s:"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)+C(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 P(e):new F(e),this.exp(t,r)},E.ZERO=R(0),E.ONE=R(1),k.prototype.convert=H,k.prototype.revert=H,k.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},k.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,M,V,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],G=(1<<26)/K[K.length-1];function q(){this.i=0,this.j=0,this.S=new Array}function $(){!function(t){M[V++]^=255&t,M[V++]^=t>>8&255,M[V++]^=t>>16&255,M[V++]^=t>>24&255,V>=256&&(V-=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),n=x(),s=x(),o="";for(this.divRemTo(i,n,s);n.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,n.divRemTo(i,n,s);return s.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),n=!1,s=0,o=0,a=0;a<t.length;++a){var c=I(t,a);c<0?"-"==t.charAt(a)&&0==this.signum()&&(n=!0):(o=e*o+c,++s>=r&&(this.dMultiply(i),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),n&&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),D,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,n=7&t;i.length=1+(t>>3),e.nextBytes(i),n>0?i[0]&=(1<<n)-1:i[0]=0,this.fromString(i,256)}},E.prototype.bitwiseTo=function(t,e,r){var i,n,s=Math.min(t.t,this.t);for(i=0;i<s;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(n=t.s&this.DM,i=s;i<this.t;++i)r[i]=e(this[i],n);r.t=this.t}else{for(n=this.s&this.DM,i=s;i<t.t;++i)r[i]=e(n,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,n=Math.min(t.t,this.t);r<n;)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,n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(i=r.t-this.t;n<i;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t[n],r,n,0,e-n);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 n=x(),s=0;s<t;++s){n.fromInt(K[Math.floor(Math.random()*K.length)]);var o=n.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,n=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[n++]=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==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(e[n++]=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,N,e),e},E.prototype.or=function(t){var e=x();return this.bitwiseTo(t,D,e),e},E.prototype.xor=function(t){var e=x();return this.bitwiseTo(t,O,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,D)},E.prototype.clearBit=function(t){return this.changeBit(t,_)},E.prototype.flipBit=function(t){return this.changeBit(t,O)},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,n=t.bitLength(),s=R(1);if(n<=0)return s;r=n<18?1:n<48?3:n<144?4:n<768?5:6,i=n<8?new P(e):e.isEven()?new U(e):new F(e);var o=new Array,a=3,c=r-1,u=(1<<r)-1;if(o[1]=i.convert(this),r>1){var h=x();for(i.sqrTo(o[1],h);a<=u;)o[a]=x(),i.mulTo(h,o[a-2],o[a]),a+=2}var l,p,d=t.t-1,g=!0,f=x();for(n=C(t[d])-1;d>=0;){for(n>=c?l=t[d]>>n-c&u:(l=(t[d]&(1<<n+1)-1)<<c-n,d>0&&(l|=t[d-1]>>this.DB+n-c)),a=r;!(1&l);)l>>=1,--a;if((n-=a)<0&&(n+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)i.sqrTo(s,f),i.sqrTo(f,s),a-=2;a>0?i.sqrTo(s,f):(p=s,s=f,f=p),i.mulTo(f,o[l],s)}for(;d>=0&&!(t[d]&1<<n);)i.sqrTo(s,f),p=s,s=f,f=p,--n<0&&(n=this.DB-1,--d)}return i.revert(s)},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(),n=R(1),s=R(0),o=R(0),a=R(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(n.isEven()&&s.isEven()||(n.addTo(this,n),s.subTo(t,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);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&&n.subTo(o,n),s.subTo(a,s)):(i.subTo(r,i),e&&o.subTo(n,o),a.subTo(s,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 k)},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 n=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(n<s&&(s=n),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,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],n=e+1;n<K.length&&i<G;)i*=K[n++];for(i=r.modInt(i);e<n;)if(i%K[e++]==0)return!1}return r.millerRabin(t)},E.prototype.square=function(){var t=x();return this.squareTo(t),t},q.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},q.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==M){var W;if(M=new Array,V=0,void 0!==g&&(void 0!==g.crypto||void 0!==g.msCrypto)){var z=g.crypto||g.msCrypto;if(z.getRandomValues){var Y=new Uint8Array(32);for(z.getRandomValues(Y),W=0;W<32;++W)M[V++]=Y[W]}else if("Netscape"==d.appName&&d.appVersion<"5"){var X=g.crypto.random(32);for(W=0;W<X.length;++W)M[V++]=255&X.charCodeAt(W)}}for(;V<256;)W=Math.floor(65536*Math.random()),M[V++]=W>>>8,M[V++]=255&W;V=0,$()}function J(){if(null==j){for($(),(j=new q).init(M),V=0;V<M.length;++V)M[V]=0;V=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]=J()},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,n,s,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(n,16),this.dmp1=Z(s,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 n=new E(e,16),s=t/2-100,o=E.ONE.shiftLeft(s);;){for(;this.p=new E(t-i,1,r),0!=this.p.subtract(E.ONE).gcd(n).compareTo(E.ONE)||!this.p.isProbablePrime(10););for(;this.q=new E(i,1,r),0!=this.q.subtract(E.ONE).gcd(n).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()<s||c.compareTo(o)<=0)){var u=this.p.subtract(E.ONE),h=this.q.subtract(E.ONE),l=u.multiply(h);if(0==l.gcd(n).compareTo(E.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=n.modInverse(l),this.dmp1=this.d.mod(u),this.dmq1=this.d.mod(h),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"),n=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),r.square()),a=o.multiply(r),c=n.multiply(o),u=e.square().multiply(this.z),h=u.subtract(c.shiftLeft(1)).multiply(t.z).subtract(a).multiply(r).mod(this.curve.q),l=c.multiply(i).multiply(e).subtract(s.multiply(a)).subtract(u.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(h),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),n=i.multiply(r).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);E.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(i).mod(this.curve.q),c=o.multiply(t).multiply(e).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(o.square().multiply(o)).mod(this.curve.q),u=i.square().multiply(i).shiftLeft(3).mod(this.curve.q);return new rt(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(c),u)},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")),n=this.negate(),s=this,o=this.curve.q.subtract(t),a=o.multiply(new E("3")),c=new rt(this.curve,this.x,this.y),u=c.negate();for(e=i.bitLength()-2;e>0;--e){s=s.twice();var h=i.testBit(e);h!=r.testBit(e)&&(s=s.add(h?this:n))}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:u))}return s},rt.prototype.multiplyTwo=function(t,e,r){var i;i=t.bitLength()>r.bitLength()?t.bitLength()-1:r.bitLength()-1;for(var n=this.curve.getInfinity(),s=this.add(e);i>=0;)n=n.twice(),t.testBit(i)?n=r.testBit(i)?n.add(s):n.add(this):r.testBit(i)&&(n=n.add(e)),--i;return n},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(),n=this.getB(),s=r.square().add(i).multiply(r).add(n).sqrt();return"03"==e&&(s=s.negate()),new rt(this,r,s);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(),n=e(r,32);return t?i.isEven()?n.unshift(2):n.unshift(3):(n.unshift(4),n=n.concat(e(i,32))),n},rt.decodeFrom=function(t,e){e[0];var r=e.length-1,i=e.slice(1,1+r/2),n=e.slice(1+r/2,1+r);i.unshift(0),n.unshift(0);var s=new E(i),o=new E(n);return new rt(t,t.fromBigInteger(s),t.fromBigInteger(o))},rt.decodeFromHex=function(t,e){e.substr(0,2);var r=e.length-2,i=e.substr(2,r/2),n=e.substr(2+r/2,r/2),s=new E(i,16),o=new E(n,16);return new rt(t,t.fromBigInteger(s),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),n=r.multiply(this.x.subtract(i)).subtract(this.y);return new rt(this.curve,i,n)},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)),n=r.multiply(this.x.subtract(i)).subtract(this.y);return new rt(this.curve,i,n)},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")),n=this.negate(),s=this;for(e=i.bitLength()-2;e>0;--e){s=s.twice();var o=i.testBit(e);o!=r.testBit(e)&&(s=s.add2D(o?this:n))}return s},rt.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),i=this.curve.getB().toBigInteger(),n=this.curve.getQ(),s=e.multiply(e).mod(n),o=t.multiply(t).multiply(t).add(r.multiply(t)).add(i).mod(n);return s.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 nt=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 n=new String(""),s=Object.hasOwnProperty;return function(r,o){var a,c,u=r.match(t),h=u[0],l=!1;"{"===h?a={}:"["===h?a=[]:(a=[],l=!0);for(var p=[a],d=1-l,g=u.length;d<g;++d){var f;switch((h=u[d]).charCodeAt(0)){default:(f=p[0])[c||f.length]=+h,c=void 0;break;case 34:if(-1!==(h=h.substring(1,h.length-1)).indexOf("\\")&&(h=h.replace(e,i)),f=p[0],!c){if(!(f instanceof Array)){c=h||n;break}c=f.length}f[c]=h,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 n in r)if(s.call(r,n)&&r!==t){var a=m(r,n);void 0!==a?r[n]=a:(i||(i=[]),i.push(n))}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!==st&&st||(st={}),void 0!==st.asn1&&st.asn1||(st.asn1={}),st.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 kt(t)},this.getPEMStringFromHex=function(t,e){return Et(t,e)},this.newObject=function(t){var e=st.asn1,r=e.ASN1Object,i=e.DERBoolean,n=e.DERInteger,s=e.DERBitString,o=e.DEROctetString,a=e.DERNull,c=e.DERObjectIdentifier,u=e.DEREnumerated,h=e.DERUTF8String,l=e.DERNumericString,p=e.DERPrintableString,d=e.DERTeletexString,g=e.DERIA5String,f=e.DERUTCTime,m=e.DERGeneralizedTime,y=e.DERVisibleString,S=e.DERBMPString,v=e.DERSequence,E=e.DERSet,x=e.DERTaggedObject,A=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var b=Object.keys(t);if(1!=b.length)throw new Error("key of param shall be only one.");var w=b[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+w+":"))throw new Error("undefined key: "+w);if("bool"==w)return new i(t[w]);if("int"==w)return new n(t[w]);if("bitstr"==w)return new s(t[w]);if("octstr"==w)return new o(t[w]);if("null"==w)return new a(t[w]);if("oid"==w)return new c(t[w]);if("enum"==w)return new u(t[w]);if("utf8str"==w)return new h(t[w]);if("numstr"==w)return new l(t[w]);if("prnstr"==w)return new p(t[w]);if("telstr"==w)return new d(t[w]);if("ia5str"==w)return new g(t[w]);if("utctime"==w)return new f(t[w]);if("gentime"==w)return new m(t[w]);if("visstr"==w)return new y(t[w]);if("bmpstr"==w)return new S(t[w]);if("asn1"==w)return new r(t[w]);if("seq"==w){for(var T=t[w],I=[],R=0;R<T.length;R++){var C=A(T[R]);I.push(C)}return new v({array:I})}if("set"==w){for(T=t[w],I=[],R=0;R<T.length;R++)C=A(T[R]),I.push(C);return new E({array:I})}if("tag"==w){var P=t[w];if("[object Array]"===Object.prototype.toString.call(P)&&3==P.length){var F=A(P[2]);return new x({tag:P[0],explicit:P[1],obj:F})}return new x(P)}},this.jsonToASN1HEX=function(t){return this.newObject(t).tohex()}},st.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),i=(e=Math.floor(r/40)+"."+r%40,""),n=2;n<t.length;n+=2){var s=("00000000"+parseInt(t.substr(n,2),16).toString(2)).slice(-8);i+=s.substr(1,7),"0"==s.substr(0,1)&&(e=e+"."+new E(i,2).toString(10),i="")}return e},st.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),n=7-i.length%7;7==n&&(n=0);for(var s="",o=0;o<n;o++)s+="0";for(i=s+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="",n=t.split("."),s=40*parseInt(n[0])+parseInt(n[1]);i+=e(s),n.splice(0,2);for(var o=0;o<n.length;o++)i+=r(n[o]);return i},st.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)},st.asn1.DERAbstractString=function(t){st.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))},Mt(st.asn1.DERAbstractString,st.asn1.ASN1Object),st.asn1.DERAbstractTime=function(t){st.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,n=this.localDateToUTC(t),s=String(n.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+i(String(n.getMonth()+1),2)+i(String(n.getDate()),2)+i(String(n.getHours()),2)+i(String(n.getMinutes()),2)+i(String(n.getSeconds()),2);if(!0===r){var a=n.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,n,s){var o=new Date(Date.UTC(t,e-1,r,i,n,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},Mt(st.asn1.DERAbstractTime,st.asn1.ASN1Object),st.asn1.DERAbstractStructured=function(t){st.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)},Mt(st.asn1.DERAbstractStructured,st.asn1.ASN1Object),st.asn1.DERBoolean=function(t){st.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},Mt(st.asn1.DERBoolean,st.asn1.ASN1Object),st.asn1.DERInteger=function(t){st.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var e=kt;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)},Mt(st.asn1.DERInteger,st.asn1.ASN1Object),st.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=st.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.tohex()}st.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 n=t.substr(i,8),s=parseInt(n,2).toString(16);1==s.length&&(s="0"+s),r+=s}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))},Mt(st.asn1.DERBitString,st.asn1.ASN1Object),st.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=st.asn1.ASN1Util.newObject(t.obj);t.hex=e.tohex()}st.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Mt(st.asn1.DEROctetString,st.asn1.DERAbstractString),st.asn1.DERNull=function(){st.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Mt(st.asn1.DERNull,st.asn1.ASN1Object),st.asn1.DERObjectIdentifier=function(t){st.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),n=7-i.length%7;7==n&&(n=0);for(var s="",o=0;o<n;o++)s+="0";for(i=s+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="",n=t.split("."),s=40*parseInt(n[0],10)+parseInt(n[1],10);i+=e(s),n.splice(0,2);for(var o=0;o<n.length;o++)i+=r(n[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=st.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)},Mt(st.asn1.DERObjectIdentifier,st.asn1.ASN1Object),st.asn1.DEREnumerated=function(t){st.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=kt(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))},Mt(st.asn1.DEREnumerated,st.asn1.ASN1Object),st.asn1.DERUTF8String=function(t){st.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Mt(st.asn1.DERUTF8String,st.asn1.DERAbstractString),st.asn1.DERNumericString=function(t){st.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Mt(st.asn1.DERNumericString,st.asn1.DERAbstractString),st.asn1.DERPrintableString=function(t){st.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Mt(st.asn1.DERPrintableString,st.asn1.DERAbstractString),st.asn1.DERTeletexString=function(t){st.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Mt(st.asn1.DERTeletexString,st.asn1.DERAbstractString),st.asn1.DERIA5String=function(t){st.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Mt(st.asn1.DERIA5String,st.asn1.DERAbstractString),st.asn1.DERVisibleString=function(t){st.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},Mt(st.asn1.DERVisibleString,st.asn1.DERAbstractString),st.asn1.DERBMPString=function(t){st.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},Mt(st.asn1.DERBMPString,st.asn1.DERAbstractString),st.asn1.DERUTCTime=function(t){st.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=ht(t)}else if(null!=t.str)this.hV=ht(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ht(this.formatDate(e,"utc",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ht(this.formatDate(t.date,"utc",r))}else t instanceof Date&&(this.hV=ht(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)},Mt(st.asn1.DERUTCTime,st.asn1.DERAbstractTime),st.asn1.DERGeneralizedTime=function(t){st.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=ht(t)}else if(null!=t.str)this.hV=ht(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ht(this.formatDate(e,"gen",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ht(this.formatDate(t.date,"gen",r))}else t instanceof Date&&(this.hV=ht(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)},Mt(st.asn1.DERGeneralizedTime,st.asn1.DERAbstractTime),st.asn1.DERSequence=function(t){st.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}},Mt(st.asn1.DERSequence,st.asn1.DERAbstractStructured),st.asn1.DERSet=function(t){st.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)},Mt(st.asn1.DERSet,st.asn1.DERAbstractStructured),st.asn1.DERTaggedObject=function(t){st.asn1.DERTaggedObject.superclass.constructor.call(this);var e=st.asn1,r=ct,i=r.getV,n=(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=n(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)},Mt(st.asn1.DERTaggedObject,st.asn1.ASN1Object);var st,ot,at,ct=new function(){};function ut(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 ht(t){return ut(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(S(t))}function gt(t){return v(pt(t))}function ft(t){return At(Nt(t)).toLowerCase()}function mt(t){try{return decodeURIComponent(bt(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 n=parseInt(e[i],16);161<=n&&n<=191?(r.push("c2"),r.push(e[i])):192<=n&&n<=255?(r.push("c3"),r.push((n-64).toString(16))):r.push(e[i])}return r.join("")}(t))}function St(t){for(var e="",r=0;r<t.length-1;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e}function vt(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 S(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 v(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 At(t){return t.replace(/%/g,"")}function bt(t){return t.replace(/(..)/g,"%$1")}function wt(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),n=(t=t.replace("::",i)).split(":");if(8!=n.length)throw e;for(var s=0;s<8;s++)n[s]=("0000"+n[s]).slice(-4);return n.join("")}function Tt(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 Tt(t);if(64!=t.length)return t;try{return Tt(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 Ct(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 Ct((r=t.split("/"))[0])+Pt(parseInt(r[1]),32);if(t.match(/^[0-9a-f:]+$/)&&-1!==t.indexOf(":"))return wt(t);if(t.match(/^[0-9a-f:]+\/[0-9]+$/)&&-1!==t.indexOf(":"))return wt((r=t.split("/"))[0])+Pt(parseInt(r[1]),128);throw e}var i=t.split(".");if(4!==i.length)throw e;var n="";try{for(var s=0;s<4;s++)n+=("0"+parseInt(i[s]).toString(16)).slice(-2);return n}catch(t){throw e}}function Pt(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 Ft(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 n=128|63&r;return mt((224|(240&e)>>4).toString(16)+i.toString(16)+n.toString(16))});return e.join("")}function Nt(t){for(var e=encodeURIComponent(t),r="",i=0;i<e.length;i++)"%"==e[i]?(r+=e.substr(i,3),i+=2):r=r+"%"+ht(e[i]);return r}function Dt(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))}function Ot(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(!Dt(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 n=t.substr(2),s=[],o=0;o<n.length/2;o++)s.push(parseInt(n.substr(2*o,2),16));var a=[],c="";for(o=0;o<s.length;o++)128&s[o]?c+=Ht((127&s[o]).toString(2),7):(c+=Ht((127&s[o]).toString(2),7),a.push(new String(parseInt(c,2))),c="");var u=e.join(".");return a.length>0&&(u=u+"."+a.join(".")),u}catch(t){return null}}function Bt(t){return kt(new E(String(t),10))}function kt(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="",n=0;n<r;n++)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,n,s=ct,o=[];r=s.getVidx(t,e),i=2*s.getVblen(t,e),"03"==t.substr(e,2)&&(r+=2,i-=2),n=0;for(var a=r;n<=i;){var c=s.getTLVblen(t,a);if((n+=c)<=i&&o.push(a),a+=c,n>=i)break}return o},ct.getNthChildIdx=function(t,e,r){return ct.getChildIdx(t,e)[r]},ct.getIdxbyList=function(t,e,r,i){var n,s,o=ct;return 0==r.length?void 0!==i&&t.substr(e,2)!==i?-1:e:(n=r.shift())>=(s=o.getChildIdx(t,e)).length?-1:o.getIdxbyList(t,s[n],r,i)},ct.getIdxbyListEx=function(t,e,r,i){var n,s,o=ct;if(0==r.length)return void 0!==i&&t.substr(e,2)!==i?-1:e;n=r.shift(),s=o.getChildIdx(t,e);for(var a=0,c=0;c<s.length;c++){var u=t.substr(s[c],2);if("number"==typeof n&&!o.isContextTag(u)&&a==n||"string"==typeof n&&o.isContextTag(u,n))return o.getIdxbyListEx(t,s[c],r,i);o.isContextTag(u)||a++}return-1},ct.getTLVbyList=function(t,e,r,i){var n=ct,s=n.getIdxbyList(t,e,r,i);return-1==s||s>=t.length?null:n.getTLV(t,s)},ct.getTLVbyListEx=function(t,e,r,i){var n=ct,s=n.getIdxbyListEx(t,e,r,i);return-1==s?null:n.getTLV(t,s)},ct.getVbyList=function(t,e,r,i,n){var s,o,a=ct;return-1==(s=a.getIdxbyList(t,e,r,i))||s>=t.length?null:(o=a.getV(t,s),!0===n&&(o=o.substr(2)),o)},ct.getVbyListEx=function(t,e,r,i,n){var s,o,a=ct;return-1==(s=a.getIdxbyListEx(t,e,r,i))?null:(o=a.getV(t,s),"03"==t.substr(s,2)&&!1!==n&&(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 n=ct.getV(t,e);return"02"==i?parseInt(n,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),n=parseInt(i,16).toString(2);"0"==n&&(n="00000000"),n=n.slice(0,0-r);var s=parseInt(n,2);return NaN==s?-1:s}catch(t){return-1}}(n)}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 n=st.asn1.x509.OID.oid2name(i);return""==n?i:n}catch(t){return r}},ct.getString=function(t,e,r){null==r&&(r=null);try{return St(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),n=parseInt(i,16);r[0]=new String(Math.floor(n/40)),r[1]=new String(n%40);for(var s=t.substr(2),o=[],a=0;a<s.length/2;a++)o.push(parseInt(s.substr(2*a,2),16));var c=[],u="";for(a=0;a<o.length;a++)128&o[a]?u+=e((127&o[a]).toString(2),7):(u+=e((127&o[a]).toString(2),7),c.push(new String(parseInt(u,2))),u="");var h=r.join(".");return c.length>0&&(h=h+"."+c.join(".")),h},ct.dump=function(t,e,r,i){var n=ct,s=n.getV,o=n.dump,a=n.getChildIdx,c=t;t instanceof st.asn1.ASN1Object&&(c=t.tohex());var u=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 h,l=e.ommit_long_octet;if("01"==(h=c.substr(r,2)))return"00"==(p=s(c,r))?i+"BOOLEAN FALSE\n":i+"BOOLEAN TRUE\n";if("02"==h)return i+"INTEGER "+u(p=s(c,r),l)+"\n";if("03"==h){var p=s(c,r);return n.isASN1HEX(p.substr(2))?(x=i+"BITSTRING, encapsulates\n")+o(p.substr(2),e,0,i+" "):i+"BITSTRING "+u(p,l)+"\n"}if("04"==h)return p=s(c,r),n.isASN1HEX(p)?(x=i+"OCTETSTRING, encapsulates\n")+o(p,e,0,i+" "):i+"OCTETSTRING "+u(p,l)+"\n";if("05"==h)return i+"NULL\n";if("06"==h){var d=s(c,r),g=st.asn1.ASN1Util.oidHexToInt(d),f=st.asn1.x509.OID.oid2name(g),m=g.replace(/\./g," ");return""!=f?i+"ObjectIdentifier "+f+" ("+m+")\n":i+"ObjectIdentifier ("+m+")\n"}if("0a"==h)return i+"ENUMERATED "+parseInt(s(c,r))+"\n";if("0c"==h)return i+"UTF8String '"+mt(s(c,r))+"'\n";if("13"==h)return i+"PrintableString '"+mt(s(c,r))+"'\n";if("14"==h)return i+"TeletexString '"+mt(s(c,r))+"'\n";if("16"==h)return i+"IA5String '"+mt(s(c,r))+"'\n";if("17"==h)return i+"UTCTime "+mt(s(c,r))+"\n";if("18"==h)return i+"GeneralizedTime "+mt(s(c,r))+"\n";if("1a"==h)return i+"VisualString '"+mt(s(c,r))+"'\n";if("1e"==h)return i+"BMPString '"+Ft(s(c,r))+"'\n";if("30"==h){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=n.oidname(s(c,E[0]));var S=JSON.parse(JSON.stringify(e));S.x509ExtName=f,y=S}for(var v=0;v<E.length;v++)x+=o(c,y,E[v],i+" ");return x}if("31"==h){x=i+"SET\n";var E=a(c,r);for(v=0;v<E.length;v++)x+=o(c,e,E[v],i+" ");return x}if(128&(h=parseInt(h,16))){var x,A=31&h;if(32&h){for(x=i+"["+A+"]\n",E=a(c,r),v=0;v<E.length;v++)x+=o(c,e,E[v],i+" ");return x}return p=s(c,r),ct.isASN1HEX(p)?(x=i+"["+A+"]\n")+o(p,e,0,i+" "):(("68747470"==p.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==A)&&(p=mt(p)),i+"["+A+"] "+p+"\n")}return i+"UNKNOWN("+h+") "+s(c,r)+"\n"},ct.parse=function(t){var e=ct,r=e.parse,i=e.isASN1HEX,n=e.getV,s=e.getTLV,o=e.getChildIdx,a=st.asn1,c=a.ASN1Util.oidHexToInt,u=a.x509.OID.oid2name,h=mt,l=Ft,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=n(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 S=null;return m.length<=10&&(S=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="",n=0;n<r.length;n+=2){var s=r.substr(n,2),o=parseInt(s,16).toString(2);i+=o=("0000000"+o).slice(-8)}return i.substr(0,i.length-e)}catch(t){return null}}(m)),null==S?{bitstr:{hex:m}}:{bitstr:{bin:S}}}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 v=c(m),E=u(v);return""==E?{oid:v}:{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),n=0;n<i.length;n++){var a=i[n],c=s(t,a),u=r(c);e.push(u)}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=h(m),f[d[g]]={str:x},f;if(g.match(/^8[0-9]$/))return null==(x=h(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 A=new st.asn1.ASN1Object;return A.hV=m,{asn1:{tlv:g+A.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),n=e.getL(t,0);return t.length-i.length-n.length==2*r},ct.checkStrictDER=function(t,e,r,i,n){var s=ct;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!st.lang.String.isHex(t))throw new Error("not hex string");r=t.length,n=(i=t.length/2)<128?1:Math.ceil(i.toString(16))+1}if(s.getL(t,e).length>2*n)throw new Error("L of TLV too long: idx="+e);var o=s.getVblen(t,e);if(o>i)throw new Error("value of L too long than hex: idx="+e);var a=s.getTLV(t,e),c=a.length-2-s.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 u=t.substr(e,2);if("02"===u){var h=s.getVidx(t,e);if("00"==t.substr(h,2)&&t.charCodeAt(h+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(u,16)){for(var l=s.getVblen(t,e),p=0,d=s.getChildIdx(t,e),g=0;g<d.length;g++)p+=s.getTLV(t,d[g]).length,s.checkStrictDER(t,d[g],r,i,n);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=st.asn1;st.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var r=e.x509.OID.oid2name(t);return""===r&&(r=t),r},void 0!==st&&st||(st={}),void 0!==st.asn1&&st.asn1||(st.asn1={}),void 0!==st.asn1.x509&&st.asn1.x509||(st.asn1.x509={}),st.asn1.x509.Certificate=function(t){st.asn1.x509.Certificate.superclass.constructor.call(this);var e=st.asn1,r=e.DERBitString,i=e.DERSequence,n=e.x509,s=n.TBSCertificate,o=n.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 st.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 s(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)},Mt(st.asn1.x509.Certificate,st.asn1.ASN1Object),st.asn1.x509.TBSCertificate=function(t){st.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=st.asn1,r=e.x509,i=e.DERTaggedObject,n=e.DERInteger,s=e.DERSequence,o=r.AlgorithmIdentifier,a=r.Time,c=r.X500Name,u=r.Extensions,h=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 n({int:r})});t.push(l)}return t.push(new n(e.serial)),t.push(new o({name:e.sigalg})),t.push(new c(e.issuer)),t.push(new s({array:[new a(e.notbefore),new a(e.notafter)]})),t.push(new c(e.subject)),t.push(new h(Vt.getKey(e.sbjpubkey))),void 0!==e.ext&&e.ext.length>0&&t.push(new i({tag:"a3",obj:new u(e.ext)})),new st.asn1.DERSequence({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.TBSCertificate,st.asn1.ASN1Object),st.asn1.x509.Extensions=function(t){st.asn1.x509.Extensions.superclass.constructor.call(this);var e=st.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 n=this.aParam[e],s=n.extname,o=null;if(null!=n.extn)o=new i.PrivateExtension(n);else if("subjectKeyIdentifier"==s)o=new i.SubjectKeyIdentifier(n);else if("keyUsage"==s)o=new i.KeyUsage(n);else if("subjectAltName"==s)o=new i.SubjectAltName(n);else if("issuerAltName"==s)o=new i.IssuerAltName(n);else if("basicConstraints"==s)o=new i.BasicConstraints(n);else if("nameConstraints"==s)o=new i.NameConstraints(n);else if("cRLDistributionPoints"==s)o=new i.CRLDistributionPoints(n);else if("certificatePolicies"==s)o=new i.CertificatePolicies(n);else if("policyMappings"==s)o=new i.PolicyMappings(n);else if("policyConstraints"==s)o=new i.PolicyConstraints(n);else if("inhibitAnyPolicy"==s)o=new i.InhibitAnyPolicy(n);else if("authorityKeyIdentifier"==s)o=new i.AuthorityKeyIdentifier(n);else if("extKeyUsage"==s)o=new i.ExtKeyUsage(n);else if("authorityInfoAccess"==s)o=new i.AuthorityInfoAccess(n);else if("cRLNumber"==s)o=new i.CRLNumber(n);else if("cRLReason"==s)o=new i.CRLReason(n);else if("ocspNonce"==s)o=new i.OCSPNonce(n);else if("ocspNoCheck"==s)o=new i.OCSPNoCheck(n);else if("adobeTimeStamp"==s)o=new i.AdobeTimeStamp(n);else{if("subjectDirectoryAttributes"!=s)throw new Error("extension not supported:"+JSON.stringify(n));o=new i.SubjectDirectoryAttributes(n)}null!=o&&t.push(o)}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.x509.Extensions,st.asn1.ASN1Object),st.asn1.x509.Extension=function(t){st.asn1.x509.Extension.superclass.constructor.call(this);var e=st.asn1,r=e.DERObjectIdentifier,i=e.DEROctetString,n=(e.DERBitString,e.DERBoolean),s=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 n),o.push(e),new s({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},Mt(st.asn1.x509.Extension,st.asn1.ASN1Object),st.asn1.x509.KeyUsage=function(t){st.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 st.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)},Mt(st.asn1.x509.KeyUsage,st.asn1.x509.Extension),st.asn1.x509.BasicConstraints=function(t){st.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=st.asn1,r=e.DERBoolean,i=e.DERInteger,n=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 n({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))},Mt(st.asn1.x509.BasicConstraints,st.asn1.x509.Extension),st.asn1.x509.CRLDistributionPoints=function(t){st.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=st.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(t){for(var i=[],n=0;n<t.length;n++)if(t[n]instanceof st.asn1.ASN1Object)i.push(t[n]);else{var s=new r.DistributionPoint(t[n]);i.push(s)}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))},Mt(st.asn1.x509.CRLDistributionPoints,st.asn1.x509.Extension),st.asn1.x509.DistributionPoint=function(t){st.asn1.x509.DistributionPoint.superclass.constructor.call(this);var e=st.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}]})))},Mt(st.asn1.x509.DistributionPoint,st.asn1.ASN1Object),st.asn1.x509.DistributionPointName=function(t){st.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=st.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)}},Mt(st.asn1.x509.DistributionPointName,st.asn1.ASN1Object),st.asn1.x509.CertificatePolicies=function(t){st.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=st.asn1,r=e.x509,i=e.DERSequence,n=r.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new n(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)},Mt(st.asn1.x509.CertificatePolicies,st.asn1.x509.Extension),st.asn1.x509.PolicyInformation=function(t){st.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=st.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,n=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=[],s=0;s<this.params.array.length;s++)e.push(new n(this.params.array[s]));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)},Mt(st.asn1.x509.PolicyInformation,st.asn1.ASN1Object),st.asn1.x509.PolicyQualifierInfo=function(t){st.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=st.asn1,r=e.DERSequence,i=e.DERIA5String,n=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.tohex=function(){return void 0!==this.params.cps?new r({array:[new n({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 n({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).tohex():void 0},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Mt(st.asn1.x509.PolicyQualifierInfo,st.asn1.ASN1Object),st.asn1.x509.UserNotice=function(t){st.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=st.asn1.DERSequence,r=(st.asn1.DERInteger,st.asn1.x509.DisplayText),i=st.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)},Mt(st.asn1.x509.UserNotice,st.asn1.ASN1Object),st.asn1.x509.NoticeReference=function(t){st.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=st.asn1.DERSequence,r=st.asn1.DERInteger,i=st.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 n=[],s=this.params.noticenum,o=0;o<s.length;o++)n.push(new r(s[o]));t.push(new e({array:n}))}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)},Mt(st.asn1.x509.NoticeReference,st.asn1.ASN1Object),st.asn1.x509.DisplayText=function(t){st.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"))},Mt(st.asn1.x509.DisplayText,st.asn1.DERAbstractString),st.asn1.x509.PolicyMappings=function(t){st.asn1.x509.PolicyMappings.superclass.constructor.call(this,t);var e=st.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 n=t.array[i];e.push({seq:[{oid:n[0]},{oid:n[1]}]})}return this.asn1ExtnValue=r({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.33",void 0!==t&&(this.params=t)},Mt(st.asn1.x509.PolicyMappings,st.asn1.x509.Extension),st.asn1.x509.PolicyConstraints=function(t){st.asn1.x509.PolicyConstraints.superclass.constructor.call(this,t);var e=st.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)},Mt(st.asn1.x509.PolicyConstraints,st.asn1.x509.Extension),st.asn1.x509.InhibitAnyPolicy=function(t){st.asn1.x509.InhibitAnyPolicy.superclass.constructor.call(this,t);var e=st.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)},Mt(st.asn1.x509.InhibitAnyPolicy,st.asn1.x509.Extension),st.asn1.x509.NameConstraints=function(t){st.asn1.x509.NameConstraints.superclass.constructor.call(this,t);var e=st.asn1,r=e.x509,i=e.ASN1Util.newObject,n=r.GeneralSubtree;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];if(null!=t.permit&&null!=t.permit.length){for(var r=[],s=0;s<t.permit.length;s++)r.push(new n(t.permit[s]));e.push({tag:{tagi:"a0",obj:{seq:r}}})}if(null!=t.exclude&&null!=t.exclude.length){var o=[];for(s=0;s<t.exclude.length;s++)o.push(new n(t.exclude[s]));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)},Mt(st.asn1.x509.NameConstraints,st.asn1.x509.Extension),st.asn1.x509.GeneralSubtree=function(t){st.asn1.x509.GeneralSubtree.superclass.constructor.call(this);var e=st.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)},Mt(st.asn1.x509.GeneralSubtree,st.asn1.ASN1Object),st.asn1.x509.ExtKeyUsage=function(t){st.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=st.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)},Mt(st.asn1.x509.ExtKeyUsage,st.asn1.x509.Extension),st.asn1.x509.AuthorityKeyIdentifier=function(t){st.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=st,r=e.asn1,i=r.DERTaggedObject,n=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 n([{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 st.asn1.DEROctetString(t);else if("object"==typeof t&&st.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN ")){var e=t;"string"==typeof t&&(e=Vt.getKey(t));var r=Vt.getKeyID(e);this.asn1KID=new st.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 st.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new st.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 st.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 st.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)))},Mt(st.asn1.x509.AuthorityKeyIdentifier,st.asn1.x509.Extension),st.asn1.x509.SubjectKeyIdentifier=function(t){st.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var e=st.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&&st.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN")){var r=t;"string"==typeof t&&(r=Vt.getKey(t));var i=Vt.getKeyID(r);this.asn1KID=new st.asn1.DEROctetString({hex:i})}},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},Mt(st.asn1.x509.SubjectKeyIdentifier,st.asn1.x509.Extension),st.asn1.x509.AuthorityInfoAccess=function(t){st.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,r=st.asn1,i=r.DERSequence,n=r.DERObjectIdentifier,s=r.x509.GeneralName,o=0;o<t.length;o++){var a,c=t[o];if(void 0!==c.ocsp)a=new i({array:[new n({oid:"1.3.6.1.5.5.7.48.1"}),new s({uri:c.ocsp})]});else{if(void 0===c.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(c));a=new i({array:[new n({oid:"1.3.6.1.5.5.7.48.2"}),new s({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)},Mt(st.asn1.x509.AuthorityInfoAccess,st.asn1.x509.Extension),st.asn1.x509.SubjectAltName=function(t){st.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new st.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)},Mt(st.asn1.x509.SubjectAltName,st.asn1.x509.Extension),st.asn1.x509.IssuerAltName=function(t){st.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new st.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)},Mt(st.asn1.x509.IssuerAltName,st.asn1.x509.Extension),st.asn1.x509.SubjectDirectoryAttributes=function(t){st.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=st.asn1,r=e.DERSequence,i=e.ASN1Util.newObject,n=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var s=this.params.array[e];if(null==s.attr||null==s.array){var o={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==s.attr)o.seq[0].oid=n(s.attr),o.seq[1].set[0]={gentime:s.str};else if("placeOfBirth"==s.attr)o.seq[0].oid=n(s.attr),o.seq[1].set[0]={utf8str:s.str};else if("gender"==s.attr)o.seq[0].oid=n(s.attr),o.seq[1].set[0]={prnstr:s.str};else if("countryOfCitizenship"==s.attr)o.seq[0].oid=n(s.attr),o.seq[1].set[0]={prnstr:s.str};else{if("countryOfResidence"!=s.attr)throw new Error("unsupported attribute: "+s.attr);o.seq[0].oid=n(s.attr),o.seq[1].set[0]={prnstr:s.str}}t.push(new i(o))}else{var a={seq:[{oid:s.attr},{set:s.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)},Mt(st.asn1.x509.SubjectDirectoryAttributes,st.asn1.x509.Extension),st.asn1.x509.PrivateExtension=function(t){st.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=st,r=e.lang.String.isHex,i=e.asn1,n=i.x509.OID.name2oid,s=i.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=n(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 s(t).tohex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},Mt(st.asn1.x509.PrivateExtension,st.asn1.x509.Extension),st.asn1.x509.CRL=function(t){st.asn1.x509.CRL.superclass.constructor.call(this);var e=st.asn1,r=e.DERSequence,i=e.DERBitString,n=e.x509,s=n.AlgorithmIdentifier,o=n.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new o(this.params).tohex(),e=new st.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 s({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)},Mt(st.asn1.x509.CRL,st.asn1.ASN1Object),st.asn1.x509.TBSCertList=function(t){st.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=st.asn1,r=e.DERInteger,i=e.DERSequence,n=e.DERTaggedObject,s=(e.DERObjectIdentifier,e.x509),o=s.AlgorithmIdentifier,a=s.Time,c=s.Extensions,u=s.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,n=0;n<e.length;n++){var s=[new r(e[n].sn),new a(e[n].date)];null!=e[n].ext&&s.push(new c(e[n].ext)),t.push(new i({array:s}))}return new i({array:t})},this.tohex=function(){var t=[],e=this.params;if(null!=e.version){var s=e.version-1,h=new r({int:s});t.push(h)}if(t.push(new o({name:e.sigalg})),t.push(new u(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 n({tag:"a0",explicit:!0,obj:l}))}return new i({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.TBSCertList,st.asn1.ASN1Object),st.asn1.x509.CRLEntry=function(t){st.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=st.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))},Mt(st.asn1.x509.CRLEntry,st.asn1.ASN1Object),st.asn1.x509.CRLNumber=function(t){st.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new st.asn1.DERInteger(this.params.num),this.asn1ExtnValue.tohex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},Mt(st.asn1.x509.CRLNumber,st.asn1.x509.Extension),st.asn1.x509.CRLReason=function(t){st.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new st.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.tohex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},Mt(st.asn1.x509.CRLReason,st.asn1.x509.Extension),st.asn1.x509.OCSPNonce=function(t){st.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new st.asn1.DEROctetString(this.params),this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},Mt(st.asn1.x509.OCSPNonce,st.asn1.x509.Extension),st.asn1.x509.OCSPNoCheck=function(t){st.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new st.asn1.DERNull,this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},Mt(st.asn1.x509.OCSPNoCheck,st.asn1.x509.Extension),st.asn1.x509.AdobeTimeStamp=function(t){st.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=st.asn1,r=e.DERInteger,i=e.DERBoolean,n=e.DERSequence,s=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new r(1)];return e.push(new s({uri:t.uri})),null!=t.reqauth&&e.push(new i(t.reqauth)),this.asn1ExtnValue=new n({array:e}),this.asn1ExtnValue.tohex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.AdobeTimeStamp,st.asn1.x509.Extension),st.asn1.x509.X500Name=function(t){st.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=st.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 n=[],s=0;s<r.length;s++)if(r[s].match(/^[^=]+=.+$/))n.push(r[s]);else{var o=n.length-1;n[o]=n[o]+"/"+r[s]}for(s=0;s<n.length;s++)this.asn1Array.push(new i({str:n[s],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 n=new i({str:r+"="+t[r],rule:this.sRule});this.asn1Array?this.asn1Array.push(n):this.asn1Array=[n]}},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 n=new i(r);this.asn1Array.push(n)}var s=new e.DERSequence({array:this.asn1Array});return this.hTLV=s.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.X500Name,st.asn1.ASN1Object),st.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(",")},st.asn1.x509.X500Name.onelineToLDAP=function(t){return st.asn1.x509.X500Name.compatToLDAP(t)},st.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),r=!1,i=[],n=0;e.length>0;n++){var s=e.shift();if(!0===r){var o=(i.pop()+","+s).replace(/\\,/g,",");i.push(o),r=!1}else i.push(s);"\\"===s.substr(-1,1)&&(r=!0)}return i=i.map(function(t){return t.replace("/","\\/")}),i.reverse(),"/"+i.join("/")},st.asn1.x509.X500Name.ldapToOneline=function(t){return st.asn1.x509.X500Name.ldapToCompat(t)},st.asn1.x509.RDN=function(t){st.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=st.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 st.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=st.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 n=new st.asn1.DERSet({array:this.asn1Array});return this.TLV=n.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.RDN,st.asn1.ASN1Object),st.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),r=!1,i=[],n=0;e.length>0;n++){var s=e.shift();if(!0===r){var o=(i.pop()+"+"+s).replace(/\\\+/g,"+");i.push(o),r=!1}else i.push(s);"\\"===s.substr(-1,1)&&(r=!0)}var a=!1,c=[];for(n=0;i.length>0;n++){if(s=i.shift(),!0===a){var u=c.pop();s.match(/"$/)?(o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2"),c.push(o),a=!1):c.push(u+"+"+s)}else c.push(s);s.match(/^[^=]+="/)&&(a=!0)}return c},st.asn1.x509.AttributeTypeAndValue=function(t){st.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=st,r=e.asn1,i=r.DERSequence,n=r.DERUTF8String,s=r.DERPrintableString,o=r.DERTeletexString,a=r.DERIA5String,c=r.DERVisibleString,u=r.DERBMPString,h=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&&h(e)?"ia5":l(e)?"prn":"utf8":"utf8"===r?"CN"==t&&h(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 n({str:e});if("prn"==t)return new s({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 u({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=st.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)},Mt(st.asn1.x509.AttributeTypeAndValue,st.asn1.ASN1Object),st.asn1.x509.SubjectPublicKeyInfo=function(t){st.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=st,r=e.asn1,i=r.DERInteger,n=r.DERBitString,s=r.DERObjectIdentifier,o=r.DERSequence,a=r.ASN1Util.newObject,c=r.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.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 n({hex:"00"+e})}}catch(t){}try{if(t instanceof st.crypto.ECDSA){var r=new s({name:t.curveName});this.asn1AlgId=new c({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new n({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof st.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 n({hex:"00"+o.tohex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},Mt(st.asn1.x509.SubjectPublicKeyInfo,st.asn1.ASN1Object),st.asn1.x509.Time=function(t){st.asn1.x509.Time.superclass.constructor.call(this);var e=st.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)},st.asn1.x509.Time_bak=function(t){st.asn1.x509.Time_bak.superclass.constructor.call(this);var e=st.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)},Mt(st.asn1.x509.Time,st.asn1.ASN1Object),st.asn1.x509.AlgorithmIdentifier=function(t){st.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=st.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 n=[this.asn1Alg];null!==this.asn1Params&&n.push(this.asn1Params);var s=new e.DERSequence({array:n});return this.hTLV=s.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)}},Mt(st.asn1.x509.AlgorithmIdentifier,st.asn1.ASN1Object),st.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},st.asn1.x509.GeneralName=function(t){st.asn1.x509.GeneralName.superclass.constructor.call(this);var e=st.asn1,r=e.x509,i=r.X500Name,n=r.OtherName,s=e.DERIA5String,o=(e.DERPrintableString,e.DEROctetString),a=e.DERTaggedObject,c=e.ASN1Object,u=Error;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e,r=this.params,h=!1;if(void 0!==r.other)t="a0",e=new n(r.other);else if(void 0!==r.rfc822)t="81",e=new s({str:r.rfc822});else if(void 0!==r.dns)t="82",e=new s({str:r.dns});else if(void 0!==r.dn)t="a4",h=!0,e="string"==typeof r.dn?new i({str:r.dn}):r.dn instanceof st.asn1.x509.X500Name?r.dn:new i(r.dn);else if(void 0!==r.ldapdn)t="a4",h=!0,e=new i({ldapstr:r.ldapdn});else if(void 0!==r.certissuer||void 0!==r.certsubj){var l,p;t="a4",h=!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 s({str:r.uri});else{if(void 0===r.ip)throw new u("improper params");var m;t="87";var y=r.ip;try{if(y.match(/^[0-9a-f]+$/)){var S=y.length;if(8!=S&&16!=S&&32!=S&&64!=S)throw"err";m=y}else m=Ct(y)}catch(t){throw new u("malformed IP address: "+r.ip+":"+t.message)}e=new o({hex:m})}return new a({tag:t,explicit:h,obj:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.GeneralName,st.asn1.ASN1Object),st.asn1.x509.GeneralNames=function(t){st.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=st.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)},Mt(st.asn1.x509.GeneralNames,st.asn1.ASN1Object),st.asn1.x509.OtherName=function(t){st.asn1.x509.OtherName.superclass.constructor.call(this);var e=st.asn1,r=e.DERObjectIdentifier,i=e.DERSequence,n=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}),s=n({tag:{tag:"a0",explicit:!0,obj:t.value}});return new i({array:[e,s]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.x509.OtherName,st.asn1.ASN1Object),st.asn1.x509.OID=new function(){var t=st.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}}},st.asn1.x509.OID.oid2name=function(t){var e=st.asn1.x509.OID.name2oidList;for(var r in e)if(e[r]==t)return r;return""},st.asn1.x509.OID.oid2atype=function(t){var e=st.asn1.x509.OID.atype2oidList;for(var r in e)if(e[r]==t)return r;return t},st.asn1.x509.OID.name2oid=function(t){if(t.match(/^[0-9.]+$/))return t;var e=st.asn1.x509.OID.name2oidList;return void 0===e[t]?"":e[t]},st.asn1.x509.X509Util={},st.asn1.x509.X509Util.newCertPEM=function(t){var e=st.asn1.x509;return e.TBSCertificate,new(0,e.Certificate)(t).getPEM()},void 0!==st&&st||(st={}),void 0!==st.asn1&&st.asn1||(st.asn1={}),void 0!==st.asn1.cms&&st.asn1.cms||(st.asn1.cms={}),st.asn1.cms.Attribute=function(t){var e=Error,r=st.asn1,i=r.DERSequence,n=r.DERSet,s=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 s({oid:this.typeOid}),e=new n({array:this.getValueArray()});return new i({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()}},Mt(st.asn1.cms.Attribute,st.asn1.ASN1Object),st.asn1.cms.ContentType=function(t){var e=st.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)},Mt(st.asn1.cms.ContentType,st.asn1.cms.Attribute),st.asn1.cms.MessageDigest=function(t){var e=st.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)},Mt(st.asn1.cms.MessageDigest,st.asn1.cms.Attribute),st.asn1.cms.SigningTime=function(t){var e=st.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)},Mt(st.asn1.cms.SigningTime,st.asn1.cms.Attribute),st.asn1.cms.SigningCertificate=function(t){var e=Error,r=st,i=r.asn1,n=i.DERSequence,s=i.cms,o=s.ESSCertID;r.crypto,s.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=[],s=0;s<r.length;s++){var a=r[s];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 n({array:i});return[new n({array:[c]})]},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.SigningCertificate,st.asn1.cms.Attribute),st.asn1.cms.ESSCertID=function(t){st.asn1.cms.ESSCertID.superclass.constructor.call(this);var e=Error,r=st,i=r.asn1,n=i.DEROctetString,s=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 n,s,o;if("string"==typeof t)n=t;else{if(null==t.cert)throw new e("hash nor cert unspecified");n=t.cert}if(s=-1!=n.indexOf("-----BEGIN")?xt(n):n,"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?s=xt(t):ct.isASN1HEX(t)&&(s=t)),null!=t.alg)o=t.alg;else{if(null==i)throw new e("hash alg unspecified");o=i}return r.crypto.Util.hashHex(s,o)},this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha1"),r=[];return r.push(new n({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 s({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.ESSCertID,st.asn1.ASN1Object),st.asn1.cms.SigningCertificateV2=function(t){var e=Error,r=st,i=r.asn1,n=i.DERSequence,s=(i.x509,i.cms),o=s.ESSCertIDv2;r.crypto,s.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=[],s=0;s<r.length;s++){var a=r[s];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 n({array:i});return[new n({array:[c]})]},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.SigningCertificateV2,st.asn1.cms.Attribute),st.asn1.cms.ESSCertIDv2=function(t){st.asn1.cms.ESSCertIDv2.superclass.constructor.call(this),Error;var e=st.asn1,r=e.DEROctetString,i=e.DERSequence,n=e.cms.IssuerSerial,s=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 s({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 n(t)),new i({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.ESSCertIDv2,st.asn1.cms.ESSCertID),st.asn1.cms.IssuerSerial=function(t){var e=Error,r=st.asn1,i=r.DERInteger,n=r.DERSequence,s=r.cms,o=r.x509.GeneralNames,a=$t;s.IssuerSerial.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.tohex=function(){var t,r,s=this.params;if("string"==typeof s&&-1!=s.indexOf("-----BEGIN")||null!=s.cert){var c;c=null!=s.cert?s.cert:s;var u=new a;u.readCertPEM(c),t=u.getIssuer(),r={hex:u.getSerialNumberHex()}}else{if(null==s.issuer||!s.serial)throw new e("cert or issuer and serial parameter not specified");t=s.issuer,r=s.serial}var h=new o([{dn:t}]),l=new i(r);return new n({array:[h,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.IssuerSerial,st.asn1.ASN1Object),st.asn1.cms.SignerIdentifier=function(t){var e=st.asn1,r=(e.DERInteger,e.DERSequence,e.cms),i=r.IssuerAndSerialNumber,n=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 n(t).tohex();throw new Error("wrong property for isssn or skid")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.SignerIdentifier,st.asn1.ASN1Object),st.asn1.cms.IssuerAndSerialNumber=function(t){var e=st.asn1,r=e.DERInteger,i=e.DERSequence,n=e.cms,s=e.x509.X500Name,o=$t,a=Error;n.IssuerAndSerialNumber.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e,n=this.params;if("string"==typeof n&&-1!=n.indexOf("-----BEGIN")||null!=n.cert){var c;c=null!=n.cert?n.cert:n;var u=new o;u.readCertPEM(c),t=u.getIssuer(),e={hex:u.getSerialNumberHex()}}else{if(null==n.issuer||!n.serial)throw new a("cert or issuer and serial parameter not specified");t=n.issuer,e=n.serial}var h=new s(t),l=new r(e);return new i({array:[h,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.IssuerAndSerialNumber,st.asn1.ASN1Object),st.asn1.cms.SubjectKeyIdentifier=function(t){var e=st.asn1,r=(e.DERInteger,e.DERSequence,e.ASN1Util.newObject),i=e.cms,n=(i.IssuerAndSerialName,i.SubjectKeyIdentifier,e.x509.X500Name,$t),s=Error;i.SubjectKeyIdentifier.superclass.constructor.call(this),this.tohex=function(){var t,e=this.params;if(null==e.cert&&null==e.skid)throw new s("property cert nor skid undefined");return null!=e.cert?t=new n(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)},Mt(st.asn1.cms.SubjectKeyIdentifier,st.asn1.ASN1Object),st.asn1.cms.AttributeList=function(t){var e=Error,r=st.asn1,i=r.DERSet,n=r.cms;n.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 s=t.array,o=[],a=0;a<s.length;a++){var c=s[a],u=c.attr;if("contentType"==u)o.push(new n.ContentType(c));else if("messageDigest"==u)o.push(new n.MessageDigest(c));else if("signingTime"==u)o.push(new n.SigningTime(c));else if("signingCertificate"==u)o.push(new n.SigningCertificate(c));else if("signingCertificateV2"==u)o.push(new n.SigningCertificateV2(c));else if("signaturePolicyIdentifier"==u)o.push(new st.asn1.cades.SignaturePolicyIdentifier(c));else{if("signatureTimeStamp"!=u&&"timeStampToken"!=u)throw new e("unknown attr: "+u);o.push(new st.asn1.cades.SignatureTimeStamp(c))}}var h=new i({array:o,sortflag:r});return this.hTLV=h.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.AttributeList,st.asn1.ASN1Object),st.asn1.cms.SignerInfo=function(t){var e=Error,r=st,i=r.asn1,n=i.DERInteger,s=i.DEROctetString,o=i.DERSequence,a=i.DERTaggedObject,c=i.cms,u=c.SignerIdentifier,h=c.AttributeList,l=(c.ContentType,c.EncapsulatedContentInfo,c.MessageDigest,c.SignedData,i.x509.AlgorithmIdentifier),p=r.crypto,d=Vt;c.SignerInfo.superclass.constructor.call(this),this.params=null,this.sign=function(){var t=this.params,e=t.sigalg,r=new h(t.sattrs).tohex(),i=d.getKey(t.signkey),n=new p.Signature({alg:e});n.init(i),n.updateHex(r);var s=n.sign();t.sighex=s},this.tohex=function(){var t=this.params,r=[];if(r.push(new n({int:t.version})),r.push(new u(t.id)),r.push(new l({name:t.hashalg})),null!=t.sattrs){var i=new h(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 s({hex:t.sighex})),null!=t.uattrs){i=new h(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)},Mt(st.asn1.cms.SignerInfo,st.asn1.ASN1Object),st.asn1.cms.EncapsulatedContentInfo=function(t){var e=st.asn1,r=e.DERTaggedObject,i=e.DERSequence,n=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];if(e.push(new n(t.type)),null!=t.content&&(null!=t.content.hex||null!=t.content.str)&&1!=t.isDetached){var o=new s(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)},Mt(st.asn1.cms.EncapsulatedContentInfo,st.asn1.ASN1Object),st.asn1.cms.ContentInfo=function(t){var e=st.asn1,r=e.DERTaggedObject,i=e.DERSequence,n=e.DERObjectIdentifier;e.x509.OID.name2obj,st.asn1.cms.ContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];e.push(new n(t.type));var s=new r({tag:"a0",explicit:!0,obj:t.obj});return e.push(s),new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.ContentInfo,st.asn1.ASN1Object),st.asn1.cms.SignedData=function(t){Error;var e=st.asn1,r=(e.ASN1Object,e.DERInteger),i=e.DERSet,n=e.DERSequence,s=(e.DERTaggedObject,e.cms),o=s.EncapsulatedContentInfo,a=s.SignerInfo,c=s.ContentInfo,u=s.CertificateSet,h=s.RevocationInfoChoices,l=e.x509.AlgorithmIdentifier;st.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 n=r[i];this._getAttrParamByName(n,"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=vt(e.content.str));for(var i=t.sinfos,n=0;n<i.length;n++){var s=i[n],o=s.hashalg,a=this._getAttrParamByName(s,"messageDigest"),c=st.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],n=1;"skid"==i.id.type&&(n=3),i.version=n}},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 s=[],c=0;c<t.hashalgs.length;c++){var p=t.hashalgs[c];s.push(new l({name:p}))}e.push(new i({array:s})),e.push(new o(t.econtent)),null!=t.certs&&e.push(new u(t.certs)),null!=t.revinfos&&e.push(new h(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 n({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)},Mt(st.asn1.cms.SignedData,st.asn1.ASN1Object),st.asn1.cms.CertificateSet=function(t){st.asn1.cms.CertificateSet.superclass.constructor.call(this);var e=Error,r=st.asn1,i=r.DERTaggedObject,n=r.DERSet,s=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]),u=new s;u.hTLV=c,o.push(u)}var h={array:o};0==r.sortflag&&(h.sortflag=!1);var l=new n(h);return new i({tag:"a0",explicit:!1,obj:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.CertificateSet,st.asn1.ASN1Object),st.asn1.cms.RevocationInfoChoices=function(t){st.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 st.asn1.cms.RevocationInfoChoice(t[r]));return st.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:{set:e}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.RevocationInfoChoices,st.asn1.ASN1Object),st.asn1.cms.RevocationInfoChoice=function(t){st.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 st.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:new st.asn1.cms.OtherRevocationFormat(t)}}).tohex();throw new Error("property crl or ocsp undefined")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cms.RevocationInfoChoice,st.asn1.ASN1Object),st.asn1.cms.OtherRevocationFormat=function(t){st.asn1.cms.OtherRevocationFormat.superclass.constructor.call(this);var e=Error,r=st,i=r.asn1.ASN1Util.newObject,n=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(!n(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)},Mt(st.asn1.cms.OtherRevocationFormat,st.asn1.ASN1Object),st.asn1.cms.CMSUtil=new function(){},st.asn1.cms.CMSUtil.newSignedData=function(t){return new st.asn1.cms.SignedData(t)},st.asn1.cms.CMSUtil.verifySignedData=function(t){var e=st,r=e.asn1,i=r.cms,n=(i.SignerInfo,i.SignedData,i.SigningTime,i.SigningCertificate,i.SigningCertificateV2,r.cades.SignaturePolicyIdentifier,e.lang.String.isHex),s=ct,o=s.getVbyList,a=s.getTLVbyList,c=s.getIdxbyList,u=s.getChildIdx,h=s.getTLV,l=s.oidname,p=e.crypto.Util.hashHex;void 0===t.cms&&n(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 n=u(t,r).length;if(n<6)throw"malformed SignerInfo";e.sigalg=l(o(t,r,[n-2,0],"06")),e.sigval=o(t,r,[n-1],"04")},f=function(t,e,r){var i=u(t,r);e.signedAttrIdxList=i;for(var n=0;n<i.length;n++){var s,a=i[n],c=o(t,a,[0],"06");"2a864886f70d010905"===c?(s=mt(o(t,a,[1,0])),e.saSigningTime=s):"2a864886f70d010904"===c&&(s=o(t,a,[1,0],"04"),e.saMessageDigest=s)}},m=function(t,e,r,i){r.verifyDetail={};var n=r.verifyDetail,s=e.parse.econtent,o=r.hashalg,a=r.saMessageDigest;n.validMessageDigest=!1,p(s,o)===a&&(n.validMessageDigest=!0),function(t,e,r){var i,n=e.parse.certsIdx;if(void 0===e.certs){i=[],e.certkeys=[];for(var s=u(t,n),o=0;o<s.length;o++){var a=h(t,s[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=s.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),n.validSignatureValue=!1;var c=r.sigalg,l="31"+h(t,r.idxSignedAttrs).substr(2);r.signedattrshex=l;var d=e.certs[r.certkey_idx].getPublicKey(),g=new st.crypto.Signature({alg:c});g.init(d),g.updateHex(l);var f=g.verify(r.sigval);n.validSignatureValue_isValid=f,!0===f&&(n.validSignatureValue=!0),r.isValid=!1,n.validMessageDigest&&n.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 n=t.substr(r,2);"a0"===n&&(e.certsIdx=r),"a1"===n&&(e.revinfosIdx=r),"31"===n&&(e.signerinfosIdx=r)}}(t,e),e.signerInfos=[],function(t,e){var r=e.signerinfosIdx;if(void 0!==r){var i=u(t,r);e.signerInfoIdxList=i;for(var n=0;n<i.length;n++){var s={idx:i[n]};g(t,s),e.signerInfos.push(s)}}}(t,e)}(d,y.parse),function(t,e){for(var r=e.parse.signerInfos,i=r.length,n=!0,s=0;s<i;s++){var o=r[s];m(t,e,o),o.isValid||(n=!1)}e.isValid=n}(d,y),y},st.asn1.cms.CMSParser=function(){var t=Error,e=$t,r=new e,i=ct,n=i.getV,s=i.getTLV,o=(i.getIdxbyList,i.getTLVbyList),a=i.getTLVbyListEx,c=i.getVbyList,u=i.getVbyListEx,h=i.getChildIdx;this.getCMSSignedData=function(t){var e=o(t,0,[1,0]);return this.getSignedData(e)},this.getSignedData=function(t){var e=h(t,0),r={},i=n(t,e[0]),o=parseInt(i,16);r.version=o;var c=s(t,e[1]);r.hashalgs=this.getHashAlgArray(c);var u=s(t,e[2]);r.econtent=this.getEContent(u);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=h(t,0),i=new e,n=[],o=0;o<r.length;o++){var a=s(t,r[o]),c=i.getAlgorithmIdentifierName(a);n.push(c)}return n},this.getEContent=function(t){var e={},r=c(t,0,[0]),i=c(t,0,[1,0]);return e.type=st.asn1.x509.OID.oid2name(ct.hextooidstr(r)),e.content={hex:i},e},this.getSignerInfos=function(t){for(var e=[],r=h(t,0),i=0;i<r.length;i++){var n=s(t,r[i]),o=this.getSignerInfo(n);e.push(o)}return e},this.getSignerInfo=function(t){var e={},n=h(t,0),o=i.getInt(t,n[0],-1);-1!=o&&(e.version=o);var c=s(t,n[1]),l=this.getIssuerAndSerialNumber(c);e.id=l;var p=s(t,n[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 S=u(t,0,[4]);e.sighex=S;var v=a(t,0,["[1]"]);if(null!=v){var E=this.getAttributeList(v);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=h(t,0),o=s(t,i[0]);e.issuer=r.getX500Name(o);var a=n(t,i[1]);return e.serial={hex:a},e},this.getAttributeList=function(t){for(var e=[],r=h(t,0),i=0;i<r.length;i++){var n=s(t,r[i]),o=this.getAttribute(n);e.push(o)}return{array:e}},this.getAttribute=function(t){var e={},r=h(t,0),n=i.getOID(t,r[0]),o=st.asn1.x509.OID.oid2name(n);e.attr=o;var a=s(t,r[1]),c=h(a,0);if(1==c.length)e.valhex=s(a,c[0]);else{for(var u=[],l=0;l<c.length;l++)u.push(s(a,c[l]));e.valhex=u}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(n(t.valhex,0));t.str=e,delete t.valhex},this.setMessageDigest=function(t){var e=n(t.valhex,0);t.hex=e,delete t.valhex},this.setSigningCertificate=function(t){var e=h(t.valhex,0);if(e.length>0){for(var r=s(t.valhex,e[0]),i=h(r,0),n=[],o=0;o<i.length;o++){var a=s(r,i[o]),c=this.getESSCertID(a);n.push(c)}t.array=n}if(e.length>1){var u=s(t.valhex,e[1]);t.polhex=u}delete t.valhex},this.setSignaturePolicyIdentifier=function(t){var r=h(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=h(t.valhex,r[1]),u=s(t.valhex,c[0]),l=a.getAlgorithmIdentifierName(u);t.alg=l;var p=n(t.valhex,c[1]);t.hash=p}delete t.valhex},this.setSigningCertificateV2=function(t){var e=h(t.valhex,0);if(e.length>0){for(var r=s(t.valhex,e[0]),i=h(r,0),n=[],o=0;o<i.length;o++){var a=s(r,i[o]),c=this.getESSCertIDv2(a);n.push(c)}t.array=n}if(e.length>1){var u=s(t.valhex,e[1]);t.polhex=u}delete t.valhex},this.getESSCertID=function(t){var e={},r=h(t,0);if(r.length>0){var i=n(t,r[0]);e.hash=i}if(r.length>1){var o=s(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=h(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=s(e,o[0]);i.alg=r.getAlgorithmIdentifierName(c),a++}else i.alg="sha256";var u=n(e,o[a]);if(i.hash=u,o.length>a+1){var l=s(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=h(t,0),o=s(t,i[0]),a=r.getGeneralNames(o)[0].dn;e.issuer=a;var c=n(t,i[1]);return e.serial={hex:c},e},this.getCertificateSet=function(t){for(var e=h(t,0),r=[],i=0;i<e.length;i++){var n=s(t,e[i]);if("30"==n.substr(0,2)){var o=Et(n,"CERTIFICATE");r.push(o)}}return{array:r,sortflag:!1}}},void 0!==st&&st||(st={}),void 0!==st.asn1&&st.asn1||(st.asn1={}),void 0!==st.asn1.tsp&&st.asn1.tsp||(st.asn1.tsp={}),st.asn1.tsp.TimeStampToken=function(t){var e=st.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)},Mt(st.asn1.tsp.TimeStampToken,st.asn1.cms.SignedData),st.asn1.tsp.TSTInfo=function(t){Error;var e=st.asn1,r=e.DERSequence,i=e.DERInteger,n=e.DERBoolean,s=e.DERGeneralizedTime,o=e.DERObjectIdentifier,a=e.DERTaggedObject,c=e.tsp,u=c.MessageImprint,h=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 u(t.messageImprint)),void 0!==t.serial&&(this.dSerial=new i(t.serial)),void 0!==t.genTime&&(this.dGenTime=new s(t.genTime)),void 0!==t.accuracy&&(this.dAccuracy=new h(t.accuracy)),void 0!==t.ordering&&1==t.ordering&&(this.dOrdering=new n),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})}))}},Mt(st.asn1.tsp.TSTInfo,st.asn1.ASN1Object),st.asn1.tsp.Accuracy=function(t){var e=st.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)},Mt(st.asn1.tsp.Accuracy,st.asn1.ASN1Object),st.asn1.tsp.MessageImprint=function(t){var e=st.asn1,r=e.DERSequence,i=e.DEROctetString,n=e.x509.AlgorithmIdentifier;e.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=new n({name:t.alg}),s=new i({hex:t.hash});return new r({array:[e,s]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.tsp.MessageImprint,st.asn1.ASN1Object),st.asn1.tsp.TimeStampReq=function(t){var e=st.asn1,r=e.DERSequence,i=e.DERInteger,n=e.DERBoolean,s=(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 st.asn1.ASN1Object?e.push(t.messageImprint):e.push(new a(t.messageImprint)),null!=t.policy&&e.push(new s(t.policy)),null!=t.nonce&&e.push(new i(t.nonce)),1==t.certreq&&e.push(new n),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.tsp.TimeStampReq,st.asn1.ASN1Object),st.asn1.tsp.TimeStampResp=function(t){var e=st.asn1,r=e.DERSequence,i=(e.ASN1Object,e.tsp),n=i.PKIStatusInfo;i.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,s=[];if(null!=t.econtent||null!=t.tst)if(null!=t.statusinfo?s.push(new n(t.statusinfo)):s.push(new n("granted")),null!=t.econtent)s.push(new i.TimeStampToken(t).getContentInfo());else{if(!(t.tst instanceof e.ASN1Object))throw new Error("improper member tst value");s.push(t.tst)}else{if(null==t.statusinfo)throw new Error("parameter for token nor statusinfo not specified");s.push(new n(t.statusinfo))}return new r({array:s}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.tsp.TimeStampResp,st.asn1.ASN1Object),st.asn1.tsp.PKIStatusInfo=function(t){var e=Error,r=st.asn1,i=r.DERSequence,n=r.tsp,s=n.PKIStatus,o=n.PKIFreeText,a=n.PKIFailureInfo;n.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,r=[];if("string"==typeof t)r.push(new s(t));else{if(null==t.status)throw new e("property 'status' unspecified");r.push(new s(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)},Mt(st.asn1.tsp.PKIStatusInfo,st.asn1.ASN1Object),st.asn1.tsp.PKIStatus=function(t){var e=Error,r=st.asn1,i=r.DERInteger;r.tsp.PKIStatus.superclass.constructor.call(this);var n={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=n[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)},Mt(st.asn1.tsp.PKIStatus,st.asn1.ASN1Object),st.asn1.tsp.PKIFreeText=function(t){var e=Error,r=st.asn1,i=r.DERSequence,n=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=[],s=0;s<t.length;s++)r.push(new n({str:t[s]}));return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.tsp.PKIFreeText,st.asn1.ASN1Object),st.asn1.tsp.PKIFailureInfo=function(t){var e=Error,r=st.asn1,i=r.DERBitString,n=r.tsp.PKIFailureInfo,s={badAlg:0,badRequest:2,badDataFormat:5,timeNotAvailable:14,unacceptedPolicy:15,unacceptedExtension:16,addInfoNotAvailable:17,systemFailure:25};n.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),n="",o=i.length-1;o>=0;o--)n+=i[o];return n}if("string"==typeof t&&null!=s[t])return Ut([t],s);if("object"==typeof t&&null!=t.length)return Ut(t,s);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)},Mt(st.asn1.tsp.PKIFailureInfo,st.asn1.ASN1Object),st.asn1.tsp.AbstractTSAAdapter=function(t){this.getTSTHex=function(t,e){throw"not implemented yet"}},st.asn1.tsp.SimpleTSAAdapter=function(t){var e=st,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 n=i(t,e);this.params.econtent.content.messageImprint={alg:e,hash:n},this.params.econtent.content.serial={int:this.serial++};var s=Math.floor(1e9*Math.random());return this.params.econtent.content.nonce={int:s},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},Mt(st.asn1.tsp.SimpleTSAAdapter,st.asn1.tsp.AbstractTSAAdapter),st.asn1.tsp.FixedTSAAdapter=function(t){var e=st,r=e.asn1.tsp,i=e.crypto.Util.hashHex;r.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(t,e){var n=i(t,e);return this.params.econtent.content.messageImprint={alg:e,hash:n},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},Mt(st.asn1.tsp.FixedTSAAdapter,st.asn1.tsp.AbstractTSAAdapter),st.asn1.tsp.TSPUtil=new function(){},st.asn1.tsp.TSPUtil.newTimeStampToken=function(t){return new st.asn1.tsp.TimeStampToken(t)},st.asn1.tsp.TSPUtil.parseTimeStampReq=function(t){return(new st.asn1.tsp.TSPParser).getTimeStampReq(t)},st.asn1.tsp.TSPUtil.parseMessageImprint=function(t){return(new st.asn1.tsp.TSPParser).getMessageImprint(t)},st.asn1.tsp.TSPParser=function(){Error;var t=new $t,e=ct,r=e.getV,i=e.getTLV,n=e.getIdxbyList,s=(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=s(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])),n=i(t,e[1]),o=this.getToken(n);return o.statusinfo=r,o}},this.getToken=function(t){var e=(new st.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 n={},o=s(e,0),a=r(e,o[1]);n.policy=Lt(a);var c=i(e,o[2]);n.messageImprint=this.getMessageImprint(c);var u=r(e,o[3]);n.serial={hex:u};var h=r(e,o[4]);n.genTime={str:mt(h)};var l=0;if(o.length>5&&"30"==e.substr(o[5],2)){var p=i(e,o[5]);n.accuracy=this.getAccuracy(p),l++}if(o.length>5+l&&"01"==e.substr(o[5+l],2)&&("ff"==r(e,o[5+l])&&(n.ordering=!0),l++),o.length>5+l&&"02"==e.substr(o[5+l],2)){var d=r(e,o[5+l]);n.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;n.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);n.ext=y,l++}return n},this.getAccuracy=function(t){for(var e={},i=s(t,0),n=0;n<i.length;n++){var o=t.substr(i[n],2),a=r(t,i[n]),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=(s(t,0),n(t,0,[0,0])),a=r(t,o),c=e.hextooidstr(a),u=st.asn1.x509.OID.oid2name(c);if(""==u)throw new Error("hashAlg name undefined: "+c);var h=u,l=n(t,0,[1]);return i.alg=h,i.hash=r(t,l),i},this.getPKIStatusInfo=function(t){var e={},n=s(t,0),a=0;try{var c=r(t,n[0]),u=parseInt(c,16);e.status=o[u]}catch(t){}if(n.length>1&&"30"==t.substr(n[1],2)){var h=i(t,n[1]);e.statusstr=this.getPKIFreeText(h),a++}if(n.length>a&&"03"==t.substr(n[1+a],2)){var l=i(t,n[1+a]);e.failinfo=this.getPKIFailureInfo(l)}return e},this.getPKIFreeText=function(t){for(var r=[],i=s(t,0),n=0;n<i.length;n++)r.push(e.getString(t,i[n]));return r},this.getPKIFailureInfo=function(t){var r=e.getInt(t,0);return null!=a[r]?a[r]:r},this.getTimeStampReq=function(t){var n={certreq:!1},o=s(t,0);if(o.length<2)throw new Error("TimeStampReq must have at least 2 items");var a=i(t,o[1]);n.messageImprint=st.asn1.tsp.TSPUtil.parseMessageImprint(a);for(var c=2;c<o.length;c++){var u=o[c],h=t.substr(u,2);if("06"==h){var l=r(t,u);n.policy=e.hextooidstr(l)}"02"==h&&(n.nonce=r(t,u)),"01"==h&&(n.certreq=!0)}return n}},void 0!==st&&st||(st={}),void 0!==st.asn1&&st.asn1||(st.asn1={}),void 0!==st.asn1.cades&&st.asn1.cades||(st.asn1.cades={}),st.asn1.cades.SignaturePolicyIdentifier=function(t){var e=st.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)},Mt(st.asn1.cades.SignaturePolicyIdentifier,st.asn1.cms.Attribute),st.asn1.cades.SignaturePolicyId=function(t){var e=st.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,n=(e.x509.AlgorithmIdentifier,e.cades),s=n.SignaturePolicyId,o=n.OtherHashAlgAndValue;s.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)},Mt(st.asn1.cades.SignaturePolicyId,st.asn1.ASN1Object),st.asn1.cades.OtherHashAlgAndValue=function(t){var e=Error,r=st.asn1,i=r.DERSequence,n=r.DEROctetString,s=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=st.crypto.Util.hashHex(o,t.alg)}var a=[];return a.push(new s({name:t.alg})),a.push(new n({hex:r})),new i({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cades.OtherHashAlgAndValue,st.asn1.ASN1Object),st.asn1.cades.OtherHashValue=function(t){st.asn1.cades.OtherHashValue.superclass.constructor.call(this);var e=Error,r=st,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 n=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(n=xt(t.cert)),r=st.crypto.Util.hashHex(n,"sha1")}return new i({hex:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cades.OtherHashValue,st.asn1.ASN1Object),st.asn1.cades.SignatureTimeStamp=function(t){var e=Error,r=st,i=r.lang.String.isHex,n=r.asn1,s=n.ASN1Object;n.x509,n.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 s).hTLV=t.tst,[r];if(t.tst instanceof s)return[t.tst];throw new e("params.tst has wrong value")}if(null!=t.res){var r,n=t.res;if(n instanceof s&&(n=n.tohex()),"string"!=typeof n||!i(n))throw new e("params.res has wrong value");return ct.getTLVbyList(n,0,[1]),(r=new s).hTLV=t.tst,[r]}},null!=t&&this.setByParam(t)},Mt(st.asn1.cades.SignatureTimeStamp,st.asn1.cms.Attribute),st.asn1.cades.CompleteCertificateRefs=function(t){var e=Error,r=st,i=r.asn1,n=i.DERSequence,s=i.cades,o=s.OtherCertID,a=r.lang.String.isHex;s.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 s=t.array[i];if("string"==typeof s)if(-1!=s.indexOf("-----BEGIN"))s={cert:s};else{if(!a(s))throw new e("unsupported value: "+s);s={hash:s}}null!=t.alg&&null==s.alg&&(s.alg=t.alg),null!=t.hasis&&null==s.hasis&&(s.hasis=t.hasis);var c=new o(s);r.push(c)}return[new n({array:r})]},null!=t&&this.setByParam(t)},Mt(st.asn1.cades.CompleteCertificateRefs,st.asn1.cms.Attribute),st.asn1.cades.OtherCertID=function(t){var e=st.asn1,r=e.DERSequence,i=e.cms.IssuerSerial,n=e.cades,s=n.OtherHashValue,o=n.OtherHashAlgAndValue;n.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,n=[];if(e=null!=t.alg?new o(t):new s(t),n.push(e),null!=t.cert&&1==t.hasis||null!=t.issuer&&null!=t.serial){var a=new i(t);n.push(a)}return new r({array:n}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cades.OtherCertID,st.asn1.ASN1Object),st.asn1.cades.OtherHash=function(t){Error;var e=st,r=e.asn1,i=(r.cms,r.cades),n=i.OtherHashAlgAndValue,s=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 n(t):new s(t)).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.cades.OtherHash,st.asn1.ASN1Object),st.asn1.cades.CAdESUtil=new function(){},st.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned=function(t){return(new st.asn1.cms.CMSParser).getCMSSignedData(t)},st.asn1.cades.CAdESUtil.parseSignerInfoForAddingUnsigned=function(t,e,r){var i=ct,n=i.getChildIdx,s=i.getTLV,o=i.getV,a=st.asn1,c=a.ASN1Object,u=a.cms,h=u.AttributeList,l=u.SignerInfo,p={},d=n(t,e);if(6!=d.length)throw"not supported items for SignerInfo (!=6)";var g=d.shift();p.version=s(t,g);var f=d.shift();p.si=s(t,f);var m=d.shift();p.digalg=s(t,m);var y=d.shift();p.sattrs=s(t,y);var S=d.shift();p.sigalg=s(t,S);var v=d.shift();p.sig=s(t,v),p.sigval=o(t,v);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 h,p},void 0!==st.asn1.csr&&st.asn1.csr||(st.asn1.csr={}),st.asn1.csr.CertificationRequest=function(t){var e=st.asn1,r=e.DERBitString,i=e.DERSequence,n=e.csr,s=(e.x509,n.CertificationRequestInfo);n.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.sign=function(){var t=new s(this.params).tohex(),e=new st.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 st.asn1.csr.CertificationRequestInfo(this.params),n=new st.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 s=new r({hex:"00"+t.sighex});return new i({array:[e,n,s]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.csr.CertificationRequest,st.asn1.ASN1Object),st.asn1.csr.CertificationRequestInfo=function(t){var e=st.asn1,r=(e.DERBitString,e.DERSequence),i=e.DERInteger,n=e.DERUTF8String,s=e.DERTaggedObject,o=e.ASN1Util.newObject,a=e.csr,c=e.x509,u=c.X500Name,h=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 u(t.subject)),e.push(new l(Vt.getKey(t.sbjpubkey))),null!=t.attrs){var a=function(t){for(var e=Error,r=st.asn1.x509.Extensions,i=[],n=0;n<t.length;n++){var s=t[n],o=s.attr;if("extensionRequest"==o){var a={seq:[{oid:"1.2.840.113549.1.9.14"},{set:[new r(s.ext)]}]};i.push(a)}else if("unstructuredName"==o)a={seq:[{oid:"1.2.840.113549.1.9.2"},{set:s.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:s.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 h(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 s({tag:"a0",explicit:!1,obj:new n({str:""})}));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Mt(st.asn1.csr.CertificationRequestInfo,st.asn1.ASN1Object),st.asn1.csr.AttributeList=function(t){},Mt(st.asn1.csr.AttributeList,st.asn1.ASN1Object),st.asn1.csr.CSRUtil=new function(){},st.asn1.csr.CSRUtil.newCSRPEM=function(t){return new st.asn1.csr.CertificationRequest(t).getPEM()},st.asn1.csr.CSRUtil.getParam=function(t,e){var r=ct,i=r.getV,n=r.getIdxbyList,s=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 u=xt(t,"CERTIFICATE REQUEST");e&&(c.tbs=s(u,0,[0]));try{var h=o(u,0,[0,1]);if("3000"==h)c.subject={};else{var l=new $t;c.subject=l.getX500Name(h)}}catch(t){}var p=o(u,0,[0,2]),d=Vt.getKey(p,null,"pkcs8pub");c.sbjpubkey=Vt.getPEM(d,"PKCS8PUB");var g=function(t){var e=n(t,0,[0,3,0,0],"06");return"2a864886f70d01090e"!=i(t,e)?null:s(t,0,[0,3,0,1,0],"30")}(u);l=new $t,null!=g&&(c.extreq=l.getExtParamArray(g));try{var f=o(u,0,[1],"30");l=new $t,c.sigalg=l.getAlgorithmIdentifierName(f)}catch(t){}try{var m=a(u,0,[2]);c.sighex=m}catch(t){}return c},st.asn1.csr.CSRUtil.verifySignature=function(t){try{var e=null;if("string"==typeof t&&-1!=t.indexOf("-----BEGIN CERTIFICATE REQUEST")?e=st.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 st.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!==st&&st||(st={}),void 0!==st.asn1&&st.asn1||(st.asn1={}),void 0!==st.asn1.ocsp&&st.asn1.ocsp||(st.asn1.ocsp={}),st.asn1.ocsp.DEFAULT_HASH="sha1",st.asn1.ocsp.OCSPResponse=function(t){st.asn1.ocsp.OCSPResponse.superclass.constructor.call(this),st.asn1.DEREnumerated;var e=st.asn1.ASN1Util.newObject,r=st.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 n=new r(t);return e({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:n}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.ocsp.OCSPResponse,st.asn1.ASN1Object),st.asn1.ocsp.ResponseBytes=function(t){st.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var e=st.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,n=e.DEROctetString,s=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 s(t),o=[];return o.push(new i({name:"ocspBasic"})),o.push(new n({hex:e.tohex()})),new r({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.ocsp.ResponseBytes,st.asn1.ASN1Object),st.asn1.ocsp.BasicOCSPResponse=function(t){st.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var e=Error,r=st.asn1,i=r.ASN1Object,n=r.DERSequence,s=(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 st.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=[],u=0;u<t.certs.length;u++){var h=t.certs[u],l=null;if(ct.isASN1HEX(h))l=h;else{if(!h.match(/-----BEGIN/))throw new e("certs["+u+"] not hex or PEM");l=xt(h)}c.push(new i({tlv:l}))}var p=new n({array:c});r.push(new s({tag:"a0",explicit:!0,obj:p}))}return new n({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.ocsp.BasicOCSPResponse,st.asn1.ASN1Object),st.asn1.ocsp.ResponseData=function(t){st.asn1.ocsp.ResponseData.superclass.constructor.call(this);var e=Error,r=st.asn1,i=r.DERSequence,n=r.DERGeneralizedTime,s=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 n(t.prodat)),r.push(new _SingleResponseList(t.array)),null!=t.ext){var a=new o(t.ext);r.push(new s({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)},Mt(st.asn1.ocsp.ResponseData,st.asn1.ASN1Object),st.asn1.ocsp.ResponderID=function(t){st.asn1.ocsp.ResponderID.superclass.constructor.call(this);var e=st,r=e.asn1,i=r.ASN1Util.newObject,n=r.x509.X500Name,s=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?(s(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 n(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)},Mt(st.asn1.ocsp.ResponderID,st.asn1.ASN1Object),st.asn1.ocsp.SingleResponseList=function(t){st.asn1.ocsp.SingleResponseList.superclass.constructor.call(this);var e=st.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=[],n=0;n<t.length;n++)e.push(new i(t[n]));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)},Mt(st.asn1.ocsp.SingleResponseList,st.asn1.ASN1Object),st.asn1.ocsp.SingleResponse=function(t){var e=Error,r=st.asn1,i=r.DERSequence,n=r.DERGeneralizedTime,s=r.DERTaggedObject,o=r.ocsp,a=o.CertID,c=o.CertStatus,u=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 n(t.thisupdate)),null!=t.nextupdate){var o=new n(t.nextupdate);r.push(new s({tag:"a0",explicit:!0,obj:o}))}if(null!=t.ext){var h=new u(t.ext);r.push(new s({tag:"a1",explicit:!0,obj:h}))}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)},Mt(st.asn1.ocsp.SingleResponse,st.asn1.ASN1Object),st.asn1.ocsp.CertID=function(t){var e=st,r=e.asn1,i=r.DEROctetString,n=r.DERInteger,s=r.DERSequence,o=r.x509.AlgorithmIdentifier,a=r.ocsp,c=(a.DEFAULT_HASH,e.crypto.Util.hashHex),u=$t,h=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 u(t),n=new u(e),s=c(i.getSubjectHex(),r),o=i.getPublicKeyHex();return{alg:r,issname:s,isskey:c(h(o,0,[1],"03",!0),r),sbjsn:n.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 u=this.getParamByCerts(c.issuerCert,c.subjectCert,a);t=u.issname,e=u.isskey,r=u.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 h=new o({name:a}),l=new i({hex:t}),p=new i({hex:e}),d=new n({hex:r}),g=new s({array:[h,l,p,d]});return this.hTLV=g.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Mt(st.asn1.ocsp.CertID,st.asn1.ASN1Object),st.asn1.ocsp.CertStatus=function(t){st.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 st.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)},Mt(st.asn1.ocsp.CertStatus,st.asn1.ASN1Object),st.asn1.ocsp.Request=function(t){var e=st.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 n=new i.CertID(t);this.dReqCert=n}},Mt(st.asn1.ocsp.Request,st.asn1.ASN1Object),st.asn1.ocsp.TBSRequest=function(t){var e=st.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 n=new i.Request(t[0]);e.push(n)}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)},Mt(st.asn1.ocsp.TBSRequest,st.asn1.ASN1Object),st.asn1.ocsp.OCSPRequest=function(t){var e=st.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 n=new i.TBSRequest(t);this.dTbsRequest=n}},Mt(st.asn1.ocsp.OCSPRequest,st.asn1.ASN1Object),st.asn1.ocsp.OCSPUtil={},st.asn1.ocsp.OCSPUtil.getRequestHex=function(t,e,r){var i=st.asn1.ocsp;void 0===r&&(r=i.DEFAULT_HASH);var n={alg:r,issuerCert:t,subjectCert:e};return new i.OCSPRequest({reqList:[n]}).tohex()},st.asn1.ocsp.OCSPUtil.getOCSPResponseInfo=function(t){var e=ct,r=e.getVbyList,i=e.getVbyListEx,n=e.getIdxbyList,s=(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=n(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 u=n(t,0,[1,0,1,0,0,2,0,2]);o.thisUpdate=mt(s(t,u))}catch(t){}try{var h=n(t,0,[1,0,1,0,0,2,0,3]);"a0"===t.substr(h,2)&&(o.nextUpdate=mt(r(t,h,[0])))}catch(t){}return o},st.asn1.ocsp.OCSPParser=function(){var t=Error,e=$t,r=new e,i=ct,n=i.getV,s=i.getTLV,o=i.getIdxbyList,a=i.getVbyList,c=i.getTLVbyList,u=i.getVbyListEx,h=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(s(e,r[0]))},this.getTBSRequest=function(t){var e={},i=h(t,0,[0],"30");e.array=this.getRequestList(i);var n=h(t,0,["[2]",0],"30");return null!=n&&(e.ext=r.getExtParamArray(n)),e},this.getRequestList=function(t){for(var e=[],r=l(t,0),i=0;i<r.length;i++)t=s(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 n=this.getCertID(s(e,i[0]));if(2==i.length){var a=o(e,0,[1,0]);n.ext=r.getExtParamArray(s(e,a))}return n},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(s(r,i[0])),a.issname=n(r,i[1]),a.isskey=n(r,i[2]),a.sbjsn=n(r,i[3]),a},this.getOCSPResponse=function(t){var e,r=l(t,0),i=n(t,r[0]),s=parseInt(i);if(1==r.length)return{resstatus:s};var o=c(t,0,[1,0]);return(e=this.getResponseBytes(o)).resstatus=s,e},this.getResponseBytes=function(t){var e,r=l(t,0),i=c(t,0,[1,0]);e=this.getBasicOCSPResponse(i);var s=n(t,r[0]);return e.restype=st.asn1.x509.OID.oid2name(Lt(s)),e},this.getBasicOCSPResponse=function(t){var e,r=l(t,0);e=this.getResponseData(s(t,r[0]));var i=new $t;e.alg=i.getAlgorithmIdentifierName(s(t,r[1]));var o=n(t,r[2]);e.sighex=o.substr(2);var a=u(t,0,["[0]"]);if(null!=a){for(var c=l(a,0),h=[],p=0;p<c.length;p++){var d=s(a,c[p]);h.push(d)}e.certs=h}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(s(t,e[o++]));var a=n(t,e[o++]);if(i.prodat=mt(a),i.array=this.getSingleResponseList(s(t,e[o++])),"a1"==t.substr(e[r-1],2)){var u=c(t,e[r-1],[0]),h=new $t;i.ext=h.getExtParamArray(u)}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]),n=new $t;e.name=n.getX500Name(i)}return e},this.getSingleResponseList=function(t){for(var e=l(t,0),r=[],i=0;i<e.length;i++){var n=this.getSingleResponse(s(t,e[i]));r.push(n)}return r},this.getSingleResponse=function(t){var e=l(t,0),r={},i=this.getCertID(s(t,e[0]));r.certid=i;var o=this.getCertStatus(s(t,e[1]));if(r.status=o,"18"==t.substr(e[2],2)){var u=n(t,e[2]);r.thisupdate=mt(u)}for(var h=3;h<e.length;h++){if("a0"==t.substr(e[h],2)){var p=a(t,e[h],[0],"18");r.nextupdate=mt(p)}if("a1"==t.substr(e[h],2)){var d=new $t,g=c(t,0,[h,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!==st&&st||(st={}),void 0!==st.lang&&st.lang||(st.lang={}),st.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(At(Nt(t)))},at=function(t){return decodeURIComponent(bt(gt(t)))}),st.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},st.lang.String.isHex=function(t){return Dt(t)},st.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},st.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=pt(t),st.lang.String.isBase64(t))},st.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},st.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},st.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},st.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 Ht=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 n=r.toString(2),s="";for(i=n.length-1;i>=0;i--)s+=n[i];return s}function jt(t,e,r){if("object"==typeof t){e=String(e).split(".");for(var i=0;i<e.length&&t;i++){var n=e[i];n.match(/^[0-9]+$/)&&(n=parseInt(n)),t=t[n]}return t||!1===t?t:r}}function Mt(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!==st&&st||(st={}),void 0!==st.crypto&&st.crypto||(st.crypto={}),st.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),n=r/4;if(i.length+22>n)throw"key is too short for SigAlg: keylen="+r+","+e;for(var s="00"+i,o="",a=n-4-s.length,c=0;c<a;c+=2)o+="ff";return"0001"+o+s},this.hashString=function(t,e){return new st.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new st.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 st.crypto.DSA||t instanceof st.crypto.ECDSA}},st.crypto.Util.md5=function(t){return new st.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},st.crypto.Util.ripemd160=function(t){return new st.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},st.crypto.Util.SECURERANDOMGEN=new Q,st.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return st.crypto.Util.SECURERANDOMGEN.nextBytes(e),ut(e)},st.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new E(st.crypto.Util.getRandomHexOfNbytes(t),16)},st.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,r=new Array((t-e)/8+1);return st.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<e&255^255)&r[0],ut(r)},st.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new E(st.crypto.Util.getRandomHexOfNbits(t),16)},st.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=st.crypto.Util.getRandomBigIntegerOfNbits(e);if(t.compareTo(r)>=0)return r}},st.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 st.crypto.Util.getRandomBigIntegerZeroToMax(i).add(t)},st.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=st.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=st.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=st.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=st.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},st.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},st.crypto.MessageDigest.getHashLength=function(t){var e=st.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},st.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},st.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=st.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=st.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=vt(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=vt(t.rstr)),void 0!==t.b64&&(e=v(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=st.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},st.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,n=0;n<i;n++)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 st.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?Vt.getKey(t):Vt.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!==st.crypto.ECDSA&&(this.prvKey=new st.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 st.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof st.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!==st.crypto.ECDSA&&(this.pubKey=new st.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!==st.crypto.ECDSA&&this.pubKey instanceof st.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==st.crypto.DSA&&this.pubKey instanceof st.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=st.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=Vt.getKey(t.prvkeypem),this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},st.crypto.Cipher=function(t){},st.crypto.Cipher.encrypt=function(t,e,r,i){if(null!=jt(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var n=e,s=t;null!=jt(i,"key")&&(n=i.key),null!=jt(i,"enc")&&(hEnc=i.enc);var o,a=f.enc.Hex.parse(n),c=f.enc.Hex.parse(s),u=f.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)o=f.TripleDES.encrypt(c,a,{iv:u});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);o=f.AES.encrypt(c,a,{iv:u})}return o+""}throw new Error("Cipher.encrypt: unsupported key or algorithm")},st.crypto.Cipher.decrypt=function(t,e,r,i){if(null!=jt(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var n=e,s=t;null!=jt(i,"key")&&(n=i.key),null!=jt(i,"enc")&&(s=i.enc);var o,a=f.enc.Hex.parse(n),c=f.enc.Hex.parse(s),u=f.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)o=f.TripleDES.decrypt({ciphertext:c},a,{iv:u});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);o=f.AES.decrypt({ciphertext:c},a,{iv:u})}return f.enc.Hex.stringify(o)}throw new Error("Cipher.decrypt: unsupported key or algorithm")},st.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!==st&&st||(st={}),void 0!==st.crypto&&st.crypto||(st.crypto={}),st.crypto.ECDSA=function(t){var e=Error,r=E,i=rt,n=st.crypto.ECDSA,s=st.crypto.ECParameterDB,o=n.getName,a=ct,c=a.getVbyListEx,u=a.isASN1HEX,h=new Q;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(t){return new r(t.bitLength(),h).mod(t.subtract(r.ONE)).add(r.ONE)},this.setNamedCurve=function(t){this.ecparams=s.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(),n=e.getY().toBigInteger(),s=this.ecparams.keycharlen,o="04"+("0000000000"+i.toString(16)).slice(-s)+("0000000000"+n.toString(16)).slice(-s);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),s=this.ecparams.n,o=new r(t.substring(0,this.ecparams.keycharlen),16);do{var a=this.getBigRandom(s),c=this.ecparams.G.multiply(a).getX().toBigInteger().mod(s)}while(c.compareTo(r.ZERO)<=0);var u=a.modInverse(s).multiply(o.add(i.multiply(c))).mod(s);return n.biRSSigToASN1Sig(c,u)},this.sign=function(t,e){var i=e,n=this.ecparams.n,s=r.fromByteArrayUnsigned(t);do{var o=this.getBigRandom(n),a=this.ecparams.G.multiply(o).getX().toBigInteger().mod(n)}while(a.compareTo(E.ZERO)<=0);var c=o.modInverse(n).multiply(s.add(i.multiply(a))).mod(n);return this.serializeSig(a,c)},this.verifyWithMessageHash=function(t,e){return this.verifyHex(t,e,this.pubKeyHex)},this.verifyHex=function(t,e,s){try{var o,a,c=n.parseSigHex(e);o=c.r,a=c.s;var u=i.decodeFromHex(this.ecparams.curve,s),h=new r(t.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(h,o,a,u)}catch(t){return!1}},this.verify=function(t,e,n){var s,o,a;if(Bitcoin.Util.isArray(e)){var c=this.parseSig(e);s=c.r,o=c.s}else{if("object"!=typeof e||!e.r||!e.s)throw"Invalid value for signature";s=e.r,o=e.s}if(n instanceof rt)a=n;else{if(!Bitcoin.Util.isArray(n))throw"Invalid format for pubkey value, must be byte array or ECPointFp";a=i.decodeFrom(this.ecparams.curve,n)}var u=r.fromByteArrayUnsigned(t);return this.verifyRaw(u,s,o,a)},this.verifyRaw=function(t,e,i,n){var s=this.ecparams.n,o=this.ecparams.G;if(e.compareTo(r.ONE)<0||e.compareTo(s)>=0)return!1;if(i.compareTo(r.ONE)<0||i.compareTo(s)>=0)return!1;var a=i.modInverse(s),c=t.multiply(a).mod(s),u=e.multiply(a).mod(s);return o.multiply(c).add(n.multiply(u)).getX().toBigInteger().mod(s).equals(e)},this.serializeSig=function(t,e){var r=t.toByteArraySigned(),i=e.toByteArraySigned(),n=[];return n.push(2),n.push(r.length),(n=n.concat(r)).push(2),n.push(i.length),(n=n.concat(i)).unshift(n.length),n.unshift(48),n},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 n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:r.fromByteArrayUnsigned(i),s:r.fromByteArrayUnsigned(n)}},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===u(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===u(t))throw new e("not ASN.1 hex string");var r,i,n;try{c(t,0,[1,0],"06"),r=c(t,0,[1,1],"06"),i=c(t,0,[2,0,1],"04");try{n=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(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===u(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===u(t))throw new e("not ASN.1 hex string");var i,n;try{i=c(t,0,[0,5,0,1],"06"),n=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(n)},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))},st.crypto.ECDSA.parseSigHex=function(t){var e=st.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new E(e.r,16),s:new E(e.s,16)}},st.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 n=r(t,0);if(2!=n.length)throw new Error("signature shall have two elements");var s=n[0],o=n[1];if("02"!=t.substr(s,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,s),s:i(t,o)}},st.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=st.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 n=Math.max(r.length,i.length);return(r=("000000"+r).slice(-n))+("000000"+i).slice(-n)}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},st.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 st.crypto.ECDSA.hexRSSigToASN1Sig(e,r)},st.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var r=new E(t,16),i=new E(e,16);return st.crypto.ECDSA.biRSSigToASN1Sig(r,i)},st.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var r=st.asn1,i=new r.DERInteger({bigint:t}),n=new r.DERInteger({bigint:e});return new r.DERSequence({array:[i,n]}).tohex()},st.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!==st&&st||(st={}),void 0!==st.crypto&&st.crypto||(st.crypto={}),st.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,n,s,o,a,c,u,h,l,p,d,g){t[i]={};var f=r(s),m=r(o),y=r(a),S=r(c),v=r(u),E=new it(f,m,y),x=E.decodePointHex("04"+h+l);t[i].name=i,t[i].keylen=n,t[i].keycharlen=2*Math.ceil(n/8),t[i].curve=E,t[i].G=x,t[i].n=S,t[i].h=v,t[i].oid=d,t[i].info=g;for(var A=0;A<p.length;A++)e[p[A]]=i}},st.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),st.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),st.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),st.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),st.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),st.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),st.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),st.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),st.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),st.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]),void 0!==st&&st||(st={}),void 0!==st.crypto&&st.crypto||(st.crypto={}),st.crypto.DSA=function(){var t=ct,e=(t.getVbyList,t.getVbyListEx),r=t.isASN1HEX,i=E,n=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,n){this.isPrivate=!0,this.p=t,this.q=e,this.g=r,this.y=i,this.x=n},this.setPrivateHex=function(t,e,r,i,n){var s,o,a,c,u;s=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,u=new E(n,16),this.setPrivate(s,o,a,c,u)},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(n.compareTo(e)>=0||e.compareTo(t)>=0)throw new Error("invalid DSA public key");if(n.compareTo(r)>=0||r.compareTo(t)>=0)throw new Error("invalid DSA public key");if(n.compareTo(i)>=0||i.compareTo(t)>=0)throw new Error("invalid DSA public key");if(0!=r.modPow(e,t).compareTo(n))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 n,s,o,a;n=new E(t,16),s=new E(e,16),o=new E(r,16),a=new E(i,16),this.setPublic(n,s,o,a)},this.signWithMessageHash=function(t){var e,r,i,n=this.p,s=this.q,o=this.g,a=(this.y,this.x),c=new E(t.substr(0,s.bitLength()/4),16);do{e=st.crypto.Util.getRandomBigIntegerMinToMax(E.ONE.add(E.ONE),s.subtract(E.ONE)),r=o.modPow(e,n).mod(s),i=e.modInverse(s).multiply(c.add(a.multiply(r))).mod(s)}while(0==r.compareTo(E.ZERO)||0==i.compareTo(E.ZERO));return st.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:r}},{int:{bigint:i}}]})},this.verifyWithMessageHash=function(t,e){var r=this.p,i=this.q,n=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],c=o[1],u=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 h=c.modInverse(i),l=u.multiply(h).mod(i),p=a.multiply(h).mod(i);return 0==n.modPow(l,r).multiply(s.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,n,s,o,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1],"02"),n=e(t,0,[2],"02"),s=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,n,s,o,a)},this.readPKCS8PrvKeyHex=function(t){var i,n,s,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1,1,0],"02"),n=e(t,0,[1,1,1],"02"),s=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,n,s,null,o)},this.readPKCS8PubKeyHex=function(t){var i,n,s,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[0,1,0],"02"),n=e(t,0,[0,1,1],"02"),s=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,n,s,o)},this.readCertPubKeyHex=function(t,i){var n,s,o,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{n=e(t,0,[0,5,0,1,0],"02"),s=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(n,s,o,a)}};var Vt=function(){var t=function(t,r,i){return e(f.AES,t,r,i)},e=function(t,e,r,i){var n=f.enc.Hex.parse(e),s=f.enc.Hex.parse(r),o=f.enc.Hex.parse(i),a={};a.key=s,a.iv=o,a.ciphertext=n;var c=t.decrypt(a,s,{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 n=f.enc.Hex.parse(e),s=f.enc.Hex.parse(r),o=f.enc.Hex.parse(i),a=t.encrypt(n,s,{iv:o}),c=f.enc.Hex.parse(a.toString());return f.enc.Base64.stringify(c)},n={"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}},s=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 n=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(n=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(n=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=n&&-1!=o){var a=t.substring(n+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,r){for(var i=r.substring(0,16),s=f.enc.Hex.parse(i),o=f.enc.Utf8.parse(e),a=n[t].keylen+n[t].ivlen,c="",u=null;;){var h=f.algo.MD5.create();if(null!=u&&h.update(u),h.update(o),h.update(s),u=h.finalize(),(c+=f.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=c.substr(0,2*n[t].keylen),l.ivhex=c.substr(2*n[t].keylen,2*n[t].ivlen),l},a=function(t,e,r,i){var s=f.enc.Base64.parse(t),o=f.enc.Hex.stringify(s);return(0,n[e].proc)(o,r,i)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(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=s(t),i=(r.type,r.cipher),n=r.ivsalt,c=r.data,u=o(i,e,n).keyhex;return a(c,i,u,n)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,i,s){var a="";if(void 0!==i&&null!=i||(i="AES-256-CBC"),void 0===n[i])throw new Error("KEYUTIL unsupported algorithm: "+i);if(void 0===s||null==s){var c=function(t){var e=f.lib.WordArray.random(t);return f.enc.Hex.stringify(e)}(n[i].ivlen);s=c.toUpperCase()}var u=function(t,e,r,i){return(0,n[e].eproc)(t,r,i)}(e,i,o(i,r,s).keyhex,s);return a="-----BEGIN "+t+" PRIVATE KEY-----\r\n",a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+i+","+s+"\r\n",a+="\r\n",(a+=u.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 n=this.generatePBES2ASN1Param(i);return st.asn1.ASN1Util.newObject(n).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=Vt.getDKFromPBES2Param(t,e);try{var i=st.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,n={},s=r(t,0);if(2!=s.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+s.length);n.ciphertext=i(t,s[1]);var o=r(t,s[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";n.encryptionSchemeAlg="TripleDES",n.encryptionSchemeIV=i(t,c[1]);var u=r(t,a[0]);if(2!=u.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length);if("2a864886f70d01050c"!=i(t,u[0]))throw new Error("this only supports pkcs5PBKDF2");var h=r(t,u[1]);if(h.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+h.length);n.pbkdf2Salt=i(t,h[0]);var l=i(t,h[1]);try{n.pbkdf2Iter=parseInt(l,16)}catch(t){throw new Error("malformed format pbkdf2Iter: "+l)}return n},getPBKDF2KeyHexFromParam:function(t,e){var r=f.enc.Hex.parse(t.pbkdf2Salt),i=t.pbkdf2Iter,n=f.PBKDF2(e,r,{keySize:6,iterations:i});return f.enc.Hex.stringify(n)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=xt(t,"ENCRYPTED PRIVATE KEY"),i=this.parseHexOfEncryptedPKCS8(r),n=Vt.getPBKDF2KeyHexFromParam(i,e),s={};s.ciphertext=f.enc.Hex.parse(i.ciphertext);var o=f.enc.Hex.parse(n),a=f.enc.Hex.parse(i.encryptionSchemeIV),c=f.TripleDES.decrypt(s,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"),n=jt(r,"1.int.hex"),s=jt(r,"2.seq.0.oid","hmacWithSHA1"),o=-1;try{o=parseInt(n,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"),u=jt(e,"seq.1.octstr.hex");if(null==a||null==c||null==u)throw new Error("encalg, enciv or enc is undefined");return{salt:i,iter:o,prf:s,encalg:a,enciv:c,enc:u}},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 n=f.enc.Hex.parse(t.salt),s=t.iter;try{var o=f.PBKDF2(e,n,{keySize:i,iterations:s,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=Vt.parsePBES2(i)}catch(t){throw new Error("malformed PBES2 format: "+t.message)}var n=Vt.getDKFromPBES2Param(r,e);return st.crypto.Cipher.decrypt(r.enc,n,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,n={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=r(t,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");var o=r(t,s[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(n.algoid=i(t,o[0]),"06"==t.substr(o[1],2)&&(n.algparam=i(t,o[1])),"04"!=t.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return n.keyidx=e.getVidx(t,s[2]),n},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 st.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw new Error("unsupported private key algorithm");e=new st.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 st.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw new Error("unsupported PKCS#8 public key hex");e=new st.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=ct,r=e.getChildIdx,i=e.getV,n={};if("30"!=t.substr(0,2))throw new Error("malformed RSA key(code:001)");var s=r(t,0);if(2!=s.length)throw new Error("malformed RSA key(code:002)");if("02"!=t.substr(s[0],2))throw new Error("malformed RSA key(code:003)");if(n.n=i(t,s[0]),"02"!=t.substr(s[1],2))throw new Error("malformed RSA key(code:004)");return n.e=i(t,s[1]),n},parsePublicPKCS8Hex:function(t){var e=ct,r=e.getChildIdx,i=e.getV,n={algparam:null},s=r(t,0);if(2!=s.length)throw new Error("outer DERSequence shall have 2 elements: "+s.length);var o=s[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(n.algoid=i(t,a[0]),"06"==t.substr(a[1],2)?n.algparam=i(t,a[1]):"30"==t.substr(a[1],2)&&(n.algparam={},n.algparam.p=e.getVbyList(t,a[1],[0],"02"),n.algparam.q=e.getVbyList(t,a[1],[1],"02"),n.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw new Error("malformed PKCS8 public key(code:004)");return n.key=i(t,s[1]).substr(2),n}}}();function Kt(t,e){for(var r="",i=e/4-t.length,n=0;n<i;n++)r+="0";return r+t}function Gt(t,e,r){for(var i="",n=0;i.length<e;)i+=St(r(vt(t+String.fromCharCode.apply(String,[(4278190080&n)>>24,(16711680&n)>>16,(65280&n)>>8,255&n])))),n+=1;return i}function qt(t){for(var e in st.crypto.Util.DIGESTINFOHEAD){var r=st.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,n=r.getV,s=(r.dump,r.parse),o=r.getTLV,a=r.getVbyList,c=r.getVbyListEx,u=r.getTLVbyList,h=r.getTLVbyListEx,l=r.getIdxbyList,p=r.getIdxbyListEx,d=r.getVidx,g=r.getInt,f=r.oidname,m=r.hextooidstr,y=xt,S=Error;try{e=st.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=u(this.hex,0,[0,0]);if("a0"==t.substr(0,2)){var e=u(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=h(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 u(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 u(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 u(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 Vt.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=u(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=u(this.hex,0,[0],"30"),n=new st.crypto.Signature({alg:e});return n.init(t),n.updateHex(i),n.verify(r)},this.parseExt=function(t){var e,s,o;if(void 0===t){if(o=this.hex,3!==this.version)return-1;e=l(o,0,[0,7,0],"30"),s=i(o,e)}else{o=xt(t);var c=l(o,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=n(o,c))return void(this.aExtInfo=new Array);e=l(o,0,[0,3,0,1,0],"30"),s=i(o,e),this.hex=o}this.aExtInfo=new Array;for(var u=0;u<s.length;u++){var h={critical:!1},p=0;3===i(o,s[u]).length&&(h.critical=!0,p=1),h.oid=r.hextooidstr(a(o,s[u],[0],"06"));var g=l(o,s[u],[1+p]);h.vidx=d(o,g),this.aExtInfo.push(h)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(t.match(/^[0-9.]+$/)||(r=st.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 s=n(t,10),a=parseInt(s,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 n={extname:"nameConstraints"};e&&(n.critical=!0);for(var s=i(t,0),a=0;a<s.length;a++){for(var c=[],u=i(t,s[a]),h=0;h<u.length;h++){var l=o(t,u[h]),p=this.getGeneralSubtree(l);c.push(p)}var d=t.substr(s[a],2);"a0"==d?n.permit=c:"a1"==d&&(n.exclude=c)}return n}},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 s=this.getGeneralName(o(t,e[0])),a=1;a<r;a++){var c=t.substr(e[a],2),u=n(t,e[a]),h=parseInt(u,16);"80"==c&&(s.min=h),"81"==c&&(s.max=h)}return s},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 s=n(t,0);return i.kid={hex:s},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 s={extname:"authorityKeyIdentifier"};e&&(s.critical=!0);for(var a=i(t,0),c=0;c<a.length;c++){var u=t.substr(a[c],2);if("80"===u&&(s.kid={hex:n(t,a[c])}),"a1"===u){var h=o(t,a[c]),l=this.getGeneralNames(h);s.issuer=l[0].dn}"82"===u&&(s.sn={hex:n(t,a[c])})}return s},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 s={extname:"extKeyUsage",array:[]};e&&(s.critical=!0);for(var a=i(t,0),c=0;c<a.length;c++)s.array.push(f(n(t,a[c])));return s},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 s=i(r,0),a=0;a<s.length;a++)e.push(f(n(r,s[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=[],n=0;n<e.length;n++){var s=this.getGeneralName(o(t,e[n]));void 0!==s&&r.push(s)}return r},this.getGeneralName=function(t){var e=t.substr(0,2),r=n(t,0),i=St(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,s=this.getExtInfo("subjectAltName");if(void 0===s)return s;for(var a=new Array,c=o(this.hex,s.vidx),u=i(c,0),h=0;h<u.length;h++)r=c.substr(u[h],2),t=n(c,u[h]),"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 n={extname:"cRLDistributionPoints",array:[]};e&&(n.critical=!0);for(var s=i(t,0),a=0;a<s.length;a++){var c=o(t,s[a]);n.array.push(this.getDistributionPoint(c))}return n},this.getDistributionPoint=function(t){for(var e={},r=i(t,0),n=0;n<r.length;n++){var s=t.substr(r[n],2),a=o(t,r[n]);"a0"==s&&(e.dpname=this.getDistributionPointName(a))}return e},this.getDistributionPointName=function(t){for(var e={},r=i(t,0),n=0;n<r.length;n++){var s=t.substr(r[n],2),a=o(t,r[n]);"a0"==s&&(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),n=0;n<r.length;n++){var s=a(this.hex,r[n],[0],"06"),o=a(this.hex,r[n],[1],"86");"2b06010505073001"===s&&e.ocsp.push(mt(o)),"2b06010505073002"===s&&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 n={extname:"authorityInfoAccess",array:[]};e&&(n.critical=!0);for(var s=i(t,0),u=0;u<s.length;u++){var h=c(t,s[u],[0],"06"),l=mt(a(t,s[u],[1],"86"));if("2b06010505073001"==h)n.array.push({ocsp:l});else{if("2b06010505073002"!=h)throw new Error("unknown method: "+h);n.array.push({caissuer:l})}}return n},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 n={extname:"certificatePolicies",array:[]};e&&(n.critical=!0);for(var s=i(t,0),a=0;a<s.length;a++){var c=o(t,s[a]),u=this.getPolicyInformation(c);n.array.push(u)}return n},this.getPolicyInformation=function(t){var e={},r=a(t,0,[0],"06");e.policyoid=f(r);var n=p(t,0,[1],"30");if(-1!=n){e.array=[];for(var s=i(t,n),c=0;c<s.length;c++){var u=o(t,s[c]),h=this.getPolicyQualifierInfo(u);e.array.push(h)}}return e},this.getOtherName=function(t){var e={},r=i(t,0),n=a(t,r[0],[],"06"),o=a(t,r[1],[]);return e.oid=f(n),e.value=s(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=St(i)}else if("2b06010505070202"===r){var n=u(t,0,[1],"30");e.unotice=this.getUserNotice(n)}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 n=this._asn1ToNoticeRef(r[i]);null!=n&&(e.noticeref=n);var s=this.asn1ToDisplayText(r[i]);null!=s&&(e.exptext=s)}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 n=this._asn1ToNoticeNum(r[i]);null!=n&&(e.noticenum=n);var s=this.asn1ToDisplayText(r[i]);null!=s&&(e.org=s)}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 n=e[i];r.push(parseInt(jt(n,"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=St(n(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 n=s(t).seq,o=[],a=0;a<n.length;a++){var c=n[a].seq;o.push([c[0].oid,c[1].oid])}i.array=o}catch(t){throw new S("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 n=s(t);try{for(var o=n.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 S("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 n=g(t,0);return-1==n?new S("wrong value"):(i.skip=n,i)}},this.getExtCRLNumber=function(t,e){var r={extname:"cRLNumber"};if(e&&(r.critical=!0),"02"==t.substr(0,2))return r.num={hex:n(t,0)},r;throw new S("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(n(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=n(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 n={extname:"adobeTimeStamp"};e&&(n.critical=!0);var s=i(t,0);if(s.length>1){var a=o(t,s[1]),c=this.getGeneralName(a);null!=c.uri&&(n.uri=c.uri)}if(s.length>2){var u=o(t,s[2]);"0101ff"==u&&(n.reqauth=!0),"010100"==u&&(n.reqauth=!1)}return n},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 n=s(t),a=[],c=0;c<n.seq.length;c++){var u=n.seq[c],h=jt(u,"seq.0.oid"),l=jt(u,"seq.1.set");if(null==h||null==l)throw"error";a.push({attr:h,array:l})}return i.array=a,i}catch(t){throw new Error("malformed subjectDirectoryAttributes extension value")}};var v=function(t){var e={};try{var r=t.seq[0].oid,i=st.asn1.x509.OID.name2oid(r);e.type=st.asn1.x509.OID.oid2atype(i);var n=t.seq[1];if(null!=n.utf8str)e.ds="utf8",e.value=n.utf8str.str;else if(null!=n.numstr)e.ds="num",e.value=n.numstr.str;else if(null!=n.telstr)e.ds="tel",e.value=n.telstr.str;else if(null!=n.prnstr)e.ds="prn",e.value=n.prnstr.str;else if(null!=n.ia5str)e.ds="ia5",e.value=n.ia5str.str;else if(null!=n.visstr)e.ds="vis",e.value=n.visstr.str;else{if(null==n.bmpstr)throw"error";e.ds="bmp",e.value=n.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 v(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 n=t[i],s=0;s<n.length;s++)r.push(n[s]);for(i=0;i<r.length;i++){var o=r[i],a=o.ds,c=o.value,u=o.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=u)return"mixed";if(st.lang.String.isMail(c))continue;return"mixed"}if("C"==u){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=s(t);return v(e)},this.getRDN=function(t){var e=s(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)}}(s(t))},this.getX500Name=function(t,e,r){var i=this.getX500NameArray(t),n={str:this.dnarraytostr(i)};return n.array=i,1==r&&(n.hex=t),1==e&&(n.canon=this.c14nRDNArray(i)),n},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=u(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=h(this.hex,0,[0,"[3]",0],"30"));for(var e=[],r=i(t,0),n=0;n<r.length;n++){var s=o(t,r[n]),a=this.getExtParam(s);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")),n=!1;3==e&&"0101ff"==u(t,0,[1])&&(n=!0);var o=u(t,0,[e-1,0]),c=void 0;if("2.5.29.14"==r?c=this.getExtSubjectKeyIdentifier(o,n):"2.5.29.15"==r?c=this.getExtKeyUsage(o,n):"2.5.29.17"==r?c=this.getExtSubjectAltName(o,n):"2.5.29.18"==r?c=this.getExtIssuerAltName(o,n):"2.5.29.19"==r?c=this.getExtBasicConstraints(o,n):"2.5.29.30"==r?c=this.getExtNameConstraints(o,n):"2.5.29.31"==r?c=this.getExtCRLDistributionPoints(o,n):"2.5.29.32"==r?c=this.getExtCertificatePolicies(o,n):"2.5.29.33"==r?c=this.getExtPolicyMappings(o,n):"2.5.29.35"==r?c=this.getExtAuthorityKeyIdentifier(o,n):"2.5.29.36"==r?c=this.getExtPolicyConstraints(o,n):"2.5.29.37"==r?c=this.getExtExtKeyUsage(o,n):"2.5.29.54"==r?c=this.getExtInhibitAnyPolicy(o,n):"1.3.6.1.5.5.7.1.1"==r?c=this.getExtAuthorityInfoAccess(o,n):"2.5.29.20"==r?c=this.getExtCRLNumber(o,n):"2.5.29.21"==r?c=this.getExtCRLReason(o,n):"2.5.29.9"==r?c=this.getExtSubjectDirectoryAttributes(o,n):"1.3.6.1.5.5.7.48.1.2"==r?c=this.getExtOcspNonce(o,n):"1.3.6.1.5.5.7.48.1.5"==r?c=this.getExtOcspNoCheck(o,n):"1.2.840.113583.1.1.9.1"==r?c=this.getExtAdobeTimeStamp(o,n):null!=$t.EXT_PARSER[r]&&(c=$t.EXT_PARSER[r](r,n,o)),null!=c)return c;var h={extname:r,extn:o};try{h.extn=s(o)}catch(t){}return n&&(h.critical=!0),h},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,n=0;n<i.length;n++)if(null!=i[n].dpname&&null!=i[n].dpname.full)for(var s=i[n].dpname.full,o=0;o<s.length;o++){var a=s[n];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,n=0;n<i.length;n++)null!=i[n].ocsp&&(i[n].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var i=r.array,n=0;n<i.length;n++)null!=i[n].caissuer&&(i[n].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 st.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],n=[],s=0;s<i.length;s++){var o=i[s],a=o.value;a=(a=(a=(a=a.replace(/^\s*/,"")).replace(/\s*$/,"")).replace(/\s+/g," ")).toLowerCase(),n.push(o.type.toLowerCase()+"="+a)}e.push(n.join("+"))}return"/"+e.join("/")},this.getInfo=function(){var t,e,r,i=function(t){for(var e="",r=" ",i="\n",n=t.array,s=0;s<n.length;s++){var o=n[s];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$/,"")},n=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var n=r[i];if(e+=" policy oid: "+n.policyoid+"\n",void 0!==n.array)for(var s=0;s<n.array.length;s++){var o=n.array[s];void 0!==o.cps&&(e+=" cps: "+o.cps+"\n")}}return e},s=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var n=r[i];try{void 0!==n.dpname.full[0].uri&&(e+=" "+n.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==n.dname.full[0].dn.hex&&(e+=" "+$t.hex2dn(n.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 n=r[i];void 0!==n.caissuer&&(e+=" caissuer: "+n.caissuer+"\n"),void 0!==n.ocsp&&(e+=" ocsp: "+n.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],u=st.asn1.x509.OID.oid2name(c.oid);""===u&&(u=c.oid);var h="";if(!0===c.critical&&(h="CRITICAL"),t+=" "+u+" "+h+":\n","basicConstraints"===u){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"==u)t+=" "+this.getExtPolicyMappings().array.map(function(t){var e=t;return e[0]+":"+e[1]}).join(", ")+"\n";else if("policyConstraints"==u)t+=" ",null!=(p=this.getExtPolicyConstraints()).reqexp&&(t+=" reqexp="+p.reqexp),null!=p.inhibit&&(t+=" inhibit="+p.inhibit),t+="\n";else if("inhibitAnyPolicy"==u)t+=" skip="+(p=this.getExtInhibitAnyPolicy()).skip+"\n";else if("keyUsage"==u)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"==u)t+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"==u){var d=this.getExtAuthorityKeyIdentifier();void 0!==d.kid&&(t+=" kid="+d.kid.hex+"\n")}else"extKeyUsage"==u?t+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n":"subjectAltName"==u?t+=i(this.getExtSubjectAltName())+"\n":"cRLDistributionPoints"==u?t+=s(this.getExtCRLDistributionPoints()):"authorityInfoAccess"==u?t+=o(this.getExtAuthorityInfoAccess()):"certificatePolicies"==u&&(t+=n(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):st.lang.String.isHex(t)&&this.readCertHex(t))}Vt.getKey=function(t,e,r){var i,n=(y=ct).getChildIdx,s=(y.getV,y.getVbyList),o=st.crypto,a=o.ECDSA,c=o.DSA,u=tt,h=xt,l=Vt;if(void 0!==u&&t instanceof u)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(P=new u).setPublic(t.n,t.e),P;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(P=new u).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),P;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(P=new u).setPrivate(t.n,t.e,t.d),P;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(P=new c).setPublic(t.p,t.q,t.g,t.y),P;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(P=new c).setPrivate(t.p,t.q,t.g,t.y,t.x),P;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(P=new u).setPublic(gt(t.n),gt(t.e)),P;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(P=new u).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)),P;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(P=new u).setPrivate(gt(t.n),gt(t.e),gt(t.d)),P;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var p=(C=new a({curve:t.crv})).ecparams.keycharlen,d="04"+("0000000000"+gt(t.x)).slice(-p)+("0000000000"+gt(t.y)).slice(-p);return C.setPublicKeyHex(d),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){p=(C=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 C.setPublicKeyHex(d),C.setPrivateKeyHex(g),C}if("pkcs5prv"===r){var f,m=t,y=ct;if(9===(f=n(m,0)).length)(P=new u).readPKCS5PrvKeyHex(m);else if(6===f.length)(P=new c).readPKCS5PrvKeyHex(m);else{if(!(f.length>2&&"04"===m.substr(f[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(P=new a).readPKCS5PrvKeyHex(m)}return P}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 S=xt(t,"PUBLIC KEY");return l._getKeyFromPublicPKCS8Hex(S)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var v=h(t,"RSA PRIVATE KEY");return l.getKey(v,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var x=s(i=h(t,"DSA PRIVATE KEY"),0,[1],"02"),A=s(i,0,[2],"02"),b=s(i,0,[3],"02"),w=s(i,0,[4],"02"),T=s(i,0,[5],"02");return(P=new c).setPrivate(new E(x,16),new E(A,16),new E(b,16),new E(w,16),new E(T,16)),P}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED"))return v=h(t,"EC PRIVATE KEY"),l.getKey(v,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 C,P=s(i=l.getDecryptedKeyHex(t,e),0,[1],"04"),F=s(i,0,[2,0],"06"),N=s(i,0,[3,0],"03").substr(2);if(void 0===st.crypto.OID.oidhex2name[F])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+F);return(C=new a({curve:st.crypto.OID.oidhex2name[F]})).setPublicKeyHex(N),C.setPrivateKeyHex(P),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED"))return x=s(i=l.getDecryptedKeyHex(t,e),0,[1],"02"),A=s(i,0,[2],"02"),b=s(i,0,[3],"02"),w=s(i,0,[4],"02"),T=s(i,0,[5],"02"),(P=new c).setPrivate(new E(x,16),new E(A,16),new E(b,16),new E(w,16),new E(T,16)),P;if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return l.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},Vt.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,n=o.n.toString(16),s=o.e.toString(16);return i.setPublic(n,s),i.isPrivate=!1,i.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=i,a}if("EC"==t){var o,a,c=e,u=new st.crypto.ECDSA({curve:c}).generateKeyPairHex();return(o=new st.crypto.ECDSA({curve:c})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(i=new st.crypto.ECDSA({curve:c})).setPublicKeyHex(u.ecpubhex),i.isPrivate=!1,i.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=i,a}throw new Error("unknown algorithm: "+t)},Vt.getPEM=function(t,e,r,i,n,s){var o=st,a=o.asn1,c=a.DERObjectIdentifier,u=a.DERInteger,h=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,p=o.crypto,d=p.DSA,g=p.ECDSA,f=tt;function m(t){return h({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 h({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return h({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(A=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(A=m(t).tohex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===r||null==r)&&1==t.isPrivate){var v=new c({name:t.curveName}).tohex(),E=y(t).tohex(),x="";return(x+=Et(v,"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(A=S(t).tohex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==f&&t instanceof f&&void 0!==r&&null!=r&&1==t.isPrivate){var A=m(t).tohex();return void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",A,r,i,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==r&&null!=r&&1==t.isPrivate)return A=y(t).tohex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",A,r,i,s);if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==r&&null!=r&&1==t.isPrivate)return A=S(t).tohex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",A,r,i,s);var b=function(t,e){if("string"==typeof e)return Vt.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,Vt.getEncryptedPKCS8PEM(t,i,r)}};if("PKCS8PRV"==e&&null!=f&&t instanceof f&&1==t.isPrivate){var w=m(t).tohex();return A=h({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:w}}]}).tohex(),void 0===r||null==r?Et(A,"PRIVATE KEY"):b(A,r)}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){var T={seq:[{int:1},{octstr:{hex:t.prvKeyHex}}]};return"string"==typeof t.pubKeyHex&&T.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}),w=new h(T).tohex(),A=h({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:w}}]}).tohex(),void 0===r||null==r?Et(A,"PRIVATE KEY"):b(A,r)}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate)return w=new u({bigint:t.x}).tohex(),A=h({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:w}}]}).tohex(),void 0===r||null==r?Et(A,"PRIVATE KEY"):b(A,r);throw new Error("unsupported object nor format")},Vt.getKeyFromCSRPEM=function(t){var e=xt(t,"CERTIFICATE REQUEST");return Vt.getKeyFromCSRHex(e)},Vt.getKeyFromCSRHex=function(t){var e=Vt.parseCSRHex(t);return Vt.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Vt.parseCSRHex=function(t){var e=ct,r=e.getChildIdx,i=e.getTLV,n={},s=t;if("30"!=s.substr(0,2))throw new Error("malformed CSR(code:001)");var o=r(s,0);if(o.length<1)throw new Error("malformed CSR(code:002)");if("30"!=s.substr(o[0],2))throw new Error("malformed CSR(code:003)");var a=r(s,o[0]);if(a.length<3)throw new Error("malformed CSR(code:004)");return n.p8pubkeyhex=i(s,a[2]),n},Vt.getKeyID=function(t){var e=Vt,r=ct;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var i=xt(e.getPEM(t)),n=r.getIdxbyList(i,0,[1]),s=r.getV(i,n).substring(2);return st.crypto.Util.hashHex(s,"sha1")},Vt.getJWK=function(t,e,r,i,n){var s,o,a={},c=st.crypto.Util.hashHex;if("string"==typeof t)s=Vt.getKey(t),-1!=t.indexOf("CERTIFICATE")&&(o=xt(t));else{if("object"!=typeof t)throw new Error("unsupported keyinfo type");t instanceof $t?(s=t.getPublicKey(),o=t.hex):s=t}if(s instanceof tt&&s.isPrivate)a.kty="RSA",a.n=dt(s.n.toString(16)),a.e=dt(s.e.toString(16)),a.d=dt(s.d.toString(16)),a.p=dt(s.p.toString(16)),a.q=dt(s.q.toString(16)),a.dp=dt(s.dmp1.toString(16)),a.dq=dt(s.dmq1.toString(16)),a.qi=dt(s.coeff.toString(16));else if(s instanceof tt&&s.isPublic)a.kty="RSA",a.n=dt(s.n.toString(16)),a.e=dt(s.e.toString(16));else if(s instanceof st.crypto.ECDSA&&s.isPrivate){if("P-256"!==(h=s.getShortNISTPCurveName())&&"P-384"!==h&&"P-521"!==h)throw new Error("unsupported curve name for JWT: "+h);var u=s.getPublicKeyXYHex();a.kty="EC",a.crv=h,a.x=dt(u.x),a.y=dt(u.y),a.d=dt(s.prvKeyHex)}else if(s instanceof st.crypto.ECDSA&&s.isPublic){var h;if("P-256"!==(h=s.getShortNISTPCurveName())&&"P-384"!==h&&"P-521"!==h)throw new Error("unsupported curve name for JWT: "+h);u=s.getPublicKeyXYHex(),a.kty="EC",a.crv=h,a.x=dt(u.x),a.y=dt(u.y)}if(null==a.kty)throw new Error("unsupported keyinfo");return s.isPrivate||1==e||(a.kid=st.jws.JWS.getJWKthumbprint(a)),null!=o&&1!=r&&(a.x5c=[S(o)]),null!=o&&1!=i&&(a.x5t=lt(S(c(o,"sha1")))),null!=o&&1!=n&&(a["x5t#S256"]=lt(S(c(o,"sha256")))),a},Vt.getJWKFromKey=function(t){return Vt.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]),n=r(t,e[1]),s=r(t,e[2]),o=r(t,e[3]),a=r(t,e[4]),c=r(t,e[5]),u=r(t,e[6]),h=r(t,e[7]),l=r(t,e[8]);return(e=new Array).push(i,n,s,o,a,c,u,h,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,n,s,o,a,c,u=ct,h=u.getVbyListEx;if(!1===u.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=h(t,0,[2,0,1],"02"),r=h(t,0,[2,0,2],"02"),i=h(t,0,[2,0,3],"02"),n=h(t,0,[2,0,4],"02"),s=h(t,0,[2,0,5],"02"),o=h(t,0,[2,0,6],"02"),a=h(t,0,[2,0,7],"02"),c=h(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,i,n,s,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 n=r(t,i[0]),s=r(t,i[1]);this.setPublic(n,s)},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 st.crypto.Util.hashString(t,e)}(t);return this.signWithMessageHash(r,e)},tt.prototype.signWithMessageHash=function(t,e){var r=Z(st.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,n=(i=vt(t),st.crypto.Util.hashHex(i,e));return void 0===r&&(r=-1),this.signWithMessageHashPSS(n,e,r)},tt.prototype.signWithMessageHashPSS=function(t,e,r){var i,n=St(t),s=n.length,o=this.n.bitLength()-1,a=Math.ceil(o/8),c=function(t){return st.crypto.Util.hashHex(t,e)};if(-1===r||void 0===r)r=s;else if(-2===r)r=a-s-2;else if(r<-2)throw new Error("invalid salt length");if(a<s+r+2)throw new Error("data too long");var u="";r>0&&(u=new Array(r),(new Q).nextBytes(u),u=String.fromCharCode.apply(String,u));var h=St(c(vt("\0\0\0\0\0\0\0\0"+n+u))),l=[];for(i=0;i<a-r-s-2;i+=1)l[i]=0;var p=String.fromCharCode.apply(String,l)+""+u,d=Gt(h,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<s;i++)g.push(h.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 n=this.doPublic(r).toString(16);if(n.length+3!=i/4)return!1;var s=qt(n.replace(/^1f+00/,""));if(0==s.length)return!1;var o=s[0],a=s[1],c=function(t){return st.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=qt(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 n,s=(n=vt(t),st.crypto.Util.hashHex(n,r));return void 0===i&&(i=-1),this.verifyWithMessageHashPSS(s,e,r,i)},tt.prototype.verifyWithMessageHashPSS=function(t,e,r,i){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var n,s=new E(e,16),o=function(t){return st.crypto.Util.hashHex(t,r)},a=St(t),c=a.length,u=this.n.bitLength()-1,h=Math.ceil(u/8);if(-1===i||void 0===i)i=c;else if(-2===i)i=h-c-2;else if(i<-2)throw new Error("invalid salt length");if(h<c+i+2)throw new Error("data too long");var l=this.doPublic(s).toByteArray();for(n=0;n<l.length;n+=1)l[n]&=255;for(;l.length<h;)l.unshift(0);if(188!==l[h-1])throw new Error("encoded message does not end in 0xbc");var p=(l=String.fromCharCode.apply(String,l)).substr(0,h-c-1),d=l.substr(p.length,c),g=65280>>8*h-u&255;if(0!==(p.charCodeAt(0)&g))throw new Error("bits beyond keysize not zero");var f=Gt(d,p.length,o),m=[];for(n=0;n<p.length;n+=1)m[n]=p.charCodeAt(n)^f.charCodeAt(n);m[0]&=~g;var y=h-c-i-2;for(n=0;n<y;n+=1)if(0!==m[n])throw new Error("leftmost octets not zero");if(1!==m[y])throw new Error("0x01 marker not found");return d===St(o(vt("\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),n=0;n<i.length;n++)r.push($t.hex2attrTypeValue(t,i[n]));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 n=r.getChildIdx(t,e);2!==n.length||t.substr(n[0],2);var s=i(t,n[0]),o=st.asn1.ASN1Util.oidHexToInt(s);return st.asn1.x509.OID.oid2atype(o)+"="+St(i(t,n[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,n={algparam:null};return(e=new $t).readCertPEM(t),r=e.getPublicKeyHex(),n.keyhex=i(r,0,[1],"03").substr(2),n.algoid=i(r,0,[0,0],"06"),"2a8648ce3d0201"===n.algoid&&(n.algparam=i(r,0,[0,1],"06")),n},$t.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],void 0!==st&&st||(st={}),void 0!==st.jws&&st.jws||(st.jws={}),st.jws.JWS=function(){var t=st.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 n=i[1],s=i[2],o=i[3],a=n+"."+s;if(this.parsedJWS={},this.parsedJWS.headB64U=n,this.parsedJWS.payloadB64U=s,this.parsedJWS.sigvalB64U=o,this.parsedJWS.si=a,!r){var c=gt(o),u=Z(c,16);this.parsedJWS.sigvalH=c,this.parsedJWS.sigvalBI=u}var h=at(n),l=at(s);if(this.parsedJWS.headS=h,this.parsedJWS.payloadS=l,!t(h,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+h}}},st.jws.JWS.sign=function(t,e,r,i,n){var s,o,a,c=st,u=c.jws.JWS,h=u.readSafeJSONString,l=u.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,s=f.stringify(o)),"string"==typeof e){if(!l(s=e))throw"JWS Head is not safe JSON string: "+s;o=h(s)}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,s=f.stringify(o)),t!==o.alg)throw"alg and sHeader.alg doesn't match: "+t+"!="+o.alg;var m=null;if(void 0===u.jwsalg2sigalg[t])throw"unsupported alg name: "+t;m=u.jwsalg2sigalg[t];var y=ot(s)+"."+ot(a),S="";if("Hmac"==m.substr(0,4)){if(void 0===i)throw"mac key shall be specified for HS* alg";var v=new d({alg:m,prov:"cryptojs",pass:i});v.updateString(y),S=v.doFinal()}else if(-1!=m.indexOf("withECDSA")){(x=new g({alg:m})).init(i,n),x.updateString(y);var E=x.sign();S=st.crypto.ECDSA.asn1SigToConcatSig(E)}else{var x;"none"!=m&&((x=new g({alg:m})).init(i,n),x.updateString(y),S=x.sign())}return y+"."+dt(S)},st.jws.JWS.verify=function(t,e,r){var i,n=st,s=n.jws.JWS,o=s.readSafeJSONString,a=n.crypto,c=a.ECDSA,u=a.Mac,h=a.Signature;if(i=tt,!Ot(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=Vt.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===s.jwsalg2sigalg[f.alg])throw"unsupported alg name: "+m;if("none"==(y=s.jwsalg2sigalg[m]))throw"not supported";if("Hmac"==y.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var S=new u({alg:y,pass:e});return S.updateString(d),g==S.doFinal()}if(-1!=y.indexOf("withECDSA")){var v,E=null;try{E=c.concatSigToASN1Sig(g)}catch(t){return!1}return(v=new h({alg:y})).init(e),v.updateString(d),v.verify(E)}return(v=new h({alg:y})).init(e),v.updateString(d),v.verify(g)},st.jws.JWS.parse=function(t){var e,r,i,n=t.split("."),s={};if(2!=n.length&&3!=n.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=n[0],r=n[1],3==n.length&&(i=n[2]),s.headerObj=st.jws.JWS.readSafeJSONString(at(e)),s.payloadObj=st.jws.JWS.readSafeJSONString(at(r)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=at(r):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==i&&(s.sigHex=gt(i)),s},st.jws.JWS.verifyJWT=function(t,e,r){var i=st.jws,n=i.JWS,s=n.readSafeJSONString,o=n.inArray,a=n.includedArray;if(!Ot(t))return!1;var c=t.split(".");if(3!=c.length)return!1;var u=c[0],h=c[1],l=(gt(c[2]),s(at(u))),p=s(at(h));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||!n.verify(t,e,r.alg))},st.jws.JWS.includedArray=function(t,e){var r=st.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},st.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},st.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"},st.jws.JWS.isSafeJSONString=function(t,e,r){var i=null;try{return"object"!=typeof(i=nt(t))||i.constructor===Array?0:(e&&(e[r]=i),1)}catch(t){return 0}},st.jws.JWS.readSafeJSONString=function(t){var e=null;try{return"object"!=typeof(e=nt(t))||e.constructor===Array?null:e}catch(t){return null}},st.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]},st.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=vt(e);return dt(st.crypto.Util.hashHex(r,"sha256"))},st.jws.IntDate={},st.jws.IntDate.get=function(t){var e=st.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},st.jws.IntDate.getZulu=function(t){return function(t){return Math.round(function(t){var e,r,i,n,s,o,a,c,u,h;if(h=(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(h[1]),r=parseInt(h[2])-1,i=parseInt(h[3]),n=parseInt(h[4]),s=parseInt(h[5]),o=parseInt(h[6]),a=0,""!==(c=h[7])&&(u=(c.substr(1)+"00").substr(0,3),a=parseInt(u)),Date.UTC(e,r,i,n,s,o,a);throw new Error("unsupported zulu format: "+t)}(t)/1e3)}(t)},st.jws.IntDate.getNow=function(){return~~(new Date/1e3)},st.jws.IntDate.intDate2UTCString=function(t){return new Date(1e3*t).toUTCString()},st.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!==st&&st||(st={}),void 0!==st.jws&&st.jws||(st.jws={}),st.jws.JWSJS=function(){var t=st.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 n=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var s=st.jws.JWS.sign(t,e,this.sPayload,r,i).split(".");s[0],s[2],this.aHeader.push(s[0]),this.aSignature.push(s[2])}catch(t){throw this.aHeader.length>n&&this.aHeader.pop(),this.aSignature.length>n&&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 n=this.aHeader[e],s=this.aSignature[e],o=n+"."+this.sPayload+"."+s,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}},st.crypto.ECDSA,st.crypto.DSA,st.crypto.Signature,st.crypto.MessageDigest,st.crypto.Mac,e.ym=Vt,e.wV=dt,e.cV=at,e.pj=st,st.crypto,st.asn1,st.jws,st.lang}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var s=e[i]={exports:{}};return t[i](s,s.exports,r),s.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 n{theme="default";themeMode=i.light;constructor(t){t&&(this.theme=t.theme??this.theme,this.themeMode=t.themeMode??this.themeMode,this.jsonLdExportSettings=t.jsonLdExportSettings??this.jsonLdExportSettings)}isSystemMode(){return this.themeMode===i.system}toString(){return JSON.stringify(this)}}const s=t=>t.location?`${t.id}@${t.location}`:t.id;class o{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(!o.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)||!o.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(o.hasCopyMethod(t))return t.copy();const e=o.copyBuiltInType(t);return null!==e?e:o.copyPlainObject(t)}static copyBuiltInType(t){return Array.isArray(t)?t.map(t=>o.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])=>[o.deepCopy(t),o.deepCopy(e)])):t instanceof Set?new Set(Array.from(t.values()).map(t=>o.deepCopy(t))):null}static copyPlainObject(t){const e=Object.create(Object.getPrototypeOf(t));for(const r of Object.keys(t))e[r]=o.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=o.deepCopy(t);return Object.keys(e).forEach(t=>{const i=r[t],n=e[t];o.isNullOrUndefined(i)?r[t]=o.deepCopy(n):o.canRecursivelyMerge(i,n)&&(r[t]=o.mergeWithDefaults(i,n))}),r}static canRecursivelyMerge(t,e){return"object"==typeof t&&null!==t&&"object"==typeof e&&null!==e&&!Array.isArray(t)&&!Array.isArray(e)}}const a={BYTES:1,KB:1024,MB:1048576,GB:1024**3,TB:1024**4,PB:1024**5},c=/^(\d+(?:\.\d+)?)\s*(bytes|KB|MB|GB|TB|PB)$/i,u=/^\d+$/;class h{static convertToBytes(t){if(null==t)return 0;if("number"==typeof t)return t;if(t=t.trim(),u.test(t))return Number.parseInt(t,10);const e=c.exec(t);if(!e)return 0;const r=Number.parseFloat(e[1]),i=e[2];return r*a[i.toUpperCase()]}static convertToHumanReadable(t){if(!t)return"0 bytes";if("string"==typeof t&&(t=t.trim()),c.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(a).reverse();for(const r of e){const e=a[r];if(t>=e){const i=t/e;return`${Number.isInteger(i)?i:i.toFixed(2)} ${"BYTES"===r?"bytes":r}`}}return"0 bytes"}}class l{static getWindow(){return window}static getParentWindow(){return l.getWindow().parent}static getReferer(){let t="*";if(l.getDocument().referrer)try{const e=new URL(l.getDocument().referrer);e.origin&&(t=e.origin)}catch(t){console.warn(`Failed to parse document.referrer: ${l.getDocument().referrer}. Using default targetOrigin '*'`,t)}return t}static getDocument(){return l.getWindow().document}static getPluginRegistry(){return l.getWindow().PluginRegistry}static setPluginRegistry(t){this.getWindow().PluginRegistry=t}static getCrypto(){return l.getWindow().crypto}static reloadPage(){l.getWindow().location.reload()}static getLocationHref(){return l.getWindow().location.href}static setLocationHref(t){l.getWindow().location.href=t}static getLocationQueryParams(){return l.getWindow().location.search}static getLocationHash(){return l.getWindow().location.hash}static matchMedia(t){return l.getWindow().matchMedia(t)}static getLocationPathname(){return l.getWindow().location.pathname}static getLocationOrigin(){return l.getWindow().location.origin}static getBaseHref(){return l.getDocument().querySelector("base")?.getAttribute("href")??"/"}static openWindow(t,e,r){l.getWindow().open(t,e,r)}static navigateSingleSpa(t){l.getWindow().singleSpa.navigateToUrl(t)}}class p{static isDevMode(){return l.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=p.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 g{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 f(t){return e=>{e?.preventDefault&&e.preventDefault(),m(t)}}function m(t){let e=t;e.startsWith(".")&&(e=e.slice(1)),e.startsWith("/")&&!e.startsWith(A())&&(e=A().slice(0,-1)+e),l.navigateSingleSpa(e)}function y(t){l.openWindow(t,"_blank","noopener,noreferrer")}function S(){return"/"===E()}function v(){return"/login"===E()}function E(){return l.getLocationPathname().substring(A().length-1)}function x(){return`${l.getLocationOrigin()}${A()}`}function A(){return l.getBaseHref()}function b(){return E().substring(1)}function w(){return E()+l.getLocationQueryParams()}function I(t,e){if(Object.values(t).includes(e))return e;throw new Error(`Invalid enum value '${e}' for enum ${JSON.stringify(t)}`)}class T{static now(){return Date.now()}static formatDuration(t){if(!t||t<=0)return"-";const e=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);let n="";return e&&(n+=e+"d "),(e||r)&&(n+=r+"h "),(e||r||i)&&(n+=i+"m "),n+=Math.round(t%60)+"s",n.replace(/( 0[a-z])+$/,"")}}function R(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function C(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var i,n,s,o,a=[],c=!0,u=!1;try{if(s=(r=r.call(t)).next,0===e);else for(;!(c=(i=s.call(r)).done)&&(a.push(i.value),a.length!==e);c=!0);}catch(t){u=!0,n=t}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw n}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return R(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?R(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const P=Object.entries,F=Object.setPrototypeOf,N=Object.isFrozen,D=Object.getPrototypeOf,O=Object.getOwnPropertyDescriptor;let _=Object.freeze,L=Object.seal,B=Object.create,k="undefined"!=typeof Reflect&&Reflect,H=k.apply,U=k.construct;_||(_=function(t){return t}),L||(L=function(t){return t}),H||(H=function(t,e){for(var r=arguments.length,i=new Array(r>2?r-2:0),n=2;n<r;n++)i[n-2]=arguments[n];return t.apply(e,i)}),U||(U=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return new t(...r)});const M=at(Array.prototype.forEach),j=at(Array.prototype.lastIndexOf),V=at(Array.prototype.pop),K=at(Array.prototype.push),G=at(Array.prototype.splice),q=Array.isArray,$=at(String.prototype.toLowerCase),W=at(String.prototype.toString),z=at(String.prototype.match),Y=at(String.prototype.replace),X=at(String.prototype.indexOf),J=at(String.prototype.trim),Q=at(Number.prototype.toString),Z=at(Boolean.prototype.toString),tt="undefined"==typeof BigInt?null:at(BigInt.prototype.toString),et="undefined"==typeof Symbol?null:at(Symbol.prototype.toString),rt=at(Object.prototype.hasOwnProperty),it=at(Object.prototype.toString),nt=at(RegExp.prototype.test),st=(ot=TypeError,function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return U(ot,e)});var ot;function at(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];return H(t,e,i)}}function ct(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$;if(F&&F(t,null),!q(e))return t;let i=e.length;for(;i--;){let n=e[i];if("string"==typeof n){const t=r(n);t!==n&&(N(e)||(e[i]=t),n=t)}t[n]=!0}return t}function ut(t){for(let e=0;e<t.length;e++)rt(t,e)||(t[e]=null);return t}function ht(t){const e=B(null);for(const i of P(t)){var r=C(i,2);const n=r[0],s=r[1];rt(t,n)&&(q(s)?e[n]=ut(s):s&&"object"==typeof s&&s.constructor===Object?e[n]=ht(s):e[n]=s)}return e}function lt(t,e){for(;null!==t;){const r=O(t,e);if(r){if(r.get)return at(r.get);if("function"==typeof r.value)return at(r.value)}t=D(t)}return function(){return null}}const pt=_(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),dt=_(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),gt=_(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ft=_(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),mt=_(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),yt=_(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),St=_(["#text"]),vt=_(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Et=_(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),xt=_(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),At=_(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),bt=L(/{{[\w\W]*|^[\w\W]*}}/g),wt=L(/<%[\w\W]*|^[\w\W]*%>/g),It=L(/\${[\w\W]*/g),Tt=L(/^data-[\-\w.\u00B7-\uFFFF]+$/),Rt=L(/^aria-[\-\w]+$/),Ct=L(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Pt=L(/^(?:\w+script|data):/i),Ft=L(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Nt=L(/^html$/i),Dt=L(/^[a-z][.\w]*(-[.\w]+)+$/i),Ot=L(/<[/\w!]/g),_t=L(/<[/\w]/g),Lt=L(/<\/no(script|embed|frames)/i),Bt=L(/\/>/i),kt=function(){return"undefined"==typeof window?null:window},Ht=function(t,e,r,i){return rt(t,e)&&q(t[e])?ct(i.base?ht(i.base):{},t[e],i.transform):r};var Ut=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:kt();const r=e=>t(e);if(r.version="3.4.12",r.removed=[],!e||!e.document||9!==e.document.nodeType||!e.Element)return r.isSupported=!1,r;let i=e.document;const n=i,s=n.currentScript;e.DocumentFragment;const o=e.HTMLTemplateElement,a=e.Node,c=e.Element,u=e.NodeFilter;void 0===e.NamedNodeMap&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const h=e.DOMParser,l=e.trustedTypes,p=c.prototype,d=lt(p,"cloneNode"),g=lt(p,"remove"),f=lt(p,"nextSibling"),m=lt(p,"childNodes"),y=lt(p,"parentNode"),S=lt(p,"shadowRoot"),v=lt(p,"attributes"),E=a&&a.prototype?lt(a.prototype,"nodeType"):null,x=a&&a.prototype?lt(a.prototype,"nodeName"):null;if("function"==typeof o){const t=i.createElement("template");t.content&&t.content.ownerDocument&&(i=t.content.ownerDocument)}let A,b,w="",T=!1,I=0;const R=function(){if(I>0)throw st('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},C=function(t){R(),I++;try{return A.createHTML(t)}finally{I--}},F=i,N=F.implementation,D=F.createNodeIterator,O=F.createDocumentFragment,k=F.getElementsByTagName,H=n.importNode;let U={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};r.isSupported="function"==typeof P&&"function"==typeof y&&N&&void 0!==N.createHTMLDocument;const ot=bt,at=wt,ut=It,Ut=Tt,jt=Rt,Mt=Pt,Vt=Ft,Kt=Dt;let Gt=Ct,qt=null;const $t=ct({},[...pt,...dt,...gt,...mt,...St]);let Wt=null;const zt=ct({},[...vt,...Et,...xt,...At]);let Yt=Object.seal(B(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Xt=null,Jt=null;const Qt=Object.seal(B(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Zt=!0,te=!0,ee=!1,re=!0,ie=!1,ne=!0,se=!1,oe=!1,ae=null,ce=null,ue=!1,he=!1,le=!1,pe=!1,de=!0,ge=!1;const fe="user-content-";let me=!0,ye=!1,Se={},ve=null;const Ee=ct({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let xe=null;const Ae=ct({},["audio","video","img","source","image","track"]);let be=null;const we=ct({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Te="http://www.w3.org/1998/Math/MathML",Ie="http://www.w3.org/2000/svg",Re="http://www.w3.org/1999/xhtml";let Ce=Re,Pe=!1,Fe=null;const Ne=ct({},[Te,Ie,Re],W),De=_(["mi","mo","mn","ms","mtext"]);let Oe=ct({},De);const _e=_(["annotation-xml"]);let Le=ct({},_e);const Be=ct({},["title","style","font","a","script"]);let ke=null;const He=["application/xhtml+xml","text/html"];let Ue=null,je=null;const Me=i.createElement("form"),Ve=function(t){return t instanceof RegExp||t instanceof Function},Ke=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(je&&je===t)return;t&&"object"==typeof t||(t={}),t=ht(t),ke=-1===He.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,Ue="application/xhtml+xml"===ke?W:$,qt=Ht(t,"ALLOWED_TAGS",$t,{transform:Ue}),Wt=Ht(t,"ALLOWED_ATTR",zt,{transform:Ue}),Fe=Ht(t,"ALLOWED_NAMESPACES",Ne,{transform:W}),be=Ht(t,"ADD_URI_SAFE_ATTR",we,{transform:Ue,base:we}),xe=Ht(t,"ADD_DATA_URI_TAGS",Ae,{transform:Ue,base:Ae}),ve=Ht(t,"FORBID_CONTENTS",Ee,{transform:Ue}),Xt=Ht(t,"FORBID_TAGS",ht({}),{transform:Ue}),Jt=Ht(t,"FORBID_ATTR",ht({}),{transform:Ue}),Se=!!rt(t,"USE_PROFILES")&&(t.USE_PROFILES&&"object"==typeof t.USE_PROFILES?ht(t.USE_PROFILES):t.USE_PROFILES),Zt=!1!==t.ALLOW_ARIA_ATTR,te=!1!==t.ALLOW_DATA_ATTR,ee=t.ALLOW_UNKNOWN_PROTOCOLS||!1,re=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,ie=t.SAFE_FOR_TEMPLATES||!1,ne=!1!==t.SAFE_FOR_XML,se=t.WHOLE_DOCUMENT||!1,he=t.RETURN_DOM||!1,le=t.RETURN_DOM_FRAGMENT||!1,pe=t.RETURN_TRUSTED_TYPE||!1,ue=t.FORCE_BODY||!1,de=!1!==t.SANITIZE_DOM,ge=t.SANITIZE_NAMED_PROPS||!1,me=!1!==t.KEEP_CONTENT,ye=t.IN_PLACE||!1,Gt=function(t){try{return nt(t,""),!0}catch(t){return!1}}(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:Ct,Ce="string"==typeof t.NAMESPACE?t.NAMESPACE:Re,Oe=rt(t,"MATHML_TEXT_INTEGRATION_POINTS")&&t.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof t.MATHML_TEXT_INTEGRATION_POINTS?ht(t.MATHML_TEXT_INTEGRATION_POINTS):ct({},De),Le=rt(t,"HTML_INTEGRATION_POINTS")&&t.HTML_INTEGRATION_POINTS&&"object"==typeof t.HTML_INTEGRATION_POINTS?ht(t.HTML_INTEGRATION_POINTS):ct({},_e);const e=rt(t,"CUSTOM_ELEMENT_HANDLING")&&t.CUSTOM_ELEMENT_HANDLING&&"object"==typeof t.CUSTOM_ELEMENT_HANDLING?ht(t.CUSTOM_ELEMENT_HANDLING):B(null);if(Yt=B(null),rt(e,"tagNameCheck")&&Ve(e.tagNameCheck)&&(Yt.tagNameCheck=e.tagNameCheck),rt(e,"attributeNameCheck")&&Ve(e.attributeNameCheck)&&(Yt.attributeNameCheck=e.attributeNameCheck),rt(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(Yt.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),L(Yt),ie&&(te=!1),le&&(he=!0),Se&&(qt=ct({},St),Wt=B(null),!0===Se.html&&(ct(qt,pt),ct(Wt,vt)),!0===Se.svg&&(ct(qt,dt),ct(Wt,Et),ct(Wt,At)),!0===Se.svgFilters&&(ct(qt,gt),ct(Wt,Et),ct(Wt,At)),!0===Se.mathMl&&(ct(qt,mt),ct(Wt,xt),ct(Wt,At))),Qt.tagCheck=null,Qt.attributeCheck=null,rt(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?Qt.tagCheck=t.ADD_TAGS:q(t.ADD_TAGS)&&(qt===$t&&(qt=ht(qt)),ct(qt,t.ADD_TAGS,Ue))),rt(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?Qt.attributeCheck=t.ADD_ATTR:q(t.ADD_ATTR)&&(Wt===zt&&(Wt=ht(Wt)),ct(Wt,t.ADD_ATTR,Ue))),rt(t,"ADD_URI_SAFE_ATTR")&&q(t.ADD_URI_SAFE_ATTR)&&ct(be,t.ADD_URI_SAFE_ATTR,Ue),rt(t,"FORBID_CONTENTS")&&q(t.FORBID_CONTENTS)&&(ve===Ee&&(ve=ht(ve)),ct(ve,t.FORBID_CONTENTS,Ue)),rt(t,"ADD_FORBID_CONTENTS")&&q(t.ADD_FORBID_CONTENTS)&&(ve===Ee&&(ve=ht(ve)),ct(ve,t.ADD_FORBID_CONTENTS,Ue)),me&&(qt["#text"]=!0),se&&ct(qt,["html","head","body"]),qt.table&&(ct(qt,["tbody"]),delete Xt.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw st('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw st('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const e=A;A=t.TRUSTED_TYPES_POLICY;try{w=C("")}catch(t){throw A=e,t}}else null===t.TRUSTED_TYPES_POLICY?(A=void 0,w=""):(void 0===A&&(T||(b=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let r=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(r=e.getAttribute(i));const n="dompurify"+(r?"#"+r:"");try{return t.createPolicy(n,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+n+" could not be created."),null}}(l,s),T=!0),A=b),A&&"string"==typeof w&&(w=C("")));_&&_(t),je=t},Ge=ct({},[...dt,...gt,...ft]),qe=ct({},[...mt,...yt]),$e=function(t){K(r.removed,{element:t});try{y(t).removeChild(t)}catch(e){if(g(t),!y(t))throw st("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},We=function(t){Xe(t);const e=m(t);if(e){const t=[];M(e,e=>{K(t,e)}),M(t,t=>{try{g(t)}catch(t){}})}const r=v(t);if(r)for(let e=r.length-1;e>=0;--e){const i=r[e],n=i&&i.name;if("string"==typeof n)try{t.removeAttribute(n)}catch(t){}}},ze=function(t,e){try{K(r.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){K(r.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(he||le)try{$e(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Ye=function(t){const e=v(t);if(e)for(let r=e.length-1;r>=0;--r){const i=e[r],n=i&&i.name;if("string"==typeof n&&!Wt[Ue(n)])try{t.removeAttribute(n)}catch(t){}}},Xe=function(t){const e=[t];for(;e.length>0;){const t=e.pop();1===(E?E(t):t.nodeType)&&Ye(t);const r=m(t);if(r)for(let t=r.length-1;t>=0;--t)e.push(r[t])}},Je=function(t){let e=null,r=null;if(ue)t="<remove></remove>"+t;else{const e=z(t,/^[\r\n\t ]+/);r=e&&e[0]}"application/xhtml+xml"===ke&&Ce===Re&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const n=A?C(t):t;if(Ce===Re)try{e=(new h).parseFromString(n,ke)}catch(t){}if(!e||!e.documentElement){e=N.createDocument(Ce,"template",null);try{e.documentElement.innerHTML=Pe?w:n}catch(t){}}const s=e.body||e.documentElement;return t&&r&&s.insertBefore(i.createTextNode(r),s.childNodes[0]||null),Ce===Re?k.call(e,se?"html":"body")[0]:se?e.documentElement:s},Qe=function(t){return D.call(t.ownerDocument||t,t,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ze=function(t){return t=Y(t,ot," "),t=Y(t,at," "),Y(t,ut," ")},tr=function(t){var e;t.normalize();const r=D.call(t.ownerDocument||t,t,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let i=r.nextNode();for(;i;)i.data=Ze(i.data),i=r.nextNode();const n=null===(e=t.querySelectorAll)||void 0===e?void 0:e.call(t,"template");n&&M(n,t=>{rr(t.content)&&tr(t.content)})},er=function(t){const e=x?x(t):null;return"string"==typeof e&&"form"===Ue(e)&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||t.attributes!==v(t)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes||t.nodeType!==E(t)||t.childNodes!==m(t))},rr=function(t){if(!E||"object"!=typeof t||null===t)return!1;try{return 11===E(t)}catch(t){return!1}},ir=function(t){if(!E||"object"!=typeof t||null===t)return!1;try{return"number"==typeof E(t)}catch(t){return!1}};function nr(t,e,i){0!==t.length&&M(t,t=>{t.call(r,e,i,je)})}const sr=function(t,e){if(nr(U.beforeSanitizeElements,t,null),t!==e&&null===y(t))return!0;if(er(t))return $e(t),!0;const i=Ue(x?x(t):t.nodeName);if(nr(U.uponSanitizeElement,t,{tagName:i,allowedTags:qt}),t!==e&&null===y(t))return!0;if(function(t,e){return!!(ne&&t.hasChildNodes()&&!ir(t.firstElementChild)&&nt(Ot,t.textContent)&&nt(Ot,t.innerHTML))||!(!ne||t.namespaceURI!==Re||"style"!==e||!ir(t.firstElementChild))||7===t.nodeType||!(!ne||8!==t.nodeType||!nt(_t,t.data))}(t,i))return $e(t),!0;if(Xt[i]||!(Qt.tagCheck instanceof Function&&Qt.tagCheck(i))&&!qt[i]){const e=function(t,e){if(!Xt[e]&&cr(e)){if(Yt.tagNameCheck instanceof RegExp&&nt(Yt.tagNameCheck,e))return!1;if(Yt.tagNameCheck instanceof Function&&Yt.tagNameCheck(e))return!1}if(me&&!ve[e]){const e=y(t),r=m(t);if(r&&e)for(let i=r.length-1;i>=0;--i){const n=ye?r[i]:d(r[i],!0);e.insertBefore(n,f(t))}}return $e(t),!0}(t,i);return!1===e&&nr(U.afterSanitizeElements,t,null),e}if(1===(E?E(t):t.nodeType)&&!function(t){let e=y(t);e&&e.tagName||(e={namespaceURI:Ce,tagName:"template"});const r=$(t.tagName),i=$(e.tagName);return!!Fe[t.namespaceURI]&&(t.namespaceURI===Ie?function(t,e,r){return e.namespaceURI===Re?"svg"===t:e.namespaceURI===Te?"svg"===t&&("annotation-xml"===r||Oe[r]):Boolean(Ge[t])}(r,e,i):t.namespaceURI===Te?function(t,e,r){return e.namespaceURI===Re?"math"===t:e.namespaceURI===Ie?"math"===t&&Le[r]:Boolean(qe[t])}(r,e,i):t.namespaceURI===Re?function(t,e,r){return!(e.namespaceURI===Ie&&!Le[r])&&!(e.namespaceURI===Te&&!Oe[r])&&!qe[t]&&(Be[t]||!Ge[t])}(r,e,i):!("application/xhtml+xml"!==ke||!Fe[t.namespaceURI]))}(t))return $e(t),!0;if(("noscript"===i||"noembed"===i||"noframes"===i)&&nt(Lt,t.innerHTML))return $e(t),!0;if(ie&&3===t.nodeType){const e=Ze(t.textContent);t.textContent!==e&&(K(r.removed,{element:t.cloneNode()}),t.textContent=e)}return nr(U.afterSanitizeElements,t,null),!1},or=function(t,e,r){if(Jt[e])return!1;if(ne&&"patchsrc"===e)return!1;if(ne&&"for"===e&&"label"!==t&&"output"!==t)return!1;if(de&&("id"===e||"name"===e)&&(r in i||r in Me))return!1;const n=Wt[e]||Qt.attributeCheck instanceof Function&&Qt.attributeCheck(e,t);if(te&&nt(Ut,e));else if(Zt&&nt(jt,e));else if(n){if(be[e]);else if(nt(Gt,Y(r,Vt,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==X(r,"data:")||!xe[t])if(ee&&!nt(Mt,Y(r,Vt,"")));else if(r)return!1}else if(!(cr(t)&&(Yt.tagNameCheck instanceof RegExp&&nt(Yt.tagNameCheck,t)||Yt.tagNameCheck instanceof Function&&Yt.tagNameCheck(t))&&(Yt.attributeNameCheck instanceof RegExp&&nt(Yt.attributeNameCheck,e)||Yt.attributeNameCheck instanceof Function&&Yt.attributeNameCheck(e,t))||"is"===e&&Yt.allowCustomizedBuiltInElements&&(Yt.tagNameCheck instanceof RegExp&&nt(Yt.tagNameCheck,r)||Yt.tagNameCheck instanceof Function&&Yt.tagNameCheck(r))))return!1;return!0},ar=ct({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),cr=function(t){return!ar[$(t)]&&nt(Kt,t)},ur=function(t,e,r,i){if(A&&"object"==typeof l&&"function"==typeof l.getAttributeType&&!r)switch(l.getAttributeType(t,e)){case"TrustedHTML":return C(i);case"TrustedScriptURL":return function(t){R(),I++;try{return A.createScriptURL(t)}finally{I--}}(i)}return i},hr=function(t,e,i,n){try{i?t.setAttributeNS(i,e,n):t.setAttribute(e,n),er(t)?$e(t):V(r.removed)}catch(r){ze(e,t)}},lr=function(t){nr(U.beforeSanitizeAttributes,t,null);const e=t.attributes;if(!e||er(t))return;const r={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Wt,forceKeepAttr:void 0};let i=e.length;const n=Ue(t.nodeName);for(;i--;){const s=e[i],o=s.name,a=s.namespaceURI,c=s.value,u=Ue(o),h=c;let l="value"===o?h:J(h);r.attrName=u,r.attrValue=l,r.keepAttr=!0,r.forceKeepAttr=void 0,nr(U.uponSanitizeAttribute,t,r),l=r.attrValue,!ge||"id"!==u&&"name"!==u||0===X(l,fe)||(ze(o,t),l=fe+l),ne&&nt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,l)||"attributename"===u&&z(l,"href")?ze(o,t):r.forceKeepAttr||(!r.keepAttr||!re&&nt(Bt,l)?ze(o,t):(ie&&(l=Ze(l)),or(n,u,l)?(l=ur(n,u,a,l),l!==h&&hr(t,o,a,l)):ze(o,t)))}nr(U.afterSanitizeAttributes,t,null)},pr=function(t){let e=null;const r=Qe(t);for(nr(U.beforeSanitizeShadowDOM,t,null);e=r.nextNode();)if(nr(U.uponSanitizeShadowNode,e,null),sr(e,t),lr(e),rr(e.content)&&pr(e.content),1===(E?E(e):e.nodeType)){const t=S(e);rr(t)&&(dr(t),pr(t))}nr(U.afterSanitizeShadowDOM,t,null)},dr=function(t){const e=[{node:t,shadow:null}];for(;e.length>0;){const t=e.pop();if(t.shadow){pr(t.shadow);continue}const r=t.node,i=1===(E?E(r):r.nodeType),n=m(r);if(n)for(let t=n.length-1;t>=0;--t)e.push({node:n[t],shadow:null});if(i){const t=x?x(r):null;if("string"==typeof t&&"template"===Ue(t)){const t=r.content;rr(t)&&e.push({node:t,shadow:null})}}if(i){const t=S(r);rr(t)&&e.push({node:null,shadow:t},{node:t,shadow:null})}}};return r.sanitize=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,s=null,o=null,a=null;if(Pe=!t,Pe&&(t="\x3c!--\x3e"),"string"!=typeof t&&!ir(t)&&"string"!=typeof(t=function(t){switch(typeof t){case"string":return t;case"number":return Q(t);case"boolean":return Z(t);case"bigint":return tt?tt(t):"0";case"symbol":return et?et(t):"Symbol()";case"undefined":default:return it(t);case"function":case"object":{if(null===t)return it(t);const e=t,r=lt(e,"toString");if("function"==typeof r){const t=r(e);return"string"==typeof t?t:it(t)}return it(t)}}}(t)))throw st("dirty is not a string, aborting");if(!r.isSupported)return t;oe?(qt=ae,Wt=ce):Ke(e),(U.uponSanitizeElement.length>0||U.uponSanitizeAttribute.length>0)&&(qt=ht(qt)),U.uponSanitizeAttribute.length>0&&(Wt=ht(Wt)),r.removed=[];const c=ye&&"string"!=typeof t&&ir(t);if(c){!function(t){if(!ne)return;const e=[t];for(;e.length>0;){const r=e.pop(),i=E?E(r):r.nodeType;if(7===i||8===i&&nt(_t,r.data)){try{g(r)}catch(t){}continue}if(1===i){const e=r,i=Ue(x?x(r):r.nodeName);try{e.hasAttribute&&e.hasAttribute("patchsrc")&&e.removeAttribute("patchsrc"),e.hasAttribute&&e.hasAttribute("for")&&"label"!==i&&"output"!==i&&e.removeAttribute("for")}catch(t){}}const n=m(r);if(n)for(let t=n.length-1;t>=0;--t)e.push(n[t])}}(t);const r=x?x(t):t.nodeName;if("string"==typeof r){const e=Ue(r);if(!qt[e]||Xt[e])throw We(t),st("root node is forbidden and cannot be sanitized in-place")}if(er(t))throw We(t),st("root node is clobbered and cannot be sanitized in-place");try{dr(t)}catch(e){throw We(t),e}}else if(ir(t))i=Je("\x3c!----\x3e"),s=i.ownerDocument.importNode(t,!0),1===s.nodeType&&"BODY"===s.nodeName||"HTML"===s.nodeName?i=s:i.appendChild(s),dr(s);else{if(!he&&!ie&&!se&&-1===t.indexOf("<"))return A&&pe?C(t):t;if(i=Je(t),!i)return he?null:pe?w:""}i&&ue&&$e(i.firstChild);const u=c?t:i,h=Qe(u);try{for(;o=h.nextNode();)sr(o,u),lr(o),rr(o.content)&&pr(o.content)}catch(e){throw c&&(We(t),M(r.removed,t=>{t.element&&Xe(t.element)})),e}if(c)return M(r.removed,t=>{t.element&&Xe(t.element)}),ie&&tr(t),t;if(he){if(ie&&tr(i),le)for(a=O.call(i.ownerDocument);i.firstChild;)a.appendChild(i.firstChild);else a=i;return(Wt.shadowroot||Wt.shadowrootmode)&&(a=H.call(n,a,!0)),a}let l=se?i.outerHTML:i.innerHTML;return se&&qt["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&nt(Nt,i.ownerDocument.doctype.name)&&(l="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+l),ie&&(l=Ze(l)),A&&pe?C(l):l},r.setConfig=function(){Ke(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),oe=!0,ae=qt,ce=Wt},r.clearConfig=function(){je=null,oe=!1,ae=null,ce=null,A=b,w=""},r.isValidAttribute=function(t,e,r){je||Ke({});const i=Ue(t),n=Ue(e);return or(i,n,r)},r.addHook=function(t,e){"function"==typeof e&&rt(U,t)&&K(U[t],e)},r.removeHook=function(t,e){if(rt(U,t)){if(void 0!==e){const r=j(U[t],e);return-1===r?void 0:G(U[t],r,1)[0]}return V(U[t])}},r.removeHooks=function(t){rt(U,t)&&(U[t]=[])},r.removeAllHooks=function(){U={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},r}();const Mt=Ut(globalThis),jt={ADD_ATTR:["target","rel"]};Mt.addHook("afterSanitizeAttributes",t=>{"_blank"===t.getAttribute("target")?t.setAttribute("rel","noopener noreferrer"):t.hasAttribute("target")||!t.hasAttribute("xlink:href")&&!t.hasAttribute("href")||t.setAttribute("xlink:show","new")});class Vt{static sanitize(t,e={}){const r={...jt,...e};return Mt.sanitize(t,r)}}class Kt{copy(){return o.deepCopy(this)}}class Gt extends Kt{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 qt extends Gt{constructor(t){super(t)}add(t){this.items.push(t)}remove(t){this.items=this.items.filter(e=>e!==t)}addAll(t){this.items.push(...t)}unsubscribeAll(){this.items.forEach(t=>t()),this.items=[]}}class $t extends Kt{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 Wt=(t,e)=>{const r=t.location.localeCompare(e.location);return 0!==r?r:t.id.localeCompare(e.id)};class zt extends Gt{constructor(t){super(t)}findRepository(t,e,r=!1){return super.find(i=>i.id===t&&(r||i.location===e))}sortByLocationAndId(){super.sort(Wt)}filterByRepository(t){return super.filter(this.createIdLocationFilter(t))}createIdLocationFilter(t){return e=>t.some(t=>t.id!==e.id||t.location!==e.location)}}class Yt extends Kt{constructor(t){super(),this.inferred=t?.inferred||0,this.total=t?.total||0,this.explicit=t?.explicit||0}}let Xt=function(t){return t.INACTIVE="INACTIVE",t.STARTING="STARTING",t.RUNNING="RUNNING",t.RESTARTING="RESTARTING",t.STOPPING="STOPPING",t}({}),Jt=function(t){return t.GRAPH_DB="graphdb",t.ONTOP="ontop",t.FEDX="fedx",t.SYSTEM="system",t.OTHER="other",t}({});const Qt="repositoryId";let Zt=function(t){return t.NONE="NONE",t.READ="READ",t.WRITE="WRITE",t.MAINTAIN="MAINTAIN",t.GRAPHQL_READ="GRAPHQL_READ",t.GRAPHQL_WRITE="GRAPHQL_WRITE",t}({});class te extends Kt{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 ee=function(t){return t.GDB="GDB",t.ONTOPIC="ONTOPIC",t.SPARQL="SPARQL",t}({});class re{constructor(t){this.namespaces=t}getByPrefix(t){return this.namespaces[t]||""}}class ie{constructor(t,e){this.NAME=t,this.payload=e}}const ne={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",BEFORE_MOUNT_ROUTING_EVENT:"beforeMountRoutingEvent"};class se extends ie{constructor(t,e){super(ne.NAVIGATION_END,{oldUrl:t,newUrl:e})}}class oe{}class ae extends ie{constructor(t,e,r){super(ne.NAVIGATION_START,{oldUrl:t,newUrl:e,cancelNavigation:r})}}class ce extends ie{constructor(){super(ne.APPLICATION_MOUNTED)}}class ue extends ie{constructor(){super(ne.APPLICATION_UNMOUNTED)}}class he extends ie{constructor(){super(ne.APPLICATION_BEFORE_CHANGE)}}class le extends ie{constructor(){super(ne.APPLICATION_CHANGED)}}class pe extends ie{constructor(t){super(ne.BEFORE_MOUNT_ROUTING_EVENT,t)}}class de extends ie{constructor(){super(ne.LOGOUT)}}class ge extends ie{constructor(){super(ne.LOGIN)}}let fe=function(t){return t.NONE="NONE",t.BASIC="BASIC",t.SIGNATURE="SIGNATURE",t}({}),me=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_REPO_MAINTAINER="ROLE_REPO_MAINTAINER",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.MAINTAIN_REPO="MAINTAIN_REPO",t.GRAPHQL="GRAPHQL",t.WRITE_REPO_PREFIX="WRITE_REPO_",t.MAINTAIN_REPO_PREFIX="MAINTAIN_REPO_",t.GRAPHQL_PREFIX="GRAPHQL_",t.SUFFIX_DELIMITER=":",t.CUSTOM_PREFIX="CUSTOM_",t}({});class ye{static getRepoFromAuthority(t){return t.startsWith(me.READ_REPO_PREFIX)?{prefix:me.READ_REPO_PREFIX,repo:t.substring(me.READ_REPO_PREFIX.length)}:t.startsWith(me.WRITE_REPO_PREFIX)?{prefix:me.WRITE_REPO_PREFIX,repo:t.substring(me.WRITE_REPO_PREFIX.length)}:t.startsWith(me.MAINTAIN_REPO_PREFIX)?{prefix:me.MAINTAIN_REPO_PREFIX,repo:t.substring(me.MAINTAIN_REPO_PREFIX.length)}:t.startsWith(me.GRAPHQL_PREFIX)?{prefix:me.GRAPHQL_PREFIX,repo:t.substring(me.GRAPHQL_PREFIX.length)}:null}}const Se=t=>{const e=me.SUFFIX_DELIMITER+me.GRAPHQL,r=t.getItems();if(!r.length)return r;const i=[],n={};let s=!1,o=!1,a=!1;r.forEach(t=>{const e=ye.getRepoFromAuthority(t);if(!e)return void i.push(t);const{prefix:r,repo:c}=e,u=(n[h=c]||(n[h]={read:!1,write:!1,maintain:!1,graphql:!1}),n[h]);var h;r===me.READ_REPO_PREFIX?(u.read=!0,"*"===c&&(s=!0)):r===me.WRITE_REPO_PREFIX?(u.write=!0,"*"===c&&(o=!0)):r===me.MAINTAIN_REPO_PREFIX?u.maintain=!0:r===me.GRAPHQL_PREFIX&&(u.graphql=!0,"*"===c&&(a=!0))});const c=[];return Object.keys(n).forEach(t=>{const r=n[t];r.maintain?c.push(`${me.MAINTAIN_REPO_PREFIX}${t}`,`${me.WRITE_REPO_PREFIX}${t}`,`${me.READ_REPO_PREFIX}${t}`):r.graphql||a?r.write||o?c.push(`${me.WRITE_REPO_PREFIX}${t}${e}`,`${me.READ_REPO_PREFIX}${t}${e}`):(r.read||s)&&c.push(`${me.READ_REPO_PREFIX}${t}${e}`):r.write?c.push(`${me.WRITE_REPO_PREFIX}${t}`,`${me.READ_REPO_PREFIX}${t}`):r.read&&c.push(`${me.READ_REPO_PREFIX}${t}`)}),[...i,...c]},ve=t=>{if(!t)return new xe;const e=[],r=(t instanceof xe?t.getItems():t)??[];for(const t of r)Ee(t,e)||e.includes(t)||e.push(t);return new xe(e)};function Ee(t,e){if(!t.includes(me.SUFFIX_DELIMITER))return!1;const[r,i]=t.split(me.SUFFIX_DELIMITER);if(!r.startsWith(me.READ_REPO_PREFIX)&&!r.startsWith(me.WRITE_REPO_PREFIX)||i!==me.GRAPHQL)return!1;const n=ye.getRepoFromAuthority(r);if(!n)return!1;const{repo:s}=n,o=me.GRAPHQL_PREFIX+s;return e.includes(r)||e.push(r),e.includes(o)||e.push(o),!0}class xe extends Gt{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 n=e.substring(0,e.length-r.length);if(t.startsWith(n)){i=!0;break}}return i}getCustomRoles(){return this.getItems().filter(t=>0===t.indexOf(me.CUSTOM_PREFIX)).map(t=>t.substring(me.CUSTOM_PREFIX.length))}toUIModel(){const t={[me.READ_REPO]:{},[me.WRITE_REPO]:{},[me.MAINTAIN_REPO]:{},[me.GRAPHQL]:{}};return ve(this.getItems()).getItems().forEach(e=>{if(e.startsWith(me.READ_REPO_PREFIX)||e.startsWith(me.WRITE_REPO_PREFIX)||e.startsWith(me.MAINTAIN_REPO_PREFIX)||e.startsWith(me.GRAPHQL_PREFIX)){const r=ye.getRepoFromAuthority(e);if(r){const{prefix:e,repo:i}=r;e===me.MAINTAIN_REPO_PREFIX?t[me.MAINTAIN_REPO][i]=!0:e===me.READ_REPO_PREFIX?t[me.READ_REPO][i]=!0:e===me.WRITE_REPO_PREFIX?t[me.WRITE_REPO][i]=!0:e===me.GRAPHQL_PREFIX&&(t[me.GRAPHQL][i]=!0)}}}),t}toGraphdbAuthoritiesModel(){return Se(this)}getRepositoriesPermissions(){const t={},e=this.getItems();for(const r of e){const e=ye.getRepoFromAuthority(r);if(e){const{prefix:r,repo:i}=e,n=t[i]??{read:!1,write:!1,maintain:!1,graphql:!1};r===me.READ_REPO_PREFIX?n.read=!0:r===me.WRITE_REPO_PREFIX?n.write=!0:r===me.MAINTAIN_REPO_PREFIX&&(n.maintain=!0),i.split(":")[1]!==me.GRAPHQL||n.maintain||(n.graphql=!0),t[i]=n}}return t}}class Ae{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 be=function(t){return t.ADMIN="admin",t.REPO_MANAGER="repoManager",t.USER="user",t}({});class we extends Kt{constructor(t){super(),this.username=t?.username??"",this.password=t?.password,this.confirmPassword=t?.confirmPassword,this.authorities=t?.authorities??new xe,this.appSettings=t?.appSettings??new Ae,this.dateCreated=t?.dateCreated??null,this.gptThreads=t?.gptThreads??[],this.hasExternalLogin=t?.hasExternalLogin??!1}getUserType(){return this.authorities.hasAuthority(me.ROLE_ADMIN)?be.ADMIN:this.authorities.hasAuthority(me.ROLE_REPO_MANAGER)?be.REPO_MANAGER:be.USER}getUserTypeDescription(){const t=this.getUserType();return t===be.USER?"User":t===be.REPO_MANAGER?"Repository manager":t===be.ADMIN?"Administrator":"Unknown"}}class Ie extends Kt{toUser(){return new we({username:this.username,authorities:this.authorities,appSettings:this.appSettings})}static fromUser(t){return new Ie({username:t.username,authorities:t.authorities,appSettings:t.appSettings})}constructor(t){super(),this.external=t?.external??!1,this.username=t?.username??"",this.password=t?.password??"",this.authorities=t?.authorities??new xe,this.grantedAuthoritiesUiModel=ve(t?.authorities??[]),this.appSettings=t?.appSettings??new Ae}getCookieConsent(){return this.appSettings.COOKIE_CONSENT}setAuthorities(t=new xe){return this.authorities=t,this.grantedAuthoritiesUiModel=ve(t.getItems()),this}setAppSettings(t=new Ae){return this.appSettings=t,this}}class Te extends Kt{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 Re=t=>new xe(t);class Ce extends Kt{constructor(t){super(),this.appSettings=t.appSettings,t.authorities instanceof xe?this.authorities=t.authorities:this.authorities=Re(t.authorities??[]),this.enabled=t.enabled}}const Pe=t=>{const e=new Ce({});return e.appSettings=new Ae(t.appSettings),e.authorities=Re(t.authorities||[]),e.enabled=t.enabled,e};let Fe=function(t){return t.LOCAL="Local",t.LDAP="LDAP",t.OAUTH="OAuth",t}({});class Ne extends Kt{constructor(t){super(),this.authImplementation=I(Fe,t.authImplementation??Fe.LOCAL),this.enabled=t.enabled,this.passwordLoginEnabled=t.passwordLoginEnabled,this.freeAccess=Pe(t.freeAccess),this.overrideAuth=Pe(t.overrideAuth),this.openIdEnabled=t.openIdEnabled??!1,this.freeAccessActive=t.freeAccess?.enabled,this.hasExternalAuth=t.hasExternalAuth,this.allowSecurityToggle=t.allowSecurityToggle,t.methodSettings?.openid&&(this.openidSecurityConfig=new Te(t.methodSettings?.openid)),this.additionalAuthSources=(t.additionalAuthSources??[]).map(t=>I(Fe,t))}isEnabled(){return this.enabled??!1}isFreeAccessEnabled(){return this.freeAccess.enabled??!1}getFreeAccessAuthSettings(){return this.freeAccess}hasOverrideAuth(){return this.overrideAuth?.enabled??!1}isSecurityToggleAllowed(){return this.allowSecurityToggle??!0}hasAdditionalAuthSource(){return!!this.additionalAuthSources.length}getAuthSourceType(){return this.authImplementation}isOpenIdEnabled(){return this.openIdEnabled}isPasswordLoginEnabled(){return this.passwordLoginEnabled??!1}hasLocalAdditionalAuthSources(){return this.additionalAuthSources.includes(Fe.LOCAL)}}class De extends Kt{pages={};isRestricted(t){return this.pages[t]??!1}setPageRestriction(t,e=!0){return this.pages[t]=e,this}}class Oe extends Kt{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 _e extends Gt{constructor(t){super(t)}}class Le{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?.trim();if(!e)return"";const r=/^(\d+\.\d+)/.exec(e);if(r){const t=/(-[^-]+)/.exec(e),i=t?.[1]??"";return r[1]+i}return e}}let Be=function(t){return t.CONSOLE="console",t}({}),ke=function(t){return t.DEBUG="DEBUG",t.INFO="INFO",t.WARN="WARN",t.ERROR="ERROR",t}({});const He=t=>Ue[t],Ue={[ke.DEBUG]:0,[ke.INFO]:1,[ke.WARN]:2,[ke.ERROR]:3};class Me{static SERVICE_INSTANCES=new Map;static get(t){if(!Me.SERVICE_INSTANCES.has(t.name)){const e=new t;Me.implementsLifecycleHooks(e)&&e.onCreated?.(),Me.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(Me.SERVICE_INSTANCES.values()).filter(e=>e instanceof t)}}function je(t){return Me.get(t)}const Ve=new Map([[Be.CONSOLE,je(class{log(t,e,r){switch(t){case ke.DEBUG:console.debug(e,...r);break;case ke.INFO:console.info(e,...r);break;case ke.WARN:console.warn(e,...r);break;case ke.ERROR:console.error(e,...r);break;default:console.debug(e,...r)}}})]]);class Ke{callbackFunctions=[];beforeChangeValidationPromises=[];afterValueChangeCallbackFunctions=[];setValue(t){o.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 o.hasCopyMethod(t)?t.copy():o.deepCopy(t)}}class Ge{subscribers=[];unsubFns=new qt;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=Me.getAllBySuperType(qe).filter(t=>t.canSubscribeAll);for(const n of i)this.unsubFns.add(n.subscribeAll(t,e,r));const n={callback:t,beforeChangeValidationPromise:e,afterChangeCallback:r};this.subscribers.push(n);let s=!1;return()=>{if(s)return;s=!0,this.unsubFns.unsubscribeAll();const t=this.subscribers.indexOf(n);t>=0&&this.subscribers.splice(t,1)}}}class qe{context=new Map;_canSubscribeAll=!1;onCreated(){this._canSubscribeAll=!0,Me.get(Ge).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,n=!1){return!n&&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 n=new qt;for(const s of this.getContextFields())n.add(this.subscribe(s,t,e,r,i));return()=>n.unsubscribeAll()}getContextFields(){return Object.values(this).filter(t=>"string"==typeof t)}getOrCreateValueContext(t){let e=this.context.get(t);return e||(e=new Ke,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 $e extends qe{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,n=t===i.dark?i.light:i.dark;return r&&r[n]?r[n]:e.applicationLogoPath}}class We{loggers=Ve;constructor(t){this.module=t}debug(t,...e){this.log(ke.DEBUG,t,e)}error(t,...e){this.log(ke.ERROR,t,e)}info(t,...e){this.log(ke.INFO,t,e)}warn(t,...e){this.log(ke.WARN,t,e)}log(t,e,r){const i=this.loadConfiguration();i?.loggers.forEach(n=>{const s=this.loggers.get(n);if(!s)throw new Error(`Logger '${n}' not found`);if(He(i.minLogLevel)<=He(t)){const i=this.getFormattedMessage(t,e);s.log(t,i,r)}})}getFormattedMessage(t,e){return`[${t}] [${this.module}] [${(new Date).toLocaleString()}] ${e}`}loadConfiguration(){const t=je($e).getApplicationConfiguration();return t?.loggerConfig}}class ze{static loggerInstances=new Map;static getLoggerInstance(t){return this.loggerInstances.has(t)||this.loggerInstances.set(t,new We(t)),this.loggerInstances.get(t)}}class Ye{static get logger(){return ze.getLoggerInstance("API")}}class Xe{logger=Ye.logger;constructor(t){this.value=t}getValue(){return this.value}isDefined(){return!o.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 Je{static GLOBAL_NAMESPACE="ontotext.gdb"}class Qe{constructor(t=[]){this.languages=t}getLanguageCodes(){return this.languages?.map(t=>t.key)}}const Ze=["en","fr"];class tr extends Kt{constructor(t){super(),this.defaultLanguage=t.defaultLanguage||"en",this.availableLanguages=t.availableLanguages||new Qe,this.languageBundleVersion=t.languageBundleVersion||""}}class er{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 er({policyAccepted:void 0,statistic:!0,thirdParty:!0})}static ACCEPTED_NO_TRACKING(){return new er({policyAccepted:!0,statistic:!1,thirdParty:!1})}static fromJSON(t){return new er({policyAccepted:t?.policyAccepted,statistic:t?.statistic,thirdParty:t?.thirdParty,updatedAt:t?.updatedAt})}}let rr=function(t){return t.INFORMATION="INFORMATION",t.WARNING="WARNING",t.CRITICAL="CRITICAL",t}({});const ir={[rr.INFORMATION]:0,[rr.WARNING]:1,[rr.CRITICAL]:2};class nr extends Kt{constructor(t){super(),this.id=`${t.group}-${t.status}-${t.totalOperations}`,this.group=t.group,this.totalOperations=t.totalOperations,this.status=t.status}}class sr extends Gt{constructor(t){super(t)}}class or extends Kt{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 nr({group:e.group,totalOperations:0,status:rr.INFORMATION}));const r=t.get(e.group);r.totalOperations+=e.count,ir[e.status]>ir[r.status]&&(r.status=e.status)}),Array.from(t.values())}toOperationGroupSummaryList(){return new sr(this.toOperationsGroupSummary())}}class ar extends Gt{constructor(t){super(t)}}let cr=function(t){return t.UPDATES="updates",t.QUERIES="queries",t.IMPORT="imports",t.BACKUP_AND_RESTORE="backupAndRestore",t.CLUSTER_HEALTH="clusterHealth",t}({}),ur=function(t){return t.QUERY="QUERY",t.BACKUP="BACKUP",t.CLUSTER="CLUSTER",t.IMPORT="IMPORT",t}({});const hr=[cr.QUERIES,cr.UPDATES,cr.IMPORT],lr={[cr.UPDATES]:"monitor/queries",[cr.QUERIES]:"monitor/queries",[cr.BACKUP_AND_RESTORE]:"monitor/backup-and-restore",[cr.IMPORT]:"import",[cr.CLUSTER_HEALTH]:"cluster"},pr={[cr.QUERIES]:ur.QUERY,[cr.UPDATES]:ur.QUERY,[cr.BACKUP_AND_RESTORE]:ur.BACKUP,[cr.IMPORT]:ur.IMPORT,[cr.CLUSTER_HEALTH]:ur.CLUSTER};class dr extends Kt{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=pr[this.type],this.href=lr[this.type],this.labelKey=this.getLabelKey(this.type,this.value)}getCount(t,e){return hr.includes(t)?parseInt(e,10):0}getLabelKey(t,e){return hr.includes(t)?t:e}}let gr=function(t){return t.BOTTOM_RIGHT="bottom-right",t.BOTTOM_LEFT="bottom-left",t}({});class fr{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 mr extends fr{constructor(t){super(),this.timeout=t.timeout,this.position=t.position}static getDefaultConfig(){return this.instance||(this.instance=new mr({timeout:5e3,position:gr.BOTTOM_RIGHT})),this.instance}}let yr=function(t){return t.ERROR="error",t.INFO="info",t.SUCCESS="success",t.WARNING="warning",t}({});class Sr{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 n=Math.random()*t;return e>0?(n=(e+n)%t|0,e=Math.floor(e/t)):(n=(r+n)%t|0,r=Math.floor(r/t)),("x"===i?n:3&n|8).toString(t)})}static generateRandomString(t){const e=new Uint32Array(t);return l.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 vr extends Kt{constructor(){super(),this.id=Sr.uuid()}}class Er extends vr{constructor(t,e,r){super(),this.type=t,this.message=e,this.config=r}}const xr="create-toast-event";class Ar extends Gt{constructor(t){super(t)}}let br=function(t){return t.CANCEL="cancel",t.EXIT="exit",t.DONT_SHOW_AGAIN="dontShowAgain",t}({});const wr="confirm-cancel-event";class Ir{constructor(t,e){this.hasDontShowAgain=t,this.onClose=e}}class Tr extends Gt{constructor(t){super(t)}}class Rr extends Kt{constructor(t){super(),this.setRadio(t.isRadio),this.setButtons(new Tr(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 Cr extends Kt{constructor(t){super(),this.id=t.id,this.label=t.label,this.selected=t.selected,this.callback=t.callback}}class Pr extends Gt{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 Fr extends Kt{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 Pr,this.copy()}getByValue(t){return this.suggestions.findSuggestionByValue(t)}clearSelectedState(){this.suggestions.deselectAllSuggestions()}clearHoveredState(){this.suggestions.unhoverAllSuggestions()}}class Nr extends Kt{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 Dr=function(t){return t.URI="uri",t.PREFIX="prefix",t}({});class Or{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 _r=function(t){return t.DATA_LOADED="DATA_LOADED",t}({}),Lr=function(t){return t.MOUNTED="MOUNTED",t.UNMOUNTED="UNMOUNTED",t}({}),Br=function(t){return t.LEGACY_ANGULAR="@ontotext/legacy-workbench",t.NEW_ANGULAR="@ontotext/workbench",t}({});class kr{constructor(t){this.applicationsState=t}isLegacyAngularLoaded(){return this.applicationsState[Br.LEGACY_ANGULAR]===Lr.MOUNTED}isNewAngularLoaded(){return this.applicationsState[Br.NEW_ANGULAR]===Lr.MOUNTED}equals(t){if(!t)return!1;const e=Object.keys(this.applicationsState),r=Object.keys(t.applicationsState);if(e.length!==r.length)return!1;for(const r of e)if(this.applicationsState[r]!==t.applicationsState[r])return!1;return!0}}class Hr{constructor(t,e){this.entry=t,this.name=e}}class Ur extends Kt{constructor(t){super(),this._pluginDefinitions=t}getPluginDefinitions(){return this._pluginDefinitions}}class Mr extends Gt{}class jr{plugins=new Mr;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 Vr extends Gt{constructor(t){super(t)}}class Kr extends Kt{_disabled=!1;constructor(t={}){super(),this._disabled=t.disabled??!1}get disabled(){return this._disabled}set disabled(t){this._disabled=t}}class Gr extends Kr{constructor(t){super(),this._items=t.items||[]}get items(){return this._items}set items(t){this._items=t||[]}}class qr{_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 $r extends Kr{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 Wr extends Kr{constructor(t){super(t),this.guideBlockName=t.guideBlockName||"",this.getStep=t.getStep,this.getSteps=t.getSteps}}class zr extends jr{static NAME="main.menu";name=zr.NAME}class Yr extends jr{static NAME="route";name=Yr.NAME}class Xr extends jr{static NAME="guide.step";name=Xr.NAME;fieldIdName="guideBlockName"}class Jr extends jr{static NAME="themes";name=Jr.NAME}class Qr 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 Zr extends Kt{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 n=r.find(e=>e.guideBlockName===t.guideBlockName);if(!n)return[];const s={...n.options??{},...t.options,...e};let a=[];if(n.getSteps)a=a.concat(this._getSteps(o.deepCopy(n.getSteps(s,i)),e,r,i));else{if(!n.getStep)throw new Qr(n.guideBlockName);a.push(o.deepCopy(n.getStep(s,i)))}return a.forEach((t,e)=>{t.stepN=e,t.stepsTotalN=a.length}),a}}let ti=function(t){return t.ERROR="error",t.INFO="info",t.SUCCESS="success",t.WARNING="warning",t}({});class ei extends vr{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 ei(t).withType(ti.INFO)}static error(t){return new ei(t).withType(ti.ERROR)}static warning(t){return new ei(t).withType(ti.WARNING)}static success(t){return new ei(t).withType(ti.SUCCESS)}}let ri=function(t){return t.SHOULD_TOAST="shouldToast",t}({});class ii{priority=0}class ni extends Gt{constructor(t){super(t)}}class si{constructor(t){this.url=t.url,this.method=t.method,this.headers={...t.headers},this.body=t.body,this.signal=t.signal}}class oi{constructor(t){this.status=t.status,this.statusText=t.statusText,this.headers=t.headers,this.config=t.config,this.originalResponse=t.originalResponse}}class ai extends oi{constructor(t){super(t),this.data=t.data}}class ci extends oi{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 ui extends Gt{constructor(t=[]){super(t)}getFirstQuery(){return this.getFirstItem()}}class hi{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 li=function(t){return t.CENTER="center",t.START="start",t}({});class pi{constructor(t,e,r,i,n,s,o){this.status=t,this.command=e,this.messageLabelKey=r,this.parameters=i,this.message=n,this.iri=s,this.name=o}}const di={ERROR:"error",SUCCESS:"success"};class gi extends Kt{constructor(t="",e=0,r=0,i=0,n=0,s=0,o=!1){super(),this.status=t,this.processedEntities=e,this.estimatedEntities=r,this.indexedEntities=i,this.entitiesPerSecond=n,this.etaSeconds=s,this.repair=o}get isBuilt(){return"BUILT"===this.status}get percentDone(){return this.estimatedEntities?Number.parseFloat((100*this.processedEntities/this.estimatedEntities).toFixed(0)):0}}let fi=function(t){return t.CREATE="create",t.REPAIR="repair",t.DROP="drop",t}({});class mi extends Kt{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 yi extends Gt{constructor(t){super(t)}getByStartMode(t){return this.items.filter(e=>e.startMode===t)}}let Si=function(t){return t.SEARCH="search",t.NODE="node",t.QUERY="query",t}({}),vi=function(t){return t.RETURN_URL="r",t.NO_ACCESS="noaccess",t.EXPIRED="expired",t}({}),Ei=function(t){return t.REPOSITORIES_UPDATED="repositoriesUpdated",t}({});class xi{constructor(t,e){this.type=t,this.params=e}}class Ai{getStorage(){return localStorage}get(t,e=!0){const r=this.getStorage().getItem(e?this.getPrefixedKey(t):t);return new Xe(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=`${Je.GLOBAL_NAMESPACE}.${this.NAMESPACE}.`,r=`${this.NAMESPACE}.`;return t.startsWith(e)?t:t.startsWith(r)?`${Je.GLOBAL_NAMESPACE}.${t}`:`${e}${t}`}}class bi{logger=Ye.logger;handleStorageChange(t){const e=t.key?.substring(Je.GLOBAL_NAMESPACE.length+1);let r="",i="";e&&(r=e.substring(0,e.indexOf(".")),i=e.substring(r.length+1));const n=this.resolveHandler(r,i);if(n){let e;null!==t.newValue&&(e=n.deserializeProperty(i,t.newValue)),n.updateContextProperty(i,e)}}resolveHandler(t,e){if(!t)return void this.logger.debug("Namespace is required to resolve a context property change handler.");const r=Me.getAllBySuperType(qe).find(t=>t.canHandle(e));if(r)return r;this.logger.debug(`No context property change handler found for namespace: ${t} and property: ${e}`)}}class wi extends Ai{NAMESPACE="application";SETTINGS="settings";logger=Ye.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 n;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 n(t):new n}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}getJsonLDExportSettings(){return this.getApplicationSettings().jsonLdExportSettings}setJsonLDExportSettings(t){const e=this.getApplicationSettings();e.jsonLdExportSettings=t,this.setApplicationSettings(e)}}class Ii extends qe{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 Ti{applicationSettingsStorageService=je(wi);runtimeConfigurationContextService=je(Ii);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()?Ti.CODE_EDITOR_DARK_THEME:void 0}getPreferredScheme(){return l.matchMedia("(prefers-color-scheme: dark)").matches?i.dark:i.light}getRootElement(){return document.querySelector(this.rootSelector)??null}}class Ri{preProcessors=new Gt;postProcessors=new Gt;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 Ci{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 Pi="http-request-done-event";class Fi{interceptorService=Me.get(Ri);eventEmitter=new Ci;get(t,e){const{params:r,headers:i,responseType:n="body"}=e??{};return"response"===n?this.request(t,"GET",{params:r,headers:i},"response"):"blob"===n?this.request(t,"GET",{params:r,headers:i},"blob"):this.request(t,"GET",{params:r,headers:i},"body")}post(t,e){const{body:r,headers:i,responseType:n="body"}=e??{};return"response"===n?this.request(t,"POST",{body:r,headers:i},"response"):"blob"===n?this.request(t,"POST",{body:r,headers:i},"blob"):this.request(t,"POST",{body:r,headers:i},"body")}put(t,e){const{params:r,body:i,headers:n,responseType:s="body"}=e??{};return"response"===s?this.request(t,"PUT",{params:r,body:i,headers:n},"response"):this.request(t,"PUT",{params:r,body:i,headers:n},"body")}patch(t,e){const{params:r,body:i,headers:n,responseType:s="body"}=e??{};return"response"===s?this.request(t,"PATCH",{params:r,body:i,headers:n},"response"):this.request(t,"PATCH",{params:r,body:i,headers:n},"body")}delete(t,e){const{params:r,headers:i,responseType:n="body"}=e??{};return"response"===n?this.request(t,"DELETE",{params:r,headers:i},"response"):this.request(t,"DELETE",{params:r,headers:i},"body")}uploadFile(t,e,r="file",i,n){const s=new FormData;s.append(r,e,e instanceof File?e.name:void 0),n&&Object.entries(n).forEach(([t,e])=>{s.append(t,e)});const o={...i};return delete o["Content-Type"],this.post(t,{body:s,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:n,headers:s}=this.getRequestConfig(t,r),o=new si({url:n,method:e,headers:s,body:r.body});let a;return this.executeRequest(o).then(async t=>{a=t;const e=t.clone();if(!t.ok){const r=await this.getDataFromResponse(i,e),n=new ci({status:t.status,statusText:t.statusText,headers:this.extractHeaders(t),config:o,originalResponse:t,data:r});return Promise.reject(n)}const r=await this.getDataFromResponse(i,e);return"body"===i?r:new ai({status:t.status,statusText:t.statusText,headers:this.extractHeaders(t),config:o,originalResponse:t,data:r})}).catch(t=>{if(t instanceof ci)return Promise.reject(t);if("AbortError"===t?.name)throw t;a??=t;const e=new ci({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:Pi,payload:void 0}))}async getDataFromResponse(t,e){if("blob"===t)return e.blob();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}`:""}`,n=e.body instanceof FormData,s={Accept:"application/json, text/plain, */*",...e.headers};return n||(s["Content-Type"]=e.headers?.["Content-Type"]??"application/json"),{fullUrl:i,headers:s,signal:e.signal}}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,signal:t.signal})}).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 Ni extends Fi{I18N_ENDPOINT="assets/i18n";getLanguage(t,e){return this.get(`${this.I18N_ENDPOINT}/${t}.json`,e?{params:{version:e}}:void 0)}getLanguageConfiguration(){return this.get(`${this.I18N_ENDPOINT}/language-config.json`)}}class Di extends Ai{NAMESPACE="i18n";set(t,e){this.storeValue(t,e)}}class Oi extends qe{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||Me.get(Bi).getDefaultLanguage();Me.get(Di).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 _i extends Kt{constructor(t,e){super(),this.key=t,this.name=e}}function Li(t){const e=t.map(t=>new _i(t.key,t.name));return new Qe(e)}class Bi{languageRestService=Me.get(Ni);languageContextService=Me.get(Oi);getSupportedLanguages(){const t=this.languageContextService.getLanguageConfig();return t?t.availableLanguages.getLanguageCodes():Ze}getLanguage(t){return this.languageRestService.getLanguage(t,this.languageContextService.getLanguageConfig()?.languageBundleVersion)}getLanguageConfiguration(){return this.languageRestService.getLanguageConfiguration().then(t=>{return new tr({defaultLanguage:(e=t).defaultLanguage,availableLanguages:Li(e.availableLanguages),languageBundleVersion:e.languageBundleVersion});var e})}getDefaultLanguage(){const t=this.languageContextService.getLanguageConfig();return t?t.defaultLanguage:"en"}}class ki extends Fi{static REPOSITORIES_ENDPOINT="rest/repositories";getRepositories(){return this.get(`${ki.REPOSITORIES_ENDPOINT}/all`)}getRepositorySizeInfo(t){return this.get(`${ki.REPOSITORIES_ENDPOINT}/${t.id}/size?location=${encodeURIComponent(t.location)}`)}}const Hi=t=>{if(!t||"object"!=typeof t)return new zt;const e=[];return Object.entries(t).forEach(([,t])=>{Array.isArray(t)&&t.forEach(t=>{const r=new $t({id:t.id,title:t.title,type:I(Jt,t.type),sesameType:t.sesameType,uri:t.uri,externalUrl:t.externalUrl,location:t.location,state:I(Xt,t.state),local:t.local,readable:t.readable,writable:t.writable,unsupported:t.unsupported});e.push(r)})}),new zt(e)};class Ui{constructor(){this.repositoryRestService=je(ki)}async getRepositories(){const t=await this.repositoryRestService.getRepositories();return Hi(t)}async getRepositorySizeInfo(t){return e=await this.repositoryRestService.getRepositorySizeInfo(t),new Yt(e);var e}}class Mi extends Ai{NAMESPACE="repository";logger=Ye.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 ji extends qe{SELECTED_REPOSITORY="selectedRepository";REPOSITORY_LIST="repositoryList";logger=Ye.logger;updateSelectedRepository(t){const e=je(Mi),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 zt([])}onRepositoryListChanged(t){return this.subscribe(this.REPOSITORY_LIST,t)}getDeserializedContext(){return{[this.SELECTED_REPOSITORY]:this.deserializeRepository}}deserializeRepository=t=>{try{return this.findRepository(JSON.parse(t))}catch(e){return void this.logger.error(`Failed to deserialize repository from: "${t}"`,e)}};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 Vi{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 Ki extends Fi{getActiveRepositoryLocation(){return this.get("rest/locations/active")}}const Gi=t=>new te({uri:t.uri,label:t.label,username:t.username??void 0,password:t.password??void 0,authType:t.authType?I(fe,t.authType):void 0,locationType:t.locationType?I(ee,t.locationType):void 0,active:t.active,local:t.local,system:t.system,errorMsg:t.errorMsg??"",defaultRepository:t.defaultRepository??void 0});class qi{constructor(){this.locationRestService=Me.get(Ki)}getActiveRepositoryLocation(){return this.locationRestService.getActiveRepositoryLocation().then(Gi)}}class $i extends qe{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 Wi extends Fi{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 zi=function(t){return t.GRAPHDB_LITE="GRAPHDB_LITE",t.GRAPHDB_SE="GRAPHDB_SE",t.GRAPHDB_ENTERPRISE="GRAPHDB_ENTERPRISE",t.GRAPHDB_SANDBOX="GRAPHDB_SANDBOX",t}({}),Yi=function(t){return t.FREE="free",t.STANDARD="standard",t.ENTERPRISE="enterprise",t.SANDBOX="sandbox",t}({});function Xi(t){return Object.values(Yi).find(e=>e===t)}const Ji=t=>{return new Oe({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(zi).find(t=>t===e)),productType:Xi(t?.productType),licenseCapabilities:Qi(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 Qi(t){const e=(t??[]).filter(t=>t?.trim());return new _e(e)}class Zi extends qe{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 tn{licenseRestService=je(Wi);licenseContextService=je(Zi);trackableProductTypes=[Yi.FREE,Yi.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 Ji(t)}registerLicense(t){return this.licenseRestService.registerLicense(t).then(t=>Ji(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=>Ji(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 en extends qe{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 rn extends Fi{VERSION_URL="rest/info/version";getProductInfoLocal(){return this.get(`${this.VERSION_URL}?local=1`)}}class nn{productInfoRestService=je(rn);async getProductInfoLocal(){const t=await this.productInfoRestService.getProductInfoLocal();return new Le({workbench:(e=t).Workbench||"",productType:e.productType||"",productVersion:e.productVersion||"",sesame:e.sesame||"",connectors:e.connectors||"",ontop:e.Ontop||""});var e}}class sn extends qe{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 De}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 on extends Ai{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 an=r(355);class cn extends Error{constructor(t){super(),this.text=t}get message(){return`${this.constructor.name}: ${this.text}`}}class un extends cn{}class hn extends un{constructor(){super("Invalid JWT token")}}let ln=function(t){return t.ACCESS="access",t.ID="id",t.REFRESH="refresh",t}({});class pn{logger=Ye.logger;openidStorageService=je(on);securityContextService=je(sn);REFRESH_TOKEN_TOLERANCE=5e3;hasValidIdToken(t){return this.getTokenByType(ln.ID)?this.verifyToken(ln.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(ln.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()===ln.ID?"Bearer "+this.getTokenByType(ln.ID):"Bearer "+this.getTokenByType(ln.ACCESS)}getTokenHeader(t){try{const e=an.pj.jws.JWS.readSafeJSONString((0,an.cV)(t.split(".")[0]));if(e)return e}catch(t){throw this.logger.error("OpenID: token header decode failed",t),new hn}}getTokenPayload(t){try{const e=an.pj.jws.JWS.readSafeJSONString((0,an.cV)(t.split(".")[1]));if(e)return e}catch(t){throw this.logger.debug("Token payload decode error",t),new hn}}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!==ln.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 n=this.securityContextService.getJsonWebKeysSet()?.[i.kid];if(!n)return this.logger.debug("OpenID: no key to verify JWT token (token considered invalid)"),!1;const s=an.ym.getKey(n),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]),an.pj.jws.JWS.verifyJWT(r,s,o)}clearTokens(){this.openidStorageService.clearTokens()}getTokenByType(t){return t===ln.ID?this.openidStorageService.getIdToken().getValue():t===ln.ACCESS?this.openidStorageService.getAccessToken().getValue():t===ln.REFRESH?this.openidStorageService.getRefreshToken().getValue():null}}class dn{static pkceChallengeFromVerifier(t){const e=new an.pj.crypto.MessageDigest({alg:"sha256",prov:"cryptojs"});return(0,an.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=l.getLocationHash().substring(1);r=new URLSearchParams(t)}else r=new URLSearchParams(l.getLocationQueryParams());return 0===r.size||Object.keys(e).forEach(t=>{const i=r.get(t);i&&(e[t]=decodeURIComponent(i))}),e}}class gn extends un{constructor(t){super(`Invalid OpenID authentication flow: ${t}`)}}class fn extends un{constructor(){super("Missing authorization code")}}let mn=function(t){return t.CODE="code",t.CODE_NO_PKCE="code_no_pkce",t.IMPLICIT="implicit",t}({}),yn=function(t){return t.CODE="code",t.TOKEN="token id_token",t}({});class Sn{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 vn{notificationAddedCallbackFunctions=[];notifications=new Sn;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 En(t){je(vn).addNotification(t)}class xn{logger=Ye.logger;tokenUtils=je(pn);openidStorageService=je(on);async handleAuthorizationCode(t,e,r){if(!e.code)throw this.logger.error("OpenID: Missing authorization code"),new fn;const i=`${x()}`;if(t.authFlow===mn.CODE)await this.handlePkceFlow(e,i,r);else{if(t.authFlow!==mn.CODE_NO_PKCE)throw this.logger.error("OpenID: Invalid OpenID authentication flow"),new gn(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(Sr.generateRandomString(28))}getCodeChallengeForCodeFlow(){const t=this.openidStorageService.getPkceCodeVerifier().getValue();if(!t)throw new un("Missing PKCE code verifier");return dn.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}`),En(ei.error("openid.errors.invalid_pkce_state").withTitle("openid.errors.title").withParameters({[ri.SHOULD_TOAST]:!0})),new un(`PKCE state mismatch ${i} != ${t.state}`);if(!t.code)throw new fn;const n=this.openidStorageService.getPkceCodeVerifier().getValue();await r(t.code,e,n)}async handleCodeNoPkceFlow(t,e,r){await r(t,e)}}class An extends un{constructor(){super("OpenID security configuration is not available")}}class bn extends Fi{securityContextService=je(sn);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 n={...this.getDomainHeaders(),"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},s=this.transformURLEncodedRequest(i);return this.post(this.getTokensEndpoint(),{body:s,headers:n})}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 An}getJWKSEndpoint(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.openIdKeysUri;throw new An}getTokensEndpoint(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.openIdTokenUrl;throw new An}getDomainHeaders(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;return t?.oracleDomain?{[this.OAUTH_IDENTITY_DOMAIN_NAME_HEADER]:t.oracleDomain}:{}}}class wn{securityContextService=je(sn);buildLoginUrl(t,e,r){const i=this.getResponseType(),n=[...this.buildBaseParameters(i,r),...this.buildFlowSpecificParameters(t,e),...this.buildAdditionalParameters()];return`${this.getOpenIdConfig().oidcAuthorizationEndpoint}?${n.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 An;return t}getResponseType(){const t=this.getOpenIdConfig().authFlow;if(t===mn.CODE||t===mn.CODE_NO_PKCE)return yn.CODE;if(t===mn.IMPLICIT)return yn.TOKEN;throw new gn(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===mn.CODE?i.push(`state=${encodeURIComponent(t)}`,`code_challenge=${encodeURIComponent(e)}`,"code_challenge_method=S256"):r===mn.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 In{DEFAULT_REFRESH_CONFIGURATION={refreshAheadMs:6e4,minDelayMs:1e3};logger=Ye.logger;tokenUtils=je(pn);openidStorageService=je(on);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&&(l.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=l.getWindow().setTimeout(async()=>{this.logger.debug("OpenID: tokens will refresh now, "+e),await r(t)},e)}}class Tn extends Ai{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(){return this.isGDBToken()||this.isOpenIDToken()}isGDBToken(){const t=this.getAuthToken().getValue();return!!t?.startsWith("GDB")}isOpenIDToken(){const t=this.getAuthToken().getValue();return!!t?.startsWith("Bearer")}}class Rn{constructor(t){this.notify=t}}class Cn{eventSubscribers=new Map;emit(t){const e=this.eventSubscribers.get(t.NAME);e&&e.forEach(e=>{e.notify(o.deepCopy(t.payload))})}subscribe(t,e){const r=new Rn(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 Pn{logger=Ye.logger;openIdRestService=je(bn);openidStorageService=je(on);securityContextService=je(sn);tokenUtils=je(pn);authenticationStorageService=je(Tn);authFlowHandler=je(xn);tokenRefreshManager=je(In);openIdUrlBuilder=je(wn);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 ci&&(e=t.data?.error_description??"unknown error"),En(ei.error("openid.errors.cannot_refresh_token").withTitle("openid.errors.title").withParameters({error:e,[ri.SHOULD_TOAST]:!0})),this.softLogout(),je(Cn).emit(new de)}}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(x()):this.softLogout()}getOpenIdConfig(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(!t)throw new An;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===mn.IMPLICIT,r=dn.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 n=await this.getTokens(e,t,r);this.logger.debug("OpenID: successfully retrieved tokens"),this.tokenUtils.saveTokens(n,i),await this.setupTokensRefresh()}catch(t){throw this.logger.error("OpenID: Cannot retrieve token after login",{error:t}),En(ei.error("openid.errors.cannot_retrieve_token").withTitle("openid.errors.title").withParameters({error:t instanceof Error?t.message:String(t),[ri.SHOULD_TOAST]:!0})),new un("Cannot retrieve token after login")}}softLogout(){this.clearAuthentication()}hardLogout(t){this.softLogout();const e=this.getLogoutUrl(t);this.redirectToUrl(e)}redirectToUrl(t){l.setLocationHref(t)}getLoginUrl(t,e,r){return this.openIdUrlBuilder.buildLoginUrl(t,e,r)}getLogoutUrl(t){return this.openIdUrlBuilder.buildLogoutUrl(t)}}let Fn=function(t){return t.GDB_TOKEN="GDB_TOKEN",t.OPENID="OPENID",t.EXTERNAL="EXTERNAL",t.NO_SECURITY="NO_SECURITY",t}({});class Nn{logger=Ye.logger;securityService=je($n);securityContextService=je(sn);type=Fn.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 Dn extends un{constructor(){super("OpenID user has no access rights")}}class On{logger=Ye.logger;securityService=je($n);authenticationStorageService=je(Tn);authenticationService=je(ts);securityContextService=je(sn);openIdService=je(Pn);openidStorageService=je(on);tokenUtils=je(pn);type=Fn.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&&m(e),t}catch(t){return this.handleAuthenticationError(t),!1}}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}login(){this.validateConfiguration();const t=this.getReturnUrl(),e=Sr.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 An}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),En(ei.error("openid.errors.user_no_access").withTitle("openid.errors.title").withParameters({[ri.SHOULD_TOAST]:!0})),new Dn}}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`${x()}`}executeAuthFlow(t,e,r){switch(t){case mn.CODE:this.openIdService.setupCodeFlow(e,r);break;case mn.CODE_NO_PKCE:this.openIdService.setupCodeNoPkceFlow(e,r);break;case mn.IMPLICIT:this.openIdService.setupImplicitFlow(e,r);break;default:throw this.logger.debug(`OpenID: Invalid OpenID authentication flow: ${t}`),En(ei.error("openid.errors.unknown_flow").withTitle("openid.errors.title").withParameters({authFlow:t,[ri.SHOULD_TOAST]:!0})),new gn(t)}}}class _n extends cn{constructor(){super("Missing token in authentication header")}}class Ln extends cn{constructor(){super("Invalid login data. Expected an object of type LoginData.")}}class Bn{securityService=je($n);authStorageService=je(Tn);securityContextService=je(sn);type=Fn.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()}async login(t){this.assertIsLoginData(t);const{username:e,password:r}=t,i=await this.securityService.loginGdbToken(e,r),n=this.getAuthenticationHeader(i),s=Gn(i.data);if(!n)throw new _n;return this.authStorageService.setAuthToken(n),s}assertIsLoginData(t){if("object"!=typeof t||null===t||!("username"in t)||!("password"in t))throw new Ln}getAuthenticationHeader(t){return t.headers.authorization}logout(){return this.authStorageService.clearAuthToken(),Promise.resolve()}isAuthenticated(){return null!==this.authStorageService.getAuthToken().getValue()}isExternal(){return!1}isCurrentRouteLogin(){return"login"===b()}}class kn extends cn{constructor(){super()}}class Hn extends Fi{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 Un extends Fi{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 Mn{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 jn=t=>new Mn({password:t.password,grantedAuthorities:t.authorities.toGraphdbAuthoritiesModel(),appSettings:t.appSettings.toJSON()}),Vn=t=>new we({username:t.username,authorities:new xe(t.grantedAuthorities),appSettings:new Ae({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 er(t.appSettings.COOKIE_CONSENT):void 0}),dateCreated:new Date(t.dateCreated),gptThreads:t.gptThreads,hasExternalLogin:t.hasExternalLogin});class Kn{static ADMIN_USERNAME="admin";usersRestService=je(Un);getUser(t){return this.usersRestService.getUser(t).then(t=>Vn(t))}getUsers(){return this.usersRestService.getUsers().then(t=>t.map(t=>Vn(t)))}getAdminUser(){return this.usersRestService.getUser(Kn.ADMIN_USERNAME).then(t=>Vn(t))}createUser(t){const e=jn(t);return this.usersRestService.createUser(t.username,e)}updateUser(t){const e=jn(t);return this.usersRestService.updateUser(t.username,e)}deleteUser(t){return this.usersRestService.deleteUser(t)}updateCurrentUser(t){const e=jn(t);return this.usersRestService.updateCurrentUser(t.username,e)}}const Gn=t=>new Ie({username:t.username,password:t.password,authorities:new xe(qn(t.authorities)),appSettings:new Ae(t.appSettings),external:t.external}),qn=t=>{if(!t)return[];const e=[...t];return e.some(t=>t===me.ROLE_REPO_MANAGER||t.startsWith(me.MAINTAIN_REPO_PREFIX))&&e.push(me.ROLE_REPO_MAINTAINER),e};class $n{securityRestService=je(Hn);securityContextService=je(sn);usersService=je(Kn);updateAuthenticatedUser(t){return this.usersService.updateCurrentUser(t)}getSecurityConfig(){return this.securityRestService.getSecurityConfig().then(t=>new Ne(t))}getFreeAccess(){return this.securityRestService.getFreeAccess().then(function(t){return Pe(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=Se(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=>Gn(t))}getAuthenticatedAdminUser(){return this.usersService.getAdminUser().then(t=>Ie.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 Wn{securityService=je($n);securityContextService=je(sn);type=Fn.EXTERNAL;initialize(){return Promise.resolve(!0)}isAuthenticated(){return!!this.securityContextService.getAuthenticatedUser()}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}login(){throw new kn}logout(){throw new kn}isExternal(){return!0}}class zn{securityContextService=je(sn);authStorageService=je(Tn);resolveStrategy(t){const e=this._resolveStrategy(t);return this.setStrategy(e),e}setStrategy(t){this.authStrategy=t}getAuthStrategy(){return this.authStrategy}_resolveStrategy(t){return t.isEnabled()?this.securityContextService.getAuthenticatedUser()?this.authStorageService.isGDBToken()?new Bn:this.authStorageService.isOpenIDToken()?new On:new Wn:t.openIdEnabled?new On:new Bn:new Nn}}class Yn{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 Xn{routePlugins=l.getPluginRegistry().get(Yr.NAME);getActiveRoute(t){const e=this.routePlugins.find(e=>this.routeToRegex(e.url).getRegex().test(t));return e?new $r(e):void 0}routeToRegex(t){const e=[],r=t.replace(/([().])/g,"\\$1").replace(/(\/)?:(\w+)(\*\?|[?*])?/g,function(t,r,i,n){const s="?"===n||"*?"===n,o="*"===n||"*?"===n;return e.push(i),r=r||"",(s?"(?:"+r:r+"(?:")+(o?"(.+?)":"([^/]+)")+(s?"?)?":")")}).replace(/([/$*])/g,"\\$1");return new Yn(new RegExp("^"+r+"(?:[?#]|$)"),new Gt(e))}}class Jn{securityContextService=je(sn);repositoryStorageService=je(Mi);repositoryContextService=je(ji);repositoryAuthorityService=je(Vi);constructor(){this.permissionResolvers=this.initPermissionResolvers()}hasFreeAccess(){const t=this.getSecurityConfig();return!(!t?.isEnabled()||!t?.freeAccess?.enabled)}initializeFreeAccess(){const t=this.getSecurityConfig();if(t?.isEnabled()&&t?.isFreeAccessEnabled()){const e=(new Ie).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 Ie;e.username="overrideauth",e.setAuthorities(t.overrideAuth.authorities),e.setAppSettings(t.overrideAuth.appSettings),this.securityContextService.updateAuthenticatedUser(e)}}isAdmin(){return this.hasRole(me.ROLE_ADMIN)}isRepoManager(){return this.hasRole(me.ROLE_REPO_MANAGER)}isRepoMaintainer(){return this.hasRole(me.ROLE_REPO_MAINTAINER)}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=me.IS_AUTHENTICATED_FULLY===t,n=!!r?.authorities.hasAuthority(t);return i||n}canReadRepo(t){return this.hasRepoPermission(Zt.READ,t)}canWriteRepo(t){return this.hasRepoPermission(Zt.WRITE,t)}canMaintainRepo(t){return this.hasRepoPermission(Zt.MAINTAIN,t)}canReadGqlRepo(t){return this.hasGraphqlPermissions(Zt.GRAPHQL_READ,t)}canWriteGqlRepo(t){return this.hasGraphqlPermissions(Zt.GRAPHQL_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)}getRepositoryPermission(t){return this.permissionResolvers.find(e=>e.matches(t))?.permission??Zt.NONE}hasAuthority(){if(this.isAdminOrRepoManager())return!0;const t=je(Xn).getActiveRoute(E());if(!t)return!1;if(!t.allowAuthorities)return!0;if(!je(Mi).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=l.getWindow().PluginRegistry.get(Yr.NAME),n=l.getWindow().PluginRegistry.get(zr.NAME);i.forEach(i=>{const s=n.flatMap(t=>t.items).filter(t=>t.role?.startsWith("ROLE_")).find(t=>i.url.includes(t.href));if(!s)return;const o=!r&&!e?.authorities.hasAuthority(s.role??"");t.setPageRestriction(i.url,o)}),this.securityContextService.updateRestrictedPages(t)}isAdminOrRepoManager(){return this.hasRole(me.ROLE_ADMIN)||this.hasRole(me.ROLE_REPO_MANAGER)}canExtendExternalUsers(){const t=this.getSecurityConfig();return!!t&&t.hasAdditionalAuthSource()&&t.hasLocalAdditionalAuthSources()}resolveAuthorities(t){if(!t)return[];const e=je(Mi).getRepositoryReference();return e?.id?[...t.map(t=>t.replace("{repoId}",s(e))),...t.map(t=>t.replace("{repoId}","*"))]:t}getSecurityConfig(){return je(sn).getSecurityConfig()}getAuthenticatedUser(){return je(sn).getAuthenticatedUser()}hasRepoPermission(t,e){if(!e||""===e.id)return!1;const r=this.getSecurityConfig(),i=this.getAuthenticatedUser();return!r?.isEnabled()&&!r?.hasOverrideAuth()||!!i&&(!!this.isAdminOrRepoManager()||!this.repositoryAuthorityService.isSystemRepository(e)&&(Zt.GRAPHQL_WRITE===t||Zt.GRAPHQL_READ===t?this.hasGraphqlPermissions(t,e):this.hasBasePermissions(t,e)))}hasBasePermissions(t,e){const r=this.repositoryAuthorityService.getLocationSpecificId(e),i=this.repositoryAuthorityService.getCurrentRepoAuthority(t,r),n=this.repositoryAuthorityService.getOverallRepoAuthority(t),s=this.getAuthenticatedUser();return!!(s?.authorities.hasAuthority(i)||s?.authorities.hasAuthority(n)||s?.authorities.hasWildcardAuthority(i))}hasGraphqlPermissions(t,e){if(!e||""===e.id)return!1;const r=t===Zt.GRAPHQL_WRITE?"WRITE":"READ",i=this.securityContextService.getAuthenticatedUser();if(!i)return!1;const n=this.repositoryAuthorityService.getLocationSpecificId(e),s=this.repositoryAuthorityService.getCurrentGqlRepoAuthority(r,n),o=this.repositoryAuthorityService.getOverallGqlRepoAuthority(r);return i.authorities.hasAuthority(s)||i.authorities.hasAuthority(o)||i.authorities.hasWildcardAuthority(s,!0)}initPermissionResolvers(){return[{priority:100,permission:Zt.MAINTAIN,matches:t=>this.isAdminOrRepoManager()||this.canMaintainRepo(t)},{priority:90,permission:Zt.GRAPHQL_WRITE,matches:t=>this.canWriteGqlRepo(t)},{priority:80,permission:Zt.GRAPHQL_READ,matches:t=>this.canReadGqlRepo(t)},{priority:70,permission:Zt.WRITE,matches:t=>this.canWriteRepo(t)},{priority:60,permission:Zt.READ,matches:t=>this.canReadRepo(t)}].sort((t,e)=>e.priority-t.priority)}}class Qn extends cn{constructor(){super("Authentication strategy not set")}}class Zn extends qe{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 ts{eventService=je(Cn);authStrategyResolver=je(zn);authorizationService=je(Jn);securityContextService=je(sn);authenticationStorageService=je(Tn);navigationContextService=je(Zn);isAuthenticationStrategySet(){return!!this.authStrategyResolver.getAuthStrategy()}getCurrentUser(){return this.getAuthenticationStrategy().fetchAuthenticatedUser()}async login(t){t?this.authStrategyResolver.setStrategy(new Bn):this.authStrategyResolver.setStrategy(new On);const e=this.getAuthenticationStrategy(),r=await e.login(t);this.securityContextService.updateIsLoggedIn(!0),this.securityContextService.updateAuthenticatedUser(r),this.eventService.emit(new ge)}logout(){const t=this.getAuthenticationStrategy();this.authenticationStorageService.setAuthenticated(!1);const e=E();return t.logout().then(()=>{v()||this.navigationContextService.updateReturnUrl(e),this.securityContextService.updateIsLoggedIn(!1),this.authorizationService.hasFreeAccess()?(this.authorizationService.initializeFreeAccess(),this.eventService.emit(new ge)):(m("login"),this.eventService.emit(new de))})}isLoggedIn(){const t=this.securityContextService.getIsLoggedIn()??!1,e=je(sn).getAuthenticatedUser();return this.isSecurityEnabled()&&t&&!!e}isAuthenticated(){return this.getAuthenticationStrategy().isAuthenticated()}isExternalUser(){return this.getAuthenticationStrategy().isExternal()}isSecurityEnabled(){return!!this.getSecurityConfig()?.isEnabled()}getSecurityConfig(){return je(sn).getSecurityConfig()}getAuthenticationStrategy(){const t=this.authStrategyResolver.getAuthStrategy();if(!t)throw new Qn;return t}}class es extends cn{constructor(t){super(t)}}class rs{static DEFAULT_PATH="/";static MILLISECONDS_PER_DAY=864e5;path=rs.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:n,httpOnly:s,sameSite:o}=t;return e&&this.setExpiration(e),this.setPath(r),i&&this.setDomain(i),n&&this.setSecure(),s&&this.setHttpOnly(),o&&this.setSameSite(o),this}setExpiration(t){if(!Number.isFinite(t))throw new es(`Invalid expiration value: ${t}`);const e=new Date(T.now()+t*rs.MILLISECONDS_PER_DAY);return this.expires=e.toUTCString(),this}setPath(t){return this.path=t||rs.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 is{read(){return l.getDocument().cookie}write(t){l.getDocument().cookie=t}}class ns{constructor(t){this.store=t??new is}get(t){return this.parseCookies()[t]}set(t,e,r={}){this.store.write(new rs(t,e,r).build())}remove(t){this.store.write(new rs(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 ss extends Ai{NAMESPACE="tracking";COOKIE_CONSENT="cookieConsent";LEGACY_COOKIE_CONSENT="cookie-consent";logger=Ye.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 er(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 os="_wb";class as{cookieService=je(ns);timeProvider=T;get(){return this.cookieService.get(os)}set(t){const e=`WB1.${t}.${this.timeProvider.now()}`;this.cookieService.set(os,e,{expiration:400,sameSite:"Lax"})}setIfAbsent(t){this.get()||this.set(t)}remove(){this.cookieService.remove(os)}}class cs{cookieService=je(ns);isSettingUp=!1;setIfAbsent(){if(!this.isSettingUp&&!this.gtmScriptExists()&&(this.isSettingUp=!0,!this.gtmScriptExists())){l.getWindow().dataLayer&&(l.getWindow().dataLayer=[]);const t=l.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');",l.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(){l.getWindow().dataLayer&&(l.getWindow().dataLayer=[]);const t=l.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();l.getWindow().google_tag_manager&&delete l.getWindow().google_tag_manager,l.getWindow().google_tag_data&&delete l.getWindow().google_tag_data}gtmScriptExists(){const t=l.getDocument().getElementsByTagName("script");return Array.from(t).some(t=>t.src?.includes("googletagmanager"))}}const us="cookie-consent-changed-event";class hs{securityService=je($n);securityContextService=je(sn);authenticationService=je(ts);authorizationService=je(Jn);trackingStorageService=je(ss);licenseService=je(tn);licenseContextService=je(Zi);installationCookieService=je(as);googleAnalyticsCookieService=je(cs);eventEmitter=new Ci;isTrackingAllowed(){return this.licenseService.isTrackableLicense()&&!l.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:us,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?er.fromJSON(t.appSettings.COOKIE_CONSENT):er.NOT_ACCEPTED_WITH_TRACKING():this.authorizationService.hasFreeAccess()?this.trackingStorageService.getCookieConsent()||er.NOT_ACCEPTED_WITH_TRACKING():er.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 er(t.appSettings.COOKIE_CONSENT):new er({thirdParty:!0,statistic:!0}),e.policyAccepted=!0,e.updatedAt=Date.now(),t.appSettings.COOKIE_CONSENT=e}}class ls extends Fi{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 ps={[cr.CLUSTER_HEALTH]:0,[cr.BACKUP_AND_RESTORE]:1,[cr.IMPORT]:2,[cr.QUERIES]:3,[cr.UPDATES]:4},ds=t=>{if(!t?.status||!t.allRunningOperations)return new or({status:rr.INFORMATION,allRunningOperations:new ar([])});const e=t.allRunningOperations.map(t=>new dr({value:t.value||"",status:I(rr,t.status),type:I(cr,t.type)})),r=new ar(e);return r.sort((t,e)=>ps[t.type]-ps[e.type]),new or({status:I(rr,t.status),allRunningOperations:r})};class gs{monitoringRestService=je(ls);async getOperations(t){const e=await this.monitoringRestService.getOperations(t);return ds(e)}deleteQuery(t,e){return this.monitoringRestService.deleteQuery(t,e)}}class fs extends cn{constructor(){super("Class is not initializable")}}const ms={[ti.ERROR]:yr.ERROR,[ti.SUCCESS]:yr.SUCCESS,[ti.WARNING]:yr.WARNING,[ti.INFO]:yr.INFO};class ys{constructor(){throw new fs}static fromNotification(t){const e=this.notificationTypeToToastType(t.type);return new Er(e,t.code,{title:t.title,translationParams:this.toTranslationParams(t.parameters)})}static notificationTypeToToastType(t){return t?ms[t]:yr.INFO}static toTranslationParams(t){return t?Object.entries(t).map(([t,e])=>({key:t,value:String(e)})):[]}}class Ss{eventEmitter=new Ci;notificationService=je(vn);constructor(){this.subscribeToNotificationEvents()}error(t,e){this.createToastElement(t,yr.ERROR,e)}info(t,e){this.createToastElement(t,yr.INFO,e)}success(t,e){this.createToastElement(t,yr.SUCCESS,e)}warning(t,e){this.createToastElement(t,yr.WARNING,e)}createToastElement(t,e,r){this.eventEmitter.emit({NAME:xr,payload:new Er(e,t,r)})}subscribeToNotificationEvents(){this.notificationService.onNotificationAdded(t=>{if(t.parameters?.[ri.SHOULD_TOAST]){const e=ys.fromNotification(t);this.createToastElement(e.message,e.type,e.config)}})}}class vs extends Fi{autocompleteRestPrefix="rest/autocomplete";search(t,e){return this.get(`${this.autocompleteRestPrefix}/query`,{params:{q:t},signal:e})}enabled(){return this.get(`${this.autocompleteRestPrefix}/enabled`)}}class Es{autocompleteRestService=je(vs);async search(t,e){return(t=>{const e=t?.suggestions.map(t=>new Nr({id:Sr.hashCode(`${t.type}-${t.value}-${t.description}`),type:I(Dr,t.type),value:t.value,description:t.description}));return new Fr(new Pr(e||[]))})(await this.autocompleteRestService.search(t,e))}isAutocompleteEnabled(){return this.autocompleteRestService.enabled()}}class xs extends Ai{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 As extends qe{AUTOCOMPLETE_ENABLED="isAutocompleteEnabled";updateAutocompleteEnabled(t){this.updateContextProperty(this.AUTOCOMPLETE_ENABLED,t),Me.get(xs).setEnabled(t)}onAutocompleteEnabledChanged(t){return this.subscribe(this.AUTOCOMPLETE_ENABLED,t)}}const bs=t=>{const e=(t?.results.bindings||[]).reduce((t,e)=>(t[e.prefix.value]=e.namespace.value,t),{});return new re(e)};class ws extends Fi{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`)}downloadResultsAsFile(t,e,r,i){const n=Object.entries(e).filter(([,t])=>void 0!==t).map(([t,e])=>`${t}=${encodeURIComponent(e)}`).join("&");return this.post(`${this.REPOSITORIES_ENDPOINT}/${t}`,{responseType:"blob",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=utf-8",Accept:r,Link:i},body:n})}getRepositorySize(t){return this.get(`${this.REPOSITORIES_ENDPOINT}/${t}/size`)}executeSparqlQuery(t,e){return this.post(`${this.REPOSITORIES_ENDPOINT}/${t}`,{body:new URLSearchParams({query:e}),headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/sparql-results+json","X-GraphDB-Local-Consistency":"updating"}})}}class Is extends cn{constructor(t){super(`Unexpected repository size value: "${t}"`)}}class Ts{rdf4jRestService=je(ws);getStatementsEndpoint(t){return this.rdf4jRestService.getStatementsEndpoint(t)}getSparqlEndpoint(t){return this.rdf4jRestService.getSparqlEndpoint(t)}async getRepositorySize(t){const e=await this.rdf4jRestService.getRepositorySize(t),r=Number(e);if(!Number.isFinite(r))throw new Is(e);return r}async downloadResultsAsFile(t,e,r,i){const n=await this.rdf4jRestService.downloadResultsAsFile(t,e,r,i);return await this.extractFileFromResponse(n)}executeSparqlQuery(t,e){return this.rdf4jRestService.executeSparqlQuery(t,e)}async extractFileFromResponse(t,e="download"){const r=t.headers["content-disposition"];return r?.includes("filename=")&&(e=r.split("filename=")[1].replace(/['"]/g,"")),{data:t.data,filename:e}}}class Rs{rdf4jRestService=je(ws);async getNamespaces(t){const e=await this.rdf4jRestService.getNamespaces(t);return bs(e)}}class Cs extends qe{NAMESPACES="namespaces";updateNamespaces(t){this.updateContextProperty(this.NAMESPACES,t)}onNamespacesChanged(t){return this.subscribe(this.NAMESPACES,t)}}class Ps extends Ai{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 Fs extends qe{APPLICATION_DATA_STATE="applicationDataLoaded";APPLICATIONS_STATE="applicationsState";APPLICATIONS_STATE_BEFORE_CHANGE="applicationsStateBeforeChange";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)}updateApplicationsState(t){this.updateContextProperty(this.APPLICATIONS_STATE,t)}onApplicationsStateChanged(t){return this.subscribe(this.APPLICATIONS_STATE,t)}getApplicationsState(){return this.getContextPropertyValue(this.APPLICATIONS_STATE)}updateApplicationsStateBeforeChange(t){this.updateContextProperty(this.APPLICATIONS_STATE_BEFORE_CHANGE,t)}onApplicationsStateBeforeChange(t){return this.subscribe(this.APPLICATIONS_STATE_BEFORE_CHANGE,t)}}class Ns extends Fi{configurationContextService=je($e);logger=Ye.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:`${x()}${t.entry}`;return await import(e)}catch(e){this.logger.warn(`Failed to load plugin ${t.name}:`,e)}}))}}class Ds{logger=Ye.logger;constructor(){this.pluginsRestService=Me.get(Ns)}async getPluginsManifest(){return(t=>{const e=t.plugins.map(t=>new Hr(t.entry,t.name));return new Ur(new Vr(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(l.getPluginRegistry()):this.logger.warn("Plugin module is missing the register method. Skipping registration.",t)})}}class Os extends jr{}class _s extends cn{constructor(t){super(`Extension point "${t.name}" is already registered.`)}}class Ls extends cn{constructor(t){super(`Extension point "${t}" does not exist.`)}}class Bs extends cn{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 ks{extensionPoints={};constructor(t={}){this.extensionPoints=t}registerExtensionPoint(t){if(this.extensionPoints[t.name])throw new _s(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 Ls(t);return e}registerPlugin(t,e){e.disabled||(t.removePluginByFieldIdName(e),t instanceof Os?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 Bs(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 Hs=JSON.parse('{"configUrl":"assets/configuration.default.json"}');class Us extends cn{}class Ms extends Fi{async getConfiguration(){let t,e=Hs;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 Us(`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 js{configurationRestService=je(Ms);configurationContextService=je($e);async getConfiguration(){const t=await this.configurationRestService.getConfiguration();return t&&this.configurationContextService.updateApplicationConfiguration(t),t}}const Vs=t=>{if(!t)return{items:[]};const e=je(ji).getSelectedRepository();let r="";return e&&(r=`${Qt}=${e.id}&`),{items:t.map(t=>({id:t,href:`sparql-template/create?${r}templateID=${encodeURIComponent(t)}`}))}};class Ks extends Fi{static SPARQL_ENDPOINT="rest/sparql";static SAVED_QUERIES_ENDPOINT=`${Ks.SPARQL_ENDPOINT}/saved-queries`;getSavedQuery(t,e){const r={name:t};return e&&(r.owner=e),this.get(Ks.SAVED_QUERIES_ENDPOINT,{params:r})}async getSavedQueries(){return this.get(Ks.SAVED_QUERIES_ENDPOINT)}saveQuery(t){return this.post(Ks.SAVED_QUERIES_ENDPOINT,{body:t})}updateQuery(t,e){return this.put(Ks.SAVED_QUERIES_ENDPOINT,{params:{oldQueryName:t},body:e})}deleteQuery(t){return this.delete(Ks.SAVED_QUERIES_ENDPOINT,{params:{name:t}})}addKnownPrefixes(t){return this.post(`${Ks.SPARQL_ENDPOINT}/add-known-prefixes`,{body:t})}}const Gs=t=>{if(!t||!Array.isArray(t))return new ui;const e=je(sn),r=e.getAuthenticatedUser()?.username,i=t.map(t=>{const e=r!==t.owner;return new hi({queryName:t.name,query:t.body,owner:t.owner,isPublic:t.shared,readonly:e})});return new ui(i)};class qs{sparqlRestService=je(Ks);async getSavedQuery(t,e){const r=await this.sparqlRestService.getSavedQuery(t,e);return Gs(r)}async getSavedQueries(){const t=await this.sparqlRestService.getSavedQueries();return Gs(t)}saveQuery(t){return this.sparqlRestService.saveQuery(t)}updateQuery(t,e){return this.sparqlRestService.updateQuery(t,e)}deleteQuery(t){return this.sparqlRestService.deleteQuery(t)}addKnownPrefixes(t){return this.sparqlRestService.addKnownPrefixes(t)}}class $s extends Ai{NAMESPACE="sparqlEditor";logger=Ye.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 Ws{postMessage(t,e="*"){l.getParentWindow().postMessage(t,e)}}class zs{static CURRENT_VERSION=1;preferences={};constructor(t){this.version=t?.version??zs.CURRENT_VERSION,this.preferences=t?.preferences??{}}getUserPreferences(t){return this.preferences[t]}setUserPreferences(t,e){this.preferences[t]=e}toString(){return JSON.stringify(this)}}class Ys extends Ai{NAMESPACE="userPreferences";USER_PREFERENCES="preferences";set(t,e){this.storeValue(t,e)}setUsersPreferences(t){this.set(this.USER_PREFERENCES,t.toString())}getPreferences(){const t=this.get(this.USER_PREFERENCES).getValue();if(!t)return new zs;try{return new zs(JSON.parse(t))}catch{return new zs}}}class Xs extends qe{USER_PREFERENCES="userPreferences";getUserPreferences(){return this.getContextPropertyValue(this.USER_PREFERENCES)}updateUserPreferences(t){this.updateContextProperty(this.USER_PREFERENCES,t)}onUserPreferencesChanged(t){return this.subscribe(this.USER_PREFERENCES,t)}}class Js{isSolrDeprecationBannerDismissed=!1;constructor(t={}){this.isSolrDeprecationBannerDismissed=t.isSolrDeprecationBannerDismissed??!1}}class Qs{static ANONYMOUS_USER="anonymous";userPreferencesStorageService=je(Ys);userPreferencesContextService=je(Xs);securityContextService=je(sn);authenticationService=je(ts);dismissSolrDeprecationBanner(){const t=this.getCurrentUserPreferences();t.isSolrDeprecationBannerDismissed=!0,this.userPreferencesContextService.updateUserPreferences(t),this.persistCurrentUserPreferences(t)}isSolrDeprecationBannerDismissed(){return this.userPreferencesContextService.getUserPreferences()?.isSolrDeprecationBannerDismissed??!1}loadUserPreferences(){const t=this.getCurrentUsername();if(!t)return;const e=this.loadCurrentUserPreferences(t)??new Js;this.userPreferencesContextService.updateUserPreferences(e)}getCurrentUsername(){return this.authenticationService.isLoggedIn()?this.securityContextService.getAuthenticatedUser()?.toUser().username:Qs.ANONYMOUS_USER}loadCurrentUserPreferences(t){return this.userPreferencesStorageService.getPreferences().getUserPreferences(t)}getCurrentUserPreferences(){return this.userPreferencesContextService.getUserPreferences()??new Js}persistCurrentUserPreferences(t){const e=this.getCurrentUsername();if(!e)return;const r=this.userPreferencesStorageService.getPreferences();r.setUserPreferences(e,t),this.userPreferencesStorageService.setUsersPreferences(r)}}var Zs=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===to}(t)}(t)},to="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function eo(t,e){return!1!==e.clone&&e.isMergeableObject(t)?so((r=t,Array.isArray(r)?[]:{}),t,e):t;var r}function ro(t,e,r){return t.concat(e).map(function(t){return eo(t,r)})}function io(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 no(t,e){try{return e in t}catch(t){return!1}}function so(t,e,r){(r=r||{}).arrayMerge=r.arrayMerge||ro,r.isMergeableObject=r.isMergeableObject||Zs,r.cloneUnlessOtherwiseSpecified=eo;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)&&io(t).forEach(function(e){i[e]=eo(t[e],r)}),io(e).forEach(function(n){(function(t,e){return no(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,n)||(no(t,n)&&r.isMergeableObject(e[n])?i[n]=function(t,e){if(!e.customMerge)return so;var r=e.customMerge(t);return"function"==typeof r?r:so}(n,r)(t[n],e[n],r):i[n]=eo(e[n],r))}),i}(t,e,r):eo(e,r)}so.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,r){return so(t,r,e)},{})};var oo=so;function ao(t){return t instanceof HTMLElement}function co(t){return"function"==typeof t}function uo(t){return"string"==typeof t}function ho(t){return void 0===t}class lo{on(t,e,r,i=!1){return ho(this.bindings)&&(this.bindings={}),ho(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 ho(this.bindings)||ho(this.bindings[t])||(ho(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!ho(this.bindings)&&this.bindings[t]&&this.bindings[t].forEach((r,i)=>{const{ctx:n,handler:s,once:o}=r,a=n||this;s.apply(a,e),o&&this.bindings[t].splice(i,1)}),this}}function po(t){const e=Object.getOwnPropertyNames(t.constructor.prototype);for(let r=0;r<e.length;r++){const i=e[r],n=t[i];"constructor"!==i&&"function"==typeof n&&(t[i]=n.bind(t))}return t}function go(t){return uo(t)&&""!==t?"-"!==t.charAt(t.length-1)?`${t}-`:t:""}function fo(t){return null==t||!t.element||!t.on}function mo(){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 yo(){return yo=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},yo.apply(this,arguments)}function So(t,e){if(null==t)return{};var r,i,n={},s=Object.keys(t);for(i=0;i<s.length;i++)r=s[i],e.indexOf(r)>=0||(n[r]=t[r]);return n}const vo=Math.min,Eo=Math.max,xo=Math.round,Ao=Math.floor,bo=t=>({x:t,y:t}),wo={left:"right",right:"left",bottom:"top",top:"bottom"},Io={start:"end",end:"start"};function To(t,e,r){return Eo(t,vo(e,r))}function Ro(t,e){return"function"==typeof t?t(e):t}function Co(t){return t.split("-")[0]}function Po(t){return t.split("-")[1]}function Fo(t){return"x"===t?"y":"x"}function No(t){return"y"===t?"height":"width"}function Do(t){return["top","bottom"].includes(Co(t))?"y":"x"}function Oo(t){return Fo(Do(t))}function _o(t){return t.replace(/start|end/g,t=>Io[t])}function Lo(t){return t.replace(/left|right|bottom|top/g,t=>wo[t])}function Bo(t){return"number"!=typeof t?function(t){return yo({top:0,right:0,bottom:0,left:0},t)}(t):{top:t,right:t,bottom:t,left:t}}function ko(t){return yo({},t,{top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height})}const Ho=["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"],Uo=["mainAxis","crossAxis","limiter"];function Mo(t,e,r){let{reference:i,floating:n}=t;const s=Do(e),o=Oo(e),a=No(o),c=Co(e),u="y"===s,h=i.x+i.width/2-n.width/2,l=i.y+i.height/2-n.height/2,p=i[a]/2-n[a]/2;let d;switch(c){case"top":d={x:h,y:i.y-n.height};break;case"bottom":d={x:h,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:l};break;case"left":d={x:i.x-n.width,y:l};break;default:d={x:i.x,y:i.y}}switch(Po(e)){case"start":d[o]-=p*(r&&u?-1:1);break;case"end":d[o]+=p*(r&&u?-1:1)}return d}async function jo(t,e){var r;void 0===e&&(e={});const{x:i,y:n,platform:s,rects:o,elements:a,strategy:c}=t,{boundary:u="clippingAncestors",rootBoundary:h="viewport",elementContext:l="floating",altBoundary:p=!1,padding:d=0}=Ro(e,t),g=Bo(d),f=a[p?"floating"===l?"reference":"floating":l],m=ko(await s.getClippingRect({element:null==(r=await(null==s.isElement?void 0:s.isElement(f)))||r?f:f.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:h,strategy:c})),y="floating"===l?yo({},o.floating,{x:i,y:n}):o.reference,S=await(null==s.getOffsetParent?void 0:s.getOffsetParent(a.floating)),v=await(null==s.isElement?void 0:s.isElement(S))&&await(null==s.getScale?void 0:s.getScale(S))||{x:1,y:1},E=ko(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({rect:y,offsetParent:S,strategy:c}):y);return{top:(m.top-E.top+g.top)/v.y,bottom:(E.bottom-m.bottom+g.bottom)/v.y,left:(m.left-E.left+g.left)/v.x,right:(E.right-m.right+g.right)/v.x}}const Vo=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:r,y:i,placement:n,rects:s,middlewareData:o}=e,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=Ro(t,e),h={x:r,y:i},l=Do(n),p=Fo(l);let d=h[p],g=h[l];const f=Ro(a,e),m="number"==typeof f?{mainAxis:f,crossAxis:0}:yo({mainAxis:0,crossAxis:0},f);if(c){const t="y"===p?"height":"width",e=s.reference[p]-s.floating[t]+m.mainAxis,r=s.reference[p]+s.reference[t]-m.mainAxis;d<e?d=e:d>r&&(d=r)}if(u){var y,S;const t="y"===p?"width":"height",e=["top","left"].includes(Co(n)),r=s.reference[l]-s.floating[t]+(e&&(null==(y=o.offset)?void 0:y[l])||0)+(e?0:m.crossAxis),i=s.reference[l]+s.reference[t]+(e?0:(null==(S=o.offset)?void 0:S[l])||0)-(e?m.crossAxis:0);g<r?g=r:g>i&&(g=i)}return{[p]:d,[l]:g}}}};function Ko(t){return $o(t)?(t.nodeName||"").toLowerCase():"#document"}function Go(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function qo(t){var e;return null==(e=($o(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function $o(t){return t instanceof Node||t instanceof Go(t).Node}function Wo(t){return t instanceof Element||t instanceof Go(t).Element}function zo(t){return t instanceof HTMLElement||t instanceof Go(t).HTMLElement}function Yo(t){return"undefined"!=typeof ShadowRoot&&(t instanceof ShadowRoot||t instanceof Go(t).ShadowRoot)}function Xo(t){const{overflow:e,overflowX:r,overflowY:i,display:n}=ea(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+r)&&!["inline","contents"].includes(n)}function Jo(t){return["table","td","th"].includes(Ko(t))}function Qo(t){const e=Zo(),r=ea(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 Zo(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function ta(t){return["html","body","#document"].includes(Ko(t))}function ea(t){return Go(t).getComputedStyle(t)}function ra(t){return Wo(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function ia(t){if("html"===Ko(t))return t;const e=t.assignedSlot||t.parentNode||Yo(t)&&t.host||qo(t);return Yo(e)?e.host:e}function na(t){const e=ia(t);return ta(e)?t.ownerDocument?t.ownerDocument.body:t.body:zo(e)&&Xo(e)?e:na(e)}function sa(t,e){var r;void 0===e&&(e=[]);const i=na(t),n=i===(null==(r=t.ownerDocument)?void 0:r.body),s=Go(i);return n?e.concat(s,s.visualViewport||[],Xo(i)?i:[]):e.concat(i,sa(i))}function oa(t){const e=ea(t);let r=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const n=zo(t),s=n?t.offsetWidth:r,o=n?t.offsetHeight:i,a=xo(r)!==s||xo(i)!==o;return a&&(r=s,i=o),{width:r,height:i,$:a}}function aa(t){return Wo(t)?t:t.contextElement}function ca(t){const e=aa(t);if(!zo(e))return bo(1);const r=e.getBoundingClientRect(),{width:i,height:n,$:s}=oa(e);let o=(s?xo(r.width):r.width)/i,a=(s?xo(r.height):r.height)/n;return o&&Number.isFinite(o)||(o=1),a&&Number.isFinite(a)||(a=1),{x:o,y:a}}const ua=bo(0);function ha(t){const e=Go(t);return Zo()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:ua}function la(t,e,r,i){void 0===e&&(e=!1),void 0===r&&(r=!1);const n=t.getBoundingClientRect(),s=aa(t);let o=bo(1);e&&(i?Wo(i)&&(o=ca(i)):o=ca(t));const a=function(t,e,r){return void 0===e&&(e=!1),!(!r||e&&r!==Go(t))&&e}(s,r,i)?ha(s):bo(0);let c=(n.left+a.x)/o.x,u=(n.top+a.y)/o.y,h=n.width/o.x,l=n.height/o.y;if(s){const t=Go(s),e=i&&Wo(i)?Go(i):i;let r=t.frameElement;for(;r&&i&&e!==t;){const t=ca(r),e=r.getBoundingClientRect(),i=ea(r),n=e.left+(r.clientLeft+parseFloat(i.paddingLeft))*t.x,s=e.top+(r.clientTop+parseFloat(i.paddingTop))*t.y;c*=t.x,u*=t.y,h*=t.x,l*=t.y,c+=n,u+=s,r=Go(r).frameElement}}return ko({width:h,height:l,x:c,y:u})}function pa(t){return la(qo(t)).left+ra(t).scrollLeft}function da(t,e,r){let i;if("viewport"===e)i=function(t,e){const r=Go(t),i=qo(t),n=r.visualViewport;let s=i.clientWidth,o=i.clientHeight,a=0,c=0;if(n){s=n.width,o=n.height;const t=Zo();(!t||t&&"fixed"===e)&&(a=n.offsetLeft,c=n.offsetTop)}return{width:s,height:o,x:a,y:c}}(t,r);else if("document"===e)i=function(t){const e=qo(t),r=ra(t),i=t.ownerDocument.body,n=Eo(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=Eo(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let o=-r.scrollLeft+pa(t);const a=-r.scrollTop;return"rtl"===ea(i).direction&&(o+=Eo(e.clientWidth,i.clientWidth)-n),{width:n,height:s,x:o,y:a}}(qo(t));else if(Wo(e))i=function(t,e){const r=la(t,!0,"fixed"===e),i=r.top+t.clientTop,n=r.left+t.clientLeft,s=zo(t)?ca(t):bo(1);return{width:t.clientWidth*s.x,height:t.clientHeight*s.y,x:n*s.x,y:i*s.y}}(e,r);else{const r=ha(t);i=yo({},e,{x:e.x-r.x,y:e.y-r.y})}return ko(i)}function ga(t,e){const r=ia(t);return!(r===e||!Wo(r)||ta(r))&&("fixed"===ea(r).position||ga(r,e))}function fa(t,e,r){const i=zo(e),n=qo(e),s="fixed"===r,o=la(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const c=bo(0);if(i||!i&&!s)if(("body"!==Ko(e)||Xo(n))&&(a=ra(e)),i){const t=la(e,!0,s,e);c.x=t.x+e.clientLeft,c.y=t.y+e.clientTop}else n&&(c.x=pa(n));return{x:o.left+a.scrollLeft-c.x,y:o.top+a.scrollTop-c.y,width:o.width,height:o.height}}function ma(t,e){return zo(t)&&"fixed"!==ea(t).position?e?e(t):t.offsetParent:null}function ya(t,e){const r=Go(t);if(!zo(t))return r;let i=ma(t,e);for(;i&&Jo(i)&&"static"===ea(i).position;)i=ma(i,e);return i&&("html"===Ko(i)||"body"===Ko(i)&&"static"===ea(i).position&&!Qo(i))?r:i||function(t){let e=ia(t);for(;zo(e)&&!ta(e);){if(Qo(e))return e;e=ia(e)}return null}(t)||r}const Sa={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:r,strategy:i}=t;const n=zo(r),s=qo(r);if(r===s)return e;let o={scrollLeft:0,scrollTop:0},a=bo(1);const c=bo(0);if((n||!n&&"fixed"!==i)&&(("body"!==Ko(r)||Xo(s))&&(o=ra(r)),zo(r))){const t=la(r);a=ca(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:qo,getClippingRect:function(t){let{element:e,boundary:r,rootBoundary:i,strategy:n}=t;const s=[..."clippingAncestors"===r?function(t,e){const r=e.get(t);if(r)return r;let i=sa(t).filter(t=>Wo(t)&&"body"!==Ko(t)),n=null;const s="fixed"===ea(t).position;let o=s?ia(t):t;for(;Wo(o)&&!ta(o);){const e=ea(o),r=Qo(o);r||"fixed"!==e.position||(n=null),(s?!r&&!n:!r&&"static"===e.position&&n&&["absolute","fixed"].includes(n.position)||Xo(o)&&!r&&ga(t,o))?i=i.filter(t=>t!==o):n=e,o=ia(o)}return e.set(t,i),i}(e,this._c):[].concat(r),i],o=s[0],a=s.reduce((t,r)=>{const i=da(e,r,n);return t.top=Eo(i.top,t.top),t.right=vo(i.right,t.right),t.bottom=vo(i.bottom,t.bottom),t.left=Eo(i.left,t.left),t},da(e,o,n));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:ya,getElementRects:async function(t){let{reference:e,floating:r,strategy:i}=t;const n=this.getOffsetParent||ya,s=this.getDimensions;return{reference:fa(e,await n(r),i),floating:yo({x:0,y:0},await s(r))}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){return oa(t)},getScale:ca,isElement:Wo,isRTL:function(t){return"rtl"===ea(t).direction}};function va(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 fo(t)||(r.middleware.push(function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var r;const{placement:i,middlewareData:n,rects:s,initialPlacement:o,platform:a,elements:c}=e,u=Ro(t,e),{mainAxis:h=!0,crossAxis:l=!0,fallbackPlacements:p,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:f=!0}=u,m=So(u,Ho),y=Co(i),S=Co(o)===o,v=await(null==a.isRTL?void 0:a.isRTL(c.floating)),E=p||(S||!f?[Lo(o)]:function(t){const e=Lo(t);return[_o(t),e,_o(e)]}(o));p||"none"===g||E.push(...function(t,e,r,i){const n=Po(t);let s=function(t,e,r){const i=["left","right"],n=["right","left"],s=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return r?e?n:i:e?i:n;case"left":case"right":return e?s:o;default:return[]}}(Co(t),"start"===r,i);return n&&(s=s.map(t=>t+"-"+n),e&&(s=s.concat(s.map(_o)))),s}(o,f,g,v));const x=[o,...E],A=await jo(e,m),b=[];let w=(null==(r=n.flip)?void 0:r.overflows)||[];if(h&&b.push(A[y]),l){const t=function(t,e,r){void 0===r&&(r=!1);const i=Po(t),n=Oo(t),s=No(n);let o="x"===n?i===(r?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Lo(o)),[o,Lo(o)]}(i,s,v);b.push(A[t[0]],A[t[1]])}if(w=[...w,{placement:i,overflows:b}],!b.every(t=>t<=0)){var T,I;const t=((null==(T=n.flip)?void 0:T.index)||0)+1,e=x[t];if(e)return{data:{index:t,overflows:w},reset:{placement:e}};let r=null==(I=w.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=w.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:n}=e,s=Ro(t,e),{mainAxis:o=!0,crossAxis:a=!1,limiter:c={fn:t=>{let{x:e,y:r}=t;return{x:e,y:r}}}}=s,u=So(s,Uo),h={x:r,y:i},l=await jo(e,u),p=Do(Co(n)),d=Fo(p);let g=h[d],f=h[p];if(o){const t="y"===d?"bottom":"right";g=To(g+l["y"===d?"top":"left"],g,g-l[t])}if(a){const t="y"===p?"bottom":"right";f=To(f+l["y"===p?"top":"left"],f,f-l[t])}const m=c.fn(yo({},e,{[d]:g,[p]:f}));return yo({},m,{data:{x:m.x-r,y:m.y-i}})}}}({limiter:Vo(),crossAxis:!0})),i&&r.middleware.push((t=>({name:"arrow",options:t,async fn(e){const{x:r,y:i,placement:n,rects:s,platform:o,elements:a}=e,{element:c,padding:u=0}=Ro(t,e)||{};if(null==c)return{};const h=Bo(u),l={x:r,y:i},p=Oo(n),d=No(p),g=await o.getDimensions(c),f="y"===p,m=f?"top":"left",y=f?"bottom":"right",S=f?"clientHeight":"clientWidth",v=s.reference[d]+s.reference[p]-l[p]-s.floating[d],E=l[p]-s.reference[p],x=await(null==o.getOffsetParent?void 0:o.getOffsetParent(c));let A=x?x[S]:0;A&&await(null==o.isElement?void 0:o.isElement(x))||(A=a.floating[S]||s.floating[d]);const b=v/2-E/2,w=A/2-g[d]/2-1,T=vo(h[m],w),I=vo(h[y],w),R=T,C=A-g[d]-I,P=A/2-g[d]/2+b,F=To(R,P,C),N=null!=Po(n)&&P!=F&&s.reference[d]/2-(P<R?T:I)-g[d]/2<0?P<R?R-P:C-P:0;return{[p]:l[p]-N,data:{[p]:F,centerOffset:P-F+N}}}}))({element:i})),r.placement=t.on),oo(e.options.floatingUIOptions||{},r)}(e,t),n=fo(e);return n&&(r=document.body,t.shepherdElementComponent.getElement().classList.add("shepherd-centered")),t.cleanup=function(t,e,r,i){void 0===i&&(i={});const{ancestorScroll:n=!0,ancestorResize:s=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:c=!1}=i,u=aa(t),h=n||s?[...u?sa(u):[],...sa(e)]:[];h.forEach(t=>{n&&t.addEventListener("scroll",r,{passive:!0}),s&&t.addEventListener("resize",r)});const l=u&&a?function(t,e){let r,i=null;const n=qo(t);function s(){clearTimeout(r),i&&i.disconnect(),i=null}return function o(a,c){void 0===a&&(a=!1),void 0===c&&(c=1),s();const{left:u,top:h,width:l,height:p}=t.getBoundingClientRect();if(a||e(),!l||!p)return;const d={rootMargin:-Ao(h)+"px "+-Ao(n.clientWidth-(u+l))+"px "+-Ao(n.clientHeight-(h+p))+"px "+-Ao(u)+"px",threshold:Eo(0,vo(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,yo({},d,{root:n.ownerDocument}))}catch(t){i=new IntersectionObserver(f,d)}i.observe(t)}(!0),s}(u,r):null;let p,d=-1,g=null;o&&(g=new ResizeObserver(t=>{let[i]=t;i&&i.target===u&&g&&(g.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{g&&g.observe(e)})),r()}),u&&!c&&g.observe(u),g.observe(e));let f=c?la(t):null;return c&&function e(){const i=la(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(),()=>{h.forEach(t=>{n&&t.removeEventListener("scroll",r),s&&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,n=yo({platform:Sa},r),s=yo({},n.platform,{_c:i});return(async(t,e,r)=>{const{placement:i="bottom",strategy:n="absolute",middleware:s=[],platform:o}=r,a=s.filter(Boolean),c=await(null==o.isRTL?void 0:o.isRTL(e));let u=await o.getElementRects({reference:t,floating:e,strategy:n}),{x:h,y:l}=Mo(u,i,c),p=i,d={},g=0;for(let r=0;r<a.length;r++){const{name:s,fn:f}=a[r],{x:m,y,data:S,reset:v}=await f({x:h,y:l,initialPlacement:i,placement:p,strategy:n,middlewareData:d,rects:u,platform:o,elements:{reference:t,floating:e}});h=null!=m?m:h,l=null!=y?y:l,d=yo({},d,{[s]:yo({},d[s],S)}),v&&g<=50&&(g++,"object"==typeof v&&(v.placement&&(p=v.placement),v.rects&&(u=!0===v.rects?await o.getElementRects({reference:t,floating:e,strategy:n}):v.rects),({x:h,y:l}=Mo(u,p,c))),r=-1)}return{x:h,y:l,placement:p,strategy:n,middlewareData:d}})(t,e,yo({},n,{platform:s}))})(t,e.el,r).then(function(t,e){return({x:r,y:i,placement:n,middlewareData:s})=>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=n,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,s),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,n):t.cleanup()}),t.target=e.element,i}function Ea(){}function xa(t,e){for(const r in e)t[r]=e[r];return t}function Aa(t){return t()}function ba(){return Object.create(null)}function wa(t){t.forEach(Aa)}function Ia(t){return"function"==typeof t}function Ta(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function Ra(t,e){t.appendChild(e)}function Ca(t,e,r){t.insertBefore(e,r||null)}function Pa(t){t.parentNode&&t.parentNode.removeChild(t)}function Fa(t){return document.createElement(t)}function Na(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Da(t){return document.createTextNode(t)}function Oa(){return Da(" ")}function _a(t,e,r,i){return t.addEventListener(e,r,i),()=>t.removeEventListener(e,r,i)}function La(t,e,r){null==r?t.removeAttribute(e):t.getAttribute(e)!==r&&t.setAttribute(e,r)}const Ba=["width","height"];function ka(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===Ba.indexOf(i)?t[i]=e[i]:La(t,i,e[i])}function Ha(t,e,r){t.classList[r?"add":"remove"](e)}let Ua;function Ma(t){Ua=t}function ja(){if(!Ua)throw new Error("Function called outside component initialization");return Ua}function Va(t){ja().$$.after_update.push(t)}const Ka=[],Ga=[];let qa=[];const $a=[],Wa=Promise.resolve();let za=!1;function Ya(t){qa.push(t)}const Xa=new Set;let Ja=0;function Qa(){if(0!==Ja)return;const t=Ua;do{try{for(;Ja<Ka.length;){const t=Ka[Ja];Ja++,Ma(t),Za(t.$$)}}catch(t){throw Ka.length=0,Ja=0,t}for(Ma(null),Ka.length=0,Ja=0;Ga.length;)Ga.pop()();for(let t=0;t<qa.length;t+=1){const e=qa[t];Xa.has(e)||(Xa.add(e),e())}qa.length=0}while(Ka.length);for(;$a.length;)$a.pop()();za=!1,Xa.clear(),Ma(t)}function Za(t){if(null!==t.fragment){t.update(),wa(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(Ya)}}const tc=new Set;let ec;function rc(){ec={r:0,c:[],p:ec}}function ic(){ec.r||wa(ec.c),ec=ec.p}function nc(t,e){t&&t.i&&(tc.delete(t),t.i(e))}function sc(t,e,r,i){if(t&&t.o){if(tc.has(t))return;tc.add(t),ec.c.push(()=>{tc.delete(t),i&&(r&&t.d(1),i())}),t.o(e)}else i&&i()}function oc(t){t&&t.c()}function ac(t,e,r,i){const{fragment:n,after_update:s}=t.$$;n&&n.m(e,r),i||Ya(()=>{const e=t.$$.on_mount.map(Aa).filter(Ia);t.$$.on_destroy?t.$$.on_destroy.push(...e):wa(e),t.$$.on_mount=[]}),s.forEach(Ya)}function cc(t,e){const r=t.$$;null!==r.fragment&&(function(t){const e=[],r=[];qa.forEach(i=>-1===t.indexOf(i)?e.push(i):r.push(i)),r.forEach(t=>t()),qa=e}(r.after_update),wa(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function uc(t,e,r,i,n,s,o,a=[-1]){const c=Ua;Ma(t);const u=t.$$={fragment:null,ctx:[],props:s,update:Ea,not_equal:n,bound:ba(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:ba(),dirty:a,skip_bound:!1,root:e.target||c.$$.root};o&&o(u.root);let h=!1;if(u.ctx=r?r(t,e.props||{},(e,r,...i)=>{const s=i.length?i[0]:r;return u.ctx&&n(u.ctx[e],u.ctx[e]=s)&&(!u.skip_bound&&u.bound[e]&&u.bound[e](s),h&&function(t,e){-1===t.$$.dirty[0]&&(Ka.push(t),za||(za=!0,Wa.then(Qa)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}(t,e)),r}):[],u.update(),h=!0,wa(u.before_update),u.fragment=!!i&&i(u.ctx),e.target){if(e.hydrate){const t=(l=e.target,Array.from(l.childNodes));u.fragment&&u.fragment.l(t),t.forEach(Pa)}else u.fragment&&u.fragment.c();e.intro&&nc(t.$$.fragment),ac(t,e.target,e.anchor,e.customElement),Qa()}var l;Ma(c)}class hc{$destroy(){cc(this,1),this.$destroy=Ea}$on(t,e){if(!Ia(e))return Ea;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 lc(t){let e,r,i,n,s;return{c(){e=Fa("button"),La(e,"aria-label",r=t[3]?t[3]:null),La(e,"class",i=`${t[1]||""} shepherd-button ${t[4]?"shepherd-button-secondary":""}`),e.disabled=t[2],La(e,"tabindex","0")},m(r,i){Ca(r,e,i),e.innerHTML=t[5],n||(s=_a(e,"click",function(){Ia(t[0])&&t[0].apply(this,arguments)}),n=!0)},p(n,[s]){t=n,32&s&&(e.innerHTML=t[5]),8&s&&r!==(r=t[3]?t[3]:null)&&La(e,"aria-label",r),18&s&&i!==(i=`${t[1]||""} shepherd-button ${t[4]?"shepherd-button-secondary":""}`)&&La(e,"class",i),4&s&&(e.disabled=t[2])},i:Ea,o:Ea,d(t){t&&Pa(e),n=!1,s()}}}function pc(t,e,r){let i,n,s,o,a,c,{config:u,step:h}=e;function l(t){return co(t)?t.call(h):t}return t.$$set=t=>{"config"in t&&r(6,u=t.config),"step"in t&&r(7,h=t.step)},t.$$.update=()=>{192&t.$$.dirty&&(r(0,i=u.action?u.action.bind(h.tour):null),r(1,n=u.classes),r(2,s=!!u.disabled&&l(u.disabled)),r(3,o=u.label?l(u.label):null),r(4,a=u.secondary),r(5,c=u.text?l(u.text):null))},[i,n,s,o,a,c,u,h]}class dc extends hc{constructor(t){super(),uc(this,t,pc,lc,Ta,{config:6,step:7})}}function gc(t,e,r){const i=t.slice();return i[2]=e[r],i}function fc(t){let e,r,i=t[1],n=[];for(let e=0;e<i.length;e+=1)n[e]=mc(gc(t,i,e));const s=t=>sc(n[t],1,1,()=>{n[t]=null});return{c(){for(let t=0;t<n.length;t+=1)n[t].c();e=Da("")},m(t,i){for(let e=0;e<n.length;e+=1)n[e]&&n[e].m(t,i);Ca(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 s=gc(t,i,o);n[o]?(n[o].p(s,r),nc(n[o],1)):(n[o]=mc(s),n[o].c(),nc(n[o],1),n[o].m(e.parentNode,e))}for(rc(),o=i.length;o<n.length;o+=1)s(o);ic()}},i(t){if(!r){for(let t=0;t<i.length;t+=1)nc(n[t]);r=!0}},o(t){n=n.filter(Boolean);for(let t=0;t<n.length;t+=1)sc(n[t]);r=!1},d(t){!function(t,e){for(let r=0;r<t.length;r+=1)t[r]&&t[r].d(e)}(n,t),t&&Pa(e)}}}function mc(t){let e,r;return e=new dc({props:{config:t[2],step:t[0]}}),{c(){oc(e.$$.fragment)},m(t,i){ac(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||(nc(e.$$.fragment,t),r=!0)},o(t){sc(e.$$.fragment,t),r=!1},d(t){cc(e,t)}}}function yc(t){let e,r,i=t[1]&&fc(t);return{c(){e=Fa("footer"),i&&i.c(),La(e,"class","shepherd-footer")},m(t,n){Ca(t,e,n),i&&i.m(e,null),r=!0},p(t,[r]){t[1]?i?(i.p(t,r),2&r&&nc(i,1)):(i=fc(t),i.c(),nc(i,1),i.m(e,null)):i&&(rc(),sc(i,1,1,()=>{i=null}),ic())},i(t){r||(nc(i),r=!0)},o(t){sc(i),r=!1},d(t){t&&Pa(e),i&&i.d()}}}function Sc(t,e,r){let i,{step:n}=e;return t.$$set=t=>{"step"in t&&r(0,n=t.step)},t.$$.update=()=>{1&t.$$.dirty&&r(1,i=n.options.buttons)},[n,i]}class vc extends hc{constructor(t){super(),uc(this,t,Sc,yc,Ta,{step:0})}}function Ec(t){let e,r,i,n,s;return{c(){e=Fa("button"),r=Fa("span"),r.textContent="×",La(r,"aria-hidden","true"),La(e,"aria-label",i=t[0].label?t[0].label:"Close Tour"),La(e,"class","shepherd-cancel-icon"),La(e,"type","button")},m(i,o){Ca(i,e,o),Ra(e,r),n||(s=_a(e,"click",t[1]),n=!0)},p(t,[r]){1&r&&i!==(i=t[0].label?t[0].label:"Close Tour")&&La(e,"aria-label",i)},i:Ea,o:Ea,d(t){t&&Pa(e),n=!1,s()}}}function xc(t,e,r){let{cancelIcon:i,step:n}=e;return t.$$set=t=>{"cancelIcon"in t&&r(0,i=t.cancelIcon),"step"in t&&r(2,n=t.step)},[i,t=>{t.preventDefault(),n.cancel()},n]}class Ac extends hc{constructor(t){super(),uc(this,t,xc,Ec,Ta,{cancelIcon:0,step:2})}}function bc(t){let e;return{c(){e=Fa("h3"),La(e,"id",t[1]),La(e,"class","shepherd-title")},m(r,i){Ca(r,e,i),t[3](e)},p(t,[r]){2&r&&La(e,"id",t[1])},i:Ea,o:Ea,d(r){r&&Pa(e),t[3](null)}}}function wc(t,e,r){let{labelId:i,element:n,title:s}=e;return Va(()=>{co(s)&&r(2,s=s()),r(0,n.innerHTML=s,n)}),t.$$set=t=>{"labelId"in t&&r(1,i=t.labelId),"element"in t&&r(0,n=t.element),"title"in t&&r(2,s=t.title)},[n,i,s,function(t){Ga[t?"unshift":"push"](()=>{n=t,r(0,n)})}]}class Ic extends hc{constructor(t){super(),uc(this,t,wc,bc,Ta,{labelId:1,element:0,title:2})}}function Tc(t){let e,r;return e=new Ic({props:{labelId:t[0],title:t[2]}}),{c(){oc(e.$$.fragment)},m(t,i){ac(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||(nc(e.$$.fragment,t),r=!0)},o(t){sc(e.$$.fragment,t),r=!1},d(t){cc(e,t)}}}function Rc(t){let e,r;return e=new Ac({props:{cancelIcon:t[3],step:t[1]}}),{c(){oc(e.$$.fragment)},m(t,i){ac(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||(nc(e.$$.fragment,t),r=!0)},o(t){sc(e.$$.fragment,t),r=!1},d(t){cc(e,t)}}}function Cc(t){let e,r,i,n=t[2]&&Tc(t),s=t[3]&&t[3].enabled&&Rc(t);return{c(){e=Fa("header"),n&&n.c(),r=Oa(),s&&s.c(),La(e,"class","shepherd-header")},m(t,o){Ca(t,e,o),n&&n.m(e,null),Ra(e,r),s&&s.m(e,null),i=!0},p(t,[i]){t[2]?n?(n.p(t,i),4&i&&nc(n,1)):(n=Tc(t),n.c(),nc(n,1),n.m(e,r)):n&&(rc(),sc(n,1,1,()=>{n=null}),ic()),t[3]&&t[3].enabled?s?(s.p(t,i),8&i&&nc(s,1)):(s=Rc(t),s.c(),nc(s,1),s.m(e,null)):s&&(rc(),sc(s,1,1,()=>{s=null}),ic())},i(t){i||(nc(n),nc(s),i=!0)},o(t){sc(n),sc(s),i=!1},d(t){t&&Pa(e),n&&n.d(),s&&s.d()}}}function Pc(t,e,r){let i,n,{labelId:s,step:o}=e;return t.$$set=t=>{"labelId"in t&&r(0,s=t.labelId),"step"in t&&r(1,o=t.step)},t.$$.update=()=>{2&t.$$.dirty&&(r(2,i=o.options.title),r(3,n=o.options.cancelIcon))},[s,o,i,n]}class Fc extends hc{constructor(t){super(),uc(this,t,Pc,Cc,Ta,{labelId:0,step:1})}}function Nc(t){let e;return{c(){e=Fa("div"),La(e,"class","shepherd-text"),La(e,"id",t[1])},m(r,i){Ca(r,e,i),t[3](e)},p(t,[r]){2&r&&La(e,"id",t[1])},i:Ea,o:Ea,d(r){r&&Pa(e),t[3](null)}}}function Dc(t,e,r){let{descriptionId:i,element:n,step:s}=e;return Va(()=>{let{text:t}=s.options;co(t)&&(t=t.call(s)),ao(t)?n.appendChild(t):r(0,n.innerHTML=t,n)}),t.$$set=t=>{"descriptionId"in t&&r(1,i=t.descriptionId),"element"in t&&r(0,n=t.element),"step"in t&&r(2,s=t.step)},[n,i,s,function(t){Ga[t?"unshift":"push"](()=>{n=t,r(0,n)})}]}class Oc extends hc{constructor(t){super(),uc(this,t,Dc,Nc,Ta,{descriptionId:1,element:0,step:2})}}function _c(t){let e,r;return e=new Fc({props:{labelId:t[1],step:t[2]}}),{c(){oc(e.$$.fragment)},m(t,i){ac(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||(nc(e.$$.fragment,t),r=!0)},o(t){sc(e.$$.fragment,t),r=!1},d(t){cc(e,t)}}}function Lc(t){let e,r;return e=new Oc({props:{descriptionId:t[0],step:t[2]}}),{c(){oc(e.$$.fragment)},m(t,i){ac(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||(nc(e.$$.fragment,t),r=!0)},o(t){sc(e.$$.fragment,t),r=!1},d(t){cc(e,t)}}}function Bc(t){let e,r;return e=new vc({props:{step:t[2]}}),{c(){oc(e.$$.fragment)},m(t,i){ac(e,t,i),r=!0},p(t,r){const i={};4&r&&(i.step=t[2]),e.$set(i)},i(t){r||(nc(e.$$.fragment,t),r=!0)},o(t){sc(e.$$.fragment,t),r=!1},d(t){cc(e,t)}}}function kc(t){let e,r,i,n,s=!ho(t[2].options.title)||t[2].options.cancelIcon&&t[2].options.cancelIcon.enabled,o=!ho(t[2].options.text),a=Array.isArray(t[2].options.buttons)&&t[2].options.buttons.length,c=s&&_c(t),u=o&&Lc(t),h=a&&Bc(t);return{c(){e=Fa("div"),c&&c.c(),r=Oa(),u&&u.c(),i=Oa(),h&&h.c(),La(e,"class","shepherd-content")},m(t,s){Ca(t,e,s),c&&c.m(e,null),Ra(e,r),u&&u.m(e,null),Ra(e,i),h&&h.m(e,null),n=!0},p(t,[n]){4&n&&(s=!ho(t[2].options.title)||t[2].options.cancelIcon&&t[2].options.cancelIcon.enabled),s?c?(c.p(t,n),4&n&&nc(c,1)):(c=_c(t),c.c(),nc(c,1),c.m(e,r)):c&&(rc(),sc(c,1,1,()=>{c=null}),ic()),4&n&&(o=!ho(t[2].options.text)),o?u?(u.p(t,n),4&n&&nc(u,1)):(u=Lc(t),u.c(),nc(u,1),u.m(e,i)):u&&(rc(),sc(u,1,1,()=>{u=null}),ic()),4&n&&(a=Array.isArray(t[2].options.buttons)&&t[2].options.buttons.length),a?h?(h.p(t,n),4&n&&nc(h,1)):(h=Bc(t),h.c(),nc(h,1),h.m(e,null)):h&&(rc(),sc(h,1,1,()=>{h=null}),ic())},i(t){n||(nc(c),nc(u),nc(h),n=!0)},o(t){sc(c),sc(u),sc(h),n=!1},d(t){t&&Pa(e),c&&c.d(),u&&u.d(),h&&h.d()}}}function Hc(t,e,r){let{descriptionId:i,labelId:n,step:s}=e;return t.$$set=t=>{"descriptionId"in t&&r(0,i=t.descriptionId),"labelId"in t&&r(1,n=t.labelId),"step"in t&&r(2,s=t.step)},[i,n,s]}class Uc extends hc{constructor(t){super(),uc(this,t,Hc,kc,Ta,{descriptionId:0,labelId:1,step:2})}}function Mc(t){let e;return{c(){e=Fa("div"),La(e,"class","shepherd-arrow"),La(e,"data-popper-arrow","")},m(t,r){Ca(t,e,r)},d(t){t&&Pa(e)}}}function jc(t){let e,r,i,n,s,o,a,c,u=t[4].options.arrow&&t[4].options.attachTo&&t[4].options.attachTo.element&&t[4].options.attachTo.on&&Mc();i=new Uc({props:{descriptionId:t[2],labelId:t[3],step:t[4]}});let h=[{"aria-describedby":n=ho(t[4].options.text)?null:t[2]},{"aria-labelledby":s=t[4].options.title?t[3]:null},t[1],{role:"dialog"},{tabindex:"0"}],l={};for(let t=0;t<h.length;t+=1)l=xa(l,h[t]);return{c(){e=Fa("div"),u&&u.c(),r=Oa(),oc(i.$$.fragment),ka(e,l),Ha(e,"shepherd-has-cancel-icon",t[5]),Ha(e,"shepherd-has-title",t[6]),Ha(e,"shepherd-element",!0)},m(n,s){Ca(n,e,s),u&&u.m(e,null),Ra(e,r),ac(i,e,null),t[13](e),o=!0,a||(c=_a(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?u||(u=Mc(),u.c(),u.m(e,r)):u&&(u.d(1),u=null);const c={};4&a&&(c.descriptionId=t[2]),8&a&&(c.labelId=t[3]),16&a&&(c.step=t[4]),i.$set(c),ka(e,l=function(t,e){const r={},i={},n={$$scope:1};let s=t.length;for(;s--;){const o=t[s],a=e[s];if(a){for(const t in o)t in a||(i[t]=1);for(const t in a)n[t]||(r[t]=a[t],n[t]=1);t[s]=a}else for(const t in o)n[t]=1}for(const t in i)t in r||(r[t]=void 0);return r}(h,[(!o||20&a&&n!==(n=ho(t[4].options.text)?null:t[2]))&&{"aria-describedby":n},(!o||24&a&&s!==(s=t[4].options.title?t[3]:null))&&{"aria-labelledby":s},2&a&&t[1],{role:"dialog"},{tabindex:"0"}])),Ha(e,"shepherd-has-cancel-icon",t[5]),Ha(e,"shepherd-has-title",t[6]),Ha(e,"shepherd-element",!0)},i(t){o||(nc(i.$$.fragment,t),o=!0)},o(t){sc(i.$$.fragment,t),o=!1},d(r){r&&Pa(e),u&&u.d(),cc(i),t[13](null),a=!1,c()}}}function Vc(t){return t.split(" ").filter(t=>!!t.length)}function Kc(t,e,r){let i,n,s,{classPrefix:o,element:a,descriptionId:c,firstFocusableElement:u,focusableElements:h,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,h=a.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]')),r(8,u=h[0]),r(10,p=h[h.length-1])},ja().$$.on_mount.push(f),Va(()=>{s!==d.options.classes&&(function(t){if(uo(t)){const e=Vc(t);e.length&&a.classList.remove(...e)}}(s),s=d.options.classes,function(t){if(uo(t)){const e=Vc(t);e.length&&a.classList.add(...e)}}(s))}),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,u=t.firstFocusableElement),"focusableElements"in t&&r(9,h=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,n=d.options&&d.options.title))},[a,g,c,l,d,i,n,t=>{const{tour:e}=d;switch(t.keyCode){case 9:if(0===h.length){t.preventDefault();break}t.shiftKey?(document.activeElement===u||document.activeElement.classList.contains("shepherd-element"))&&(t.preventDefault(),p.focus()):document.activeElement===p&&(t.preventDefault(),u.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())}},u,h,p,o,()=>a,function(t){Ga[t?"unshift":"push"](()=>{a=t,r(0,a)})}]}class Gc extends hc{constructor(t){super(),uc(this,t,Kc,jc,Ta,{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 qc extends lo{constructor(t,e={}){return super(t,e),this.tour=t,this.classPrefix=this.tour.options?go(this.tour.options.classPrefix):"",this.styles=t.styles,this._resolvedAttachTo=null,po(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,ao(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(co(r.element)&&(r.element=r.element.call(t)),uo(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 co(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 Gc({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();co(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:"",n=[...r.split(" "),...i.split(" ")],s=new Set(n);return Array.from(s).join(" ").trim()}_setOptions(t={}){let e=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions;e=oo({},e||{}),this.options=Object.assign({arrow:!0},e,t,function(t,e){return{floatingUIOptions:oo(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-${mo()}`,r&&Object.keys(r).forEach(t=>{this.on(t,r[t],this)})}_setupElements(){ho(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;(!ho(t)&&r.currentTarget.matches(t)||i)&&e.tour.next()}}}(r,t);let n;try{n=document.querySelector(r)}catch(t){}if(!ho(r)&&!n)return console.error(`No element was found for the selector supplied to advanceOn: ${r}`);n?(n.addEventListener(e,i),t.on("destroy",()=>n.removeEventListener(e,i))):(document.body.addEventListener(e,i,!0),t.on("destroy",()=>document.body.removeEventListener(e,i,!0)))}}(this),va(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 $c(t){let e,r,i,n,s;return{c(){e=Na("svg"),r=Na("path"),La(r,"d",t[2]),La(e,"class",i=(t[1]?"shepherd-modal-is-visible":"")+" shepherd-modal-overlay-container")},m(i,o){Ca(i,e,o),Ra(e,r),t[11](e),n||(s=_a(e,"touchmove",t[3]),n=!0)},p(t,[n]){4&n&&La(r,"d",t[2]),2&n&&i!==(i=(t[1]?"shepherd-modal-is-visible":"")+" shepherd-modal-overlay-container")&&La(e,"class",i)},i:Ea,o:Ea,d(r){r&&Pa(e),t[11](null),n=!1,s()}}}function Wc(t){if(!t)return null;const e=t instanceof HTMLElement&&window.getComputedStyle(t).overflowY;return"hidden"!==e&&"visible"!==e&&t.scrollHeight>=t.clientHeight?t:Wc(t.parentElement)}function zc(t,e,r){let{element:i,openingProperties:n}=e;mo();let s,o,a=!1;function c(){r(4,n={width:0,height:0,x:0,y:0,r:0})}function u(){r(1,a=!1),d()}function h(t=0,e=0,i,s){if(s){const{y:o,height:a}=function(t,e){const r=t.getBoundingClientRect();let i=r.y||r.top,n=r.bottom||i+r.height;if(e){const t=e.getBoundingClientRect(),r=t.y||t.top,s=t.bottom||r+t.height;i=Math.max(i,r),n=Math.min(n,s)}return{y:i,height:Math.max(n-i,0)}}(s,i),{x:c,width:u,left:h}=s.getBoundingClientRect();r(4,n={width:u+2*t,height:a+2*t,x:(c||h)-t,y:o-t,r:e})}else c()}function l(){r(1,a=!0)}c();const p=t=>{t.preventDefault()};function d(){s&&(cancelAnimationFrame(s),s=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,n=t.openingProperties)},t.$$.update=()=>{16&t.$$.dirty&&r(2,o=function({width:t,height:e,x:r=0,y:i=0,r:n=0}){const{innerWidth:s,innerHeight:o}=window,{topLeft:a=0,topRight:c=0,bottomRight:u=0,bottomLeft:h=0}="number"==typeof n?{topLeft:n,topRight:n,bottomRight:n,bottomLeft:n}:n;return`M${s},${o}H0V0H${s}V${o}ZM${r+a},${i}a${a},${a},0,0,0-${a},${a}V${e+i-h}a${h},${h},0,0,0,${h},${h}H${t+r-u}a${u},${u},0,0,0,${u}-${u}V${i+c}a${c},${c},0,0,0-${c}-${c}Z`}(n))},[i,a,o,t=>{t.stopPropagation()},n,()=>i,c,u,h,function(t){d(),t.tour.options.useModalOverlay?(function(t){const{modalOverlayOpeningPadding:e,modalOverlayOpeningRadius:r}=t.options,i=Wc(t.target),n=()=>{s=void 0,h(e,r,i,t.target),s=requestAnimationFrame(n)};n(),window.addEventListener("touchmove",p,{passive:!1})}(t),l()):u()},l,function(t){Ga[t?"unshift":"push"](()=>{i=t,r(0,i)})}]}class Yc extends hc{constructor(t){super(),uc(this,t,zc,$c,Ta,{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 Xc=new lo,Jc="undefined"==typeof window;class Qc{constructor(){}}Jc?Object.assign(Xc,{Tour:Qc,Step:Qc}):Object.assign(Xc,{Tour:class extends lo{constructor(t={}){return super(t),po(this),this.options=Object.assign({},{exitOnEsc:!0,keyboardNavigation:!0},t),this.classPrefix=go(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,Xc.trigger(t,e)})})(t)}),this._setTourID(),this}addStep(t,e){let r=t;return r instanceof qc?r.tour=this:r=new qc(this,r),ho(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 Xc.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=uo(t)?this.getById(t):this.steps[t];r&&(this._updateStateBeforeShow(),co(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}),Xc.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()}ao(this.focusedElBeforeOpen)&&this.focusedElBeforeOpen.focus()}_setupActiveTour(){this.trigger("active",{tour:this}),Xc.activeTour=this}_setupModal(){this.modal=new Yc({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}--${mo()}`}},Step:qc});class Zc{logger=Ye.logger;languageContextService=je(Oi);productInfoContextService=je(en);RoutingUtil=this.getRoutingUtil();resolveDocumentationUrl=this._resolveDocumentationUrl.bind(this);translate=this._translate.bind(this);_translate(t,e,r={}){const i=this.languageContextService.getSelectedLanguage()??this.languageContextService.getDefaultLanguage();if("object"==typeof e){const t=e[i]??e[this.languageContextService.getDefaultLanguage()];return t?Vt.sanitize(this.applyParameters(t,r)):(this.logger.warn(`Missing translation for language [${i}] in message object`),"")}let n;if(t){const e=t[i];n=("object"==typeof e?e:void 0)??t}else n=this.languageContextService.getLanguageBundle()??this.languageContextService.getDefaultBundle();if(!n)return this.logger.warn("Translation bundle is not provided for translation key: "+JSON.stringify(e)),e?.toString()??"";let s=n[e];return!s&&t&&(s=(this.languageContextService.getLanguageBundle()??this.languageContextService.getDefaultBundle())?.[e]),s?Vt.sanitize(this.applyParameters(s,r)):(this.logger.warn(`Missing translation for [${e}] key`),e?.toString())}_resolveDocumentationUrl(t){const e=this.productInfoContextService.getProductInfo();return d.resolveDocumentationUrl(e?.shortVersion,t)}getRoutingUtil(){return{navigate:m,getCurrentRoute:b}}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,n)=>{let s=1e3*e;const o=setInterval(()=>{try{const e=document.querySelector(i);e?!r||this.isElementVisible(e)?(clearInterval(o),t(e)):(s-=100,s<0&&(clearInterval(o),this.logger.warn("Element is not visible: "+i),n(new Error("Element is not visible: "+i)))):(s-=100,s<0&&(clearInterval(o),this.logger.warn("Element is not found: "+i),n(new Error("Element is not found: "+i))))}catch(t){clearInterval(o),this.logger.error("Error when processing selector: "+i),this.logger.error(String(t)),n(t)}},100)})}getOrWaitFor(t,e=1,r=!0){const i=this.resolveSelector(t),n=document.querySelector(i);return!n||r&&!this.isElementVisible(n)?this.waitFor(t,e,r):Promise.resolve(n)}scrollToOffset(t){const e=("string"==typeof t?Zc.SCROLL_OFFSET_MAP[t]:void 0)??t;l.getWindow().scrollTo({top:e,behavior:"smooth"})}isElementVisible(t){const e=l.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:l.getWindow().innerHeight/2}}class tu extends Ai{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 eu{eventEmitter=new Ci;confirmCancel(t){return new Promise(e=>{this.eventEmitter.emit({NAME:wr,payload:new Ir(t,t=>e(t))})})}}const ru="nearest";class iu{logger=Ye.logger;toastrService=je(Ss);guideApi=je(Zc);guideStorage=je(tu);guideAutostarted=null;waitForApplicationMount=!1;beforeShowResolver=void 0;constructor(){je(Fs).onApplicationsStateChanged(()=>{this.waitForApplicationMount=!1,this.resolveBeforeShowPromise()}),je(Fs).onApplicationsStateBeforeChange(()=>{this.waitForApplicationMount=!0})}resolveBeforeShowPromise(){this.beforeShowResolver&&(this.beforeShowResolver(),delete this.beforeShowResolver)}onPause=()=>{};endSubscribers=[];startGuide(t,e,r,i=!1,n=!0){if(i&&this.guideStorage.isAutostartDisabled(t))return;if(this.guideAutostarted=i,n&&this.guideStorage.clearHistory(),!e)return;const s=this.createGuide(t);this.addGuideSteps(s,e),this.doStartGuide(s,r)}resumeGuide(t,e,r){this.guideStorage.clearPaused(),this.startGuide(t,e,r,!1,!1)}isActive(){return!!Xc.activeTour&&!this.isPaused()}isPaused(){return this.guideStorage.isPaused()}getGuideId(){return this.guideStorage.getGuideId()}getCurrentStepId(){return this.guideStorage.getCurrentStepId()}isScrollingAllowed(){const t=Xc.activeTour?.getCurrentStep()?.options?.allowScroll;return!this.isActive()||!!t}subscribeOnGuideEnd(t){return this.endSubscribers.push(t),()=>{const e=this.endSubscribers.indexOf(t);-1!==e&&this.endSubscribers.splice(e,1)}}subscribeToGuidePause(t){"function"==typeof t&&(this.onPause=t)}getPreviousStepFromHistory(t){const e=this.guideStorage.getPreviousStepIdFromHistory(t);return Xc.activeTour?.steps.find(t=>t.id===e)}createGuide(t){return this.subscribeToGuideCanceled(),new Xc.Tour({tourName:t,useModalOverlay:!0,confirmCancel:()=>this.confirmGuideCancel(),defaultStepOptions:{classes:"shadow-md bg-purple-dark",scrollTo:{behavior:"smooth",block:ru,inline:ru}}})}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,n=i.url;n&&n!==E()&&m(n);const s=i.attachTo;if(s?.element){const e=i.maxWaitTime;this.guideApi.getOrWaitFor(s.element,e).then(()=>t.show(r)).catch(e=>{this.logger.error(String(e)),this.toastrService.error(this.guideApi.translate(void 0,"guide.start.unexpected.error.message")),t.complete()})}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.endSubscribers.forEach(t=>t())};this.guideCancelSubscription||(this.guideCancelSubscription=Xc.on("cancel",t)),this.guideCompleteSubscription||(this.guideCompleteSubscription=Xc.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 n=this.toBaseGuideStep(t,r,()=>this.updateLocalStorage()),s=[];return r.skipPoint&&s.push(this.getSkipButton(t,r.skipButtonLabel)),!this.isDisablePreviousFlow(r)&&e&&s.push(this.getPreviousButton(t)),!this.isDisableNextFlow(r)&&i&&s.push(this.getNextButton(t,r,i)),n.buttons=s,n}toBaseGuideStep(t,e,r){let i;e.elementSelector&&(i={element:e.elementSelector,on:e.placement});const n=this.getTranslatedString(e.title??"");let s="";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)}),s="&nbsp;&mdash;&nbsp;"+t.outerHTML}const o="readonly"!==e.type,a=e.extraPadding||0,c={id:String(e.id),title:n+s,text:()=>{const t=this.toParagraph(this.getTranslatedString(e.content??""));let r="";if(e.extraContent){const t=this.getTranslatedString(e.extraContent,e);r=this.toParagraph(t,e.extraContentClass)}return 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){return async()=>{try{await new Promise(t=>{setTimeout(()=>{this.waitForApplicationMount&&!this.beforeShowResolver?this.beforeShowResolver=t:this.waitForApplicationMount||t()})})}catch(e){throw t.complete(),e}if("function"==typeof e.beforeShowPromise)try{return await e.beforeShowPromise(t,e)}catch(e){throw t.complete(),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=Xc.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.getTranslatedString(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"),n=this.getNextButtonAction(t,e,r),s=this.getButton(i,n);return s.classes+=" shepherd-next-button",s}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 n=i.options.initPreviousStep;("function"==typeof n?n({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 n=r.options;if(n.forceReload||n.url&&n.url!==i.options.url){const t=n.url;t&&E()!==t&&m(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)&&m(r.url),t.next()})}}backToGuides(t){m("guides"),this.completeGuide(t)}async confirmGuideCancel(){const t=Xc.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 je(eu).confirmCancel(this.guideAutostarted??!1);if(i===br.CANCEL)return r&&t.show(r.id),!1;if(i===br.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=Xc.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(),n=t.steps.findIndex(t=>t.id===i);r>n?this.guideStorage.addStepToHistory(e.options.id):n>r&&this.guideStorage.removeLastStepFromHistory();const s=t.options.tourName||"";this.guideStorage.saveStep(s,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=Xc.activeTour?.steps;if(!r)return;const i=e.querySelector(".shepherd-content");if(!i)return;const n=document.createElement("div");n.className="shepherd-progress";const s=document.createElement("span");s.className="text-muted",s.innerText=this.guideApi.translate(void 0,"guide.total.progress",{n:String(r.indexOf(t)+1),nn:String(r.length)}),s.setAttribute("gdb-tooltip",this.guideApi.translate(void 0,"guide.total.progress.tooltip")),s.setAttribute("tooltip-placement","left"),n.appendChild(s),i.appendChild(n)}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 n=document.createElement("span");n.className="shepherd-step-type icon-"+r+" icon-1-25x",n.setAttribute("gdb-tooltip",this.guideApi.translate(void 0,"guide.step-type."+i)),n.setAttribute("tooltip-placement","bottom-right");const s=t.querySelector(".shepherd-header");s&&s.insertBefore(n,s.firstChild)}isDisablePreviousFlow(t){return t.disablePreviousFlow??!1}isDisableNextFlow(t){return t.disableNextFlow??!1}getTranslatedString(t,e){return"object"==typeof t?this.guideApi.translate(void 0,t,e):t??""}}class nu extends qe{PAUSED="isPaused";HAS_RUNNING_GUIDE="hasRunningGuide";updatePaused(t){this.updateContextProperty(this.PAUSED,t)}isPaused(){return this.getContextPropertyValue(this.PAUSED)}hasRunningGuide(){return this.getContextPropertyValue(this.HAS_RUNNING_GUIDE)??!1}updateHasRunningGuide(t){this.updateContextProperty(this.HAS_RUNNING_GUIDE,t)}onHasRunningGuideChanged(t){return this.subscribe(this.HAS_RUNNING_GUIDE,t)}}class su extends Fi{GUIDES_ENDPOINT="rest/guides";getGuides(){return this.get(this.GUIDES_ENDPOINT)}}class ou{shepherdService=je(iu);toastrService=je(Ss);repositoryContextService=je(ji);guideApi=je(Zc);guideContextService=je(nu);guidesRestService=je(su);startGuide(t,e,r,i=!1){const n=je(Oi).getLanguageBundle();if(!t)return void this.toastrService.error(this.guideApi.translate(n,"guides.error.guide-not-found"));const s=t.getRepositoryIdBase();if(s){const e=this.repositoryContextService.getRepositoryList();t.setRepositoryId(s);const r=1e3;for(let i=2;i<=r&&e.findRepository(t.getRepositoryId(),"",!0);i++)t.setRepositoryId(s+i)}t.setTranslatedGuideName(this.guideApi.translate(n,t.getName())),t.setTranslatedGuideDescription(this.guideApi.translate(n,t.getDescription()));const o=l.getPluginRegistry().get(Xr.NAME),a=t.toStepsDescriptions(o,e);a.forEach((t,e)=>{t.id=e,t.scrollOffset&&(t.scrollToHandler=()=>this.guideApi.scrollToOffset(t.scrollOffset))}),this.guideContextService.updateHasRunningGuide(!0);const c=this.shepherdService.subscribeOnGuideEnd(()=>{this.guideContextService.updateHasRunningGuide(!1),c()});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 Zr({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 au extends Fi{CONNECTORS_ENDPOINT="rest/connectors";checkConnector(t){return this.post(`${this.CONNECTORS_ENDPOINT}/check`,{body:t,headers:{"Content-Type":"text/plain"}})}}class cu extends Error{constructor(t){super(`Unknown connector command: ${t}`)}}class uu{connectorsRestService=je(au);rdf4jRepositoryService=je(Ts);async checkConnector(t){return(t=>{let e;if(t.command)if(t.hasSupport)if(fi.CREATE===t.command)e=(t=>{const e=[{name:t.name}];return new pi(di.SUCCESS,t.command,"created.connector",e)})(t);else if(fi.REPAIR===t.command)e=(t=>{const e=[{name:t.name}];return new pi(di.SUCCESS,t.command,"query.editor.repaired.connector",e)})(t);else{if(fi.DROP!==t.command)throw new cu(t.command);e=(t=>{const e=[{name:t.name}];return new pi(di.SUCCESS,t.command,"externalsync.delete.success.msg",e)})(t)}else e=(t=>{const e=[{connectorName:t.connectorName},{pluginName:t.pluginName}];return new pi(di.ERROR,t.command,"query.editor.inactive.plugin.warning.msg",e)})(t);else e=(t=>new pi(di.SUCCESS,t.command))(t);return e.iri=t.iri,e.name=t.name,e})(await this.connectorsRestService.checkConnector(t))}async getConnectorBuildStatus(t,e){const r=this.createConnectorStatusQuery(t);return(t=>{const e=t?.results?.bindings?.[0]?.status?.value;if(!e)return null;try{const t=JSON.parse(e);return new gi(t.status,t.processedEntities,t.estimatedEntities,t.indexedEntities,t.entitiesPerSecond,t.etaSeconds,t.repair)}catch{return null}})(await this.rdf4jRepositoryService.executeSparqlQuery(e,r))}createConnectorStatusQuery(t){const e=t.replace(/\/instance#.+$/,"#connectorStatus");return`SELECT ?status {\n\t<${t}> <${e}> ?status\n}`}}class hu extends Fi{static EXPLORE_GRAPH_ENDPOINT="rest/explore-graph";getGraphConfigs(){return this.get(`${hu.EXPLORE_GRAPH_ENDPOINT}/config`)}}const lu=t=>new mi({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??Si.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 pu{graphConfigRestService=je(hu);async getGraphConfigs(){return t=await this.graphConfigRestService.getGraphConfigs(),Array.isArray(t)?new yi(t.map(lu)):new yi;var t}}class du extends ii{authStorage=Me.get(Tn);repositoryStorageService=Me.get(Mi);securityContextService=Me.get(sn);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 gu extends ii{authenticationStorageService=je(Tn);authenticationService=je(ts);shouldProcess(t){return 401===t.status}process(t){return this.shouldRedirectToLogin(t.url)?(this.authenticationStorageService.clearAuthToken(),v()||(m("login"),l.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 fu extends ii{securityContextService=je(sn);authenticationService=je(ts);logger=Ye.logger;shouldProcess(t){return 403===t.status}process(t){const e=E();return this.logger.warn("Permission to page denied. Some errors in the console are normal"),this.updateRestrictionsForPage(e),this.shouldRedirectToLogin()&&m("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()}}class mu{CHANNEL_NAME="ontotext-workbench-broadcast";MESSAGE_EVENT="message";sendMessage(t){this.getChannel().postMessage(t)}subscribeToMessages(t){const e=this.getChannel(),r=e=>t(e.data);return e.addEventListener(this.MESSAGE_EVENT,r),()=>e.removeEventListener(this.MESSAGE_EVENT,r)}getChannel(){return this.channel??=new BroadcastChannel(this.CHANNEL_NAME),this.channel}}export{Ae as AppSettings,he as ApplicationBeforeChange,le as ApplicationChanged,Fs as ApplicationLifecycleContextService,Lr as ApplicationMountState,ce as ApplicationMounted,Br as ApplicationNames,n as ApplicationSettings,wi as ApplicationSettingsStorageService,ue as ApplicationUnmounted,kr as ApplicationsState,du as AuthRequestInterceptor,Ce as AuthSettings,Fe as AuthSourceType,zn as AuthStrategyResolver,Ie as AuthenticatedUser,ts as AuthenticationService,Tn as AuthenticationStorageService,fe as AuthenticationType,me as Authority,xe as AuthorityList,Jn as AuthorizationService,As as AutocompleteContextService,Fr as AutocompleteSearchResult,Es as AutocompleteService,xs as AutocompleteStorageService,Qe as AvailableLanguagesList,pe as BeforeMountRouting,pi as BeforeUpdateQueryResult,di as BeforeUpdateQueryResultStatus,xi as BroadcastMessage,mu as BroadcastService,is as BrowserCookieStore,p as BuildUtil,h as ByteUtils,wr as CONFIRM_CANCEL_EVENT,us as COOKIE_CONSENT_CHANGED_EVENT,xr as CREATE_TOAST_EVENT,br as CancelDialogAction,_e as CapabilityList,$e as ConfigurationContextService,Ms as ConfigurationRestService,js as ConfigurationService,Ir as ConfirmCancelPayload,gi as ConnectorBuildStatus,fi as ConnectorCommand,au as ConnectorsRestService,uu as ConnectorsService,qe as ContextService,Ge as ContextSubscriptionManager,rs as CookieBuilder,er as CookieConsent,ns as CookieService,T as DateUtil,eu as DialogService,cn as ErrorBase,ie as Event,Ci as EventEmitter,ne as EventName,Cn as EventService,jr as ExtensionPoint,g as FibonacciGenerator,cs as GoogleAnalyticsCookieService,mi as GraphConfig,yi as GraphConfigList,pu as GraphConfigService,Zc as GuideApi,nu as GuideContextService,Wr as GuidePlugin,tu as GuideStorageService,su as GuidesRestService,ou as GuidesService,Pi as HTTP_REQUEST_DONE_EVENT,Vt as HtmlUtil,ci as HttpErrorResponse,ii as HttpInterceptor,ni as HttpInterceptorList,si as HttpRequest,ai as HttpResponse,oi as HttpResponseBase,as as InstallationCookieService,Zr as InteractiveGuide,Xr as InteractiveGuideExtensionPoint,Ri as InterceptorService,tr as LanguageConfig,Oi as LanguageContextService,Ni as LanguageRestService,Bi as LanguageService,Di as LanguageStorageService,Oe as License,Zi as LicenseContextService,tn as LicenseService,_r as LifecycleState,Ai as LocalStorageService,bi as LocalStorageSubscriptionHandlerService,We as LoggerService,ze as Loggers,ge as Login,de as Logout,zr as MainMenuExtensionPoint,qr as MainMenuItem,Gr as MainMenuPlugin,Ei as MessageType,Kt as Model,Gt as ModelList,ls as MonitoringRestService,gs as MonitoringService,re as NamespaceMap,Cs as NamespacesContextService,Rs as NamespacesService,Zn as NavigationContextService,se as NavigationEnd,oe as NavigationEndPayload,ae as NavigationStart,ei as Notification,ri as NotificationParam,vn as NotificationService,ti as NotificationType,o as ObjectUtil,Ss as OntoToastrService,xn as OpenIdAuthFlowHandler,bn as OpenIdRestService,Pn as OpenIdService,In as OpenIdTokenRefreshManager,wn as OpenIdUrlBuilder,dn as OpenIdUtils,Te as OpenidSecurityConfig,on as OpenidStorageService,dr as Operation,ur as OperationGroup,nr as OperationGroupSummary,sr as OperationGroupSummaryList,ar as OperationList,rr as OperationStatus,or as OperationStatusSummary,cr as OperationType,Ws as ParentWindowMessageService,Kr as Plugin,Hr as PluginDefinition,Vr as PluginDefinitionList,ks as PluginRegistry,Ur as PluginsManifest,Ns as PluginsRestService,Ds as PluginsService,Le as ProductInfo,en as ProductInfoContextService,nn as ProductInfoService,Qt as REPOSITORY_ID_PARAM,Ts as Rdf4jRepositoryService,ws as Rdf4jRestService,$t as Repository,Vi as RepositoryAuthorityService,ji as RepositoryContextService,zt as RepositoryList,te as RepositoryLocation,$i as RepositoryLocationContextService,qi as RepositoryLocationService,ee as RepositoryLocationType,Zt as RepositoryPermissionType,ki as RepositoryRestService,Ui as RepositoryService,Yt as RepositorySizeInfo,Xt as RepositoryState,Mi as RepositoryStorageService,Jt as RepositoryType,Ps as ResourceSearchStorageService,De as RestrictedPages,Yr as RouteExtensionPoint,$r as RoutePlugin,Ii as RuntimeConfigurationContextService,ir as STATUS_ORDER,hi as SavedQuery,ui as SavedQueryList,li as ScrollLocation,Cr as SearchButton,Rr as SearchButtonConfig,Tr as SearchButtonList,Ne as SecurityConfig,sn as SecurityContextService,$n as SecurityService,Me as ServiceProvider,iu as ShepherdService,Ks as SparqlRestService,qs as SparqlService,$s as SparqlStorageService,Si as StartMode,Xe as StorageData,Je as StorageKey,qt as SubscriptionList,Nr as Suggestion,Pr as SuggestionList,Or as SuggestionSelectedPayload,Dr as SuggestionType,i as ThemeMode,Ti as ThemeService,Jr as ThemesExtensionPoint,Er as ToastMessage,Ar as ToastMessageList,yr as ToastType,mr as ToastrConfig,gr as ToastrPosition,hs as TrackingService,ss as TrackingStorageService,gu as UnauthenticatedInterceptor,fu as UnauthorizedInterceptor,d as UriUtil,vi as UrlPathParams,we as User,Xs as UserPreferencesContextService,Qs as UserPreferencesService,be as UserType,Kn as UsersService,l as WindowService,A as getBasePath,b as getCurrentRoute,w as getLocationPathWithQueryParams,x as getOrigin,E as getPathName,s as getRepositoryIdWithLocation,S as isHomePage,v as isLoginPage,Pe as mapAuthSettingsResponseToModel,Gn as mapAuthenticatedUserResponseToModel,ve as mapGrantedAuthoritiesResponseToModel,bs as mapNamespaceResponseToModel,ds as mapOperationSummaryResponseToModel,Hi as mapRepositoryListResponseToModel,Gs as mapSavedQueryListResponseToModel,Vs as mapSparqlTemplatesResponseToModel,jn as mapUserModelToRequest,Vn as mapUserResponseToModel,m as navigate,f as navigateTo,En as notify,y as openInNewTab,je as service,I as toEnum};