gws-client 1.3.2 → 1.3.4

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.
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Ne=Object.defineProperty,xe=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var re=Object.getOwnPropertySymbols;var Te=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable;var Y=(i,e,t)=>e in i?Ne(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,S=(i,e)=>{for(var t in e||(e={}))Te.call(e,t)&&Y(i,t,e[t]);if(re)for(var t of re(e))Oe.call(e,t)&&Y(i,t,e[t]);return i},v=(i,e)=>xe(i,$e(e));var a=(i,e,t)=>Y(i,typeof e!="symbol"?e+"":e,t);var c=(i,e,t)=>new Promise((n,s)=>{var r=h=>{try{l(t.next(h))}catch(u){s(u)}},o=h=>{try{l(t.throw(h))}catch(u){s(u)}},l=h=>h.done?n(h.value):Promise.resolve(h.value).then(r,o);l((t=t.apply(i,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Me=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",oe="1",ae="2",Ge="1",Fe="2",Ve="3";var ke=(i=>(i.MIN="0",i.LOW="1",i.MIDDLE="2",i.HIGH="3",i))(ke||{});const L={LEVEL_1:1,LEVEL_2:2,LEVEL_3:4},Ze={OPEN:L.LEVEL_1,INTERNAL:L.LEVEL_2|L.LEVEL_1,OMP:L.LEVEL_3|L.LEVEL_2|L.LEVEL_1},He="00000001",q="NO_SEAL_AVAILABLE",Ue="CERTIFICATE_NOT_FOUND",je="CLIENT_CONNECTION_FAILED",Re="ACCESS_DENIED",ce=[{oid:"1.2.86.21.1.3",key:"trustServiceNo"},{oid:"1.2.156.10260.4.1.1",key:"idCardNo"},{oid:"1.2.156.10260.4.1.4",key:"orgCode"}];function Ke(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var G={},le;function ze(){if(le)return G;le=1,G.byteLength=l,G.toByteArray=u,G.fromByteArray=C;for(var i=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,r=n.length;s<r;++s)i[s]=n[s],e[n.charCodeAt(s)]=s;e[45]=62,e[95]=63;function o(y){var f=y.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var E=y.indexOf("=");E===-1&&(E=f);var w=E===f?0:4-E%4;return[E,w]}function l(y){var f=o(y),E=f[0],w=f[1];return(E+w)*3/4-w}function h(y,f,E){return(f+E)*3/4-E}function u(y){var f,E=o(y),w=E[0],m=E[1],I=new t(h(y,w,m)),_=0,B=m>0?w-4:w,k;for(k=0;k<B;k+=4)f=e[y.charCodeAt(k)]<<18|e[y.charCodeAt(k+1)]<<12|e[y.charCodeAt(k+2)]<<6|e[y.charCodeAt(k+3)],I[_++]=f>>16&255,I[_++]=f>>8&255,I[_++]=f&255;return m===2&&(f=e[y.charCodeAt(k)]<<2|e[y.charCodeAt(k+1)]>>4,I[_++]=f&255),m===1&&(f=e[y.charCodeAt(k)]<<10|e[y.charCodeAt(k+1)]<<4|e[y.charCodeAt(k+2)]>>2,I[_++]=f>>8&255,I[_++]=f&255),I}function g(y){return i[y>>18&63]+i[y>>12&63]+i[y>>6&63]+i[y&63]}function d(y,f,E){for(var w,m=[],I=f;I<E;I+=3)w=(y[I]<<16&16711680)+(y[I+1]<<8&65280)+(y[I+2]&255),m.push(g(w));return m.join("")}function C(y){for(var f,E=y.length,w=E%3,m=[],I=16383,_=0,B=E-w;_<B;_+=I)m.push(d(y,_,_+I>B?B:_+I));return w===1?(f=y[E-1],m.push(i[f>>2]+i[f<<4&63]+"==")):w===2&&(f=(y[E-2]<<8)+y[E-1],m.push(i[f>>10]+i[f>>4&63]+i[f<<2&63]+"=")),m.join("")}return G}var Je=ze();const ue=Ke(Je);class We{constructor(){a(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const n=this.deps.get(e);n==null||n(t)}}(function(){try{var i=document.createElement("style");i.appendChild(document.createTextNode("button.svelte-16iv9d0{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-16iv9d0{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-16iv9d0{background-color:#fff;padding:1.25rem;border-radius:.3125rem;width:40%}.model-title.svelte-16iv9d0{color:#303133;font-size:1.125rem;margin-bottom:1.125rem}.modal-visible.svelte-16iv9d0{display:flex}.modal-footer.svelte-16iv9d0{display:flex;align-items:center;justify-content:flex-end;margin-top:1rem}.modal-btn.svelte-16iv9d0{padding:.5rem .9375rem;border-radius:.25rem;font-size:.875rem;border:.0625rem solid #dcdfe6}.success.svelte-16iv9d0{margin-left:.75rem;color:#fff}.slot.svelte-16iv9d0{max-height:12.5rem;overflow-y:scroll}.slot.svelte-16iv9d0::-webkit-scrollbar{display:none}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:11.25rem;height:11.25rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.0625rem solid #ccc;margin-top:.625rem;margin-right:.625rem;border-radius:.25rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:6.25rem;height:6.25rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.625rem;color:#333}.cert-item.svelte-1kh75ag.svelte-1kh75ag{padding:1rem;display:flex;align-items:center;cursor:pointer;border-bottom:.0625rem solid #ebeef5;font-size:1rem}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag{word-break:break-all;color:#373a40}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag:nth-child(1){padding-right:.5rem}.cert-item-selected.svelte-1kh75ag.svelte-1kh75ag{background-color:#f1f1f1}.cert-item-first.svelte-1kh75ag.svelte-1kh75ag{border-top:.0625rem solid #ebeef5}")),document.head.appendChild(i)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Qe=Object.defineProperty,Ye=(i,e,t)=>e in i?Qe(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,he=(i,e,t)=>Ye(i,typeof e!="symbol"?e+"":e,t);function ee(){}function qe(i,e){for(const t in e)i[t]=e[t];return i}function Ie(i){return i()}function de(){return Object.create(null)}function Z(i){i.forEach(Ie)}function z(i){return typeof i=="function"}function ve(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function Xe(i){return Object.keys(i).length===0}function et(i,e,t,n){if(i){const s=Le(i,e,t,n);return i[0](s)}}function Le(i,e,t,n){return i[1]&&n?qe(t.ctx.slice(),i[1](n(e))):t.ctx}function tt(i,e,t,n){if(i[2]&&n){const s=i[2](n(t));if(e.dirty===void 0)return s;if(typeof s=="object"){const r=[],o=Math.max(e.dirty.length,s.length);for(let l=0;l<o;l+=1)r[l]=e.dirty[l]|s[l];return r}return e.dirty|s}return e.dirty}function nt(i,e,t,n,s,r){if(s){const o=Le(e,t,n,r);i.p(o,s)}}function st(i){if(i.ctx.length>32){const e=[],t=i.ctx.length/32;for(let n=0;n<t;n++)e[n]=-1;return e}return-1}function ge(i){return i==null?"":i}function D(i,e){i.appendChild(e)}function Q(i,e,t){i.insertBefore(e,t||null)}function H(i){i.parentNode&&i.parentNode.removeChild(i)}function _e(i,e){for(let t=0;t<i.length;t+=1)i[t]&&i[t].d(e)}function P(i){return document.createElement(i)}function T(i){return document.createTextNode(i)}function U(){return T(" ")}function it(){return T("")}function j(i,e,t,n){return i.addEventListener(e,t,n),()=>i.removeEventListener(e,t,n)}function A(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function rt(i){return Array.from(i.childNodes)}function R(i,e){e=""+e,i.data!==e&&(i.data=e)}function J(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,"")}let se;function V(i){se=i}const x=[],ye=[];let O=[];const Ce=[],ot=Promise.resolve();let te=!1;function at(){te||(te=!0,ot.then(De))}function ne(i){O.push(i)}const X=new Set;let N=0;function De(){if(N!==0)return;const i=se;do{try{for(;N<x.length;){const e=x[N];N++,V(e),ct(e.$$)}}catch(e){throw x.length=0,N=0,e}for(V(null),x.length=0,N=0;ye.length;)ye.pop()();for(let e=0;e<O.length;e+=1){const t=O[e];X.has(t)||(X.add(t),t())}O.length=0}while(x.length);for(;Ce.length;)Ce.pop()();te=!1,X.clear(),V(i)}function ct(i){if(i.fragment!==null){i.update(),Z(i.before_update);const e=i.dirty;i.dirty=[-1],i.fragment&&i.fragment.p(i.ctx,e),i.after_update.forEach(ne)}}function lt(i){const e=[],t=[];O.forEach(n=>i.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),O=e}const K=new Set;let ut;function ie(i,e){i&&i.i&&(K.delete(i),i.i(e))}function pe(i,e,t,n){if(i&&i.o){if(K.has(i))return;K.add(i),ut.c.push(()=>{K.delete(i)}),i.o(e)}}function W(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function ht(i){i&&i.c()}function Ae(i,e,t){const{fragment:n,after_update:s}=i.$$;n&&n.m(e,t),ne(()=>{const r=i.$$.on_mount.map(Ie).filter(z);i.$$.on_destroy?i.$$.on_destroy.push(...r):Z(r),i.$$.on_mount=[]}),s.forEach(ne)}function Be(i,e){const t=i.$$;t.fragment!==null&&(lt(t.after_update),Z(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function dt(i,e){i.$$.dirty[0]===-1&&(x.push(i),at(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<<e%31}function Pe(i,e,t,n,s,r,o=null,l=[-1]){const h=se;V(i);const u=i.$$={fragment:null,ctx:[],props:r,update:ee,not_equal:s,bound:de(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(h?h.$$.context:[])),callbacks:de(),dirty:l,skip_bound:!1,root:e.target||h.$$.root};o&&o(u.root);let g=!1;if(u.ctx=t?t(i,e.props||{},(d,C,...y)=>{const f=y.length?y[0]:C;return u.ctx&&s(u.ctx[d],u.ctx[d]=f)&&(!u.skip_bound&&u.bound[d]&&u.bound[d](f),g&&dt(i,d)),C}):[],u.update(),g=!0,Z(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){const d=rt(e.target);u.fragment&&u.fragment.l(d),d.forEach(H)}else u.fragment&&u.fragment.c();e.intro&&ie(i.$$.fragment),Ae(i,e.target,e.anchor),De()}V(h)}class be{constructor(){he(this,"$$"),he(this,"$$set")}$destroy(){Be(this,1),this.$destroy=ee}$on(e,t){if(!z(t))return ee;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}$set(e){this.$$set&&!Xe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const gt="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(gt);function yt(i){let e,t,n,s=(i[1]||"标题")+"",r,o,l,h,u,g,d=(i[3]||"取消")+"",C,y,f,E=(i[4]||"确认")+"",w,m,I,_;const B=i[8].default,k=et(B,i,i[7],null);return{c(){e=P("div"),t=P("div"),n=P("div"),r=T(s),o=U(),l=P("div"),k&&k.c(),h=U(),u=P("div"),g=P("button"),C=T(d),y=U(),f=P("button"),w=T(E),A(n,"class","model-title svelte-16iv9d0"),A(l,"class","slot svelte-16iv9d0"),A(g,"class","modal-btn svelte-16iv9d0"),A(f,"class","modal-btn success svelte-16iv9d0"),J(f,"background-color",i[5]),A(u,"class","modal-footer svelte-16iv9d0"),A(t,"class","modal-content svelte-16iv9d0"),A(e,"class","modal-background modal-visible svelte-16iv9d0")},m(p,b){Q(p,e,b),D(e,t),D(t,n),D(n,r),D(t,o),D(t,l),k&&k.m(l,null),D(t,h),D(t,u),D(u,g),D(g,C),D(u,y),D(u,f),D(f,w),m=!0,I||(_=[j(g,"click",function(){z(i[0])&&i[0].apply(this,arguments)}),j(f,"click",function(){z(i[2])&&i[2].apply(this,arguments)}),j(t,"click",Ct)],I=!0)},p(p,[b]){i=p,(!m||b&2)&&s!==(s=(i[1]||"标题")+"")&&R(r,s),k&&k.p&&(!m||b&128)&&nt(k,B,i,i[7],m?tt(B,i[7],b,null):st(i[7]),null),(!m||b&8)&&d!==(d=(i[3]||"取消")+"")&&R(C,d),(!m||b&16)&&E!==(E=(i[4]||"确认")+"")&&R(w,E),(!m||b&32)&&J(f,"background-color",i[5])},i(p){m||(ie(k,p),m=!0)},o(p){pe(k,p),m=!1},d(p){p&&H(e),k&&k.d(p),I=!1,Z(_)}}}const Ct=i=>i.stopPropagation();function ft(i,e,t){let{$$slots:n={},$$scope:s}=e,{onCancel:r}=e,{title:o}=e,{onOk:l}=e,{onClose:h}=e,{cancelText:u}=e,{okText:g}=e,{theme:d}=e;return i.$$set=C=>{"onCancel"in C&&t(0,r=C.onCancel),"title"in C&&t(1,o=C.title),"onOk"in C&&t(2,l=C.onOk),"onClose"in C&&t(6,h=C.onClose),"cancelText"in C&&t(3,u=C.cancelText),"okText"in C&&t(4,g=C.okText),"theme"in C&&t(5,d=C.theme),"$$scope"in C&&t(7,s=C.$$scope)},[r,o,l,u,g,d,h,s,n]}class wt extends be{constructor(e){super(),Pe(this,e,ft,yt,ve,{onCancel:0,title:1,onOk:2,onClose:6,cancelText:3,okText:4,theme:5})}}function fe(i,e,t){const n=i.slice();return n[13]=e[t],n[15]=t,n}function we(i,e,t){const n=i.slice();return n[16]=e[t],n}function Se(i){let e,t=(i[16].format?i[16].format(i[13]):i[13][i[16].key])+"",n;return{c(){e=P("div"),n=T(t),A(e,"class","svelte-1kh75ag"),J(e,"width",`${100/i[1].length}%`)},m(s,r){Q(s,e,r),D(e,n)},p(s,r){r&3&&t!==(t=(s[16].format?s[16].format(s[13]):s[13][s[16].key])+"")&&R(n,t),r&2&&J(e,"width",`${100/s[1].length}%`)},d(s){s&&H(e)}}}function Ee(i){let e,t,n,s,r,o=W(i[1]),l=[];for(let u=0;u<o.length;u+=1)l[u]=Se(we(i,o,u));function h(){return i[12](i[15])}return{c(){e=P("div");for(let u=0;u<l.length;u+=1)l[u].c();t=U(),A(e,"class",n=ge(`cert-item ${i[15]===0?"cert-item-first":""} ${i[15]===i[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")},m(u,g){Q(u,e,g);for(let d=0;d<l.length;d+=1)l[d]&&l[d].m(e,null);D(e,t),s||(r=j(e,"click",h),s=!0)},p(u,g){if(i=u,g&3){o=W(i[1]);let d;for(d=0;d<o.length;d+=1){const C=we(i,o,d);l[d]?l[d].p(C,g):(l[d]=Se(C),l[d].c(),l[d].m(e,t))}for(;d<l.length;d+=1)l[d].d(1);l.length=o.length}g&128&&n!==(n=ge(`cert-item ${i[15]===0?"cert-item-first":""} ${i[15]===i[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")&&A(e,"class",n)},d(u){u&&H(e),_e(l,u),s=!1,r()}}}function St(i){let e,t=W(i[0]),n=[];for(let s=0;s<t.length;s+=1)n[s]=Ee(fe(i,t,s));return{c(){for(let s=0;s<n.length;s+=1)n[s].c();e=it()},m(s,r){for(let o=0;o<n.length;o+=1)n[o]&&n[o].m(s,r);Q(s,e,r)},p(s,r){if(r&131){t=W(s[0]);let o;for(o=0;o<t.length;o+=1){const l=fe(s,t,o);n[o]?n[o].p(l,r):(n[o]=Ee(l),n[o].c(),n[o].m(e.parentNode,e))}for(;o<n.length;o+=1)n[o].d(1);n.length=t.length}},d(s){s&&H(e),_e(n,s)}}}function Et(i){let e,t;return e=new wt({props:{onOk:i[9],onClose:i[2],onCancel:i[8],cancelText:i[3],okText:i[4],title:i[6],theme:i[5],$$slots:{default:[St]},$$scope:{ctx:i}}}),{c(){ht(e.$$.fragment)},m(n,s){Ae(e,n,s),t=!0},p(n,[s]){const r={};s&4&&(r.onClose=n[2]),s&8&&(r.cancelText=n[3]),s&16&&(r.okText=n[4]),s&64&&(r.title=n[6]),s&32&&(r.theme=n[5]),s&524419&&(r.$$scope={dirty:s,ctx:n}),e.$set(r)},i(n){t||(ie(e.$$.fragment,n),t=!0)},o(n){pe(e.$$.fragment,n),t=!1},d(n){Be(e,n)}}}function mt(i,e,t){let{data:n=[]}=e,{columns:s=[]}=e,{onCancel:r}=e,{onOk:o}=e,{onClose:l}=e,{cancelText:h=""}=e,{okText:u=""}=e,{theme:g="#409eff"}=e,{title:d=""}=e,C=0;const y=()=>{r(`${d}失败`),l==null||l()},f=()=>{o==null||o(n[C]),l==null||l()},E=w=>t(7,C=w);return i.$$set=w=>{"data"in w&&t(0,n=w.data),"columns"in w&&t(1,s=w.columns),"onCancel"in w&&t(10,r=w.onCancel),"onOk"in w&&t(11,o=w.onOk),"onClose"in w&&t(2,l=w.onClose),"cancelText"in w&&t(3,h=w.cancelText),"okText"in w&&t(4,u=w.okText),"theme"in w&&t(5,g=w.theme),"title"in w&&t(6,d=w.title)},[n,s,l,h,u,g,d,C,y,f,r,o,E]}class kt extends be{constructor(e){super(),Pe(this,e,mt,Et,ve,{data:0,columns:1,onCancel:10,onOk:11,onClose:2,cancelText:3,okText:4,theme:5,title:6})}}class It{constructor(){a(this,"modalInstance",{current:null});a(this,"open",e=>new Promise((t,n)=>{this.modalInstance.current=new kt({target:document.body,props:v(S({},e),{onCancel:s=>{n({code:-1,msg:s})},onOk:s=>{t(s)},onClose:()=>{this.close()}})})}));a(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const F=new It;function vt(i=32,e=!0,t=0){const n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),s=[];if(t=t||n.length,i)for(let r=0;r<i;r++)s[r]=n[0|Math.random()*t];else{let r;s[8]=s[13]=s[18]=s[23]="-",s[14]="4";for(let o=0;o<36;o++)s[o]||(r=0|Math.random()*16,s[o]=n[o===19?r&3|8:r])}return e?(s.shift(),`u${s.join("")}`):s.join("")}function Lt(i){const e=new Uint8Array(i),t=new TextDecoder("gbk"),n=new TextDecoder("latin1").decode(e);try{const s=JSON.parse(n),r=o=>{if(typeof o=="string"){const l=new Uint8Array(o.length);for(let h=0;h<o.length;h++)l[h]=o.charCodeAt(h)&255;return t.decode(l)}if(Array.isArray(o))return o.map(r);if(o!==null&&typeof o=="object"){const l={},h=o;for(const u in o)if(Object.prototype.hasOwnProperty.call(h,u)){const g=r(u);l[g]=r(h[u])}return l}return o};return r(s)}catch(s){throw console.error("GBK JSON 修复流程失败:",s),s}}const _t=[{key:"CN"},{format:i=>`${i.DevClass}(${i.sn})`}],Dt=[{key:"SealId"},{key:"Vid"},{format:i=>`${i.FileName}(${i.FileSize}B)`}],me=[{key:"SealId"}],pt=[{key:"manu"},{key:"sn"}];class At{constructor(e){a(this,"socketInstance",null);a(this,"eventBus",new We);a(this,"scene");a(this,"isRememberPin",!1);a(this,"pinPolicy");a(this,"socketConfig",null);a(this,"isConnecting",!1);a(this,"messageQueue",[]);a(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});a(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});a(this,"sendMessage",(e,t,n)=>new Promise((s,r)=>{var l;const o=()=>{var d,C;if(((d=this.socketInstance)==null?void 0:d.readyState)!==WebSocket.OPEN){r({errCode:je,msg:"数字证书客户端连接失败"});return}const h=vt(),u=y=>{y.success?s(y.data):r(y)},g={function:e,args:t?[t]:[],msgid:h};(C=this.socketInstance)==null||C.send(JSON.stringify(g)),this.eventBus.on(e,u),this.eventBus.on(h,u)};if(n&&(this.scene&n)!==n){r({errCode:Re,msg:"无权限执行此操作"});return}if(((l=this.socketInstance)==null?void 0:l.readyState)===WebSocket.OPEN){o();return}this.messageQueue.push(o),this.isConnecting||this.initSocket(this.socketConfig)}));a(this,"flushMsgQueue",()=>{var e;(e=this.messageQueue)==null||e.forEach(t=>t()),this.messageQueue=[]});a(this,"handleEventData",e=>c(this,null,function*(){var t,n,s,r,o,l,h,u;if(e.data instanceof Blob){const g=yield e.data.arrayBuffer(),C=navigator.userAgent.includes("Windows")?Lt(g):JSON.parse(new TextDecoder().decode(g)),y={success:(t=C.result)==null?void 0:t.success,msg:(n=C.result)==null?void 0:n.msg,errCode:(s=C.result)==null?void 0:s.errCode,data:C.data,type:(r=C.result)==null?void 0:r.event},f=(o=C.result)==null?void 0:o.function,E=(l=C.result)==null?void 0:l.msgid;E?this.eventBus.emit(E,y):this.eventBus.emit(f,y),(u=(h=this.socketConfig)==null?void 0:h.onMessage)==null||u.call(h,y)}}));a(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return ue.fromByteArray(t)});a(this,"base64Decode",e=>{const t=ue.toByteArray(e);return new TextDecoder().decode(t)});a(this,"changeIsRememberPin",e=>c(this,null,function*(){this.isRememberPin=e}));a(this,"changePinPolicy",e=>c(this,null,function*(){this.pinPolicy=e}));a(this,"checkCertIsLogin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));a(this,"addUkeyEvents",()=>c(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:He}),this.eventBus.on("GZCA_OnDeviceChange",e=>{var t,n,s;(s=(t=this.socketConfig)==null?void 0:t.onUkeyChange)==null||s.call(t,v(S({},e),{data:(n=e.data)==null?void 0:n[0]}))})}));a(this,"ensureCertLogin",e=>c(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e.ContainerName});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e.ContainerName,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));a(this,"verifyPin",e=>c(this,null,function*(){var t;console.log("params2",e),yield this.sendMessage("GZCA_Login",{ContainerName:e.ContainerName,IsLogin:e.UserPin?"Y":"N",UserPin:(t=e.UserPin)!=null?t:"123456",PinPolicy:this.pinPolicy})}));a(this,"getCert",(e,t,n)=>c(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&n&&(yield this.ensureCertLogin({ContainerName:s.ContainerName})),s}));a(this,"chooseCert",e=>c(this,null,function*(){var s;const t=yield this.getCertList(e);return t!=null&&t.length?(t==null?void 0:t.length)===1?t[0]:yield F.open({title:"选择证书",data:t,columns:_t,theme:(s=this.socketConfig)==null?void 0:s.theme}):Promise.reject({errCode:Ue,msg:"暂无证书"})}));a(this,"getCertList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));a(this,"pkcs1Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"batchPkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_BatchPkcs1SignDataEx",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs1VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));a(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));a(this,"getSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"writeSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_WriteSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"deleteSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DeleteSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"getSealInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ReadSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"getTPSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicList",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"getTPSealPic",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicData",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"sm2SignPreprocess1",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));a(this,"sm2SignPreprocess2",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));a(this,"pkcs1HashSign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs1HashVerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));a(this,"pkcs7Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",S({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs7VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));a(this,"sm3Hash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));a(this,"sm3HexHash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));a(this,"sm3FileHash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));a(this,"sm3HashEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));a(this,"pkcs7Encryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));a(this,"pkcs7Decryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));a(this,"pkcs7FileEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeSealFileEx_qyzc",e)}));a(this,"pkcs7FileDecryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeOpenFileEx_qyzc",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));a(this,"asymmetricEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));a(this,"asymmetricDecryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));a(this,"sm4Encryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));a(this,"sm4Decryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));a(this,"getCertInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));a(this,"getCertInfoByOid",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));a(this,"getSealVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealIssuer",e,L.LEVEL_2)}));a(this,"deleteAllSealByVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ClearSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"applyCert",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ApplyCert",{manu:e.manu,sn:e.sn,keyid:e.ContainerName,type:e.type,url:e.url},L.LEVEL_3)}));a(this,"resetPin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_UnblockUserPin",S({},e!=null?e:{}),L.LEVEL_3)}));a(this,"getUKeyList",()=>c(this,null,function*(){return yield this.sendMessage("GetUKeyList",void 0,L.LEVEL_3)}));a(this,"getUKeyInfo",e=>c(this,null,function*(){return yield this.sendMessage("GetUKeyID",e!=null?e:{},L.LEVEL_3)}));var t,n,s;this.socketConfig=e,this.initSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.scene=(n=e.scene)!=null?n:Ze.OPEN,this.pinPolicy=(s=e.pinPolicy)!=null?s:ke.MIN}initSocket(e){this.isConnecting=!0;const t=new WebSocket(e.url);t.onerror=n=>{var s;this.isConnecting=!1,(s=e.onError)==null||s.call(e,n),this.flushMsgQueue()},t.onopen=n=>{var s;this.isConnecting=!1,(s=e.onOpen)==null||s.call(e,n),e.onUkeyChange&&this.addUkeyEvents(),this.flushMsgQueue()},t.onmessage=n=>{this.handleEventData(n)},t.onclose=n=>{var s;this.isConnecting=!1,(s=e.onClose)==null||s.call(e,n)},this.socketInstance=t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const $=class ${constructor(e){a(this,"coreInstance",null);a(this,"gwsConfig",{});a(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new At(v(S({},e!=null?e:{}),{url:Me}))});a(this,"appendCertBase64",(e,t=!0)=>c(this,null,function*(){if(e.CertB64)return e;const n=t?yield this.getSignatureCert():yield this.getEncryptionCert();return v(S({},e!=null?e:{}),{CertB64:n==null?void 0:n.CertB64})}));a(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});a(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});a(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});a(this,"verifyPin",(e,t)=>c(this,null,function*(){var s,r;const n=yield this.getSignatureCert(t);return(r=this.coreInstance)==null?void 0:r.verifyPin({ContainerName:(s=n==null?void 0:n.ContainerName)!=null?s:"",UserPin:e==null?void 0:e.UserPin})}));a(this,"ensureCertLogin",e=>c(this,null,function*(){var s,r;const t=yield this.getSignatureCert(e);return yield(r=this.coreInstance)==null?void 0:r.ensureCertLogin({ContainerName:(s=t==null?void 0:t.ContainerName)!=null?s:""})}));a(this,"getSignatureCert",(e,t=!0)=>c(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:oe},e,t)}));a(this,"getSignatureCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:oe})}));a(this,"getEncryptionCert",(e,t=!0)=>c(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:ae},e,t)}));a(this,"getEncryptionCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:ae})}));a(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});a(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});a(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});a(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});a(this,"pkcs1Sign",(e,t)=>c(this,null,function*(){var r,o,l;const n=yield this.getSignatureCert(t),s=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(v(S({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""}));return(l=s==null?void 0:s[0])==null?void 0:l.SignData}));a(this,"pkcs1VerifySignature",e=>c(this,null,function*(){var s;const t=yield this.appendCertBase64(e),n=yield(s=this.coreInstance)==null?void 0:s.pkcs1VerifySignature(t);return Array.isArray(n)}));a(this,"pkcs1Base64Sign",(e,t)=>c(this,null,function*(){var o,l,h,u,g;const n=yield this.getSignatureCert(t),s=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64Sign(v(S({},e!=null?e:{}),{ContainerName:(h=n==null?void 0:n.ContainerName)!=null?h:"",DataB64:s}));return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));a(this,"batchPkcs1Base64Sign",(e,t)=>c(this,null,function*(){var g,d,C,y,f,E;const n="|",s=(d=e.DataB64)!=null?d:(g=e.Data)==null?void 0:g.map(w=>this.base64Encode({Data:w})),r=yield this.getSignatureCert(t);let o="";o=Array.isArray(s)?s==null?void 0:s.map((w,m)=>`${m}:${w}`).join(n):"";const l=yield(y=this.coreInstance)==null?void 0:y.batchPkcs1Base64Sign({ContainerName:(C=r==null?void 0:r.ContainerName)!=null?C:"",DataB64:o}),h=(E=(f=l==null?void 0:l[0])==null?void 0:f.SignData)==null?void 0:E.split(n),u=[];return h.forEach(w=>{const m=w.split(":"),I=Number(m[0]),_=m[1];u[I]=_}),u}));a(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){var r,o,l;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=yield this.appendCertBase64(e);return!!(yield(l=this.coreInstance)==null?void 0:l.pkcs1Base64VerifySignature({CertB64:n.CertB64,DataB64:t,SignData:n.SignData}))}));a(this,"writeSeal",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return!!(yield(o=this.coreInstance)==null?void 0:o.writeSeal(v(S({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""})))}));a(this,"deleteSeal",(e,t)=>c(this,null,function*(){var h,u,g;const n=yield this.getSignatureCert(t),s=yield this.getSealList(e,n);if(!(s!=null&&s.length))return Promise.reject({errCode:q,msg:"暂无印章"});const r=yield F.open({title:"删除印章",data:s,columns:me,okText:"删除"}),o=(h=r==null?void 0:r.SealId)!=null?h:"";return!!(yield(g=this.coreInstance)==null?void 0:g.deleteSeal(S({ContainerName:(u=n==null?void 0:n.ContainerName)!=null?u:"",SealId:o},e!=null?e:{})))}));a(this,"deleteSealById",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return!!(yield(o=this.coreInstance)==null?void 0:o.deleteSeal(v(S({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""})))}));a(this,"getSealList",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return yield(o=this.coreInstance)==null?void 0:o.getSealList(S({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""},e!=null?e:{}))}));a(this,"getSealInfo",(e,t)=>c(this,null,function*(){var l,h,u,g;const n=yield this.getSignatureCert(t),s=yield this.getSealList(e,n);if(!(s!=null&&s.length))return Promise.reject({errCode:q,msg:"暂无印章"});const r=(s==null?void 0:s.length)>1?yield F.open({title:"选择印章",data:s,columns:me,theme:(l=this.gwsConfig)==null?void 0:l.theme}):s==null?void 0:s[0],o=yield(g=this.coreInstance)==null?void 0:g.getSealInfo({ContainerName:(h=n==null?void 0:n.ContainerName)!=null?h:"",SealId:(u=r==null?void 0:r.SealId)!=null?u:""});return o==null?void 0:o[0]}));a(this,"getTPSealList",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return yield(o=this.coreInstance)==null?void 0:o.getTPSealList(S({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""},e!=null?e:{}))}));a(this,"getTPSeal",(e,t)=>c(this,null,function*(){var r;const n=yield this.getTPSealList(e,t);return n!=null&&n.length?(n==null?void 0:n.length)===1?n==null?void 0:n[0]:yield F.open({title:"选择印章",data:n,columns:Dt,theme:(r=this.gwsConfig)==null?void 0:r.theme}):Promise.reject({errCode:q,msg:"暂无印章"})}));a(this,"getTPSealPic",(e,t,n)=>c(this,null,function*(){var l,h;const s=yield this.getSignatureCert(t),r=n||(yield this.getTPSeal(e,t)),o=yield(h=this.coreInstance)==null?void 0:h.getTPSealPic(v(S(S({ContainerName:(l=s==null?void 0:s.ContainerName)!=null?l:""},r!=null?r:{}),e!=null?e:{}),{FileSize:String(r==null?void 0:r.FileSize)}));return o==null?void 0:o[0]}));a(this,"sm2SignPreprocess1",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e),n=yield(s=this.coreInstance)==null?void 0:s.sm2SignPreprocess1(t);return(r=n==null?void 0:n[0])==null?void 0:r.Z}));a(this,"sm2SignPreprocess2",e=>c(this,null,function*(){var r,o;const t=this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=yield this.appendCertBase64(e),s=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:n.CertB64,DataB64:t});return s==null?void 0:s[0].H}));a(this,"pkcs1HashSign",(e,t)=>c(this,null,function*(){var r,o,l,h;const n=yield this.getSignatureCert(t),s=yield(l=this.coreInstance)==null?void 0:l.pkcs1HashSign({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:"",DataB64:e.DataB64,HashAlg:(o=e.HashAlg)!=null?o:"sm3"});return(h=s==null?void 0:s[0])==null?void 0:h.SignData}));a(this,"pkcs1HashVerifySignature",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e);return!!(yield(r=this.coreInstance)==null?void 0:r.pkcs1HashVerifySignature(v(S({},t),{HashAlg:(s=t.HashAlg)!=null?s:"sm3"})))}));a(this,"pkcs7Sign",(e,t)=>c(this,null,function*(){var o,l,h,u,g;const n=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=yield this.getSignatureCert(t),r=yield(u=this.coreInstance)==null?void 0:u.pkcs7Sign(v(S({},e!=null?e:{}),{ContainerName:(h=s==null?void 0:s.ContainerName)!=null?h:"",DataB64:n}));return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));a(this,"pkcs7VerifySignature",e=>c(this,null,function*(){var s,r,o;const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(s=e.Data)!=null?s:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));a(this,"sm3Hash",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm3Hash(e);return(s=t==null?void 0:t[0])==null?void 0:s.HashB64}));a(this,"sm3HexHash",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm3HexHash(e);return(s=t==null?void 0:t[0])==null?void 0:s.HashB64}));a(this,"sm3FileHash",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm3FileHash(e);return(s=t==null?void 0:t[0])==null?void 0:s.HashB64}));a(this,"sm3HashEncryption",e=>c(this,null,function*(){var r,o,l,h,u,g;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=(h=e.KeyB64)!=null?h:this.base64Encode({Data:(l=e.Key)!=null?l:""}),s=yield(u=this.coreInstance)==null?void 0:u.sm3HashEncryption({dataB64:t,keyB64:n,alg:"sm3"});return(g=s==null?void 0:s[0])==null?void 0:g.DataB64}));a(this,"pkcs7Encryption",e=>c(this,null,function*(){var s,r,o,l;if(!e.CertB64List){const h=yield this.getEncryptionCert();e.CertB64List=h==null?void 0:h.CertB64}const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(s=e.Data)!=null?s:""}),n=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(l=n==null?void 0:n[0])==null?void 0:l.DataB64}));a(this,"pkcs7Decryption",e=>c(this,null,function*(){var r,o;const t=yield this.getEncryptionCert(),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7Decryption(v(S({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),s=(o=n==null?void 0:n[0])==null?void 0:o.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:s}):s}));a(this,"pkcs7FileEncryption",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e,!1),n=yield(s=this.coreInstance)==null?void 0:s.pkcs7FileEncryption(t);return(r=n==null?void 0:n[0])==null?void 0:r.DataB64}));a(this,"pkcs7FileDecryption",e=>c(this,null,function*(){var s,r,o;const t=yield this.getEncryptionCert(),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7FileDecryption({SrcFile:e.SrcFile,DstFile:(s=e.DstFile)!=null?s:e.SrcFile.slice(0,-4),ContainerName:t==null?void 0:t.ContainerName});return(o=n==null?void 0:n[0])==null?void 0:o.DataB64}));a(this,"asymmetricEncryption",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e,!1),n=yield(s=this.coreInstance)==null?void 0:s.asymmetricEncryption(t);return(r=n==null?void 0:n[0])==null?void 0:r.Data}));a(this,"asymmetricDecryption",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getEncryptionCert(t),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricDecryption(v(S({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return(o=s==null?void 0:s[0])==null?void 0:o.Data}));a(this,"sm4Encryption",e=>c(this,null,function*(){var n;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Encryption(e);return t==null?void 0:t[0]}));a(this,"sm4Decryption",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Decryption(e);return(s=t==null?void 0:t[0])==null?void 0:s.Data}));a(this,"getCertInfo",e=>c(this,null,function*(){var s,r,o,l,h;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(e),n=(r=t==null?void 0:t[0])!=null?r:{};for(let u=0;u<ce.length;u++){const g=ce[u];try{const d=yield(o=this.coreInstance)==null?void 0:o.getCertInfoByOid({Oid:g.oid,CertB64:e.CertB64});n[g.key]=(h=(l=d==null?void 0:d[0])==null?void 0:l.OidValue)==null?void 0:h.replace(/\./g,"")}catch(d){n[g.key]=null}}return n!=null&&n.idCardNo?n!=null&&n.CertSubject.includes("O=")||n.orgCode?n.certCate=Fe:n.certCate=Ge:n.certCate=Ve,n}));a(this,"getCertInfoByOid",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.getCertInfoByOid(S({},e!=null?e:{}));return(s=t==null?void 0:t[0])==null?void 0:s.OidValue}));a(this,"getSealVendor",e=>c(this,null,function*(){var s;const t=yield this.getSignatureCert(e),n=yield(s=this.coreInstance)==null?void 0:s.getSealVendor({ContainerName:t==null?void 0:t.ContainerName});return n==null?void 0:n[0]}));a(this,"deleteAllSealByVendor",(e,t)=>c(this,null,function*(){var r;const n=yield this.getSignatureCert(t),s=yield(r=this.coreInstance)==null?void 0:r.deleteAllSealByVendor(v(S({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return s==null?void 0:s[0]}));a(this,"getUKey",e=>c(this,null,function*(){var s,r;if(e)return e;const t=yield(s=this.coreInstance)==null?void 0:s.getUKeyList();return yield F.open({title:"选择介质",data:t,columns:pt,theme:(r=this.gwsConfig)==null?void 0:r.theme})}));a(this,"getUKeyList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getUKeyList()}));a(this,"getUKeyInfo",e=>c(this,null,function*(){var s;const t=yield this.getUKey(e),n=yield(s=this.coreInstance)==null?void 0:s.getUKeyInfo({manu:t==null?void 0:t.manu,sn:t==null?void 0:t.sn});return n==null?void 0:n[0]}));a(this,"applyCert",(e,t)=>c(this,null,function*(){var o;const n=yield this.getUKey(t),s=yield this.getUKeyInfo(n);return yield(o=this.coreInstance)==null?void 0:o.applyCert(v(S({},e!=null?e:{}),{manu:s==null?void 0:s.manu,sn:s==null?void 0:s.sn,ContainerName:s==null?void 0:s.keyid}))}));a(this,"resetPin",(e,t)=>c(this,null,function*(){var r;const n=yield this.getSignatureCert(t);return yield(r=this.coreInstance)==null?void 0:r.resetPin(v(S({},e!=null?e:{}),{manu:n==null?void 0:n.manu,sn:n==null?void 0:n.sn,ContainerName:n==null?void 0:n.ContainerName}))}));return $.instance&&!(e!=null&&e.isCreateNew)?$.instance:(this.createGwsCore(e),$.instance=this,this)}};a($,"instance",null);let M=$;function Bt(i){return new Promise((e,t)=>{if(M.instance&&!(i!=null&&i.isCreateNew))e(M.instance);else{const n=new M(v(S({},i!=null?i:{}),{onOpen(s){var r;e(n),(r=i==null?void 0:i.onOpen)==null||r.call(i,s)},onClose(s){var r;t(s),(r=i==null?void 0:i.onClose)==null||r.call(i,s)}}))}})}exports.GwsService=M;exports.createService=Bt;
1
+ "use strict";var Ne=Object.defineProperty,xe=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var re=Object.getOwnPropertySymbols;var Te=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable;var Y=(i,e,t)=>e in i?Ne(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,S=(i,e)=>{for(var t in e||(e={}))Te.call(e,t)&&Y(i,t,e[t]);if(re)for(var t of re(e))Oe.call(e,t)&&Y(i,t,e[t]);return i},v=(i,e)=>xe(i,$e(e));var a=(i,e,t)=>Y(i,typeof e!="symbol"?e+"":e,t);var c=(i,e,t)=>new Promise((n,s)=>{var r=h=>{try{l(t.next(h))}catch(u){s(u)}},o=h=>{try{l(t.throw(h))}catch(u){s(u)}},l=h=>h.done?n(h.value):Promise.resolve(h.value).then(r,o);l((t=t.apply(i,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Me=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",oe="1",ae="2",Ge="1",Fe="2",Ve="3";var ke=(i=>(i.MIN="0",i.LOW="1",i.MIDDLE="2",i.HIGH="3",i))(ke||{});const L={LEVEL_1:1,LEVEL_2:2,LEVEL_3:4},Ze={OPEN:L.LEVEL_1,INTERNAL:L.LEVEL_2|L.LEVEL_1,OMP:L.LEVEL_3|L.LEVEL_2|L.LEVEL_1},He="00000001",q="NO_SEAL_AVAILABLE",Ue="CERTIFICATE_NOT_FOUND",je="CLIENT_CONNECTION_FAILED",Re="ACCESS_DENIED",ce=[{oid:"1.2.86.21.1.3",key:"trustServiceNo"},{oid:"1.2.156.10260.4.1.1",key:"idCardNo"},{oid:"1.2.156.10260.4.1.4",key:"orgCode"}];function Ke(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var G={},le;function ze(){if(le)return G;le=1,G.byteLength=l,G.toByteArray=u,G.fromByteArray=C;for(var i=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,r=n.length;s<r;++s)i[s]=n[s],e[n.charCodeAt(s)]=s;e[45]=62,e[95]=63;function o(y){var f=y.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var E=y.indexOf("=");E===-1&&(E=f);var w=E===f?0:4-E%4;return[E,w]}function l(y){var f=o(y),E=f[0],w=f[1];return(E+w)*3/4-w}function h(y,f,E){return(f+E)*3/4-E}function u(y){var f,E=o(y),w=E[0],m=E[1],I=new t(h(y,w,m)),_=0,B=m>0?w-4:w,k;for(k=0;k<B;k+=4)f=e[y.charCodeAt(k)]<<18|e[y.charCodeAt(k+1)]<<12|e[y.charCodeAt(k+2)]<<6|e[y.charCodeAt(k+3)],I[_++]=f>>16&255,I[_++]=f>>8&255,I[_++]=f&255;return m===2&&(f=e[y.charCodeAt(k)]<<2|e[y.charCodeAt(k+1)]>>4,I[_++]=f&255),m===1&&(f=e[y.charCodeAt(k)]<<10|e[y.charCodeAt(k+1)]<<4|e[y.charCodeAt(k+2)]>>2,I[_++]=f>>8&255,I[_++]=f&255),I}function g(y){return i[y>>18&63]+i[y>>12&63]+i[y>>6&63]+i[y&63]}function d(y,f,E){for(var w,m=[],I=f;I<E;I+=3)w=(y[I]<<16&16711680)+(y[I+1]<<8&65280)+(y[I+2]&255),m.push(g(w));return m.join("")}function C(y){for(var f,E=y.length,w=E%3,m=[],I=16383,_=0,B=E-w;_<B;_+=I)m.push(d(y,_,_+I>B?B:_+I));return w===1?(f=y[E-1],m.push(i[f>>2]+i[f<<4&63]+"==")):w===2&&(f=(y[E-2]<<8)+y[E-1],m.push(i[f>>10]+i[f>>4&63]+i[f<<2&63]+"=")),m.join("")}return G}var Je=ze();const ue=Ke(Je);class We{constructor(){a(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const n=this.deps.get(e);n==null||n(t)}}(function(){try{var i=document.createElement("style");i.appendChild(document.createTextNode("button.svelte-16iv9d0{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-16iv9d0{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-16iv9d0{background-color:#fff;padding:1.25rem;border-radius:.3125rem;width:40%}.model-title.svelte-16iv9d0{color:#303133;font-size:1.125rem;margin-bottom:1.125rem}.modal-visible.svelte-16iv9d0{display:flex}.modal-footer.svelte-16iv9d0{display:flex;align-items:center;justify-content:flex-end;margin-top:1rem}.modal-btn.svelte-16iv9d0{padding:.5rem .9375rem;border-radius:.25rem;font-size:.875rem;border:.0625rem solid #dcdfe6}.success.svelte-16iv9d0{margin-left:.75rem;color:#fff}.slot.svelte-16iv9d0{max-height:12.5rem;overflow-y:scroll}.slot.svelte-16iv9d0::-webkit-scrollbar{display:none}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:11.25rem;height:11.25rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.0625rem solid #ccc;margin-top:.625rem;margin-right:.625rem;border-radius:.25rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:6.25rem;height:6.25rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.625rem;color:#333}.cert-item.svelte-1kh75ag.svelte-1kh75ag{padding:1rem;display:flex;align-items:center;cursor:pointer;border-bottom:.0625rem solid #ebeef5;font-size:1rem}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag{word-break:break-all;color:#373a40}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag:nth-child(1){padding-right:.5rem}.cert-item-selected.svelte-1kh75ag.svelte-1kh75ag{background-color:#f1f1f1}.cert-item-first.svelte-1kh75ag.svelte-1kh75ag{border-top:.0625rem solid #ebeef5}")),document.head.appendChild(i)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Qe=Object.defineProperty,Ye=(i,e,t)=>e in i?Qe(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,he=(i,e,t)=>Ye(i,typeof e!="symbol"?e+"":e,t);function ee(){}function qe(i,e){for(const t in e)i[t]=e[t];return i}function Ie(i){return i()}function de(){return Object.create(null)}function Z(i){i.forEach(Ie)}function z(i){return typeof i=="function"}function ve(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function Xe(i){return Object.keys(i).length===0}function et(i,e,t,n){if(i){const s=Le(i,e,t,n);return i[0](s)}}function Le(i,e,t,n){return i[1]&&n?qe(t.ctx.slice(),i[1](n(e))):t.ctx}function tt(i,e,t,n){if(i[2]&&n){const s=i[2](n(t));if(e.dirty===void 0)return s;if(typeof s=="object"){const r=[],o=Math.max(e.dirty.length,s.length);for(let l=0;l<o;l+=1)r[l]=e.dirty[l]|s[l];return r}return e.dirty|s}return e.dirty}function nt(i,e,t,n,s,r){if(s){const o=Le(e,t,n,r);i.p(o,s)}}function st(i){if(i.ctx.length>32){const e=[],t=i.ctx.length/32;for(let n=0;n<t;n++)e[n]=-1;return e}return-1}function ge(i){return i==null?"":i}function D(i,e){i.appendChild(e)}function Q(i,e,t){i.insertBefore(e,t||null)}function H(i){i.parentNode&&i.parentNode.removeChild(i)}function _e(i,e){for(let t=0;t<i.length;t+=1)i[t]&&i[t].d(e)}function P(i){return document.createElement(i)}function T(i){return document.createTextNode(i)}function U(){return T(" ")}function it(){return T("")}function j(i,e,t,n){return i.addEventListener(e,t,n),()=>i.removeEventListener(e,t,n)}function A(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function rt(i){return Array.from(i.childNodes)}function R(i,e){e=""+e,i.data!==e&&(i.data=e)}function J(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,"")}let se;function V(i){se=i}const x=[],ye=[];let O=[];const Ce=[],ot=Promise.resolve();let te=!1;function at(){te||(te=!0,ot.then(De))}function ne(i){O.push(i)}const X=new Set;let N=0;function De(){if(N!==0)return;const i=se;do{try{for(;N<x.length;){const e=x[N];N++,V(e),ct(e.$$)}}catch(e){throw x.length=0,N=0,e}for(V(null),x.length=0,N=0;ye.length;)ye.pop()();for(let e=0;e<O.length;e+=1){const t=O[e];X.has(t)||(X.add(t),t())}O.length=0}while(x.length);for(;Ce.length;)Ce.pop()();te=!1,X.clear(),V(i)}function ct(i){if(i.fragment!==null){i.update(),Z(i.before_update);const e=i.dirty;i.dirty=[-1],i.fragment&&i.fragment.p(i.ctx,e),i.after_update.forEach(ne)}}function lt(i){const e=[],t=[];O.forEach(n=>i.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),O=e}const K=new Set;let ut;function ie(i,e){i&&i.i&&(K.delete(i),i.i(e))}function pe(i,e,t,n){if(i&&i.o){if(K.has(i))return;K.add(i),ut.c.push(()=>{K.delete(i)}),i.o(e)}}function W(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function ht(i){i&&i.c()}function Ae(i,e,t){const{fragment:n,after_update:s}=i.$$;n&&n.m(e,t),ne(()=>{const r=i.$$.on_mount.map(Ie).filter(z);i.$$.on_destroy?i.$$.on_destroy.push(...r):Z(r),i.$$.on_mount=[]}),s.forEach(ne)}function Be(i,e){const t=i.$$;t.fragment!==null&&(lt(t.after_update),Z(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function dt(i,e){i.$$.dirty[0]===-1&&(x.push(i),at(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<<e%31}function Pe(i,e,t,n,s,r,o=null,l=[-1]){const h=se;V(i);const u=i.$$={fragment:null,ctx:[],props:r,update:ee,not_equal:s,bound:de(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(h?h.$$.context:[])),callbacks:de(),dirty:l,skip_bound:!1,root:e.target||h.$$.root};o&&o(u.root);let g=!1;if(u.ctx=t?t(i,e.props||{},(d,C,...y)=>{const f=y.length?y[0]:C;return u.ctx&&s(u.ctx[d],u.ctx[d]=f)&&(!u.skip_bound&&u.bound[d]&&u.bound[d](f),g&&dt(i,d)),C}):[],u.update(),g=!0,Z(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){const d=rt(e.target);u.fragment&&u.fragment.l(d),d.forEach(H)}else u.fragment&&u.fragment.c();e.intro&&ie(i.$$.fragment),Ae(i,e.target,e.anchor),De()}V(h)}class be{constructor(){he(this,"$$"),he(this,"$$set")}$destroy(){Be(this,1),this.$destroy=ee}$on(e,t){if(!z(t))return ee;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}$set(e){this.$$set&&!Xe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const gt="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(gt);function yt(i){let e,t,n,s=(i[1]||"标题")+"",r,o,l,h,u,g,d=(i[3]||"取消")+"",C,y,f,E=(i[4]||"确认")+"",w,m,I,_;const B=i[8].default,k=et(B,i,i[7],null);return{c(){e=P("div"),t=P("div"),n=P("div"),r=T(s),o=U(),l=P("div"),k&&k.c(),h=U(),u=P("div"),g=P("button"),C=T(d),y=U(),f=P("button"),w=T(E),A(n,"class","model-title svelte-16iv9d0"),A(l,"class","slot svelte-16iv9d0"),A(g,"class","modal-btn svelte-16iv9d0"),A(f,"class","modal-btn success svelte-16iv9d0"),J(f,"background-color",i[5]),A(u,"class","modal-footer svelte-16iv9d0"),A(t,"class","modal-content svelte-16iv9d0"),A(e,"class","modal-background modal-visible svelte-16iv9d0")},m(p,b){Q(p,e,b),D(e,t),D(t,n),D(n,r),D(t,o),D(t,l),k&&k.m(l,null),D(t,h),D(t,u),D(u,g),D(g,C),D(u,y),D(u,f),D(f,w),m=!0,I||(_=[j(g,"click",function(){z(i[0])&&i[0].apply(this,arguments)}),j(f,"click",function(){z(i[2])&&i[2].apply(this,arguments)}),j(t,"click",Ct)],I=!0)},p(p,[b]){i=p,(!m||b&2)&&s!==(s=(i[1]||"标题")+"")&&R(r,s),k&&k.p&&(!m||b&128)&&nt(k,B,i,i[7],m?tt(B,i[7],b,null):st(i[7]),null),(!m||b&8)&&d!==(d=(i[3]||"取消")+"")&&R(C,d),(!m||b&16)&&E!==(E=(i[4]||"确认")+"")&&R(w,E),(!m||b&32)&&J(f,"background-color",i[5])},i(p){m||(ie(k,p),m=!0)},o(p){pe(k,p),m=!1},d(p){p&&H(e),k&&k.d(p),I=!1,Z(_)}}}const Ct=i=>i.stopPropagation();function ft(i,e,t){let{$$slots:n={},$$scope:s}=e,{onCancel:r}=e,{title:o}=e,{onOk:l}=e,{onClose:h}=e,{cancelText:u}=e,{okText:g}=e,{theme:d}=e;return i.$$set=C=>{"onCancel"in C&&t(0,r=C.onCancel),"title"in C&&t(1,o=C.title),"onOk"in C&&t(2,l=C.onOk),"onClose"in C&&t(6,h=C.onClose),"cancelText"in C&&t(3,u=C.cancelText),"okText"in C&&t(4,g=C.okText),"theme"in C&&t(5,d=C.theme),"$$scope"in C&&t(7,s=C.$$scope)},[r,o,l,u,g,d,h,s,n]}class wt extends be{constructor(e){super(),Pe(this,e,ft,yt,ve,{onCancel:0,title:1,onOk:2,onClose:6,cancelText:3,okText:4,theme:5})}}function fe(i,e,t){const n=i.slice();return n[13]=e[t],n[15]=t,n}function we(i,e,t){const n=i.slice();return n[16]=e[t],n}function Se(i){let e,t=(i[16].format?i[16].format(i[13]):i[13][i[16].key])+"",n;return{c(){e=P("div"),n=T(t),A(e,"class","svelte-1kh75ag"),J(e,"width",`${100/i[1].length}%`)},m(s,r){Q(s,e,r),D(e,n)},p(s,r){r&3&&t!==(t=(s[16].format?s[16].format(s[13]):s[13][s[16].key])+"")&&R(n,t),r&2&&J(e,"width",`${100/s[1].length}%`)},d(s){s&&H(e)}}}function Ee(i){let e,t,n,s,r,o=W(i[1]),l=[];for(let u=0;u<o.length;u+=1)l[u]=Se(we(i,o,u));function h(){return i[12](i[15])}return{c(){e=P("div");for(let u=0;u<l.length;u+=1)l[u].c();t=U(),A(e,"class",n=ge(`cert-item ${i[15]===0?"cert-item-first":""} ${i[15]===i[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")},m(u,g){Q(u,e,g);for(let d=0;d<l.length;d+=1)l[d]&&l[d].m(e,null);D(e,t),s||(r=j(e,"click",h),s=!0)},p(u,g){if(i=u,g&3){o=W(i[1]);let d;for(d=0;d<o.length;d+=1){const C=we(i,o,d);l[d]?l[d].p(C,g):(l[d]=Se(C),l[d].c(),l[d].m(e,t))}for(;d<l.length;d+=1)l[d].d(1);l.length=o.length}g&128&&n!==(n=ge(`cert-item ${i[15]===0?"cert-item-first":""} ${i[15]===i[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")&&A(e,"class",n)},d(u){u&&H(e),_e(l,u),s=!1,r()}}}function St(i){let e,t=W(i[0]),n=[];for(let s=0;s<t.length;s+=1)n[s]=Ee(fe(i,t,s));return{c(){for(let s=0;s<n.length;s+=1)n[s].c();e=it()},m(s,r){for(let o=0;o<n.length;o+=1)n[o]&&n[o].m(s,r);Q(s,e,r)},p(s,r){if(r&131){t=W(s[0]);let o;for(o=0;o<t.length;o+=1){const l=fe(s,t,o);n[o]?n[o].p(l,r):(n[o]=Ee(l),n[o].c(),n[o].m(e.parentNode,e))}for(;o<n.length;o+=1)n[o].d(1);n.length=t.length}},d(s){s&&H(e),_e(n,s)}}}function Et(i){let e,t;return e=new wt({props:{onOk:i[9],onClose:i[2],onCancel:i[8],cancelText:i[3],okText:i[4],title:i[6],theme:i[5],$$slots:{default:[St]},$$scope:{ctx:i}}}),{c(){ht(e.$$.fragment)},m(n,s){Ae(e,n,s),t=!0},p(n,[s]){const r={};s&4&&(r.onClose=n[2]),s&8&&(r.cancelText=n[3]),s&16&&(r.okText=n[4]),s&64&&(r.title=n[6]),s&32&&(r.theme=n[5]),s&524419&&(r.$$scope={dirty:s,ctx:n}),e.$set(r)},i(n){t||(ie(e.$$.fragment,n),t=!0)},o(n){pe(e.$$.fragment,n),t=!1},d(n){Be(e,n)}}}function mt(i,e,t){let{data:n=[]}=e,{columns:s=[]}=e,{onCancel:r}=e,{onOk:o}=e,{onClose:l}=e,{cancelText:h=""}=e,{okText:u=""}=e,{theme:g="#409eff"}=e,{title:d=""}=e,C=0;const y=()=>{r(`${d}失败`),l==null||l()},f=()=>{o==null||o(n[C]),l==null||l()},E=w=>t(7,C=w);return i.$$set=w=>{"data"in w&&t(0,n=w.data),"columns"in w&&t(1,s=w.columns),"onCancel"in w&&t(10,r=w.onCancel),"onOk"in w&&t(11,o=w.onOk),"onClose"in w&&t(2,l=w.onClose),"cancelText"in w&&t(3,h=w.cancelText),"okText"in w&&t(4,u=w.okText),"theme"in w&&t(5,g=w.theme),"title"in w&&t(6,d=w.title)},[n,s,l,h,u,g,d,C,y,f,r,o,E]}class kt extends be{constructor(e){super(),Pe(this,e,mt,Et,ve,{data:0,columns:1,onCancel:10,onOk:11,onClose:2,cancelText:3,okText:4,theme:5,title:6})}}class It{constructor(){a(this,"modalInstance",{current:null});a(this,"open",e=>new Promise((t,n)=>{this.modalInstance.current=new kt({target:document.body,props:v(S({},e),{onCancel:s=>{n({code:"ON_CANCEL",msg:s})},onOk:s=>{t(s)},onClose:()=>{this.close()}})})}));a(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const F=new It;function vt(i=32,e=!0,t=0){const n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),s=[];if(t=t||n.length,i)for(let r=0;r<i;r++)s[r]=n[0|Math.random()*t];else{let r;s[8]=s[13]=s[18]=s[23]="-",s[14]="4";for(let o=0;o<36;o++)s[o]||(r=0|Math.random()*16,s[o]=n[o===19?r&3|8:r])}return e?(s.shift(),`u${s.join("")}`):s.join("")}function Lt(i){const e=new Uint8Array(i),t=new TextDecoder("gbk"),n=new TextDecoder("latin1").decode(e);try{const s=JSON.parse(n),r=o=>{if(typeof o=="string"){const l=new Uint8Array(o.length);for(let h=0;h<o.length;h++)l[h]=o.charCodeAt(h)&255;return t.decode(l)}if(Array.isArray(o))return o.map(r);if(o!==null&&typeof o=="object"){const l={},h=o;for(const u in o)if(Object.prototype.hasOwnProperty.call(h,u)){const g=r(u);l[g]=r(h[u])}return l}return o};return r(s)}catch(s){throw console.error("GBK JSON 修复流程失败:",s),s}}const _t=[{key:"CN"},{format:i=>`${i.DevClass}(${i.sn})`}],Dt=[{key:"SealId"},{key:"Vid"},{format:i=>`${i.FileName}(${i.FileSize}B)`}],me=[{key:"SealId"}],pt=[{key:"manu"},{key:"sn"}];class At{constructor(e){a(this,"socketInstance",null);a(this,"eventBus",new We);a(this,"scene");a(this,"isRememberPin",!1);a(this,"pinPolicy");a(this,"socketConfig",null);a(this,"isConnecting",!1);a(this,"messageQueue",[]);a(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});a(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});a(this,"sendMessage",(e,t,n)=>new Promise((s,r)=>{var l;const o=()=>{var d,C;if(((d=this.socketInstance)==null?void 0:d.readyState)!==WebSocket.OPEN){r({errCode:je,msg:"数字证书客户端连接失败"});return}const h=vt(),u=y=>{y.success?s(y.data):r(y)},g={function:e,args:t?[t]:[],msgid:h};(C=this.socketInstance)==null||C.send(JSON.stringify(g)),this.eventBus.on(e,u),this.eventBus.on(h,u)};if(n&&(this.scene&n)!==n){r({errCode:Re,msg:"无权限执行此操作"});return}if(((l=this.socketInstance)==null?void 0:l.readyState)===WebSocket.OPEN){o();return}this.messageQueue.push(o),this.isConnecting||this.initSocket(this.socketConfig)}));a(this,"flushMsgQueue",()=>{var e;(e=this.messageQueue)==null||e.forEach(t=>t()),this.messageQueue=[]});a(this,"handleEventData",e=>c(this,null,function*(){var t,n,s,r,o,l,h,u;if(e.data instanceof Blob){const g=yield e.data.arrayBuffer(),C=navigator.userAgent.includes("Windows")?Lt(g):JSON.parse(new TextDecoder().decode(g)),y={success:(t=C.result)==null?void 0:t.success,msg:(n=C.result)==null?void 0:n.msg,errCode:(s=C.result)==null?void 0:s.errCode,data:C.data,type:(r=C.result)==null?void 0:r.event},f=(o=C.result)==null?void 0:o.function,E=(l=C.result)==null?void 0:l.msgid;E?this.eventBus.emit(E,y):this.eventBus.emit(f,y),(u=(h=this.socketConfig)==null?void 0:h.onMessage)==null||u.call(h,y)}}));a(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return ue.fromByteArray(t)});a(this,"base64Decode",e=>{const t=ue.toByteArray(e);return new TextDecoder().decode(t)});a(this,"changeIsRememberPin",e=>c(this,null,function*(){this.isRememberPin=e}));a(this,"changePinPolicy",e=>c(this,null,function*(){this.pinPolicy=e}));a(this,"checkCertIsLogin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));a(this,"addUkeyEvents",()=>c(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:He}),this.eventBus.on("GZCA_OnDeviceChange",e=>{var t,n,s;(s=(t=this.socketConfig)==null?void 0:t.onUkeyChange)==null||s.call(t,v(S({},e),{data:(n=e.data)==null?void 0:n[0]}))})}));a(this,"ensureCertLogin",e=>c(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e.ContainerName});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e.ContainerName,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));a(this,"verifyPin",e=>c(this,null,function*(){var t;console.log("params2",e),yield this.sendMessage("GZCA_Login",{ContainerName:e.ContainerName,IsLogin:e.UserPin?"Y":"N",UserPin:(t=e.UserPin)!=null?t:"123456",PinPolicy:this.pinPolicy})}));a(this,"getCert",(e,t,n)=>c(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&n&&(yield this.ensureCertLogin({ContainerName:s.ContainerName})),s}));a(this,"chooseCert",e=>c(this,null,function*(){var s;const t=yield this.getCertList(e);return t!=null&&t.length?(t==null?void 0:t.length)===1?t[0]:yield F.open({title:"选择证书",data:t,columns:_t,theme:(s=this.socketConfig)==null?void 0:s.theme}):Promise.reject({errCode:Ue,msg:"暂无证书"})}));a(this,"getClientVersion",()=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetClientVersion")}));a(this,"getCertList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));a(this,"pkcs1Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"batchPkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_BatchPkcs1SignDataEx",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs1VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));a(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));a(this,"getSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"writeSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_WriteSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"deleteSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DeleteSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"getSealInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ReadSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"getTPSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicList",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"getTPSealPic",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicData",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"sm2SignPreprocess1",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));a(this,"sm2SignPreprocess2",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));a(this,"pkcs1HashSign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs1HashVerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));a(this,"pkcs7Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",S({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs7VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));a(this,"sm3Hash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));a(this,"sm3HexHash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));a(this,"sm3FileHash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));a(this,"sm3HashEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));a(this,"pkcs7Encryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));a(this,"pkcs7Decryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));a(this,"pkcs7FileEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeSealFileEx_qyzc",e)}));a(this,"pkcs7FileDecryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeOpenFileEx_qyzc",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));a(this,"asymmetricEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));a(this,"asymmetricDecryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));a(this,"sm4Encryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));a(this,"sm4Decryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));a(this,"getCertInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));a(this,"getCertInfoByOid",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));a(this,"getSealVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealIssuer",e,L.LEVEL_2)}));a(this,"deleteAllSealByVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ClearSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),L.LEVEL_2)}));a(this,"applyCert",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ApplyCert",{manu:e.manu,sn:e.sn,keyid:e.ContainerName,type:e.type,url:e.url},L.LEVEL_3)}));a(this,"resetPin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_UnblockUserPin",S({},e!=null?e:{}),L.LEVEL_3)}));a(this,"getUKeyList",()=>c(this,null,function*(){return yield this.sendMessage("GetUKeyList",void 0,L.LEVEL_3)}));a(this,"getUKeyInfo",e=>c(this,null,function*(){return yield this.sendMessage("GetUKeyID",e!=null?e:{},L.LEVEL_3)}));var t,n,s;this.socketConfig=e,this.initSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.scene=(n=e.scene)!=null?n:Ze.OPEN,this.pinPolicy=(s=e.pinPolicy)!=null?s:ke.MIN}initSocket(e){this.isConnecting=!0;const t=new WebSocket(e.url);t.onerror=n=>{var s;this.isConnecting=!1,(s=e.onError)==null||s.call(e,n),this.flushMsgQueue()},t.onopen=n=>{var s;this.isConnecting=!1,(s=e.onOpen)==null||s.call(e,n),e.onUkeyChange&&this.addUkeyEvents(),this.flushMsgQueue()},t.onmessage=n=>{this.handleEventData(n)},t.onclose=n=>{var s;this.isConnecting=!1,(s=e.onClose)==null||s.call(e,n)},this.socketInstance=t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const $=class ${constructor(e){a(this,"coreInstance",null);a(this,"gwsConfig",{});a(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new At(v(S({},e!=null?e:{}),{url:Me}))});a(this,"appendCertBase64",(e,t=!0)=>c(this,null,function*(){if(e.CertB64)return e;const n=t?yield this.getSignatureCert():yield this.getEncryptionCert();return v(S({},e!=null?e:{}),{CertB64:n==null?void 0:n.CertB64})}));a(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});a(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});a(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});a(this,"verifyPin",(e,t)=>c(this,null,function*(){var s,r;const n=yield this.getSignatureCert(t);return(r=this.coreInstance)==null?void 0:r.verifyPin({ContainerName:(s=n==null?void 0:n.ContainerName)!=null?s:"",UserPin:e==null?void 0:e.UserPin})}));a(this,"ensureCertLogin",e=>c(this,null,function*(){var s,r;const t=yield this.getSignatureCert(e);return yield(r=this.coreInstance)==null?void 0:r.ensureCertLogin({ContainerName:(s=t==null?void 0:t.ContainerName)!=null?s:""})}));a(this,"getSignatureCert",(e,t=!0)=>c(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:oe},e,t)}));a(this,"getSignatureCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:oe})}));a(this,"getEncryptionCert",(e,t=!0)=>c(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:ae},e,t)}));a(this,"getEncryptionCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:ae})}));a(this,"getClientVersion",()=>c(this,null,function*(){var t;const e=yield(t=this.coreInstance)==null?void 0:t.getClientVersion();return e==null?void 0:e[0]}));a(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});a(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});a(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});a(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});a(this,"pkcs1Sign",(e,t)=>c(this,null,function*(){var r,o,l;const n=yield this.getSignatureCert(t),s=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(v(S({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""}));return(l=s==null?void 0:s[0])==null?void 0:l.SignData}));a(this,"pkcs1VerifySignature",e=>c(this,null,function*(){var s;const t=yield this.appendCertBase64(e),n=yield(s=this.coreInstance)==null?void 0:s.pkcs1VerifySignature(t);return Array.isArray(n)}));a(this,"pkcs1Base64Sign",(e,t)=>c(this,null,function*(){var o,l,h,u,g;const n=yield this.getSignatureCert(t),s=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64Sign(v(S({},e!=null?e:{}),{ContainerName:(h=n==null?void 0:n.ContainerName)!=null?h:"",DataB64:s}));return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));a(this,"batchPkcs1Base64Sign",(e,t)=>c(this,null,function*(){var g,d,C,y,f,E;const n="|",s=(d=e.DataB64)!=null?d:(g=e.Data)==null?void 0:g.map(w=>this.base64Encode({Data:w})),r=yield this.getSignatureCert(t);let o="";o=Array.isArray(s)?s==null?void 0:s.map((w,m)=>`${m}:${w}`).join(n):"";const l=yield(y=this.coreInstance)==null?void 0:y.batchPkcs1Base64Sign({ContainerName:(C=r==null?void 0:r.ContainerName)!=null?C:"",DataB64:o}),h=(E=(f=l==null?void 0:l[0])==null?void 0:f.SignData)==null?void 0:E.split(n),u=[];return h.forEach(w=>{const m=w.split(":"),I=Number(m[0]),_=m[1];u[I]=_}),u}));a(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){var r,o,l;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=yield this.appendCertBase64(e);return!!(yield(l=this.coreInstance)==null?void 0:l.pkcs1Base64VerifySignature({CertB64:n.CertB64,DataB64:t,SignData:n.SignData}))}));a(this,"writeSeal",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return!!(yield(o=this.coreInstance)==null?void 0:o.writeSeal(v(S({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""})))}));a(this,"deleteSeal",(e,t)=>c(this,null,function*(){var h,u,g;const n=yield this.getSignatureCert(t),s=yield this.getSealList(e,n);if(!(s!=null&&s.length))return Promise.reject({errCode:q,msg:"暂无印章"});const r=yield F.open({title:"删除印章",data:s,columns:me,okText:"删除"}),o=(h=r==null?void 0:r.SealId)!=null?h:"";return!!(yield(g=this.coreInstance)==null?void 0:g.deleteSeal(S({ContainerName:(u=n==null?void 0:n.ContainerName)!=null?u:"",SealId:o},e!=null?e:{})))}));a(this,"deleteSealById",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return!!(yield(o=this.coreInstance)==null?void 0:o.deleteSeal(v(S({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""})))}));a(this,"getSealList",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return yield(o=this.coreInstance)==null?void 0:o.getSealList(S({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""},e!=null?e:{}))}));a(this,"getSealInfo",(e,t)=>c(this,null,function*(){var l,h,u,g;const n=yield this.getSignatureCert(t),s=yield this.getSealList(e,n);if(!(s!=null&&s.length))return Promise.reject({errCode:q,msg:"暂无印章"});const r=(s==null?void 0:s.length)>1?yield F.open({title:"选择印章",data:s,columns:me,theme:(l=this.gwsConfig)==null?void 0:l.theme}):s==null?void 0:s[0],o=yield(g=this.coreInstance)==null?void 0:g.getSealInfo({ContainerName:(h=n==null?void 0:n.ContainerName)!=null?h:"",SealId:(u=r==null?void 0:r.SealId)!=null?u:""});return o==null?void 0:o[0]}));a(this,"getTPSealList",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return yield(o=this.coreInstance)==null?void 0:o.getTPSealList(S({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""},e!=null?e:{}))}));a(this,"getTPSeal",(e,t)=>c(this,null,function*(){var r;const n=yield this.getTPSealList(e,t);return n!=null&&n.length?(n==null?void 0:n.length)===1?n==null?void 0:n[0]:yield F.open({title:"选择印章",data:n,columns:Dt,theme:(r=this.gwsConfig)==null?void 0:r.theme}):Promise.reject({errCode:q,msg:"暂无印章"})}));a(this,"getTPSealPic",(e,t,n)=>c(this,null,function*(){var l,h;const s=yield this.getSignatureCert(t),r=n||(yield this.getTPSeal(e,t)),o=yield(h=this.coreInstance)==null?void 0:h.getTPSealPic(v(S(S({ContainerName:(l=s==null?void 0:s.ContainerName)!=null?l:""},r!=null?r:{}),e!=null?e:{}),{FileSize:String(r==null?void 0:r.FileSize)}));return o==null?void 0:o[0]}));a(this,"sm2SignPreprocess1",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e),n=yield(s=this.coreInstance)==null?void 0:s.sm2SignPreprocess1(t);return(r=n==null?void 0:n[0])==null?void 0:r.Z}));a(this,"sm2SignPreprocess2",e=>c(this,null,function*(){var r,o;const t=this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=yield this.appendCertBase64(e),s=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:n.CertB64,DataB64:t});return s==null?void 0:s[0].H}));a(this,"pkcs1HashSign",(e,t)=>c(this,null,function*(){var r,o,l,h;const n=yield this.getSignatureCert(t),s=yield(l=this.coreInstance)==null?void 0:l.pkcs1HashSign({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:"",DataB64:e.DataB64,HashAlg:(o=e.HashAlg)!=null?o:"sm3"});return(h=s==null?void 0:s[0])==null?void 0:h.SignData}));a(this,"pkcs1HashVerifySignature",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e);return!!(yield(r=this.coreInstance)==null?void 0:r.pkcs1HashVerifySignature(v(S({},t),{HashAlg:(s=t.HashAlg)!=null?s:"sm3"})))}));a(this,"pkcs7Sign",(e,t)=>c(this,null,function*(){var o,l,h,u,g;const n=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=yield this.getSignatureCert(t),r=yield(u=this.coreInstance)==null?void 0:u.pkcs7Sign(v(S({},e!=null?e:{}),{ContainerName:(h=s==null?void 0:s.ContainerName)!=null?h:"",DataB64:n}));return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));a(this,"pkcs7VerifySignature",e=>c(this,null,function*(){var s,r,o;const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(s=e.Data)!=null?s:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));a(this,"sm3Hash",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm3Hash(e);return(s=t==null?void 0:t[0])==null?void 0:s.HashB64}));a(this,"sm3HexHash",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm3HexHash(e);return(s=t==null?void 0:t[0])==null?void 0:s.HashB64}));a(this,"sm3FileHash",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm3FileHash(e);return(s=t==null?void 0:t[0])==null?void 0:s.HashB64}));a(this,"sm3HashEncryption",e=>c(this,null,function*(){var r,o,l,h,u,g;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=(h=e.KeyB64)!=null?h:this.base64Encode({Data:(l=e.Key)!=null?l:""}),s=yield(u=this.coreInstance)==null?void 0:u.sm3HashEncryption({dataB64:t,keyB64:n,alg:"sm3"});return(g=s==null?void 0:s[0])==null?void 0:g.DataB64}));a(this,"pkcs7Encryption",e=>c(this,null,function*(){var s,r,o,l;if(!e.CertB64List){const h=yield this.getEncryptionCert();e.CertB64List=h==null?void 0:h.CertB64}const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(s=e.Data)!=null?s:""}),n=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(l=n==null?void 0:n[0])==null?void 0:l.DataB64}));a(this,"pkcs7Decryption",e=>c(this,null,function*(){var r,o;const t=yield this.getEncryptionCert(),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7Decryption(v(S({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),s=(o=n==null?void 0:n[0])==null?void 0:o.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:s}):s}));a(this,"pkcs7FileEncryption",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e,!1),n=yield(s=this.coreInstance)==null?void 0:s.pkcs7FileEncryption(t);return(r=n==null?void 0:n[0])==null?void 0:r.DataB64}));a(this,"pkcs7FileDecryption",e=>c(this,null,function*(){var s,r,o;const t=yield this.getEncryptionCert(),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7FileDecryption({SrcFile:e.SrcFile,DstFile:(s=e.DstFile)!=null?s:e.SrcFile.slice(0,-4),ContainerName:t==null?void 0:t.ContainerName});return(o=n==null?void 0:n[0])==null?void 0:o.DataB64}));a(this,"asymmetricEncryption",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e,!1),n=yield(s=this.coreInstance)==null?void 0:s.asymmetricEncryption(t);return(r=n==null?void 0:n[0])==null?void 0:r.Data}));a(this,"asymmetricDecryption",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getEncryptionCert(t),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricDecryption(v(S({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return(o=s==null?void 0:s[0])==null?void 0:o.Data}));a(this,"sm4Encryption",e=>c(this,null,function*(){var n;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Encryption(e);return t==null?void 0:t[0]}));a(this,"sm4Decryption",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Decryption(e);return(s=t==null?void 0:t[0])==null?void 0:s.Data}));a(this,"getCertInfo",e=>c(this,null,function*(){var s,r,o,l,h;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(e),n=(r=t==null?void 0:t[0])!=null?r:{};for(let u=0;u<ce.length;u++){const g=ce[u];try{const d=yield(o=this.coreInstance)==null?void 0:o.getCertInfoByOid({Oid:g.oid,CertB64:e.CertB64});n[g.key]=(h=(l=d==null?void 0:d[0])==null?void 0:l.OidValue)==null?void 0:h.replace(/\./g,"")}catch(d){n[g.key]=null}}return n!=null&&n.idCardNo?n!=null&&n.CertSubject.includes("O=")||n.orgCode?n.certCate=Fe:n.certCate=Ge:n.certCate=Ve,n}));a(this,"getCertInfoByOid",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.getCertInfoByOid(S({},e!=null?e:{}));return(s=t==null?void 0:t[0])==null?void 0:s.OidValue}));a(this,"getSealVendor",e=>c(this,null,function*(){var s;const t=yield this.getSignatureCert(e),n=yield(s=this.coreInstance)==null?void 0:s.getSealVendor({ContainerName:t==null?void 0:t.ContainerName});return n==null?void 0:n[0]}));a(this,"deleteAllSealByVendor",(e,t)=>c(this,null,function*(){var r;const n=yield this.getSignatureCert(t),s=yield(r=this.coreInstance)==null?void 0:r.deleteAllSealByVendor(v(S({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return s==null?void 0:s[0]}));a(this,"getUKey",e=>c(this,null,function*(){var s,r;if(e)return e;const t=yield(s=this.coreInstance)==null?void 0:s.getUKeyList();return yield F.open({title:"选择介质",data:t,columns:pt,theme:(r=this.gwsConfig)==null?void 0:r.theme})}));a(this,"getUKeyList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getUKeyList()}));a(this,"getUKeyInfo",e=>c(this,null,function*(){var s;const t=yield this.getUKey(e),n=yield(s=this.coreInstance)==null?void 0:s.getUKeyInfo({manu:t==null?void 0:t.manu,sn:t==null?void 0:t.sn});return n==null?void 0:n[0]}));a(this,"applyCert",(e,t)=>c(this,null,function*(){var o;const n=yield this.getUKey(t),s=yield this.getUKeyInfo(n);return yield(o=this.coreInstance)==null?void 0:o.applyCert(v(S({},e!=null?e:{}),{manu:s==null?void 0:s.manu,sn:s==null?void 0:s.sn,ContainerName:s==null?void 0:s.keyid}))}));a(this,"resetPin",(e,t)=>c(this,null,function*(){var r;const n=yield this.getSignatureCert(t);return yield(r=this.coreInstance)==null?void 0:r.resetPin(v(S({},e!=null?e:{}),{manu:n==null?void 0:n.manu,sn:n==null?void 0:n.sn,ContainerName:n==null?void 0:n.ContainerName}))}));return $.instance&&!(e!=null&&e.isCreateNew)?$.instance:(this.createGwsCore(e),$.instance=this,this)}};a($,"instance",null);let M=$;function Bt(i){return new Promise((e,t)=>{if(M.instance&&!(i!=null&&i.isCreateNew))e(M.instance);else{const n=new M(v(S({},i!=null?i:{}),{onOpen(s){var r;e(n),(r=i==null?void 0:i.onOpen)==null||r.call(i,s)},onClose(s){var r;t(s),(r=i==null?void 0:i.onClose)==null||r.call(i,s)}}))}})}exports.GwsService=M;exports.createService=Bt;
package/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export declare class GwsService {
29
29
  getSignatureCertList: () => Promise<CertType[] | undefined>;
30
30
  getEncryptionCert: (cert?: CertType, checkLogin?: boolean) => Promise<Record<string, any> | undefined>;
31
31
  getEncryptionCertList: () => Promise<CertType[] | undefined>;
32
+ getClientVersion: () => Promise<any>;
32
33
  base64Encode: (params: {
33
34
  Data: string;
34
35
  }) => string;
package/dist/index.es.js CHANGED
@@ -1,8 +1,8 @@
1
- var Ne = Object.defineProperty, xe = Object.defineProperties;
1
+ var be = Object.defineProperty, xe = Object.defineProperties;
2
2
  var $e = Object.getOwnPropertyDescriptors;
3
3
  var re = Object.getOwnPropertySymbols;
4
4
  var Te = Object.prototype.hasOwnProperty, Oe = Object.prototype.propertyIsEnumerable;
5
- var Y = (i, e, t) => e in i ? Ne(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, S = (i, e) => {
5
+ var Y = (i, e, t) => e in i ? be(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, S = (i, e) => {
6
6
  for (var t in e || (e = {}))
7
7
  Te.call(e, t) && Y(i, t, e[t]);
8
8
  if (re)
@@ -250,21 +250,21 @@ function ne(i) {
250
250
  O.push(i);
251
251
  }
252
252
  const X = /* @__PURE__ */ new Set();
253
- let N = 0;
253
+ let b = 0;
254
254
  function De() {
255
- if (N !== 0)
255
+ if (b !== 0)
256
256
  return;
257
257
  const i = se;
258
258
  do {
259
259
  try {
260
- for (; N < x.length; ) {
261
- const e = x[N];
262
- N++, F(e), ct(e.$$);
260
+ for (; b < x.length; ) {
261
+ const e = x[b];
262
+ b++, F(e), ct(e.$$);
263
263
  }
264
264
  } catch (e) {
265
- throw x.length = 0, N = 0, e;
265
+ throw x.length = 0, b = 0, e;
266
266
  }
267
- for (F(null), x.length = 0, N = 0; ye.length; ) ye.pop()();
267
+ for (F(null), x.length = 0, b = 0; ye.length; ) ye.pop()();
268
268
  for (let e = 0; e < O.length; e += 1) {
269
269
  const t = O[e];
270
270
  X.has(t) || (X.add(t), t());
@@ -358,7 +358,7 @@ function Pe(i, e, t, n, s, r, o = null, l = [-1]) {
358
358
  }
359
359
  F(h);
360
360
  }
361
- class be {
361
+ class Ne {
362
362
  constructor() {
363
363
  he(this, "$$"), he(this, "$$set");
364
364
  }
@@ -421,8 +421,8 @@ function yt(i) {
421
421
  i[5]
422
422
  ), A(u, "class", "modal-footer svelte-16iv9d0"), A(t, "class", "modal-content svelte-16iv9d0"), A(e, "class", "modal-background modal-visible svelte-16iv9d0");
423
423
  },
424
- m(p, b) {
425
- Q(p, e, b), D(e, t), D(t, n), D(n, r), D(t, o), D(t, l), k && k.m(l, null), D(t, h), D(t, u), D(u, g), D(g, C), D(u, y), D(u, f), D(f, w), m = !0, I || (_ = [
424
+ m(p, N) {
425
+ Q(p, e, N), D(e, t), D(t, n), D(n, r), D(t, o), D(t, l), k && k.m(l, null), D(t, h), D(t, u), D(u, g), D(g, C), D(u, y), D(u, f), D(f, w), m = !0, I || (_ = [
426
426
  j(g, "click", function() {
427
427
  z(
428
428
  /*onCancel*/
@@ -438,10 +438,10 @@ function yt(i) {
438
438
  j(t, "click", Ct)
439
439
  ], I = !0);
440
440
  },
441
- p(p, [b]) {
442
- i = p, (!m || b & /*title*/
441
+ p(p, [N]) {
442
+ i = p, (!m || N & /*title*/
443
443
  2) && s !== (s = /*title*/
444
- (i[1] || "标题") + "") && R(r, s), k && k.p && (!m || b & /*$$scope*/
444
+ (i[1] || "标题") + "") && R(r, s), k && k.p && (!m || N & /*$$scope*/
445
445
  128) && nt(
446
446
  k,
447
447
  B,
@@ -452,18 +452,18 @@ function yt(i) {
452
452
  B,
453
453
  /*$$scope*/
454
454
  i[7],
455
- b,
455
+ N,
456
456
  null
457
457
  ) : st(
458
458
  /*$$scope*/
459
459
  i[7]
460
460
  ),
461
461
  null
462
- ), (!m || b & /*cancelText*/
462
+ ), (!m || N & /*cancelText*/
463
463
  8) && d !== (d = /*cancelText*/
464
- (i[3] || "取消") + "") && R(C, d), (!m || b & /*okText*/
464
+ (i[3] || "取消") + "") && R(C, d), (!m || N & /*okText*/
465
465
  16) && E !== (E = /*okText*/
466
- (i[4] || "确认") + "") && R(w, E), (!m || b & /*theme*/
466
+ (i[4] || "确认") + "") && R(w, E), (!m || N & /*theme*/
467
467
  32) && J(
468
468
  f,
469
469
  "background-color",
@@ -489,7 +489,7 @@ function ft(i, e, t) {
489
489
  "onCancel" in C && t(0, r = C.onCancel), "title" in C && t(1, o = C.title), "onOk" in C && t(2, l = C.onOk), "onClose" in C && t(6, h = C.onClose), "cancelText" in C && t(3, u = C.cancelText), "okText" in C && t(4, g = C.okText), "theme" in C && t(5, d = C.theme), "$$scope" in C && t(7, s = C.$$scope);
490
490
  }, [r, o, l, u, g, d, h, s, n];
491
491
  }
492
- class wt extends be {
492
+ class wt extends Ne {
493
493
  constructor(e) {
494
494
  super(), Pe(this, e, ft, yt, ve, {
495
495
  onCancel: 0,
@@ -751,7 +751,7 @@ function mt(i, e, t) {
751
751
  E
752
752
  ];
753
753
  }
754
- class kt extends be {
754
+ class kt extends Ne {
755
755
  constructor(e) {
756
756
  super(), Pe(this, e, mt, Et, ve, {
757
757
  data: 0,
@@ -775,7 +775,7 @@ class It {
775
775
  props: v(S({}, e), {
776
776
  onCancel: (s) => {
777
777
  n({
778
- code: -1,
778
+ code: "ON_CANCEL",
779
779
  msg: s
780
780
  });
781
781
  },
@@ -1003,6 +1003,9 @@ class At {
1003
1003
  msg: "暂无证书"
1004
1004
  });
1005
1005
  }));
1006
+ a(this, "getClientVersion", () => c(this, null, function* () {
1007
+ return yield this.sendMessage("GZCA_GetClientVersion");
1008
+ }));
1006
1009
  a(this, "getCertList", (e) => c(this, null, function* () {
1007
1010
  return yield this.sendMessage(
1008
1011
  "GZCA_GetCertList",
@@ -1301,6 +1304,11 @@ const $ = class $ {
1301
1304
  CertType: ae
1302
1305
  });
1303
1306
  }));
1307
+ a(this, "getClientVersion", () => c(this, null, function* () {
1308
+ var t;
1309
+ const e = yield (t = this.coreInstance) == null ? void 0 : t.getClientVersion();
1310
+ return e == null ? void 0 : e[0];
1311
+ }));
1304
1312
  a(this, "base64Encode", (e) => {
1305
1313
  var t;
1306
1314
  return (t = this.coreInstance) == null ? void 0 : t.base64Encode(e.Data);
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(_,I){typeof exports=="object"&&typeof module!="undefined"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):(_=typeof globalThis!="undefined"?globalThis:_||self,I(_.GWS_CLIENT={}))})(this,function(_){"use strict";var pt=Object.defineProperty,Dt=Object.defineProperties;var At=Object.getOwnPropertyDescriptors;var Me=Object.getOwnPropertySymbols;var Bt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable;var ge=(_,I,p)=>I in _?pt(_,I,{enumerable:!0,configurable:!0,writable:!0,value:p}):_[I]=p,S=(_,I)=>{for(var p in I||(I={}))Bt.call(I,p)&&ge(_,p,I[p]);if(Me)for(var p of Me(I))Pt.call(I,p)&&ge(_,p,I[p]);return _},D=(_,I)=>Dt(_,At(I));var a=(_,I,p)=>ge(_,typeof I!="symbol"?I+"":I,p);var c=(_,I,p)=>new Promise((z,J)=>{var ie=k=>{try{T(p.next(k))}catch(H){J(H)}},re=k=>{try{T(p.throw(k))}catch(H){J(H)}},T=k=>k.done?z(k.value):Promise.resolve(k.value).then(ie,re);T((p=p.apply(_,I)).next())});const I=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",p="1",z="2",J="1",ie="2",re="3";var T=(i=>(i.MIN="0",i.LOW="1",i.MIDDLE="2",i.HIGH="3",i))(T||{});const k={LEVEL_1:1,LEVEL_2:2,LEVEL_3:4},H={OPEN:k.LEVEL_1,INTERNAL:k.LEVEL_2|k.LEVEL_1,OMP:k.LEVEL_3|k.LEVEL_2|k.LEVEL_1},Ge="00000001",oe="NO_SEAL_AVAILABLE",Fe="CERTIFICATE_NOT_FOUND",Ve="CLIENT_CONNECTION_FAILED",Ze="ACCESS_DENIED",ye=[{oid:"1.2.86.21.1.3",key:"trustServiceNo"},{oid:"1.2.156.10260.4.1.1",key:"idCardNo"},{oid:"1.2.156.10260.4.1.4",key:"orgCode"}];function He(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var U={},Ce;function Ue(){if(Ce)return U;Ce=1,U.byteLength=l,U.toByteArray=u,U.fromByteArray=C;for(var i=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,r=n.length;s<r;++s)i[s]=n[s],e[n.charCodeAt(s)]=s;e[45]=62,e[95]=63;function o(y){var f=y.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var E=y.indexOf("=");E===-1&&(E=f);var w=E===f?0:4-E%4;return[E,w]}function l(y){var f=o(y),E=f[0],w=f[1];return(E+w)*3/4-w}function h(y,f,E){return(f+E)*3/4-E}function u(y){var f,E=o(y),w=E[0],m=E[1],L=new t(h(y,w,m)),A=0,x=m>0?w-4:w,v;for(v=0;v<x;v+=4)f=e[y.charCodeAt(v)]<<18|e[y.charCodeAt(v+1)]<<12|e[y.charCodeAt(v+2)]<<6|e[y.charCodeAt(v+3)],L[A++]=f>>16&255,L[A++]=f>>8&255,L[A++]=f&255;return m===2&&(f=e[y.charCodeAt(v)]<<2|e[y.charCodeAt(v+1)]>>4,L[A++]=f&255),m===1&&(f=e[y.charCodeAt(v)]<<10|e[y.charCodeAt(v+1)]<<4|e[y.charCodeAt(v+2)]>>2,L[A++]=f>>8&255,L[A++]=f&255),L}function g(y){return i[y>>18&63]+i[y>>12&63]+i[y>>6&63]+i[y&63]}function d(y,f,E){for(var w,m=[],L=f;L<E;L+=3)w=(y[L]<<16&16711680)+(y[L+1]<<8&65280)+(y[L+2]&255),m.push(g(w));return m.join("")}function C(y){for(var f,E=y.length,w=E%3,m=[],L=16383,A=0,x=E-w;A<x;A+=L)m.push(d(y,A,A+L>x?x:A+L));return w===1?(f=y[E-1],m.push(i[f>>2]+i[f<<4&63]+"==")):w===2&&(f=(y[E-2]<<8)+y[E-1],m.push(i[f>>10]+i[f>>4&63]+i[f<<2&63]+"=")),m.join("")}return U}var je=Ue();const fe=He(je);class Re{constructor(){a(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const n=this.deps.get(e);n==null||n(t)}}(function(){try{var i=document.createElement("style");i.appendChild(document.createTextNode("button.svelte-16iv9d0{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-16iv9d0{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-16iv9d0{background-color:#fff;padding:1.25rem;border-radius:.3125rem;width:40%}.model-title.svelte-16iv9d0{color:#303133;font-size:1.125rem;margin-bottom:1.125rem}.modal-visible.svelte-16iv9d0{display:flex}.modal-footer.svelte-16iv9d0{display:flex;align-items:center;justify-content:flex-end;margin-top:1rem}.modal-btn.svelte-16iv9d0{padding:.5rem .9375rem;border-radius:.25rem;font-size:.875rem;border:.0625rem solid #dcdfe6}.success.svelte-16iv9d0{margin-left:.75rem;color:#fff}.slot.svelte-16iv9d0{max-height:12.5rem;overflow-y:scroll}.slot.svelte-16iv9d0::-webkit-scrollbar{display:none}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:11.25rem;height:11.25rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.0625rem solid #ccc;margin-top:.625rem;margin-right:.625rem;border-radius:.25rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:6.25rem;height:6.25rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.625rem;color:#333}.cert-item.svelte-1kh75ag.svelte-1kh75ag{padding:1rem;display:flex;align-items:center;cursor:pointer;border-bottom:.0625rem solid #ebeef5;font-size:1rem}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag{word-break:break-all;color:#373a40}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag:nth-child(1){padding-right:.5rem}.cert-item-selected.svelte-1kh75ag.svelte-1kh75ag{background-color:#f1f1f1}.cert-item-first.svelte-1kh75ag.svelte-1kh75ag{border-top:.0625rem solid #ebeef5}")),document.head.appendChild(i)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Ke=Object.defineProperty,We=(i,e,t)=>e in i?Ke(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,we=(i,e,t)=>We(i,typeof e!="symbol"?e+"":e,t);function ae(){}function ze(i,e){for(const t in e)i[t]=e[t];return i}function Se(i){return i()}function Ee(){return Object.create(null)}function j(i){i.forEach(Se)}function Q(i){return typeof i=="function"}function me(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function Je(i){return Object.keys(i).length===0}function Qe(i,e,t,n){if(i){const s=ke(i,e,t,n);return i[0](s)}}function ke(i,e,t,n){return i[1]&&n?ze(t.ctx.slice(),i[1](n(e))):t.ctx}function Ye(i,e,t,n){if(i[2]&&n){const s=i[2](n(t));if(e.dirty===void 0)return s;if(typeof s=="object"){const r=[],o=Math.max(e.dirty.length,s.length);for(let l=0;l<o;l+=1)r[l]=e.dirty[l]|s[l];return r}return e.dirty|s}return e.dirty}function qe(i,e,t,n,s,r){if(s){const o=ke(e,t,n,r);i.p(o,s)}}function Xe(i){if(i.ctx.length>32){const e=[],t=i.ctx.length/32;for(let n=0;n<t;n++)e[n]=-1;return e}return-1}function Ie(i){return i==null?"":i}function B(i,e){i.appendChild(e)}function Y(i,e,t){i.insertBefore(e,t||null)}function R(i){i.parentNode&&i.parentNode.removeChild(i)}function ve(i,e){for(let t=0;t<i.length;t+=1)i[t]&&i[t].d(e)}function N(i){return document.createElement(i)}function O(i){return document.createTextNode(i)}function q(){return O(" ")}function et(){return O("")}function X(i,e,t,n){return i.addEventListener(e,t,n),()=>i.removeEventListener(e,t,n)}function P(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function tt(i){return Array.from(i.childNodes)}function ee(i,e){e=""+e,i.data!==e&&(i.data=e)}function te(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,"")}let ce;function K(i){ce=i}const M=[],Le=[];let G=[];const _e=[],nt=Promise.resolve();let le=!1;function st(){le||(le=!0,nt.then(pe))}function ue(i){G.push(i)}const he=new Set;let F=0;function pe(){if(F!==0)return;const i=ce;do{try{for(;F<M.length;){const e=M[F];F++,K(e),it(e.$$)}}catch(e){throw M.length=0,F=0,e}for(K(null),M.length=0,F=0;Le.length;)Le.pop()();for(let e=0;e<G.length;e+=1){const t=G[e];he.has(t)||(he.add(t),t())}G.length=0}while(M.length);for(;_e.length;)_e.pop()();le=!1,he.clear(),K(i)}function it(i){if(i.fragment!==null){i.update(),j(i.before_update);const e=i.dirty;i.dirty=[-1],i.fragment&&i.fragment.p(i.ctx,e),i.after_update.forEach(ue)}}function rt(i){const e=[],t=[];G.forEach(n=>i.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),G=e}const ne=new Set;let ot;function de(i,e){i&&i.i&&(ne.delete(i),i.i(e))}function De(i,e,t,n){if(i&&i.o){if(ne.has(i))return;ne.add(i),ot.c.push(()=>{ne.delete(i)}),i.o(e)}}function se(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function at(i){i&&i.c()}function Ae(i,e,t){const{fragment:n,after_update:s}=i.$$;n&&n.m(e,t),ue(()=>{const r=i.$$.on_mount.map(Se).filter(Q);i.$$.on_destroy?i.$$.on_destroy.push(...r):j(r),i.$$.on_mount=[]}),s.forEach(ue)}function Be(i,e){const t=i.$$;t.fragment!==null&&(rt(t.after_update),j(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function ct(i,e){i.$$.dirty[0]===-1&&(M.push(i),st(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<<e%31}function Pe(i,e,t,n,s,r,o=null,l=[-1]){const h=ce;K(i);const u=i.$$={fragment:null,ctx:[],props:r,update:ae,not_equal:s,bound:Ee(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(h?h.$$.context:[])),callbacks:Ee(),dirty:l,skip_bound:!1,root:e.target||h.$$.root};o&&o(u.root);let g=!1;if(u.ctx=t?t(i,e.props||{},(d,C,...y)=>{const f=y.length?y[0]:C;return u.ctx&&s(u.ctx[d],u.ctx[d]=f)&&(!u.skip_bound&&u.bound[d]&&u.bound[d](f),g&&ct(i,d)),C}):[],u.update(),g=!0,j(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){const d=tt(e.target);u.fragment&&u.fragment.l(d),d.forEach(R)}else u.fragment&&u.fragment.c();e.intro&&de(i.$$.fragment),Ae(i,e.target,e.anchor),pe()}K(h)}class be{constructor(){we(this,"$$"),we(this,"$$set")}$destroy(){Be(this,1),this.$destroy=ae}$on(e,t){if(!Q(t))return ae;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}$set(e){this.$$set&&!Je(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const lt="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(lt);function ut(i){let e,t,n,s=(i[1]||"标题")+"",r,o,l,h,u,g,d=(i[3]||"取消")+"",C,y,f,E=(i[4]||"确认")+"",w,m,L,A;const x=i[8].default,v=Qe(x,i,i[7],null);return{c(){e=N("div"),t=N("div"),n=N("div"),r=O(s),o=q(),l=N("div"),v&&v.c(),h=q(),u=N("div"),g=N("button"),C=O(d),y=q(),f=N("button"),w=O(E),P(n,"class","model-title svelte-16iv9d0"),P(l,"class","slot svelte-16iv9d0"),P(g,"class","modal-btn svelte-16iv9d0"),P(f,"class","modal-btn success svelte-16iv9d0"),te(f,"background-color",i[5]),P(u,"class","modal-footer svelte-16iv9d0"),P(t,"class","modal-content svelte-16iv9d0"),P(e,"class","modal-background modal-visible svelte-16iv9d0")},m(b,$){Y(b,e,$),B(e,t),B(t,n),B(n,r),B(t,o),B(t,l),v&&v.m(l,null),B(t,h),B(t,u),B(u,g),B(g,C),B(u,y),B(u,f),B(f,w),m=!0,L||(A=[X(g,"click",function(){Q(i[0])&&i[0].apply(this,arguments)}),X(f,"click",function(){Q(i[2])&&i[2].apply(this,arguments)}),X(t,"click",ht)],L=!0)},p(b,[$]){i=b,(!m||$&2)&&s!==(s=(i[1]||"标题")+"")&&ee(r,s),v&&v.p&&(!m||$&128)&&qe(v,x,i,i[7],m?Ye(x,i[7],$,null):Xe(i[7]),null),(!m||$&8)&&d!==(d=(i[3]||"取消")+"")&&ee(C,d),(!m||$&16)&&E!==(E=(i[4]||"确认")+"")&&ee(w,E),(!m||$&32)&&te(f,"background-color",i[5])},i(b){m||(de(v,b),m=!0)},o(b){De(v,b),m=!1},d(b){b&&R(e),v&&v.d(b),L=!1,j(A)}}}const ht=i=>i.stopPropagation();function dt(i,e,t){let{$$slots:n={},$$scope:s}=e,{onCancel:r}=e,{title:o}=e,{onOk:l}=e,{onClose:h}=e,{cancelText:u}=e,{okText:g}=e,{theme:d}=e;return i.$$set=C=>{"onCancel"in C&&t(0,r=C.onCancel),"title"in C&&t(1,o=C.title),"onOk"in C&&t(2,l=C.onOk),"onClose"in C&&t(6,h=C.onClose),"cancelText"in C&&t(3,u=C.cancelText),"okText"in C&&t(4,g=C.okText),"theme"in C&&t(5,d=C.theme),"$$scope"in C&&t(7,s=C.$$scope)},[r,o,l,u,g,d,h,s,n]}class gt extends be{constructor(e){super(),Pe(this,e,dt,ut,me,{onCancel:0,title:1,onOk:2,onClose:6,cancelText:3,okText:4,theme:5})}}function Ne(i,e,t){const n=i.slice();return n[13]=e[t],n[15]=t,n}function xe(i,e,t){const n=i.slice();return n[16]=e[t],n}function $e(i){let e,t=(i[16].format?i[16].format(i[13]):i[13][i[16].key])+"",n;return{c(){e=N("div"),n=O(t),P(e,"class","svelte-1kh75ag"),te(e,"width",`${100/i[1].length}%`)},m(s,r){Y(s,e,r),B(e,n)},p(s,r){r&3&&t!==(t=(s[16].format?s[16].format(s[13]):s[13][s[16].key])+"")&&ee(n,t),r&2&&te(e,"width",`${100/s[1].length}%`)},d(s){s&&R(e)}}}function Te(i){let e,t,n,s,r,o=se(i[1]),l=[];for(let u=0;u<o.length;u+=1)l[u]=$e(xe(i,o,u));function h(){return i[12](i[15])}return{c(){e=N("div");for(let u=0;u<l.length;u+=1)l[u].c();t=q(),P(e,"class",n=Ie(`cert-item ${i[15]===0?"cert-item-first":""} ${i[15]===i[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")},m(u,g){Y(u,e,g);for(let d=0;d<l.length;d+=1)l[d]&&l[d].m(e,null);B(e,t),s||(r=X(e,"click",h),s=!0)},p(u,g){if(i=u,g&3){o=se(i[1]);let d;for(d=0;d<o.length;d+=1){const C=xe(i,o,d);l[d]?l[d].p(C,g):(l[d]=$e(C),l[d].c(),l[d].m(e,t))}for(;d<l.length;d+=1)l[d].d(1);l.length=o.length}g&128&&n!==(n=Ie(`cert-item ${i[15]===0?"cert-item-first":""} ${i[15]===i[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")&&P(e,"class",n)},d(u){u&&R(e),ve(l,u),s=!1,r()}}}function yt(i){let e,t=se(i[0]),n=[];for(let s=0;s<t.length;s+=1)n[s]=Te(Ne(i,t,s));return{c(){for(let s=0;s<n.length;s+=1)n[s].c();e=et()},m(s,r){for(let o=0;o<n.length;o+=1)n[o]&&n[o].m(s,r);Y(s,e,r)},p(s,r){if(r&131){t=se(s[0]);let o;for(o=0;o<t.length;o+=1){const l=Ne(s,t,o);n[o]?n[o].p(l,r):(n[o]=Te(l),n[o].c(),n[o].m(e.parentNode,e))}for(;o<n.length;o+=1)n[o].d(1);n.length=t.length}},d(s){s&&R(e),ve(n,s)}}}function Ct(i){let e,t;return e=new gt({props:{onOk:i[9],onClose:i[2],onCancel:i[8],cancelText:i[3],okText:i[4],title:i[6],theme:i[5],$$slots:{default:[yt]},$$scope:{ctx:i}}}),{c(){at(e.$$.fragment)},m(n,s){Ae(e,n,s),t=!0},p(n,[s]){const r={};s&4&&(r.onClose=n[2]),s&8&&(r.cancelText=n[3]),s&16&&(r.okText=n[4]),s&64&&(r.title=n[6]),s&32&&(r.theme=n[5]),s&524419&&(r.$$scope={dirty:s,ctx:n}),e.$set(r)},i(n){t||(de(e.$$.fragment,n),t=!0)},o(n){De(e.$$.fragment,n),t=!1},d(n){Be(e,n)}}}function ft(i,e,t){let{data:n=[]}=e,{columns:s=[]}=e,{onCancel:r}=e,{onOk:o}=e,{onClose:l}=e,{cancelText:h=""}=e,{okText:u=""}=e,{theme:g="#409eff"}=e,{title:d=""}=e,C=0;const y=()=>{r(`${d}失败`),l==null||l()},f=()=>{o==null||o(n[C]),l==null||l()},E=w=>t(7,C=w);return i.$$set=w=>{"data"in w&&t(0,n=w.data),"columns"in w&&t(1,s=w.columns),"onCancel"in w&&t(10,r=w.onCancel),"onOk"in w&&t(11,o=w.onOk),"onClose"in w&&t(2,l=w.onClose),"cancelText"in w&&t(3,h=w.cancelText),"okText"in w&&t(4,u=w.okText),"theme"in w&&t(5,g=w.theme),"title"in w&&t(6,d=w.title)},[n,s,l,h,u,g,d,C,y,f,r,o,E]}class wt extends be{constructor(e){super(),Pe(this,e,ft,Ct,me,{data:0,columns:1,onCancel:10,onOk:11,onClose:2,cancelText:3,okText:4,theme:5,title:6})}}class St{constructor(){a(this,"modalInstance",{current:null});a(this,"open",e=>new Promise((t,n)=>{this.modalInstance.current=new wt({target:document.body,props:D(S({},e),{onCancel:s=>{n({code:-1,msg:s})},onOk:s=>{t(s)},onClose:()=>{this.close()}})})}));a(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const W=new St;function Et(i=32,e=!0,t=0){const n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),s=[];if(t=t||n.length,i)for(let r=0;r<i;r++)s[r]=n[0|Math.random()*t];else{let r;s[8]=s[13]=s[18]=s[23]="-",s[14]="4";for(let o=0;o<36;o++)s[o]||(r=0|Math.random()*16,s[o]=n[o===19?r&3|8:r])}return e?(s.shift(),`u${s.join("")}`):s.join("")}function mt(i){const e=new Uint8Array(i),t=new TextDecoder("gbk"),n=new TextDecoder("latin1").decode(e);try{const s=JSON.parse(n),r=o=>{if(typeof o=="string"){const l=new Uint8Array(o.length);for(let h=0;h<o.length;h++)l[h]=o.charCodeAt(h)&255;return t.decode(l)}if(Array.isArray(o))return o.map(r);if(o!==null&&typeof o=="object"){const l={},h=o;for(const u in o)if(Object.prototype.hasOwnProperty.call(h,u)){const g=r(u);l[g]=r(h[u])}return l}return o};return r(s)}catch(s){throw console.error("GBK JSON 修复流程失败:",s),s}}const kt=[{key:"CN"},{format:i=>`${i.DevClass}(${i.sn})`}],It=[{key:"SealId"},{key:"Vid"},{format:i=>`${i.FileName}(${i.FileSize}B)`}],Oe=[{key:"SealId"}],vt=[{key:"manu"},{key:"sn"}];class Lt{constructor(e){a(this,"socketInstance",null);a(this,"eventBus",new Re);a(this,"scene");a(this,"isRememberPin",!1);a(this,"pinPolicy");a(this,"socketConfig",null);a(this,"isConnecting",!1);a(this,"messageQueue",[]);a(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});a(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});a(this,"sendMessage",(e,t,n)=>new Promise((s,r)=>{var l;const o=()=>{var d,C;if(((d=this.socketInstance)==null?void 0:d.readyState)!==WebSocket.OPEN){r({errCode:Ve,msg:"数字证书客户端连接失败"});return}const h=Et(),u=y=>{y.success?s(y.data):r(y)},g={function:e,args:t?[t]:[],msgid:h};(C=this.socketInstance)==null||C.send(JSON.stringify(g)),this.eventBus.on(e,u),this.eventBus.on(h,u)};if(n&&(this.scene&n)!==n){r({errCode:Ze,msg:"无权限执行此操作"});return}if(((l=this.socketInstance)==null?void 0:l.readyState)===WebSocket.OPEN){o();return}this.messageQueue.push(o),this.isConnecting||this.initSocket(this.socketConfig)}));a(this,"flushMsgQueue",()=>{var e;(e=this.messageQueue)==null||e.forEach(t=>t()),this.messageQueue=[]});a(this,"handleEventData",e=>c(this,null,function*(){var t,n,s,r,o,l,h,u;if(e.data instanceof Blob){const g=yield e.data.arrayBuffer(),C=navigator.userAgent.includes("Windows")?mt(g):JSON.parse(new TextDecoder().decode(g)),y={success:(t=C.result)==null?void 0:t.success,msg:(n=C.result)==null?void 0:n.msg,errCode:(s=C.result)==null?void 0:s.errCode,data:C.data,type:(r=C.result)==null?void 0:r.event},f=(o=C.result)==null?void 0:o.function,E=(l=C.result)==null?void 0:l.msgid;E?this.eventBus.emit(E,y):this.eventBus.emit(f,y),(u=(h=this.socketConfig)==null?void 0:h.onMessage)==null||u.call(h,y)}}));a(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return fe.fromByteArray(t)});a(this,"base64Decode",e=>{const t=fe.toByteArray(e);return new TextDecoder().decode(t)});a(this,"changeIsRememberPin",e=>c(this,null,function*(){this.isRememberPin=e}));a(this,"changePinPolicy",e=>c(this,null,function*(){this.pinPolicy=e}));a(this,"checkCertIsLogin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));a(this,"addUkeyEvents",()=>c(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:Ge}),this.eventBus.on("GZCA_OnDeviceChange",e=>{var t,n,s;(s=(t=this.socketConfig)==null?void 0:t.onUkeyChange)==null||s.call(t,D(S({},e),{data:(n=e.data)==null?void 0:n[0]}))})}));a(this,"ensureCertLogin",e=>c(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e.ContainerName});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e.ContainerName,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));a(this,"verifyPin",e=>c(this,null,function*(){var t;console.log("params2",e),yield this.sendMessage("GZCA_Login",{ContainerName:e.ContainerName,IsLogin:e.UserPin?"Y":"N",UserPin:(t=e.UserPin)!=null?t:"123456",PinPolicy:this.pinPolicy})}));a(this,"getCert",(e,t,n)=>c(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&n&&(yield this.ensureCertLogin({ContainerName:s.ContainerName})),s}));a(this,"chooseCert",e=>c(this,null,function*(){var s;const t=yield this.getCertList(e);return t!=null&&t.length?(t==null?void 0:t.length)===1?t[0]:yield W.open({title:"选择证书",data:t,columns:kt,theme:(s=this.socketConfig)==null?void 0:s.theme}):Promise.reject({errCode:Fe,msg:"暂无证书"})}));a(this,"getCertList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));a(this,"pkcs1Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"batchPkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_BatchPkcs1SignDataEx",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs1VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));a(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));a(this,"getSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",S({IsLogin:this.getIsLogin()},e!=null?e:{}),k.LEVEL_2)}));a(this,"writeSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_WriteSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),k.LEVEL_2)}));a(this,"deleteSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DeleteSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),k.LEVEL_2)}));a(this,"getSealInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ReadSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),k.LEVEL_2)}));a(this,"getTPSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicList",S({IsLogin:this.getIsLogin()},e!=null?e:{}),k.LEVEL_2)}));a(this,"getTPSealPic",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicData",S({IsLogin:this.getIsLogin()},e!=null?e:{}),k.LEVEL_2)}));a(this,"sm2SignPreprocess1",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));a(this,"sm2SignPreprocess2",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));a(this,"pkcs1HashSign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs1HashVerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));a(this,"pkcs7Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",S({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs7VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));a(this,"sm3Hash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));a(this,"sm3HexHash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));a(this,"sm3FileHash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));a(this,"sm3HashEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));a(this,"pkcs7Encryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));a(this,"pkcs7Decryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));a(this,"pkcs7FileEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeSealFileEx_qyzc",e)}));a(this,"pkcs7FileDecryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeOpenFileEx_qyzc",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));a(this,"asymmetricEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));a(this,"asymmetricDecryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));a(this,"sm4Encryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));a(this,"sm4Decryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));a(this,"getCertInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));a(this,"getCertInfoByOid",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));a(this,"getSealVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealIssuer",e,k.LEVEL_2)}));a(this,"deleteAllSealByVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ClearSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),k.LEVEL_2)}));a(this,"applyCert",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ApplyCert",{manu:e.manu,sn:e.sn,keyid:e.ContainerName,type:e.type,url:e.url},k.LEVEL_3)}));a(this,"resetPin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_UnblockUserPin",S({},e!=null?e:{}),k.LEVEL_3)}));a(this,"getUKeyList",()=>c(this,null,function*(){return yield this.sendMessage("GetUKeyList",void 0,k.LEVEL_3)}));a(this,"getUKeyInfo",e=>c(this,null,function*(){return yield this.sendMessage("GetUKeyID",e!=null?e:{},k.LEVEL_3)}));var t,n,s;this.socketConfig=e,this.initSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.scene=(n=e.scene)!=null?n:H.OPEN,this.pinPolicy=(s=e.pinPolicy)!=null?s:T.MIN}initSocket(e){this.isConnecting=!0;const t=new WebSocket(e.url);t.onerror=n=>{var s;this.isConnecting=!1,(s=e.onError)==null||s.call(e,n),this.flushMsgQueue()},t.onopen=n=>{var s;this.isConnecting=!1,(s=e.onOpen)==null||s.call(e,n),e.onUkeyChange&&this.addUkeyEvents(),this.flushMsgQueue()},t.onmessage=n=>{this.handleEventData(n)},t.onclose=n=>{var s;this.isConnecting=!1,(s=e.onClose)==null||s.call(e,n)},this.socketInstance=t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const Z=class Z{constructor(e){a(this,"coreInstance",null);a(this,"gwsConfig",{});a(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new Lt(D(S({},e!=null?e:{}),{url:I}))});a(this,"appendCertBase64",(e,t=!0)=>c(this,null,function*(){if(e.CertB64)return e;const n=t?yield this.getSignatureCert():yield this.getEncryptionCert();return D(S({},e!=null?e:{}),{CertB64:n==null?void 0:n.CertB64})}));a(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});a(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});a(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});a(this,"verifyPin",(e,t)=>c(this,null,function*(){var s,r;const n=yield this.getSignatureCert(t);return(r=this.coreInstance)==null?void 0:r.verifyPin({ContainerName:(s=n==null?void 0:n.ContainerName)!=null?s:"",UserPin:e==null?void 0:e.UserPin})}));a(this,"ensureCertLogin",e=>c(this,null,function*(){var s,r;const t=yield this.getSignatureCert(e);return yield(r=this.coreInstance)==null?void 0:r.ensureCertLogin({ContainerName:(s=t==null?void 0:t.ContainerName)!=null?s:""})}));a(this,"getSignatureCert",(e,t=!0)=>c(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:p},e,t)}));a(this,"getSignatureCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:p})}));a(this,"getEncryptionCert",(e,t=!0)=>c(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:z},e,t)}));a(this,"getEncryptionCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:z})}));a(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});a(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});a(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});a(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});a(this,"pkcs1Sign",(e,t)=>c(this,null,function*(){var r,o,l;const n=yield this.getSignatureCert(t),s=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(D(S({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""}));return(l=s==null?void 0:s[0])==null?void 0:l.SignData}));a(this,"pkcs1VerifySignature",e=>c(this,null,function*(){var s;const t=yield this.appendCertBase64(e),n=yield(s=this.coreInstance)==null?void 0:s.pkcs1VerifySignature(t);return Array.isArray(n)}));a(this,"pkcs1Base64Sign",(e,t)=>c(this,null,function*(){var o,l,h,u,g;const n=yield this.getSignatureCert(t),s=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64Sign(D(S({},e!=null?e:{}),{ContainerName:(h=n==null?void 0:n.ContainerName)!=null?h:"",DataB64:s}));return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));a(this,"batchPkcs1Base64Sign",(e,t)=>c(this,null,function*(){var g,d,C,y,f,E;const n="|",s=(d=e.DataB64)!=null?d:(g=e.Data)==null?void 0:g.map(w=>this.base64Encode({Data:w})),r=yield this.getSignatureCert(t);let o="";o=Array.isArray(s)?s==null?void 0:s.map((w,m)=>`${m}:${w}`).join(n):"";const l=yield(y=this.coreInstance)==null?void 0:y.batchPkcs1Base64Sign({ContainerName:(C=r==null?void 0:r.ContainerName)!=null?C:"",DataB64:o}),h=(E=(f=l==null?void 0:l[0])==null?void 0:f.SignData)==null?void 0:E.split(n),u=[];return h.forEach(w=>{const m=w.split(":"),L=Number(m[0]),A=m[1];u[L]=A}),u}));a(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){var r,o,l;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=yield this.appendCertBase64(e);return!!(yield(l=this.coreInstance)==null?void 0:l.pkcs1Base64VerifySignature({CertB64:n.CertB64,DataB64:t,SignData:n.SignData}))}));a(this,"writeSeal",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return!!(yield(o=this.coreInstance)==null?void 0:o.writeSeal(D(S({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""})))}));a(this,"deleteSeal",(e,t)=>c(this,null,function*(){var h,u,g;const n=yield this.getSignatureCert(t),s=yield this.getSealList(e,n);if(!(s!=null&&s.length))return Promise.reject({errCode:oe,msg:"暂无印章"});const r=yield W.open({title:"删除印章",data:s,columns:Oe,okText:"删除"}),o=(h=r==null?void 0:r.SealId)!=null?h:"";return!!(yield(g=this.coreInstance)==null?void 0:g.deleteSeal(S({ContainerName:(u=n==null?void 0:n.ContainerName)!=null?u:"",SealId:o},e!=null?e:{})))}));a(this,"deleteSealById",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return!!(yield(o=this.coreInstance)==null?void 0:o.deleteSeal(D(S({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""})))}));a(this,"getSealList",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return yield(o=this.coreInstance)==null?void 0:o.getSealList(S({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""},e!=null?e:{}))}));a(this,"getSealInfo",(e,t)=>c(this,null,function*(){var l,h,u,g;const n=yield this.getSignatureCert(t),s=yield this.getSealList(e,n);if(!(s!=null&&s.length))return Promise.reject({errCode:oe,msg:"暂无印章"});const r=(s==null?void 0:s.length)>1?yield W.open({title:"选择印章",data:s,columns:Oe,theme:(l=this.gwsConfig)==null?void 0:l.theme}):s==null?void 0:s[0],o=yield(g=this.coreInstance)==null?void 0:g.getSealInfo({ContainerName:(h=n==null?void 0:n.ContainerName)!=null?h:"",SealId:(u=r==null?void 0:r.SealId)!=null?u:""});return o==null?void 0:o[0]}));a(this,"getTPSealList",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return yield(o=this.coreInstance)==null?void 0:o.getTPSealList(S({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""},e!=null?e:{}))}));a(this,"getTPSeal",(e,t)=>c(this,null,function*(){var r;const n=yield this.getTPSealList(e,t);return n!=null&&n.length?(n==null?void 0:n.length)===1?n==null?void 0:n[0]:yield W.open({title:"选择印章",data:n,columns:It,theme:(r=this.gwsConfig)==null?void 0:r.theme}):Promise.reject({errCode:oe,msg:"暂无印章"})}));a(this,"getTPSealPic",(e,t,n)=>c(this,null,function*(){var l,h;const s=yield this.getSignatureCert(t),r=n||(yield this.getTPSeal(e,t)),o=yield(h=this.coreInstance)==null?void 0:h.getTPSealPic(D(S(S({ContainerName:(l=s==null?void 0:s.ContainerName)!=null?l:""},r!=null?r:{}),e!=null?e:{}),{FileSize:String(r==null?void 0:r.FileSize)}));return o==null?void 0:o[0]}));a(this,"sm2SignPreprocess1",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e),n=yield(s=this.coreInstance)==null?void 0:s.sm2SignPreprocess1(t);return(r=n==null?void 0:n[0])==null?void 0:r.Z}));a(this,"sm2SignPreprocess2",e=>c(this,null,function*(){var r,o;const t=this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=yield this.appendCertBase64(e),s=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:n.CertB64,DataB64:t});return s==null?void 0:s[0].H}));a(this,"pkcs1HashSign",(e,t)=>c(this,null,function*(){var r,o,l,h;const n=yield this.getSignatureCert(t),s=yield(l=this.coreInstance)==null?void 0:l.pkcs1HashSign({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:"",DataB64:e.DataB64,HashAlg:(o=e.HashAlg)!=null?o:"sm3"});return(h=s==null?void 0:s[0])==null?void 0:h.SignData}));a(this,"pkcs1HashVerifySignature",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e);return!!(yield(r=this.coreInstance)==null?void 0:r.pkcs1HashVerifySignature(D(S({},t),{HashAlg:(s=t.HashAlg)!=null?s:"sm3"})))}));a(this,"pkcs7Sign",(e,t)=>c(this,null,function*(){var o,l,h,u,g;const n=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=yield this.getSignatureCert(t),r=yield(u=this.coreInstance)==null?void 0:u.pkcs7Sign(D(S({},e!=null?e:{}),{ContainerName:(h=s==null?void 0:s.ContainerName)!=null?h:"",DataB64:n}));return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));a(this,"pkcs7VerifySignature",e=>c(this,null,function*(){var s,r,o;const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(s=e.Data)!=null?s:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));a(this,"sm3Hash",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm3Hash(e);return(s=t==null?void 0:t[0])==null?void 0:s.HashB64}));a(this,"sm3HexHash",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm3HexHash(e);return(s=t==null?void 0:t[0])==null?void 0:s.HashB64}));a(this,"sm3FileHash",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm3FileHash(e);return(s=t==null?void 0:t[0])==null?void 0:s.HashB64}));a(this,"sm3HashEncryption",e=>c(this,null,function*(){var r,o,l,h,u,g;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=(h=e.KeyB64)!=null?h:this.base64Encode({Data:(l=e.Key)!=null?l:""}),s=yield(u=this.coreInstance)==null?void 0:u.sm3HashEncryption({dataB64:t,keyB64:n,alg:"sm3"});return(g=s==null?void 0:s[0])==null?void 0:g.DataB64}));a(this,"pkcs7Encryption",e=>c(this,null,function*(){var s,r,o,l;if(!e.CertB64List){const h=yield this.getEncryptionCert();e.CertB64List=h==null?void 0:h.CertB64}const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(s=e.Data)!=null?s:""}),n=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(l=n==null?void 0:n[0])==null?void 0:l.DataB64}));a(this,"pkcs7Decryption",e=>c(this,null,function*(){var r,o;const t=yield this.getEncryptionCert(),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7Decryption(D(S({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),s=(o=n==null?void 0:n[0])==null?void 0:o.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:s}):s}));a(this,"pkcs7FileEncryption",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e,!1),n=yield(s=this.coreInstance)==null?void 0:s.pkcs7FileEncryption(t);return(r=n==null?void 0:n[0])==null?void 0:r.DataB64}));a(this,"pkcs7FileDecryption",e=>c(this,null,function*(){var s,r,o;const t=yield this.getEncryptionCert(),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7FileDecryption({SrcFile:e.SrcFile,DstFile:(s=e.DstFile)!=null?s:e.SrcFile.slice(0,-4),ContainerName:t==null?void 0:t.ContainerName});return(o=n==null?void 0:n[0])==null?void 0:o.DataB64}));a(this,"asymmetricEncryption",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e,!1),n=yield(s=this.coreInstance)==null?void 0:s.asymmetricEncryption(t);return(r=n==null?void 0:n[0])==null?void 0:r.Data}));a(this,"asymmetricDecryption",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getEncryptionCert(t),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricDecryption(D(S({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return(o=s==null?void 0:s[0])==null?void 0:o.Data}));a(this,"sm4Encryption",e=>c(this,null,function*(){var n;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Encryption(e);return t==null?void 0:t[0]}));a(this,"sm4Decryption",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Decryption(e);return(s=t==null?void 0:t[0])==null?void 0:s.Data}));a(this,"getCertInfo",e=>c(this,null,function*(){var s,r,o,l,h;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(e),n=(r=t==null?void 0:t[0])!=null?r:{};for(let u=0;u<ye.length;u++){const g=ye[u];try{const d=yield(o=this.coreInstance)==null?void 0:o.getCertInfoByOid({Oid:g.oid,CertB64:e.CertB64});n[g.key]=(h=(l=d==null?void 0:d[0])==null?void 0:l.OidValue)==null?void 0:h.replace(/\./g,"")}catch(d){n[g.key]=null}}return n!=null&&n.idCardNo?n!=null&&n.CertSubject.includes("O=")||n.orgCode?n.certCate=ie:n.certCate=J:n.certCate=re,n}));a(this,"getCertInfoByOid",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.getCertInfoByOid(S({},e!=null?e:{}));return(s=t==null?void 0:t[0])==null?void 0:s.OidValue}));a(this,"getSealVendor",e=>c(this,null,function*(){var s;const t=yield this.getSignatureCert(e),n=yield(s=this.coreInstance)==null?void 0:s.getSealVendor({ContainerName:t==null?void 0:t.ContainerName});return n==null?void 0:n[0]}));a(this,"deleteAllSealByVendor",(e,t)=>c(this,null,function*(){var r;const n=yield this.getSignatureCert(t),s=yield(r=this.coreInstance)==null?void 0:r.deleteAllSealByVendor(D(S({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return s==null?void 0:s[0]}));a(this,"getUKey",e=>c(this,null,function*(){var s,r;if(e)return e;const t=yield(s=this.coreInstance)==null?void 0:s.getUKeyList();return yield W.open({title:"选择介质",data:t,columns:vt,theme:(r=this.gwsConfig)==null?void 0:r.theme})}));a(this,"getUKeyList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getUKeyList()}));a(this,"getUKeyInfo",e=>c(this,null,function*(){var s;const t=yield this.getUKey(e),n=yield(s=this.coreInstance)==null?void 0:s.getUKeyInfo({manu:t==null?void 0:t.manu,sn:t==null?void 0:t.sn});return n==null?void 0:n[0]}));a(this,"applyCert",(e,t)=>c(this,null,function*(){var o;const n=yield this.getUKey(t),s=yield this.getUKeyInfo(n);return yield(o=this.coreInstance)==null?void 0:o.applyCert(D(S({},e!=null?e:{}),{manu:s==null?void 0:s.manu,sn:s==null?void 0:s.sn,ContainerName:s==null?void 0:s.keyid}))}));a(this,"resetPin",(e,t)=>c(this,null,function*(){var r;const n=yield this.getSignatureCert(t);return yield(r=this.coreInstance)==null?void 0:r.resetPin(D(S({},e!=null?e:{}),{manu:n==null?void 0:n.manu,sn:n==null?void 0:n.sn,ContainerName:n==null?void 0:n.ContainerName}))}));return Z.instance&&!(e!=null&&e.isCreateNew)?Z.instance:(this.createGwsCore(e),Z.instance=this,this)}};a(Z,"instance",null);let V=Z;function _t(i){return new Promise((e,t)=>{if(V.instance&&!(i!=null&&i.isCreateNew))e(V.instance);else{const n=new V(D(S({},i!=null?i:{}),{onOpen(s){var r;e(n),(r=i==null?void 0:i.onOpen)==null||r.call(i,s)},onClose(s){var r;t(s),(r=i==null?void 0:i.onClose)==null||r.call(i,s)}}))}})}_.GwsService=V,_.createService=_t,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
1
+ (function(_,k){typeof exports=="object"&&typeof module!="undefined"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(_=typeof globalThis!="undefined"?globalThis:_||self,k(_.GWS_CLIENT={}))})(this,function(_){"use strict";var pt=Object.defineProperty,Dt=Object.defineProperties;var At=Object.getOwnPropertyDescriptors;var Me=Object.getOwnPropertySymbols;var Bt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable;var ge=(_,k,p)=>k in _?pt(_,k,{enumerable:!0,configurable:!0,writable:!0,value:p}):_[k]=p,S=(_,k)=>{for(var p in k||(k={}))Bt.call(k,p)&&ge(_,p,k[p]);if(Me)for(var p of Me(k))Pt.call(k,p)&&ge(_,p,k[p]);return _},D=(_,k)=>Dt(_,At(k));var a=(_,k,p)=>ge(_,typeof k!="symbol"?k+"":k,p);var c=(_,k,p)=>new Promise((z,J)=>{var ie=I=>{try{T(p.next(I))}catch(H){J(H)}},re=I=>{try{T(p.throw(I))}catch(H){J(H)}},T=I=>I.done?z(I.value):Promise.resolve(I.value).then(ie,re);T((p=p.apply(_,k)).next())});const k=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",p="1",z="2",J="1",ie="2",re="3";var T=(i=>(i.MIN="0",i.LOW="1",i.MIDDLE="2",i.HIGH="3",i))(T||{});const I={LEVEL_1:1,LEVEL_2:2,LEVEL_3:4},H={OPEN:I.LEVEL_1,INTERNAL:I.LEVEL_2|I.LEVEL_1,OMP:I.LEVEL_3|I.LEVEL_2|I.LEVEL_1},Ge="00000001",oe="NO_SEAL_AVAILABLE",Fe="CERTIFICATE_NOT_FOUND",Ve="CLIENT_CONNECTION_FAILED",Ze="ACCESS_DENIED",ye=[{oid:"1.2.86.21.1.3",key:"trustServiceNo"},{oid:"1.2.156.10260.4.1.1",key:"idCardNo"},{oid:"1.2.156.10260.4.1.4",key:"orgCode"}];function He(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var U={},Ce;function Ue(){if(Ce)return U;Ce=1,U.byteLength=l,U.toByteArray=u,U.fromByteArray=C;for(var i=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,r=n.length;s<r;++s)i[s]=n[s],e[n.charCodeAt(s)]=s;e[45]=62,e[95]=63;function o(y){var f=y.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var E=y.indexOf("=");E===-1&&(E=f);var w=E===f?0:4-E%4;return[E,w]}function l(y){var f=o(y),E=f[0],w=f[1];return(E+w)*3/4-w}function h(y,f,E){return(f+E)*3/4-E}function u(y){var f,E=o(y),w=E[0],m=E[1],L=new t(h(y,w,m)),A=0,x=m>0?w-4:w,v;for(v=0;v<x;v+=4)f=e[y.charCodeAt(v)]<<18|e[y.charCodeAt(v+1)]<<12|e[y.charCodeAt(v+2)]<<6|e[y.charCodeAt(v+3)],L[A++]=f>>16&255,L[A++]=f>>8&255,L[A++]=f&255;return m===2&&(f=e[y.charCodeAt(v)]<<2|e[y.charCodeAt(v+1)]>>4,L[A++]=f&255),m===1&&(f=e[y.charCodeAt(v)]<<10|e[y.charCodeAt(v+1)]<<4|e[y.charCodeAt(v+2)]>>2,L[A++]=f>>8&255,L[A++]=f&255),L}function g(y){return i[y>>18&63]+i[y>>12&63]+i[y>>6&63]+i[y&63]}function d(y,f,E){for(var w,m=[],L=f;L<E;L+=3)w=(y[L]<<16&16711680)+(y[L+1]<<8&65280)+(y[L+2]&255),m.push(g(w));return m.join("")}function C(y){for(var f,E=y.length,w=E%3,m=[],L=16383,A=0,x=E-w;A<x;A+=L)m.push(d(y,A,A+L>x?x:A+L));return w===1?(f=y[E-1],m.push(i[f>>2]+i[f<<4&63]+"==")):w===2&&(f=(y[E-2]<<8)+y[E-1],m.push(i[f>>10]+i[f>>4&63]+i[f<<2&63]+"=")),m.join("")}return U}var je=Ue();const fe=He(je);class Re{constructor(){a(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const n=this.deps.get(e);n==null||n(t)}}(function(){try{var i=document.createElement("style");i.appendChild(document.createTextNode("button.svelte-16iv9d0{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-16iv9d0{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-16iv9d0{background-color:#fff;padding:1.25rem;border-radius:.3125rem;width:40%}.model-title.svelte-16iv9d0{color:#303133;font-size:1.125rem;margin-bottom:1.125rem}.modal-visible.svelte-16iv9d0{display:flex}.modal-footer.svelte-16iv9d0{display:flex;align-items:center;justify-content:flex-end;margin-top:1rem}.modal-btn.svelte-16iv9d0{padding:.5rem .9375rem;border-radius:.25rem;font-size:.875rem;border:.0625rem solid #dcdfe6}.success.svelte-16iv9d0{margin-left:.75rem;color:#fff}.slot.svelte-16iv9d0{max-height:12.5rem;overflow-y:scroll}.slot.svelte-16iv9d0::-webkit-scrollbar{display:none}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:11.25rem;height:11.25rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.0625rem solid #ccc;margin-top:.625rem;margin-right:.625rem;border-radius:.25rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:6.25rem;height:6.25rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.625rem;color:#333}.cert-item.svelte-1kh75ag.svelte-1kh75ag{padding:1rem;display:flex;align-items:center;cursor:pointer;border-bottom:.0625rem solid #ebeef5;font-size:1rem}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag{word-break:break-all;color:#373a40}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag:nth-child(1){padding-right:.5rem}.cert-item-selected.svelte-1kh75ag.svelte-1kh75ag{background-color:#f1f1f1}.cert-item-first.svelte-1kh75ag.svelte-1kh75ag{border-top:.0625rem solid #ebeef5}")),document.head.appendChild(i)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Ke=Object.defineProperty,We=(i,e,t)=>e in i?Ke(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,we=(i,e,t)=>We(i,typeof e!="symbol"?e+"":e,t);function ae(){}function ze(i,e){for(const t in e)i[t]=e[t];return i}function Se(i){return i()}function Ee(){return Object.create(null)}function j(i){i.forEach(Se)}function Q(i){return typeof i=="function"}function me(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function Je(i){return Object.keys(i).length===0}function Qe(i,e,t,n){if(i){const s=Ie(i,e,t,n);return i[0](s)}}function Ie(i,e,t,n){return i[1]&&n?ze(t.ctx.slice(),i[1](n(e))):t.ctx}function Ye(i,e,t,n){if(i[2]&&n){const s=i[2](n(t));if(e.dirty===void 0)return s;if(typeof s=="object"){const r=[],o=Math.max(e.dirty.length,s.length);for(let l=0;l<o;l+=1)r[l]=e.dirty[l]|s[l];return r}return e.dirty|s}return e.dirty}function qe(i,e,t,n,s,r){if(s){const o=Ie(e,t,n,r);i.p(o,s)}}function Xe(i){if(i.ctx.length>32){const e=[],t=i.ctx.length/32;for(let n=0;n<t;n++)e[n]=-1;return e}return-1}function ke(i){return i==null?"":i}function B(i,e){i.appendChild(e)}function Y(i,e,t){i.insertBefore(e,t||null)}function R(i){i.parentNode&&i.parentNode.removeChild(i)}function ve(i,e){for(let t=0;t<i.length;t+=1)i[t]&&i[t].d(e)}function N(i){return document.createElement(i)}function O(i){return document.createTextNode(i)}function q(){return O(" ")}function et(){return O("")}function X(i,e,t,n){return i.addEventListener(e,t,n),()=>i.removeEventListener(e,t,n)}function P(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function tt(i){return Array.from(i.childNodes)}function ee(i,e){e=""+e,i.data!==e&&(i.data=e)}function te(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,"")}let ce;function K(i){ce=i}const M=[],Le=[];let G=[];const _e=[],nt=Promise.resolve();let le=!1;function st(){le||(le=!0,nt.then(pe))}function ue(i){G.push(i)}const he=new Set;let F=0;function pe(){if(F!==0)return;const i=ce;do{try{for(;F<M.length;){const e=M[F];F++,K(e),it(e.$$)}}catch(e){throw M.length=0,F=0,e}for(K(null),M.length=0,F=0;Le.length;)Le.pop()();for(let e=0;e<G.length;e+=1){const t=G[e];he.has(t)||(he.add(t),t())}G.length=0}while(M.length);for(;_e.length;)_e.pop()();le=!1,he.clear(),K(i)}function it(i){if(i.fragment!==null){i.update(),j(i.before_update);const e=i.dirty;i.dirty=[-1],i.fragment&&i.fragment.p(i.ctx,e),i.after_update.forEach(ue)}}function rt(i){const e=[],t=[];G.forEach(n=>i.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),G=e}const ne=new Set;let ot;function de(i,e){i&&i.i&&(ne.delete(i),i.i(e))}function De(i,e,t,n){if(i&&i.o){if(ne.has(i))return;ne.add(i),ot.c.push(()=>{ne.delete(i)}),i.o(e)}}function se(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function at(i){i&&i.c()}function Ae(i,e,t){const{fragment:n,after_update:s}=i.$$;n&&n.m(e,t),ue(()=>{const r=i.$$.on_mount.map(Se).filter(Q);i.$$.on_destroy?i.$$.on_destroy.push(...r):j(r),i.$$.on_mount=[]}),s.forEach(ue)}function Be(i,e){const t=i.$$;t.fragment!==null&&(rt(t.after_update),j(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function ct(i,e){i.$$.dirty[0]===-1&&(M.push(i),st(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<<e%31}function Pe(i,e,t,n,s,r,o=null,l=[-1]){const h=ce;K(i);const u=i.$$={fragment:null,ctx:[],props:r,update:ae,not_equal:s,bound:Ee(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(h?h.$$.context:[])),callbacks:Ee(),dirty:l,skip_bound:!1,root:e.target||h.$$.root};o&&o(u.root);let g=!1;if(u.ctx=t?t(i,e.props||{},(d,C,...y)=>{const f=y.length?y[0]:C;return u.ctx&&s(u.ctx[d],u.ctx[d]=f)&&(!u.skip_bound&&u.bound[d]&&u.bound[d](f),g&&ct(i,d)),C}):[],u.update(),g=!0,j(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){const d=tt(e.target);u.fragment&&u.fragment.l(d),d.forEach(R)}else u.fragment&&u.fragment.c();e.intro&&de(i.$$.fragment),Ae(i,e.target,e.anchor),pe()}K(h)}class be{constructor(){we(this,"$$"),we(this,"$$set")}$destroy(){Be(this,1),this.$destroy=ae}$on(e,t){if(!Q(t))return ae;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}$set(e){this.$$set&&!Je(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const lt="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(lt);function ut(i){let e,t,n,s=(i[1]||"标题")+"",r,o,l,h,u,g,d=(i[3]||"取消")+"",C,y,f,E=(i[4]||"确认")+"",w,m,L,A;const x=i[8].default,v=Qe(x,i,i[7],null);return{c(){e=N("div"),t=N("div"),n=N("div"),r=O(s),o=q(),l=N("div"),v&&v.c(),h=q(),u=N("div"),g=N("button"),C=O(d),y=q(),f=N("button"),w=O(E),P(n,"class","model-title svelte-16iv9d0"),P(l,"class","slot svelte-16iv9d0"),P(g,"class","modal-btn svelte-16iv9d0"),P(f,"class","modal-btn success svelte-16iv9d0"),te(f,"background-color",i[5]),P(u,"class","modal-footer svelte-16iv9d0"),P(t,"class","modal-content svelte-16iv9d0"),P(e,"class","modal-background modal-visible svelte-16iv9d0")},m(b,$){Y(b,e,$),B(e,t),B(t,n),B(n,r),B(t,o),B(t,l),v&&v.m(l,null),B(t,h),B(t,u),B(u,g),B(g,C),B(u,y),B(u,f),B(f,w),m=!0,L||(A=[X(g,"click",function(){Q(i[0])&&i[0].apply(this,arguments)}),X(f,"click",function(){Q(i[2])&&i[2].apply(this,arguments)}),X(t,"click",ht)],L=!0)},p(b,[$]){i=b,(!m||$&2)&&s!==(s=(i[1]||"标题")+"")&&ee(r,s),v&&v.p&&(!m||$&128)&&qe(v,x,i,i[7],m?Ye(x,i[7],$,null):Xe(i[7]),null),(!m||$&8)&&d!==(d=(i[3]||"取消")+"")&&ee(C,d),(!m||$&16)&&E!==(E=(i[4]||"确认")+"")&&ee(w,E),(!m||$&32)&&te(f,"background-color",i[5])},i(b){m||(de(v,b),m=!0)},o(b){De(v,b),m=!1},d(b){b&&R(e),v&&v.d(b),L=!1,j(A)}}}const ht=i=>i.stopPropagation();function dt(i,e,t){let{$$slots:n={},$$scope:s}=e,{onCancel:r}=e,{title:o}=e,{onOk:l}=e,{onClose:h}=e,{cancelText:u}=e,{okText:g}=e,{theme:d}=e;return i.$$set=C=>{"onCancel"in C&&t(0,r=C.onCancel),"title"in C&&t(1,o=C.title),"onOk"in C&&t(2,l=C.onOk),"onClose"in C&&t(6,h=C.onClose),"cancelText"in C&&t(3,u=C.cancelText),"okText"in C&&t(4,g=C.okText),"theme"in C&&t(5,d=C.theme),"$$scope"in C&&t(7,s=C.$$scope)},[r,o,l,u,g,d,h,s,n]}class gt extends be{constructor(e){super(),Pe(this,e,dt,ut,me,{onCancel:0,title:1,onOk:2,onClose:6,cancelText:3,okText:4,theme:5})}}function Ne(i,e,t){const n=i.slice();return n[13]=e[t],n[15]=t,n}function xe(i,e,t){const n=i.slice();return n[16]=e[t],n}function $e(i){let e,t=(i[16].format?i[16].format(i[13]):i[13][i[16].key])+"",n;return{c(){e=N("div"),n=O(t),P(e,"class","svelte-1kh75ag"),te(e,"width",`${100/i[1].length}%`)},m(s,r){Y(s,e,r),B(e,n)},p(s,r){r&3&&t!==(t=(s[16].format?s[16].format(s[13]):s[13][s[16].key])+"")&&ee(n,t),r&2&&te(e,"width",`${100/s[1].length}%`)},d(s){s&&R(e)}}}function Te(i){let e,t,n,s,r,o=se(i[1]),l=[];for(let u=0;u<o.length;u+=1)l[u]=$e(xe(i,o,u));function h(){return i[12](i[15])}return{c(){e=N("div");for(let u=0;u<l.length;u+=1)l[u].c();t=q(),P(e,"class",n=ke(`cert-item ${i[15]===0?"cert-item-first":""} ${i[15]===i[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")},m(u,g){Y(u,e,g);for(let d=0;d<l.length;d+=1)l[d]&&l[d].m(e,null);B(e,t),s||(r=X(e,"click",h),s=!0)},p(u,g){if(i=u,g&3){o=se(i[1]);let d;for(d=0;d<o.length;d+=1){const C=xe(i,o,d);l[d]?l[d].p(C,g):(l[d]=$e(C),l[d].c(),l[d].m(e,t))}for(;d<l.length;d+=1)l[d].d(1);l.length=o.length}g&128&&n!==(n=ke(`cert-item ${i[15]===0?"cert-item-first":""} ${i[15]===i[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")&&P(e,"class",n)},d(u){u&&R(e),ve(l,u),s=!1,r()}}}function yt(i){let e,t=se(i[0]),n=[];for(let s=0;s<t.length;s+=1)n[s]=Te(Ne(i,t,s));return{c(){for(let s=0;s<n.length;s+=1)n[s].c();e=et()},m(s,r){for(let o=0;o<n.length;o+=1)n[o]&&n[o].m(s,r);Y(s,e,r)},p(s,r){if(r&131){t=se(s[0]);let o;for(o=0;o<t.length;o+=1){const l=Ne(s,t,o);n[o]?n[o].p(l,r):(n[o]=Te(l),n[o].c(),n[o].m(e.parentNode,e))}for(;o<n.length;o+=1)n[o].d(1);n.length=t.length}},d(s){s&&R(e),ve(n,s)}}}function Ct(i){let e,t;return e=new gt({props:{onOk:i[9],onClose:i[2],onCancel:i[8],cancelText:i[3],okText:i[4],title:i[6],theme:i[5],$$slots:{default:[yt]},$$scope:{ctx:i}}}),{c(){at(e.$$.fragment)},m(n,s){Ae(e,n,s),t=!0},p(n,[s]){const r={};s&4&&(r.onClose=n[2]),s&8&&(r.cancelText=n[3]),s&16&&(r.okText=n[4]),s&64&&(r.title=n[6]),s&32&&(r.theme=n[5]),s&524419&&(r.$$scope={dirty:s,ctx:n}),e.$set(r)},i(n){t||(de(e.$$.fragment,n),t=!0)},o(n){De(e.$$.fragment,n),t=!1},d(n){Be(e,n)}}}function ft(i,e,t){let{data:n=[]}=e,{columns:s=[]}=e,{onCancel:r}=e,{onOk:o}=e,{onClose:l}=e,{cancelText:h=""}=e,{okText:u=""}=e,{theme:g="#409eff"}=e,{title:d=""}=e,C=0;const y=()=>{r(`${d}失败`),l==null||l()},f=()=>{o==null||o(n[C]),l==null||l()},E=w=>t(7,C=w);return i.$$set=w=>{"data"in w&&t(0,n=w.data),"columns"in w&&t(1,s=w.columns),"onCancel"in w&&t(10,r=w.onCancel),"onOk"in w&&t(11,o=w.onOk),"onClose"in w&&t(2,l=w.onClose),"cancelText"in w&&t(3,h=w.cancelText),"okText"in w&&t(4,u=w.okText),"theme"in w&&t(5,g=w.theme),"title"in w&&t(6,d=w.title)},[n,s,l,h,u,g,d,C,y,f,r,o,E]}class wt extends be{constructor(e){super(),Pe(this,e,ft,Ct,me,{data:0,columns:1,onCancel:10,onOk:11,onClose:2,cancelText:3,okText:4,theme:5,title:6})}}class St{constructor(){a(this,"modalInstance",{current:null});a(this,"open",e=>new Promise((t,n)=>{this.modalInstance.current=new wt({target:document.body,props:D(S({},e),{onCancel:s=>{n({code:"ON_CANCEL",msg:s})},onOk:s=>{t(s)},onClose:()=>{this.close()}})})}));a(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const W=new St;function Et(i=32,e=!0,t=0){const n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),s=[];if(t=t||n.length,i)for(let r=0;r<i;r++)s[r]=n[0|Math.random()*t];else{let r;s[8]=s[13]=s[18]=s[23]="-",s[14]="4";for(let o=0;o<36;o++)s[o]||(r=0|Math.random()*16,s[o]=n[o===19?r&3|8:r])}return e?(s.shift(),`u${s.join("")}`):s.join("")}function mt(i){const e=new Uint8Array(i),t=new TextDecoder("gbk"),n=new TextDecoder("latin1").decode(e);try{const s=JSON.parse(n),r=o=>{if(typeof o=="string"){const l=new Uint8Array(o.length);for(let h=0;h<o.length;h++)l[h]=o.charCodeAt(h)&255;return t.decode(l)}if(Array.isArray(o))return o.map(r);if(o!==null&&typeof o=="object"){const l={},h=o;for(const u in o)if(Object.prototype.hasOwnProperty.call(h,u)){const g=r(u);l[g]=r(h[u])}return l}return o};return r(s)}catch(s){throw console.error("GBK JSON 修复流程失败:",s),s}}const It=[{key:"CN"},{format:i=>`${i.DevClass}(${i.sn})`}],kt=[{key:"SealId"},{key:"Vid"},{format:i=>`${i.FileName}(${i.FileSize}B)`}],Oe=[{key:"SealId"}],vt=[{key:"manu"},{key:"sn"}];class Lt{constructor(e){a(this,"socketInstance",null);a(this,"eventBus",new Re);a(this,"scene");a(this,"isRememberPin",!1);a(this,"pinPolicy");a(this,"socketConfig",null);a(this,"isConnecting",!1);a(this,"messageQueue",[]);a(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});a(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});a(this,"sendMessage",(e,t,n)=>new Promise((s,r)=>{var l;const o=()=>{var d,C;if(((d=this.socketInstance)==null?void 0:d.readyState)!==WebSocket.OPEN){r({errCode:Ve,msg:"数字证书客户端连接失败"});return}const h=Et(),u=y=>{y.success?s(y.data):r(y)},g={function:e,args:t?[t]:[],msgid:h};(C=this.socketInstance)==null||C.send(JSON.stringify(g)),this.eventBus.on(e,u),this.eventBus.on(h,u)};if(n&&(this.scene&n)!==n){r({errCode:Ze,msg:"无权限执行此操作"});return}if(((l=this.socketInstance)==null?void 0:l.readyState)===WebSocket.OPEN){o();return}this.messageQueue.push(o),this.isConnecting||this.initSocket(this.socketConfig)}));a(this,"flushMsgQueue",()=>{var e;(e=this.messageQueue)==null||e.forEach(t=>t()),this.messageQueue=[]});a(this,"handleEventData",e=>c(this,null,function*(){var t,n,s,r,o,l,h,u;if(e.data instanceof Blob){const g=yield e.data.arrayBuffer(),C=navigator.userAgent.includes("Windows")?mt(g):JSON.parse(new TextDecoder().decode(g)),y={success:(t=C.result)==null?void 0:t.success,msg:(n=C.result)==null?void 0:n.msg,errCode:(s=C.result)==null?void 0:s.errCode,data:C.data,type:(r=C.result)==null?void 0:r.event},f=(o=C.result)==null?void 0:o.function,E=(l=C.result)==null?void 0:l.msgid;E?this.eventBus.emit(E,y):this.eventBus.emit(f,y),(u=(h=this.socketConfig)==null?void 0:h.onMessage)==null||u.call(h,y)}}));a(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return fe.fromByteArray(t)});a(this,"base64Decode",e=>{const t=fe.toByteArray(e);return new TextDecoder().decode(t)});a(this,"changeIsRememberPin",e=>c(this,null,function*(){this.isRememberPin=e}));a(this,"changePinPolicy",e=>c(this,null,function*(){this.pinPolicy=e}));a(this,"checkCertIsLogin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));a(this,"addUkeyEvents",()=>c(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:Ge}),this.eventBus.on("GZCA_OnDeviceChange",e=>{var t,n,s;(s=(t=this.socketConfig)==null?void 0:t.onUkeyChange)==null||s.call(t,D(S({},e),{data:(n=e.data)==null?void 0:n[0]}))})}));a(this,"ensureCertLogin",e=>c(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e.ContainerName});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e.ContainerName,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));a(this,"verifyPin",e=>c(this,null,function*(){var t;console.log("params2",e),yield this.sendMessage("GZCA_Login",{ContainerName:e.ContainerName,IsLogin:e.UserPin?"Y":"N",UserPin:(t=e.UserPin)!=null?t:"123456",PinPolicy:this.pinPolicy})}));a(this,"getCert",(e,t,n)=>c(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&n&&(yield this.ensureCertLogin({ContainerName:s.ContainerName})),s}));a(this,"chooseCert",e=>c(this,null,function*(){var s;const t=yield this.getCertList(e);return t!=null&&t.length?(t==null?void 0:t.length)===1?t[0]:yield W.open({title:"选择证书",data:t,columns:It,theme:(s=this.socketConfig)==null?void 0:s.theme}):Promise.reject({errCode:Fe,msg:"暂无证书"})}));a(this,"getClientVersion",()=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetClientVersion")}));a(this,"getCertList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));a(this,"pkcs1Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"batchPkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_BatchPkcs1SignDataEx",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs1VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));a(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));a(this,"getSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",S({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));a(this,"writeSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_WriteSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));a(this,"deleteSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DeleteSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));a(this,"getSealInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ReadSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));a(this,"getTPSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicList",S({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));a(this,"getTPSealPic",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicData",S({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));a(this,"sm2SignPreprocess1",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));a(this,"sm2SignPreprocess2",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));a(this,"pkcs1HashSign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs1HashVerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));a(this,"pkcs7Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",S({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));a(this,"pkcs7VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));a(this,"sm3Hash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));a(this,"sm3HexHash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));a(this,"sm3FileHash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));a(this,"sm3HashEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));a(this,"pkcs7Encryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));a(this,"pkcs7Decryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));a(this,"pkcs7FileEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeSealFileEx_qyzc",e)}));a(this,"pkcs7FileDecryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeOpenFileEx_qyzc",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));a(this,"asymmetricEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));a(this,"asymmetricDecryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));a(this,"sm4Encryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));a(this,"sm4Decryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));a(this,"getCertInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));a(this,"getCertInfoByOid",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));a(this,"getSealVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealIssuer",e,I.LEVEL_2)}));a(this,"deleteAllSealByVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ClearSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));a(this,"applyCert",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ApplyCert",{manu:e.manu,sn:e.sn,keyid:e.ContainerName,type:e.type,url:e.url},I.LEVEL_3)}));a(this,"resetPin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_UnblockUserPin",S({},e!=null?e:{}),I.LEVEL_3)}));a(this,"getUKeyList",()=>c(this,null,function*(){return yield this.sendMessage("GetUKeyList",void 0,I.LEVEL_3)}));a(this,"getUKeyInfo",e=>c(this,null,function*(){return yield this.sendMessage("GetUKeyID",e!=null?e:{},I.LEVEL_3)}));var t,n,s;this.socketConfig=e,this.initSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.scene=(n=e.scene)!=null?n:H.OPEN,this.pinPolicy=(s=e.pinPolicy)!=null?s:T.MIN}initSocket(e){this.isConnecting=!0;const t=new WebSocket(e.url);t.onerror=n=>{var s;this.isConnecting=!1,(s=e.onError)==null||s.call(e,n),this.flushMsgQueue()},t.onopen=n=>{var s;this.isConnecting=!1,(s=e.onOpen)==null||s.call(e,n),e.onUkeyChange&&this.addUkeyEvents(),this.flushMsgQueue()},t.onmessage=n=>{this.handleEventData(n)},t.onclose=n=>{var s;this.isConnecting=!1,(s=e.onClose)==null||s.call(e,n)},this.socketInstance=t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const Z=class Z{constructor(e){a(this,"coreInstance",null);a(this,"gwsConfig",{});a(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new Lt(D(S({},e!=null?e:{}),{url:k}))});a(this,"appendCertBase64",(e,t=!0)=>c(this,null,function*(){if(e.CertB64)return e;const n=t?yield this.getSignatureCert():yield this.getEncryptionCert();return D(S({},e!=null?e:{}),{CertB64:n==null?void 0:n.CertB64})}));a(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});a(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});a(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});a(this,"verifyPin",(e,t)=>c(this,null,function*(){var s,r;const n=yield this.getSignatureCert(t);return(r=this.coreInstance)==null?void 0:r.verifyPin({ContainerName:(s=n==null?void 0:n.ContainerName)!=null?s:"",UserPin:e==null?void 0:e.UserPin})}));a(this,"ensureCertLogin",e=>c(this,null,function*(){var s,r;const t=yield this.getSignatureCert(e);return yield(r=this.coreInstance)==null?void 0:r.ensureCertLogin({ContainerName:(s=t==null?void 0:t.ContainerName)!=null?s:""})}));a(this,"getSignatureCert",(e,t=!0)=>c(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:p},e,t)}));a(this,"getSignatureCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:p})}));a(this,"getEncryptionCert",(e,t=!0)=>c(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:z},e,t)}));a(this,"getEncryptionCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:z})}));a(this,"getClientVersion",()=>c(this,null,function*(){var t;const e=yield(t=this.coreInstance)==null?void 0:t.getClientVersion();return e==null?void 0:e[0]}));a(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});a(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});a(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});a(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});a(this,"pkcs1Sign",(e,t)=>c(this,null,function*(){var r,o,l;const n=yield this.getSignatureCert(t),s=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(D(S({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""}));return(l=s==null?void 0:s[0])==null?void 0:l.SignData}));a(this,"pkcs1VerifySignature",e=>c(this,null,function*(){var s;const t=yield this.appendCertBase64(e),n=yield(s=this.coreInstance)==null?void 0:s.pkcs1VerifySignature(t);return Array.isArray(n)}));a(this,"pkcs1Base64Sign",(e,t)=>c(this,null,function*(){var o,l,h,u,g;const n=yield this.getSignatureCert(t),s=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64Sign(D(S({},e!=null?e:{}),{ContainerName:(h=n==null?void 0:n.ContainerName)!=null?h:"",DataB64:s}));return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));a(this,"batchPkcs1Base64Sign",(e,t)=>c(this,null,function*(){var g,d,C,y,f,E;const n="|",s=(d=e.DataB64)!=null?d:(g=e.Data)==null?void 0:g.map(w=>this.base64Encode({Data:w})),r=yield this.getSignatureCert(t);let o="";o=Array.isArray(s)?s==null?void 0:s.map((w,m)=>`${m}:${w}`).join(n):"";const l=yield(y=this.coreInstance)==null?void 0:y.batchPkcs1Base64Sign({ContainerName:(C=r==null?void 0:r.ContainerName)!=null?C:"",DataB64:o}),h=(E=(f=l==null?void 0:l[0])==null?void 0:f.SignData)==null?void 0:E.split(n),u=[];return h.forEach(w=>{const m=w.split(":"),L=Number(m[0]),A=m[1];u[L]=A}),u}));a(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){var r,o,l;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=yield this.appendCertBase64(e);return!!(yield(l=this.coreInstance)==null?void 0:l.pkcs1Base64VerifySignature({CertB64:n.CertB64,DataB64:t,SignData:n.SignData}))}));a(this,"writeSeal",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return!!(yield(o=this.coreInstance)==null?void 0:o.writeSeal(D(S({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""})))}));a(this,"deleteSeal",(e,t)=>c(this,null,function*(){var h,u,g;const n=yield this.getSignatureCert(t),s=yield this.getSealList(e,n);if(!(s!=null&&s.length))return Promise.reject({errCode:oe,msg:"暂无印章"});const r=yield W.open({title:"删除印章",data:s,columns:Oe,okText:"删除"}),o=(h=r==null?void 0:r.SealId)!=null?h:"";return!!(yield(g=this.coreInstance)==null?void 0:g.deleteSeal(S({ContainerName:(u=n==null?void 0:n.ContainerName)!=null?u:"",SealId:o},e!=null?e:{})))}));a(this,"deleteSealById",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return!!(yield(o=this.coreInstance)==null?void 0:o.deleteSeal(D(S({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""})))}));a(this,"getSealList",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return yield(o=this.coreInstance)==null?void 0:o.getSealList(S({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""},e!=null?e:{}))}));a(this,"getSealInfo",(e,t)=>c(this,null,function*(){var l,h,u,g;const n=yield this.getSignatureCert(t),s=yield this.getSealList(e,n);if(!(s!=null&&s.length))return Promise.reject({errCode:oe,msg:"暂无印章"});const r=(s==null?void 0:s.length)>1?yield W.open({title:"选择印章",data:s,columns:Oe,theme:(l=this.gwsConfig)==null?void 0:l.theme}):s==null?void 0:s[0],o=yield(g=this.coreInstance)==null?void 0:g.getSealInfo({ContainerName:(h=n==null?void 0:n.ContainerName)!=null?h:"",SealId:(u=r==null?void 0:r.SealId)!=null?u:""});return o==null?void 0:o[0]}));a(this,"getTPSealList",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getSignatureCert(t);return yield(o=this.coreInstance)==null?void 0:o.getTPSealList(S({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""},e!=null?e:{}))}));a(this,"getTPSeal",(e,t)=>c(this,null,function*(){var r;const n=yield this.getTPSealList(e,t);return n!=null&&n.length?(n==null?void 0:n.length)===1?n==null?void 0:n[0]:yield W.open({title:"选择印章",data:n,columns:kt,theme:(r=this.gwsConfig)==null?void 0:r.theme}):Promise.reject({errCode:oe,msg:"暂无印章"})}));a(this,"getTPSealPic",(e,t,n)=>c(this,null,function*(){var l,h;const s=yield this.getSignatureCert(t),r=n||(yield this.getTPSeal(e,t)),o=yield(h=this.coreInstance)==null?void 0:h.getTPSealPic(D(S(S({ContainerName:(l=s==null?void 0:s.ContainerName)!=null?l:""},r!=null?r:{}),e!=null?e:{}),{FileSize:String(r==null?void 0:r.FileSize)}));return o==null?void 0:o[0]}));a(this,"sm2SignPreprocess1",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e),n=yield(s=this.coreInstance)==null?void 0:s.sm2SignPreprocess1(t);return(r=n==null?void 0:n[0])==null?void 0:r.Z}));a(this,"sm2SignPreprocess2",e=>c(this,null,function*(){var r,o;const t=this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=yield this.appendCertBase64(e),s=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:n.CertB64,DataB64:t});return s==null?void 0:s[0].H}));a(this,"pkcs1HashSign",(e,t)=>c(this,null,function*(){var r,o,l,h;const n=yield this.getSignatureCert(t),s=yield(l=this.coreInstance)==null?void 0:l.pkcs1HashSign({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:"",DataB64:e.DataB64,HashAlg:(o=e.HashAlg)!=null?o:"sm3"});return(h=s==null?void 0:s[0])==null?void 0:h.SignData}));a(this,"pkcs1HashVerifySignature",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e);return!!(yield(r=this.coreInstance)==null?void 0:r.pkcs1HashVerifySignature(D(S({},t),{HashAlg:(s=t.HashAlg)!=null?s:"sm3"})))}));a(this,"pkcs7Sign",(e,t)=>c(this,null,function*(){var o,l,h,u,g;const n=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=yield this.getSignatureCert(t),r=yield(u=this.coreInstance)==null?void 0:u.pkcs7Sign(D(S({},e!=null?e:{}),{ContainerName:(h=s==null?void 0:s.ContainerName)!=null?h:"",DataB64:n}));return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));a(this,"pkcs7VerifySignature",e=>c(this,null,function*(){var s,r,o;const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(s=e.Data)!=null?s:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));a(this,"sm3Hash",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm3Hash(e);return(s=t==null?void 0:t[0])==null?void 0:s.HashB64}));a(this,"sm3HexHash",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm3HexHash(e);return(s=t==null?void 0:t[0])==null?void 0:s.HashB64}));a(this,"sm3FileHash",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm3FileHash(e);return(s=t==null?void 0:t[0])==null?void 0:s.HashB64}));a(this,"sm3HashEncryption",e=>c(this,null,function*(){var r,o,l,h,u,g;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=(h=e.KeyB64)!=null?h:this.base64Encode({Data:(l=e.Key)!=null?l:""}),s=yield(u=this.coreInstance)==null?void 0:u.sm3HashEncryption({dataB64:t,keyB64:n,alg:"sm3"});return(g=s==null?void 0:s[0])==null?void 0:g.DataB64}));a(this,"pkcs7Encryption",e=>c(this,null,function*(){var s,r,o,l;if(!e.CertB64List){const h=yield this.getEncryptionCert();e.CertB64List=h==null?void 0:h.CertB64}const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(s=e.Data)!=null?s:""}),n=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(l=n==null?void 0:n[0])==null?void 0:l.DataB64}));a(this,"pkcs7Decryption",e=>c(this,null,function*(){var r,o;const t=yield this.getEncryptionCert(),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7Decryption(D(S({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),s=(o=n==null?void 0:n[0])==null?void 0:o.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:s}):s}));a(this,"pkcs7FileEncryption",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e,!1),n=yield(s=this.coreInstance)==null?void 0:s.pkcs7FileEncryption(t);return(r=n==null?void 0:n[0])==null?void 0:r.DataB64}));a(this,"pkcs7FileDecryption",e=>c(this,null,function*(){var s,r,o;const t=yield this.getEncryptionCert(),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7FileDecryption({SrcFile:e.SrcFile,DstFile:(s=e.DstFile)!=null?s:e.SrcFile.slice(0,-4),ContainerName:t==null?void 0:t.ContainerName});return(o=n==null?void 0:n[0])==null?void 0:o.DataB64}));a(this,"asymmetricEncryption",e=>c(this,null,function*(){var s,r;const t=yield this.appendCertBase64(e,!1),n=yield(s=this.coreInstance)==null?void 0:s.asymmetricEncryption(t);return(r=n==null?void 0:n[0])==null?void 0:r.Data}));a(this,"asymmetricDecryption",(e,t)=>c(this,null,function*(){var r,o;const n=yield this.getEncryptionCert(t),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricDecryption(D(S({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return(o=s==null?void 0:s[0])==null?void 0:o.Data}));a(this,"sm4Encryption",e=>c(this,null,function*(){var n;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Encryption(e);return t==null?void 0:t[0]}));a(this,"sm4Decryption",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Decryption(e);return(s=t==null?void 0:t[0])==null?void 0:s.Data}));a(this,"getCertInfo",e=>c(this,null,function*(){var s,r,o,l,h;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(e),n=(r=t==null?void 0:t[0])!=null?r:{};for(let u=0;u<ye.length;u++){const g=ye[u];try{const d=yield(o=this.coreInstance)==null?void 0:o.getCertInfoByOid({Oid:g.oid,CertB64:e.CertB64});n[g.key]=(h=(l=d==null?void 0:d[0])==null?void 0:l.OidValue)==null?void 0:h.replace(/\./g,"")}catch(d){n[g.key]=null}}return n!=null&&n.idCardNo?n!=null&&n.CertSubject.includes("O=")||n.orgCode?n.certCate=ie:n.certCate=J:n.certCate=re,n}));a(this,"getCertInfoByOid",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.getCertInfoByOid(S({},e!=null?e:{}));return(s=t==null?void 0:t[0])==null?void 0:s.OidValue}));a(this,"getSealVendor",e=>c(this,null,function*(){var s;const t=yield this.getSignatureCert(e),n=yield(s=this.coreInstance)==null?void 0:s.getSealVendor({ContainerName:t==null?void 0:t.ContainerName});return n==null?void 0:n[0]}));a(this,"deleteAllSealByVendor",(e,t)=>c(this,null,function*(){var r;const n=yield this.getSignatureCert(t),s=yield(r=this.coreInstance)==null?void 0:r.deleteAllSealByVendor(D(S({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return s==null?void 0:s[0]}));a(this,"getUKey",e=>c(this,null,function*(){var s,r;if(e)return e;const t=yield(s=this.coreInstance)==null?void 0:s.getUKeyList();return yield W.open({title:"选择介质",data:t,columns:vt,theme:(r=this.gwsConfig)==null?void 0:r.theme})}));a(this,"getUKeyList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getUKeyList()}));a(this,"getUKeyInfo",e=>c(this,null,function*(){var s;const t=yield this.getUKey(e),n=yield(s=this.coreInstance)==null?void 0:s.getUKeyInfo({manu:t==null?void 0:t.manu,sn:t==null?void 0:t.sn});return n==null?void 0:n[0]}));a(this,"applyCert",(e,t)=>c(this,null,function*(){var o;const n=yield this.getUKey(t),s=yield this.getUKeyInfo(n);return yield(o=this.coreInstance)==null?void 0:o.applyCert(D(S({},e!=null?e:{}),{manu:s==null?void 0:s.manu,sn:s==null?void 0:s.sn,ContainerName:s==null?void 0:s.keyid}))}));a(this,"resetPin",(e,t)=>c(this,null,function*(){var r;const n=yield this.getSignatureCert(t);return yield(r=this.coreInstance)==null?void 0:r.resetPin(D(S({},e!=null?e:{}),{manu:n==null?void 0:n.manu,sn:n==null?void 0:n.sn,ContainerName:n==null?void 0:n.ContainerName}))}));return Z.instance&&!(e!=null&&e.isCreateNew)?Z.instance:(this.createGwsCore(e),Z.instance=this,this)}};a(Z,"instance",null);let V=Z;function _t(i){return new Promise((e,t)=>{if(V.instance&&!(i!=null&&i.isCreateNew))e(V.instance);else{const n=new V(D(S({},i!=null?i:{}),{onOpen(s){var r;e(n),(r=i==null?void 0:i.onOpen)==null||r.call(i,s)},onClose(s){var r;t(s),(r=i==null?void 0:i.onClose)==null||r.call(i,s)}}))}})}_.GwsService=V,_.createService=_t,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gws-client",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "type": "module",
5
5
  "module": "dist/index.es.js",
6
6
  "main": "dist/index.cjs.js",