!function(e,r){"object"==typeofexports&&"object"==typeofmodule?module.exports=r():"function"==typeofdefine&&define.amd?define("cryptoPro",[],r):"object"==typeofexports?exports.cryptoPro=r():e.cryptoPro=r()}(window,(function(){returnfunction(e){varr={};functiont(n){if(r[n])returnr[n].exports;var_=r[n]={i:n,l:!1,exports:{}};returne[n].call(_.exports,_,_.exports,t),_.l=!0,_.exports}returnt.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeofSymbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)returne;if(4&r&&"object"==typeofe&&e&&e.__esModule)returne;varn=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeofe)for(var_ine)t.d(n,_,function(r){returne[r]}.bind(null,_));returnn},t.n=function(e){varr=e&&e.__esModule?function(){returne.default}:function(){returne};returnt.d(r,"a",r),r},t.o=function(e,r){returnObject.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=17)}([function(e,r,t){"use strict";varn=this&&this.__awaiter||function(e,r,t,n){returnnew(t||(t=Promise))((function(_,a){functions(e){try{i(n.next(e))}catch(e){a(e)}}functiono(e){try{i(n.throw(e))}catch(e){a(e)}}functioni(e){varr;e.done?_(e.value):(r=e.value,rinstanceoft?r:newt((function(e){e(r)}))).then(s,o)}i((n=n.apply(e,r||[])).next())}))},_=this&&this.__generator||function(e,r){vart,n,_,a,s={label:0,sent:function(){if(1&_[0])throw_[1];return_[1]},trys:[],ops:[]};returna={next:o(0),throw:o(1),return:o(2)},"function"==typeofSymbol&&(a[Symbol.iterator]=function(){returnthis}),a;functiono(a){returnfunction(o){returnfunction(a){if(t)thrownewTypeError("Generator is already executing.");for(;s;)try{if(t=1,n&&(_=2&a[0]?n.return:a[0]?n.throw||((_=n.return)&&_.call(n),0):n.next)&&!(_=_.call(n,a[1])).done)return_;switch(n=0,_&&(a=[2&a[0],_.value]),a[0]){case0:case1:_=a;break;case4:returns.label++,{value:a[1],done:!1};case5:s.label++,n=a[1],a=[0];continue;case7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(_=s.trys,(_=_.length>0&&_[_.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!_||a[1]>_[0]&&a[1]<_[3])){s.label=a[1];break}if(6===a[0]&&s.label<_[1]){s.label=_[1],_=a;break}if(_&&s.label<_[2]){s.label=_[2],s.ops.push(a);break}_[2]&&s.ops.pop(),s.trys.pop();continue}a=r.call(e,s)}catch(e){a=[6,e],n=0}finally{t=_=0}if(5&a[0])throwa[1];return{value:a[0]?a[1]:void0,done:!0}}([a,o])}}};Object.defineProperty(r,"__esModule",{value:!0}),r._afterPluginsLoaded=void0;vara=t(1),s=!1,o=!1;r._afterPluginsLoaded=function(e){varr=Boolean(window.Promise);returnfunction(){for(vari=[],c=0;c<arguments.length;c++)i[c]=arguments[c];returnn(this,void0,void0,(function(){varn,c;return_(this,(function(_){switch(_.label){case0:if(!o){try{t(20)}catch(e){throwconsole.error(e),newError(a._extractMeaningfulErrorMessage(e)||"Ошибка при подключении модуля для работы с Cades plugin")}o=!0}if(n=window.cadesplugin,!r)thrownewError("Необходим полифилл для Promise");if(!n)thrownewError("Не подключен модуль для работы с Cades plugin");s||(n.set_log_level(n.LOG_LEVEL_ERROR),s=!0),_.label=1;case1:return_.trys.push([1,3,,4]),[4,n];case2:return_.sent(),[3,4];case3:throwc=_.sent(),console.error(c),newError(a._extractMeaningfulErrorMessage(c)||"Ошибка при инициализации модуля для работы с Cades plugin");case4:return[4,e.apply(this,i)];case5:return[2,_.sent()]}}))}))}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r._extractMeaningfulErrorMessage=void0,r._extractMeaningfulErrorMessage=function(e){varr,t=(null===(r=window.cadesplugin)||void0===r?void0:r.getLastError)&&window.cadesplugin.getLastError(e);if(!(null==t?void0:t.message)){if(!e.message)returnnull;t=e}if(!/[а-яА-Я]/.test(t.message))returnnull;varn=t.mes
varn=t(44),_=t(45),a=t(46);functions(){returni.TYPED_ARRAY_SUPPORT?2147483647:1073741823}functiono(e,r){if(s()<r)thrownewRangeError("Invalid typed array length");returni.TYPED_ARRAY_SUPPORT?(e=newUint8Array(r)).__proto__=i.prototype:(null===e&&(e=newi(r)),e.length=r),e}functioni(e,r,t){if(!(i.TYPED_ARRAY_SUPPORT||thisinstanceofi))returnnewi(e,r,t);if("number"==typeofe){if("string"==typeofr)thrownewError("If encoding is specified then the first argument must be a string");returnl(this,e)}returnc(this,e,r,t)}functionc(e,r,t,n){if("number"==typeofr)thrownewTypeError('"value" argument must not be a number');return"undefined"!=typeofArrayBuffer&&rinstanceofArrayBuffer?function(e,r,t,n){if(r.byteLength,t<0||r.byteLength<t)thrownewRangeError("'offset' is out of bounds");if(r.byteLength<t+(n||0))thrownewRangeError("'length' is out of bounds");r=void0===t&&void0===n?newUint8Array(r):void0===n?newUint8Array(r,t):newUint8Array(r,t,n);i.TYPED_ARRAY_SUPPORT?(e=r).__proto__=i.prototype:e=d(e,r);returne}(e,r,t,n):"string"==typeofr?function(e,r,t){"string"==typeoft&&""!==t||(t="utf8");if(!i.isEncoding(t))thrownewTypeError('"encoding" must be a valid string encoding');varn=0|E(r,t),_=(e=o(e,n)).write(r,t);_!==n&&(e=e.slice(0,_));returne}(e,r,t):function(e,r){if(i.isBuffer(r)){vart=0|C(r.length);return0===(e=o(e,t)).length||r.copy(e,0,0,t),e}if(r){if("undefined"!=typeofArrayBuffer&&r.bufferinstanceofArrayBuffer||"length"inr)return"number"!=typeofr.length||(n=r.length)!=n?o(e,0):d(e,r);if("Buffer"===r.type&&a(r.data))returnd(e,r.data)}varn;thrownewTypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,r)}functionu(e){if("number"!=typeofe)thrownewTypeError('"size" argument must be a number');if(e<0)thrownewRangeError('"size" argument must not be negative')}functionl(e,r){if(u(r),e=o(e,r<0?0:0|C(r)),!i.TYPED_ARRAY_SUPPORT)for(vart=0;t<r;++t)e[t]=0;returne}functiond(e,r){vart=r.length<0?0:0|C(r.length);e=o(e,t);for(varn=0;n<t;n+=1)e[n]=255&r[n];returne}functionC(e){if(e>=s())thrownewRangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return0|e}functionE(e,r){if(i.isBuffer(e))returne.length;if("undefined"!=typeofArrayBuffer&&"function"==typeofArrayBuffer.isView&&(ArrayBuffer.isView(e)||einstanceofArrayBuffer))returne.byteLength;"string"!=typeofe&&(e=""+e);vart=e.length;if(0===t)return0;for(varn=!1;;)switch(r){case"ascii":case"latin1":case"binary":returnt;case"utf8":case"utf-8":casevoid0:returnG(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return2*t;case"hex":returnt>>>1;case"base64":returnY(e).length;default:if(n)returnG(e).length;r=(""+r).toLowerCase(),n=!0}}functionf(e,r,t){varn=!1;if((void0===r||r<0)&&(r=0),r>this.length)return"";if((void0===t||t>this.length)&&(t=this.length),t<=0)return"";if((t>>>=0)<=(r>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":returnb(this,r,t);case"utf8":case"utf-8":returny(this,r,t);case"ascii":returnR(this,r,t);case"latin1":case"binary":returnw(this,r,t);case"base64":returnP(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":returnv(this,r,t);default:if(n)thrownewTypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}functiong(e,r,t){varn=e[r];e[r]=e[t],e[t]=n}functionp(e,r,t,n,_){if(0===e.length)return-1;if("string"==typeoft?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=_?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(_)return-1;t=e.length-1}elseif(t<0){if(!_)return-1;t=0}if("string"==typeofr&&(r=i.from(r,n)),i.isBuffer(r))return0===r.length?-1:A(e,r,t,n,_);if("number"==typeofr)returnr&=255,i.TYPED_ARRAY_SUPPORT&&"function"==typeofUint8Array.prototype.indexOf?_?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):A(e,[r],t,n,_);thrownewTypeError("val must be string, number or Buffer")}functionA(e,r,t,n,_){vara,s=1,o=e.length,i=r.length;if(void0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs
r.read=function(e,r,t,n,_){vara,s,o=8*_-n-1,i=(1<<o)-1,c=i>>1,u=-7,l=t?_-1:0,d=t?-1:1,C=e[r+l];for(l+=d,a=C&(1<<-u)-1,C>>=-u,u+=o;u>0;a=256*a+e[r+l],l+=d,u-=8);for(s=a&(1<<-u)-1,a>>=-u,u+=n;u>0;s=256*s+e[r+l],l+=d,u-=8);if(0===a)a=1-c;else{if(a===i)returns?NaN:1/0*(C?-1:1);s+=Math.pow(2,n),a-=c}return(C?-1:1)*s*Math.pow(2,a-n)},r.write=function(e,r,t,n,_,a){vars,o,i,c=8*a-_-1,u=(1<<c)-1,l=u>>1,d=23===_?Math.pow(2,-24)-Math.pow(2,-77):0,C=n?0:a-1,E=n?1:-1,f=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(o=isNaN(r)?1:0,s=u):(s=Math.floor(Math.log(r)/Math.LN2),r*(i=Math.pow(2,-s))<1&&(s--,i*=2),(r+=s+l>=1?d/i:d*Math.pow(2,1-l))*i>=2&&(s++,i/=2),s+l>=u?(o=0,s=u):s+l>=1?(o=(r*i-1)*Math.pow(2,_),s+=l):(o=r*Math.pow(2,l-1)*Math.pow(2,_),s=0));_>=8;e[t+C]=255&o,C+=E,o/=256,_-=8);for(s=s<<_|o,c+=_;c>0;e[t+C]=255&s,C+=E,s/=256,c-=8);e[t+C-E]|=128*f}},function(e,r){vart={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},function(module,exports,__webpack_require__){"use strict";(function(Buffer){var__awaiter=this&&this.__awaiter||function(e,r,t,n){returnnew(t||(t=Promise))((function(_,a){functions(e){try{i(n.next(e))}catch(e){a(e)}}functiono(e){try{i(n.throw(e))}catch(e){a(e)}}functioni(e){varr;e.done?_(e.value):(r=e.value,rinstanceoft?r:newt((function(e){e(r)}))).then(s,o)}i((n=n.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){vart,n,_,a,s={label:0,sent:function(){if(1&_[0])throw_[1];return_[1]},trys:[],ops:[]};returna={next:o(0),throw:o(1),return:o(2)},"function"==typeofSymbol&&(a[Symbol.iterator]=function(){returnthis}),a;functiono(a){returnfunction(o){returnfunction(a){if(t)thrownewTypeError("Generator is already executing.");for(;s;)try{if(t=1,n&&(_=2&a[0]?n.return:a[0]?n.throw||((_=n.return)&&_.call(n),0):n.next)&&!(_=_.call(n,a[1])).done)return_;switch(n=0,_&&(a=[2&a[0],_.value]),a[0]){case0:case1:_=a;break;case4:returns.label++,{value:a[1],done:!1};case5:s.label++,n=a[1],a=[0];continue;case7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(_=s.trys,(_=_.length>0&&_[_.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!_||a[1]>_[0]&&a[1]<_[3])){s.label=a[1];break}if(6===a[0]&&s.label<_[1]){s.label=_[1],_=a;break}if(_&&s.label<_[2]){s.label=_[2],s.ops.push(a);break}_[2]&&s.ops.pop(),s.trys.pop();continue}a=r.call(e,s)}catch(e){a=[6,e],n=0}finally{t=_=0}if(5&a[0])throwa[1];return{value:a[0]?a[1]:void0,done:!0}}([a,o])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.addAttachedSignature=void0;varconstants_1=__webpack_require__(3),_afterPluginsLoaded_1=__webpack_require__(0),_extractMeaningfulErrorMessage_1=__webpack_require__(1),_generateCadesFn_1=__webpack_require__(2),_getCadesCert_1=__webpack_require__(5),_getDateObj_1=__webpack_require__(7);exports.addAttachedSignature=_afterPluginsLoaded_1._afterPluginsLoaded((function(thumbprint,signedMessage){return__awaiter(void0,void0,void0,(function(){varcadesplugin,cadesCertificate;return__generator(this,(function(_a){switch(_a.label){case0:returncadesplugin=window.cadesplugin,[4,_getCadesCert_1._getCadesCert(thumbprint)];case1:returncadesCertificate=_a.sent(),[2,eval(_generateCadesFn_1._generateCadesFn((function(){vare,r,t;try{e=_generateCadesFn_1.__cadesAsyncToken__+_generateCadesFn_1.__createCadesPluginObject__("CADESCOM.CPAttribute"),r=_generateCadesFn_1.__cadesAsyncToken__+_generateCadesFn_1.__createCadesPluginObject__("CAdESCOM.CadesSignedData"),t=_generateCadesFn_1.__cadesAsyncToken__+_generateCadesFn_1.__createCadesPluginObject__("CAdESCOM.CPSigner")}catch(e){throwconsole.error(e),newError(_extractMeaningfulErrorMessage_1._extractMeaningfulErrorMessage(e)||"Ошибка при инициализации подписи")}varn,_,a,s=_getDateObj_1._getDateObj(newDate);try{_generateCadesFn_1.__cadesAsyncToken__,e.propset_Name(constants_1.CADESCOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME),_generateCadesFn_1.__cadesAsyncToken__,e.propset_Value(s)}catch(e){throwconsole.error(e),newError(_extractMeaningfulErrorMessage_1._extractMeaning