@atkonoffice/sdk 1.10.0 → 1.12.0

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.
@@ -216,7 +216,7 @@ export interface AtkonofficeSessionWord {
216
216
 
217
217
  fillDataRegion(name: string, value: string): Promise<boolean>
218
218
 
219
- addDataRegion(name: string, caption?: string): Promise<boolean>
219
+ addDataRegion(name: string, caption: string): Promise<boolean>
220
220
 
221
221
  deleteDataRegion(name: string): Promise<boolean>
222
222
 
@@ -224,10 +224,38 @@ export interface AtkonofficeSessionWord {
224
224
 
225
225
  listDataRegions(prefix?: string): Promise<string[]>
226
226
 
227
+ getDataRegionValues(prefix?: string): Promise<AtkonofficeDataRegionValue[]>
228
+
229
+ setDataRegionPlaceholder(name: string, caption: string): Promise<boolean>
230
+
231
+ setDataRegionLock(name: string, lock: AtkonofficeDataRegionLock): Promise<boolean>
232
+
227
233
  receipt: AtkonofficeSessionWordReceipt
228
234
  }
229
235
 
230
236
 
237
+ export interface AtkonofficeDataRegionValue {
238
+
239
+ name: string
240
+
241
+ text?: string
242
+
243
+ placeholder?: boolean
244
+
245
+ lockContents?: boolean
246
+
247
+ lockControl?: boolean
248
+ }
249
+
250
+
251
+ export interface AtkonofficeDataRegionLock {
252
+
253
+ contents?: boolean
254
+
255
+ control?: boolean
256
+ }
257
+
258
+
231
259
  export type AtkonofficeDataRegionReceipt<T> =
232
260
  | { ok: true; value: T; error?: undefined }
233
261
  | { ok: false; value?: undefined; error: string }
@@ -237,13 +265,19 @@ export interface AtkonofficeSessionWordReceipt {
237
265
 
238
266
  fillDataRegion(name: string, value: string): Promise<AtkonofficeDataRegionReceipt<number>>
239
267
 
240
- addDataRegion(name: string, caption?: string): Promise<AtkonofficeDataRegionReceipt<number>>
268
+ addDataRegion(name: string, caption: string): Promise<AtkonofficeDataRegionReceipt<number>>
241
269
 
242
270
  deleteDataRegion(name: string): Promise<AtkonofficeDataRegionReceipt<number>>
243
271
 
244
272
  locateDataRegion(name: string): Promise<AtkonofficeDataRegionReceipt<number>>
245
273
 
246
274
  listDataRegions(prefix?: string): Promise<AtkonofficeDataRegionReceipt<string[]>>
275
+
276
+ getDataRegionValues(prefix?: string): Promise<AtkonofficeDataRegionReceipt<AtkonofficeDataRegionValue[]>>
277
+
278
+ setDataRegionPlaceholder(name: string, caption: string): Promise<AtkonofficeDataRegionReceipt<number>>
279
+
280
+ setDataRegionLock(name: string, lock: AtkonofficeDataRegionLock): Promise<AtkonofficeDataRegionReceipt<number>>
247
281
  }
248
282
 
249
283
 
@@ -1 +1 @@
1
- var y={};var n={backendBase:"",launchPath:"/atkonoffice/rpc/launch",wsTicketPath:"/atkonoffice/rpc/ws-ticket",fetchImpl:null,initialized:!1,ws:null,wsUrl:"",pairId:"",nodeBase:"",headers:null,eventHandlers:{},wsReconnectAttempt:0,wsReconnectTimer:null,wsTicketInFlight:!1,wsStopped:!1,wsBackoffExhausted:!1,channelLostAnnounced:!1,channelRestoreConfirmTimer:null,pairing:!1,launchTicket:"",openParams:null,fallbackUrl:"",pairingPrevTitle:"",pairingTitleSaved:!1,pairingRecoverTimer:null,pairingTimeoutTimer:null,pairTimeoutMs:5e3,pairRecoverMs:1e3,titleRelayInstalled:!1,trustedFrameOrigins:null,onPairDowngrade:null,replayOpen:null,launchInFlight:!1,inFlightOpen:null};function x(){n.launchInFlight=!1,n.inFlightOpen=null}var D="atkonoffice.ws.session",ee=12,te=3e5,Ie=1e3,A="channelLost",B="channelRestored",U=["documentSaved","documentOpened","documentBeforeSave","documentEmbedFailed","shellClosed",A,B,"error"],ne="shell.closed",P={"doc.saved":"documentSaved","doc.opened":"documentOpened","doc.beforeSave":"documentBeforeSave",[ne]:"shellClosed"},b="atkonoffice-launch=",H="\u2007",F="pair.ready",Ne="launch.open",ve="doc.embedFailed",M="__atkonofficeTitle",oe="atkonoffice-install-guide";function re(e){return e&&e.endsWith("/")?e.slice(0,-1):e}function Ae(e,t){if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}}function Y(e,t,o){let r=e.indexOf("?")===-1?"?":"&";return e+r+t+"="+o}function W(e){return!!e&&Object.keys(e).length>0}function R(e){return e&&e.message?e.message:String(e)}function I(e,t,o){if(t==null)return;let r=String(t).trim();r&&(e[r]=o==null?"":String(o))}function Be(e){return e?typeof e=="string"?e:typeof e=="object"?Object.keys(e).map(t=>t+"="+String(e[t])).join("; "):"":""}function Le(e){let t;if(typeof TextEncoder<"u"){let o=new TextEncoder().encode(e),r="";for(let i=0;i<o.length;i++)r+=String.fromCharCode(o[i]);t=r}else t=unescape(encodeURIComponent(e));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function k(){try{return typeof document<"u"&&typeof document.title=="string"?document.title:""}catch{return""}}function ie(){if(typeof window>"u")return!1;try{return window.top!==window.self}catch{return!0}}function G(e){try{let t=document.createElement("iframe");t.style.display="none",t.src=e,document.body.appendChild(t),setTimeout(()=>{try{document.body.removeChild(t)}catch{}},1e3)}catch{window.location.href=e}}function j(e){return!!(typeof e.launchTicket=="string"&&e.launchTicket&&typeof e.wsUrl=="string"&&e.wsUrl&&typeof e.wsTicket=="string"&&e.wsTicket&&typeof document<"u"&&typeof WebSocket<"u")}var l={CONFIG:"config",LAUNCH:"launch",CHANNEL:"channel"},se={backend_base_missing:l.CONFIG,doc_id_missing:l.CONFIG,fetch_unavailable:l.CONFIG,ws_unsupported:l.CONFIG,ws_ticket_backend_missing:l.CONFIG,ws_ticket_node_mismatch:l.CONFIG,launch_request_failed:l.LAUNCH,launch_http_error:l.LAUNCH,launch_response_not_json:l.LAUNCH,launch_response_invalid:l.LAUNCH,launch_open_frame_send_failed:l.LAUNCH,ws_url_missing:l.CHANNEL,ws_ticket_missing:l.CHANNEL,ws_connect_failed:l.CHANNEL,ws_error:l.CHANNEL,headers_frame_send_failed:l.CHANNEL,ws_no_pair_to_resume:l.CHANNEL,ws_backoff_exhausted:l.CHANNEL,ws_gave_up:l.CHANNEL,ws_ticket_http_error:l.CHANNEL,ws_ticket_response_invalid:l.CHANNEL,ws_ticket_refresh_failed:l.CHANNEL};function c(e,t){let o=new Error(t);return o.code=e,o.category=se[e],o}function ae(){return typeof n.fetchImpl=="function"?n.fetchImpl:typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):null}function Ot(){let e=ae();if(!e)throw c("fetch_unavailable","atkonoffice: no fetch available \u2014 pass fetchImpl via config in non-browser hosts");return e}async function V(e,t){let o;try{o=await Ot()(n.backendBase+n.launchPath,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(r){throw r&&se[r.code]?r:c("launch_request_failed",t+" request failed \u2014 "+R(r))}if(!o.ok)throw c("launch_http_error",t+" endpoint returned HTTP "+o.status);try{return await o.json()}catch(r){throw c("launch_response_not_json",t+" response was not JSON \u2014 "+R(r))}}var T={PERM:"PERM",SLOW:"SLOW",RETRY:"RETRY"},ce=":",St=[[T.PERM+ce,T.PERM],[T.SLOW+ce,T.SLOW],[T.RETRY+ce,T.RETRY]];function De(e){if(typeof e!="string"||!e)return T.RETRY;for(let t of St)if(e.indexOf(t[0])===0)return t[1];return T.RETRY}function Ue(e){n.launchTicket=e.launchTicket,n.openParams=e.openParams&&typeof e.openParams=="object"?e.openParams:{},n.fallbackUrl=e.launchUrl,n.pairing||(n.pairingTitleSaved=!1),n.pairing=!0,fe(),It()}function He(){if(!(!n.pairing||typeof document>"u")){if(!n.pairingTitleSaved){let e=k();e.indexOf(b)<0&&(n.pairingPrevTitle=e,n.pairingTitleSaved=!0)}Fe(),Pt()}}function Fe(){O(K(n.wsUrl,n.pairId,n.launchTicket))}function K(e,t,o){let r=Le(JSON.stringify({wsUrl:e,pairId:t,launchTicket:o}));return H+b+r}function O(e){try{typeof document<"u"&&(document.title=e)}catch{}if(ie())try{let t={};t[M]=e,window.top.postMessage(t,"*")}catch{}}function fe(){n.titleRelayInstalled||typeof window>"u"||typeof window.addEventListener!="function"||ie()||(n.titleRelayInstalled=!0,window.addEventListener("message",e=>{if(!Ct(e&&e.origin))return;let t=e&&e.data;if(t&&typeof t=="object"&&typeof t[M]=="string")try{document.title=t[M]}catch{}}))}function Ct(e){let t=n.trustedFrameOrigins;return!t||t.length===0?!0:typeof e=="string"&&t.indexOf(e)!==-1}function Pt(){n.pairingRecoverTimer||typeof setInterval>"u"||(n.pairingRecoverTimer=setInterval(()=>{n.pairing&&k().indexOf(b)<0&&Fe()},n.pairRecoverMs))}function It(){n.pairingTimeoutTimer||typeof setTimeout>"u"||(n.pairingTimeoutTimer=setTimeout(()=>{n.pairingTimeoutTimer=null,Ye(!0)},n.pairTimeoutMs))}function Me(){if(!n.pairing)return;let e=n.ws;Ye(!1),x(),e&&Nt(e)}function Nt(e){let t={v:1,type:"event",op:Ne,ts:Math.floor(Date.now()/1e3),payload:{pair_id:n.pairId,openParams:n.openParams||{}}};try{e.send(JSON.stringify(t))}catch(o){u("error",c("launch_open_frame_send_failed","atkonoffice: failed to send launch.open frame \u2014 "+R(o)))}}function Ye(e){n.pairingRecoverTimer&&(clearInterval(n.pairingRecoverTimer),n.pairingRecoverTimer=null),n.pairingTimeoutTimer&&(clearTimeout(n.pairingTimeoutTimer),n.pairingTimeoutTimer=null);let t=n.pairing;n.pairing=!1,n.pairingTitleSaved&&(O(n.pairingPrevTitle),n.pairingTitleSaved=!1),e&&t&&(G(n.fallbackUrl),typeof n.onPairDowngrade=="function"&&n.onPairDowngrade())}var vt="documentEmbedFailed";function We(e){u(vt,e||{})}function le(e,t,o){if(!(!e||typeof sessionStorage>"u"))try{sessionStorage.setItem(D,JSON.stringify({pairId:e,wsUrl:t,nodeBase:o||""}))}catch{}}function Ge(){if(n.pairId)return{pairId:n.pairId,wsUrl:n.wsUrl,nodeBase:n.nodeBase};if(typeof sessionStorage>"u")return null;try{let e=sessionStorage.getItem(D);return e?JSON.parse(e):null}catch{return null}}function At(){n.pairId="",n.wsUrl="",n.nodeBase=""}function je(){if(!(typeof sessionStorage>"u"))try{sessionStorage.removeItem(D)}catch{}}function Ve(){At(),je()}function J(){if(n.ws||n.wsReconnectTimer||n.wsTicketInFlight||n.wsStopped||!n.backendBase)return;let e=Ge();!e||!e.pairId||(n.pairId=e.pairId,n.wsUrl=e.wsUrl||n.wsUrl,n.nodeBase=e.nodeBase||n.nodeBase,n.wsReconnectAttempt=0,Je(e.pairId,t=>X(t)))}function X(e){if(typeof WebSocket>"u"){u("error",c("ws_unsupported","atkonoffice: WebSocket unavailable in this host \u2014 document events disabled"));return}if(!n.wsUrl){u("error",c("ws_url_missing","atkonoffice: no wsUrl \u2014 cannot open the document-event channel"));return}if(!e){u("error",c("ws_ticket_missing","atkonoffice: missing ws_ticket \u2014 cannot subscribe to document events"));return}de();let t=Y(n.wsUrl,"ticket",encodeURIComponent(e)),o;try{o=new WebSocket(t)}catch(r){u("error",c("ws_connect_failed","atkonoffice: WS connect failed \u2014 "+R(r))),N();return}n.ws=o,o.onopen=()=>{n.wsBackoffExhausted&&le(n.pairId,n.wsUrl,n.nodeBase),n.wsReconnectAttempt=0,n.wsStopped=!1,n.wsBackoffExhausted=!1,Bt(o),Ut(o),n.pairing&&He()},o.onmessage=r=>{Ht(r&&r.data)},o.onerror=()=>{u("error",c("ws_error","atkonoffice: WS error on the document-event channel"))},o.onclose=r=>{if(n.ws===o&&(n.ws=null),ue(),De(r&&r.reason)===T.PERM){Lt("server closed it permanently; reopen the document from the page to start a new session");return}N()}}function Ke(e){n.channelLostAnnounced||(n.channelLostAnnounced=!0,u(A,{reason:e}))}function Bt(e){ue(),n.channelLostAnnounced&&(n.channelRestoreConfirmTimer=setTimeout(()=>{n.channelRestoreConfirmTimer=null,!(n.ws!==e||!n.channelLostAnnounced)&&(n.channelLostAnnounced=!1,u(B,{}))},Ie))}function ue(){n.channelRestoreConfirmTimer&&(clearTimeout(n.channelRestoreConfirmTimer),n.channelRestoreConfirmTimer=null)}function Lt(e){n.wsStopped=!0,n.wsBackoffExhausted=!1,de(),Ve();let t=c("ws_gave_up","atkonoffice: document-event channel lost \u2014 "+e);t.terminal=!0,u("error",t),Ke("rejected")}function Dt(e){n.wsBackoffExhausted=!0,je();let t=c("ws_backoff_exhausted","atkonoffice: document-event channel still unreachable "+e+" \u2014 left fast reconnect, now probing every "+Math.round(te/1e3)+"s until it comes back");t.terminal=!1,u("error",t),Ke("unreachable")}function de(){n.wsReconnectTimer&&(clearTimeout(n.wsReconnectTimer),n.wsReconnectTimer=null),ue();let e=n.ws;if(n.ws=null,e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close(1e3,"client_close")}catch{}}}function Ut(e){if(!W(n.headers))return;let t={v:1,type:"event",op:"client.headers",ts:Math.floor(Date.now()/1e3),payload:{headers:n.headers}};try{e.send(JSON.stringify(t))}catch(o){u("error",c("headers_frame_send_failed","atkonoffice: failed to send headers frame \u2014 "+R(o)))}}function Ht(e){if(typeof e!="string")return;let t;try{t=JSON.parse(e)}catch{return}if(!t||t.type!=="event")return;if(t.op===F){Me();return}if(t.op===ve){We(t.payload||{});return}let o=P[t.op];o&&u(o,t.payload||{}),t.op===ne&&(n.wsBackoffExhausted=!1,Ve(),de())}function N(){if(n.wsReconnectTimer||n.wsStopped)return;let e=Ge();if(!e||!e.pairId){u("error",c("ws_no_pair_to_resume","atkonoffice: document-event channel dropped and no pair to resume"));return}let t=n.wsReconnectAttempt>=ee,o;if(t)o=te;else{let r=n.wsReconnectAttempt+1;n.wsReconnectAttempt=r,o=Math.min(3e4,500*Math.pow(2,r-1))}n.wsReconnectTimer=setTimeout(()=>{n.wsReconnectTimer=null,n.nodeBase=e.nodeBase||n.nodeBase,Je(e.pairId,r=>{n.pairId=e.pairId,n.wsUrl=e.wsUrl||n.wsUrl,X(r)})},o),t&&!n.wsBackoffExhausted&&Dt("after "+ee+" consecutive fast reconnect attempts")}async function Je(e,t){let o=ae();if(!o||!n.backendBase){u("error",c("ws_ticket_backend_missing","atkonoffice: cannot refresh ws_ticket \u2014 backend not configured")),N();return}n.wsTicketInFlight=!0;let r=Ae(n.nodeBase,n.backendBase)?n.nodeBase:n.backendBase;try{let i=await o(r+n.wsTicketPath,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pairId:e,backendBase:r})});if(!i.ok){u("error",c("ws_ticket_http_error","atkonoffice: ws_ticket refresh returned HTTP "+i.status)),N();return}let s=await i.json();if(!s||typeof s.wsTicket!="string"||!s.wsTicket){u("error",c("ws_ticket_response_invalid","atkonoffice: ws_ticket refresh response missing wsTicket")),N();return}typeof s.wsUrl=="string"&&s.wsUrl&&(n.nodeBase&&n.wsUrl&&s.wsUrl!==n.wsUrl?u("error",c("ws_ticket_node_mismatch","atkonoffice: ws_ticket refresh was served by a different backend instance than this session \u2014 expected "+n.wsUrl+", got "+s.wsUrl+" (multi-instance: check the load balancer routes this session node prefix to that instance)")):n.wsUrl=s.wsUrl),t(s.wsTicket)}catch(i){u("error",c("ws_ticket_refresh_failed","atkonoffice: ws_ticket refresh failed \u2014 "+R(i))),N()}finally{n.wsTicketInFlight=!1}}function Ft(e){let t=n.eventHandlers[e];return!!t&&t.length>0}function Mt(e){for(let t in P)if(P.hasOwnProperty(t)&&P[t]===e)return!0;return!1}function Xe(e){return Mt(e)||e===A||e===B}function qe(){return U.some(e=>Xe(e)&&Ft(e))}function u(e,t){let o=n.eventHandlers[e];if(!o||o.length===0){if(e==="error")try{console.error("[atkonoffice] "+(t&&t.message?t.message:t))}catch{}return}for(let r of o.slice())try{r(t)}catch{}}function ze(e,t){if(typeof e!="string"||U.indexOf(e)===-1)throw new TypeError('atkonoffice.on: unknown event "'+e+'" (expected one of '+U.join(", ")+")");if(typeof t!="function")throw new TypeError("atkonoffice.on: handler must be a function");return n.eventHandlers[e]||(n.eventHandlers[e]=[]),n.eventHandlers[e].push(t),Xe(e)&&J(),y}function $e(){Wt(n.pairTimeoutMs).then(e=>{x(),e.installed||jt(e.clientDownloadUrl)})}function Yt(e){let t=e.indexOf(b);if(t<0)return null;let o=t;for(;o>0&&e.charAt(o-1)===H;)o-=1;return e.slice(0,o)}function Wt(e){return new Promise(t=>{let o=!1,r=null,i=null,s=null,h=!1,f="",g="",_=()=>{if(i&&(clearTimeout(i),i=null),s&&(clearInterval(s),s=null),h)O(f),h=!1;else{let p=Yt(k());p!==null&&O(p)}if(r){r.onopen=r.onmessage=r.onerror=r.onclose=null;try{r.close(1e3,"probe_done")}catch{}r=null}},m=p=>{o||(o=!0,_(),t({installed:p,clientDownloadUrl:g}))};i=setTimeout(()=>m(!1),e),Gt().then(p=>{if(p&&typeof p.clientDownloadUrl=="string"&&(g=p.clientDownloadUrl),o||!j(p)){m(!1);return}let Z=p.wsUrl,Se=typeof p.pairId=="string"?p.pairId:"",Ce=p.launchTicket;fe();let S;try{S=new WebSocket(Y(Z,"ticket",encodeURIComponent(p.wsTicket)))}catch{m(!1);return}r=S,S.onopen=()=>{let C=k();C.indexOf(b)<0&&(f=C,h=!0),O(K(Z,Se,Ce)),s=setInterval(()=>{!o&&k().indexOf(b)<0&&O(K(Z,Se,Ce))},n.pairRecoverMs)},S.onmessage=C=>{let Pe=C&&C.data;if(typeof Pe!="string")return;let L;try{L=JSON.parse(Pe)}catch{return}L&&L.type==="event"&&L.op===F&&m(!0)},S.onerror=()=>{},S.onclose=()=>{}}).catch(()=>{m(!1)})})}async function Gt(){return V({docId:"",pageUrl:"",user:"",backendBase:n.backendBase},"atkonoffice: launch-probe")}function jt(e){if(typeof document>"u"||!document.body||typeof document.createElement!="function")return null;pe();let t=document.createElement("div");t.setAttribute("data-atkonoffice-guide",oe),t.style.cssText="position:fixed;inset:0;z-index:2147483647;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.45);font:14px/1.6 system-ui,-apple-system,sans-serif;";let o=document.createElement("div");o.style.cssText="background:#fff;color:#222;max-width:420px;width:86%;border-radius:8px;padding:24px;box-shadow:0 8px 32px rgba(0,0,0,0.25);box-sizing:border-box;";let r=document.createElement("h2");r.textContent="\u9700\u8981\u5B89\u88C5\u7F16\u8F91\u5668\u5BA2\u6237\u7AEF",r.style.cssText="margin:0 0 12px;font-size:18px;";let i=document.createElement("p");i.style.cssText="margin:0 0 20px;color:#444;",i.textContent=e?"\u672A\u68C0\u6D4B\u5230\u672C\u673A\u5DF2\u5B89\u88C5\u7F16\u8F91\u5668\u5BA2\u6237\u7AEF\u3002\u8BF7\u5148\u4E0B\u8F7D\u5E76\u5B89\u88C5,\u5B89\u88C5\u5B8C\u6210\u540E\u70B9\u300C\u6211\u5DF2\u5B89\u88C5,\u91CD\u8BD5\u300D\u3002":"\u672A\u68C0\u6D4B\u5230\u672C\u673A\u5DF2\u5B89\u88C5\u7F16\u8F91\u5668\u5BA2\u6237\u7AEF,\u4E14\u672A\u914D\u7F6E\u4E0B\u8F7D\u5730\u5740\u3002\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u83B7\u53D6\u5B89\u88C5\u5305,\u5B89\u88C5\u5B8C\u6210\u540E\u70B9\u300C\u6211\u5DF2\u5B89\u88C5,\u91CD\u8BD5\u300D\u3002";let s=document.createElement("div");s.style.cssText="display:flex;gap:10px;justify-content:flex-end;flex-wrap:wrap;";let h="font:inherit;padding:8px 16px;border-radius:6px;cursor:pointer;border:1px solid #ccc;background:#f6f6f6;color:#222;",f="font:inherit;padding:8px 16px;border-radius:6px;cursor:pointer;border:1px solid #1a6dd6;background:#1a6dd6;color:#fff;text-decoration:none;display:inline-block;";if(e){let m=document.createElement("a");m.textContent="\u4E0B\u8F7D\u5BA2\u6237\u7AEF",m.href=e,m.target="_blank",m.rel="noopener noreferrer",m.style.cssText=f,s.appendChild(m)}let g=document.createElement("button");g.type="button",g.textContent="\u6211\u5DF2\u5B89\u88C5,\u91CD\u8BD5",g.style.cssText=h,g.addEventListener("click",()=>{pe();try{typeof n.replayOpen=="function"&&n.replayOpen()}catch{}});let _=document.createElement("button");return _.type="button",_.textContent="\u5173\u95ED",_.style.cssText=h,_.addEventListener("click",()=>pe()),s.appendChild(g),s.appendChild(_),o.appendChild(r),o.appendChild(i),o.appendChild(s),t.appendChild(o),document.body.appendChild(t),t}function pe(){if(!(typeof document>"u"||typeof document.querySelector!="function"))try{let e=document.querySelector('[data-atkonoffice-guide="'+oe+'"]');e&&typeof e.remove=="function"?e.remove():e&&e.parentNode&&typeof e.parentNode.removeChild=="function"&&e.parentNode.removeChild(e)}catch{}}function Qe(e){if(!e||typeof e!="object")throw new TypeError("atkonoffice.config requires an options object");if(typeof e.backendBase=="string"&&(n.backendBase=re(e.backendBase)),typeof e.launchPath=="string"&&e.launchPath&&(n.launchPath=e.launchPath),typeof e.wsTicketPath=="string"&&e.wsTicketPath&&(n.wsTicketPath=e.wsTicketPath),typeof e.fetchImpl=="function"&&(n.fetchImpl=e.fetchImpl),Array.isArray(e.trustedFrameOrigins)){let t=e.trustedFrameOrigins.filter(o=>typeof o=="string"&&o);n.trustedFrameOrigins=t.length>0?t:null}return n.initialized=!0,qe()&&J(),y}function me(e){if(n.launchInFlight)return n.inFlightOpen;n.launchInFlight=!0;let t=Vt(e);return n.launchInFlight&&(n.inFlightOpen=t),t}async function Vt(e){try{let t=e||{};if(!n.backendBase)throw c("backend_base_missing","atkonoffice.open: backendBase not configured \u2014 call atkonoffice.config({ backendBase }) first");let o=t.pageUrl!=null?String(t.pageUrl):"",r=t.params||{},i=r.docId!=null?String(r.docId):"";if(!o&&!i)throw c("doc_id_missing","atkonoffice.open: docId is required \u2014 call open({ params: { docId, \u2026 } }) (page-less \u6A21\u5F0F\u4E0B\u65E0\u4E1A\u52A1\u9875\u53EF\u951A docId\uFF0C\u4E0B\u8F7D/\u4FDD\u5B58\u5747 docId \u7ED1\u5B9A)");let s={pageUrl:o,params:r,backendBase:n.backendBase},h=Xt(t.options);h&&(s.options=h),typeof t.pageApi=="string"&&t.pageApi&&(s.pageApi=t.pageApi),t.storage&&typeof t.storage=="object"&&Object.keys(t.storage).length>0&&(s.storage=t.storage);let f=await V(s,"atkonoffice.open: launch");if(!f||typeof f.launchUrl!="string"||!f.launchUrl)throw c("launch_response_invalid","atkonoffice.open: launch endpoint response missing launchUrl");let g=Kt(t);n.headers=W(g)?g:null;let _=j(f);return n.replayOpen=()=>me(e),n.onPairDowngrade=_?$e:null,typeof f.wsTicket=="string"&&f.wsTicket&&typeof f.wsUrl=="string"&&f.wsUrl&&(n.wsUrl=f.wsUrl,n.pairId=typeof f.pairId=="string"?f.pairId:"",n.nodeBase=Jt(f),le(n.pairId,n.wsUrl,n.nodeBase),n.wsReconnectAttempt=0,n.wsStopped=!1,n.wsBackoffExhausted=!1,n.wsTicketInFlight=!1,_&&Ue(f),X(f.wsTicket)),_||(G(f.launchUrl),x()),{launchUrl:f.launchUrl,downloadUrl:typeof f.downloadUrl=="string"?f.downloadUrl:"",pairId:n.pairId,wsUrl:n.wsUrl}}catch(t){throw x(),t}}function Kt(e){let t={},o=e.headers;if(Array.isArray(o)){for(let i of o)if(Array.isArray(i)&&i.length>=2)I(t,i[0],i[1]);else if(typeof i=="string"&&i.indexOf(":")!==-1){let s=i.indexOf(":");I(t,i.slice(0,s),i.slice(s+1).trim())}}else if(o&&typeof o=="object")for(let i of Object.keys(o))I(t,i,o[i]);let r=Be(e.cookie);return r&&I(t,"Cookie",r),e.storage&&typeof e.storage=="object"&&I(t,"X-Atkonoffice-Storage",JSON.stringify(e.storage)),t}function Jt(e){let t=e&&e.openParams?e.openParams.backend:null;return typeof t=="string"&&t?re(t):""}function Xt(e){if(!e||typeof e!="object")return null;let t={};return typeof e.width=="number"&&(t.width=e.width),typeof e.height=="number"&&(t.height=e.height),typeof e.modal=="boolean"&&(t.modal=e.modal),Object.keys(t).length>0?t:null}var d={};var Ze="atkonoffice-doc-host",he="__atkonofficeDocHostEvent",ge=["documentSaved","documentOpened","documentBeforeSave","error","controlReady","compareDiff","documentReady","documentFailed"],_e="doc.ready",we="doc.embedFailed",ye="doc.opened",q={"doc.saved":"documentSaved",[ye]:"documentOpened","doc.beforeSave":"documentBeforeSave","compare.diff":"compareDiff",[_e]:"documentReady",[we]:"documentFailed"},et="controlReady",tt="toolbarClick",nt="readbackResult",ot="messageBoxResult",a={eventHandlers:{},hintShown:!1,toolbarButtons:{},toolbarSeq:0,readbackPending:{},readbackSeq:0,messageBoxPending:{},messageBoxSeq:0,docTerminal:null};function rt(e,t,o){if(typeof e!="string")throw new TypeError("atkonoffice embed.addCustomToolButton: caption must be a string");if(typeof o!="function")throw new TypeError("atkonoffice embed.addCustomToolButton: onClick must be a function");if(typeof window>"u")return null;w();let r=typeof t=="number"&&isFinite(t)?Math.trunc(t):0,i="btn-"+ ++a.toolbarSeq;return a.toolbarButtons[i]=o,E("toolbarAdd",JSON.stringify({buttonId:i,caption:e,iconIndex:r}))?{remove:function(){delete a.toolbarButtons[i],E("toolbarRemove",JSON.stringify({buttonId:i}))}}:(delete a.toolbarButtons[i],ft(),null)}function it(e){if(typeof e!="boolean")throw new TypeError("atkonoffice embed.setCustomToolbarVisible: visible must be a boolean");return typeof window>"u"?d:(w(),E("toolbarSetVisible",JSON.stringify({visible:e})),d)}function st(e){let t=e&&e.buttonId;if(typeof t!="string"||!t)return;let o=a.toolbarButtons[t];if(typeof o=="function")try{o()}catch(r){lt("addCustomToolButton onClick threw: "+(r&&r.message?r.message:r))}}function z(){if(typeof window>"u")return null;let e=window.atkonofficeCtrl=window.atkonofficeCtrl||{};return typeof e.save!="function"&&(e.save=function(t){let o=t&&typeof t=="object"?JSON.stringify(t):void 0;return typeof e._WebSave=="function"?e._WebSave(o):E("save",o)}),typeof e.exec!="function"&&(e.exec=function(t){return typeof t!="string"||!t?!1:E("executeJs",t)}),typeof e.setSavePath!="function"&&(e.setSavePath=function(t){return typeof t!="string"||!t?!1:E("setSavePath",t)}),e}function at(e){let t=z();return t&&typeof t.save=="function"?t.save(e):!1}function ct(e){let t=z();return t&&typeof t.setSavePath=="function"?t.setSavePath(e):!1}function E(e,t){if(typeof window>"u")return!1;let o=window.__atkonofficeDocHost;return o&&typeof o.sendCommand=="function"?(t!=null?o.sendCommand(e,t):o.sendCommand(e),!0):!1}var qt=15e3;function v(e,t){if(typeof window>"u")return Promise.resolve({ok:!1,error:"non-browser"});w();let o=++a.readbackSeq,r=JSON.stringify({rid:o,method:e,args:Array.isArray(t)?t:[]});return new Promise(i=>{let s=setTimeout(function(){Te(o,{ok:!1,error:"timeout"})},qt);s&&typeof s.unref=="function"&&s.unref(),a.readbackPending[o]={resolve:i,timer:s},E("readback",r)||Te(o,{ok:!1,error:"shell-absent"})})}function Te(e,t){let o=a.readbackPending[e];o&&(delete a.readbackPending[e],clearTimeout(o.timer),o.resolve(t))}function ut(e){let t=e&&e.rid;typeof t=="number"&&Te(t,e.ok?{ok:!0,value:e.value,error:void 0}:{ok:!1,value:void 0,error:e.error||"invoke failed"})}var zt=6e5;function dt(e){if(typeof window>"u")return Promise.resolve({ok:!1,error:"non-browser"});w();let t=e&&typeof e=="object"?e:{},o=++a.messageBoxSeq,r=JSON.stringify({rid:o,type:t.type,title:t.title,text:t.text,buttons:t.buttons});return new Promise(i=>{let s=setTimeout(function(){Ee(o,{ok:!1,error:"timeout"})},zt);s&&typeof s.unref=="function"&&s.unref(),a.messageBoxPending[o]={resolve:i,timer:s},E("messageBox",r)||Ee(o,{ok:!1,error:"shell-absent"})})}function Ee(e,t){let o=a.messageBoxPending[e];o&&(delete a.messageBoxPending[e],clearTimeout(o.timer),o.resolve(t))}function pt(e){let t=e&&e.rid;typeof t=="number"&&Ee(t,{ok:!!(e&&e.ok),button:e?e.button:void 0,error:e?e.error:void 0})}function mt(e,t){if(e===ye){a.docTerminal=null;return}(e===_e||e===we)&&(a.docTerminal={event:q[e],payload:t||{}})}function ht(e,t){!a.docTerminal||a.docTerminal.event!==e||typeof setTimeout=="function"&&setTimeout(function(){let o=a.docTerminal;if(!(!o||o.event!==e))try{t(o.payload)}catch{}},0)}function w(){$t(),z()}function _t(e,t){if(typeof e!="string"||ge.indexOf(e)===-1)throw new TypeError('atkonoffice embed.on: unknown event "'+e+'" (expected one of '+ge.join(", ")+")");if(typeof t!="function")throw new TypeError("atkonoffice embed.on: handler must be a function");return w(),a.eventHandlers[e]||(a.eventHandlers[e]=[]),a.eventHandlers[e].push(t),ht(e,t),d}function $t(){typeof window>"u"||typeof window[he]=="function"||(window[he]=function(e,t){if(e===et){gt("controlReady",t||{});return}if(e===tt){st(t||{});return}if(e===nt){ut(t||{});return}if(e===ot){pt(t||{});return}mt(e,t||{});let o=q[e];o&&gt(o,t||{})})}function gt(e,t){let o=a.eventHandlers[e];if(!o||o.length===0){if(e==="error")try{console.error("[atkonoffice embed] "+(t&&t.message?t.message:t))}catch{}return}for(let r of o.slice())try{r(t)}catch{}}function ft(){if(!a.hintShown){a.hintShown=!0;try{console.info("[atkonoffice embed] <"+Ze+"> \u672A\u88AB\u5B9A\u4E49 \u2014\u2014 \u8BF7\u5728\u5DF2\u5B89\u88C5 atkonoffice \u5BA2\u6237\u7AEF\u7684\u58F3\u5185\u6253\u5F00\u672C\u7F16\u8F91\u9875;\u666E\u901A\u6D4F\u89C8\u5668\u91CC\u5B83\u662F\u7A7A\u76D2(\u4E0D\u5F71\u54CD\u9875\u9762\u5176\u4F59\u90E8\u5206)\u3002")}catch{}}}function lt(e){try{console.warn("[atkonoffice embed] "+e)}catch{}}function wt(e){if(typeof e!="function")throw new TypeError("atkonoffice embed.onBeforeSave: fn must be a function");return w(),Tt("onBeforeSave",e),d}function yt(e){if(typeof e!="function")throw new TypeError("atkonoffice embed.onBeforeClose: fn must be a function");return w(),Tt("onBeforeClose",e),d}function Tt(e,t){if(typeof window>"u")return!1;let o=window.__atkonofficeDocHost;return o&&typeof o[e]=="function"?(o[e](t),!0):!1}var Qt="AO_";function $(e){return!!(e&&e.ok&&Number(e.value)>0)}function Q(){return Promise.resolve({ok:!1,error:"bad-args"})}function Et(e,t){return Re(e,t).then($)}function Re(e,t){if(typeof e!="string"||!e)return Q();let o=typeof t=="string"?t:t==null?"":String(t),r={};return r[e]=o,v("Word_FillDataRegion",[JSON.stringify(r)])}function Rt(e,t){return be(e,t).then($)}function be(e,t){if(typeof e!="string"||!e)return Q();let o=typeof t=="string"?t:t==null?"":String(t);return v("Word_AddDataRegion",[e,o])}function bt(e){return xe(e).then($)}function xe(e){return typeof e!="string"||!e?Q():v("Word_DeleteDataRegion",[e])}function xt(e){return ke(e).then($)}function ke(e){return typeof e!="string"||!e?Q():v("Word_LocateDataRegion",[e])}function kt(e){return Oe(e).then(function(t){return t.ok?t.value:[]})}function Oe(e){let t=typeof e=="string"?e:Qt;return v("BookmarksAsJson",[]).then(function(o){if(!o||!o.ok)return{ok:!1,error:o&&o.error||"invoke failed"};let r;try{r=JSON.parse(o.value)}catch{r=null}return Array.isArray(r)?{ok:!0,value:r.filter(function(i){return typeof i=="string"&&(t===""||i.indexOf(t)===0)})}:{ok:!1,error:"bad-value"}})}d.on=_t;d.addCustomToolButton=rt;d.setCustomToolbarVisible=it;d.save=at;d.setSavePath=ct;d.showMessageBox=dt;d.onBeforeSave=wt;d.onBeforeClose=yt;d.word={fillDataRegion:Et,addDataRegion:Rt,deleteDataRegion:bt,locateDataRegion:xt,listDataRegions:kt,receipt:{fillDataRegion:Re,addDataRegion:be,deleteDataRegion:xe,locateDataRegion:ke,listDataRegions:Oe}};y.config=Qe;y.open=me;y.on=ze;y.session=d;var Zt=y,Ao=Zt;export{Zt as atkonoffice,Ao as default};
1
+ var R={};var n={backendBase:"",launchPath:"/atkonoffice/rpc/launch",wsTicketPath:"/atkonoffice/rpc/ws-ticket",fetchImpl:null,initialized:!1,ws:null,wsUrl:"",pairId:"",nodeBase:"",headers:null,eventHandlers:{},wsReconnectAttempt:0,wsReconnectTimer:null,wsTicketInFlight:!1,wsStopped:!1,wsBackoffExhausted:!1,channelLostAnnounced:!1,channelRestoreConfirmTimer:null,pairing:!1,launchTicket:"",openParams:null,fallbackUrl:"",pairingPrevTitle:"",pairingTitleSaved:!1,pairingRecoverTimer:null,pairingTimeoutTimer:null,pairTimeoutMs:5e3,pairRecoverMs:1e3,titleRelayInstalled:!1,trustedFrameOrigins:null,onPairDowngrade:null,replayOpen:null,launchInFlight:!1,inFlightOpen:null};function O(){n.launchInFlight=!1,n.inFlightOpen=null}var H="atkonoffice.ws.session",ee=12,te=3e5,Ae=1e3,B="channelLost",L="channelRestored",F=["documentSaved","documentOpened","documentBeforeSave","documentEmbedFailed","shellClosed",B,L,"error"],ne="shell.closed",v={"doc.saved":"documentSaved","doc.opened":"documentOpened","doc.beforeSave":"documentBeforeSave",[ne]:"shellClosed"},k="atkonoffice-launch=",M="\u2007",V="pair.ready",De="launch.open",Be="doc.embedFailed",W="__atkonofficeTitle",oe="atkonoffice-install-guide";function re(e){return e&&e.endsWith("/")?e.slice(0,-1):e}function Le(e,t){if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}}function j(e,t,o){let r=e.indexOf("?")===-1?"?":"&";return e+r+t+"="+o}function Y(e){return!!e&&Object.keys(e).length>0}function b(e){return e&&e.message?e.message:String(e)}function N(e,t,o){if(t==null)return;let r=String(t).trim();r&&(e[r]=o==null?"":String(o))}function Ue(e){return e?typeof e=="string"?e:typeof e=="object"?Object.keys(e).map(t=>t+"="+String(e[t])).join("; "):"":""}function He(e){let t;if(typeof TextEncoder<"u"){let o=new TextEncoder().encode(e),r="";for(let i=0;i<o.length;i++)r+=String.fromCharCode(o[i]);t=r}else t=unescape(encodeURIComponent(e));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function S(){try{return typeof document<"u"&&typeof document.title=="string"?document.title:""}catch{return""}}function ie(){if(typeof window>"u")return!1;try{return window.top!==window.self}catch{return!0}}function G(e){try{let t=document.createElement("iframe");t.style.display="none",t.src=e,document.body.appendChild(t),setTimeout(()=>{try{document.body.removeChild(t)}catch{}},1e3)}catch{window.location.href=e}}function J(e){return!!(typeof e.launchTicket=="string"&&e.launchTicket&&typeof e.wsUrl=="string"&&e.wsUrl&&typeof e.wsTicket=="string"&&e.wsTicket&&typeof document<"u"&&typeof WebSocket<"u")}var l={CONFIG:"config",LAUNCH:"launch",CHANNEL:"channel"},ae={backend_base_missing:l.CONFIG,doc_id_missing:l.CONFIG,fetch_unavailable:l.CONFIG,ws_unsupported:l.CONFIG,ws_ticket_backend_missing:l.CONFIG,ws_ticket_node_mismatch:l.CONFIG,launch_request_failed:l.LAUNCH,launch_http_error:l.LAUNCH,launch_response_not_json:l.LAUNCH,launch_response_invalid:l.LAUNCH,launch_open_frame_send_failed:l.LAUNCH,ws_url_missing:l.CHANNEL,ws_ticket_missing:l.CHANNEL,ws_connect_failed:l.CHANNEL,ws_error:l.CHANNEL,headers_frame_send_failed:l.CHANNEL,ws_no_pair_to_resume:l.CHANNEL,ws_backoff_exhausted:l.CHANNEL,ws_gave_up:l.CHANNEL,ws_ticket_http_error:l.CHANNEL,ws_ticket_response_invalid:l.CHANNEL,ws_ticket_refresh_failed:l.CHANNEL};function c(e,t){let o=new Error(t);return o.code=e,o.category=ae[e],o}function se(){return typeof n.fetchImpl=="function"?n.fetchImpl:typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):null}function Bt(){let e=se();if(!e)throw c("fetch_unavailable","atkonoffice: no fetch available \u2014 pass fetchImpl via config in non-browser hosts");return e}async function K(e,t){let o;try{o=await Bt()(n.backendBase+n.launchPath,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(r){throw r&&ae[r.code]?r:c("launch_request_failed",t+" request failed \u2014 "+b(r))}if(!o.ok)throw c("launch_http_error",t+" endpoint returned HTTP "+o.status);try{return await o.json()}catch(r){throw c("launch_response_not_json",t+" response was not JSON \u2014 "+b(r))}}var T={PERM:"PERM",SLOW:"SLOW",RETRY:"RETRY"},ce=":",Lt=[[T.PERM+ce,T.PERM],[T.SLOW+ce,T.SLOW],[T.RETRY+ce,T.RETRY]];function Fe(e){if(typeof e!="string"||!e)return T.RETRY;for(let t of Lt)if(e.indexOf(t[0])===0)return t[1];return T.RETRY}function Me(e){n.launchTicket=e.launchTicket,n.openParams=e.openParams&&typeof e.openParams=="object"?e.openParams:{},n.fallbackUrl=e.launchUrl,n.pairing||(n.pairingTitleSaved=!1),n.pairing=!0,fe(),Ft()}function Ve(){if(!(!n.pairing||typeof document>"u")){if(!n.pairingTitleSaved){let e=S();e.indexOf(k)<0&&(n.pairingPrevTitle=e,n.pairingTitleSaved=!0)}We(),Ht()}}function We(){C(X(n.wsUrl,n.pairId,n.launchTicket))}function X(e,t,o){let r=He(JSON.stringify({wsUrl:e,pairId:t,launchTicket:o}));return M+k+r}function C(e){try{typeof document<"u"&&(document.title=e)}catch{}if(ie())try{let t={};t[W]=e,window.top.postMessage(t,"*")}catch{}}function fe(){n.titleRelayInstalled||typeof window>"u"||typeof window.addEventListener!="function"||ie()||(n.titleRelayInstalled=!0,window.addEventListener("message",e=>{if(!Ut(e&&e.origin))return;let t=e&&e.data;if(t&&typeof t=="object"&&typeof t[W]=="string")try{document.title=t[W]}catch{}}))}function Ut(e){let t=n.trustedFrameOrigins;return!t||t.length===0?!0:typeof e=="string"&&t.indexOf(e)!==-1}function Ht(){n.pairingRecoverTimer||typeof setInterval>"u"||(n.pairingRecoverTimer=setInterval(()=>{n.pairing&&S().indexOf(k)<0&&We()},n.pairRecoverMs))}function Ft(){n.pairingTimeoutTimer||typeof setTimeout>"u"||(n.pairingTimeoutTimer=setTimeout(()=>{n.pairingTimeoutTimer=null,Ye(!0)},n.pairTimeoutMs))}function je(){if(!n.pairing)return;let e=n.ws;Ye(!1),O(),e&&Mt(e)}function Mt(e){let t={v:1,type:"event",op:De,ts:Math.floor(Date.now()/1e3),payload:{pair_id:n.pairId,openParams:n.openParams||{}}};try{e.send(JSON.stringify(t))}catch(o){u("error",c("launch_open_frame_send_failed","atkonoffice: failed to send launch.open frame \u2014 "+b(o)))}}function Ye(e){n.pairingRecoverTimer&&(clearInterval(n.pairingRecoverTimer),n.pairingRecoverTimer=null),n.pairingTimeoutTimer&&(clearTimeout(n.pairingTimeoutTimer),n.pairingTimeoutTimer=null);let t=n.pairing;n.pairing=!1,n.pairingTitleSaved&&(C(n.pairingPrevTitle),n.pairingTitleSaved=!1),e&&t&&(G(n.fallbackUrl),typeof n.onPairDowngrade=="function"&&n.onPairDowngrade())}var Vt="documentEmbedFailed";function Ge(e){u(Vt,e||{})}function le(e,t,o){if(!(!e||typeof sessionStorage>"u"))try{sessionStorage.setItem(H,JSON.stringify({pairId:e,wsUrl:t,nodeBase:o||""}))}catch{}}function Je(){if(n.pairId)return{pairId:n.pairId,wsUrl:n.wsUrl,nodeBase:n.nodeBase};if(typeof sessionStorage>"u")return null;try{let e=sessionStorage.getItem(H);return e?JSON.parse(e):null}catch{return null}}function Wt(){n.pairId="",n.wsUrl="",n.nodeBase=""}function Ke(){if(!(typeof sessionStorage>"u"))try{sessionStorage.removeItem(H)}catch{}}function Xe(){Wt(),Ke()}function q(){if(n.ws||n.wsReconnectTimer||n.wsTicketInFlight||n.wsStopped||!n.backendBase)return;let e=Je();!e||!e.pairId||(n.pairId=e.pairId,n.wsUrl=e.wsUrl||n.wsUrl,n.nodeBase=e.nodeBase||n.nodeBase,n.wsReconnectAttempt=0,ze(e.pairId,t=>z(t)))}function z(e){if(typeof WebSocket>"u"){u("error",c("ws_unsupported","atkonoffice: WebSocket unavailable in this host \u2014 document events disabled"));return}if(!n.wsUrl){u("error",c("ws_url_missing","atkonoffice: no wsUrl \u2014 cannot open the document-event channel"));return}if(!e){u("error",c("ws_ticket_missing","atkonoffice: missing ws_ticket \u2014 cannot subscribe to document events"));return}de();let t=j(n.wsUrl,"ticket",encodeURIComponent(e)),o;try{o=new WebSocket(t)}catch(r){u("error",c("ws_connect_failed","atkonoffice: WS connect failed \u2014 "+b(r))),A();return}n.ws=o,o.onopen=()=>{n.wsBackoffExhausted&&le(n.pairId,n.wsUrl,n.nodeBase),n.wsReconnectAttempt=0,n.wsStopped=!1,n.wsBackoffExhausted=!1,jt(o),Jt(o),n.pairing&&Ve()},o.onmessage=r=>{Kt(r&&r.data)},o.onerror=()=>{u("error",c("ws_error","atkonoffice: WS error on the document-event channel"))},o.onclose=r=>{if(n.ws===o&&(n.ws=null),ue(),Fe(r&&r.reason)===T.PERM){Yt("server closed it permanently; reopen the document from the page to start a new session");return}A()}}function qe(e){n.channelLostAnnounced||(n.channelLostAnnounced=!0,u(B,{reason:e}))}function jt(e){ue(),n.channelLostAnnounced&&(n.channelRestoreConfirmTimer=setTimeout(()=>{n.channelRestoreConfirmTimer=null,!(n.ws!==e||!n.channelLostAnnounced)&&(n.channelLostAnnounced=!1,u(L,{}))},Ae))}function ue(){n.channelRestoreConfirmTimer&&(clearTimeout(n.channelRestoreConfirmTimer),n.channelRestoreConfirmTimer=null)}function Yt(e){n.wsStopped=!0,n.wsBackoffExhausted=!1,de(),Xe();let t=c("ws_gave_up","atkonoffice: document-event channel lost \u2014 "+e);t.terminal=!0,u("error",t),qe("rejected")}function Gt(e){n.wsBackoffExhausted=!0,Ke();let t=c("ws_backoff_exhausted","atkonoffice: document-event channel still unreachable "+e+" \u2014 left fast reconnect, now probing every "+Math.round(te/1e3)+"s until it comes back");t.terminal=!1,u("error",t),qe("unreachable")}function de(){n.wsReconnectTimer&&(clearTimeout(n.wsReconnectTimer),n.wsReconnectTimer=null),ue();let e=n.ws;if(n.ws=null,e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close(1e3,"client_close")}catch{}}}function Jt(e){if(!Y(n.headers))return;let t={v:1,type:"event",op:"client.headers",ts:Math.floor(Date.now()/1e3),payload:{headers:n.headers}};try{e.send(JSON.stringify(t))}catch(o){u("error",c("headers_frame_send_failed","atkonoffice: failed to send headers frame \u2014 "+b(o)))}}function Kt(e){if(typeof e!="string")return;let t;try{t=JSON.parse(e)}catch{return}if(!t||t.type!=="event")return;if(t.op===V){je();return}if(t.op===Be){Ge(t.payload||{});return}let o=v[t.op];o&&u(o,t.payload||{}),t.op===ne&&(n.wsBackoffExhausted=!1,Xe(),de())}function A(){if(n.wsReconnectTimer||n.wsStopped)return;let e=Je();if(!e||!e.pairId){u("error",c("ws_no_pair_to_resume","atkonoffice: document-event channel dropped and no pair to resume"));return}let t=n.wsReconnectAttempt>=ee,o;if(t)o=te;else{let r=n.wsReconnectAttempt+1;n.wsReconnectAttempt=r,o=Math.min(3e4,500*Math.pow(2,r-1))}n.wsReconnectTimer=setTimeout(()=>{n.wsReconnectTimer=null,n.nodeBase=e.nodeBase||n.nodeBase,ze(e.pairId,r=>{n.pairId=e.pairId,n.wsUrl=e.wsUrl||n.wsUrl,z(r)})},o),t&&!n.wsBackoffExhausted&&Gt("after "+ee+" consecutive fast reconnect attempts")}async function ze(e,t){let o=se();if(!o||!n.backendBase){u("error",c("ws_ticket_backend_missing","atkonoffice: cannot refresh ws_ticket \u2014 backend not configured")),A();return}n.wsTicketInFlight=!0;let r=Le(n.nodeBase,n.backendBase)?n.nodeBase:n.backendBase;try{let i=await o(r+n.wsTicketPath,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pairId:e,backendBase:r})});if(!i.ok){u("error",c("ws_ticket_http_error","atkonoffice: ws_ticket refresh returned HTTP "+i.status)),A();return}let a=await i.json();if(!a||typeof a.wsTicket!="string"||!a.wsTicket){u("error",c("ws_ticket_response_invalid","atkonoffice: ws_ticket refresh response missing wsTicket")),A();return}typeof a.wsUrl=="string"&&a.wsUrl&&(n.nodeBase&&n.wsUrl&&a.wsUrl!==n.wsUrl?u("error",c("ws_ticket_node_mismatch","atkonoffice: ws_ticket refresh was served by a different backend instance than this session \u2014 expected "+n.wsUrl+", got "+a.wsUrl+" (multi-instance: check the load balancer routes this session node prefix to that instance)")):n.wsUrl=a.wsUrl),t(a.wsTicket)}catch(i){u("error",c("ws_ticket_refresh_failed","atkonoffice: ws_ticket refresh failed \u2014 "+b(i))),A()}finally{n.wsTicketInFlight=!1}}function Xt(e){let t=n.eventHandlers[e];return!!t&&t.length>0}function qt(e){for(let t in v)if(v.hasOwnProperty(t)&&v[t]===e)return!0;return!1}function $e(e){return qt(e)||e===B||e===L}function Qe(){return F.some(e=>$e(e)&&Xt(e))}function u(e,t){let o=n.eventHandlers[e];if(!o||o.length===0){if(e==="error")try{console.error("[atkonoffice] "+(t&&t.message?t.message:t))}catch{}return}for(let r of o.slice())try{r(t)}catch{}}function Ze(e,t){if(typeof e!="string"||F.indexOf(e)===-1)throw new TypeError('atkonoffice.on: unknown event "'+e+'" (expected one of '+F.join(", ")+")");if(typeof t!="function")throw new TypeError("atkonoffice.on: handler must be a function");return n.eventHandlers[e]||(n.eventHandlers[e]=[]),n.eventHandlers[e].push(t),$e(e)&&q(),R}function et(){$t(n.pairTimeoutMs).then(e=>{O(),e.installed||Zt(e.clientDownloadUrl)})}function zt(e){let t=e.indexOf(k);if(t<0)return null;let o=t;for(;o>0&&e.charAt(o-1)===M;)o-=1;return e.slice(0,o)}function $t(e){return new Promise(t=>{let o=!1,r=null,i=null,a=null,h=!1,f="",g="",y=()=>{if(i&&(clearTimeout(i),i=null),a&&(clearInterval(a),a=null),h)C(f),h=!1;else{let p=zt(S());p!==null&&C(p)}if(r){r.onopen=r.onmessage=r.onerror=r.onclose=null;try{r.close(1e3,"probe_done")}catch{}r=null}},m=p=>{o||(o=!0,y(),t({installed:p,clientDownloadUrl:g}))};i=setTimeout(()=>m(!1),e),Qt().then(p=>{if(p&&typeof p.clientDownloadUrl=="string"&&(g=p.clientDownloadUrl),o||!J(p)){m(!1);return}let Z=p.wsUrl,Ie=typeof p.pairId=="string"?p.pairId:"",ve=p.launchTicket;fe();let P;try{P=new WebSocket(j(Z,"ticket",encodeURIComponent(p.wsTicket)))}catch{m(!1);return}r=P,P.onopen=()=>{let I=S();I.indexOf(k)<0&&(f=I,h=!0),C(X(Z,Ie,ve)),a=setInterval(()=>{!o&&S().indexOf(k)<0&&C(X(Z,Ie,ve))},n.pairRecoverMs)},P.onmessage=I=>{let Ne=I&&I.data;if(typeof Ne!="string")return;let U;try{U=JSON.parse(Ne)}catch{return}U&&U.type==="event"&&U.op===V&&m(!0)},P.onerror=()=>{},P.onclose=()=>{}}).catch(()=>{m(!1)})})}async function Qt(){return K({docId:"",pageUrl:"",user:"",backendBase:n.backendBase},"atkonoffice: launch-probe")}function Zt(e){if(typeof document>"u"||!document.body||typeof document.createElement!="function")return null;pe();let t=document.createElement("div");t.setAttribute("data-atkonoffice-guide",oe),t.style.cssText="position:fixed;inset:0;z-index:2147483647;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.45);font:14px/1.6 system-ui,-apple-system,sans-serif;";let o=document.createElement("div");o.style.cssText="background:#fff;color:#222;max-width:420px;width:86%;border-radius:8px;padding:24px;box-shadow:0 8px 32px rgba(0,0,0,0.25);box-sizing:border-box;";let r=document.createElement("h2");r.textContent="\u9700\u8981\u5B89\u88C5\u7F16\u8F91\u5668\u5BA2\u6237\u7AEF",r.style.cssText="margin:0 0 12px;font-size:18px;";let i=document.createElement("p");i.style.cssText="margin:0 0 20px;color:#444;",i.textContent=e?"\u672A\u68C0\u6D4B\u5230\u672C\u673A\u5DF2\u5B89\u88C5\u7F16\u8F91\u5668\u5BA2\u6237\u7AEF\u3002\u8BF7\u5148\u4E0B\u8F7D\u5E76\u5B89\u88C5,\u5B89\u88C5\u5B8C\u6210\u540E\u70B9\u300C\u6211\u5DF2\u5B89\u88C5,\u91CD\u8BD5\u300D\u3002":"\u672A\u68C0\u6D4B\u5230\u672C\u673A\u5DF2\u5B89\u88C5\u7F16\u8F91\u5668\u5BA2\u6237\u7AEF,\u4E14\u672A\u914D\u7F6E\u4E0B\u8F7D\u5730\u5740\u3002\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u83B7\u53D6\u5B89\u88C5\u5305,\u5B89\u88C5\u5B8C\u6210\u540E\u70B9\u300C\u6211\u5DF2\u5B89\u88C5,\u91CD\u8BD5\u300D\u3002";let a=document.createElement("div");a.style.cssText="display:flex;gap:10px;justify-content:flex-end;flex-wrap:wrap;";let h="font:inherit;padding:8px 16px;border-radius:6px;cursor:pointer;border:1px solid #ccc;background:#f6f6f6;color:#222;",f="font:inherit;padding:8px 16px;border-radius:6px;cursor:pointer;border:1px solid #1a6dd6;background:#1a6dd6;color:#fff;text-decoration:none;display:inline-block;";if(e){let m=document.createElement("a");m.textContent="\u4E0B\u8F7D\u5BA2\u6237\u7AEF",m.href=e,m.target="_blank",m.rel="noopener noreferrer",m.style.cssText=f,a.appendChild(m)}let g=document.createElement("button");g.type="button",g.textContent="\u6211\u5DF2\u5B89\u88C5,\u91CD\u8BD5",g.style.cssText=h,g.addEventListener("click",()=>{pe();try{typeof n.replayOpen=="function"&&n.replayOpen()}catch{}});let y=document.createElement("button");return y.type="button",y.textContent="\u5173\u95ED",y.style.cssText=h,y.addEventListener("click",()=>pe()),a.appendChild(g),a.appendChild(y),o.appendChild(r),o.appendChild(i),o.appendChild(a),t.appendChild(o),document.body.appendChild(t),t}function pe(){if(!(typeof document>"u"||typeof document.querySelector!="function"))try{let e=document.querySelector('[data-atkonoffice-guide="'+oe+'"]');e&&typeof e.remove=="function"?e.remove():e&&e.parentNode&&typeof e.parentNode.removeChild=="function"&&e.parentNode.removeChild(e)}catch{}}function tt(e){if(!e||typeof e!="object")throw new TypeError("atkonoffice.config requires an options object");if(typeof e.backendBase=="string"&&(n.backendBase=re(e.backendBase)),typeof e.launchPath=="string"&&e.launchPath&&(n.launchPath=e.launchPath),typeof e.wsTicketPath=="string"&&e.wsTicketPath&&(n.wsTicketPath=e.wsTicketPath),typeof e.fetchImpl=="function"&&(n.fetchImpl=e.fetchImpl),Array.isArray(e.trustedFrameOrigins)){let t=e.trustedFrameOrigins.filter(o=>typeof o=="string"&&o);n.trustedFrameOrigins=t.length>0?t:null}return n.initialized=!0,Qe()&&q(),R}function me(e){if(n.launchInFlight)return n.inFlightOpen;n.launchInFlight=!0;let t=en(e);return n.launchInFlight&&(n.inFlightOpen=t),t}async function en(e){try{let t=e||{};if(!n.backendBase)throw c("backend_base_missing","atkonoffice.open: backendBase not configured \u2014 call atkonoffice.config({ backendBase }) first");let o=t.pageUrl!=null?String(t.pageUrl):"",r=t.params||{},i=r.docId!=null?String(r.docId):"";if(!o&&!i)throw c("doc_id_missing","atkonoffice.open: docId is required \u2014 call open({ params: { docId, \u2026 } }) (page-less \u6A21\u5F0F\u4E0B\u65E0\u4E1A\u52A1\u9875\u53EF\u951A docId\uFF0C\u4E0B\u8F7D/\u4FDD\u5B58\u5747 docId \u7ED1\u5B9A)");let a={pageUrl:o,params:r,backendBase:n.backendBase},h=on(t.options);h&&(a.options=h),typeof t.pageApi=="string"&&t.pageApi&&(a.pageApi=t.pageApi),t.storage&&typeof t.storage=="object"&&Object.keys(t.storage).length>0&&(a.storage=t.storage);let f=await K(a,"atkonoffice.open: launch");if(!f||typeof f.launchUrl!="string"||!f.launchUrl)throw c("launch_response_invalid","atkonoffice.open: launch endpoint response missing launchUrl");let g=tn(t);n.headers=Y(g)?g:null;let y=J(f);return n.replayOpen=()=>me(e),n.onPairDowngrade=y?et:null,typeof f.wsTicket=="string"&&f.wsTicket&&typeof f.wsUrl=="string"&&f.wsUrl&&(n.wsUrl=f.wsUrl,n.pairId=typeof f.pairId=="string"?f.pairId:"",n.nodeBase=nn(f),le(n.pairId,n.wsUrl,n.nodeBase),n.wsReconnectAttempt=0,n.wsStopped=!1,n.wsBackoffExhausted=!1,n.wsTicketInFlight=!1,y&&Me(f),z(f.wsTicket)),y||(G(f.launchUrl),O()),{launchUrl:f.launchUrl,downloadUrl:typeof f.downloadUrl=="string"?f.downloadUrl:"",pairId:n.pairId,wsUrl:n.wsUrl}}catch(t){throw O(),t}}function tn(e){let t={},o=e.headers;if(Array.isArray(o)){for(let i of o)if(Array.isArray(i)&&i.length>=2)N(t,i[0],i[1]);else if(typeof i=="string"&&i.indexOf(":")!==-1){let a=i.indexOf(":");N(t,i.slice(0,a),i.slice(a+1).trim())}}else if(o&&typeof o=="object")for(let i of Object.keys(o))N(t,i,o[i]);let r=Ue(e.cookie);return r&&N(t,"Cookie",r),e.storage&&typeof e.storage=="object"&&N(t,"X-Atkonoffice-Storage",JSON.stringify(e.storage)),t}function nn(e){let t=e&&e.openParams?e.openParams.backend:null;return typeof t=="string"&&t?re(t):""}function on(e){if(!e||typeof e!="object")return null;let t={};return typeof e.width=="number"&&(t.width=e.width),typeof e.height=="number"&&(t.height=e.height),typeof e.modal=="boolean"&&(t.modal=e.modal),Object.keys(t).length>0?t:null}var d={};var nt="atkonoffice-doc-host",he="__atkonofficeDocHostEvent",ge=["documentSaved","documentOpened","documentBeforeSave","error","controlReady","compareDiff","documentReady","documentFailed"],ye="doc.ready",_e="doc.embedFailed",we="doc.opened",$={"doc.saved":"documentSaved",[we]:"documentOpened","doc.beforeSave":"documentBeforeSave","compare.diff":"compareDiff",[ye]:"documentReady",[_e]:"documentFailed"},ot="controlReady",rt="toolbarClick",it="readbackResult",at="messageBoxResult",s={eventHandlers:{},hintShown:!1,toolbarButtons:{},toolbarSeq:0,readbackPending:{},readbackSeq:0,messageBoxPending:{},messageBoxSeq:0,docTerminal:null};function st(e,t,o){if(typeof e!="string")throw new TypeError("atkonoffice embed.addCustomToolButton: caption must be a string");if(typeof o!="function")throw new TypeError("atkonoffice embed.addCustomToolButton: onClick must be a function");if(typeof window>"u")return null;_();let r=typeof t=="number"&&isFinite(t)?Math.trunc(t):0,i="btn-"+ ++s.toolbarSeq;return s.toolbarButtons[i]=o,E("toolbarAdd",JSON.stringify({buttonId:i,caption:e,iconIndex:r}))?{remove:function(){delete s.toolbarButtons[i],E("toolbarRemove",JSON.stringify({buttonId:i}))}}:(delete s.toolbarButtons[i],dt(),null)}function ct(e){if(typeof e!="boolean")throw new TypeError("atkonoffice embed.setCustomToolbarVisible: visible must be a boolean");return typeof window>"u"?d:(_(),E("toolbarSetVisible",JSON.stringify({visible:e})),d)}function ft(e){let t=e&&e.buttonId;if(typeof t!="string"||!t)return;let o=s.toolbarButtons[t];if(typeof o=="function")try{o()}catch(r){pt("addCustomToolButton onClick threw: "+(r&&r.message?r.message:r))}}function Q(){if(typeof window>"u")return null;let e=window.atkonofficeCtrl=window.atkonofficeCtrl||{};return typeof e.save!="function"&&(e.save=function(t){let o=t&&typeof t=="object"?JSON.stringify(t):void 0;return typeof e._WebSave=="function"?e._WebSave(o):E("save",o)}),typeof e.exec!="function"&&(e.exec=function(t){return typeof t!="string"||!t?!1:E("executeJs",t)}),typeof e.setSavePath!="function"&&(e.setSavePath=function(t){return typeof t!="string"||!t?!1:E("setSavePath",t)}),e}function lt(e){let t=Q();return t&&typeof t.save=="function"?t.save(e):!1}function ut(e){let t=Q();return t&&typeof t.setSavePath=="function"?t.setSavePath(e):!1}function E(e,t){if(typeof window>"u")return!1;let o=window.__atkonofficeDocHost;return o&&typeof o.sendCommand=="function"?(t!=null?o.sendCommand(e,t):o.sendCommand(e),!0):!1}var rn=15e3;function x(e,t){if(typeof window>"u")return Promise.resolve({ok:!1,error:"non-browser"});_();let o=++s.readbackSeq,r=JSON.stringify({rid:o,method:e,args:Array.isArray(t)?t:[]});return new Promise(i=>{let a=setTimeout(function(){Re(o,{ok:!1,error:"timeout"})},rn);a&&typeof a.unref=="function"&&a.unref(),s.readbackPending[o]={resolve:i,timer:a},E("readback",r)||Re(o,{ok:!1,error:"shell-absent"})})}function Re(e,t){let o=s.readbackPending[e];o&&(delete s.readbackPending[e],clearTimeout(o.timer),o.resolve(t))}function mt(e){let t=e&&e.rid;typeof t=="number"&&Re(t,e.ok?{ok:!0,value:e.value,error:void 0}:{ok:!1,value:void 0,error:e.error||"invoke failed"})}var an=6e5;function ht(e){if(typeof window>"u")return Promise.resolve({ok:!1,error:"non-browser"});_();let t=e&&typeof e=="object"?e:{},o=++s.messageBoxSeq,r=JSON.stringify({rid:o,type:t.type,title:t.title,text:t.text,buttons:t.buttons});return new Promise(i=>{let a=setTimeout(function(){Te(o,{ok:!1,error:"timeout"})},an);a&&typeof a.unref=="function"&&a.unref(),s.messageBoxPending[o]={resolve:i,timer:a},E("messageBox",r)||Te(o,{ok:!1,error:"shell-absent"})})}function Te(e,t){let o=s.messageBoxPending[e];o&&(delete s.messageBoxPending[e],clearTimeout(o.timer),o.resolve(t))}function gt(e){let t=e&&e.rid;typeof t=="number"&&Te(t,{ok:!!(e&&e.ok),button:e?e.button:void 0,error:e?e.error:void 0})}function yt(e,t){if(e===we){s.docTerminal=null;return}(e===ye||e===_e)&&(s.docTerminal={event:$[e],payload:t||{}})}function _t(e,t){!s.docTerminal||s.docTerminal.event!==e||typeof setTimeout=="function"&&setTimeout(function(){let o=s.docTerminal;if(!(!o||o.event!==e))try{t(o.payload)}catch{}},0)}function _(){sn(),Q()}function Rt(e,t){if(typeof e!="string"||ge.indexOf(e)===-1)throw new TypeError('atkonoffice embed.on: unknown event "'+e+'" (expected one of '+ge.join(", ")+")");if(typeof t!="function")throw new TypeError("atkonoffice embed.on: handler must be a function");return _(),s.eventHandlers[e]||(s.eventHandlers[e]=[]),s.eventHandlers[e].push(t),_t(e,t),d}function sn(){typeof window>"u"||typeof window[he]=="function"||(window[he]=function(e,t){if(e===ot){wt("controlReady",t||{});return}if(e===rt){ft(t||{});return}if(e===it){mt(t||{});return}if(e===at){gt(t||{});return}yt(e,t||{});let o=$[e];o&&wt(o,t||{})})}function wt(e,t){let o=s.eventHandlers[e];if(!o||o.length===0){if(e==="error")try{console.error("[atkonoffice embed] "+(t&&t.message?t.message:t))}catch{}return}for(let r of o.slice())try{r(t)}catch{}}function dt(){if(!s.hintShown){s.hintShown=!0;try{console.info("[atkonoffice embed] <"+nt+"> \u672A\u88AB\u5B9A\u4E49 \u2014\u2014 \u8BF7\u5728\u5DF2\u5B89\u88C5 atkonoffice \u5BA2\u6237\u7AEF\u7684\u58F3\u5185\u6253\u5F00\u672C\u7F16\u8F91\u9875;\u666E\u901A\u6D4F\u89C8\u5668\u91CC\u5B83\u662F\u7A7A\u76D2(\u4E0D\u5F71\u54CD\u9875\u9762\u5176\u4F59\u90E8\u5206)\u3002")}catch{}}}function pt(e){try{console.warn("[atkonoffice embed] "+e)}catch{}}function Tt(e){if(typeof e!="function")throw new TypeError("atkonoffice embed.onBeforeSave: fn must be a function");return _(),bt("onBeforeSave",e),d}function Et(e){if(typeof e!="function")throw new TypeError("atkonoffice embed.onBeforeClose: fn must be a function");return _(),bt("onBeforeClose",e),d}function bt(e,t){if(typeof window>"u")return!1;let o=window.__atkonofficeDocHost;return o&&typeof o[e]=="function"?(o[e](t),!0):!1}var xt="AO_";function D(e){return!!(e&&e.ok&&Number(e.value)>0)}function w(){return Promise.resolve({ok:!1,error:"bad-args"})}function kt(e){return typeof e=="string"?e:e==null?"":String(e)}function Ot(e){if(!e||!e.ok)return{ok:!1,error:e&&e.error||"invoke failed"};let t;try{t=JSON.parse(e.value)}catch{t=null}return Array.isArray(t)?{ok:!0,value:t}:{ok:!1,error:"bad-value"}}function St(e,t){return Ee(e,t).then(D)}function Ee(e,t){if(typeof e!="string"||!e)return w();let o=typeof t=="string"?t:t==null?"":String(t),r={};return r[e]=o,x("Word_FillDataRegion",[JSON.stringify(r)])}function Ct(e,t){return be(e,t).then(D)}function be(e,t){if(typeof e!="string"||!e)return w();let o=kt(t);return o?x("Word_AddDataRegion",[e,o]):w()}function Pt(e){return xe(e).then(D)}function xe(e){return typeof e!="string"||!e?w():x("Word_DeleteDataRegion",[e])}function It(e){return ke(e).then(D)}function ke(e){return typeof e!="string"||!e?w():x("Word_LocateDataRegion",[e])}function vt(e){return Oe(e).then(function(t){return t.ok?t.value:[]})}function Oe(e){let t=typeof e=="string"?e:xt;return x("BookmarksAsJson",[]).then(function(o){let r=Ot(o);return r.ok?{ok:!0,value:r.value.filter(function(i){return typeof i=="string"&&(t===""||i.indexOf(t)===0)})}:r})}function Nt(e){return Se(e).then(function(t){return t.ok?t.value:[]})}function Se(e){let t=typeof e=="string"?e:xt;return x("Word_GetDataRegionValues",[]).then(function(o){let r=Ot(o);return r.ok?{ok:!0,value:r.value.filter(function(i){return!!i&&typeof i=="object"&&typeof i.name=="string"&&(t===""||i.name.indexOf(t)===0)})}:r})}function At(e,t){return Ce(e,t).then(D)}function Ce(e,t){if(typeof e!="string"||!e)return w();let o=kt(t);return o?x("Word_SetDataRegionPlaceholder",[e,o]):w()}function Dt(e,t){return Pe(e,t).then(D)}function Pe(e,t){if(typeof e!="string"||!e||!t||typeof t!="object"||Array.isArray(t))return w();let o={};for(let r of["contents","control"])if(t[r]!==void 0){if(typeof t[r]!="boolean")return w();o[r]=t[r]}return Object.keys(o).length?x("Word_SetDataRegionLock",[e,JSON.stringify(o)]):w()}d.on=Rt;d.addCustomToolButton=st;d.setCustomToolbarVisible=ct;d.save=lt;d.setSavePath=ut;d.showMessageBox=ht;d.onBeforeSave=Tt;d.onBeforeClose=Et;d.word={fillDataRegion:St,addDataRegion:Ct,deleteDataRegion:Pt,locateDataRegion:It,listDataRegions:vt,getDataRegionValues:Nt,setDataRegionPlaceholder:At,setDataRegionLock:Dt,receipt:{fillDataRegion:Ee,addDataRegion:be,deleteDataRegion:xe,locateDataRegion:ke,listDataRegions:Oe,getDataRegionValues:Se,setDataRegionPlaceholder:Ce,setDataRegionLock:Pe}};R.config=tt;R.open=me;R.on=Ze;R.session=d;var cn=R,Vo=cn;export{cn as atkonoffice,Vo as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atkonoffice/sdk",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "Browser-side SDK for the atkonoffice editor shell",
5
5
  "homepage": "https://atkon.yunhuichongming.cn",
6
6
  "type": "module",