@rhc-office/sdk 6.6.266 → 6.6.268
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/browser/document-viewer.js +1 -1
- package/dist/browser/document-viewer.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +666 -523
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/dist/tools/AnnotationToolImpl.d.ts +47 -0
- package/dist/tools/AnnotationToolImpl.d.ts.map +1 -0
- package/dist/tools/CryptoToolImpl.d.ts +9 -0
- package/dist/tools/CryptoToolImpl.d.ts.map +1 -0
- package/dist/tools/DigitalSignToolImpl.d.ts +27 -0
- package/dist/tools/DigitalSignToolImpl.d.ts.map +1 -0
- package/dist/tools/DocumentToolImpl.d.ts +1 -0
- package/dist/tools/DocumentToolImpl.d.ts.map +1 -1
- package/dist/tools/SignServerToolImpl.d.ts +19 -0
- package/dist/tools/SignServerToolImpl.d.ts.map +1 -0
- package/dist/tools/SymbologyToolImpl.d.ts +8 -0
- package/dist/tools/SymbologyToolImpl.d.ts.map +1 -0
- package/dist/tools/TemplateSignToolImpl.d.ts +13 -0
- package/dist/tools/TemplateSignToolImpl.d.ts.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/viewer/DocumentSDK.d.ts +0 -1
- package/dist/viewer/DocumentSDK.d.ts.map +1 -1
- package/dist/viewer/SdkCallbackRegistry.d.ts +3 -0
- package/dist/viewer/SdkCallbackRegistry.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/tools/AnnotationToolImpl.ts +263 -0
- package/src/tools/CryptoToolImpl.ts +27 -0
- package/src/tools/DigitalSignToolImpl.ts +155 -0
- package/src/tools/DocumentToolImpl.ts +24 -2
- package/src/tools/SignServerToolImpl.ts +92 -0
- package/src/tools/SymbologyToolImpl.ts +34 -0
- package/src/tools/TemplateSignToolImpl.ts +51 -0
- package/src/tools/index.ts +6 -0
- package/src/viewer/DocumentSDK.ts +13 -114
- package/src/viewer/SdkCallbackRegistry.ts +9 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var RHCOfficeSDK=function(g){"use strict";var M=(n=>(n.DEFAULT="default",n.COMPACT="compact",n.HIDE="none",n))(M||{});const V="RIGHT_CENTER",B="REGULAR_ESM",K="auto",I="__RHC_OFFICE_DIGITAL_SIGN_ENVIRONMENT__",H={defaults:{bjca:{pin:""},deviceType:"client",edgePosition:V,kol:{appId:"",appName:"",pin:"",serviceUrl:"",token:""},plugin:{pin:"",usbKeyType:14},rsaMode:K,signatureType:B},signServer:{authSource:"Password",defaultLogin:"",defaultPassword:"",defaultServer:"",kol:{appId:"",appName:"",serviceUrl:"",token:""},macAddress:"",token:"",usbKey:{checkCertificateBinding:!1,usbKeyType:14}}},G=n=>({bjca:{pin:n.bjca.pin},deviceType:n.deviceType,edgePosition:n.edgePosition,kol:{appId:n.kol.appId,appName:n.kol.appName,pin:n.kol.pin,serviceUrl:n.kol.serviceUrl,token:n.kol.token},plugin:{pin:n.plugin.pin,usbKeyType:n.plugin.usbKeyType},rsaMode:n.rsaMode,signatureType:n.signatureType}),x=n=>({authSource:n.authSource,defaultLogin:n.defaultLogin,defaultPassword:n.defaultPassword,defaultServer:n.defaultServer,kol:{appId:n.kol.appId,appName:n.kol.appName,serviceUrl:n.kol.serviceUrl,token:n.kol.token},macAddress:n.macAddress,token:n.token,usbKey:{checkCertificateBinding:n.usbKey.checkCertificateBinding,usbKeyType:n.usbKey.usbKeyType}}),v=n=>({defaults:G(n.defaults),signServer:x(n.signServer)}),q=n=>({defaults:n.defaults?{...n.defaults,bjca:n.defaults.bjca?{...n.defaults.bjca}:void 0,kol:n.defaults.kol?{...n.defaults.kol}:void 0,plugin:n.defaults.plugin?{...n.defaults.plugin}:void 0}:void 0,signServer:n.signServer?{...n.signServer,kol:n.signServer.kol?{...n.signServer.kol}:void 0,usbKey:n.signServer.usbKey?{...n.signServer.usbKey}:void 0}:void 0}),de=(n,t)=>{var e,i,r,a,s,o,d,h,u,l,m,c,f,p,k,b,T,E,A,D;return t?{bjca:{pin:(i=(e=t.bjca)==null?void 0:e.pin)!=null?i:n.bjca.pin},deviceType:(r=t.deviceType)!=null?r:n.deviceType,edgePosition:(a=t.edgePosition)!=null?a:n.edgePosition,kol:{appId:(o=(s=t.kol)==null?void 0:s.appId)!=null?o:n.kol.appId,appName:(h=(d=t.kol)==null?void 0:d.appName)!=null?h:n.kol.appName,pin:(l=(u=t.kol)==null?void 0:u.pin)!=null?l:n.kol.pin,serviceUrl:(c=(m=t.kol)==null?void 0:m.serviceUrl)!=null?c:n.kol.serviceUrl,token:(p=(f=t.kol)==null?void 0:f.token)!=null?p:n.kol.token},plugin:{pin:(b=(k=t.plugin)==null?void 0:k.pin)!=null?b:n.plugin.pin,usbKeyType:(E=(T=t.plugin)==null?void 0:T.usbKeyType)!=null?E:n.plugin.usbKeyType},rsaMode:(A=t.rsaMode)!=null?A:n.rsaMode,signatureType:(D=t.signatureType)!=null?D:n.signatureType}:G(n)},le=(n,t)=>{var e,i,r,a,s,o,d,h,u,l,m,c,f,p,k,b,T,E;return t?{authSource:(e=t.authSource)!=null?e:n.authSource,defaultLogin:(i=t.defaultLogin)!=null?i:n.defaultLogin,defaultPassword:(r=t.defaultPassword)!=null?r:n.defaultPassword,defaultServer:(a=t.defaultServer)!=null?a:n.defaultServer,kol:{appId:(o=(s=t.kol)==null?void 0:s.appId)!=null?o:n.kol.appId,appName:(h=(d=t.kol)==null?void 0:d.appName)!=null?h:n.kol.appName,serviceUrl:(l=(u=t.kol)==null?void 0:u.serviceUrl)!=null?l:n.kol.serviceUrl,token:(c=(m=t.kol)==null?void 0:m.token)!=null?c:n.kol.token},macAddress:(f=t.macAddress)!=null?f:n.macAddress,token:(p=t.token)!=null?p:n.token,usbKey:{checkCertificateBinding:(b=(k=t.usbKey)==null?void 0:k.checkCertificateBinding)!=null?b:n.usbKey.checkCertificateBinding,usbKeyType:(E=(T=t.usbKey)==null?void 0:T.usbKeyType)!=null?E:n.usbKey.usbKeyType}}:x(n)},Q=(n,t)=>({defaults:de(n.defaults,t.defaults),signServer:le(n.signServer,t.signServer)}),ce=(n,t)=>{var e,i,r,a,s,o,d,h,u,l,m,c,f,p,k,b,T,E,A,D;return{defaults:n.defaults||t.defaults?{...n.defaults,...t.defaults,bjca:{...(i=(e=n.defaults)==null?void 0:e.bjca)!=null?i:{},...(a=(r=t.defaults)==null?void 0:r.bjca)!=null?a:{}},kol:{...(o=(s=n.defaults)==null?void 0:s.kol)!=null?o:{},...(h=(d=t.defaults)==null?void 0:d.kol)!=null?h:{}},plugin:{...(l=(u=n.defaults)==null?void 0:u.plugin)!=null?l:{},...(c=(m=t.defaults)==null?void 0:m.plugin)!=null?c:{}}}:void 0,signServer:n.signServer||t.signServer?{...n.signServer,...t.signServer,kol:{...(p=(f=n.signServer)==null?void 0:f.kol)!=null?p:{},...(b=(k=t.signServer)==null?void 0:k.kol)!=null?b:{}},usbKey:{...(E=(T=n.signServer)==null?void 0:T.usbKey)!=null?E:{},...(D=(A=t.signServer)==null?void 0:A.usbKey)!=null?D:{}}}:void 0}},ue=()=>globalThis,y=()=>{const n=ue();return n[I]||(n[I]={current:v(H),defaults:v(H),overrides:{}}),n[I]},z=()=>y().current,W=n=>{const t=y();return t.defaults=v(n),t.current=Q(t.defaults,t.overrides),t.current},$=n=>{const t=y();return t.current=v(n),t.overrides=q(n),t.current},j=n=>{const t=y();return t.overrides=ce(t.overrides,q(n)),t.current=Q(t.current,n),t.current},Y=n=>{const t=y();return n&&(t.defaults=v(n)),t.overrides={},t.current=v(t.defaults),t.current},X={EDGE_POSITION:V,RSA_MODE:K,SIGNATURE_TYPE:B},w=n=>{if(n.length!==0)return n.length===1?n[0]:n},R=(n,t,e)=>new Proxy({},{get:(i,r)=>{if(r==="then")return;if(typeof r=="symbol")return r===Symbol.toStringTag?n:void 0;const a=t[r];return a?(...s)=>{var d,h,u;if(a.kind==="callbackRegister"){(d=a.callback)==null||d.call(a,e.callbacks,s);return}if(a.kind==="stateGetter")return(h=a.state)==null?void 0:h.call(a,e.state.snapshot(),s);const o=(u=a.adapterMethod)!=null?u:r;if(a.kind==="query")return e.bridge.request(n,o,w(s));if(a.kind==="callbackQuery"){const l=s.find(c=>typeof c=="function"),m=s.filter(c=>typeof c!="function");e.bridge.request(n,o,w(m)).then(c=>{var p,k;const f=(k=(p=a.mapCallbackResult)==null?void 0:p.call(a,c))!=null?k:[c];l==null||l(...f)}).catch(e.onAsyncError);return}e.bridge.request(n,o,w(s)).catch(e.onAsyncError)}:(...s)=>{const o=new Error(`${n}.${r} is not implemented by the SDK adapter.`);e.onAsyncError(o)}}}),P=(n,t)=>new Proxy({},{get:(e,i)=>{if(i!=="then"&&typeof i!="symbol")return(...r)=>{const a=`${n}.${i} is not implemented by the SDK adapter.`;t.onAsyncError(new Error(a))}}}),he={addDocumentOpenedCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.documentOpened.push(e)}},addDocumentSavedCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.documentSaved.push(e)}},addDocumentClosedCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.documentClosed.push(e)}},openPDFDocument:{kind:"callbackQuery",adapterMethod:"open"},openPdfDocument:{kind:"callbackQuery",adapterMethod:"open"},openOFDDocument:{kind:"callbackQuery",adapterMethod:"open"},openOfdDocument:{kind:"callbackQuery",adapterMethod:"open"},openOfficeDocument:{kind:"callbackQuery",adapterMethod:"open"},openImageDocument:{kind:"callbackQuery",adapterMethod:"open"},openTextDocument:{kind:"callbackQuery",adapterMethod:"open"},openFromLocalStorage:{kind:"command"},setUploadUrl:{kind:"command"},save:{kind:"callbackQuery"},saveAs:{kind:"query"},getDocumentContent:{kind:"callbackQuery",mapCallbackResult:n=>{const t=n;return[t==null?void 0:t.fileCacheId,t==null?void 0:t.fileBuffer]}},closeDocument:{kind:"callbackQuery"},isDocumentOpened:{kind:"stateGetter",state:n=>n.documentOpened},isDocumentModified:{kind:"stateGetter",state:n=>n.documentModified},print:{kind:"command"},createPreview:{kind:"command"}};class me{constructor(t){this.addDocumentOpenedCallback=e=>this.adapter.addDocumentOpenedCallback(e),this.addDocumentSavedCallback=e=>this.adapter.addDocumentSavedCallback(e),this.addDocumentClosedCallback=e=>this.adapter.addDocumentClosedCallback(e),this.openPDFDocument=(e,i)=>this.adapter.openPDFDocument(e,i),this.openPdfDocument=(e,i)=>this.adapter.openPdfDocument(e,i),this.openOFDDocument=(e,i)=>this.adapter.openOFDDocument(e,i),this.openOfdDocument=(e,i)=>this.adapter.openOfdDocument(e,i),this.openOfficeDocument=(e,i)=>this.adapter.openOfficeDocument(e,i),this.openImageDocument=(e,i)=>this.adapter.openImageDocument(e,i),this.openTextDocument=(e,i)=>this.adapter.openTextDocument(e,i),this.openFromLocalStorage=()=>this.adapter.openFromLocalStorage(),this.setUploadUrl=e=>this.adapter.setUploadUrl(e),this.save=(e,i,r)=>this.adapter.save(e,i,r),this.saveAs=e=>this.adapter.saveAs(e),this.getDocumentContent=e=>this.adapter.getDocumentContent(e),this.closeDocument=(e,i,r)=>this.adapter.closeDocument(e,i,r),this.isDocumentOpened=()=>this.adapter.isDocumentOpened(),this.isDocumentModified=()=>this.adapter.isDocumentModified(),this.print=()=>this.adapter.print(),this.createPreview=(e,i)=>this.adapter.createPreview(e,i),this.adapter=R("document",he,t)}}const ge={clearFind:{kind:"command"},findNext:{kind:"command"},findPrevious:{kind:"command"}};class pe{constructor(t){this.clearFind=()=>this.adapter.clearFind(),this.findNext=e=>this.adapter.findNext(e),this.findPrevious=e=>this.adapter.findPrevious(e),this.adapter=R("find",ge,t)}}const ke={configFileUpload:{kind:"command"},setHttpHeaders:{kind:"command"},setHttpFormFields:{kind:"command"}};class fe{constructor(t){this.configFileUpload=e=>this.adapter.configFileUpload(e),this.setHttpHeaders=e=>this.adapter.setHttpHeaders(e),this.setHttpFormFields=e=>this.adapter.setHttpFormFields(e),this.adapter=R("networking",ke,t)}}const be=n=>({addPageChangeCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.pageChange.push(i)}},addPageModeChangeCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.pageModeChange.push(i)}},getPageCount:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&i(n.state.snapshot().pageCount)}},getPageIndex:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&i(n.state.snapshot().pageIndex)}},setSinglePageViewMode:{kind:"command"},setTwoPagesViewMode:{kind:"command"},setPageScrollVertical:{kind:"command"},setPageScrollHorizontal:{kind:"command"},setPageCursorPanDrag:{kind:"command"},setPageCursorTextSelect:{kind:"command"},rotateCW:{kind:"command"},rotateCCW:{kind:"command"},autoFitPage:{kind:"command"},fitPageSize:{kind:"command"},fitPageWidth:{kind:"command"},fitPageHeight:{kind:"command"},increasePageScale:{kind:"command"},decreasePageScale:{kind:"command"},setPageScale:{kind:"command"},setPageBlendColor:{kind:"command"},gotoPage:{kind:"command"},gotoNextPage:{kind:"command"},gotoPreviousPage:{kind:"command"},rotatePage:{kind:"command"}});class Te{constructor(t){this.addPageChangeCallback=e=>this.adapter.addPageChangeCallback(e),this.addPageModeChangeCallback=e=>this.adapter.addPageModeChangeCallback(e),this.getPageCount=e=>this.adapter.getPageCount(e),this.getPageIndex=e=>this.adapter.getPageIndex(e),this.setSinglePageViewMode=()=>this.adapter.setSinglePageViewMode(),this.setTwoPagesViewMode=()=>this.adapter.setTwoPagesViewMode(),this.setPageScrollVertical=()=>this.adapter.setPageScrollVertical(),this.setPageScrollHorizontal=()=>this.adapter.setPageScrollHorizontal(),this.setPageCursorPanDrag=()=>this.adapter.setPageCursorPanDrag(),this.setPageCursorTextSelect=()=>this.adapter.setPageCursorTextSelect(),this.rotateCW=()=>this.adapter.rotateCW(),this.rotateCCW=()=>this.adapter.rotateCCW(),this.autoFitPage=()=>this.adapter.autoFitPage(),this.fitPageSize=()=>this.adapter.fitPageSize(),this.fitPageWidth=()=>this.adapter.fitPageWidth(),this.fitPageHeight=()=>this.adapter.fitPageHeight(),this.increasePageScale=()=>this.adapter.increasePageScale(),this.decreasePageScale=()=>this.adapter.decreasePageScale(),this.setPageScale=e=>this.adapter.setPageScale(e),this.setPageBlendColor=(e,i,r,a)=>this.adapter.setPageBlendColor(e,i,r,a),this.gotoPage=(e,i,r)=>this.adapter.gotoPage(e,i,r),this.gotoNextPage=()=>this.adapter.gotoNextPage(),this.gotoPreviousPage=()=>this.adapter.gotoPreviousPage(),this.rotatePage=e=>this.adapter.rotatePage(e),this.adapter=R("page",be(t),t)}}const Ee={open:{kind:"command"},setFormFieldValue:{kind:"command"},setFormFieldReadonly:{kind:"command"},commit:{kind:"callbackQuery",mapCallbackResult:()=>[]},clear:{kind:"callbackQuery",mapCallbackResult:()=>[]},toKeyValue:{kind:"callbackQuery",mapCallbackResult:n=>[Array.isArray(n)?n:[]]}};class Re{constructor(t){this.open=()=>this.adapter.open(),this.setFormFieldValue=(e,i)=>this.adapter.setFormFieldValue(e,i),this.setFormFieldReadonly=(e,i)=>this.adapter.setFormFieldReadonly(e,i),this.commit=e=>this.adapter.commit(e),this.clear=e=>this.adapter.clear(e),this.toKeyValue=e=>this.adapter.toKeyValue(e),this.adapter=R("pdfFormFiller",Ee,t)}}const ve=/\s*,\s*/,Se=/\s*-\s*/,_=n=>{const t=Number.parseInt(n.trim(),10);return!Number.isFinite(t)||t<=0?null:t},ye=n=>{var r,a,s;const t=n.split(Se);if(t.length===1){const o=_((r=t[0])!=null?r:"");return o?[o]:[]}const e=_((a=t[0])!=null?a:""),i=_((s=t[1])!=null?s:"");return!e||!i||i<e?[]:Array.from({length:i-e+1},(o,d)=>e+d)},Pe=n=>n?n.split(ve).flatMap(e=>ye(e)).filter((e,i,r)=>r.indexOf(e)===i):[];class Ce{constructor(t,e,i){this.setFieldName=r=>{this.key=r},this.setFieldValue=r=>{this.value=r},this.setDescription=r=>{this.description=r},this.key=t,this.value=e,this.description=i}}class Ae{constructor(){this.fields=[],this.keywordTextFixedPositions=void 0,this.keywordOffsetX=0,this.keywordOffsetY=0,this.bookmarkOffsetX=0,this.bookmarkOffsetY=0,this.printMargin=0,this.grayscaleSealImage=!1,this.signType=0,this.sealPosition=0,this.getSignType=()=>this.signType,this.setSignType=t=>{this.signType=t},this.isCrossPageSideSign=()=>this.signType===2||this.signType===3,this.getSealPosition=()=>this.sealPosition,this.setSignOnPageSides=t=>{t>=0&&t<=3&&(this.signType=t)},this.setSignPositionOnPageSides=t=>{this.sealPosition=t},this.setPageRange=t=>{this.pageRange=t},this.getPageRange=()=>this.pageRange,this.getPageRanges=()=>Pe(this.pageRange),this.setSignUserData=t=>{this.signUserData=t},this.setPrintMargin=t=>{this.printMargin=t},this.getPrintMargin=()=>{var t;return(t=this.printMargin)!=null?t:0},this.setSignReason=t=>{this.signReason=t},this.getSignReason=()=>this.signReason,this.setSignLocation=t=>{this.signLocation=t},this.getSignLocation=()=>this.signLocation,this.setDefaultStampPassword=t=>{this.defaultStampPassword=t}}}const De=new Set([2,5]),Me=n=>({showToolbarMenu:{kind:"command"},hideToolbarMenu:{kind:"command"},setupToolbarMenu:{kind:"command"},showToolbarMenuItem:{kind:"command"},hideToolbarMenuItem:{kind:"command"},setupRibbonMenu:{kind:"command"},setupRibbonMenuItem:{kind:"command"},setupRibbonTitleBar:{kind:"command"},showRibbonMenu:{kind:"command"},hideRibbonMenu:{kind:"command"},showRibbonMenuItem:{kind:"command"},hideRibbonMenuItem:{kind:"command"},showRibbonTitleBar:{kind:"command"},hideRibbonTitleBar:{kind:"command"},selectRibbonMenu:{kind:"command"},setRibbonMenuButtonStyle:{kind:"command"},setWatermark:{kind:"command"},setCompactMode:{kind:"command"},enterBookViewMode:{kind:"callbackQuery",mapCallbackResult:()=>[]},exitBookViewMode:{kind:"command"},isBookViewActivated:{kind:"stateGetter",state:()=>De.has(n.state.snapshot().pageMode)},requestFullScreen:{kind:"command"},exitFullScreen:{kind:"command"},invalidateView:{kind:"command"}});class Ie{constructor(t){this.showToolbarMenu=()=>this.adapter.showToolbarMenu(),this.hideToolbarMenu=()=>this.adapter.hideToolbarMenu(),this.setupToolbarMenu=e=>this.adapter.setupToolbarMenu(e),this.showToolbarMenuItem=e=>this.adapter.showToolbarMenuItem(e),this.hideToolbarMenuItem=e=>this.adapter.hideToolbarMenuItem(e),this.setupRibbonMenu=e=>this.adapter.setupRibbonMenu(e),this.setupRibbonMenuItem=(e,i,r)=>this.adapter.setupRibbonMenuItem(e,i,r),this.setupRibbonTitleBar=e=>this.adapter.setupRibbonTitleBar(e),this.showRibbonMenu=()=>this.adapter.showRibbonMenu(),this.hideRibbonMenu=()=>this.adapter.hideRibbonMenu(),this.showRibbonMenuItem=(e,i)=>this.adapter.showRibbonMenuItem(e,i),this.hideRibbonMenuItem=(e,i)=>this.adapter.hideRibbonMenuItem(e,i),this.showRibbonTitleBar=()=>this.adapter.showRibbonTitleBar(),this.hideRibbonTitleBar=()=>this.adapter.hideRibbonTitleBar(),this.selectRibbonMenu=e=>this.adapter.selectRibbonMenu(e),this.setRibbonMenuButtonStyle=(e,i)=>this.adapter.setRibbonMenuButtonStyle(e,i),this.setWatermark=e=>this.adapter.setWatermark(e),this.setCompactMode=e=>this.adapter.setCompactMode(e),this.enterBookViewMode=e=>this.adapter.enterBookViewMode(e),this.exitBookViewMode=()=>this.adapter.exitBookViewMode(),this.isBookViewActivated=()=>this.adapter.isBookViewActivated(),this.requestFullScreen=()=>this.adapter.requestFullScreen(),this.exitFullScreen=()=>this.adapter.exitFullScreen(),this.invalidateView=()=>this.adapter.invalidateView(),this.adapter=R("ui",Me(t),t)}}const we=n=>{if(!n)return;const t=n.trim().toLowerCase();if(t==="application")return"auto";if(t==="light"||t==="dark"||t==="high-contrast"||t==="auto")return t},J=n=>{var e,i;const t=new URL(n,(i=(e=globalThis.location)==null?void 0:e.href)!=null?i:"http://localhost/");return t.hash="",t.pathname.endsWith("/")||(t.pathname=`${t.pathname}/`),t.toString()},_e=n=>new URL("editors.bootstrap.js",n).toString(),Oe=(n,t)=>{var i;const e=J(n);return{...t,appUrl:e,scrollIntoView:(i=t.scrollIntoView)!=null?i:!0,theme:we(t.theme)}},S="rhc-office-editor",O="__RHC_OFFICE_SDK_READER_LOADER__",Z=()=>{const n=globalThis;return n[O]||(n[O]={activeAppUrl:null,loadPromises:new Map}),n[O]},Fe=n=>{var t;return(t=Array.from(document.querySelectorAll("script")).find(e=>e.src===n))!=null?t:null};class ee extends Error{constructor(t){super(`Failed to load reader bootstrap script: ${t}`),this.name="ReaderScriptLoadError"}}class Le extends Error{constructor(t,e){super(`Reader Web Component "${S}" is already bound to ${t} and cannot be reloaded from ${e}.`),this.name="ReaderSourceConflictError"}}const te=n=>{const t=Z();if(t.activeAppUrl&&t.activeAppUrl!==n)throw new Le(t.activeAppUrl,n)},Ue=n=>{var s;const t=Z();te(n);const e=t.loadPromises.get(n);if(e)return e;if((s=globalThis.customElements)!=null&&s.get(S)){t.activeAppUrl=n;const o=Promise.resolve();return t.loadPromises.set(n,o),o}const i=_e(n),r=Fe(i);t.activeAppUrl=n;const a=new Promise((o,d)=>{var m;const h=c=>{c==null||c.remove(),d(new ee(i))},u=()=>{globalThis.customElements.whenDefined(S).then(()=>{o()}).catch(d)};if(r){if((m=globalThis.customElements)!=null&&m.get(S)){o();return}r.addEventListener("error",()=>d(new ee(i)),{once:!0}),u();return}const l=document.createElement("script");l.src=i,l.async=!0,l.dataset.rhcOfficeSdkReader=n,l.addEventListener("load",u,{once:!0}),l.addEventListener("error",()=>h(l),{once:!0}),document.head.appendChild(l)}).catch(o=>{var d;throw t.loadPromises.delete(n),!((d=globalThis.customElements)!=null&&d.get(S))&&t.activeAppUrl===n&&(t.activeAppUrl=null),o});return t.loadPromises.set(n,a),a},Ne="rhc-office.editor-adapter",Ve=1,Be="__RHC_OFFICE_EDITOR_ADAPTER__",ne="rhcOfficeAdapterReady",ie="rhcOfficeAdapterEvent",Ke="data-rhc-office-reader-id",He=5e3,Ge=5e3,xe=()=>{const n=globalThis.crypto;return typeof(n==null?void 0:n.randomUUID)=="function"?n.randomUUID():`adapter-${Date.now()}-${Math.random().toString(36).slice(2)}`},C=()=>globalThis[Be];class qe extends Error{constructor(t,e,i){super(e),this.name="ReaderBridgeError",this.code=t,this.details=i}}class Qe{constructor(t){var e,i;this.readerId=null,this.readyTimeoutMs=(e=t==null?void 0:t.readyTimeoutMs)!=null?e:Ge,this.requestTimeoutMs=(i=t==null?void 0:t.requestTimeoutMs)!=null?i:He}configureTimeouts(t){var e,i;this.readyTimeoutMs=(e=t==null?void 0:t.readyTimeoutMs)!=null?e:this.readyTimeoutMs,this.requestTimeoutMs=(i=t==null?void 0:t.requestTimeoutMs)!=null?i:this.requestTimeoutMs}setReaderId(t){this.readerId=t}getReaderId(){return this.readerId}async request(t,e,i,r){const a=await this.requestRaw(t,e,i,r);if(a.ok)return a.result;throw new qe(a.error.code,a.error.message,a.error.details)}async requestRaw(t,e,i,r){var o;if(!this.readerId)return{ok:!1,requestId:"",error:{code:"READER_NOT_READY",message:"Reader is not mounted."}};const a=await this.waitForAdapter(this.readerId,r==null?void 0:r.timeoutMs);if(!a)return{ok:!1,requestId:"",error:{code:"ADAPTER_UNAVAILABLE",message:"Editor adapter is not available."}};const s={protocol:Ne,version:Ve,requestId:xe(),readerId:this.readerId,tool:t,method:e,params:i};return this.withTimeout(a.request(s),s.requestId,(o=r==null?void 0:r.timeoutMs)!=null?o:this.requestTimeoutMs)}getCapabilities(){var t,e;return this.readerId&&(e=(t=C())==null?void 0:t.getCapabilities(this.readerId))!=null?e:null}async waitForAdapter(t,e=this.readyTimeoutMs){const i=C();return i!=null&&i.getCapabilities(t)?i:new Promise(r=>{let a;const s=()=>{a&&clearTimeout(a),globalThis.removeEventListener(ne,o)},o=d=>{const h=d instanceof CustomEvent?d.detail:void 0;if((h==null?void 0:h.readerId)!==t)return;const u=C();s(),r(u!=null?u:null)};globalThis.addEventListener(ne,o),a=setTimeout(()=>{var d;s(),r((d=C())!=null&&d.getCapabilities(t)?C():null)},e)})}async withTimeout(t,e,i){return new Promise(r=>{const a=setTimeout(()=>{r({ok:!1,requestId:e,error:{code:"TIMEOUT",message:`Editor adapter request timed out after ${i}ms.`}})},i);t.then(s=>r(s)).catch(s=>{r({ok:!1,requestId:e,error:{code:"EXECUTION_FAILED",message:s instanceof Error?s.message:String(s)}})}).finally(()=>{clearTimeout(a)})})}}const re={annotationEnabled:!1,documentModified:!1,documentOpened:!1,pageCount:0,pageIndex:1,pageMode:0,zoomLevel:100};class ze{constructor(){this.state={...re}}reset(){this.state={...re}}update(t){t&&(this.state={...this.state,...t})}setDocumentOpened(t){this.state={...this.state,documentOpened:t}}snapshot(){return{...this.state}}}class We{constructor(){this.annotationEvents=[],this.annotationPersist=[],this.annotationRetrieve=[],this.digitalAnnotationRetrieve=[],this.digitalSignatureParse=[],this.digitalSignatureRetrieve=[],this.documentClosed=[],this.documentOpened=[],this.documentSaved=[],this.pageChange=[],this.pageModeChange=[]}emit(t,e){switch(t){case"documentOpened":case"documentLoaded":this.documentOpened.forEach(i=>i("ok",""));return;case"documentSaved":this.documentSaved.forEach(i=>i(e));return;case"documentClosed":this.documentClosed.forEach(i=>i(e));return;case"pageChange":{const i=e;this.pageChange.forEach(r=>{var a,s;return r((a=i.pageIndex)!=null?a:1,(s=i.pageCount)!=null?s:0)});return}case"pageModeChange":{const i=e;this.pageModeChange.forEach(r=>{var a;return r((a=i.pageMode)!=null?a:0)});return}case"annotationEvent":{const i=e;this.annotationEvents.forEach(r=>{var a;return r((a=i.event)!=null?a:"annotationEvent",i.payload)});return}case"annotationPersist":this.annotationPersist.forEach(i=>i(e));return;case"annotationRetrieve":this.annotationRetrieve.forEach(i=>i(e));return;case"digitalAnnotationRetrieve":this.digitalAnnotationRetrieve.forEach(i=>i(Array.isArray(e)?e:[]));return;case"digitalSignatureRetrieve":this.digitalSignatureRetrieve.forEach(i=>i(Array.isArray(e)?e:[]));return;case"digitalSignatureParse":this.digitalSignatureParse.forEach(i=>i(Array.isArray(e)?e:[]));return;default:return}}}const $e=["documentLoaded","documentStateChange","documentError"],je="readerReady",Ye="readerUnload",F="readerError",Xe=()=>{var n;return typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function"?globalThis.crypto.randomUUID():`rhc-reader-${Date.now()}-${Math.random().toString(36).slice(2)}`},ae=(n,t)=>{var e;return{appUrl:(e=t==null?void 0:t.appUrl)!=null?e:null,configuration:t,element:n}},Je=n=>{if(typeof n=="string"){const t=document.getElementById(n);if(!t)throw new Error(`Reader container "${n}" was not found.`);if(!(t instanceof HTMLDivElement))throw new Error(`Reader container "${n}" must be a div element.`);return t}if(!(n instanceof HTMLDivElement))throw new Error("Reader container must be a div element.");return n},Ze=()=>{const n=typeof globalThis.matchMedia=="function";return(n?globalThis.matchMedia("(prefers-contrast: more)").matches:!1)?"high-contrast":(n?globalThis.matchMedia("(prefers-color-scheme: dark)").matches:!1)?"dark":"light"},se=(n,t)=>{const e=n;if(typeof e.addEventListener=="function"){e.addEventListener("change",t);return}typeof e.addListener=="function"&&e.addListener(t)},oe=(n,t)=>{const e=n;if(typeof e.removeEventListener=="function"){e.removeEventListener("change",t);return}typeof e.removeListener=="function"&&e.removeListener(t)},et=(n,t)=>{var e,i;t.style&&(n.style.cssText=t.style),n.style.display||(n.style.display="block"),n.style.width?t.width&&(n.style.width=t.width):n.style.width=(e=t.width)!=null?e:"100%",n.style.height?t.height&&(n.style.height=t.height):n.style.height=(i=t.height)!=null?i:"100%"},tt=(n,t)=>{const e=t.theme;if(!e)return n.removeAttribute("theme"),null;if(e!=="auto")return n.setAttribute("theme",e),null;const i=()=>{n.setAttribute("theme",Ze())};if(i(),typeof globalThis.matchMedia!="function")return null;const r=globalThis.matchMedia("(prefers-color-scheme: dark)"),a=globalThis.matchMedia("(prefers-contrast: more)"),s=()=>{i()};return se(r,s),se(a,s),()=>{oe(r,s),oe(a,s)}};class L{constructor(t){this.bridge=new Qe,this.callbacks=new We,this.readerState=new ze,this.bridgeToolContext={bridge:this.bridge,callbacks:this.callbacks,debug:()=>this.debugEnabled,onAsyncError:e=>this.reportAdapterError(e),state:this.readerState},this.documentTool=new me(this.bridgeToolContext),this.uiTool=new Ie(this.bridgeToolContext),this.pageTool=new Te(this.bridgeToolContext),this.findTool=new pe(this.bridgeToolContext),this.signServerTool=P("signServer",this.bridgeToolContext),this.digitalSignTool=P("digitalSign",this.bridgeToolContext),this.symbologyTool=P("symbology",this.bridgeToolContext),this.annotationTool=this.createAnnotationTool(),this.templateSignTool=P("templateSign",this.bridgeToolContext),this.pdfFormFiller=new Re(this.bridgeToolContext),this.networkingTool=new fe(this.bridgeToolContext),this.cryptoTool=P("crypto",this.bridgeToolContext),this.readyCallbacks=[],this.unloadCallbacks=[],this.debugEnabled=!1,this.isReady=!1,this.removed=!1,this.mountToken=0,this.hostContainer=null,this.readerElement=null,this.readerId=null,this.normalizedConfiguration=null,this.nativeEventCleanupCallbacks=[],this.themeCleanup=null,this.enableDebug=e=>{this.debugEnabled=e},this.changeLanguage=()=>{},this.setLicense=(e,i)=>{this.license={license:e,feature:i}},this.setSessionUser=e=>{this.sessionUser=e},this.setSessionUserId=e=>{if(typeof this.sessionUser=="string"||!this.sessionUser){this.sessionUser={userName:typeof this.sessionUser=="string"?this.sessionUser:"",userId:e};return}this.sessionUser={...this.sessionUser,userId:e}},this.setSessionData=e=>{this.sessionData=e},this.isReaderReady=()=>this.isReady,this.isReaderDestroyed=()=>this.removed&&!this.isReady,this.addReaderReadyCallback=e=>{this.readyCallbacks.push(e)},this.addReaderUnloadCallback=e=>{this.unloadCallbacks.push(e)},this.setReaderEventListener=e=>{this.readerEventListener=e},this.embedReader=(e,i,r)=>{const a=Je(e),s=J(i);te(s);const o=Oe(s,r),d=this.mountToken+1;this.removeReader(),this.mountToken=d,this.removed=!1,this.hostContainer=a,this.normalizedConfiguration=o,this.mountReader(a,o,d)},this.removeReader=()=>{var r;const e=!!(this.readerElement||this.hostContainer);if(this.mountToken+=1,this.cleanupNativeEventForwarders(),this.cleanupThemeBinding(),(r=this.readerElement)!=null&&r.parentNode&&this.readerElement.parentNode.removeChild(this.readerElement),this.readerElement=null,this.readerId=null,this.bridge.setReaderId(null),this.readerState.reset(),this.hostContainer=null,this.normalizedConfiguration=null,this.isReady=!1,this.removed=!0,!e)return;const i=ae(null,null);this.emitReaderEvent(Ye,i),this.unloadCallbacks.forEach(a=>a())},this.getDocumentTool=()=>this.documentTool,this.getUITool=()=>this.uiTool,this.getPageTool=()=>this.pageTool,this.getFindTool=()=>this.findTool,this.getSignServerTool=()=>this.signServerTool,this.getDigitalSignTool=()=>this.digitalSignTool,this.getSymbologyTool=()=>this.symbologyTool,this.getAnnotationTool=()=>this.annotationTool,this.getTemplateSignTool=()=>this.templateSignTool,this.getPdfFormFiller=()=>this.pdfFormFiller,this.getNetworkingTool=()=>this.networkingTool,this.getCryptoTool=()=>this.cryptoTool,this.createDigitalSignOptions=()=>new Ae,this.createKVField=(e,i,r)=>new Ce(e,i,r),this.mountReader=async(e,i,r)=>{try{if(await Ue(i.appUrl),this.mountToken!==r)return;const a=document.createElement(S),s=Xe();if(a.setAttribute(Ke,s),this.readerId=s,this.bridge.setReaderId(s),et(a,i),this.themeCleanup=tt(a,i),this.bindNativeReaderEvents(a),e.replaceChildren(a),this.readerElement=a,await Promise.resolve(),this.mountToken!==r)return;i.scrollIntoView&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({behavior:"smooth",block:"nearest"}),this.isReady=!0;const o=ae(a,i);this.emitReaderEvent(je,o),this.readyCallbacks.forEach(d=>d())}catch(a){if(this.mountToken!==r)return;this.reportReaderError(a)}},this.bindNativeReaderEvents=e=>{this.cleanupNativeEventForwarders();const i=r=>{const a=r instanceof CustomEvent?r.detail:null;!a||a.readerId!==this.readerId||(this.readerState.update(a.statePatch),this.callbacks.emit(a.event,a.payload),this.emitReaderEvent(a.event,a.payload))};e.addEventListener(ie,i),this.nativeEventCleanupCallbacks.push(()=>{e.removeEventListener(ie,i)}),$e.forEach(r=>{const a=s=>{const o=s instanceof CustomEvent?s.detail:s;r==="documentLoaded"&&this.readerState.setDocumentOpened(!0),this.emitReaderEvent(r,o),r==="documentError"&&this.emitReaderEvent(F,o)};e.addEventListener(r,a),this.nativeEventCleanupCallbacks.push(()=>{e.removeEventListener(r,a)})})},this.cleanupNativeEventForwarders=()=>{this.nativeEventCleanupCallbacks.splice(0).forEach(e=>e())},this.cleanupThemeBinding=()=>{var e;(e=this.themeCleanup)==null||e.call(this),this.themeCleanup=null},this.emitReaderEvent=(e,i)=>{var r;(r=this.readerEventListener)==null||r.call(this,e,i)},this.reportReaderError=e=>{this.isReady=!1,this.debugEnabled&&console.error("[RHC Office SDK] Reader mount failed",e),this.emitReaderEvent(F,e)},this.reportAdapterError=e=>{this.debugEnabled&&console.error("[RHC Office SDK] Adapter command failed",e),this.emitReaderEvent(F,e)},this.bridge.configureTimeouts({readyTimeoutMs:t==null?void 0:t.adapterReadyTimeoutMs,requestTimeoutMs:t==null?void 0:t.adapterRequestTimeoutMs})}createAnnotationTool(){return R("annotation",{addAnnotationEventCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.annotationEvents.push(i)}},addAnnotationPersistCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.annotationPersist.push(i)}},addAnnotationRetrieveCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.annotationRetrieve.push(i)}},addDigitalAnnotationRetrieveCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.digitalAnnotationRetrieve.push(i)}},isInAnnotationMode:{kind:"stateGetter",state:t=>t.annotationEnabled},getAnnotations:{kind:"stateGetter",state:()=>[]},getAnnotationsCount:{kind:"stateGetter",state:()=>0},queryAnnotationsBy:{kind:"stateGetter",state:()=>[]},setToolSource:{kind:"command"},openAnnotationView:{kind:"command"},closeAnnotationView:{kind:"command"},openTextAnnotationView:{kind:"command"},setTextAnnotationFontColor:{kind:"command"},setTextAnnotationFontSize:{kind:"command"},closeTextAnnotationView:{kind:"command"},createTextAnnotation:{kind:"command"},setPersistToDocument:{kind:"command"},saveAnnotations:{kind:"callbackQuery"},saveTextAnnotations:{kind:"command"},clearAnnotations:{kind:"command"},clearTextAnnotations:{kind:"command"},undoAnnotation:{kind:"command"},redoAnnotation:{kind:"command"},selectAnnotationTool:{kind:"command"},showAnnotationColorPicker:{kind:"command"},setAnnotationPenType:{kind:"command"},appendAnnotations:{kind:"callbackQuery"},batchAppendAnnotations:{kind:"callbackQuery"},setAnnotationPenColor:{kind:"command"},setAnnotationPenWidth:{kind:"command"},setAnnotationPenThickness:{kind:"command"},enableAnnotationsInfoView:{kind:"command"},enableAnnotationsDeletion:{kind:"command"},enableAnnotationsDeletionOnlyByAuthor:{kind:"command"},listDigitalStamps:{kind:"command"},listAnnotations:{kind:"command"},deleteAnnotationsBy:{kind:"command"},deleteAnnotationsById:{kind:"command"},addDigitalAnnotation:{kind:"command"},addInkAnnotationCallback:{kind:"callbackRegister"}},this.bridgeToolContext)}}const U=n=>new L(n),N={DocumentSDK:L,WatermarkDisplay:M,DIGITAL_SIGN_DEFAULTS:X,createNewDocumentSdk:U,newDocumentSDK:U,getDigitalSignEnvironment:z,initializeDigitalSignEnvironment:W,patchDigitalSignEnvironment:j,resetDigitalSignEnvironment:Y,setDigitalSignEnvironment:$};return typeof document<"u"&&(n=>{Object.entries(N).forEach(([t,e])=>{Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0})}),n.RHCOfficeSDK=N})(document),g.DIGITAL_SIGN_DEFAULTS=X,g.DocumentSDK=L,g.RHCOfficeSDK=N,g.WatermarkDisplay=M,g.createNewDocumentSdk=U,g.getDigitalSignEnvironment=z,g.initializeDigitalSignEnvironment=W,g.patchDigitalSignEnvironment=j,g.resetDigitalSignEnvironment=Y,g.setDigitalSignEnvironment=$,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"}),g}({});
|
|
1
|
+
var RHCOfficeSDK=function(l){"use strict";var C=(n=>(n.DEFAULT="default",n.COMPACT="compact",n.HIDE="none",n))(C||{});const U="RIGHT_CENTER",B="REGULAR_ESM",V="auto",I="__RHC_OFFICE_DIGITAL_SIGN_ENVIRONMENT__",K={defaults:{bjca:{pin:""},deviceType:"client",edgePosition:U,kol:{appId:"",appName:"",pin:"",serviceUrl:"",token:""},plugin:{pin:"",usbKeyType:14},rsaMode:V,signatureType:B},signServer:{authSource:"Password",defaultLogin:"",defaultPassword:"",defaultServer:"",kol:{appId:"",appName:"",serviceUrl:"",token:""},macAddress:"",token:"",usbKey:{checkCertificateBinding:!1,usbKeyType:14}}},G=n=>({bjca:{pin:n.bjca.pin},deviceType:n.deviceType,edgePosition:n.edgePosition,kol:{appId:n.kol.appId,appName:n.kol.appName,pin:n.kol.pin,serviceUrl:n.kol.serviceUrl,token:n.kol.token},plugin:{pin:n.plugin.pin,usbKeyType:n.plugin.usbKeyType},rsaMode:n.rsaMode,signatureType:n.signatureType}),x=n=>({authSource:n.authSource,defaultLogin:n.defaultLogin,defaultPassword:n.defaultPassword,defaultServer:n.defaultServer,kol:{appId:n.kol.appId,appName:n.kol.appName,serviceUrl:n.kol.serviceUrl,token:n.kol.token},macAddress:n.macAddress,token:n.token,usbKey:{checkCertificateBinding:n.usbKey.checkCertificateBinding,usbKeyType:n.usbKey.usbKeyType}}),A=n=>({defaults:G(n.defaults),signServer:x(n.signServer)}),H=n=>({defaults:n.defaults?{...n.defaults,bjca:n.defaults.bjca?{...n.defaults.bjca}:void 0,kol:n.defaults.kol?{...n.defaults.kol}:void 0,plugin:n.defaults.plugin?{...n.defaults.plugin}:void 0}:void 0,signServer:n.signServer?{...n.signServer,kol:n.signServer.kol?{...n.signServer.kol}:void 0,usbKey:n.signServer.usbKey?{...n.signServer.usbKey}:void 0}:void 0}),Re=(n,t)=>{var e,i,a,r,s,o,d,m,h,c,g,u,f,k,S,b,T,v,P,D;return t?{bjca:{pin:(i=(e=t.bjca)==null?void 0:e.pin)!=null?i:n.bjca.pin},deviceType:(a=t.deviceType)!=null?a:n.deviceType,edgePosition:(r=t.edgePosition)!=null?r:n.edgePosition,kol:{appId:(o=(s=t.kol)==null?void 0:s.appId)!=null?o:n.kol.appId,appName:(m=(d=t.kol)==null?void 0:d.appName)!=null?m:n.kol.appName,pin:(c=(h=t.kol)==null?void 0:h.pin)!=null?c:n.kol.pin,serviceUrl:(u=(g=t.kol)==null?void 0:g.serviceUrl)!=null?u:n.kol.serviceUrl,token:(k=(f=t.kol)==null?void 0:f.token)!=null?k:n.kol.token},plugin:{pin:(b=(S=t.plugin)==null?void 0:S.pin)!=null?b:n.plugin.pin,usbKeyType:(v=(T=t.plugin)==null?void 0:T.usbKeyType)!=null?v:n.plugin.usbKeyType},rsaMode:(P=t.rsaMode)!=null?P:n.rsaMode,signatureType:(D=t.signatureType)!=null?D:n.signatureType}:G(n)},ye=(n,t)=>{var e,i,a,r,s,o,d,m,h,c,g,u,f,k,S,b,T,v;return t?{authSource:(e=t.authSource)!=null?e:n.authSource,defaultLogin:(i=t.defaultLogin)!=null?i:n.defaultLogin,defaultPassword:(a=t.defaultPassword)!=null?a:n.defaultPassword,defaultServer:(r=t.defaultServer)!=null?r:n.defaultServer,kol:{appId:(o=(s=t.kol)==null?void 0:s.appId)!=null?o:n.kol.appId,appName:(m=(d=t.kol)==null?void 0:d.appName)!=null?m:n.kol.appName,serviceUrl:(c=(h=t.kol)==null?void 0:h.serviceUrl)!=null?c:n.kol.serviceUrl,token:(u=(g=t.kol)==null?void 0:g.token)!=null?u:n.kol.token},macAddress:(f=t.macAddress)!=null?f:n.macAddress,token:(k=t.token)!=null?k:n.token,usbKey:{checkCertificateBinding:(b=(S=t.usbKey)==null?void 0:S.checkCertificateBinding)!=null?b:n.usbKey.checkCertificateBinding,usbKeyType:(v=(T=t.usbKey)==null?void 0:T.usbKeyType)!=null?v:n.usbKey.usbKeyType}}:x(n)},q=(n,t)=>({defaults:Re(n.defaults,t.defaults),signServer:ye(n.signServer,t.signServer)}),Ee=(n,t)=>{var e,i,a,r,s,o,d,m,h,c,g,u,f,k,S,b,T,v,P,D;return{defaults:n.defaults||t.defaults?{...n.defaults,...t.defaults,bjca:{...(i=(e=n.defaults)==null?void 0:e.bjca)!=null?i:{},...(r=(a=t.defaults)==null?void 0:a.bjca)!=null?r:{}},kol:{...(o=(s=n.defaults)==null?void 0:s.kol)!=null?o:{},...(m=(d=t.defaults)==null?void 0:d.kol)!=null?m:{}},plugin:{...(c=(h=n.defaults)==null?void 0:h.plugin)!=null?c:{},...(u=(g=t.defaults)==null?void 0:g.plugin)!=null?u:{}}}:void 0,signServer:n.signServer||t.signServer?{...n.signServer,...t.signServer,kol:{...(k=(f=n.signServer)==null?void 0:f.kol)!=null?k:{},...(b=(S=t.signServer)==null?void 0:S.kol)!=null?b:{}},usbKey:{...(v=(T=n.signServer)==null?void 0:T.usbKey)!=null?v:{},...(D=(P=t.signServer)==null?void 0:P.usbKey)!=null?D:{}}}:void 0}},Pe=()=>globalThis,y=()=>{const n=Pe();return n[I]||(n[I]={current:A(K),defaults:A(K),overrides:{}}),n[I]},Q=()=>y().current,z=n=>{const t=y();return t.defaults=A(n),t.current=q(t.defaults,t.overrides),t.current},W=n=>{const t=y();return t.current=A(n),t.overrides=H(n),t.current},$=n=>{const t=y();return t.overrides=Ee(t.overrides,H(n)),t.current=q(t.current,n),t.current},j=n=>{const t=y();return n&&(t.defaults=A(n)),t.overrides={},t.current=A(t.defaults),t.current},Y={EDGE_POSITION:U,RSA_MODE:V,SIGNATURE_TYPE:B},w=n=>{if(n.length!==0)return n.length===1?n[0]:n},p=(n,t,e)=>new Proxy({},{get:(i,a)=>{if(a==="then")return;if(typeof a=="symbol")return a===Symbol.toStringTag?n:void 0;const r=t[a];return r?(...s)=>{var d,m,h;if(r.kind==="callbackRegister"){(d=r.callback)==null||d.call(r,e.callbacks,s);return}if(r.kind==="stateGetter")return(m=r.state)==null?void 0:m.call(r,e.state.snapshot(),s);const o=(h=r.adapterMethod)!=null?h:a;if(r.kind==="query")return e.bridge.request(n,o,w(s));if(r.kind==="callbackQuery"){const c=s.find(u=>typeof u=="function"),g=s.filter(u=>typeof u!="function");e.bridge.request(n,o,w(g)).then(u=>{var k,S;const f=(S=(k=r.mapCallbackResult)==null?void 0:k.call(r,u))!=null?S:[u];c==null||c(...f)}).catch(e.onAsyncError);return}e.bridge.request(n,o,w(s)).catch(e.onAsyncError)}:(...s)=>{const o=new Error(`${n}.${a} is not implemented by the SDK adapter.`);e.onAsyncError(o)}}}),De={addAnnotationEventCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.annotationEvents.push(e)}},addAnnotationPersistCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.annotationPersist.push(e)}},addAnnotationRetrieveCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.annotationRetrieve.push(e)}},addDigitalAnnotationRetrieveCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.digitalAnnotationRetrieve.push(e)}},isInAnnotationMode:{kind:"stateGetter",state:n=>n.annotationEnabled},getAnnotations:{kind:"stateGetter",state:()=>[]},getAnnotationsCount:{kind:"stateGetter",state:()=>0},queryAnnotationsBy:{kind:"stateGetter",state:()=>[]},setToolSource:{kind:"command"},openAnnotationView:{kind:"command"},closeAnnotationView:{kind:"command"},openTextAnnotationView:{kind:"command"},setTextAnnotationFontColor:{kind:"command"},setTextAnnotationFontSize:{kind:"command"},closeTextAnnotationView:{kind:"command"},createTextAnnotation:{kind:"command"},setPersistToDocument:{kind:"command"},saveAnnotations:{kind:"callbackQuery"},saveTextAnnotations:{kind:"command"},clearAnnotations:{kind:"command"},clearTextAnnotations:{kind:"command"},undoAnnotation:{kind:"command"},redoAnnotation:{kind:"command"},selectAnnotationTool:{kind:"command"},showAnnotationColorPicker:{kind:"command"},setAnnotationPenType:{kind:"command"},appendAnnotations:{kind:"callbackQuery"},batchAppendAnnotations:{kind:"callbackQuery"},setAnnotationPenColor:{kind:"command"},setAnnotationPenWidth:{kind:"command"},setAnnotationPenThickness:{kind:"command"},enableAnnotationsInfoView:{kind:"command"},enableAnnotationsDeletion:{kind:"command"},enableAnnotationsDeletionOnlyByAuthor:{kind:"command"},listDigitalStamps:{kind:"command"},listAnnotations:{kind:"command"},deleteAnnotationsBy:{kind:"command"},deleteAnnotationsById:{kind:"command"},addDigitalAnnotation:{kind:"command"},addInkAnnotationCallback:{kind:"callbackRegister"}};class X{constructor(t){this.setToolSource=e=>this.adapter.setToolSource(e),this.openAnnotationView=e=>this.adapter.openAnnotationView(e),this.closeAnnotationView=e=>this.adapter.closeAnnotationView(e),this.openTextAnnotationView=()=>this.adapter.openTextAnnotationView(),this.setTextAnnotationFontColor=e=>this.adapter.setTextAnnotationFontColor(e),this.setTextAnnotationFontSize=e=>this.adapter.setTextAnnotationFontSize(e),this.closeTextAnnotationView=e=>this.adapter.closeTextAnnotationView(e),this.createTextAnnotation=e=>this.adapter.createTextAnnotation(e),this.setPersistToDocument=e=>this.adapter.setPersistToDocument(e),this.saveAnnotations=e=>this.adapter.saveAnnotations(e),this.saveTextAnnotations=()=>this.adapter.saveTextAnnotations(),this.clearAnnotations=()=>this.adapter.clearAnnotations(),this.clearTextAnnotations=()=>this.adapter.clearTextAnnotations(),this.undoAnnotation=()=>this.adapter.undoAnnotation(),this.redoAnnotation=()=>this.adapter.redoAnnotation(),this.selectAnnotationTool=e=>this.adapter.selectAnnotationTool(e),this.showAnnotationColorPicker=()=>this.adapter.showAnnotationColorPicker(),this.setAnnotationPenType=e=>this.adapter.setAnnotationPenType(e),this.appendAnnotations=(e,i)=>this.adapter.appendAnnotations(e,i),this.batchAppendAnnotations=(e,i)=>this.adapter.batchAppendAnnotations(e,i),this.setAnnotationPenColor=e=>this.adapter.setAnnotationPenColor(e),this.setAnnotationPenWidth=e=>this.adapter.setAnnotationPenWidth(e),this.setAnnotationPenThickness=e=>this.adapter.setAnnotationPenThickness(e),this.enableAnnotationsInfoView=e=>this.adapter.enableAnnotationsInfoView(e),this.enableAnnotationsDeletion=e=>this.adapter.enableAnnotationsDeletion(e),this.enableAnnotationsDeletionOnlyByAuthor=e=>this.adapter.enableAnnotationsDeletionOnlyByAuthor(e),this.listDigitalStamps=()=>this.adapter.listDigitalStamps(),this.isInAnnotationMode=()=>this.adapter.isInAnnotationMode(),this.listAnnotations=e=>this.adapter.listAnnotations(e),this.getAnnotations=()=>this.adapter.getAnnotations(),this.getAnnotationsCount=()=>this.adapter.getAnnotationsCount(),this.queryAnnotationsBy=e=>this.adapter.queryAnnotationsBy(e),this.deleteAnnotationsBy=(e,i)=>this.adapter.deleteAnnotationsBy(e,i),this.deleteAnnotationsById=(e,i)=>this.adapter.deleteAnnotationsById(e,i),this.addDigitalAnnotation=e=>this.adapter.addDigitalAnnotation(e),this.addInkAnnotationCallback=e=>this.adapter.addInkAnnotationCallback(e),this.addAnnotationEventCallback=e=>this.adapter.addAnnotationEventCallback(e),this.addAnnotationPersistCallback=e=>this.adapter.addAnnotationPersistCallback(e),this.addAnnotationRetrieveCallback=e=>this.adapter.addAnnotationRetrieveCallback(e),this.addDigitalAnnotationRetrieveCallback=e=>this.adapter.addDigitalAnnotationRetrieveCallback(e),this.adapter=p("annotation",De,t)}}const Ce={configSecurityProvider:{kind:"command"},getSecurityProviders:{kind:"query"}};class J{constructor(t){this.configSecurityProvider=e=>this.adapter.configSecurityProvider(e),this.getSecurityProviders=()=>this.adapter.getSecurityProviders(),this.adapter=p("crypto",Ce,t)}}const Ie={addDigitalSignatureRetrieveCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.digitalSignatureRetrieve.push(e)}},addDigitalSignatureParseCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.digitalSignatureParse.push(e)}},addDigitalSignCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.digitalSign.push(e)}},setCryptoProvider:{kind:"command"},setSealSource:{kind:"command"},setDefaultStampPassword:{kind:"command"},setDefaultSealPassword:{kind:"command"},setDefaultKeystorePassword:{kind:"command"},setDefaultUSBKeyPassword:{kind:"command"},setupExternalSealServer:{kind:"command"},setDigitalSignOptions:{kind:"command"},setExternalDigitalSignOptions:{kind:"command"},setPDFDigitalSignCaptionOptions:{kind:"command"},addDigitalSignature:{kind:"callbackQuery"},addDigitalSignatureBySelectedSearchHighlight:{kind:"command"},listDigitalSignatures:{kind:"callbackQuery"},getDigitalSignatures:{kind:"stateGetter",state:()=>[]},getDigitalSignaturesCount:{kind:"stateGetter",state:()=>0},enableDigitalSignatureInfoView:{kind:"command"},enableDigitalSignatureRevocation:{kind:"command"}};class Z{constructor(t){this.addDigitalSignatureRetrieveCallback=e=>this.adapter.addDigitalSignatureRetrieveCallback(e),this.addDigitalSignatureParseCallback=e=>this.adapter.addDigitalSignatureParseCallback(e),this.setCryptoProvider=(e,i,a)=>this.adapter.setCryptoProvider(e,i,a),this.setSealSource=e=>this.adapter.setSealSource(e),this.setDefaultStampPassword=e=>this.adapter.setDefaultStampPassword(e),this.setDefaultSealPassword=e=>this.adapter.setDefaultSealPassword(e),this.setDefaultKeystorePassword=e=>this.adapter.setDefaultKeystorePassword(e),this.setDefaultUSBKeyPassword=e=>this.adapter.setDefaultUSBKeyPassword(e),this.addDigitalSignCallback=e=>this.adapter.addDigitalSignCallback(e),this.setupExternalSealServer=e=>this.adapter.setupExternalSealServer(e),this.setDigitalSignOptions=e=>this.adapter.setDigitalSignOptions(e),this.setExternalDigitalSignOptions=e=>this.adapter.setExternalDigitalSignOptions(e),this.setPDFDigitalSignCaptionOptions=e=>this.adapter.setPDFDigitalSignCaptionOptions(e),this.addDigitalSignature=(e,i)=>this.adapter.addDigitalSignature(e,i),this.addDigitalSignatureBySelectedSearchHighlight=e=>this.adapter.addDigitalSignatureBySelectedSearchHighlight(e),this.listDigitalSignatures=e=>this.adapter.listDigitalSignatures(e),this.getDigitalSignatures=()=>this.adapter.getDigitalSignatures(),this.getDigitalSignaturesCount=()=>this.adapter.getDigitalSignaturesCount(),this.enableDigitalSignatureInfoView=e=>this.adapter.enableDigitalSignatureInfoView(e),this.enableDigitalSignatureRevocation=e=>this.adapter.enableDigitalSignatureRevocation(e),this.adapter=p("digitalSign",Ie,t)}}const we="rhc-office.editor-adapter",Me=1,Oe="__RHC_OFFICE_EDITOR_ADAPTER__",ee="rhcOfficeAdapterReady",te="rhcOfficeAdapterEvent",ne="data-rhc-office-reader-id",_e={addDocumentOpenedCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.documentOpened.push(e)}},addDocumentSavedCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.documentSaved.push(e)}},addDocumentClosedCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.documentClosed.push(e)}},openPDFDocument:{kind:"callbackQuery",adapterMethod:"open"},openPdfDocument:{kind:"callbackQuery",adapterMethod:"open"},openOFDDocument:{kind:"callbackQuery",adapterMethod:"open"},openOfdDocument:{kind:"callbackQuery",adapterMethod:"open"},openOfficeDocument:{kind:"callbackQuery",adapterMethod:"open"},openImageDocument:{kind:"callbackQuery",adapterMethod:"open"},openTextDocument:{kind:"callbackQuery",adapterMethod:"open"},openFromLocalStorage:{kind:"command"},setUploadUrl:{kind:"command"},save:{kind:"callbackQuery"},saveAs:{kind:"query"},getDocumentContent:{kind:"callbackQuery",mapCallbackResult:n=>{const t=n;return[t==null?void 0:t.fileCacheId,t==null?void 0:t.fileBuffer]}},closeDocument:{kind:"callbackQuery"},isDocumentOpened:{kind:"stateGetter",state:n=>n.documentOpened},isDocumentModified:{kind:"stateGetter",state:n=>n.documentModified},print:{kind:"command"},createPreview:{kind:"command"}};class ie{constructor(t){this.context=t,this.addDocumentOpenedCallback=e=>this.adapter.addDocumentOpenedCallback(e),this.addDocumentSavedCallback=e=>this.adapter.addDocumentSavedCallback(e),this.addDocumentClosedCallback=e=>this.adapter.addDocumentClosedCallback(e),this.openPDFDocument=(e,i)=>this.adapter.openPDFDocument(e,i),this.openPdfDocument=(e,i)=>this.adapter.openPdfDocument(e,i),this.openOFDDocument=(e,i)=>this.adapter.openOFDDocument(e,i),this.openOfdDocument=(e,i)=>this.adapter.openOfdDocument(e,i),this.openOfficeDocument=(e,i)=>this.adapter.openOfficeDocument(e,i),this.openImageDocument=(e,i)=>this.adapter.openImageDocument(e,i),this.openTextDocument=(e,i)=>this.adapter.openTextDocument(e,i),this.openFromLocalStorage=()=>this.adapter.openFromLocalStorage(),this.setUploadUrl=e=>this.adapter.setUploadUrl(e),this.save=(e,i,a)=>this.adapter.save(e,i,a),this.saveAs=e=>{const i=this.context.bridge.getReaderId();if(!i)return Promise.resolve({success:!1,action:"save-as",filename:e==null?void 0:e.filename,error:"Reader is not mounted or does not expose saveAs."});const a=document.querySelector(`[${ne}="${i}"]`);return typeof(a==null?void 0:a.saveAs)=="function"?a.saveAs(e):this.adapter.saveAs(e)},this.getDocumentContent=e=>this.adapter.getDocumentContent(e),this.closeDocument=(e,i,a)=>this.adapter.closeDocument(e,i,a),this.isDocumentOpened=()=>this.adapter.isDocumentOpened(),this.isDocumentModified=()=>this.adapter.isDocumentModified(),this.print=()=>this.adapter.print(),this.createPreview=(e,i)=>this.adapter.createPreview(e,i),this.adapter=p("document",_e,t)}}const Fe={clearFind:{kind:"command"},findNext:{kind:"command"},findPrevious:{kind:"command"}};class ae{constructor(t){this.clearFind=()=>this.adapter.clearFind(),this.findNext=e=>this.adapter.findNext(e),this.findPrevious=e=>this.adapter.findPrevious(e),this.adapter=p("find",Fe,t)}}const Le={configFileUpload:{kind:"command"},setHttpHeaders:{kind:"command"},setHttpFormFields:{kind:"command"}};class re{constructor(t){this.configFileUpload=e=>this.adapter.configFileUpload(e),this.setHttpHeaders=e=>this.adapter.setHttpHeaders(e),this.setHttpFormFields=e=>this.adapter.setHttpFormFields(e),this.adapter=p("networking",Le,t)}}const Ne=n=>({addPageChangeCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.pageChange.push(i)}},addPageModeChangeCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.pageModeChange.push(i)}},getPageCount:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&i(n.state.snapshot().pageCount)}},getPageIndex:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&i(n.state.snapshot().pageIndex)}},setSinglePageViewMode:{kind:"command"},setTwoPagesViewMode:{kind:"command"},setPageScrollVertical:{kind:"command"},setPageScrollHorizontal:{kind:"command"},setPageCursorPanDrag:{kind:"command"},setPageCursorTextSelect:{kind:"command"},rotateCW:{kind:"command"},rotateCCW:{kind:"command"},autoFitPage:{kind:"command"},fitPageSize:{kind:"command"},fitPageWidth:{kind:"command"},fitPageHeight:{kind:"command"},increasePageScale:{kind:"command"},decreasePageScale:{kind:"command"},setPageScale:{kind:"command"},setPageBlendColor:{kind:"command"},gotoPage:{kind:"command"},gotoNextPage:{kind:"command"},gotoPreviousPage:{kind:"command"},rotatePage:{kind:"command"}});class se{constructor(t){this.addPageChangeCallback=e=>this.adapter.addPageChangeCallback(e),this.addPageModeChangeCallback=e=>this.adapter.addPageModeChangeCallback(e),this.getPageCount=e=>this.adapter.getPageCount(e),this.getPageIndex=e=>this.adapter.getPageIndex(e),this.setSinglePageViewMode=()=>this.adapter.setSinglePageViewMode(),this.setTwoPagesViewMode=()=>this.adapter.setTwoPagesViewMode(),this.setPageScrollVertical=()=>this.adapter.setPageScrollVertical(),this.setPageScrollHorizontal=()=>this.adapter.setPageScrollHorizontal(),this.setPageCursorPanDrag=()=>this.adapter.setPageCursorPanDrag(),this.setPageCursorTextSelect=()=>this.adapter.setPageCursorTextSelect(),this.rotateCW=()=>this.adapter.rotateCW(),this.rotateCCW=()=>this.adapter.rotateCCW(),this.autoFitPage=()=>this.adapter.autoFitPage(),this.fitPageSize=()=>this.adapter.fitPageSize(),this.fitPageWidth=()=>this.adapter.fitPageWidth(),this.fitPageHeight=()=>this.adapter.fitPageHeight(),this.increasePageScale=()=>this.adapter.increasePageScale(),this.decreasePageScale=()=>this.adapter.decreasePageScale(),this.setPageScale=e=>this.adapter.setPageScale(e),this.setPageBlendColor=(e,i,a,r)=>this.adapter.setPageBlendColor(e,i,a,r),this.gotoPage=(e,i,a)=>this.adapter.gotoPage(e,i,a),this.gotoNextPage=()=>this.adapter.gotoNextPage(),this.gotoPreviousPage=()=>this.adapter.gotoPreviousPage(),this.rotatePage=e=>this.adapter.rotatePage(e),this.adapter=p("page",Ne(t),t)}}const Ue={open:{kind:"command"},setFormFieldValue:{kind:"command"},setFormFieldReadonly:{kind:"command"},commit:{kind:"callbackQuery",mapCallbackResult:()=>[]},clear:{kind:"callbackQuery",mapCallbackResult:()=>[]},toKeyValue:{kind:"callbackQuery",mapCallbackResult:n=>[Array.isArray(n)?n:[]]}};class oe{constructor(t){this.open=()=>this.adapter.open(),this.setFormFieldValue=(e,i)=>this.adapter.setFormFieldValue(e,i),this.setFormFieldReadonly=(e,i)=>this.adapter.setFormFieldReadonly(e,i),this.commit=e=>this.adapter.commit(e),this.clear=e=>this.adapter.clear(e),this.toKeyValue=e=>this.adapter.toKeyValue(e),this.adapter=p("pdfFormFiller",Ue,t)}}class de extends Error{constructor(t,e){super(`[Phase 1] ${t}.${e} is not implemented yet.`),this.name="SDKPhase1NotImplementedError"}}const Be=(n,t)=>()=>{throw new de(n,t)},Ve=n=>new Proxy({},{get:(t,e)=>{if(e!=="then")return typeof e=="symbol"?e===Symbol.toStringTag?n:void 0:Be(n,e)}}),Ke=/\s*,\s*/,Ge=/\s*-\s*/,M=n=>{const t=Number.parseInt(n.trim(),10);return!Number.isFinite(t)||t<=0?null:t},xe=n=>{var a,r,s;const t=n.split(Ge);if(t.length===1){const o=M((a=t[0])!=null?a:"");return o?[o]:[]}const e=M((r=t[0])!=null?r:""),i=M((s=t[1])!=null?s:"");return!e||!i||i<e?[]:Array.from({length:i-e+1},(o,d)=>e+d)},He=n=>n?n.split(Ke).flatMap(e=>xe(e)).filter((e,i,a)=>a.indexOf(e)===i):[];class le{constructor(t,e,i){this.setFieldName=a=>{this.key=a},this.setFieldValue=a=>{this.value=a},this.setDescription=a=>{this.description=a},this.key=t,this.value=e,this.description=i}}class ce{constructor(){this.fields=[],this.keywordTextFixedPositions=void 0,this.keywordOffsetX=0,this.keywordOffsetY=0,this.bookmarkOffsetX=0,this.bookmarkOffsetY=0,this.printMargin=0,this.grayscaleSealImage=!1,this.signType=0,this.sealPosition=0,this.getSignType=()=>this.signType,this.setSignType=t=>{this.signType=t},this.isCrossPageSideSign=()=>this.signType===2||this.signType===3,this.getSealPosition=()=>this.sealPosition,this.setSignOnPageSides=t=>{t>=0&&t<=3&&(this.signType=t)},this.setSignPositionOnPageSides=t=>{this.sealPosition=t},this.setPageRange=t=>{this.pageRange=t},this.getPageRange=()=>this.pageRange,this.getPageRanges=()=>He(this.pageRange),this.setSignUserData=t=>{this.signUserData=t},this.setPrintMargin=t=>{this.printMargin=t},this.getPrintMargin=()=>{var t;return(t=this.printMargin)!=null?t:0},this.setSignReason=t=>{this.signReason=t},this.getSignReason=()=>this.signReason,this.setSignLocation=t=>{this.signLocation=t},this.getSignLocation=()=>this.signLocation,this.setDefaultStampPassword=t=>{this.defaultStampPassword=t}}}const qe={setSignServer:{kind:"command"},addSignServerAuthCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.signServerAuth.push(e)}},setSignServerDefaultLogin:{kind:"command"},setDefaultSignServerLogin:{kind:"command"},setSignServerDefaultPassword:{kind:"command"},setDefaultSignServerPassword:{kind:"command"},loginNTKOSignServer:{kind:"command"},loginSignServer:{kind:"callbackQuery"},signOutSignServer:{kind:"command"},isAuthenticatedOnSignServer:{kind:"stateGetter",state:()=>!1},setSignServerLoginFromUSBKey:{kind:"command"},setUserAuthSource:{kind:"command"}};class ue{constructor(t){this.setSignServer=e=>this.adapter.setSignServer(e),this.addSignServerAuthCallback=e=>this.adapter.addSignServerAuthCallback(e),this.setSignServerDefaultLogin=e=>this.adapter.setSignServerDefaultLogin(e),this.setDefaultSignServerLogin=e=>this.adapter.setDefaultSignServerLogin(e),this.setSignServerDefaultPassword=e=>this.adapter.setSignServerDefaultPassword(e),this.setDefaultSignServerPassword=e=>this.adapter.setDefaultSignServerPassword(e),this.loginNTKOSignServer=(e,i,a)=>this.adapter.loginNTKOSignServer(e,i,a),this.loginSignServer=(e,i,a,r)=>this.adapter.loginSignServer(e,i,a,r),this.signOutSignServer=()=>this.adapter.signOutSignServer(),this.isAuthenticatedOnSignServer=()=>this.adapter.isAuthenticatedOnSignServer(),this.setSignServerLoginFromUSBKey=(e,i)=>this.adapter.setSignServerLoginFromUSBKey(e,i),this.setUserAuthSource=e=>this.adapter.setUserAuthSource(e),this.adapter=p("signServer",qe,t)}}const Qe={createPDF417Barcode:{kind:"command"}};class he{constructor(t){this.createPDF417Barcode=(e,i,a,r,s,o,d)=>this.adapter.createPDF417Barcode(e,i,a,r,s,o,d),this.adapter=p("symbology",Qe,t)}}const ze={setup:{kind:"command"},create:{kind:"command"},getMarkups:{kind:"callbackQuery"},removeMarkup:{kind:"command"},removeAllMarkups:{kind:"command"},sign:{kind:"callbackQuery"}};class me{constructor(t){this.setup=e=>this.adapter.setup(e),this.create=e=>this.adapter.create(e),this.getMarkups=e=>this.adapter.getMarkups(e),this.removeMarkup=(e,i)=>this.adapter.removeMarkup(e,i),this.removeAllMarkups=e=>this.adapter.removeAllMarkups(e),this.sign=e=>this.adapter.sign(e),this.adapter=p("templateSign",ze,t)}}const We=new Set([2,5]),$e=n=>({showToolbarMenu:{kind:"command"},hideToolbarMenu:{kind:"command"},setupToolbarMenu:{kind:"command"},showToolbarMenuItem:{kind:"command"},hideToolbarMenuItem:{kind:"command"},setupRibbonMenu:{kind:"command"},setupRibbonMenuItem:{kind:"command"},setupRibbonTitleBar:{kind:"command"},showRibbonMenu:{kind:"command"},hideRibbonMenu:{kind:"command"},showRibbonMenuItem:{kind:"command"},hideRibbonMenuItem:{kind:"command"},showRibbonTitleBar:{kind:"command"},hideRibbonTitleBar:{kind:"command"},selectRibbonMenu:{kind:"command"},setRibbonMenuButtonStyle:{kind:"command"},setWatermark:{kind:"command"},setCompactMode:{kind:"command"},enterBookViewMode:{kind:"callbackQuery",mapCallbackResult:()=>[]},exitBookViewMode:{kind:"command"},isBookViewActivated:{kind:"stateGetter",state:()=>We.has(n.state.snapshot().pageMode)},requestFullScreen:{kind:"command"},exitFullScreen:{kind:"command"},invalidateView:{kind:"command"}});class ge{constructor(t){this.showToolbarMenu=()=>this.adapter.showToolbarMenu(),this.hideToolbarMenu=()=>this.adapter.hideToolbarMenu(),this.setupToolbarMenu=e=>this.adapter.setupToolbarMenu(e),this.showToolbarMenuItem=e=>this.adapter.showToolbarMenuItem(e),this.hideToolbarMenuItem=e=>this.adapter.hideToolbarMenuItem(e),this.setupRibbonMenu=e=>this.adapter.setupRibbonMenu(e),this.setupRibbonMenuItem=(e,i,a)=>this.adapter.setupRibbonMenuItem(e,i,a),this.setupRibbonTitleBar=e=>this.adapter.setupRibbonTitleBar(e),this.showRibbonMenu=()=>this.adapter.showRibbonMenu(),this.hideRibbonMenu=()=>this.adapter.hideRibbonMenu(),this.showRibbonMenuItem=(e,i)=>this.adapter.showRibbonMenuItem(e,i),this.hideRibbonMenuItem=(e,i)=>this.adapter.hideRibbonMenuItem(e,i),this.showRibbonTitleBar=()=>this.adapter.showRibbonTitleBar(),this.hideRibbonTitleBar=()=>this.adapter.hideRibbonTitleBar(),this.selectRibbonMenu=e=>this.adapter.selectRibbonMenu(e),this.setRibbonMenuButtonStyle=(e,i)=>this.adapter.setRibbonMenuButtonStyle(e,i),this.setWatermark=e=>this.adapter.setWatermark(e),this.setCompactMode=e=>this.adapter.setCompactMode(e),this.enterBookViewMode=e=>this.adapter.enterBookViewMode(e),this.exitBookViewMode=()=>this.adapter.exitBookViewMode(),this.isBookViewActivated=()=>this.adapter.isBookViewActivated(),this.requestFullScreen=()=>this.adapter.requestFullScreen(),this.exitFullScreen=()=>this.adapter.exitFullScreen(),this.invalidateView=()=>this.adapter.invalidateView(),this.adapter=p("ui",$e(t),t)}}const je=n=>{if(!n)return;const t=n.trim().toLowerCase();if(t==="application")return"auto";if(t==="light"||t==="dark"||t==="high-contrast"||t==="auto")return t},pe=n=>{var e,i;const t=new URL(n,(i=(e=globalThis.location)==null?void 0:e.href)!=null?i:"http://localhost/");return t.hash="",t.pathname.endsWith("/")||(t.pathname=`${t.pathname}/`),t.toString()},Ye=n=>new URL("editors.bootstrap.js",n).toString(),Xe=(n,t)=>{var i;const e=pe(n);return{...t,appUrl:e,scrollIntoView:(i=t.scrollIntoView)!=null?i:!0,theme:je(t.theme)}},R="rhc-office-editor",O="__RHC_OFFICE_SDK_READER_LOADER__",ke=()=>{const n=globalThis;return n[O]||(n[O]={activeAppUrl:null,loadPromises:new Map}),n[O]},Je=n=>{var t;return(t=Array.from(document.querySelectorAll("script")).find(e=>e.src===n))!=null?t:null};class Se extends Error{constructor(t){super(`Failed to load reader bootstrap script: ${t}`),this.name="ReaderScriptLoadError"}}class Ze extends Error{constructor(t,e){super(`Reader Web Component "${R}" is already bound to ${t} and cannot be reloaded from ${e}.`),this.name="ReaderSourceConflictError"}}const fe=n=>{const t=ke();if(t.activeAppUrl&&t.activeAppUrl!==n)throw new Ze(t.activeAppUrl,n)},et=n=>{var s;const t=ke();fe(n);const e=t.loadPromises.get(n);if(e)return e;if((s=globalThis.customElements)!=null&&s.get(R)){t.activeAppUrl=n;const o=Promise.resolve();return t.loadPromises.set(n,o),o}const i=Ye(n),a=Je(i);t.activeAppUrl=n;const r=new Promise((o,d)=>{var g;const m=u=>{u==null||u.remove(),d(new Se(i))},h=()=>{globalThis.customElements.whenDefined(R).then(()=>{o()}).catch(d)};if(a){if((g=globalThis.customElements)!=null&&g.get(R)){o();return}a.addEventListener("error",()=>d(new Se(i)),{once:!0}),h();return}const c=document.createElement("script");c.src=i,c.async=!0,c.dataset.rhcOfficeSdkReader=n,c.addEventListener("load",h,{once:!0}),c.addEventListener("error",()=>m(c),{once:!0}),document.head.appendChild(c)}).catch(o=>{var d;throw t.loadPromises.delete(n),!((d=globalThis.customElements)!=null&&d.get(R))&&t.activeAppUrl===n&&(t.activeAppUrl=null),o});return t.loadPromises.set(n,r),r},tt=5e3,nt=5e3,it=()=>{const n=globalThis.crypto;return typeof(n==null?void 0:n.randomUUID)=="function"?n.randomUUID():`adapter-${Date.now()}-${Math.random().toString(36).slice(2)}`},E=()=>globalThis[Oe];class at extends Error{constructor(t,e,i){super(e),this.name="ReaderBridgeError",this.code=t,this.details=i}}class rt{constructor(t){var e,i;this.readerId=null,this.readyTimeoutMs=(e=t==null?void 0:t.readyTimeoutMs)!=null?e:nt,this.requestTimeoutMs=(i=t==null?void 0:t.requestTimeoutMs)!=null?i:tt}configureTimeouts(t){var e,i;this.readyTimeoutMs=(e=t==null?void 0:t.readyTimeoutMs)!=null?e:this.readyTimeoutMs,this.requestTimeoutMs=(i=t==null?void 0:t.requestTimeoutMs)!=null?i:this.requestTimeoutMs}setReaderId(t){this.readerId=t}getReaderId(){return this.readerId}async request(t,e,i,a){const r=await this.requestRaw(t,e,i,a);if(r.ok)return r.result;throw new at(r.error.code,r.error.message,r.error.details)}async requestRaw(t,e,i,a){var o;if(!this.readerId)return{ok:!1,requestId:"",error:{code:"READER_NOT_READY",message:"Reader is not mounted."}};const r=await this.waitForAdapter(this.readerId,a==null?void 0:a.timeoutMs);if(!r)return{ok:!1,requestId:"",error:{code:"ADAPTER_UNAVAILABLE",message:"Editor adapter is not available."}};const s={protocol:we,version:Me,requestId:it(),readerId:this.readerId,tool:t,method:e,params:i};return this.withTimeout(r.request(s),s.requestId,(o=a==null?void 0:a.timeoutMs)!=null?o:this.requestTimeoutMs)}getCapabilities(){var t,e;return this.readerId&&(e=(t=E())==null?void 0:t.getCapabilities(this.readerId))!=null?e:null}async waitForAdapter(t,e=this.readyTimeoutMs){const i=E();return i!=null&&i.getCapabilities(t)?i:new Promise(a=>{let r;const s=()=>{r&&clearTimeout(r),globalThis.removeEventListener(ee,o)},o=d=>{const m=d instanceof CustomEvent?d.detail:void 0;if((m==null?void 0:m.readerId)!==t)return;const h=E();s(),a(h!=null?h:null)};globalThis.addEventListener(ee,o),r=setTimeout(()=>{var d;s(),a((d=E())!=null&&d.getCapabilities(t)?E():null)},e)})}async withTimeout(t,e,i){return new Promise(a=>{const r=setTimeout(()=>{a({ok:!1,requestId:e,error:{code:"TIMEOUT",message:`Editor adapter request timed out after ${i}ms.`}})},i);t.then(s=>a(s)).catch(s=>{a({ok:!1,requestId:e,error:{code:"EXECUTION_FAILED",message:s instanceof Error?s.message:String(s)}})}).finally(()=>{clearTimeout(r)})})}}const be={annotationEnabled:!1,documentModified:!1,documentOpened:!1,pageCount:0,pageIndex:1,pageMode:0,zoomLevel:100};class st{constructor(){this.state={...be}}reset(){this.state={...be}}update(t){t&&(this.state={...this.state,...t})}setDocumentOpened(t){this.state={...this.state,documentOpened:t}}snapshot(){return{...this.state}}}class ot{constructor(){this.annotationEvents=[],this.annotationPersist=[],this.annotationRetrieve=[],this.digitalAnnotationRetrieve=[],this.digitalSign=[],this.digitalSignatureParse=[],this.digitalSignatureRetrieve=[],this.documentClosed=[],this.documentOpened=[],this.documentSaved=[],this.pageChange=[],this.pageModeChange=[],this.signServerAuth=[]}emit(t,e){switch(t){case"documentOpened":case"documentLoaded":this.documentOpened.forEach(i=>i("ok",""));return;case"documentSaved":this.documentSaved.forEach(i=>i(e));return;case"documentClosed":this.documentClosed.forEach(i=>i(e));return;case"pageChange":{const i=e;this.pageChange.forEach(a=>{var r,s;return a((r=i.pageIndex)!=null?r:1,(s=i.pageCount)!=null?s:0)});return}case"pageModeChange":{const i=e;this.pageModeChange.forEach(a=>{var r;return a((r=i.pageMode)!=null?r:0)});return}case"annotationEvent":{const i=e;this.annotationEvents.forEach(a=>{var r;return a((r=i.event)!=null?r:"annotationEvent",i.payload)});return}case"annotationPersist":this.annotationPersist.forEach(i=>i(e));return;case"annotationRetrieve":this.annotationRetrieve.forEach(i=>i(e));return;case"digitalAnnotationRetrieve":this.digitalAnnotationRetrieve.forEach(i=>i(Array.isArray(e)?e:[]));return;case"digitalSign":this.digitalSign.forEach(i=>i(e));return;case"digitalSignatureRetrieve":this.digitalSignatureRetrieve.forEach(i=>i(Array.isArray(e)?e:[]));return;case"digitalSignatureParse":this.digitalSignatureParse.forEach(i=>i(Array.isArray(e)?e:[]));return;case"signServerAuth":this.signServerAuth.forEach(i=>i(e));return;default:return}}}const dt=["documentLoaded","documentStateChange","documentError"],lt="readerReady",ct="readerUnload",_="readerError",ut=()=>{var n;return typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function"?globalThis.crypto.randomUUID():`rhc-reader-${Date.now()}-${Math.random().toString(36).slice(2)}`},Te=(n,t)=>{var e;return{appUrl:(e=t==null?void 0:t.appUrl)!=null?e:null,configuration:t,element:n}},ht=n=>{if(typeof n=="string"){const t=document.getElementById(n);if(!t)throw new Error(`Reader container "${n}" was not found.`);if(!(t instanceof HTMLDivElement))throw new Error(`Reader container "${n}" must be a div element.`);return t}if(!(n instanceof HTMLDivElement))throw new Error("Reader container must be a div element.");return n},mt=()=>{const n=typeof globalThis.matchMedia=="function";return(n?globalThis.matchMedia("(prefers-contrast: more)").matches:!1)?"high-contrast":(n?globalThis.matchMedia("(prefers-color-scheme: dark)").matches:!1)?"dark":"light"},ve=(n,t)=>{const e=n;if(typeof e.addEventListener=="function"){e.addEventListener("change",t);return}typeof e.addListener=="function"&&e.addListener(t)},Ae=(n,t)=>{const e=n;if(typeof e.removeEventListener=="function"){e.removeEventListener("change",t);return}typeof e.removeListener=="function"&&e.removeListener(t)},gt=(n,t)=>{var e,i;t.style&&(n.style.cssText=t.style),n.style.display||(n.style.display="block"),n.style.width?t.width&&(n.style.width=t.width):n.style.width=(e=t.width)!=null?e:"100%",n.style.height?t.height&&(n.style.height=t.height):n.style.height=(i=t.height)!=null?i:"100%"},pt=(n,t)=>{const e=t.theme;if(!e)return n.removeAttribute("theme"),null;if(e!=="auto")return n.setAttribute("theme",e),null;const i=()=>{n.setAttribute("theme",mt())};if(i(),typeof globalThis.matchMedia!="function")return null;const a=globalThis.matchMedia("(prefers-color-scheme: dark)"),r=globalThis.matchMedia("(prefers-contrast: more)"),s=()=>{i()};return ve(a,s),ve(r,s),()=>{Ae(a,s),Ae(r,s)}};class F{constructor(t){this.bridge=new rt,this.callbacks=new ot,this.readerState=new st,this.bridgeToolContext={bridge:this.bridge,callbacks:this.callbacks,debug:()=>this.debugEnabled,onAsyncError:e=>this.reportAdapterError(e),state:this.readerState},this.documentTool=new ie(this.bridgeToolContext),this.uiTool=new ge(this.bridgeToolContext),this.pageTool=new se(this.bridgeToolContext),this.findTool=new ae(this.bridgeToolContext),this.signServerTool=new ue(this.bridgeToolContext),this.digitalSignTool=new Z(this.bridgeToolContext),this.symbologyTool=new he(this.bridgeToolContext),this.annotationTool=new X(this.bridgeToolContext),this.templateSignTool=new me(this.bridgeToolContext),this.pdfFormFiller=new oe(this.bridgeToolContext),this.networkingTool=new re(this.bridgeToolContext),this.cryptoTool=new J(this.bridgeToolContext),this.readyCallbacks=[],this.unloadCallbacks=[],this.debugEnabled=!1,this.isReady=!1,this.removed=!1,this.mountToken=0,this.hostContainer=null,this.readerElement=null,this.readerId=null,this.normalizedConfiguration=null,this.nativeEventCleanupCallbacks=[],this.themeCleanup=null,this.enableDebug=e=>{this.debugEnabled=e},this.changeLanguage=()=>{},this.setLicense=(e,i)=>{this.license={license:e,feature:i}},this.setSessionUser=e=>{this.sessionUser=e},this.setSessionUserId=e=>{if(typeof this.sessionUser=="string"||!this.sessionUser){this.sessionUser={userName:typeof this.sessionUser=="string"?this.sessionUser:"",userId:e};return}this.sessionUser={...this.sessionUser,userId:e}},this.setSessionData=e=>{this.sessionData=e},this.isReaderReady=()=>this.isReady,this.isReaderDestroyed=()=>this.removed&&!this.isReady,this.addReaderReadyCallback=e=>{this.readyCallbacks.push(e)},this.addReaderUnloadCallback=e=>{this.unloadCallbacks.push(e)},this.setReaderEventListener=e=>{this.readerEventListener=e},this.embedReader=(e,i,a)=>{const r=ht(e),s=pe(i);fe(s);const o=Xe(s,a),d=this.mountToken+1;this.removeReader(),this.mountToken=d,this.removed=!1,this.hostContainer=r,this.normalizedConfiguration=o,this.mountReader(r,o,d)},this.removeReader=()=>{var a;const e=!!(this.readerElement||this.hostContainer);if(this.mountToken+=1,this.cleanupNativeEventForwarders(),this.cleanupThemeBinding(),(a=this.readerElement)!=null&&a.parentNode&&this.readerElement.parentNode.removeChild(this.readerElement),this.readerElement=null,this.readerId=null,this.bridge.setReaderId(null),this.readerState.reset(),this.hostContainer=null,this.normalizedConfiguration=null,this.isReady=!1,this.removed=!0,!e)return;const i=Te(null,null);this.emitReaderEvent(ct,i),this.unloadCallbacks.forEach(r=>r())},this.getDocumentTool=()=>this.documentTool,this.getUITool=()=>this.uiTool,this.getPageTool=()=>this.pageTool,this.getFindTool=()=>this.findTool,this.getSignServerTool=()=>this.signServerTool,this.getDigitalSignTool=()=>this.digitalSignTool,this.getSymbologyTool=()=>this.symbologyTool,this.getAnnotationTool=()=>this.annotationTool,this.getTemplateSignTool=()=>this.templateSignTool,this.getPdfFormFiller=()=>this.pdfFormFiller,this.getNetworkingTool=()=>this.networkingTool,this.getCryptoTool=()=>this.cryptoTool,this.createDigitalSignOptions=()=>new ce,this.createKVField=(e,i,a)=>new le(e,i,a),this.mountReader=async(e,i,a)=>{try{if(await et(i.appUrl),this.mountToken!==a)return;const r=document.createElement(R),s=ut();if(r.setAttribute(ne,s),this.readerId=s,this.bridge.setReaderId(s),gt(r,i),this.themeCleanup=pt(r,i),this.bindNativeReaderEvents(r),e.replaceChildren(r),this.readerElement=r,await Promise.resolve(),this.mountToken!==a)return;i.scrollIntoView&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({behavior:"smooth",block:"nearest"}),this.isReady=!0;const o=Te(r,i);this.emitReaderEvent(lt,o),this.readyCallbacks.forEach(d=>d())}catch(r){if(this.mountToken!==a)return;this.reportReaderError(r)}},this.bindNativeReaderEvents=e=>{this.cleanupNativeEventForwarders();const i=a=>{const r=a instanceof CustomEvent?a.detail:null;!r||r.readerId!==this.readerId||(this.readerState.update(r.statePatch),this.callbacks.emit(r.event,r.payload),this.emitReaderEvent(r.event,r.payload))};e.addEventListener(te,i),this.nativeEventCleanupCallbacks.push(()=>{e.removeEventListener(te,i)}),dt.forEach(a=>{const r=s=>{const o=s instanceof CustomEvent?s.detail:s;a==="documentLoaded"&&this.readerState.setDocumentOpened(!0),this.emitReaderEvent(a,o),a==="documentError"&&this.emitReaderEvent(_,o)};e.addEventListener(a,r),this.nativeEventCleanupCallbacks.push(()=>{e.removeEventListener(a,r)})})},this.cleanupNativeEventForwarders=()=>{this.nativeEventCleanupCallbacks.splice(0).forEach(e=>e())},this.cleanupThemeBinding=()=>{var e;(e=this.themeCleanup)==null||e.call(this),this.themeCleanup=null},this.emitReaderEvent=(e,i)=>{var a;(a=this.readerEventListener)==null||a.call(this,e,i)},this.reportReaderError=e=>{this.isReady=!1,this.debugEnabled&&console.error("[RHC Office SDK] Reader mount failed",e),this.emitReaderEvent(_,e)},this.reportAdapterError=e=>{this.debugEnabled&&console.error("[RHC Office SDK] Adapter command failed",e),this.emitReaderEvent(_,e)},this.bridge.configureTimeouts({readyTimeoutMs:t==null?void 0:t.adapterReadyTimeoutMs,requestTimeoutMs:t==null?void 0:t.adapterRequestTimeoutMs})}}const L=n=>new F(n),N={DocumentSDK:F,WatermarkDisplay:C,DIGITAL_SIGN_DEFAULTS:Y,createNewDocumentSdk:L,newDocumentSDK:L,getDigitalSignEnvironment:Q,initializeDigitalSignEnvironment:z,patchDigitalSignEnvironment:$,resetDigitalSignEnvironment:j,setDigitalSignEnvironment:W};return typeof document<"u"&&(n=>{Object.entries(N).forEach(([t,e])=>{Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0})}),n.RHCOfficeSDK=N})(document),l.AnnotationToolImpl=X,l.CryptoToolImpl=J,l.DIGITAL_SIGN_DEFAULTS=Y,l.DigitalSignOptions=ce,l.DigitalSignToolImpl=Z,l.DocumentSDK=F,l.DocumentToolImpl=ie,l.FindToolImpl=ae,l.KVField=le,l.NetworkingToolImpl=re,l.PageToolImpl=se,l.PdfFormFillerImpl=oe,l.RHCOfficeSDK=N,l.SDKPhase1NotImplementedError=de,l.SignServerToolImpl=ue,l.SymbologyToolImpl=he,l.TemplateSignToolImpl=me,l.UIToolImpl=ge,l.WatermarkDisplay=C,l.createNewDocumentSdk=L,l.createPhase1ToolPlaceholder=Ve,l.getDigitalSignEnvironment=Q,l.initializeDigitalSignEnvironment=z,l.patchDigitalSignEnvironment=$,l.resetDigitalSignEnvironment=j,l.setDigitalSignEnvironment=W,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),l}({});
|
|
2
2
|
//# sourceMappingURL=document-viewer.js.map
|