@rhc-office/sdk 6.6.259 → 6.6.266

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +44 -5
  2. package/dist/api/callbacks.d.ts +0 -1
  3. package/dist/api/callbacks.d.ts.map +1 -1
  4. package/dist/api/crypto-tool.d.ts +12 -1
  5. package/dist/api/crypto-tool.d.ts.map +1 -1
  6. package/dist/api/document-sdk.d.ts +0 -10
  7. package/dist/api/document-sdk.d.ts.map +1 -1
  8. package/dist/api/sign-tool.d.ts +43 -1
  9. package/dist/api/sign-tool.d.ts.map +1 -1
  10. package/dist/browser/document-viewer.js +2 -0
  11. package/dist/browser/document-viewer.js.map +1 -0
  12. package/dist/browser.d.ts +33 -0
  13. package/dist/browser.d.ts.map +1 -0
  14. package/dist/index.d.ts +0 -3
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +119 -148
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.umd.cjs +1 -1
  19. package/dist/index.umd.cjs.map +1 -1
  20. package/dist/viewer/DocumentSDK.d.ts +0 -7
  21. package/dist/viewer/DocumentSDK.d.ts.map +1 -1
  22. package/dist/viewer/ReaderConfiguration.d.ts +1 -1
  23. package/dist/viewer/ReaderConfiguration.d.ts.map +1 -1
  24. package/dist/viewer/ReaderStateStore.d.ts +0 -1
  25. package/dist/viewer/ReaderStateStore.d.ts.map +1 -1
  26. package/dist/viewer/SdkCallbackRegistry.d.ts +1 -2
  27. package/dist/viewer/SdkCallbackRegistry.d.ts.map +1 -1
  28. package/package.json +12 -2
  29. package/src/api/callbacks.ts +4 -17
  30. package/src/api/crypto-tool.ts +13 -1
  31. package/src/api/document-sdk.ts +0 -13
  32. package/src/api/sign-tool.ts +62 -1
  33. package/src/browser.ts +85 -0
  34. package/src/index.ts +0 -3
  35. package/src/viewer/DocumentSDK.ts +2 -45
  36. package/src/viewer/ReaderBridgeClient.ts +1 -1
  37. package/src/viewer/ReaderConfiguration.ts +2 -2
  38. package/src/viewer/ReaderStateStore.ts +0 -2
  39. package/src/viewer/SdkCallbackRegistry.ts +0 -9
  40. package/dist/api/ekey-tool.d.ts +0 -8
  41. package/dist/api/ekey-tool.d.ts.map +0 -1
  42. package/dist/api/extension-tool.d.ts +0 -5
  43. package/dist/api/extension-tool.d.ts.map +0 -1
  44. package/dist/api/review-tool.d.ts +0 -71
  45. package/dist/api/review-tool.d.ts.map +0 -1
  46. package/src/api/ekey-tool.ts +0 -11
  47. package/src/api/extension-tool.ts +0 -5
  48. package/src/api/review-tool.ts +0 -105
@@ -1,2 +1,2 @@
1
- (function(l,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(l=typeof globalThis<"u"?globalThis:l||self,m(l.RHCOfficeSDK={}))})(this,function(l){"use strict";var m=(n=>(n.DEFAULT="default",n.COMPACT="compact",n.HIDE="none",n))(m||{});const C="RIGHT_CENTER",P="REGULAR_ESM",A="auto",T="__RHC_OFFICE_DIGITAL_SIGN_ENVIRONMENT__",D={defaults:{bjca:{pin:""},deviceType:"client",edgePosition:C,kol:{appId:"",appName:"",pin:"",serviceUrl:"",token:""},plugin:{pin:"",usbKeyType:14},rsaMode:A,signatureType:P},signServer:{authSource:"Password",defaultLogin:"",defaultPassword:"",defaultServer:"",kol:{appId:"",appName:"",serviceUrl:"",token:""},macAddress:"",token:"",usbKey:{checkCertificateBinding:!1,usbKeyType:14}}},M=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}),I=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}}),g=n=>({defaults:M(n.defaults),signServer:I(n.signServer)}),w=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}),q=(n,t)=>t?{bjca:{pin:t.bjca?.pin??n.bjca.pin},deviceType:t.deviceType??n.deviceType,edgePosition:t.edgePosition??n.edgePosition,kol:{appId:t.kol?.appId??n.kol.appId,appName:t.kol?.appName??n.kol.appName,pin:t.kol?.pin??n.kol.pin,serviceUrl:t.kol?.serviceUrl??n.kol.serviceUrl,token:t.kol?.token??n.kol.token},plugin:{pin:t.plugin?.pin??n.plugin.pin,usbKeyType:t.plugin?.usbKeyType??n.plugin.usbKeyType},rsaMode:t.rsaMode??n.rsaMode,signatureType:t.signatureType??n.signatureType}:M(n),Q=(n,t)=>t?{authSource:t.authSource??n.authSource,defaultLogin:t.defaultLogin??n.defaultLogin,defaultPassword:t.defaultPassword??n.defaultPassword,defaultServer:t.defaultServer??n.defaultServer,kol:{appId:t.kol?.appId??n.kol.appId,appName:t.kol?.appName??n.kol.appName,serviceUrl:t.kol?.serviceUrl??n.kol.serviceUrl,token:t.kol?.token??n.kol.token},macAddress:t.macAddress??n.macAddress,token:t.token??n.token,usbKey:{checkCertificateBinding:t.usbKey?.checkCertificateBinding??n.usbKey.checkCertificateBinding,usbKeyType:t.usbKey?.usbKeyType??n.usbKey.usbKeyType}}:I(n),_=(n,t)=>({defaults:q(n.defaults,t.defaults),signServer:Q(n.signServer,t.signServer)}),z=(n,t)=>({defaults:n.defaults||t.defaults?{...n.defaults,...t.defaults,bjca:{...n.defaults?.bjca??{},...t.defaults?.bjca??{}},kol:{...n.defaults?.kol??{},...t.defaults?.kol??{}},plugin:{...n.defaults?.plugin??{},...t.defaults?.plugin??{}}}:void 0,signServer:n.signServer||t.signServer?{...n.signServer,...t.signServer,kol:{...n.signServer?.kol??{},...t.signServer?.kol??{}},usbKey:{...n.signServer?.usbKey??{},...t.signServer?.usbKey??{}}}:void 0}),W=()=>globalThis,k=()=>{const n=W();return n[T]||(n[T]={current:g(D),defaults:g(D),overrides:{}}),n[T]},$=()=>k().current,j=n=>{const t=k();return t.defaults=g(n),t.current=_(t.defaults,t.overrides),t.current},Y=n=>{const t=k();return t.current=g(n),t.overrides=w(n),t.current},X=n=>{const t=k();return t.overrides=z(t.overrides,w(n)),t.current=_(t.current,n),t.current},J=n=>{const t=k();return n&&(t.defaults=g(n)),t.overrides={},t.current=g(t.defaults),t.current},Z={EDGE_POSITION:C,RSA_MODE:A,SIGNATURE_TYPE:P},E=n=>{if(n.length!==0)return n.length===1?n[0]:n},u=(n,t,e)=>new Proxy({},{get:(i,r)=>{if(r==="then")return;if(typeof r=="symbol")return r===Symbol.toStringTag?n:void 0;const o=t[r];return o?(...a)=>{if(o.kind==="callbackRegister"){o.callback?.(e.callbacks,a);return}if(o.kind==="stateGetter")return o.state?.(e.state.snapshot(),a);const s=o.adapterMethod??r;if(o.kind==="query")return e.bridge.request(n,s,E(a));if(o.kind==="callbackQuery"){const c=a.find(d=>typeof d=="function"),b=a.filter(d=>typeof d!="function");e.bridge.request(n,s,E(b)).then(d=>{const S=o.mapCallbackResult?.(d)??[d];c?.(...S)}).catch(e.onAsyncError);return}e.bridge.request(n,s,E(a)).catch(e.onAsyncError)}:(...a)=>{const s=new Error(`${n}.${r} is not implemented by the SDK adapter.`);e.onAsyncError(s)}}}),h=(n,t)=>new Proxy({},{get:(e,i)=>{if(i!=="then"&&typeof i!="symbol")return(...r)=>{const o=`${n}.${i} is not implemented by the SDK adapter.`;t.onAsyncError(new Error(o))}}}),ee={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?.fileCacheId,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 te{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=u("document",ee,t)}}const ne={clearFind:{kind:"command"},findNext:{kind:"command"},findPrevious:{kind:"command"}};class ie{constructor(t){this.clearFind=()=>this.adapter.clearFind(),this.findNext=e=>this.adapter.findNext(e),this.findPrevious=e=>this.adapter.findPrevious(e),this.adapter=u("find",ne,t)}}const re={configFileUpload:{kind:"command"},setHttpHeaders:{kind:"command"},setHttpFormFields:{kind:"command"}};class oe{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=u("networking",re,t)}}const ae=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,r,o)=>this.adapter.setPageBlendColor(e,i,r,o),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=u("page",ae(t),t)}}const de={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 le{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=u("pdfFormFiller",de,t)}}const ce=/\s*,\s*/,ue=/\s*-\s*/,R=n=>{const t=Number.parseInt(n.trim(),10);return!Number.isFinite(t)||t<=0?null:t},he=n=>{const t=n.split(ue);if(t.length===1){const r=R(t[0]??"");return r?[r]:[]}const e=R(t[0]??""),i=R(t[1]??"");return!e||!i||i<e?[]:Array.from({length:i-e+1},(r,o)=>e+o)},me=n=>n?n.split(ce).flatMap(e=>he(e)).filter((e,i,r)=>r.indexOf(e)===i):[];class ge{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 pe{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=()=>me(this.pageRange),this.setSignUserData=t=>{this.signUserData=t},this.setPrintMargin=t=>{this.printMargin=t},this.getPrintMargin=()=>this.printMargin??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 ke=new Set([2,5]),fe=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:()=>ke.has(n.state.snapshot().pageMode)},requestFullScreen:{kind:"command"},exitFullScreen:{kind:"command"},invalidateView:{kind:"command"}});class be{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=u("ui",fe(t),t)}}const Te=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},F=n=>{const t=new URL(n,globalThis.location?.href??"http://localhost/");return t.hash="",t.pathname.endsWith("/")||(t.pathname=`${t.pathname}/`),t.toString()},Ee=n=>new URL("editors.bootstrap.js",n).toString(),Re=(n,t)=>{const e=F(n);return{...t,officeServer:e,scrollIntoView:t.scrollIntoView??!0,theme:Te(t.theme)}},p="rhc-office-editor",v="__RHC_OFFICE_SDK_READER_LOADER__",O=()=>{const n=globalThis;return n[v]||(n[v]={activeAppUrl:null,loadPromises:new Map}),n[v]},ve=n=>Array.from(document.querySelectorAll("script")).find(t=>t.src===n)??null;class L extends Error{constructor(t){super(`Failed to load reader bootstrap script: ${t}`),this.name="ReaderScriptLoadError"}}class ye extends Error{constructor(t,e){super(`Reader Web Component "${p}" is already bound to ${t} and cannot be reloaded from ${e}.`),this.name="ReaderSourceConflictError"}}const N=n=>{const t=O();if(t.activeAppUrl&&t.activeAppUrl!==n)throw new ye(t.activeAppUrl,n)},Se=n=>{const t=O();N(n);const e=t.loadPromises.get(n);if(e)return e;if(globalThis.customElements?.get(p)){t.activeAppUrl=n;const a=Promise.resolve();return t.loadPromises.set(n,a),a}const i=Ee(n),r=ve(i);t.activeAppUrl=n;const o=new Promise((a,s)=>{const c=S=>{S?.remove(),s(new L(i))},b=()=>{globalThis.customElements.whenDefined(p).then(()=>{a()}).catch(s)};if(r){if(globalThis.customElements?.get(p)){a();return}r.addEventListener("error",()=>s(new L(i)),{once:!0}),b();return}const d=document.createElement("script");d.src=i,d.async=!0,d.dataset.rhcOfficeSdkReader=n,d.addEventListener("load",b,{once:!0}),d.addEventListener("error",()=>c(d),{once:!0}),document.head.appendChild(d)}).catch(a=>{throw t.loadPromises.delete(n),!globalThis.customElements?.get(p)&&t.activeAppUrl===n&&(t.activeAppUrl=null),a});return t.loadPromises.set(n,o),o},Ce="rhc-office.editor-adapter",Pe=1,Ae="__RHC_OFFICE_EDITOR_ADAPTER__",U="rhcOfficeAdapterReady",x="rhcOfficeAdapterEvent",De="data-rhc-office-reader-id",Me=5e3,Ie=5e3,we=()=>{const n=globalThis.crypto;return typeof n?.randomUUID=="function"?n.randomUUID():`adapter-${Date.now()}-${Math.random().toString(36).slice(2)}`},f=()=>globalThis[Ae];class _e extends Error{constructor(t,e,i){super(e),this.name="ReaderBridgeError",this.code=t,this.details=i}}class Fe{constructor(t){this.readerId=null,this.readyTimeoutMs=t?.readyTimeoutMs??Ie,this.requestTimeoutMs=t?.requestTimeoutMs??Me}configureTimeouts(t){this.readyTimeoutMs=t?.readyTimeoutMs??this.readyTimeoutMs,this.requestTimeoutMs=t?.requestTimeoutMs??this.requestTimeoutMs}setReaderId(t){this.readerId=t}getReaderId(){return this.readerId}async request(t,e,i,r){const o=await this.requestRaw(t,e,i,r);if(o.ok)return o.result;throw new _e(o.error.code,o.error.message,o.error.details)}async requestRaw(t,e,i,r){if(!this.readerId)return{ok:!1,requestId:"",error:{code:"READER_NOT_READY",message:"Reader is not mounted."}};const o=await this.waitForAdapter(this.readerId,r?.timeoutMs);if(!o)return{ok:!1,requestId:"",error:{code:"ADAPTER_UNAVAILABLE",message:"Editor adapter is not available."}};const a={protocol:Ce,version:Pe,requestId:we(),readerId:this.readerId,tool:t,method:e,params:i};return this.withTimeout(o.request(a),a.requestId,r?.timeoutMs??this.requestTimeoutMs)}getCapabilities(){return this.readerId?f()?.getCapabilities(this.readerId)??null:null}async waitForAdapter(t,e=this.readyTimeoutMs){const i=f();return i?.getCapabilities(t)?i:new Promise(r=>{let o;const a=()=>{o&&clearTimeout(o),globalThis.removeEventListener(U,s)},s=c=>{if((c instanceof CustomEvent?c.detail:void 0)?.readerId!==t)return;const d=f();a(),r(d??null)};globalThis.addEventListener(U,s),o=setTimeout(()=>{a(),r(f()?.getCapabilities(t)?f():null)},e)})}async withTimeout(t,e,i){return new Promise(r=>{const o=setTimeout(()=>{r({ok:!1,requestId:e,error:{code:"TIMEOUT",message:`Editor adapter request timed out after ${i}ms.`}})},i);t.then(a=>r(a)).catch(a=>{r({ok:!1,requestId:e,error:{code:"EXECUTION_FAILED",message:a instanceof Error?a.message:String(a)}})}).finally(()=>{clearTimeout(o)})})}}const V={annotationEnabled:!1,documentModified:!1,documentOpened:!1,extensionState:"disconnected",pageCount:0,pageIndex:1,pageMode:0,zoomLevel:100};class Oe{constructor(){this.state={...V}}reset(){this.state={...V}}update(t){t&&(this.state={...this.state,...t})}setDocumentOpened(t){this.state={...this.state,documentOpened:t}}snapshot(){return{...this.state}}}class Le{constructor(){this.annotationEvents=[],this.annotationPersist=[],this.annotationRetrieve=[],this.digitalAnnotationRetrieve=[],this.digitalSignatureParse=[],this.digitalSignatureRetrieve=[],this.documentClosed=[],this.documentOpened=[],this.documentSaved=[],this.extensionStateChanged=[],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=>r(i.pageIndex??1,i.pageCount??0));return}case"pageModeChange":{const i=e;this.pageModeChange.forEach(r=>r(i.pageMode??0));return}case"annotationEvent":{const i=e;this.annotationEvents.forEach(r=>r(i.event??"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;case"extensionStateChanged":{const i=e;this.extensionStateChanged.forEach(r=>r(i.state??"disconnected"));return}default:return}}}const Ne=["documentLoaded","documentStateChange","documentError"],Ue="readerReady",xe="readerUnload",y="readerError",Ve=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`rhc-reader-${Date.now()}-${Math.random().toString(36).slice(2)}`,B=(n,t)=>({appUrl:t?.officeServer??null,configuration:t,element:n}),Be=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},Ke=()=>{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"},K=(n,t)=>{const e=n;if(typeof e.addEventListener=="function"){e.addEventListener("change",t);return}typeof e.addListener=="function"&&e.addListener(t)},G=(n,t)=>{const e=n;if(typeof e.removeEventListener=="function"){e.removeEventListener("change",t);return}typeof e.removeListener=="function"&&e.removeListener(t)},Ge=(n,t)=>{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=t.width??"100%",n.style.height?t.height&&(n.style.height=t.height):n.style.height=t.height??"100%"},He=(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",Ke())};if(i(),typeof globalThis.matchMedia!="function")return null;const r=globalThis.matchMedia("(prefers-color-scheme: dark)"),o=globalThis.matchMedia("(prefers-contrast: more)"),a=()=>{i()};return K(r,a),K(o,a),()=>{G(r,a),G(o,a)}};class H{constructor(t){this.bridge=new Fe,this.callbacks=new Le,this.readerState=new Oe,this.bridgeToolContext={bridge:this.bridge,callbacks:this.callbacks,debug:()=>this.debugEnabled,onAsyncError:e=>this.reportAdapterError(e),state:this.readerState},this.documentTool=new te(this.bridgeToolContext),this.uiTool=new be(this.bridgeToolContext),this.pageTool=new se(this.bridgeToolContext),this.findTool=new ie(this.bridgeToolContext),this.signServerTool=h("signServer",this.bridgeToolContext),this.digitalSignTool=h("digitalSign",this.bridgeToolContext),this.reviewTool=h("review",this.bridgeToolContext),this.ekeyTool=h("ekey",this.bridgeToolContext),this.symbologyTool=h("symbology",this.bridgeToolContext),this.annotationTool=this.createAnnotationTool(),this.templateSignTool=h("templateSign",this.bridgeToolContext),this.pdfFormFiller=new le(this.bridgeToolContext),this.extensionTool=this.createExtensionTool(),this.networkingTool=new oe(this.bridgeToolContext),this.cryptoTool=h("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 o=Be(e),a=F(i);N(a);const s=Re(a,r),c=this.mountToken+1;this.removeReader(),this.mountToken=c,this.removed=!1,this.hostContainer=o,this.normalizedConfiguration=s,this.mountReader(o,s,c)},this.removeReader=()=>{const e=!!(this.readerElement||this.hostContainer);if(this.mountToken+=1,this.cleanupNativeEventForwarders(),this.cleanupThemeBinding(),this.readerElement?.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=B(null,null);this.emitReaderEvent(xe,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.getReviewTool=()=>this.reviewTool,this.getEkeyTool=()=>this.ekeyTool,this.getSymbologyTool=()=>this.symbologyTool,this.getAnnotationTool=()=>this.annotationTool,this.getTemplateSignTool=()=>this.templateSignTool,this.getPdfFormFiller=()=>this.pdfFormFiller,this.getExtensionTool=()=>this.extensionTool,this.getNetworkingTool=()=>this.networkingTool,this.getCryptoTool=()=>this.cryptoTool,this.createDigitalSignOptions=()=>new pe,this.createKVField=(e,i,r)=>new ge(e,i,r),this.mountReader=async(e,i,r)=>{try{if(await Se(i.officeServer),this.mountToken!==r)return;const o=document.createElement(p),a=Ve();if(o.setAttribute(De,a),this.readerId=a,this.bridge.setReaderId(a),Ge(o,i),this.themeCleanup=He(o,i),this.bindNativeReaderEvents(o),e.replaceChildren(o),this.readerElement=o,await Promise.resolve(),this.mountToken!==r)return;i.scrollIntoView&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({behavior:"smooth",block:"nearest"}),this.isReady=!0;const s=B(o,i);this.emitReaderEvent(Ue,s),this.readyCallbacks.forEach(c=>c())}catch(o){if(this.mountToken!==r)return;this.reportReaderError(o)}},this.bindNativeReaderEvents=e=>{this.cleanupNativeEventForwarders();const i=r=>{const o=r instanceof CustomEvent?r.detail:null;!o||o.readerId!==this.readerId||(this.readerState.update(o.statePatch),this.callbacks.emit(o.event,o.payload),this.emitReaderEvent(o.event,o.payload))};e.addEventListener(x,i),this.nativeEventCleanupCallbacks.push(()=>{e.removeEventListener(x,i)}),Ne.forEach(r=>{const o=a=>{const s=a instanceof CustomEvent?a.detail:a;r==="documentLoaded"&&this.readerState.setDocumentOpened(!0),this.emitReaderEvent(r,s),r==="documentError"&&this.emitReaderEvent(y,s)};e.addEventListener(r,o),this.nativeEventCleanupCallbacks.push(()=>{e.removeEventListener(r,o)})})},this.cleanupNativeEventForwarders=()=>{this.nativeEventCleanupCallbacks.splice(0).forEach(e=>e())},this.cleanupThemeBinding=()=>{this.themeCleanup?.(),this.themeCleanup=null},this.emitReaderEvent=(e,i)=>{this.readerEventListener?.(e,i)},this.reportReaderError=e=>{this.isReady=!1,this.debugEnabled&&console.error("[RHC Office SDK] Reader mount failed",e),this.emitReaderEvent(y,e)},this.reportAdapterError=e=>{this.debugEnabled&&console.error("[RHC Office SDK] Adapter command failed",e),this.emitReaderEvent(y,e)},this.bridge.configureTimeouts({readyTimeoutMs:t?.adapterReadyTimeoutMs,requestTimeoutMs:t?.adapterRequestTimeoutMs})}createAnnotationTool(){return u("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)}createExtensionTool(){return u("extension",{addExtensionStateChangedCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.extensionStateChanged.push(i)}}},this.bridgeToolContext)}}const qe=n=>new H(n);l.DIGITAL_SIGN_DEFAULTS=Z,l.DocumentSDK=H,l.WatermarkDisplay=m,l.createNewDocumentSdk=qe,l.getDigitalSignEnvironment=$,l.initializeDigitalSignEnvironment=j,l.patchDigitalSignEnvironment=X,l.resetDigitalSignEnvironment=J,l.setDigitalSignEnvironment=Y,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
1
+ (function(l,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(l=typeof globalThis<"u"?globalThis:l||self,h(l.RHCOfficeSDK={}))})(this,function(l){"use strict";var h=(n=>(n.DEFAULT="default",n.COMPACT="compact",n.HIDE="none",n))(h||{});const P="RIGHT_CENTER",C="REGULAR_ESM",A="auto",T="__RHC_OFFICE_DIGITAL_SIGN_ENVIRONMENT__",D={defaults:{bjca:{pin:""},deviceType:"client",edgePosition:P,kol:{appId:"",appName:"",pin:"",serviceUrl:"",token:""},plugin:{pin:"",usbKeyType:14},rsaMode:A,signatureType:C},signServer:{authSource:"Password",defaultLogin:"",defaultPassword:"",defaultServer:"",kol:{appId:"",appName:"",serviceUrl:"",token:""},macAddress:"",token:"",usbKey:{checkCertificateBinding:!1,usbKeyType:14}}},M=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}),I=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}}),m=n=>({defaults:M(n.defaults),signServer:I(n.signServer)}),w=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}),q=(n,t)=>t?{bjca:{pin:t.bjca?.pin??n.bjca.pin},deviceType:t.deviceType??n.deviceType,edgePosition:t.edgePosition??n.edgePosition,kol:{appId:t.kol?.appId??n.kol.appId,appName:t.kol?.appName??n.kol.appName,pin:t.kol?.pin??n.kol.pin,serviceUrl:t.kol?.serviceUrl??n.kol.serviceUrl,token:t.kol?.token??n.kol.token},plugin:{pin:t.plugin?.pin??n.plugin.pin,usbKeyType:t.plugin?.usbKeyType??n.plugin.usbKeyType},rsaMode:t.rsaMode??n.rsaMode,signatureType:t.signatureType??n.signatureType}:M(n),Q=(n,t)=>t?{authSource:t.authSource??n.authSource,defaultLogin:t.defaultLogin??n.defaultLogin,defaultPassword:t.defaultPassword??n.defaultPassword,defaultServer:t.defaultServer??n.defaultServer,kol:{appId:t.kol?.appId??n.kol.appId,appName:t.kol?.appName??n.kol.appName,serviceUrl:t.kol?.serviceUrl??n.kol.serviceUrl,token:t.kol?.token??n.kol.token},macAddress:t.macAddress??n.macAddress,token:t.token??n.token,usbKey:{checkCertificateBinding:t.usbKey?.checkCertificateBinding??n.usbKey.checkCertificateBinding,usbKeyType:t.usbKey?.usbKeyType??n.usbKey.usbKeyType}}:I(n),_=(n,t)=>({defaults:q(n.defaults,t.defaults),signServer:Q(n.signServer,t.signServer)}),z=(n,t)=>({defaults:n.defaults||t.defaults?{...n.defaults,...t.defaults,bjca:{...n.defaults?.bjca??{},...t.defaults?.bjca??{}},kol:{...n.defaults?.kol??{},...t.defaults?.kol??{}},plugin:{...n.defaults?.plugin??{},...t.defaults?.plugin??{}}}:void 0,signServer:n.signServer||t.signServer?{...n.signServer,...t.signServer,kol:{...n.signServer?.kol??{},...t.signServer?.kol??{}},usbKey:{...n.signServer?.usbKey??{},...t.signServer?.usbKey??{}}}:void 0}),W=()=>globalThis,g=()=>{const n=W();return n[T]||(n[T]={current:m(D),defaults:m(D),overrides:{}}),n[T]},$=()=>g().current,j=n=>{const t=g();return t.defaults=m(n),t.current=_(t.defaults,t.overrides),t.current},Y=n=>{const t=g();return t.current=m(n),t.overrides=w(n),t.current},X=n=>{const t=g();return t.overrides=z(t.overrides,w(n)),t.current=_(t.current,n),t.current},J=n=>{const t=g();return n&&(t.defaults=m(n)),t.overrides={},t.current=m(t.defaults),t.current},Z={EDGE_POSITION:P,RSA_MODE:A,SIGNATURE_TYPE:C},E=n=>{if(n.length!==0)return n.length===1?n[0]:n},u=(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?(...o)=>{if(a.kind==="callbackRegister"){a.callback?.(e.callbacks,o);return}if(a.kind==="stateGetter")return a.state?.(e.state.snapshot(),o);const s=a.adapterMethod??r;if(a.kind==="query")return e.bridge.request(n,s,E(o));if(a.kind==="callbackQuery"){const c=o.find(d=>typeof d=="function"),b=o.filter(d=>typeof d!="function");e.bridge.request(n,s,E(b)).then(d=>{const S=a.mapCallbackResult?.(d)??[d];c?.(...S)}).catch(e.onAsyncError);return}e.bridge.request(n,s,E(o)).catch(e.onAsyncError)}:(...o)=>{const s=new Error(`${n}.${r} is not implemented by the SDK adapter.`);e.onAsyncError(s)}}}),k=(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))}}}),ee={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?.fileCacheId,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 te{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=u("document",ee,t)}}const ne={clearFind:{kind:"command"},findNext:{kind:"command"},findPrevious:{kind:"command"}};class ie{constructor(t){this.clearFind=()=>this.adapter.clearFind(),this.findNext=e=>this.adapter.findNext(e),this.findPrevious=e=>this.adapter.findPrevious(e),this.adapter=u("find",ne,t)}}const re={configFileUpload:{kind:"command"},setHttpHeaders:{kind:"command"},setHttpFormFields:{kind:"command"}};class ae{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=u("networking",re,t)}}const oe=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,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=u("page",oe(t),t)}}const de={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 le{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=u("pdfFormFiller",de,t)}}const ce=/\s*,\s*/,ue=/\s*-\s*/,R=n=>{const t=Number.parseInt(n.trim(),10);return!Number.isFinite(t)||t<=0?null:t},he=n=>{const t=n.split(ue);if(t.length===1){const r=R(t[0]??"");return r?[r]:[]}const e=R(t[0]??""),i=R(t[1]??"");return!e||!i||i<e?[]:Array.from({length:i-e+1},(r,a)=>e+a)},me=n=>n?n.split(ce).flatMap(e=>he(e)).filter((e,i,r)=>r.indexOf(e)===i):[];class pe{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 ge{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=()=>me(this.pageRange),this.setSignUserData=t=>{this.signUserData=t},this.setPrintMargin=t=>{this.printMargin=t},this.getPrintMargin=()=>this.printMargin??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 ke=new Set([2,5]),fe=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:()=>ke.has(n.state.snapshot().pageMode)},requestFullScreen:{kind:"command"},exitFullScreen:{kind:"command"},invalidateView:{kind:"command"}});class be{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=u("ui",fe(t),t)}}const Te=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},F=n=>{const t=new URL(n,globalThis.location?.href??"http://localhost/");return t.hash="",t.pathname.endsWith("/")||(t.pathname=`${t.pathname}/`),t.toString()},Ee=n=>new URL("editors.bootstrap.js",n).toString(),Re=(n,t)=>{const e=F(n);return{...t,appUrl:e,scrollIntoView:t.scrollIntoView??!0,theme:Te(t.theme)}},p="rhc-office-editor",v="__RHC_OFFICE_SDK_READER_LOADER__",O=()=>{const n=globalThis;return n[v]||(n[v]={activeAppUrl:null,loadPromises:new Map}),n[v]},ve=n=>Array.from(document.querySelectorAll("script")).find(t=>t.src===n)??null;class L extends Error{constructor(t){super(`Failed to load reader bootstrap script: ${t}`),this.name="ReaderScriptLoadError"}}class ye extends Error{constructor(t,e){super(`Reader Web Component "${p}" is already bound to ${t} and cannot be reloaded from ${e}.`),this.name="ReaderSourceConflictError"}}const U=n=>{const t=O();if(t.activeAppUrl&&t.activeAppUrl!==n)throw new ye(t.activeAppUrl,n)},Se=n=>{const t=O();U(n);const e=t.loadPromises.get(n);if(e)return e;if(globalThis.customElements?.get(p)){t.activeAppUrl=n;const o=Promise.resolve();return t.loadPromises.set(n,o),o}const i=Ee(n),r=ve(i);t.activeAppUrl=n;const a=new Promise((o,s)=>{const c=S=>{S?.remove(),s(new L(i))},b=()=>{globalThis.customElements.whenDefined(p).then(()=>{o()}).catch(s)};if(r){if(globalThis.customElements?.get(p)){o();return}r.addEventListener("error",()=>s(new L(i)),{once:!0}),b();return}const d=document.createElement("script");d.src=i,d.async=!0,d.dataset.rhcOfficeSdkReader=n,d.addEventListener("load",b,{once:!0}),d.addEventListener("error",()=>c(d),{once:!0}),document.head.appendChild(d)}).catch(o=>{throw t.loadPromises.delete(n),!globalThis.customElements?.get(p)&&t.activeAppUrl===n&&(t.activeAppUrl=null),o});return t.loadPromises.set(n,a),a},Pe="rhc-office.editor-adapter",Ce=1,Ae="__RHC_OFFICE_EDITOR_ADAPTER__",N="rhcOfficeAdapterReady",V="rhcOfficeAdapterEvent",De="data-rhc-office-reader-id",Me=5e3,Ie=5e3,we=()=>{const n=globalThis.crypto;return typeof n?.randomUUID=="function"?n.randomUUID():`adapter-${Date.now()}-${Math.random().toString(36).slice(2)}`},f=()=>globalThis[Ae];class _e extends Error{constructor(t,e,i){super(e),this.name="ReaderBridgeError",this.code=t,this.details=i}}class Fe{constructor(t){this.readerId=null,this.readyTimeoutMs=t?.readyTimeoutMs??Ie,this.requestTimeoutMs=t?.requestTimeoutMs??Me}configureTimeouts(t){this.readyTimeoutMs=t?.readyTimeoutMs??this.readyTimeoutMs,this.requestTimeoutMs=t?.requestTimeoutMs??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 _e(a.error.code,a.error.message,a.error.details)}async requestRaw(t,e,i,r){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?.timeoutMs);if(!a)return{ok:!1,requestId:"",error:{code:"ADAPTER_UNAVAILABLE",message:"Editor adapter is not available."}};const o={protocol:Pe,version:Ce,requestId:we(),readerId:this.readerId,tool:t,method:e,params:i};return this.withTimeout(a.request(o),o.requestId,r?.timeoutMs??this.requestTimeoutMs)}getCapabilities(){return this.readerId?f()?.getCapabilities(this.readerId)??null:null}async waitForAdapter(t,e=this.readyTimeoutMs){const i=f();return i?.getCapabilities(t)?i:new Promise(r=>{let a;const o=()=>{a&&clearTimeout(a),globalThis.removeEventListener(N,s)},s=c=>{if((c instanceof CustomEvent?c.detail:void 0)?.readerId!==t)return;const d=f();o(),r(d??null)};globalThis.addEventListener(N,s),a=setTimeout(()=>{o(),r(f()?.getCapabilities(t)?f():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(o=>r(o)).catch(o=>{r({ok:!1,requestId:e,error:{code:"EXECUTION_FAILED",message:o instanceof Error?o.message:String(o)}})}).finally(()=>{clearTimeout(a)})})}}const B={annotationEnabled:!1,documentModified:!1,documentOpened:!1,pageCount:0,pageIndex:1,pageMode:0,zoomLevel:100};class Oe{constructor(){this.state={...B}}reset(){this.state={...B}}update(t){t&&(this.state={...this.state,...t})}setDocumentOpened(t){this.state={...this.state,documentOpened:t}}snapshot(){return{...this.state}}}class Le{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=>r(i.pageIndex??1,i.pageCount??0));return}case"pageModeChange":{const i=e;this.pageModeChange.forEach(r=>r(i.pageMode??0));return}case"annotationEvent":{const i=e;this.annotationEvents.forEach(r=>r(i.event??"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 Ue=["documentLoaded","documentStateChange","documentError"],Ne="readerReady",Ve="readerUnload",y="readerError",Be=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`rhc-reader-${Date.now()}-${Math.random().toString(36).slice(2)}`,K=(n,t)=>({appUrl:t?.appUrl??null,configuration:t,element:n}),Ke=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},xe=()=>{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"},x=(n,t)=>{const e=n;if(typeof e.addEventListener=="function"){e.addEventListener("change",t);return}typeof e.addListener=="function"&&e.addListener(t)},G=(n,t)=>{const e=n;if(typeof e.removeEventListener=="function"){e.removeEventListener("change",t);return}typeof e.removeListener=="function"&&e.removeListener(t)},Ge=(n,t)=>{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=t.width??"100%",n.style.height?t.height&&(n.style.height=t.height):n.style.height=t.height??"100%"},He=(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",xe())};if(i(),typeof globalThis.matchMedia!="function")return null;const r=globalThis.matchMedia("(prefers-color-scheme: dark)"),a=globalThis.matchMedia("(prefers-contrast: more)"),o=()=>{i()};return x(r,o),x(a,o),()=>{G(r,o),G(a,o)}};class H{constructor(t){this.bridge=new Fe,this.callbacks=new Le,this.readerState=new Oe,this.bridgeToolContext={bridge:this.bridge,callbacks:this.callbacks,debug:()=>this.debugEnabled,onAsyncError:e=>this.reportAdapterError(e),state:this.readerState},this.documentTool=new te(this.bridgeToolContext),this.uiTool=new be(this.bridgeToolContext),this.pageTool=new se(this.bridgeToolContext),this.findTool=new ie(this.bridgeToolContext),this.signServerTool=k("signServer",this.bridgeToolContext),this.digitalSignTool=k("digitalSign",this.bridgeToolContext),this.symbologyTool=k("symbology",this.bridgeToolContext),this.annotationTool=this.createAnnotationTool(),this.templateSignTool=k("templateSign",this.bridgeToolContext),this.pdfFormFiller=new le(this.bridgeToolContext),this.networkingTool=new ae(this.bridgeToolContext),this.cryptoTool=k("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=Ke(e),o=F(i);U(o);const s=Re(o,r),c=this.mountToken+1;this.removeReader(),this.mountToken=c,this.removed=!1,this.hostContainer=a,this.normalizedConfiguration=s,this.mountReader(a,s,c)},this.removeReader=()=>{const e=!!(this.readerElement||this.hostContainer);if(this.mountToken+=1,this.cleanupNativeEventForwarders(),this.cleanupThemeBinding(),this.readerElement?.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=K(null,null);this.emitReaderEvent(Ve,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 ge,this.createKVField=(e,i,r)=>new pe(e,i,r),this.mountReader=async(e,i,r)=>{try{if(await Se(i.appUrl),this.mountToken!==r)return;const a=document.createElement(p),o=Be();if(a.setAttribute(De,o),this.readerId=o,this.bridge.setReaderId(o),Ge(a,i),this.themeCleanup=He(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 s=K(a,i);this.emitReaderEvent(Ne,s),this.readyCallbacks.forEach(c=>c())}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(V,i),this.nativeEventCleanupCallbacks.push(()=>{e.removeEventListener(V,i)}),Ue.forEach(r=>{const a=o=>{const s=o instanceof CustomEvent?o.detail:o;r==="documentLoaded"&&this.readerState.setDocumentOpened(!0),this.emitReaderEvent(r,s),r==="documentError"&&this.emitReaderEvent(y,s)};e.addEventListener(r,a),this.nativeEventCleanupCallbacks.push(()=>{e.removeEventListener(r,a)})})},this.cleanupNativeEventForwarders=()=>{this.nativeEventCleanupCallbacks.splice(0).forEach(e=>e())},this.cleanupThemeBinding=()=>{this.themeCleanup?.(),this.themeCleanup=null},this.emitReaderEvent=(e,i)=>{this.readerEventListener?.(e,i)},this.reportReaderError=e=>{this.isReady=!1,this.debugEnabled&&console.error("[RHC Office SDK] Reader mount failed",e),this.emitReaderEvent(y,e)},this.reportAdapterError=e=>{this.debugEnabled&&console.error("[RHC Office SDK] Adapter command failed",e),this.emitReaderEvent(y,e)},this.bridge.configureTimeouts({readyTimeoutMs:t?.adapterReadyTimeoutMs,requestTimeoutMs:t?.adapterRequestTimeoutMs})}createAnnotationTool(){return u("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 qe=n=>new H(n);l.DIGITAL_SIGN_DEFAULTS=Z,l.DocumentSDK=H,l.WatermarkDisplay=h,l.createNewDocumentSdk=qe,l.getDigitalSignEnvironment=$,l.initializeDigitalSignEnvironment=j,l.patchDigitalSignEnvironment=X,l.resetDigitalSignEnvironment=J,l.setDigitalSignEnvironment=Y,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=index.umd.cjs.map