@docx-editor.dev/editor-api 2.19.0 → 2.20.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.
package/README.md CHANGED
@@ -152,6 +152,18 @@ require the Pro review module and an editable document. Handle errors by `code`.
152
152
  See [Comments](https://www.docx-editor.dev/docs/2.x/editor-api/comments) and
153
153
  [Tracked changes](https://www.docx-editor.dev/docs/2.x/editor-api/revisions) for supported operations.
154
154
 
155
+ ## Resolve revisions in a batch
156
+
157
+ Use `RevisionCollection.resolve('accept')` or `resolve('reject')` to process supported
158
+ changes in one story. To select changes, pass revision objects as the second argument.
159
+ API batches don't inherit editor filters. Read `result.value` after `context.sync()`
160
+ for resolved and skipped decisions and the remaining count.
161
+
162
+ To require every change in the story to resolve, use `acceptAll()` or `rejectAll()`.
163
+ These methods fail if any revision is unsupported. See
164
+ [Resolve a batch of changes](https://www.docx-editor.dev/docs/2.x/editor-api/revisions#resolve-a-batch-of-changes)
165
+ for examples and result handling.
166
+
155
167
  ## Range snapshots
156
168
 
157
169
  Ranges retain the paragraph offsets where they were found.
@@ -21,11 +21,11 @@
21
21
  * @packageDocumentation
22
22
  * @public
23
23
  */
24
- import { ab as RevisionTextView, G as DocxEditorRuntime, C as CreateServerOptions, D as DocxEditorServerRuntime, a as CreateCollaborativeOptions } from './server-wsxDd90b.mjs';
25
- export { A as Alignment, B as BesideLocation, b as Body, c as BodyInsertParagraphLocation, d as BodyInsertTextLocation, e as Bookmark, f as BookmarkCollection, g as BreakType, h as ChangeTrackingMode, i as ClientObject, j as ClientResult, k as Comment, l as CommentCollection, m as CommentReply, n as CommentReplyCollection, o as ContentControl, p as ContentControlCollection, q as ContentControlLockState, r as ContentControlSubtype, s as ContentControlType, t as ContentControlValue, u as Document, v as DocumentCapabilities, w as DocumentLimits, x as DocumentXmlLimits, y as DocumentZipLimits, z as DocxEditorError, E as DocxEditorErrorCode, F as DocxEditorErrorInit, H as EditorModule, I as Field, J as FieldCollection, K as FieldType, L as FieldTypeLiteral, M as Font, N as HeaderFooterType, O as InlinePicture, P as InlinePictureCollection, Q as InsertLocation, R as List, S as ListBullet, T as ListCollection, U as ListItem, V as ListNumbering, W as LoadOption, X as LoadQueryOptions, Y as NoteItem, Z as NoteItemCollection, _ as NoteItemType, $ as PageOrientation, a0 as PageSetup, a1 as Paragraph, a2 as ParagraphAlignment, a3 as ParagraphCollection, a4 as ParagraphInsertTextLocation, a5 as Range, a6 as RangeCollection, a7 as RangeInsertTextLocation, a8 as RequestContext, a9 as Revision, aa as RevisionCollection, ac as RevisionType, ad as RunCallback, ae as SearchOptions, af as Section, ag as SectionCollection, ah as SelectionMode, ai as ServerPaginationOptions, aj as Table, ak as TableCell, al as TableCellCollection, am as TableCollection, an as TableRow, ao as TableRowCollection, ap as TrackedObjects, aq as UnderlineType, ar as VerticalAlignment, as as isDocxEditorError } from './server-wsxDd90b.mjs';
24
+ import { ab as RevisionTextView, G as DocxEditorRuntime, C as CreateServerOptions, D as DocxEditorServerRuntime, a as CreateCollaborativeOptions } from './server-mLIW1Y6U.mjs';
25
+ export { A as Alignment, B as BesideLocation, b as Body, c as BodyInsertParagraphLocation, d as BodyInsertTextLocation, e as Bookmark, f as BookmarkCollection, g as BreakType, h as ChangeTrackingMode, i as ClientObject, j as ClientResult, k as Comment, l as CommentCollection, m as CommentReply, n as CommentReplyCollection, o as ContentControl, p as ContentControlCollection, q as ContentControlLockState, r as ContentControlSubtype, s as ContentControlType, t as ContentControlValue, u as Document, v as DocumentCapabilities, w as DocumentLimits, x as DocumentXmlLimits, y as DocumentZipLimits, z as DocxEditorError, E as DocxEditorErrorCode, F as DocxEditorErrorInit, H as EditorModule, I as Field, J as FieldCollection, K as FieldType, L as FieldTypeLiteral, M as Font, N as HeaderFooterType, O as InlinePicture, P as InlinePictureCollection, Q as InsertLocation, R as List, S as ListBullet, T as ListCollection, U as ListItem, V as ListNumbering, W as LoadOption, X as LoadQueryOptions, Y as NoteItem, Z as NoteItemCollection, _ as NoteItemType, $ as PageOrientation, a0 as PageSetup, a1 as Paragraph, a2 as ParagraphAlignment, a3 as ParagraphCollection, a4 as ParagraphInsertTextLocation, a5 as Range, a6 as RangeCollection, a7 as RangeInsertTextLocation, a8 as RequestContext, a9 as Revision, aa as RevisionCollection, ac as RevisionType, ad as RunCallback, ae as SearchOptions, af as Section, ag as SectionCollection, ah as SelectionMode, ai as ServerPaginationOptions, aj as Table, ak as TableCell, al as TableCellCollection, am as TableCollection, an as TableRow, ao as TableRowCollection, ap as TrackedObjects, aq as UnderlineType, ar as VerticalAlignment, as as isDocxEditorError } from './server-mLIW1Y6U.mjs';
26
26
  import { EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
27
27
  import { DocxEditorInstance } from '@docx-editor.dev/core/editor';
28
- import '@docx-editor.dev/core/automation';
28
+ export { RevisionBatchEntry, RevisionBatchResult, RevisionBatchSkipReason } from '@docx-editor.dev/core/automation';
29
29
 
30
30
  /**
31
31
  * How `DocxEditor.createBrowser` borrows a live editor.
package/dist/browser.d.ts CHANGED
@@ -21,11 +21,11 @@
21
21
  * @packageDocumentation
22
22
  * @public
23
23
  */
24
- import { ab as RevisionTextView, G as DocxEditorRuntime, C as CreateServerOptions, D as DocxEditorServerRuntime, a as CreateCollaborativeOptions } from './server-wsxDd90b.js';
25
- export { A as Alignment, B as BesideLocation, b as Body, c as BodyInsertParagraphLocation, d as BodyInsertTextLocation, e as Bookmark, f as BookmarkCollection, g as BreakType, h as ChangeTrackingMode, i as ClientObject, j as ClientResult, k as Comment, l as CommentCollection, m as CommentReply, n as CommentReplyCollection, o as ContentControl, p as ContentControlCollection, q as ContentControlLockState, r as ContentControlSubtype, s as ContentControlType, t as ContentControlValue, u as Document, v as DocumentCapabilities, w as DocumentLimits, x as DocumentXmlLimits, y as DocumentZipLimits, z as DocxEditorError, E as DocxEditorErrorCode, F as DocxEditorErrorInit, H as EditorModule, I as Field, J as FieldCollection, K as FieldType, L as FieldTypeLiteral, M as Font, N as HeaderFooterType, O as InlinePicture, P as InlinePictureCollection, Q as InsertLocation, R as List, S as ListBullet, T as ListCollection, U as ListItem, V as ListNumbering, W as LoadOption, X as LoadQueryOptions, Y as NoteItem, Z as NoteItemCollection, _ as NoteItemType, $ as PageOrientation, a0 as PageSetup, a1 as Paragraph, a2 as ParagraphAlignment, a3 as ParagraphCollection, a4 as ParagraphInsertTextLocation, a5 as Range, a6 as RangeCollection, a7 as RangeInsertTextLocation, a8 as RequestContext, a9 as Revision, aa as RevisionCollection, ac as RevisionType, ad as RunCallback, ae as SearchOptions, af as Section, ag as SectionCollection, ah as SelectionMode, ai as ServerPaginationOptions, aj as Table, ak as TableCell, al as TableCellCollection, am as TableCollection, an as TableRow, ao as TableRowCollection, ap as TrackedObjects, aq as UnderlineType, ar as VerticalAlignment, as as isDocxEditorError } from './server-wsxDd90b.js';
24
+ import { ab as RevisionTextView, G as DocxEditorRuntime, C as CreateServerOptions, D as DocxEditorServerRuntime, a as CreateCollaborativeOptions } from './server-mLIW1Y6U.js';
25
+ export { A as Alignment, B as BesideLocation, b as Body, c as BodyInsertParagraphLocation, d as BodyInsertTextLocation, e as Bookmark, f as BookmarkCollection, g as BreakType, h as ChangeTrackingMode, i as ClientObject, j as ClientResult, k as Comment, l as CommentCollection, m as CommentReply, n as CommentReplyCollection, o as ContentControl, p as ContentControlCollection, q as ContentControlLockState, r as ContentControlSubtype, s as ContentControlType, t as ContentControlValue, u as Document, v as DocumentCapabilities, w as DocumentLimits, x as DocumentXmlLimits, y as DocumentZipLimits, z as DocxEditorError, E as DocxEditorErrorCode, F as DocxEditorErrorInit, H as EditorModule, I as Field, J as FieldCollection, K as FieldType, L as FieldTypeLiteral, M as Font, N as HeaderFooterType, O as InlinePicture, P as InlinePictureCollection, Q as InsertLocation, R as List, S as ListBullet, T as ListCollection, U as ListItem, V as ListNumbering, W as LoadOption, X as LoadQueryOptions, Y as NoteItem, Z as NoteItemCollection, _ as NoteItemType, $ as PageOrientation, a0 as PageSetup, a1 as Paragraph, a2 as ParagraphAlignment, a3 as ParagraphCollection, a4 as ParagraphInsertTextLocation, a5 as Range, a6 as RangeCollection, a7 as RangeInsertTextLocation, a8 as RequestContext, a9 as Revision, aa as RevisionCollection, ac as RevisionType, ad as RunCallback, ae as SearchOptions, af as Section, ag as SectionCollection, ah as SelectionMode, ai as ServerPaginationOptions, aj as Table, ak as TableCell, al as TableCellCollection, am as TableCollection, an as TableRow, ao as TableRowCollection, ap as TrackedObjects, aq as UnderlineType, ar as VerticalAlignment, as as isDocxEditorError } from './server-mLIW1Y6U.js';
26
26
  import { EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
27
27
  import { DocxEditorInstance } from '@docx-editor.dev/core/editor';
28
- import '@docx-editor.dev/core/automation';
28
+ export { RevisionBatchEntry, RevisionBatchResult, RevisionBatchSkipReason } from '@docx-editor.dev/core/automation';
29
29
 
30
30
  /**
31
31
  * How `DocxEditor.createBrowser` borrows a live editor.
package/dist/browser.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var editor=require('@docx-editor.dev/core/editor'),automation=require('@docx-editor.dev/core/automation');var le=Object.freeze({PropertyNotLoaded:"the property has not been loaded. Call load(...) and await context.sync() before reading it.",ValueNotLoaded:"the result has not been filled in yet. Await context.sync() before reading it.",InvalidObjectPath:"the object cannot be addressed. Await context.sync() after creating an object with an edit. Keep proxies within their run, or use context.trackedObjects.add(...) before the run ends.",ObjectInUse:"the object still belongs to a run that has not finished. Await that run before passing the object to another one.",InvalidArgument:"the argument is not one this API accepts.",ResourceLimitExceeded:"the document exceeds a supported resource limit.",ItemNotFound:"the collection has no such item.",NotSupported:"the operation or argument is outside this document or host\u2019s supported capabilities.",NotImplemented:"this version does not implement that yet.",ConflictingChanges:"these operations cannot share one atomic batch. Split them across separate context.sync() calls.",InvalidRequestContext:"the request context has finished. Start another run to continue.",RuntimeDisposed:"the runtime has been disposed.",StaleDocument:"the document changed after this context read it, so nothing was applied.",DocumentUnavailable:"the document is not available right now.",GeneralException:"the document could not complete the request."}),C=class extends Error{code;limit;target;expectedRevision;actualRevision;constructor(t){let e=t.target?`${le[t.code]} (${t.target})`:le[t.code];super(e),this.name="DocxEditorError",this.code=t.code,t.limit!==void 0&&(this.limit=t.limit),t.target!==void 0&&(this.target=t.target),t.expectedRevision!==void 0&&(this.expectedRevision=t.expectedRevision),t.actualRevision!==void 0&&(this.actualRevision=t.actualRevision);}};function Se(o){return o instanceof C?true:typeof o=="object"&&o!==null&&o.name==="DocxEditorError"&&typeof o.code=="string"}function a(o){throw new C(o)}var Y=Symbol("docx-editor.runtime.internals"),St=Symbol("docx-editor.runtime.release"),jt=Symbol("docx-editor.runtime.rebind");function J(o){return o[Y]}var je=new Set(["select","expand","top","skip"]),Te=/^[A-Za-z][A-Za-z0-9]*$/;function ce(o,t){if(o===void 0)return [];let e=typeof o=="string"?o.split(",").map(r=>r.trim()):Array.isArray(o)?o.map(r=>typeof r=="string"?r.trim():r):a({code:"InvalidArgument",target:t}),n=[];for(let r of e)(typeof r!="string"||!Te.test(r))&&a({code:"InvalidArgument",target:t}),n.includes(r)||n.push(r);return n.length===0&&a({code:"InvalidArgument",target:t}),n}function he(o,t){return (typeof o!="number"||!Number.isInteger(o)||o<0)&&a({code:"InvalidArgument",target:t}),o}function Ee(o,t){o===void 0||Array.isArray(o)&&o.length===0||a({code:"InvalidArgument",target:t});}function pe(o,t){if(o===void 0)return {select:[]};if(typeof o=="string"||Array.isArray(o))return {select:ce(o,t)};(typeof o!="object"||o===null)&&a({code:"InvalidArgument",target:t});let e=o;for(let n of Object.keys(e))je.has(n)||a({code:"InvalidArgument",target:`${t}.${n}`});return Ee(e.expand,`${t}.expand`),{select:ce(e.select,`${t}.select`),...e.top===void 0?{}:{top:he(e.top,`${t}.top`)},...e.skip===void 0?{}:{skip:he(e.skip,`${t}.skip`)}}}var B=class{#t;#n;#e;#o;#i=new Map;#s=false;constructor(t,e,n={}){this.#t=t,this.#n=t[Y],this.#e=e,this.#o=n.nullable===true,this.#n.register(this);}get context(){return this.#t}get isNullObject(){return this.#e.isReleased&&a({code:"InvalidObjectPath",target:this.#e.label}),this.#o?(this.#e.isPending&&a({code:"PropertyNotLoaded",target:`${this.#e.label}.isNullObject`}),this.#e.isNull):false}load(t){this.#s=true;try{return this.requireUsablePath(),this.onLoad(pe(t,this.#e.label)),this}finally{this.#s=false;}}get path(){return this.#e}get internals(){return this.#n}handle(){return this.#e.handle()}requireAddressable(){this.#e.isAddressable||a({code:"InvalidObjectPath",target:this.#e.label}),this.#n.assertUsable(this.#e.label);}requireUsablePath(){(this.#e.isReleased||this.#e.isNull&&!(this.#s&&this.#o))&&a({code:"InvalidObjectPath",target:this.#e.label}),this.#n.assertUsable(this.#e.label);}enqueue(t){this.requireUsablePath(),this.#n.queue.push({...t,dependencies:[...t.dependencies??[],this.#e],...this.#s&&this.#o&&t.sort==="read"?{nullableLoad:this.#e}:{}});}loadedProperty(t){return this.#e.isReleased&&!this.#i.has(t)&&a({code:"InvalidObjectPath",target:this.#e.label}),this.#i.has(t)||a({code:"PropertyNotLoaded",target:`${this.#e.label}.${t}`}),this.#i.get(t)}hasLoadedProperty(t){return this.#i.has(t)}setLoadedProperty(t,e){this.#i.set(t,e);}[St](){this.#e.release();}[jt](t){this.#t=t,this.#n=t[Y];}};var Vt=class o{#t=false;#n;#e;constructor(t){this.#e=t;}get value(){return this.#t||a({code:"ValueNotLoaded",target:this.#e}),this.#n}get isLoaded(){return this.#t}static create(t){let e=new o(t);return {result:e,fill(n){e.#t=true,e.#n=n;}}}};function S(o){return new C({code:"GeneralException",target:o})}function O(o,t){if(o.kind!=="text")throw S(t);return o.text}function u(o,t){if(o.kind!=="handle")throw S(t);return o.handle}function v(o,t){if(o.kind!=="handles")throw S(t);return o.handles}function P(o,t){if(o.kind!=="span")throw S(t);return o.span}function Tt(o,t){if(o.kind!=="spans")throw S(t);return o.spans}function Wt(o,t){if(o.kind!=="font")throw S(t);return o.font}function Ut(o,t){if(o.kind!=="paragraphFormat")throw S(t);return o.format}function xt(o,t){if(o.kind!=="style")throw S(t);return o.name}function Et(o,t){if(o.kind!=="number")throw S(t);return o.value}function _(o,t){if(o.kind!=="flag")throw S(t);return o.value}function Gt(o,t){if(o.kind!=="pageSetup")throw S(t);return o.setup}function m(o,t){if(o.kind!=="applied")throw S(t)}var c=class o{label;#t;#n;constructor(t,e,n=null){this.label=t,this.#t=e,this.#n=n;}static of(t,e){return new o(t,{status:"resolved",address:{kind:"handle",handle:e}})}static ofSpan(t,e){return new o(t,{status:"resolved",address:{kind:"span",span:e}})}static pending(t){return new o(t,{status:"pending"})}static derived(t,e){return new o(t,{status:"pending"},e)}get state(){return this.#n?this.#n.state:this.#t}get isAddressable(){return this.state.status==="resolved"}get isPending(){return this.state.status==="pending"}get isNull(){return this.state.status==="null"}get isReleased(){return this.state.status==="released"}address(){let t=this.state;if(t.status==="resolved")return t.address;a({code:"InvalidObjectPath",target:this.label});}handle(){let t=this.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.label}),t.handle}span(){let t=this.address();return t.kind!=="span"&&a({code:"InvalidObjectPath",target:this.label}),t.span}resolveTo(t){this.#e({kind:"handle",handle:t});}resolveToSpan(t){this.#e({kind:"span",span:t});}resolveNull(){this.#t.status!=="released"&&(this.#t={status:"null"});}release(){this.#n||(this.#t={status:"released"});}#e(t){this.#t.status!=="released"&&(this.#t={status:"resolved",address:t});}};function ue(o){let t=[],e=false,n=false;for(let r of o)t.push(r.plan()),r.sort==="write"?n=true:e=true;return {operations:t,hasRead:e,hasWrite:n}}var Ne=Object.freeze({"stale-revision":"StaleDocument","invalid-handle":"InvalidObjectPath","invalid-offset":"InvalidArgument","unsupported-capability":"NotSupported",disposed:"RuntimeDisposed","transaction-refused":"GeneralException","unknown-operation":"NotSupported","unsupported-content":"InvalidArgument","unsupported-revision":"NotImplemented","ambiguous-document":"GeneralException","conflicting-operations":"ConflictingChanges","document-unavailable":"DocumentUnavailable"});function Nt(o,t={}){let e=Ne[o.code]??"GeneralException",n=e==="StaleDocument";return new C({code:e,...t.target===void 0?{}:{target:t.target},...n&&t.expectedRevision!==void 0?{expectedRevision:t.expectedRevision}:{},...n&&t.actualRevision!==void 0?{actualRevision:t.actualRevision}:{}})}function zt(o,t,e){for(let n=0;n<o.results.length;n+=1){let r=o.results[n];if(r?.status!=="error")continue;let i=t[n]?.label;return Nt(r.error,{...i===void 0?{}:{target:i},...e===void 0?{}:{expectedRevision:e},actualRevision:o.revision})}return new C({code:"GeneralException"})}function Qt(o,t){if(t.results.length!==o.length)throw new C({code:"GeneralException"});for(let e=0;e<o.length;e+=1){let n=t.results[e],r=o[e];if(n.status!=="ok")throw new C({code:"GeneralException",target:r.label});r.settle(n.value);}}var Dt=class{#t=[];get size(){return this.#t.length}get pending(){return this.#t}push(t){this.#t.push(t);}take(){let t=this.#t;this.#t=[];for(let e of t)e.capture?.();return t}clear(){for(let t of this.#t)t.dispose?.();this.#t=[];}};function me(o,t){if(Array.isArray(o)){for(let e of o)t(e);return}t(o);}var Ct=class{#t;#n;constructor(t,e){this.#t=t,this.#n=e;}add(t){this.#t.assertUsable(),me(t,e=>{this.#e(e),this.#t.track(e);});}remove(t){this.#t.assertUsable(),me(t,e=>{this.#e(e),this.#t.untrack(e);});}#e(t){this.#n(t)||a({code:"InvalidObjectPath"});}};var At=class o{#t;#n=new Dt;#e=new Set;#o=new Set;#i;#s;#r;#a=false;#l=null;#c=false;constructor(t){this.#t=t,this.#i={host:t.host,capabilities:t.capabilities,...t.author===void 0?{}:{author:t.author},revisionTextView:t.revisionTextView,queue:this.#n,session:t.id,roots:()=>t.roots(),assertUsable:e=>{this.#t.assertLive(e),this.#a&&a({code:"InvalidRequestContext",...e===void 0?{}:{target:e}});},isFinished:()=>this.#a,readRevision:()=>this.#l,register:e=>{this.#e.add(e);},track:e=>{this.#o.add(e);},untrack:e=>{this.#o.delete(e);},isTracked:e=>this.#o.has(e),disown:e=>{this.#e.delete(e),this.#o.delete(e);}},this.#s=new Ct(this.#i,e=>this.#e.has(e));}get document(){return this.#i.assertUsable("document"),this.#r??=this.#t.openDocument(this),this.#r}get capabilities(){return this.#t.capabilities}get trackedObjects(){return this.#s}async sync(){this.#i.assertUsable(),this.#c&&a({code:"InvalidRequestContext"});let t=this.#n.take();if(t.length!==0){this.#c=true;try{let e=t.filter(s=>!s.nullableLoad?.isNull),n=t.some(s=>s.sort==="write"),r,i=s=>s.dependencies?.some(d=>!d.isAddressable)??false;for(;e.some(i);){r??=n&&this.#l!==null?this.#l:this.#t.host.revision();let s=e.filter(h=>h.sort==="read"&&!i(h));s.length===0&&a({code:"InvalidObjectPath",target:e.find(i)?.label}),await this.#d(s,r);let d=new Set(s);e=e.filter(h=>!d.has(h)&&!h.nullableLoad?.isNull);}if(e.length){let s=r??(n&&this.#l!==null?this.#l:void 0);await this.#d(e,s);}}finally{for(let e of t)e.dispose?.();this.#c=false;}}}async#d(t,e){let n=ue(t),r={operations:n.operations,...e===void 0?{}:{expectedRevision:e}};if(this.#t.host.prepare){let s={...r,expectedRevision:r.expectedRevision??this.#t.host.revision()};await this.#t.host.prepare(s);let d=this.#t.host.execute(s);if(!d.ok)throw zt(d,t,s.expectedRevision);Qt(t,d),this.#l=d.revision;return}let i=this.#t.host.execute(r);if(!i.ok)throw zt(i,t,e);Qt(t,i),(n.hasRead||n.hasWrite)&&(this.#l=i.revision);}get[Y](){return this.#i}static begin(t){let e=new o(t);return {context:e,adopt(n){for(let r of n)e.#h(r);},finish(){e.#u();}}}#h(t){let e=t.context;if(e===this)return;let n=e[Y];if(n.session!==this.#t.id)throw new C({code:"InvalidObjectPath"});if(!n.isFinished())throw new C({code:"ObjectInUse"});if(!n.isTracked(t))throw new C({code:"InvalidObjectPath"});let r=n.readRevision();n.disown(t),t[jt](this),this.#e.add(t),this.#o.add(t),r!==null&&this.#p(r);}#p(t){this.#l=this.#l===null?t:Math.min(this.#l,t);}#u(){if(!this.#a){this.#a=true,this.#n.clear();for(let t of this.#e)this.#o.has(t)||t[St]();this.#e.clear();}}};function vt(o,t,e){if(o.select.length===0)return t;for(let n of o.select)t.includes(n)||a({code:"InvalidArgument",target:`${e}.${n}`});return o.select}function R(o,t){let e=o.address();return t==="span"?(e.kind!=="span"&&a({code:"InvalidObjectPath",target:o.label}),{start:e.span.start,end:e.span.end}):(e.kind!=="handle"&&a({code:"InvalidObjectPath",target:o.label}),t==="body"?{body:e.handle}:{paragraph:e.handle})}function it(o,t){return (typeof o!="string"||o.trim().length===0||o.length>255)&&a({code:"InvalidArgument",target:t}),o}var p=class extends B{revisionTextView(){return J(this.context).revisionTextView}loadTextInto(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"read",label:n,plan:e,settle:r=>{this.setLoadedProperty(t,O(r,n));}});}command(t,e,n){let r=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:r,plan:e,settle:i=>m(i,r),...n?{capture:n,dispose:n}:{}});}commandDiscarding(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:n,plan:e,settle:()=>{}});}commandAnswering(t,e,n,r){this.enqueue({sort:"write",label:t,plan:e,settle:n,...r?{capture:r,dispose:r}:{}});}read(t,e,n){this.enqueue({sort:"read",label:t,plan:e,settle:n});}selection(t,e){return vt(t,e,this.path.label)}onLoad(t){this.selection(t,[]);}};var T=class extends B{#t;#n=[];constructor(t,e){super(t,e);}get items(){return this.loadedProperty("items")}fill(t,e){this.setLoadedProperty("items",this.#o(t,e,0,void 0)),this.#t={value:t,label:e};let n=this.#n.splice(0,this.#n.length);for(let r of n)this.#e(r,t);}onLoad(t){vt(t,["items"],this.path.label);let e=this.path.isPending?void 0:this.listing();if(e===null)return;let n=`${this.path.label}.items`,r=t.skip??0,i=t.top;this.enqueue({sort:"read",label:n,plan:()=>{let s=e??this.listing();return s||a({code:"InvalidObjectPath",target:this.path.label}),s},settle:s=>{this.setLoadedProperty("items",this.#o(s,n,r,i));}});}edge(t,e,n){let r=`${this.path.label}.${e}()`,i=this.promised(r,n),s=this.path.isPending?void 0:this.listing();if(s===null){let d={edge:t,target:r,nullable:n,item:i};return this.#t?this.#e(d,this.#t.value):this.#n.push(d),i}return this.enqueue({sort:"read",label:r,plan:()=>{let d=s??this.listing();return d||a({code:"InvalidObjectPath",target:this.path.label}),d},settle:d=>{this.#e({edge:t,target:r,nullable:n,item:i},d);}}),i}#e(t,e){let{edge:n,target:r,nullable:i,item:s}=t,d=this.size(e,r);if(d===0){i||a({code:"ItemNotFound",target:r}),s.hydrateNull();return}let h=this.addressAt(e,r,n==="first"?0:d-1);h||a({code:"ItemNotFound",target:r}),s.hydrateAddress(h);}#o(t,e,n,r){let i=this.size(t,e),s=r===void 0?i:Math.min(i,n+r),d=[];for(let h=n;h<s;h+=1){let A=this.addressAt(t,e,h);A&&d.push(this.itemAt(`${e}[${String(h)}]`,A));}return d}},x=class extends T{size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}};var H=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get code(){return this.loadedProperty("code")}set code(t){if(this.requireUsablePath(),(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:`${this.path.label}.code`}),this.#t){this.#t.code=t;return}let e={code:t};this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setFieldCode",field:this.#e(),code:e.code}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}delete(){this.#n("deleteField");}updateResult(){this.#n("updateFieldResult");}#n(t){this.requireUsablePath(),this.commandAnswering(this.path.label,()=>({op:t,field:this.#e()}),e=>m(e,this.path.label));}onLoad(t){this.selection(t,["code"]).length!==0&&this.read(this.path.label,()=>({op:"getField",field:this.#e()}),e=>{e.kind!=="field"&&a({code:"GeneralException",target:this.path.label}),this.setLoadedProperty("code",e.field.code);});}#e(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},M=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getFields",span:R(this.path,this.#t)}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return H.at(this.context,t,e)}promised(t,e){return H.promised(this.context,t,e)}};var De=["width","height","lockAspectRatio","altTextDescription"],F=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get width(){return this.loadedProperty("width")}set width(t){this.#n("width",t);}get height(){return this.loadedProperty("height")}set height(t){this.#n("height",t);}get lockAspectRatio(){return this.loadedProperty("lockAspectRatio")}set lockAspectRatio(t){typeof t!="boolean"&&a({code:"InvalidArgument",target:`${this.path.label}.lockAspectRatio`}),this.#e({lockAspectRatio:t});}get altTextDescription(){return this.loadedProperty("altTextDescription")}set altTextDescription(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.altTextDescription`}),this.#e({altTextDescription:t});}delete(){let t=`${this.path.label}.delete`;this.commandAnswering(t,()=>({op:"deleteInlinePicture",picture:this.#o()}),e=>m(e,t));}onLoad(t){let e=this.selection(t,De);e.length&&this.read(this.path.label,()=>({op:"getInlinePicture",picture:this.#o()}),n=>{n.kind!=="inlinePicture"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.picture[r]);});}#n(t,e){(typeof e!="number"||!Number.isFinite(e)||e<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#e({[t]:e});}#e(t){if(this.requireUsablePath(),this.#t){Object.assign(this.#t,t);return}let e=t;this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setInlinePicture",picture:this.#o(),properties:e}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}#o(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},V=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getInlinePictures",span:R(this.path,this.#t)}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return F.at(this.context,t,e)}promised(t,e){return F.promised(this.context,t,e)}};function D(o,t,e=0){return (!Number.isInteger(o)||o<e)&&a({code:"InvalidArgument",target:t}),o}function Xt(o,t){return (!Array.isArray(o)||o.some(e=>!Array.isArray(e)||e.some(n=>typeof n!="string")))&&a({code:"InvalidArgument",target:t}),o.map(e=>[...e])}function ge(o,t){return o!=="Start"&&o!=="End"&&a({code:"InvalidArgument",target:t}),o==="Start"?"start":"end"}var W=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get values(){return this.loadedProperty("values")}set values(t){let e=Xt(t,`${this.path.label}.values`);this.command("values",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"values",values:e}}));}get style(){return this.loadedProperty("style")}set style(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.style`}),this.command("style",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"properties",styleId:t}}));}get headerRowCount(){return this.loadedProperty("headerRowCount")}set headerRowCount(t){D(t,`${this.path.label}.headerRowCount`),this.command("headerRowCount",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"properties",headerRowCount:t}}));}get rowCount(){return this.loadedProperty("rowCount")}get columnCount(){return this.loadedProperty("columnCount")}get rows(){return this.#t??=st.of(this.context,`${this.path.label}.rows`,this.path,()=>({op:"getTableRows",table:this.path.handle()}))}getCell(t,e){let n=`${this.path.label}.getCell`;D(t,n),D(e,n);let r=tt.promised(this.context,n);return this.read(n,()=>({op:"getTableCell",table:this.path.handle(),rowIndex:t,cellIndex:e}),i=>r.hydrateAddress({kind:"handle",handle:u(i,n)})),r}addRows(t,e,n){let r=`${this.path.label}.addRows`,i=ge(t,r);D(e,r,1);let s=n===void 0?void 0:Xt(n,r),d=st.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addRows",location:i,count:e,...s?{values:s}:{}}}),h=>d.fill(h,r)),d}addColumns(t,e,n){let r=`${this.path.label}.addColumns`,i=ge(t,r);D(e,r,1);let s=n===void 0?void 0:Xt(n,r);this.command("addColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addColumns",location:i,count:e,...s?{values:s}:{}}}));}deleteRows(t,e){e===void 0&&(e=1),D(t,this.path.label),D(e,this.path.label,1),this.command("deleteRows",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"deleteRows",index:t,count:e}}));}deleteColumns(t,e){e===void 0&&(e=1),D(t,this.path.label),D(e,this.path.label,1),this.command("deleteColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"deleteColumns",index:t,count:e}}));}delete(){this.command("delete",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"delete"}}));}onLoad(t){let e=this.selection(t,["values","style","headerRowCount","rowCount","columnCount"]);this.read(this.path.label,()=>({op:"getTable",table:this.path.handle()}),n=>{n.kind!=="table"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.table[r]);});}},at=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get cells(){return this.#t??=Pt.of(this.context,`${this.path.label}.cells`,this.path,()=>({op:"getTableCells",row:this.path.handle()}))}},tt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=I.promisedStory(this.context,t);return this.read(t,()=>({op:"getTableCellBody",cell:this.path.handle()}),n=>e.hydrateAddress({kind:"handle",handle:u(n,t)})),this.#t=e,e}get value(){return this.loadedProperty("value")}set value(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.value`}),this.command("value",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{value:t}}));}get columnWidth(){return this.loadedProperty("columnWidth")}set columnWidth(t){(typeof t!="number"||!Number.isFinite(t)||t<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.columnWidth`}),this.command("columnWidth",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{columnWidth:t}}));}get shadingColor(){return this.loadedProperty("shadingColor")}set shadingColor(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.shadingColor`}),this.command("shadingColor",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{shadingColor:t}}));}get verticalAlignment(){return this.loadedProperty("verticalAlignment")}set verticalAlignment(t){t!=="Top"&&t!=="Center"&&t!=="Bottom"&&a({code:"InvalidArgument",target:`${this.path.label}.verticalAlignment`}),this.command("verticalAlignment",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{verticalAlignment:t}}));}onLoad(t){let e=this.selection(t,["value","columnWidth","shadingColor","verticalAlignment"]);this.read(this.path.label,()=>({op:"getTableCellProperties",cell:this.path.handle()}),n=>{n.kind!=="tableCell"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.cell[r]);});}},U=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}static over(t,e,n,r){return o.of(t,e,n,()=>({op:"getTables",scope:r()}))}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return W.at(this.context,t,e)}promised(t,e){return W.promised(this.context,t,e)}},st=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return at.at(this.context,t,e)}promised(t,e){return at.promised(this.context,t,e)}},Pt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return tt.at(this.context,t,e)}promised(t,e){return tt.promised(this.context,t,e)}};var Kt=(i=>(i.replace="Replace",i.start="Start",i.end="End",i.before="Before",i.after="After",i))(Kt||{}),Zt=(s=>(s.mixed="Mixed",s.unknown="Unknown",s.left="Left",s.centered="Centered",s.right="Right",s.justified="Justified",s))(Zt||{}),Yt=(e=>(e.portrait="Portrait",e.landscape="Landscape",e))(Yt||{}),Jt=(n=>(n.off="Off",n.trackAll="TrackAll",n.trackMineOnly="TrackMineOnly",n))(Jt||{}),_t=(r=>(r.mixed="Mixed",r.top="Top",r.center="Center",r.bottom="Bottom",r))(_t||{}),te=(d=>(d.line="Line",d.page="Page",d.next="Next",d.sectionNext="SectionNext",d.sectionContinuous="SectionContinuous",d.sectionEven="SectionEven",d.sectionOdd="SectionOdd",d))(te||{}),ee=(y=>(y.unknown="Unknown",y.richText="RichText",y.plainText="PlainText",y.picture="Picture",y.buildingBlockGallery="BuildingBlockGallery",y.checkBox="CheckBox",y.comboBox="ComboBox",y.datePicker="DatePicker",y.dropDownList="DropDownList",y.group="Group",y.repeatingSection="RepeatingSection",y.plainTextInline="PlainTextInline",y.plainTextParagraph="PlainTextParagraph",y.richTextInline="RichTextInline",y.richTextParagraphs="RichTextParagraphs",y.richTextTable="RichTextTable",y.richTextTableCell="RichTextTableCell",y.richTextTableRow="RichTextTableRow",y))(ee||{});var qe=["Replace","Start","End"],$e=["Start","End"],Be=["Replace","Start","End"],He=["Before","After"],Me=["Replace","Start","End","Before","After"],Fe=["Select","Start","End"];function dt(o,t,e){return (typeof o!="string"||!t.includes(o))&&a({code:"InvalidArgument",target:e}),o}var fe=(o,t)=>dt(o,qe,t),be=(o,t)=>dt(o,$e,t),ye=(o,t)=>dt(o,Be,t),xe=(o,t)=>dt(o,He,t),Ot=(o,t)=>dt(o,Me,t),qt=(o,t)=>o===void 0?"Select":dt(o,Fe,t);function k(o,t){return typeof o!="string"&&a({code:"InvalidArgument",target:t}),/[\r\n\v\f\u2028\u2029]/.test(o)&&a({code:"InvalidArgument",target:t}),o}var Ve=8,oe=(d=>(d.custom="Custom",d.solid="Solid",d.hollow="Hollow",d.square="Square",d.diamonds="Diamonds",d.arrow="Arrow",d.checkmark="Checkmark",d))(oe||{}),re=(s=>(s.none="None",s.arabic="Arabic",s.upperRoman="UpperRoman",s.lowerRoman="LowerRoman",s.upperLetter="UpperLetter",s.lowerLetter="LowerLetter",s))(re||{}),j=class o extends p{#t;#n=new Map;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get paragraphs(){return this.#t??=L.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getListParagraphs",list:this.#o()})),this.#t}getLevelParagraphs(t){let e=`${this.path.label}.getLevelParagraphs`,n=ne(t,e);return L.overListing(this.context,e,this.path,()=>({op:"getListParagraphs",list:this.#o(),level:n}))}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n);e!=="Start"&&e!=="End"&&e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:n});let i=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertListParagraph",list:this.#o(),where:e==="Start"||e==="Before"?"start":"end",text:r}),s=>{i.hydrateAddress({kind:"handle",handle:u(s,n)});}),i}setLevelBullet(t,e,n,r){this.#e(t,{bullet:e,...n===void 0?{}:{charCode:n},...r===void 0?{}:{fontName:r}});}setLevelNumbering(t,e,n){this.#e(t,{numbering:e,...n===void 0?{}:{formatString:[...n]}});}setLevelStartingNumber(t,e){this.#e(t,{startingNumber:e});}setLevelIndents(t,e,n){this.#e(t,{textIndent:e,bulletNumberPictureIndent:n});}#e(t,e){let n=`${this.path.label}.levelFormat`,r=ne(t,n);this.requireUsablePath();let i=this.#n.get(r);if(i){Object.assign(i,e),"bullet"in e&&(delete i.numbering,delete i.formatString),"numbering"in e&&(delete i.bullet,delete i.charCode,delete i.fontName);return}let s={...e};this.#n.set(r,s),this.commandAnswering(n,()=>({op:"setListLevelFormat",list:this.#o(),level:r,format:s}),d=>{m(d,n);},()=>{this.#n.get(r)===s&&this.#n.delete(r);});}onLoad(t){if(!this.selection(t,["id"]).includes("id"))return;let e=`${this.path.label}.id`;this.read(e,()=>({op:"getListId",list:this.#o()}),n=>{this.setLoadedProperty("id",Et(n,e));});}#o(){return this.requireAddressable(),this.path.handle()}},lt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getById(t){let e=`${this.path.label}.getById`,n=We(t,e),r=this.#t,i=j.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getListById",body:r,id:n}),settle:s=>{i.hydrateAddress({kind:"handle",handle:u(s,e)});}}),i}listing(){return {op:"getLists",body:this.#t}}itemAt(t,e){return j.at(this.context,t,e)}promised(t,e){return j.promised(this.context,t,e)}},ct=class o extends p{static of(t,e,n){return new o(t,c.derived(e,n))}constructor(t,e){super(t,e);}get level(){return this.loadedProperty("level")}set level(t){let e=`${this.path.label}.level`,n=ne(t,e);this.commandAnswering(e,()=>({op:"setListLevel",paragraph:this.#t(),level:n}),r=>{m(r,e);});}onLoad(t){if(!this.selection(t,["level"]).includes("level"))return;let e=`${this.path.label}.level`;this.read(e,()=>({op:"getListLevel",paragraph:this.#t()}),n=>{this.setLoadedProperty("level",Et(n,e));});}#t(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}};function ne(o,t){return (!Number.isInteger(o)||o<0||o>Ve)&&a({code:"InvalidArgument",target:t}),o}function We(o,t){return (!Number.isInteger(o)||o<=0)&&a({code:"InvalidArgument",target:t}),o}var ie=(f=>(f.mixed="Mixed",f.none="None",f.hidden="Hidden",f.dotLine="DotLine",f.single="Single",f.word="Word",f.double="Double",f.thick="Thick",f.dotted="Dotted",f.dottedHeavy="DottedHeavy",f.dashLine="DashLine",f.dashLineHeavy="DashLineHeavy",f.dashLineLong="DashLineLong",f.dashLineLongHeavy="DashLineLongHeavy",f.dotDashLine="DotDashLine",f.dotDashLineHeavy="DotDashLineHeavy",f.twoDotDashLine="TwoDotDashLine",f.twoDotDashLineHeavy="TwoDotDashLineHeavy",f.wave="Wave",f.waveHeavy="WaveHeavy",f.waveDouble="WaveDouble",f))(ie||{}),Ue=["bold","italic","color","name","size","underline","strikeThrough","highlightColor","subscript","superscript"],E=class o extends p{#t;#n;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}get bold(){return this.loadedProperty("bold")}set bold(t){this.#e("bold",Rt(t,`${this.path.label}.bold`));}get italic(){return this.loadedProperty("italic")}set italic(t){this.#e("italic",Rt(t,`${this.path.label}.italic`));}get color(){return this.loadedProperty("color")}set color(t){this.#e("color",$t(t,`${this.path.label}.color`));}get name(){return this.loadedProperty("name")}set name(t){this.#e("name",$t(t,`${this.path.label}.name`));}get size(){return this.loadedProperty("size")}set size(t){this.#e("size",Ge(t,`${this.path.label}.size`));}get underline(){return this.loadedProperty("underline")}set underline(t){this.#e("underline",$t(t,`${this.path.label}.underline`));}get highlightColor(){return this.loadedProperty("highlightColor")}set highlightColor(t){this.#e("highlightColor",t===null?null:$t(t,`${this.path.label}.highlightColor`));}get strikeThrough(){return this.loadedProperty("strikeThrough")}set strikeThrough(t){this.#e("strikeThrough",Rt(t,`${this.path.label}.strikeThrough`));}get subscript(){return this.loadedProperty("subscript")}set subscript(t){this.#e("subscript",Rt(t,`${this.path.label}.subscript`));}get superscript(){return this.loadedProperty("superscript")}set superscript(t){this.#e("superscript",Rt(t,`${this.path.label}.superscript`));}onLoad(t){let e=this.selection(t,Ue);if(e.length===0)return;let n=`${this.path.label}.font`;this.read(n,()=>({op:"getFont",span:this.#o()}),r=>{let i=Wt(r,n);for(let s of e)this.setLoadedProperty(s,i[s]);});}#e(t,e){if(this.requireUsablePath(),this.#n){this.#n[t]=e,t==="subscript"&&e===true&&(this.#n.superscript=false),t==="superscript"&&e===true&&(this.#n.subscript=false);return}let n={[t]:e};t==="subscript"&&e===true&&(n.superscript=false),t==="superscript"&&e===true&&(n.subscript=false),this.#n=n;let r=`${this.path.label}.${t}`;this.commandAnswering(this.path.label,()=>({op:"setFont",span:this.#o(),font:n}),i=>{m(i,r);},()=>{this.#n===n&&(this.#n=void 0);});}#o(){return this.requireAddressable(),R(this.path,this.#t)}};function Rt(o,t){return typeof o!="boolean"&&a({code:"InvalidArgument",target:t}),o}function Ge(o,t){return (typeof o!="number"||!Number.isFinite(o))&&a({code:"InvalidArgument",target:t}),o}function $t(o,t){return (typeof o!="string"||o.length===0)&&a({code:"InvalidArgument",target:t}),o}var ze=16,w=class o extends p{#t;#n;#e;#o;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get uniqueLocalId(){return this.loadedProperty("uniqueLocalId")}get style(){return this.loadedProperty("style")}set style(t){this.#i("style",it(t,`${this.path.label}.style`));}get font(){return this.#t??=E.of(this.context,`${this.path.label}.font`,this.path,"paragraph"),this.#t}get alignment(){return this.loadedProperty("alignment")}set alignment(t){this.#i("alignment",Xe(t,`${this.path.label}.alignment`));}get firstLineIndent(){return this.loadedProperty("firstLineIndent")}set firstLineIndent(t){this.#i("firstLineIndent",ht(t,`${this.path.label}.firstLineIndent`));}get leftIndent(){return this.loadedProperty("leftIndent")}set leftIndent(t){this.#i("leftIndent",ht(t,`${this.path.label}.leftIndent`));}get rightIndent(){return this.loadedProperty("rightIndent")}set rightIndent(t){this.#i("rightIndent",ht(t,`${this.path.label}.rightIndent`));}get lineSpacing(){return this.loadedProperty("lineSpacing")}set lineSpacing(t){this.#i("lineSpacing",ht(t,`${this.path.label}.lineSpacing`));}get spaceBefore(){return this.loadedProperty("spaceBefore")}set spaceBefore(t){this.#i("spaceBefore",ht(t,`${this.path.label}.spaceBefore`));}get spaceAfter(){return this.loadedProperty("spaceAfter")}set spaceAfter(t){this.#i("spaceAfter",ht(t,`${this.path.label}.spaceAfter`));}get list(){return this.#n??=this.#s(`${this.path.label}.list`),this.#n}getRange(t="Whole"){let e=`${this.path.label}.getRange`;["Whole","Content","Start","End","Before","After"].includes(t)||a({code:"InvalidArgument",target:e});let n=b.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{paragraph:this.#r()},location:t}),r=>{n.hydrateAddress({kind:"span",span:P(r,e)});}),n}startNewList(){let t=`${this.path.label}.startNewList`,e=j.promised(this.context,t,false);return this.commandAnswering(t,()=>({op:"startNewList",paragraph:this.#r()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),e}attachToList(t,e){let n=`${this.path.label}.attachToList`;(!Number.isSafeInteger(t)||t<=0||!Number.isInteger(e)||e<0||e>8)&&a({code:"InvalidArgument",target:n});let r=j.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"attachToList",paragraph:this.#r(),listId:t,level:e}),i=>{r.hydrateAddress({kind:"handle",handle:u(i,n)});}),r}detachFromList(){let t=`${this.path.label}.detachFromList`;this.commandAnswering(t,()=>({op:"detachFromList",paragraph:this.#r()}),e=>{m(e,t);});}get listItem(){return this.#e??=ct.of(this.context,`${this.path.label}.listItem`,this.path),this.#e}clear(){this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{paragraph:this.#r()},text:""}));}delete(){this.command("delete",()=>({op:"deleteParagraph",paragraph:this.#r()}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=ye(e,n),s=b.promised(this.context,n,false);return this.commandAnswering(n,()=>i==="Replace"?{op:"replaceSpan",span:{paragraph:this.#r()},text:r}:{op:"insertText",at:{paragraph:this.#r(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:P(d,n)});}),s}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n),i=xe(e,n),s=o.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:this.#r()},where:i==="Before"?"before":"after",text:r}),d=>{d.kind!=="handle"&&a({code:"GeneralException",target:n}),s.hydrateAddress({kind:"handle",handle:d.handle});}),s}split(t,e,n){let r=`${this.path.label}.split`,i=Ke(t,r),s=Ae(e,`${r}.trimDelimiters`),d=Ae(n,`${r}.trimSpacing`),h=N.answered(this.context,r,this.path);return this.commandAnswering(r,()=>({op:"splitParagraph",paragraph:this.#r(),delimiters:i,...s?{trimDelimiters:true}:{},...d?{trimSpacing:true}:{}}),A=>{h.fill(A,r);}),h}onLoad(t){let e=this.selection(t,["text","uniqueLocalId",...Ce]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#r(),projection:this.revisionTextView()})),e.includes("uniqueLocalId")&&this.loadTextInto("uniqueLocalId",()=>({op:"getParagraphId",paragraph:this.#r()}));let n=Ce.filter(i=>e.includes(i));if(n.length===0)return;let r=`${this.path.label}.paragraphFormat`;this.read(r,()=>({op:"getParagraphFormat",paragraph:{paragraph:this.#r()}}),i=>{let s=Ut(i,r);for(let d of n)this.setLoadedProperty(d,s[d]);});}#i(t,e){if(this.requireUsablePath(),this.#o){this.#o[t]=e;return}let n={[t]:e};this.#o=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.paragraphFormat`,()=>({op:"setParagraphFormat",paragraph:{paragraph:this.#r()},format:n}),i=>{m(i,r);},()=>{this.#o===n&&(this.#o=void 0);});}#s(t){let e=j.promised(this.context,t,false);return this.read(t,()=>({op:"getParagraphList",paragraph:this.#r()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),e}#r(){return this.requireAddressable(),this.path.handle()}},Ce=["style","alignment","firstLineIndent","leftIndent","rightIndent","lineSpacing","spaceBefore","spaceAfter"],Qe=["Left","Centered","Right","Justified"];function Xe(o,t){return Qe.includes(o)||a({code:"InvalidArgument",target:t}),o}function ht(o,t){return (typeof o!="number"||!Number.isFinite(o))&&a({code:"InvalidArgument",target:t}),o}function Ke(o,t){(!Array.isArray(o)||o.length===0||o.length>ze)&&a({code:"InvalidArgument",target:t});for(let e of o)(typeof e!="string"||e.length===0)&&a({code:"InvalidArgument",target:t});return [...o]}function Ae(o,t){return o!==void 0&&typeof o!="boolean"&&a({code:"InvalidArgument",target:t}),o===true}var L=class o extends T{#t;static of(t,e,n){return new o(t,c.derived(e,n),null)}static overListing(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){if(this.#t)return this.#t();let t=this.path.address();return t.kind==="handle"?{op:"getParagraphs",body:t.handle}:{op:"getSpanParagraphs",span:t.span}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return w.at(this.context,t,e)}promised(t,e){return w.promised(this.context,t,e)}},N=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}static answered(t,e,n){return new o(t,c.derived(e,n),null)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t?this.#t():null}size(t,e){return Tt(t,e).length}addressAt(t,e,n){let r=Tt(t,e)[n];return r?{kind:"span",span:r}:void 0}itemAt(t,e){return b.at(this.context,t,e)}promised(t,e){return b.promised(this.context,t,e)}};var Pe=4096,q=class o extends p{#t;#n=new Map;#e;#o;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get tag(){return this.loadedProperty("tag")}set tag(t){this.#s("tag",{tag:ae(t,`${this.path.label}.tag`)});}get title(){return this.loadedProperty("title")}set title(t){this.#s("title",{title:ae(t,`${this.path.label}.title`)});}get subtype(){return this.loadedProperty("subtype")}get isBound(){return this.loadedProperty("isBound")}get cannotDelete(){let t=this.loadedProperty("lock");return t==="sdtLocked"||t==="sdtContentLocked"}set cannotDelete(t){this.#r("cannotDelete",t);}get cannotEdit(){let t=this.loadedProperty("lock");return t==="contentLocked"||t==="sdtContentLocked"}set cannotEdit(t){this.#r("cannotEdit",t);}get placeholderShown(){return this.loadedProperty("placeholderShown")}get temporary(){return this.loadedProperty("temporary")}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#e??=L.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getContentControlParagraphs",contentControl:this.#a()})),this.#e}get contentControls(){return this.#o??=$.of(this.context,`${this.path.label}.contentControls`,this.path,{contentControl:this.#a()}),this.#o}getRange(t){let e=`${this.path.label}.getRange`,n=Ze(t??"Whole",e),r=this.#n.get(n);if(r)return r;let i=this.#i(e,n);return this.#n.set(n,i),i}setValue(t){let e=`${this.path.label}.setValue`,n=Ye(t,e);this.command("setValue",()=>({op:"setContentControlValue",contentControl:this.#a(),value:n}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=e==="Replace"?"replace":e==="Start"?"start":e==="End"?"end":a({code:"InvalidArgument",target:n}),s=b.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertContentControlText",contentControl:this.#a(),text:r,at:i}),d=>{s.hydrateAddress({kind:"span",span:P(d,n)});}),s}delete(t){let e=`${this.path.label}.delete`;typeof t!="boolean"&&a({code:"InvalidArgument",target:e}),this.command("delete",()=>({op:"deleteContentControl",contentControl:this.#a(),keepContent:t}));}onLoad(t){let e=this.selection(t,["id","tag","title","subtype","isBound","text","cannotDelete","cannotEdit","placeholderShown","temporary"]);if(e.includes("id")&&this.loadTextInto("id",()=>({op:"getContentControlFileId",contentControl:this.#a()})),e.includes("tag")&&this.loadTextInto("tag",()=>({op:"getContentControlTag",contentControl:this.#a()})),e.includes("title")&&this.loadTextInto("title",()=>({op:"getContentControlTitle",contentControl:this.#a()})),e.includes("subtype")&&this.loadTextInto("subtype",()=>({op:"getContentControlSubtype",contentControl:this.#a()})),e.includes("isBound")){let r=`${this.path.label}.isBound`;this.read(r,()=>({op:"getContentControlIsBound",contentControl:this.#a()}),i=>{this.setLoadedProperty("isBound",_(i,r));});}if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getContentControlText",contentControl:this.#a(),projection:this.revisionTextView()})),e.includes("cannotDelete")||e.includes("cannotEdit")){let r=`${this.path.label}.lock`;this.read(r,()=>({op:"getContentControlLock",contentControl:this.#a()}),i=>{this.setLoadedProperty("lock",O(i,r));});}if(e.includes("placeholderShown")){let r=`${this.path.label}.placeholderShown`;this.read(r,()=>({op:"getContentControlPlaceholderShown",contentControl:this.#a()}),i=>{this.setLoadedProperty("placeholderShown",_(i,r));});}if(!e.includes("temporary"))return;let n=`${this.path.label}.temporary`;this.read(n,()=>({op:"getContentControlTemporary",contentControl:this.#a()}),r=>{this.setLoadedProperty("temporary",_(r,n));});}#i(t,e){let n=b.promised(this.context,t,false);return this.read(t,()=>({op:"getContentControlRange",contentControl:this.#a(),location:e}),r=>{n.hydrateAddress({kind:"span",span:P(r,t)});}),n}#s(t,e){this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#a(),...e}));}#r(t,e){let n=`${this.path.label}.${t}`;if(typeof e!="boolean"&&a({code:"InvalidArgument",target:n}),this.requireUsablePath(),this.#t){this.#t[t]=e;return}let r={[t]:e};this.#t=r,this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#a(),...r}),()=>{this.#t===r&&(this.#t=void 0);});}#a(){return this.requireAddressable(),this.path.handle()}},$=class o extends x{#t;#n;static of(t,e,n,r){return new o(t,c.derived(e,n),r,()=>({op:"getContentControls",scope:r}))}constructor(t,e,n,r){super(t,e),this.#t=n,this.#n=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getById(t){let e=`${this.path.label}.getById`;Number.isInteger(t)||a({code:"InvalidArgument",target:e});let n=this.#t,r=q.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getContentControlById",scope:n,id:t}),settle:i=>{r.hydrateAddress({kind:"handle",handle:u(i,e)});}}),r}getByTag(t){let e=`${this.path.label}.getByTag`,n=ve(t,e),r=this.#t;return new o(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTag",scope:r,tag:n}))}getByTitle(t){let e=`${this.path.label}.getByTitle`,n=ve(t,e),r=this.#t;return new o(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTitle",scope:r,title:n}))}listing(){return this.#n()}itemAt(t,e){return q.at(this.context,t,e)}promised(t,e){return q.promised(this.context,t,e)}};function ae(o,t){return (typeof o!="string"||o.length>Pe)&&a({code:"InvalidArgument",target:t}),o}function ve(o,t){let e=ae(o,t);return e.length===0&&a({code:"InvalidArgument",target:t}),e}function Ze(o,t){switch(o){case "Whole":return "whole";case "Content":return "content";case "Start":return "start";case "End":return "end";case "Before":return "before";case "After":return "after";default:return a({code:"InvalidArgument",target:t})}}function Ye(o,t){(typeof o!="object"||o===null)&&a({code:"InvalidArgument",target:t});let e=o;if(e.kind==="text"||e.kind==="listItem"){let n=e.kind==="text"?e.text:e.value;return (typeof n!="string"||n.length>Pe)&&a({code:"InvalidArgument",target:t}),e.kind==="text"?{kind:"text",text:n}:{kind:"listItem",value:n}}if(e.kind==="checkbox")return typeof e.checked!="boolean"&&a({code:"InvalidArgument",target:t}),{kind:"checkbox",checked:e.checked};if(e.kind==="date")return (typeof e.iso!="string"||e.iso.length>64)&&a({code:"InvalidArgument",target:t}),{kind:"date",iso:e.iso};a({code:"InvalidArgument",target:t});}function Je(o,t){return t<1||t>12?0:t===2?o%4===0&&o%100!==0||o%400===0?29:28:t===4||t===6||t===9||t===11?30:31}function Oe(o){if(o.length===0)return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/.exec(o.trim());if(!t)return null;let e=Number(t[1]),n=Number(t[2]),r=Number(t[3]),i=Je(e,n);if(e===0||i===0||r<1||r>i)return null;let s=Number(t[4]),d=Number(t[5]),h=Number(t[6]);if(s>23||d>59||h>59)return null;let A=t[7],K=A===void 0?0:Number(A.padEnd(3,"0").slice(0,3));if(Number.isNaN(K))return null;let ot=`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}.${String(K).padStart(3,"0")}Z`,Lt=Date.parse(ot);if(Number.isNaN(Lt))return null;let g=t[8];if(g==="Z")return new Date(Lt);let Z=Number(g.slice(1,3)),rt=Number(g.slice(4,6));if(rt>59||Z>14||Z===14&&rt!==0)return null;let Ft=g[0]==="+"?1:-1,wt=new Date(Lt-Ft*(Z*36e5+rt*6e4));return Number.isNaN(wt.getTime())?null:wt}var Bt=class extends p{hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get authorName(){return this.loadedProperty("authorName")}get creationDate(){return this.loadedProperty("creationDate")}get id(){return this.loadedProperty("id")}get text(){return this.loadedProperty("text")}delete(){this.command("delete",()=>({op:"deleteComment",comment:this.commentHandle()}));}loadCommentFields(t,e){let n=this.selection(t,["authorName","creationDate","id","text",...e]);if(n.includes("authorName")&&this.loadTextInto("authorName",()=>({op:"getCommentAuthor",comment:this.commentHandle()})),n.includes("text")&&this.loadTextInto("text",()=>({op:"getCommentText",comment:this.commentHandle()})),n.includes("id")&&this.loadTextInto("id",()=>({op:"getCommentId",comment:this.commentHandle()})),n.includes("creationDate")){let i=`${this.path.label}.creationDate`;this.read(i,()=>({op:"getCommentDate",comment:this.commentHandle()}),s=>{this.setLoadedProperty("creationDate",Oe(O(s,i)));});}if(!n.includes("resolved"))return;let r=`${this.path.label}.resolved`;this.read(r,()=>({op:"getCommentResolved",comment:this.commentHandle()}),i=>{this.setLoadedProperty("resolved",_(i,r));});}commentHandle(){return this.requireAddressable(),this.path.handle()}},et=class o extends Bt{static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}onLoad(t){this.loadCommentFields(t,[]);}},It=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return et.at(this.context,t,e)}promised(t,e){return et.promised(this.context,t,e)}},G=class o extends Bt{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}get resolved(){return this.loadedProperty("resolved")}set resolved(t){let e=`${this.path.label}.resolved`;typeof t!="boolean"&&a({code:"InvalidArgument",target:e}),this.commandAnswering(e,()=>({op:"setCommentResolved",comment:this.commentHandle(),resolved:t}),n=>{m(n,e);});}get replies(){return this.#t??=It.of(this.context,`${this.path.label}.replies`,this.path,()=>({op:"getCommentReplies",comment:this.commentHandle()})),this.#t}getRange(){let t=`${this.path.label}.getRange`,e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getCommentRange",comment:this.commentHandle()}),n=>{e.hydrateAddress({kind:"span",span:P(n,t)});}),e}reply(t){let e=`${this.path.label}.reply`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&a({code:"NotSupported",target:e});let r=et.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"replyToComment",comment:this.commentHandle(),text:t,author:n}),i=>{r.hydrateAddress({kind:"handle",handle:u(i,e)});}),r}onLoad(t){this.loadCommentFields(t,["resolved"]);}},z=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return G.at(this.context,t,e)}promised(t,e){return G.promised(this.context,t,e)}},pt=class o extends p{static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get author(){return this.loadedProperty("author")}get date(){return this.loadedProperty("date")}get type(){return this.loadedProperty("type")}get range(){let t=`${this.path.label}.range`,e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getRevisionRange",revision:this.#t()}),n=>{e.hydrateAddress({kind:"span",span:P(n,t)});}),e}accept(){this.command("accept",()=>({op:"acceptRevision",revision:this.#t()}));}reject(){this.command("reject",()=>({op:"rejectRevision",revision:this.#t()}));}onLoad(t){let e=this.selection(t,["author","date","type"]);if(e.includes("author")&&this.loadTextInto("author",()=>({op:"getRevisionAuthor",revision:this.#t()})),e.includes("type")&&this.loadTextInto("type",()=>({op:"getRevisionType",revision:this.#t()})),!e.includes("date"))return;let n=`${this.path.label}.date`;this.read(n,()=>({op:"getRevisionDate",revision:this.#t()}),r=>{this.setLoadedProperty("date",Oe(O(r,n)));});}#t(){return this.requireAddressable(),this.path.handle()}},Q=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}acceptAll(){let t=this.#t;this.commandOn("acceptAll",()=>({op:"acceptAllRevisions",body:t}));}rejectAll(){let t=this.#t;this.commandOn("rejectAll",()=>({op:"rejectAllRevisions",body:t}));}listing(){return {op:"getRevisions",body:this.#t}}itemAt(t,e){return pt.at(this.context,t,e)}promised(t,e){return pt.promised(this.context,t,e)}commandOn(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:n,plan:e,settle:r=>{m(r,n);}});}};var _e=new Set(["matchCase","matchWholeWord","ignorePunct","ignoreSpace","matchWildcards"]);function Ht(o,t){if(o===void 0)return;typeof o!="object"&&a({code:"InvalidArgument",target:t});for(let[n,r]of Object.entries(o))_e.has(n)||a({code:"InvalidArgument",target:`${t}.${n}`}),r!==void 0&&typeof r!="boolean"&&a({code:"InvalidArgument",target:`${t}.${n}`});let e={...o.matchCase===void 0?{}:{matchCase:o.matchCase},...o.matchWholeWord===void 0?{}:{matchWholeWord:o.matchWholeWord},...o.ignorePunct===void 0?{}:{ignorePunct:o.ignorePunct},...o.ignoreSpace===void 0?{}:{ignoreSpace:o.ignoreSpace},...o.matchWildcards===void 0?{}:{matchWildcards:o.matchWildcards}};return Object.keys(e).length===0?void 0:e}var b=class o extends p{#t;#n;#e;#o;#i;#s;static at(t,e,n){return n.kind!=="span"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.ofSpan(e,n.span),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="span"?this.path.resolveToSpan(t.span):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get font(){return this.#i??=E.of(this.context,`${this.path.label}.font`,this.path,"span"),this.#i}get paragraphs(){return this.#o??=L.of(this.context,`${this.path.label}.paragraphs`,this.path),this.#o}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=it(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:R(this.path,"span"),name:n}));}get hyperlink(){return this.loadedProperty("hyperlink")}set hyperlink(t){let e=`${this.path.label}.hyperlink`;(typeof t!="string"||t.length>2048)&&a({code:"InvalidArgument",target:e}),this.requireUsablePath(),this.command("hyperlink",()=>({op:"setHyperlink",span:this.#r(),target:t}));}get bookmarks(){let t=this.#r();return this.#s??=X.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{start:t.start,end:t.end}})),this.#s}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&a({code:"InvalidArgument",target:n});let r=Ht(e,n),i=this.#r();return N.of(this.context,n,this.path,()=>({op:"search",scope:i,text:t,options:{...r??{},projection:this.revisionTextView()}}))}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=Ot(e,n);this.requireUsablePath();let s=o.promised(this.context,n,false);return this.commandAnswering(n,()=>{let d=this.#r();return i==="Replace"?{op:"replaceSpan",span:d,text:r}:{op:"insertText",at:i==="Start"||i==="Before"?d.start:d.end,text:r}},d=>{s.hydrateAddress({kind:"span",span:P(d,n)});}),s}delete(){this.requireUsablePath(),this.commandDiscarding("delete",()=>({op:"replaceSpan",span:this.#r(),text:""}));}clear(){let t=this.#r();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:t,text:""}));}insertComment(t){let e=`${this.path.label}.insertComment`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&a({code:"NotSupported",target:e});let r=G.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertComment",span:this.#r(),text:t,author:n}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:e}),r.hydrateAddress(i);}),r}insertContentControl(t){let e=`${this.path.label}.insertContentControl`,n=t??"RichText";n!=="RichText"&&n!=="PlainText"&&a({code:"NotSupported",target:e});let r=q.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertContentControl",span:this.#r(),subtype:n==="PlainText"?"plainText":"richText",returnHandle:true}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:e}),r.hydrateAddress(i);}),r}get tables(){return this.requireUsablePath(),this.#t??=U.over(this.context,`${this.path.label}.tables`,this.path,()=>R(this.path,"span"))}get fields(){return this.requireUsablePath(),this.#n??=M.of(this.context,`${this.path.label}.fields`,this.path,"span")}insertField(t,e,n,r){let i=`${this.path.label}.insertField`;(e!==void 0&&typeof e!="string"||n!==void 0&&typeof n!="string"||r!==void 0&&typeof r!="boolean")&&a({code:"InvalidArgument",target:i});let s=Ot(t,i);this.requireUsablePath();let d=H.promised(this.context,i,false);return this.commandAnswering(i,()=>({op:"insertField",span:this.#r(),location:s,...e===void 0?{}:{fieldType:e},...n===void 0?{}:{text:n},...r===void 0?{}:{removeFormatting:r}}),h=>d.hydrateAddress({kind:"handle",handle:u(h,i)})),d}get inlinePictures(){return this.requireUsablePath(),this.#e??=V.of(this.context,`${this.path.label}.inlinePictures`,this.path,"span")}insertInlinePictureFromBase64(t,e){let n=`${this.path.label}.insertInlinePictureFromBase64`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:n});let r=Ot(e,n);this.requireUsablePath();let i=F.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertInlinePicture",span:this.#r(),base64:t,location:r}),s=>{i.hydrateAddress({kind:"handle",handle:u(s,n)});}),i}insertBreak(t,e){let n=`${this.path.label}.insertBreak`;e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:n});let r=e;this.requireUsablePath(),this.commandAnswering(n,()=>({op:"insertBreak",span:this.#r(),breakType:t,location:r}),i=>m(i,n));}insertTable(t,e,n,r){let i=`${this.path.label}.insertTable`;(!Number.isInteger(t)||!Number.isInteger(e)||t<1||e<1||!["Before","After"].includes(n))&&a({code:"InvalidArgument",target:i}),r!==void 0&&(!Array.isArray(r)||r.some(h=>!Array.isArray(h)||h.some(A=>typeof A!="string")))&&a({code:"InvalidArgument",target:i});let s=r?.map(h=>[...h]),d=W.promised(this.context,i);return this.commandAnswering(i,()=>({op:"insertTable",span:R(this.path,"span"),location:n,rowCount:t,columnCount:e,...s?{values:s}:{}}),h=>{h.kind!=="handle"&&a({code:"GeneralException",target:i}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n),i=Ot(e,n);i!=="Before"&&i!=="After"&&a({code:"InvalidArgument",target:n});let s=this.#r(),d=i==="Before"?s.start.paragraph:s.end.paragraph,h=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:d},where:i==="Before"?"before":"after",text:r}),A=>{A.kind!=="handle"&&a({code:"GeneralException",target:n}),h.hydrateAddress({kind:"handle",handle:A.handle});}),h}select(t){let e=`${this.path.label}.select`,n=qt(t,e);this.requireAddressable(),this.internals.capabilities.selection||a({code:"NotSupported",target:e});let r=this.#r();this.command("select",()=>({op:"selectSpan",span:r,mode:n==="Select"?"select":n==="Start"?"start":"end"}));}onLoad(t){let e=this.selection(t,["text","style","hyperlink"]);if(e.includes("hyperlink")&&this.loadTextInto("hyperlink",()=>({op:"getHyperlink",span:this.#r()})),e.includes("text")){let r=`${this.path.label}.text`;this.read(r,()=>({op:"getSpanText",span:this.#r(),projection:this.revisionTextView()}),i=>{this.setLoadedProperty("text",O(i,r));});}if(!e.includes("style"))return;let n=`${this.path.label}.style`;this.requireUsablePath(),this.read(n,()=>({op:"getStyle",span:R(this.path,"span")}),r=>{this.setLoadedProperty("style",xt(r,n));});}#r(){return this.requireAddressable(),this.path.span()}};var ut=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get name(){return this.loadedProperty("name")}get range(){return this.#t??=this.#n(`${this.path.label}.range`),this.#t}select(t){let e=`${this.path.label}.select`,n=qt(t,e);this.requireUsablePath(),this.internals.capabilities.selection||a({code:"NotSupported",target:e}),this.command("select",()=>({op:"selectBookmark",bookmark:this.#e(),mode:n==="Select"?"select":n==="Start"?"start":"end"}));}onLoad(t){if(!this.selection(t,["name"]).includes("name"))return;let e=`${this.path.label}.name`;this.read(e,()=>({op:"getBookmarkName",bookmark:this.#e()}),n=>{this.setLoadedProperty("name",O(n,e));});}#n(t){let e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getBookmarkRange",bookmark:this.#e()}),n=>{e.hydrateAddress({kind:"span",span:P(n,t)});}),e}#e(){return this.requireAddressable(),this.path.handle()}},X=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}listing(){return this.#t()}itemAt(t,e){return ut.at(this.context,t,e)}promised(t,e){return ut.promised(this.context,t,e)}};var I=class o extends p{#t;#n;#e;#o;#i;#s;#r;#a;#l;static main(t,e){return new o(t,c.of(e,J(t).roots().body))}static promisedStory(t,e){return new o(t,c.pending(e))}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}constructor(t,e){super(t,e);}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#o??=this.paragraphsUnder(`${this.path.label}.paragraphs`),this.#o}get bookmarks(){let t=this.#d();return this.#i??=X.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{body:t}})),this.#i}get font(){return this.#s??=E.of(this.context,`${this.path.label}.font`,this.path,"body"),this.#s}paragraphsUnder(t){return L.of(this.context,t,this.path)}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=it(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:R(this.path,"body"),name:n}));}get lists(){return this.#r??=lt.of(this.context,`${this.path.label}.lists`,this.path,this.#d()),this.#r}get contentControls(){return this.#a??=$.of(this.context,`${this.path.label}.contentControls`,this.path,{body:this.#d()}),this.#a}getComments(){let t=`${this.path.label}.getComments`,e=this.#d();return z.of(this.context,t,this.path,()=>({op:"getComments",scope:{body:e}}))}get revisions(){return this.#l??=Q.of(this.context,`${this.path.label}.revisions`,this.path,this.#d()),this.#l}getRange(t="Whole"){let e=`${this.path.label}.getRange`;this.requireUsablePath();let n=b.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{body:this.path.handle()},location:t}),r=>{n.hydrateAddress({kind:"span",span:P(r,e)});}),n}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&a({code:"InvalidArgument",target:n});let r=Ht(e,n),i=this.#d();return N.of(this.context,n,this.path,()=>({op:"search",scope:{body:i},text:t,options:{...r??{},projection:this.revisionTextView()}}))}clear(){let t=this.#d();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{body:t},text:""}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=fe(e,n);this.requireUsablePath();let s=b.promised(this.context,n,false);return this.commandAnswering(n,()=>i==="Replace"?{op:"replaceSpan",span:{body:this.#d()},text:r}:{op:"insertText",at:{body:this.#d(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:P(d,n)});}),s}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n),i=be(e,n),s=this.#d(),d=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{body:s,at:i==="Start"?"first":"last"},where:i==="Start"?"before":"after",text:r}),h=>{h.kind!=="handle"&&a({code:"GeneralException",target:n}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}onLoad(t){let e=this.selection(t,["text","style"]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#d(),projection:this.revisionTextView()})),e.includes("style")&&this.#c();}#c(){let t=`${this.path.label}.style`;this.requireUsablePath(),this.read(t,()=>({op:"getStyle",span:R(this.path,"body")}),e=>{this.setLoadedProperty("style",xt(e,t));});}get fields(){return this.requireUsablePath(),this.#n??=M.of(this.context,`${this.path.label}.fields`,this.path,"body")}get inlinePictures(){return this.requireUsablePath(),this.#e??=V.of(this.context,`${this.path.label}.inlinePictures`,this.path,"body")}get tables(){return this.requireUsablePath(),this.#t??=U.over(this.context,`${this.path.label}.tables`,this.path,()=>({body:this.#d()}))}#d(){return this.requireAddressable(),this.path.handle()}};function tn(o){return o==="endnote"?"Endnote":"Footnote"}var mt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get type(){return this.loadedProperty("type")}get text(){return this.loadedProperty("text")}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=I.promisedStory(this.context,t);return this.read(t,()=>({op:"getNoteBody",note:this.#n()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),this.#t=e,e}delete(){this.command("delete",()=>({op:"deleteNote",note:this.#n()}));}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document,r=`${t}.type`,i="footnote",s=c.pending(r);return this.read(r,()=>({op:"getNoteKind",note:this.#n()}),d=>{i=O(d,r)==="endnote"?"endnote":"footnote",s.resolveTo(this.#n());}),this.enqueue({sort:"read",label:t,dependencies:[s],plan:()=>({op:"getNotes",document:n,noteKind:i}),settle:d=>{let h=v(d,t),A=h.findIndex(ot=>ot.ref===this.#n().ref),K=A<0?void 0:h[A+1];K||a({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:K});}}),e}onLoad(t){let e=this.selection(t,["text","type"]);if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getNoteText",note:this.#n(),projection:this.revisionTextView()})),e.includes("type")){let n=`${this.path.label}.type`;this.read(n,()=>({op:"getNoteKind",note:this.#n()}),r=>{this.setLoadedProperty("type",tn(O(r,n)));});}}#n(){return this.requireAddressable(),this.path.handle()}},nt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return mt.at(this.context,t,e)}promised(t,e){return mt.promised(this.context,t,e)}};var en=Object.freeze({Primary:"default",FirstPage:"first",EvenPages:"even"}),nn=["pageWidth","pageHeight","orientation","topMargin","rightMargin","bottomMargin","leftMargin"],kt=class o extends p{#t;static of(t,e,n){return new o(t,c.derived(e,n))}constructor(t,e){super(t,e);}get pageWidth(){return this.loadedProperty("pageWidth")}set pageWidth(t){this.#n("pageWidth",gt(t,`${this.path.label}.pageWidth`));}get pageHeight(){return this.loadedProperty("pageHeight")}set pageHeight(t){this.#n("pageHeight",gt(t,`${this.path.label}.pageHeight`));}get orientation(){return this.loadedProperty("orientation")}set orientation(t){let e=`${this.path.label}.orientation`;t!=="Portrait"&&t!=="Landscape"&&a({code:"InvalidArgument",target:e}),this.#n("orientation",t==="Portrait"?"portrait":"landscape");}get topMargin(){return this.loadedProperty("topMargin")}set topMargin(t){this.#n("topMargin",gt(t,`${this.path.label}.topMargin`));}get bottomMargin(){return this.loadedProperty("bottomMargin")}set bottomMargin(t){this.#n("bottomMargin",gt(t,`${this.path.label}.bottomMargin`));}get leftMargin(){return this.loadedProperty("leftMargin")}set leftMargin(t){this.#n("leftMargin",gt(t,`${this.path.label}.leftMargin`));}get rightMargin(){return this.loadedProperty("rightMargin")}set rightMargin(t){this.#n("rightMargin",gt(t,`${this.path.label}.rightMargin`));}onLoad(t){let e=this.selection(t,nn);if(e.length===0)return;let n=`${this.path.label}.pageSetup`;this.read(n,()=>({op:"getPageSetup",section:this.#e()}),r=>{let i=Gt(r,n);for(let s of e)this.setLoadedProperty(s,s==="orientation"?i.orientation==="landscape"?"Landscape":"Portrait":i[s]);});}#n(t,e){if(this.requireUsablePath(),this.#t){this.#t[t]=e;return}let n={[t]:e};this.#t=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.pageSetup`,()=>({op:"setPageSetup",section:this.#e(),setup:n}),i=>{m(i,r);},()=>{this.#t===n&&(this.#t=void 0);});}#e(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},ft=class o extends p{#t;#n;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){return this.#n??=I.main(this.context,`${this.path.label}.body`),this.#n}get pageSetup(){return this.#t??=kt.of(this.context,`${this.path.label}.pageSetup`,this.path),this.#t}getHeader(t){return this.#e("header",t,"getHeader")}getFooter(t){return this.#e("footer",t,"getFooter")}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document;return this.read(t,()=>({op:"getSections",document:n}),r=>{let i=v(r,t),s=i.findIndex(h=>h.ref===this.#o().ref),d=s<0?void 0:i[s+1];d||a({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:d});}),e}onLoad(t){this.selection(t,[]);}#e(t,e,n){let r=`${this.path.label}.${n}`,i=en[e];i===void 0&&a({code:"InvalidArgument",target:r});let s=I.promisedStory(this.context,r);return this.read(r,()=>({op:"getFurniture",section:this.#o(),kind:t,variant:i}),d=>{s.hydrateAddress({kind:"handle",handle:u(d,r)});}),s}#o(){return this.requireAddressable(),this.path.handle()}},bt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return ft.at(this.context,t,e)}promised(t,e){return ft.promised(this.context,t,e)}};function gt(o,t){return (typeof o!="number"||!Number.isFinite(o)||o<0)&&a({code:"InvalidArgument",target:t}),o}var yt=class o extends p{#t;#n;#e;#o;#i;#s;#r;#a;static open(t){return new o(t)}constructor(t){super(t,c.of("document",J(t).roots().document));}get changeTrackingMode(){return this.loadedProperty("changeTrackingMode")}set changeTrackingMode(t){["Off","TrackAll","TrackMineOnly"].includes(t)||a({code:"InvalidArgument",target:"document.changeTrackingMode"});let e=this.internals.author;this.commandAnswering("document.changeTrackingMode",()=>({op:"setChangeTrackingMode",mode:t,...e===void 0?{}:{author:e}}),()=>this.setLoadedProperty("changeTrackingMode",t));}get body(){return this.#t??=I.main(this.context,"document.body"),this.#t}get paragraphs(){return this.#n??=this.body.paragraphsUnder("document.paragraphs"),this.#n}get sections(){let t=this.path.handle();return this.#e??=bt.of(this.context,"document.sections",this.path,()=>({op:"getSections",document:t})),this.#e}get contentControls(){return this.#s??=$.of(this.context,"document.contentControls",this.path,{body:this.internals.roots().body}),this.#s}get comments(){return this.#o??=z.of(this.context,"document.comments",this.path,()=>({op:"getComments",scope:{body:this.internals.roots().body}})),this.#o}get revisions(){return this.#i??=Q.of(this.context,"document.revisions",this.path,this.internals.roots().body),this.#i}get footnotes(){let t=this.path.handle();return this.#r??=nt.of(this.context,"document.footnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"footnote"})),this.#r}get endnotes(){let t=this.path.handle();return this.#a??=nt.of(this.context,"document.endnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"endnote"})),this.#a}onLoad(t){if(t.select.length===0)return;this.selection(t,["changeTrackingMode"]).includes("changeTrackingMode")&&this.loadTextInto("changeTrackingMode",()=>({op:"getChangeTrackingMode"}));}};function Mt(o){let t=o.host,e=Object.freeze({...t.capabilities,save:o.save&&t.capabilities.save}),n=typeof o.author=="string"&&o.author.trim().length>0?o.author:void 0,r=o.revisionTextView??"allMarkup";r!=="allMarkup"&&r!=="original"&&a({code:"InvalidArgument",target:"revisionTextView"});let i=false,s=null,d=g=>{i&&a({code:"RuntimeDisposed",...g===void 0?{}:{target:g}});},h=()=>{if(s)return s;d("document");let g=Re(t.execute({operations:[{op:"getDocument"}]}),"document"),Z=Re(t.execute({operations:[{op:"getBody",document:g}]}),"document.body");return s={document:g,body:Z},s},A={host:t,capabilities:e,...n===void 0?{}:{author:n},revisionTextView:r,id:{},roots:h,assertLive:d,openDocument:g=>yt.open(g)};try{h();}catch{s=null;}async function K(g,Z){d();let rt=typeof g=="function"?g:Z,Ft=typeof g=="function"?[]:Array.isArray(g)?g:[g];typeof rt!="function"&&a({code:"InvalidArgument",target:"run"});let{context:wt,adopt:y,finish:we}=At.begin(A);try{return y(Ft),await rt(wt)}finally{we();}}let ot={capabilities:e,run:K,dispose(){i||(i=true,s=null,t.dispose());}};return o.save?{...ot,async save(){d("save"),e.save||a({code:"NotSupported",target:"save"});let g=t.save();if(!g.ok)throw Nt(g.error,{target:"save"});return g.bytes}}:ot}function Re(o,t){let e=o.results[0];if(e?.status==="error")throw Nt(e.error,{target:t});if(e?.status!=="ok")throw new C({code:"GeneralException",target:t});return u(e.value,t)}function Ie(o,t={}){return Mt({host:editor.createBrowserAutomationHost(o),save:false,...t.author===void 0?{}:{author:t.author},...t.revisionTextView===void 0?{}:{revisionTextView:t.revisionTextView}})}function ke(o){return automation.createAutomationPaginationProvider(o)}function sn(o){if(o){for(let t of o)if(t.collaboration)return t.collaboration}}function dn(o){let t=[o?.zip?.maxEntries,o?.zip?.maxTotalBytes,o?.xml?.maxBytes,o?.xml?.maxElements,o?.maxXmlParts,o?.maxRelationships],e=o?.zip?.maxRatio;(t.some(n=>n!==void 0&&(!Number.isInteger(n)||n<0))||e!==void 0&&(!Number.isFinite(e)||e<0))&&a({code:"InvalidArgument",target:"createServer"});}async function se(o,t={}){dn(t.limits);let e=sn(t.modules),n=automation.createServerAutomationHost(o,{...t.pagination?{pagination:ke(t.pagination)}:{},...t.limits===void 0?{}:{limits:t.limits},...e===void 0?{}:{collaborationModel:e}});if(!n.ok){let r={"too-many-entries":"zip.maxEntries","too-large":"xml.maxBytes","too-many-elements":"xml.maxElements","too-deep":"xml.maxDepth","too-many-xml-parts":"maxXmlParts","too-many-relationships":"maxRelationships"},i=n.limit??r[n.reason];a({code:i===void 0?"InvalidArgument":"ResourceLimitExceeded",target:"createServer",...i===void 0?{}:{limit:i}});}return Mt({host:n.host,save:true,...t.author===void 0?{}:{author:t.author},...t.revisionTextView===void 0?{}:{revisionTextView:t.revisionTextView}})}function Le(o,t,e={}){return se(o,{...e,modules:[...e.modules??[],{id:"collaboration",collaboration:{session:t}}]})}var de=(l=>(l.addin="Addin",l.addressBlock="AddressBlock",l.advance="Advance",l.ask="Ask",l.author="Author",l.autoText="AutoText",l.autoTextList="AutoTextList",l.barCode="BarCode",l.bibliography="Bibliography",l.bidiOutline="BidiOutline",l.citation="Citation",l.comments="Comments",l.compare="Compare",l.createDate="CreateDate",l.data="Data",l.database="Database",l.date="Date",l.displayBarcode="DisplayBarcode",l.docProperty="DocProperty",l.docVariable="DocVariable",l.editTime="EditTime",l.embedded="Embedded",l.empty="Empty",l.eq="EQ",l.expression="Expression",l.fileName="FileName",l.fileSize="FileSize",l.fillIn="FillIn",l.formCheckbox="FormCheckbox",l.formDropdown="FormDropdown",l.formText="FormText",l.gotoButton="GotoButton",l.greetingLine="GreetingLine",l.hyperlink="Hyperlink",l.if="If",l.import="Import",l.include="Include",l.includePicture="IncludePicture",l.includeText="IncludeText",l.index="Index",l.info="Info",l.keywords="Keywords",l.lastSavedBy="LastSavedBy",l.link="Link",l.listNum="ListNum",l.macroButton="MacroButton",l.mergeBarcode="MergeBarcode",l.mergeField="MergeField",l.mergeRec="MergeRec",l.mergeSeq="MergeSeq",l.next="Next",l.nextIf="NextIf",l.noteRef="NoteRef",l.numChars="NumChars",l.numPages="NumPages",l.numWords="NumWords",l.ocx="OCX",l.others="Others",l.page="Page",l.pageRef="PageRef",l.print="Print",l.printDate="PrintDate",l.private="Private",l.quote="Quote",l.rd="RD",l.ref="Ref",l.revNum="RevNum",l.saveDate="SaveDate",l.section="Section",l.sectionPages="SectionPages",l.seq="Seq",l.set="Set",l.shape="Shape",l.skipIf="SkipIf",l.styleRef="StyleRef",l.subject="Subject",l.subscriber="Subscriber",l.symbol="Symbol",l.ta="TA",l.tc="TC",l.template="Template",l.time="Time",l.title="Title",l.toa="TOA",l.toc="TOC",l.undefined="Undefined",l.userAddress="UserAddress",l.userInitials="UserInitials",l.userName="UserName",l.xe="XE",l))(de||{});var zi=Object.freeze({createBrowser:Ie,createServer:se,createCollaborative:Le});exports.Alignment=Zt;exports.Body=I;exports.Bookmark=ut;exports.BookmarkCollection=X;exports.BreakType=te;exports.ChangeTrackingMode=Jt;exports.ClientObject=B;exports.ClientResult=Vt;exports.Comment=G;exports.CommentCollection=z;exports.CommentReply=et;exports.CommentReplyCollection=It;exports.ContentControl=q;exports.ContentControlCollection=$;exports.ContentControlType=ee;exports.Document=yt;exports.DocxEditor=zi;exports.DocxEditorError=C;exports.Field=H;exports.FieldCollection=M;exports.FieldType=de;exports.Font=E;exports.InlinePicture=F;exports.InlinePictureCollection=V;exports.InsertLocation=Kt;exports.List=j;exports.ListBullet=oe;exports.ListCollection=lt;exports.ListItem=ct;exports.ListNumbering=re;exports.NoteItem=mt;exports.NoteItemCollection=nt;exports.PageOrientation=Yt;exports.PageSetup=kt;exports.Paragraph=w;exports.ParagraphCollection=L;exports.Range=b;exports.RangeCollection=N;exports.RequestContext=At;exports.Revision=pt;exports.RevisionCollection=Q;exports.Section=ft;exports.SectionCollection=bt;exports.Table=W;exports.TableCell=tt;exports.TableCellCollection=Pt;exports.TableCollection=U;exports.TableRow=at;exports.TableRowCollection=st;exports.TrackedObjects=Ct;exports.UnderlineType=ie;exports.VerticalAlignment=_t;exports.isDocxEditorError=Se;
1
+ 'use strict';var editor=require('@docx-editor.dev/core/editor'),automation=require('@docx-editor.dev/core/automation');var le=Object.freeze({PropertyNotLoaded:"the property has not been loaded. Call load(...) and await context.sync() before reading it.",ValueNotLoaded:"the result has not been filled in yet. Await context.sync() before reading it.",InvalidObjectPath:"the object cannot be addressed. Await context.sync() after creating an object with an edit. Keep proxies within their run, or use context.trackedObjects.add(...) before the run ends.",ObjectInUse:"the object still belongs to a run that has not finished. Await that run before passing the object to another one.",InvalidArgument:"the argument is not one this API accepts.",ResourceLimitExceeded:"the document exceeds a supported resource limit.",ItemNotFound:"the collection has no such item.",NotSupported:"the operation or argument is outside this document or host\u2019s supported capabilities.",NotImplemented:"this version does not implement that yet.",ConflictingChanges:"these operations cannot share one atomic batch. Split them across separate context.sync() calls.",InvalidRequestContext:"the request context has finished. Start another run to continue.",RuntimeDisposed:"the runtime has been disposed.",StaleDocument:"the document changed after this context read it, so nothing was applied.",DocumentUnavailable:"the document is not available right now.",GeneralException:"the document could not complete the request."}),C=class extends Error{code;limit;target;expectedRevision;actualRevision;constructor(t){let e=t.target?`${le[t.code]} (${t.target})`:le[t.code];super(e),this.name="DocxEditorError",this.code=t.code,t.limit!==void 0&&(this.limit=t.limit),t.target!==void 0&&(this.target=t.target),t.expectedRevision!==void 0&&(this.expectedRevision=t.expectedRevision),t.actualRevision!==void 0&&(this.actualRevision=t.actualRevision);}};function je(o){return o instanceof C?true:typeof o=="object"&&o!==null&&o.name==="DocxEditorError"&&typeof o.code=="string"}function a(o){throw new C(o)}var Y=Symbol("docx-editor.runtime.internals"),St=Symbol("docx-editor.runtime.release"),jt=Symbol("docx-editor.runtime.rebind");function J(o){return o[Y]}var Te=new Set(["select","expand","top","skip"]),Ee=/^[A-Za-z][A-Za-z0-9]*$/;function ce(o,t){if(o===void 0)return [];let e=typeof o=="string"?o.split(",").map(r=>r.trim()):Array.isArray(o)?o.map(r=>typeof r=="string"?r.trim():r):a({code:"InvalidArgument",target:t}),n=[];for(let r of e)(typeof r!="string"||!Ee.test(r))&&a({code:"InvalidArgument",target:t}),n.includes(r)||n.push(r);return n.length===0&&a({code:"InvalidArgument",target:t}),n}function he(o,t){return (typeof o!="number"||!Number.isInteger(o)||o<0)&&a({code:"InvalidArgument",target:t}),o}function Ne(o,t){o===void 0||Array.isArray(o)&&o.length===0||a({code:"InvalidArgument",target:t});}function pe(o,t){if(o===void 0)return {select:[]};if(typeof o=="string"||Array.isArray(o))return {select:ce(o,t)};(typeof o!="object"||o===null)&&a({code:"InvalidArgument",target:t});let e=o;for(let n of Object.keys(e))Te.has(n)||a({code:"InvalidArgument",target:`${t}.${n}`});return Ne(e.expand,`${t}.expand`),{select:ce(e.select,`${t}.select`),...e.top===void 0?{}:{top:he(e.top,`${t}.top`)},...e.skip===void 0?{}:{skip:he(e.skip,`${t}.skip`)}}}var $=class{#t;#n;#e;#o;#i=new Map;#s=false;constructor(t,e,n={}){this.#t=t,this.#n=t[Y],this.#e=e,this.#o=n.nullable===true,this.#n.register(this);}get context(){return this.#t}get isNullObject(){return this.#e.isReleased&&a({code:"InvalidObjectPath",target:this.#e.label}),this.#o?(this.#e.isPending&&a({code:"PropertyNotLoaded",target:`${this.#e.label}.isNullObject`}),this.#e.isNull):false}load(t){this.#s=true;try{return this.requireUsablePath(),this.onLoad(pe(t,this.#e.label)),this}finally{this.#s=false;}}get path(){return this.#e}get internals(){return this.#n}handle(){return this.#e.handle()}requireAddressable(){this.#e.isAddressable||a({code:"InvalidObjectPath",target:this.#e.label}),this.#n.assertUsable(this.#e.label);}requireUsablePath(){(this.#e.isReleased||this.#e.isNull&&!(this.#s&&this.#o))&&a({code:"InvalidObjectPath",target:this.#e.label}),this.#n.assertUsable(this.#e.label);}enqueue(t){this.requireUsablePath(),this.#n.queue.push({...t,dependencies:[...t.dependencies??[],this.#e],...this.#s&&this.#o&&t.sort==="read"?{nullableLoad:this.#e}:{}});}loadedProperty(t){return this.#e.isReleased&&!this.#i.has(t)&&a({code:"InvalidObjectPath",target:this.#e.label}),this.#i.has(t)||a({code:"PropertyNotLoaded",target:`${this.#e.label}.${t}`}),this.#i.get(t)}hasLoadedProperty(t){return this.#i.has(t)}setLoadedProperty(t,e){this.#i.set(t,e);}[St](){this.#e.release();}[jt](t){this.#t=t,this.#n=t[Y];}};var Tt=class o{#t=false;#n;#e;constructor(t){this.#e=t;}get value(){return this.#t||a({code:"ValueNotLoaded",target:this.#e}),this.#n}get isLoaded(){return this.#t}static create(t){let e=new o(t);return {result:e,fill(n){e.#t=true,e.#n=n;}}}};function ue(o){return Tt.create(o)}function S(o){return new C({code:"GeneralException",target:o})}function P(o,t){if(o.kind!=="text")throw S(t);return o.text}function u(o,t){if(o.kind!=="handle")throw S(t);return o.handle}function A(o,t){if(o.kind!=="handles")throw S(t);return o.handles}function R(o,t){if(o.kind!=="span")throw S(t);return o.span}function Et(o,t){if(o.kind!=="spans")throw S(t);return o.spans}function Wt(o,t){if(o.kind!=="font")throw S(t);return o.font}function Ut(o,t){if(o.kind!=="paragraphFormat")throw S(t);return o.format}function xt(o,t){if(o.kind!=="style")throw S(t);return o.name}function Nt(o,t){if(o.kind!=="number")throw S(t);return o.value}function _(o,t){if(o.kind!=="flag")throw S(t);return o.value}function Gt(o,t){if(o.kind!=="pageSetup")throw S(t);return o.setup}function m(o,t){if(o.kind!=="applied")throw S(t)}var c=class o{label;#t;#n;constructor(t,e,n=null){this.label=t,this.#t=e,this.#n=n;}static of(t,e){return new o(t,{status:"resolved",address:{kind:"handle",handle:e}})}static ofSpan(t,e){return new o(t,{status:"resolved",address:{kind:"span",span:e}})}static pending(t){return new o(t,{status:"pending"})}static derived(t,e){return new o(t,{status:"pending"},e)}get state(){return this.#n?this.#n.state:this.#t}get isAddressable(){return this.state.status==="resolved"}get isPending(){return this.state.status==="pending"}get isNull(){return this.state.status==="null"}get isReleased(){return this.state.status==="released"}address(){let t=this.state;if(t.status==="resolved")return t.address;a({code:"InvalidObjectPath",target:this.label});}handle(){let t=this.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.label}),t.handle}span(){let t=this.address();return t.kind!=="span"&&a({code:"InvalidObjectPath",target:this.label}),t.span}resolveTo(t){this.#e({kind:"handle",handle:t});}resolveToSpan(t){this.#e({kind:"span",span:t});}resolveNull(){this.#t.status!=="released"&&(this.#t={status:"null"});}release(){this.#n||(this.#t={status:"released"});}#e(t){this.#t.status!=="released"&&(this.#t={status:"resolved",address:t});}};function me(o){let t=[],e=false,n=false;for(let r of o)t.push(r.plan()),r.sort==="write"?n=true:e=true;return {operations:t,hasRead:e,hasWrite:n}}var De=Object.freeze({"stale-revision":"StaleDocument","invalid-handle":"InvalidObjectPath","invalid-offset":"InvalidArgument","unsupported-capability":"NotSupported",disposed:"RuntimeDisposed","transaction-refused":"GeneralException","unknown-operation":"NotSupported","unsupported-content":"InvalidArgument","unsupported-revision":"NotImplemented","ambiguous-document":"GeneralException","conflicting-operations":"ConflictingChanges","document-unavailable":"DocumentUnavailable"});function Dt(o,t={}){let e=De[o.code]??"GeneralException",n=e==="StaleDocument";return new C({code:e,...t.target===void 0?{}:{target:t.target},...n&&t.expectedRevision!==void 0?{expectedRevision:t.expectedRevision}:{},...n&&t.actualRevision!==void 0?{actualRevision:t.actualRevision}:{}})}function zt(o,t,e){for(let n=0;n<o.results.length;n+=1){let r=o.results[n];if(r?.status!=="error")continue;let i=t[n]?.label;return Dt(r.error,{...i===void 0?{}:{target:i},...e===void 0?{}:{expectedRevision:e},actualRevision:o.revision})}return new C({code:"GeneralException"})}function Qt(o,t){if(t.results.length!==o.length)throw new C({code:"GeneralException"});for(let e=0;e<o.length;e+=1){let n=t.results[e],r=o[e];if(n.status!=="ok")throw new C({code:"GeneralException",target:r.label});r.settle(n.value);}}var qt=class{#t=[];get size(){return this.#t.length}get pending(){return this.#t}push(t){this.#t.push(t);}take(){let t=this.#t;this.#t=[];for(let e of t)e.capture?.();return t}clear(){for(let t of this.#t)t.dispose?.();this.#t=[];}};function ge(o,t){if(Array.isArray(o)){for(let e of o)t(e);return}t(o);}var Ct=class{#t;#n;constructor(t,e){this.#t=t,this.#n=e;}add(t){this.#t.assertUsable(),ge(t,e=>{this.#e(e),this.#t.track(e);});}remove(t){this.#t.assertUsable(),ge(t,e=>{this.#e(e),this.#t.untrack(e);});}#e(t){this.#n(t)||a({code:"InvalidObjectPath"});}};var vt=class o{#t;#n=new qt;#e=new Set;#o=new Set;#i;#s;#r;#a=false;#l=null;#c=false;constructor(t){this.#t=t,this.#i={host:t.host,capabilities:t.capabilities,...t.author===void 0?{}:{author:t.author},revisionTextView:t.revisionTextView,queue:this.#n,session:t.id,roots:()=>t.roots(),assertUsable:e=>{this.#t.assertLive(e),this.#a&&a({code:"InvalidRequestContext",...e===void 0?{}:{target:e}});},isFinished:()=>this.#a,readRevision:()=>this.#l,register:e=>{this.#e.add(e);},track:e=>{this.#o.add(e);},untrack:e=>{this.#o.delete(e);},isTracked:e=>this.#o.has(e),disown:e=>{this.#e.delete(e),this.#o.delete(e);}},this.#s=new Ct(this.#i,e=>this.#e.has(e));}get document(){return this.#i.assertUsable("document"),this.#r??=this.#t.openDocument(this),this.#r}get capabilities(){return this.#t.capabilities}get trackedObjects(){return this.#s}async sync(){this.#i.assertUsable(),this.#c&&a({code:"InvalidRequestContext"});let t=this.#n.take();if(t.length!==0){this.#c=true;try{let e=t.filter(s=>!s.nullableLoad?.isNull),n=t.some(s=>s.sort==="write"),r,i=s=>s.dependencies?.some(d=>!d.isAddressable)??false;for(;e.some(i);){r??=n&&this.#l!==null?this.#l:this.#t.host.revision();let s=e.filter(h=>h.sort==="read"&&!i(h));s.length===0&&a({code:"InvalidObjectPath",target:e.find(i)?.label}),await this.#d(s,r);let d=new Set(s);e=e.filter(h=>!d.has(h)&&!h.nullableLoad?.isNull);}if(e.length){let s=r??(n&&this.#l!==null?this.#l:void 0);await this.#d(e,s);}}finally{for(let e of t)e.dispose?.();this.#c=false;}}}async#d(t,e){let n=me(t),r={operations:n.operations,...e===void 0?{}:{expectedRevision:e}};if(this.#t.host.prepare){let s={...r,expectedRevision:r.expectedRevision??this.#t.host.revision()};await this.#t.host.prepare(s);let d=this.#t.host.execute(s);if(!d.ok)throw zt(d,t,s.expectedRevision);Qt(t,d),this.#l=d.revision;return}let i=this.#t.host.execute(r);if(!i.ok)throw zt(i,t,e);Qt(t,i),(n.hasRead||n.hasWrite)&&(this.#l=i.revision);}get[Y](){return this.#i}static begin(t){let e=new o(t);return {context:e,adopt(n){for(let r of n)e.#h(r);},finish(){e.#u();}}}#h(t){let e=t.context;if(e===this)return;let n=e[Y];if(n.session!==this.#t.id)throw new C({code:"InvalidObjectPath"});if(!n.isFinished())throw new C({code:"ObjectInUse"});if(!n.isTracked(t))throw new C({code:"InvalidObjectPath"});let r=n.readRevision();n.disown(t),t[jt](this),this.#e.add(t),this.#o.add(t),r!==null&&this.#p(r);}#p(t){this.#l=this.#l===null?t:Math.min(this.#l,t);}#u(){if(!this.#a){this.#a=true,this.#n.clear();for(let t of this.#e)this.#o.has(t)||t[St]();this.#e.clear();}}};function At(o,t,e){if(o.select.length===0)return t;for(let n of o.select)t.includes(n)||a({code:"InvalidArgument",target:`${e}.${n}`});return o.select}function O(o,t){let e=o.address();return t==="span"?(e.kind!=="span"&&a({code:"InvalidObjectPath",target:o.label}),{start:e.span.start,end:e.span.end}):(e.kind!=="handle"&&a({code:"InvalidObjectPath",target:o.label}),t==="body"?{body:e.handle}:{paragraph:e.handle})}function at(o,t){return (typeof o!="string"||o.trim().length===0||o.length>255)&&a({code:"InvalidArgument",target:t}),o}var p=class extends ${revisionTextView(){return J(this.context).revisionTextView}loadTextInto(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"read",label:n,plan:e,settle:r=>{this.setLoadedProperty(t,P(r,n));}});}command(t,e,n){let r=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:r,plan:e,settle:i=>m(i,r),...n?{capture:n,dispose:n}:{}});}commandDiscarding(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:n,plan:e,settle:()=>{}});}commandAnswering(t,e,n,r){this.enqueue({sort:"write",label:t,plan:e,settle:n,...r?{capture:r,dispose:r}:{}});}read(t,e,n){this.enqueue({sort:"read",label:t,plan:e,settle:n});}selection(t,e){return At(t,e,this.path.label)}onLoad(t){this.selection(t,[]);}};var T=class extends ${#t;#n=[];constructor(t,e){super(t,e);}get items(){return this.loadedProperty("items")}fill(t,e){this.setLoadedProperty("items",this.#o(t,e,0,void 0)),this.#t={value:t,label:e};let n=this.#n.splice(0,this.#n.length);for(let r of n)this.#e(r,t);}onLoad(t){At(t,["items"],this.path.label);let e=this.path.isPending?void 0:this.listing();if(e===null)return;let n=`${this.path.label}.items`,r=t.skip??0,i=t.top;this.enqueue({sort:"read",label:n,plan:()=>{let s=e??this.listing();return s||a({code:"InvalidObjectPath",target:this.path.label}),s},settle:s=>{this.setLoadedProperty("items",this.#o(s,n,r,i));}});}edge(t,e,n){let r=`${this.path.label}.${e}()`,i=this.promised(r,n),s=this.path.isPending?void 0:this.listing();if(s===null){let d={edge:t,target:r,nullable:n,item:i};return this.#t?this.#e(d,this.#t.value):this.#n.push(d),i}return this.enqueue({sort:"read",label:r,plan:()=>{let d=s??this.listing();return d||a({code:"InvalidObjectPath",target:this.path.label}),d},settle:d=>{this.#e({edge:t,target:r,nullable:n,item:i},d);}}),i}#e(t,e){let{edge:n,target:r,nullable:i,item:s}=t,d=this.size(e,r);if(d===0){i||a({code:"ItemNotFound",target:r}),s.hydrateNull();return}let h=this.addressAt(e,r,n==="first"?0:d-1);h||a({code:"ItemNotFound",target:r}),s.hydrateAddress(h);}#o(t,e,n,r){let i=this.size(t,e),s=r===void 0?i:Math.min(i,n+r),d=[];for(let h=n;h<s;h+=1){let v=this.addressAt(t,e,h);v&&d.push(this.itemAt(`${e}[${String(h)}]`,v));}return d}},x=class extends T{size(t,e){return A(t,e).length}addressAt(t,e,n){let r=A(t,e)[n];return r?{kind:"handle",handle:r}:void 0}};var H=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get code(){return this.loadedProperty("code")}set code(t){if(this.requireUsablePath(),(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:`${this.path.label}.code`}),this.#t){this.#t.code=t;return}let e={code:t};this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setFieldCode",field:this.#e(),code:e.code}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}delete(){this.#n("deleteField");}updateResult(){this.#n("updateFieldResult");}#n(t){this.requireUsablePath(),this.commandAnswering(this.path.label,()=>({op:t,field:this.#e()}),e=>m(e,this.path.label));}onLoad(t){this.selection(t,["code"]).length!==0&&this.read(this.path.label,()=>({op:"getField",field:this.#e()}),e=>{e.kind!=="field"&&a({code:"GeneralException",target:this.path.label}),this.setLoadedProperty("code",e.field.code);});}#e(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},M=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getFields",span:O(this.path,this.#t)}}size(t,e){return A(t,e).length}addressAt(t,e,n){let r=A(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return H.at(this.context,t,e)}promised(t,e){return H.promised(this.context,t,e)}};var qe=["width","height","lockAspectRatio","altTextDescription"],F=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get width(){return this.loadedProperty("width")}set width(t){this.#n("width",t);}get height(){return this.loadedProperty("height")}set height(t){this.#n("height",t);}get lockAspectRatio(){return this.loadedProperty("lockAspectRatio")}set lockAspectRatio(t){typeof t!="boolean"&&a({code:"InvalidArgument",target:`${this.path.label}.lockAspectRatio`}),this.#e({lockAspectRatio:t});}get altTextDescription(){return this.loadedProperty("altTextDescription")}set altTextDescription(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.altTextDescription`}),this.#e({altTextDescription:t});}delete(){let t=`${this.path.label}.delete`;this.commandAnswering(t,()=>({op:"deleteInlinePicture",picture:this.#o()}),e=>m(e,t));}onLoad(t){let e=this.selection(t,qe);e.length&&this.read(this.path.label,()=>({op:"getInlinePicture",picture:this.#o()}),n=>{n.kind!=="inlinePicture"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.picture[r]);});}#n(t,e){(typeof e!="number"||!Number.isFinite(e)||e<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#e({[t]:e});}#e(t){if(this.requireUsablePath(),this.#t){Object.assign(this.#t,t);return}let e=t;this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setInlinePicture",picture:this.#o(),properties:e}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}#o(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},V=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getInlinePictures",span:O(this.path,this.#t)}}size(t,e){return A(t,e).length}addressAt(t,e,n){let r=A(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return F.at(this.context,t,e)}promised(t,e){return F.promised(this.context,t,e)}};function D(o,t,e=0){return (!Number.isInteger(o)||o<e)&&a({code:"InvalidArgument",target:t}),o}function Xt(o,t){return (!Array.isArray(o)||o.some(e=>!Array.isArray(e)||e.some(n=>typeof n!="string")))&&a({code:"InvalidArgument",target:t}),o.map(e=>[...e])}function fe(o,t){return o!=="Start"&&o!=="End"&&a({code:"InvalidArgument",target:t}),o==="Start"?"start":"end"}var W=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get values(){return this.loadedProperty("values")}set values(t){let e=Xt(t,`${this.path.label}.values`);this.command("values",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"values",values:e}}));}get style(){return this.loadedProperty("style")}set style(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.style`}),this.command("style",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"properties",styleId:t}}));}get headerRowCount(){return this.loadedProperty("headerRowCount")}set headerRowCount(t){D(t,`${this.path.label}.headerRowCount`),this.command("headerRowCount",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"properties",headerRowCount:t}}));}get rowCount(){return this.loadedProperty("rowCount")}get columnCount(){return this.loadedProperty("columnCount")}get rows(){return this.#t??=dt.of(this.context,`${this.path.label}.rows`,this.path,()=>({op:"getTableRows",table:this.path.handle()}))}getCell(t,e){let n=`${this.path.label}.getCell`;D(t,n),D(e,n);let r=tt.promised(this.context,n);return this.read(n,()=>({op:"getTableCell",table:this.path.handle(),rowIndex:t,cellIndex:e}),i=>r.hydrateAddress({kind:"handle",handle:u(i,n)})),r}addRows(t,e,n){let r=`${this.path.label}.addRows`,i=fe(t,r);D(e,r,1);let s=n===void 0?void 0:Xt(n,r),d=dt.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addRows",location:i,count:e,...s?{values:s}:{}}}),h=>d.fill(h,r)),d}addColumns(t,e,n){let r=`${this.path.label}.addColumns`,i=fe(t,r);D(e,r,1);let s=n===void 0?void 0:Xt(n,r);this.command("addColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addColumns",location:i,count:e,...s?{values:s}:{}}}));}deleteRows(t,e){e===void 0&&(e=1),D(t,this.path.label),D(e,this.path.label,1),this.command("deleteRows",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"deleteRows",index:t,count:e}}));}deleteColumns(t,e){e===void 0&&(e=1),D(t,this.path.label),D(e,this.path.label,1),this.command("deleteColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"deleteColumns",index:t,count:e}}));}delete(){this.command("delete",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"delete"}}));}onLoad(t){let e=this.selection(t,["values","style","headerRowCount","rowCount","columnCount"]);this.read(this.path.label,()=>({op:"getTable",table:this.path.handle()}),n=>{n.kind!=="table"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.table[r]);});}},st=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get cells(){return this.#t??=Rt.of(this.context,`${this.path.label}.cells`,this.path,()=>({op:"getTableCells",row:this.path.handle()}))}},tt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=I.promisedStory(this.context,t);return this.read(t,()=>({op:"getTableCellBody",cell:this.path.handle()}),n=>e.hydrateAddress({kind:"handle",handle:u(n,t)})),this.#t=e,e}get value(){return this.loadedProperty("value")}set value(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.value`}),this.command("value",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{value:t}}));}get columnWidth(){return this.loadedProperty("columnWidth")}set columnWidth(t){(typeof t!="number"||!Number.isFinite(t)||t<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.columnWidth`}),this.command("columnWidth",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{columnWidth:t}}));}get shadingColor(){return this.loadedProperty("shadingColor")}set shadingColor(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.shadingColor`}),this.command("shadingColor",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{shadingColor:t}}));}get verticalAlignment(){return this.loadedProperty("verticalAlignment")}set verticalAlignment(t){t!=="Top"&&t!=="Center"&&t!=="Bottom"&&a({code:"InvalidArgument",target:`${this.path.label}.verticalAlignment`}),this.command("verticalAlignment",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{verticalAlignment:t}}));}onLoad(t){let e=this.selection(t,["value","columnWidth","shadingColor","verticalAlignment"]);this.read(this.path.label,()=>({op:"getTableCellProperties",cell:this.path.handle()}),n=>{n.kind!=="tableCell"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.cell[r]);});}},U=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}static over(t,e,n,r){return o.of(t,e,n,()=>({op:"getTables",scope:r()}))}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return W.at(this.context,t,e)}promised(t,e){return W.promised(this.context,t,e)}},dt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return st.at(this.context,t,e)}promised(t,e){return st.promised(this.context,t,e)}},Rt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return tt.at(this.context,t,e)}promised(t,e){return tt.promised(this.context,t,e)}};var Kt=(i=>(i.replace="Replace",i.start="Start",i.end="End",i.before="Before",i.after="After",i))(Kt||{}),Zt=(s=>(s.mixed="Mixed",s.unknown="Unknown",s.left="Left",s.centered="Centered",s.right="Right",s.justified="Justified",s))(Zt||{}),Yt=(e=>(e.portrait="Portrait",e.landscape="Landscape",e))(Yt||{}),Jt=(n=>(n.off="Off",n.trackAll="TrackAll",n.trackMineOnly="TrackMineOnly",n))(Jt||{}),_t=(r=>(r.mixed="Mixed",r.top="Top",r.center="Center",r.bottom="Bottom",r))(_t||{}),te=(d=>(d.line="Line",d.page="Page",d.next="Next",d.sectionNext="SectionNext",d.sectionContinuous="SectionContinuous",d.sectionEven="SectionEven",d.sectionOdd="SectionOdd",d))(te||{}),ee=(y=>(y.unknown="Unknown",y.richText="RichText",y.plainText="PlainText",y.picture="Picture",y.buildingBlockGallery="BuildingBlockGallery",y.checkBox="CheckBox",y.comboBox="ComboBox",y.datePicker="DatePicker",y.dropDownList="DropDownList",y.group="Group",y.repeatingSection="RepeatingSection",y.plainTextInline="PlainTextInline",y.plainTextParagraph="PlainTextParagraph",y.richTextInline="RichTextInline",y.richTextParagraphs="RichTextParagraphs",y.richTextTable="RichTextTable",y.richTextTableCell="RichTextTableCell",y.richTextTableRow="RichTextTableRow",y))(ee||{});var Be=["Replace","Start","End"],$e=["Start","End"],He=["Replace","Start","End"],Me=["Before","After"],Fe=["Replace","Start","End","Before","After"],Ve=["Select","Start","End"];function lt(o,t,e){return (typeof o!="string"||!t.includes(o))&&a({code:"InvalidArgument",target:e}),o}var be=(o,t)=>lt(o,Be,t),ye=(o,t)=>lt(o,$e,t),xe=(o,t)=>lt(o,He,t),Ce=(o,t)=>lt(o,Me,t),Pt=(o,t)=>lt(o,Fe,t),Bt=(o,t)=>o===void 0?"Select":lt(o,Ve,t);function k(o,t){return typeof o!="string"&&a({code:"InvalidArgument",target:t}),/[\r\n\v\f\u2028\u2029]/.test(o)&&a({code:"InvalidArgument",target:t}),o}var We=8,oe=(d=>(d.custom="Custom",d.solid="Solid",d.hollow="Hollow",d.square="Square",d.diamonds="Diamonds",d.arrow="Arrow",d.checkmark="Checkmark",d))(oe||{}),re=(s=>(s.none="None",s.arabic="Arabic",s.upperRoman="UpperRoman",s.lowerRoman="LowerRoman",s.upperLetter="UpperLetter",s.lowerLetter="LowerLetter",s))(re||{}),j=class o extends p{#t;#n=new Map;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get paragraphs(){return this.#t??=L.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getListParagraphs",list:this.#o()})),this.#t}getLevelParagraphs(t){let e=`${this.path.label}.getLevelParagraphs`,n=ne(t,e);return L.overListing(this.context,e,this.path,()=>({op:"getListParagraphs",list:this.#o(),level:n}))}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n);e!=="Start"&&e!=="End"&&e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:n});let i=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertListParagraph",list:this.#o(),where:e==="Start"||e==="Before"?"start":"end",text:r}),s=>{i.hydrateAddress({kind:"handle",handle:u(s,n)});}),i}setLevelBullet(t,e,n,r){this.#e(t,{bullet:e,...n===void 0?{}:{charCode:n},...r===void 0?{}:{fontName:r}});}setLevelNumbering(t,e,n){this.#e(t,{numbering:e,...n===void 0?{}:{formatString:[...n]}});}setLevelStartingNumber(t,e){this.#e(t,{startingNumber:e});}setLevelIndents(t,e,n){this.#e(t,{textIndent:e,bulletNumberPictureIndent:n});}#e(t,e){let n=`${this.path.label}.levelFormat`,r=ne(t,n);this.requireUsablePath();let i=this.#n.get(r);if(i){Object.assign(i,e),"bullet"in e&&(delete i.numbering,delete i.formatString),"numbering"in e&&(delete i.bullet,delete i.charCode,delete i.fontName);return}let s={...e};this.#n.set(r,s),this.commandAnswering(n,()=>({op:"setListLevelFormat",list:this.#o(),level:r,format:s}),d=>{m(d,n);},()=>{this.#n.get(r)===s&&this.#n.delete(r);});}onLoad(t){if(!this.selection(t,["id"]).includes("id"))return;let e=`${this.path.label}.id`;this.read(e,()=>({op:"getListId",list:this.#o()}),n=>{this.setLoadedProperty("id",Nt(n,e));});}#o(){return this.requireAddressable(),this.path.handle()}},ct=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getById(t){let e=`${this.path.label}.getById`,n=Ue(t,e),r=this.#t,i=j.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getListById",body:r,id:n}),settle:s=>{i.hydrateAddress({kind:"handle",handle:u(s,e)});}}),i}listing(){return {op:"getLists",body:this.#t}}itemAt(t,e){return j.at(this.context,t,e)}promised(t,e){return j.promised(this.context,t,e)}},ht=class o extends p{static of(t,e,n){return new o(t,c.derived(e,n))}constructor(t,e){super(t,e);}get level(){return this.loadedProperty("level")}set level(t){let e=`${this.path.label}.level`,n=ne(t,e);this.commandAnswering(e,()=>({op:"setListLevel",paragraph:this.#t(),level:n}),r=>{m(r,e);});}onLoad(t){if(!this.selection(t,["level"]).includes("level"))return;let e=`${this.path.label}.level`;this.read(e,()=>({op:"getListLevel",paragraph:this.#t()}),n=>{this.setLoadedProperty("level",Nt(n,e));});}#t(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}};function ne(o,t){return (!Number.isInteger(o)||o<0||o>We)&&a({code:"InvalidArgument",target:t}),o}function Ue(o,t){return (!Number.isInteger(o)||o<=0)&&a({code:"InvalidArgument",target:t}),o}var ie=(f=>(f.mixed="Mixed",f.none="None",f.hidden="Hidden",f.dotLine="DotLine",f.single="Single",f.word="Word",f.double="Double",f.thick="Thick",f.dotted="Dotted",f.dottedHeavy="DottedHeavy",f.dashLine="DashLine",f.dashLineHeavy="DashLineHeavy",f.dashLineLong="DashLineLong",f.dashLineLongHeavy="DashLineLongHeavy",f.dotDashLine="DotDashLine",f.dotDashLineHeavy="DotDashLineHeavy",f.twoDotDashLine="TwoDotDashLine",f.twoDotDashLineHeavy="TwoDotDashLineHeavy",f.wave="Wave",f.waveHeavy="WaveHeavy",f.waveDouble="WaveDouble",f))(ie||{}),Ge=["bold","italic","color","name","size","underline","strikeThrough","highlightColor","subscript","superscript"],E=class o extends p{#t;#n;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}get bold(){return this.loadedProperty("bold")}set bold(t){this.#e("bold",Ot(t,`${this.path.label}.bold`));}get italic(){return this.loadedProperty("italic")}set italic(t){this.#e("italic",Ot(t,`${this.path.label}.italic`));}get color(){return this.loadedProperty("color")}set color(t){this.#e("color",$t(t,`${this.path.label}.color`));}get name(){return this.loadedProperty("name")}set name(t){this.#e("name",$t(t,`${this.path.label}.name`));}get size(){return this.loadedProperty("size")}set size(t){this.#e("size",ze(t,`${this.path.label}.size`));}get underline(){return this.loadedProperty("underline")}set underline(t){this.#e("underline",$t(t,`${this.path.label}.underline`));}get highlightColor(){return this.loadedProperty("highlightColor")}set highlightColor(t){this.#e("highlightColor",t===null?null:$t(t,`${this.path.label}.highlightColor`));}get strikeThrough(){return this.loadedProperty("strikeThrough")}set strikeThrough(t){this.#e("strikeThrough",Ot(t,`${this.path.label}.strikeThrough`));}get subscript(){return this.loadedProperty("subscript")}set subscript(t){this.#e("subscript",Ot(t,`${this.path.label}.subscript`));}get superscript(){return this.loadedProperty("superscript")}set superscript(t){this.#e("superscript",Ot(t,`${this.path.label}.superscript`));}onLoad(t){let e=this.selection(t,Ge);if(e.length===0)return;let n=`${this.path.label}.font`;this.read(n,()=>({op:"getFont",span:this.#o()}),r=>{let i=Wt(r,n);for(let s of e)this.setLoadedProperty(s,i[s]);});}#e(t,e){if(this.requireUsablePath(),this.#n){this.#n[t]=e,t==="subscript"&&e===true&&(this.#n.superscript=false),t==="superscript"&&e===true&&(this.#n.subscript=false);return}let n={[t]:e};t==="subscript"&&e===true&&(n.superscript=false),t==="superscript"&&e===true&&(n.subscript=false),this.#n=n;let r=`${this.path.label}.${t}`;this.commandAnswering(this.path.label,()=>({op:"setFont",span:this.#o(),font:n}),i=>{m(i,r);},()=>{this.#n===n&&(this.#n=void 0);});}#o(){return this.requireAddressable(),O(this.path,this.#t)}};function Ot(o,t){return typeof o!="boolean"&&a({code:"InvalidArgument",target:t}),o}function ze(o,t){return (typeof o!="number"||!Number.isFinite(o))&&a({code:"InvalidArgument",target:t}),o}function $t(o,t){return (typeof o!="string"||o.length===0)&&a({code:"InvalidArgument",target:t}),o}var Qe=16,w=class o extends p{#t;#n;#e;#o;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get uniqueLocalId(){return this.loadedProperty("uniqueLocalId")}get style(){return this.loadedProperty("style")}set style(t){this.#i("style",at(t,`${this.path.label}.style`));}get font(){return this.#t??=E.of(this.context,`${this.path.label}.font`,this.path,"paragraph"),this.#t}get alignment(){return this.loadedProperty("alignment")}set alignment(t){this.#i("alignment",Ke(t,`${this.path.label}.alignment`));}get firstLineIndent(){return this.loadedProperty("firstLineIndent")}set firstLineIndent(t){this.#i("firstLineIndent",pt(t,`${this.path.label}.firstLineIndent`));}get leftIndent(){return this.loadedProperty("leftIndent")}set leftIndent(t){this.#i("leftIndent",pt(t,`${this.path.label}.leftIndent`));}get rightIndent(){return this.loadedProperty("rightIndent")}set rightIndent(t){this.#i("rightIndent",pt(t,`${this.path.label}.rightIndent`));}get lineSpacing(){return this.loadedProperty("lineSpacing")}set lineSpacing(t){this.#i("lineSpacing",pt(t,`${this.path.label}.lineSpacing`));}get spaceBefore(){return this.loadedProperty("spaceBefore")}set spaceBefore(t){this.#i("spaceBefore",pt(t,`${this.path.label}.spaceBefore`));}get spaceAfter(){return this.loadedProperty("spaceAfter")}set spaceAfter(t){this.#i("spaceAfter",pt(t,`${this.path.label}.spaceAfter`));}get list(){return this.#n??=this.#s(`${this.path.label}.list`),this.#n}getRange(t="Whole"){let e=`${this.path.label}.getRange`;["Whole","Content","Start","End","Before","After"].includes(t)||a({code:"InvalidArgument",target:e});let n=b.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{paragraph:this.#r()},location:t}),r=>{n.hydrateAddress({kind:"span",span:R(r,e)});}),n}startNewList(){let t=`${this.path.label}.startNewList`,e=j.promised(this.context,t,false);return this.commandAnswering(t,()=>({op:"startNewList",paragraph:this.#r()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),e}attachToList(t,e){let n=`${this.path.label}.attachToList`;(!Number.isSafeInteger(t)||t<=0||!Number.isInteger(e)||e<0||e>8)&&a({code:"InvalidArgument",target:n});let r=j.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"attachToList",paragraph:this.#r(),listId:t,level:e}),i=>{r.hydrateAddress({kind:"handle",handle:u(i,n)});}),r}detachFromList(){let t=`${this.path.label}.detachFromList`;this.commandAnswering(t,()=>({op:"detachFromList",paragraph:this.#r()}),e=>{m(e,t);});}get listItem(){return this.#e??=ht.of(this.context,`${this.path.label}.listItem`,this.path),this.#e}clear(){this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{paragraph:this.#r()},text:""}));}delete(){this.command("delete",()=>({op:"deleteParagraph",paragraph:this.#r()}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=xe(e,n),s=b.promised(this.context,n,false);return this.commandAnswering(n,()=>i==="Replace"?{op:"replaceSpan",span:{paragraph:this.#r()},text:r}:{op:"insertText",at:{paragraph:this.#r(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:R(d,n)});}),s}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n),i=Ce(e,n),s=o.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:this.#r()},where:i==="Before"?"before":"after",text:r}),d=>{d.kind!=="handle"&&a({code:"GeneralException",target:n}),s.hydrateAddress({kind:"handle",handle:d.handle});}),s}split(t,e,n){let r=`${this.path.label}.split`,i=Ze(t,r),s=Ae(e,`${r}.trimDelimiters`),d=Ae(n,`${r}.trimSpacing`),h=N.answered(this.context,r,this.path);return this.commandAnswering(r,()=>({op:"splitParagraph",paragraph:this.#r(),delimiters:i,...s?{trimDelimiters:true}:{},...d?{trimSpacing:true}:{}}),v=>{h.fill(v,r);}),h}onLoad(t){let e=this.selection(t,["text","uniqueLocalId",...ve]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#r(),projection:this.revisionTextView()})),e.includes("uniqueLocalId")&&this.loadTextInto("uniqueLocalId",()=>({op:"getParagraphId",paragraph:this.#r()}));let n=ve.filter(i=>e.includes(i));if(n.length===0)return;let r=`${this.path.label}.paragraphFormat`;this.read(r,()=>({op:"getParagraphFormat",paragraph:{paragraph:this.#r()}}),i=>{let s=Ut(i,r);for(let d of n)this.setLoadedProperty(d,s[d]);});}#i(t,e){if(this.requireUsablePath(),this.#o){this.#o[t]=e;return}let n={[t]:e};this.#o=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.paragraphFormat`,()=>({op:"setParagraphFormat",paragraph:{paragraph:this.#r()},format:n}),i=>{m(i,r);},()=>{this.#o===n&&(this.#o=void 0);});}#s(t){let e=j.promised(this.context,t,false);return this.read(t,()=>({op:"getParagraphList",paragraph:this.#r()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),e}#r(){return this.requireAddressable(),this.path.handle()}},ve=["style","alignment","firstLineIndent","leftIndent","rightIndent","lineSpacing","spaceBefore","spaceAfter"],Xe=["Left","Centered","Right","Justified"];function Ke(o,t){return Xe.includes(o)||a({code:"InvalidArgument",target:t}),o}function pt(o,t){return (typeof o!="number"||!Number.isFinite(o))&&a({code:"InvalidArgument",target:t}),o}function Ze(o,t){(!Array.isArray(o)||o.length===0||o.length>Qe)&&a({code:"InvalidArgument",target:t});for(let e of o)(typeof e!="string"||e.length===0)&&a({code:"InvalidArgument",target:t});return [...o]}function Ae(o,t){return o!==void 0&&typeof o!="boolean"&&a({code:"InvalidArgument",target:t}),o===true}var L=class o extends T{#t;static of(t,e,n){return new o(t,c.derived(e,n),null)}static overListing(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){if(this.#t)return this.#t();let t=this.path.address();return t.kind==="handle"?{op:"getParagraphs",body:t.handle}:{op:"getSpanParagraphs",span:t.span}}size(t,e){return A(t,e).length}addressAt(t,e,n){let r=A(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return w.at(this.context,t,e)}promised(t,e){return w.promised(this.context,t,e)}},N=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}static answered(t,e,n){return new o(t,c.derived(e,n),null)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t?this.#t():null}size(t,e){return Et(t,e).length}addressAt(t,e,n){let r=Et(t,e)[n];return r?{kind:"span",span:r}:void 0}itemAt(t,e){return b.at(this.context,t,e)}promised(t,e){return b.promised(this.context,t,e)}};var Pe=4096,q=class o extends p{#t;#n=new Map;#e;#o;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get tag(){return this.loadedProperty("tag")}set tag(t){this.#s("tag",{tag:ae(t,`${this.path.label}.tag`)});}get title(){return this.loadedProperty("title")}set title(t){this.#s("title",{title:ae(t,`${this.path.label}.title`)});}get subtype(){return this.loadedProperty("subtype")}get isBound(){return this.loadedProperty("isBound")}get cannotDelete(){let t=this.loadedProperty("lock");return t==="sdtLocked"||t==="sdtContentLocked"}set cannotDelete(t){this.#r("cannotDelete",t);}get cannotEdit(){let t=this.loadedProperty("lock");return t==="contentLocked"||t==="sdtContentLocked"}set cannotEdit(t){this.#r("cannotEdit",t);}get placeholderShown(){return this.loadedProperty("placeholderShown")}get temporary(){return this.loadedProperty("temporary")}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#e??=L.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getContentControlParagraphs",contentControl:this.#a()})),this.#e}get contentControls(){return this.#o??=B.of(this.context,`${this.path.label}.contentControls`,this.path,{contentControl:this.#a()}),this.#o}getRange(t){let e=`${this.path.label}.getRange`,n=Ye(t??"Whole",e),r=this.#n.get(n);if(r)return r;let i=this.#i(e,n);return this.#n.set(n,i),i}setValue(t){let e=`${this.path.label}.setValue`,n=Je(t,e);this.command("setValue",()=>({op:"setContentControlValue",contentControl:this.#a(),value:n}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=e==="Replace"?"replace":e==="Start"?"start":e==="End"?"end":a({code:"InvalidArgument",target:n}),s=b.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertContentControlText",contentControl:this.#a(),text:r,at:i}),d=>{s.hydrateAddress({kind:"span",span:R(d,n)});}),s}delete(t){let e=`${this.path.label}.delete`;typeof t!="boolean"&&a({code:"InvalidArgument",target:e}),this.command("delete",()=>({op:"deleteContentControl",contentControl:this.#a(),keepContent:t}));}onLoad(t){let e=this.selection(t,["id","tag","title","subtype","isBound","text","cannotDelete","cannotEdit","placeholderShown","temporary"]);if(e.includes("id")&&this.loadTextInto("id",()=>({op:"getContentControlFileId",contentControl:this.#a()})),e.includes("tag")&&this.loadTextInto("tag",()=>({op:"getContentControlTag",contentControl:this.#a()})),e.includes("title")&&this.loadTextInto("title",()=>({op:"getContentControlTitle",contentControl:this.#a()})),e.includes("subtype")&&this.loadTextInto("subtype",()=>({op:"getContentControlSubtype",contentControl:this.#a()})),e.includes("isBound")){let r=`${this.path.label}.isBound`;this.read(r,()=>({op:"getContentControlIsBound",contentControl:this.#a()}),i=>{this.setLoadedProperty("isBound",_(i,r));});}if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getContentControlText",contentControl:this.#a(),projection:this.revisionTextView()})),e.includes("cannotDelete")||e.includes("cannotEdit")){let r=`${this.path.label}.lock`;this.read(r,()=>({op:"getContentControlLock",contentControl:this.#a()}),i=>{this.setLoadedProperty("lock",P(i,r));});}if(e.includes("placeholderShown")){let r=`${this.path.label}.placeholderShown`;this.read(r,()=>({op:"getContentControlPlaceholderShown",contentControl:this.#a()}),i=>{this.setLoadedProperty("placeholderShown",_(i,r));});}if(!e.includes("temporary"))return;let n=`${this.path.label}.temporary`;this.read(n,()=>({op:"getContentControlTemporary",contentControl:this.#a()}),r=>{this.setLoadedProperty("temporary",_(r,n));});}#i(t,e){let n=b.promised(this.context,t,false);return this.read(t,()=>({op:"getContentControlRange",contentControl:this.#a(),location:e}),r=>{n.hydrateAddress({kind:"span",span:R(r,t)});}),n}#s(t,e){this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#a(),...e}));}#r(t,e){let n=`${this.path.label}.${t}`;if(typeof e!="boolean"&&a({code:"InvalidArgument",target:n}),this.requireUsablePath(),this.#t){this.#t[t]=e;return}let r={[t]:e};this.#t=r,this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#a(),...r}),()=>{this.#t===r&&(this.#t=void 0);});}#a(){return this.requireAddressable(),this.path.handle()}},B=class o extends x{#t;#n;static of(t,e,n,r){return new o(t,c.derived(e,n),r,()=>({op:"getContentControls",scope:r}))}constructor(t,e,n,r){super(t,e),this.#t=n,this.#n=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getById(t){let e=`${this.path.label}.getById`;Number.isInteger(t)||a({code:"InvalidArgument",target:e});let n=this.#t,r=q.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getContentControlById",scope:n,id:t}),settle:i=>{r.hydrateAddress({kind:"handle",handle:u(i,e)});}}),r}getByTag(t){let e=`${this.path.label}.getByTag`,n=Re(t,e),r=this.#t;return new o(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTag",scope:r,tag:n}))}getByTitle(t){let e=`${this.path.label}.getByTitle`,n=Re(t,e),r=this.#t;return new o(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTitle",scope:r,title:n}))}listing(){return this.#n()}itemAt(t,e){return q.at(this.context,t,e)}promised(t,e){return q.promised(this.context,t,e)}};function ae(o,t){return (typeof o!="string"||o.length>Pe)&&a({code:"InvalidArgument",target:t}),o}function Re(o,t){let e=ae(o,t);return e.length===0&&a({code:"InvalidArgument",target:t}),e}function Ye(o,t){switch(o){case "Whole":return "whole";case "Content":return "content";case "Start":return "start";case "End":return "end";case "Before":return "before";case "After":return "after";default:return a({code:"InvalidArgument",target:t})}}function Je(o,t){(typeof o!="object"||o===null)&&a({code:"InvalidArgument",target:t});let e=o;if(e.kind==="text"||e.kind==="listItem"){let n=e.kind==="text"?e.text:e.value;return (typeof n!="string"||n.length>Pe)&&a({code:"InvalidArgument",target:t}),e.kind==="text"?{kind:"text",text:n}:{kind:"listItem",value:n}}if(e.kind==="checkbox")return typeof e.checked!="boolean"&&a({code:"InvalidArgument",target:t}),{kind:"checkbox",checked:e.checked};if(e.kind==="date")return (typeof e.iso!="string"||e.iso.length>64)&&a({code:"InvalidArgument",target:t}),{kind:"date",iso:e.iso};a({code:"InvalidArgument",target:t});}function _e(o,t){return t<1||t>12?0:t===2?o%4===0&&o%100!==0||o%400===0?29:28:t===4||t===6||t===9||t===11?30:31}function Oe(o){if(o.length===0)return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/.exec(o.trim());if(!t)return null;let e=Number(t[1]),n=Number(t[2]),r=Number(t[3]),i=_e(e,n);if(e===0||i===0||r<1||r>i)return null;let s=Number(t[4]),d=Number(t[5]),h=Number(t[6]);if(s>23||d>59||h>59)return null;let v=t[7],K=v===void 0?0:Number(v.padEnd(3,"0").slice(0,3));if(Number.isNaN(K))return null;let rt=`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}.${String(K).padStart(3,"0")}Z`,Lt=Date.parse(rt);if(Number.isNaN(Lt))return null;let g=t[8];if(g==="Z")return new Date(Lt);let Z=Number(g.slice(1,3)),it=Number(g.slice(4,6));if(it>59||Z>14||Z===14&&it!==0)return null;let Vt=g[0]==="+"?1:-1,wt=new Date(Lt-Vt*(Z*36e5+it*6e4));return Number.isNaN(wt.getTime())?null:wt}var Ht=class extends p{hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get authorName(){return this.loadedProperty("authorName")}get creationDate(){return this.loadedProperty("creationDate")}get id(){return this.loadedProperty("id")}get text(){return this.loadedProperty("text")}delete(){this.command("delete",()=>({op:"deleteComment",comment:this.commentHandle()}));}loadCommentFields(t,e){let n=this.selection(t,["authorName","creationDate","id","text",...e]);if(n.includes("authorName")&&this.loadTextInto("authorName",()=>({op:"getCommentAuthor",comment:this.commentHandle()})),n.includes("text")&&this.loadTextInto("text",()=>({op:"getCommentText",comment:this.commentHandle()})),n.includes("id")&&this.loadTextInto("id",()=>({op:"getCommentId",comment:this.commentHandle()})),n.includes("creationDate")){let i=`${this.path.label}.creationDate`;this.read(i,()=>({op:"getCommentDate",comment:this.commentHandle()}),s=>{this.setLoadedProperty("creationDate",Oe(P(s,i)));});}if(!n.includes("resolved"))return;let r=`${this.path.label}.resolved`;this.read(r,()=>({op:"getCommentResolved",comment:this.commentHandle()}),i=>{this.setLoadedProperty("resolved",_(i,r));});}commentHandle(){return this.requireAddressable(),this.path.handle()}},nt=class o extends Ht{static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}onLoad(t){this.loadCommentFields(t,[]);}},It=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return nt.at(this.context,t,e)}promised(t,e){return nt.promised(this.context,t,e)}},G=class o extends Ht{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}get resolved(){return this.loadedProperty("resolved")}set resolved(t){let e=`${this.path.label}.resolved`;typeof t!="boolean"&&a({code:"InvalidArgument",target:e}),this.commandAnswering(e,()=>({op:"setCommentResolved",comment:this.commentHandle(),resolved:t}),n=>{m(n,e);});}get replies(){return this.#t??=It.of(this.context,`${this.path.label}.replies`,this.path,()=>({op:"getCommentReplies",comment:this.commentHandle()})),this.#t}getRange(){let t=`${this.path.label}.getRange`,e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getCommentRange",comment:this.commentHandle()}),n=>{e.hydrateAddress({kind:"span",span:R(n,t)});}),e}reply(t){let e=`${this.path.label}.reply`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&a({code:"NotSupported",target:e});let r=nt.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"replyToComment",comment:this.commentHandle(),text:t,author:n}),i=>{r.hydrateAddress({kind:"handle",handle:u(i,e)});}),r}onLoad(t){this.loadCommentFields(t,["resolved"]);}},z=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return G.at(this.context,t,e)}promised(t,e){return G.promised(this.context,t,e)}},et=class o extends p{static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get author(){return this.loadedProperty("author")}get date(){return this.loadedProperty("date")}get type(){return this.loadedProperty("type")}get range(){let t=`${this.path.label}.range`,e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getRevisionRange",revision:this.#t()}),n=>{e.hydrateAddress({kind:"span",span:R(n,t)});}),e}accept(){this.command("accept",()=>({op:"acceptRevision",revision:this.#t()}));}reject(){this.command("reject",()=>({op:"rejectRevision",revision:this.#t()}));}onLoad(t){let e=this.selection(t,["author","date","type"]);if(e.includes("author")&&this.loadTextInto("author",()=>({op:"getRevisionAuthor",revision:this.#t()})),e.includes("type")&&this.loadTextInto("type",()=>({op:"getRevisionType",revision:this.#t()})),!e.includes("date"))return;let n=`${this.path.label}.date`;this.read(n,()=>({op:"getRevisionDate",revision:this.#t()}),r=>{this.setLoadedProperty("date",Oe(P(r,n)));});}static batchHandle(t,e){return (!(t instanceof o)||t.context!==e)&&a({code:"InvalidArgument",target:"RevisionCollection.resolve"}),t.#t()}#t(){return this.requireAddressable(),this.path.handle()}},Q=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}acceptAll(){let t=this.#t;this.commandOn("acceptAll",()=>({op:"acceptAllRevisions",body:t}));}rejectAll(){let t=this.#t;this.commandOn("rejectAll",()=>({op:"rejectAllRevisions",body:t}));}resolve(t,e){let n=`${this.path.label}.resolve`;(!["accept","reject"].includes(t)||e!==void 0&&!Array.isArray(e))&&a({code:"InvalidArgument",target:n});let r=e===void 0?void 0:[...e],{result:i,fill:s}=ue(n);return this.enqueue({sort:"write",label:n,plan:()=>({op:"resolveRevisionBatch",body:this.#t,action:t,...r===void 0?{}:{revisions:r.map(d=>et.batchHandle(d,this.context))}}),settle:d=>{d.kind!=="revisionBatch"&&a({code:"GeneralException",target:n}),s(d.result);}}),i}listing(){return {op:"getRevisions",body:this.#t}}itemAt(t,e){return et.at(this.context,t,e)}promised(t,e){return et.promised(this.context,t,e)}commandOn(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:n,plan:e,settle:r=>{m(r,n);}});}};var tn=new Set(["matchCase","matchWholeWord","ignorePunct","ignoreSpace","matchWildcards"]);function Mt(o,t){if(o===void 0)return;typeof o!="object"&&a({code:"InvalidArgument",target:t});for(let[n,r]of Object.entries(o))tn.has(n)||a({code:"InvalidArgument",target:`${t}.${n}`}),r!==void 0&&typeof r!="boolean"&&a({code:"InvalidArgument",target:`${t}.${n}`});let e={...o.matchCase===void 0?{}:{matchCase:o.matchCase},...o.matchWholeWord===void 0?{}:{matchWholeWord:o.matchWholeWord},...o.ignorePunct===void 0?{}:{ignorePunct:o.ignorePunct},...o.ignoreSpace===void 0?{}:{ignoreSpace:o.ignoreSpace},...o.matchWildcards===void 0?{}:{matchWildcards:o.matchWildcards}};return Object.keys(e).length===0?void 0:e}var b=class o extends p{#t;#n;#e;#o;#i;#s;static at(t,e,n){return n.kind!=="span"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.ofSpan(e,n.span),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="span"?this.path.resolveToSpan(t.span):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get font(){return this.#i??=E.of(this.context,`${this.path.label}.font`,this.path,"span"),this.#i}get paragraphs(){return this.#o??=L.of(this.context,`${this.path.label}.paragraphs`,this.path),this.#o}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=at(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:O(this.path,"span"),name:n}));}get hyperlink(){return this.loadedProperty("hyperlink")}set hyperlink(t){let e=`${this.path.label}.hyperlink`;(typeof t!="string"||t.length>2048)&&a({code:"InvalidArgument",target:e}),this.requireUsablePath(),this.command("hyperlink",()=>({op:"setHyperlink",span:this.#r(),target:t}));}get bookmarks(){let t=this.#r();return this.#s??=X.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{start:t.start,end:t.end}})),this.#s}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&a({code:"InvalidArgument",target:n});let r=Mt(e,n),i=this.#r();return N.of(this.context,n,this.path,()=>({op:"search",scope:i,text:t,options:{...r??{},projection:this.revisionTextView()}}))}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=Pt(e,n);this.requireUsablePath();let s=o.promised(this.context,n,false);return this.commandAnswering(n,()=>{let d=this.#r();return i==="Replace"?{op:"replaceSpan",span:d,text:r}:{op:"insertText",at:i==="Start"||i==="Before"?d.start:d.end,text:r}},d=>{s.hydrateAddress({kind:"span",span:R(d,n)});}),s}delete(){this.requireUsablePath(),this.commandDiscarding("delete",()=>({op:"replaceSpan",span:this.#r(),text:""}));}clear(){let t=this.#r();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:t,text:""}));}insertComment(t){let e=`${this.path.label}.insertComment`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&a({code:"NotSupported",target:e});let r=G.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertComment",span:this.#r(),text:t,author:n}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:e}),r.hydrateAddress(i);}),r}insertContentControl(t){let e=`${this.path.label}.insertContentControl`,n=t??"RichText";n!=="RichText"&&n!=="PlainText"&&a({code:"NotSupported",target:e});let r=q.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertContentControl",span:this.#r(),subtype:n==="PlainText"?"plainText":"richText",returnHandle:true}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:e}),r.hydrateAddress(i);}),r}get tables(){return this.requireUsablePath(),this.#t??=U.over(this.context,`${this.path.label}.tables`,this.path,()=>O(this.path,"span"))}get fields(){return this.requireUsablePath(),this.#n??=M.of(this.context,`${this.path.label}.fields`,this.path,"span")}insertField(t,e,n,r){let i=`${this.path.label}.insertField`;(e!==void 0&&typeof e!="string"||n!==void 0&&typeof n!="string"||r!==void 0&&typeof r!="boolean")&&a({code:"InvalidArgument",target:i});let s=Pt(t,i);this.requireUsablePath();let d=H.promised(this.context,i,false);return this.commandAnswering(i,()=>({op:"insertField",span:this.#r(),location:s,...e===void 0?{}:{fieldType:e},...n===void 0?{}:{text:n},...r===void 0?{}:{removeFormatting:r}}),h=>d.hydrateAddress({kind:"handle",handle:u(h,i)})),d}get inlinePictures(){return this.requireUsablePath(),this.#e??=V.of(this.context,`${this.path.label}.inlinePictures`,this.path,"span")}insertInlinePictureFromBase64(t,e){let n=`${this.path.label}.insertInlinePictureFromBase64`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:n});let r=Pt(e,n);this.requireUsablePath();let i=F.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertInlinePicture",span:this.#r(),base64:t,location:r}),s=>{i.hydrateAddress({kind:"handle",handle:u(s,n)});}),i}insertBreak(t,e){let n=`${this.path.label}.insertBreak`;e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:n});let r=e;this.requireUsablePath(),this.commandAnswering(n,()=>({op:"insertBreak",span:this.#r(),breakType:t,location:r}),i=>m(i,n));}insertTable(t,e,n,r){let i=`${this.path.label}.insertTable`;(!Number.isInteger(t)||!Number.isInteger(e)||t<1||e<1||!["Before","After"].includes(n))&&a({code:"InvalidArgument",target:i}),r!==void 0&&(!Array.isArray(r)||r.some(h=>!Array.isArray(h)||h.some(v=>typeof v!="string")))&&a({code:"InvalidArgument",target:i});let s=r?.map(h=>[...h]),d=W.promised(this.context,i);return this.commandAnswering(i,()=>({op:"insertTable",span:O(this.path,"span"),location:n,rowCount:t,columnCount:e,...s?{values:s}:{}}),h=>{h.kind!=="handle"&&a({code:"GeneralException",target:i}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n),i=Pt(e,n);i!=="Before"&&i!=="After"&&a({code:"InvalidArgument",target:n});let s=this.#r(),d=i==="Before"?s.start.paragraph:s.end.paragraph,h=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:d},where:i==="Before"?"before":"after",text:r}),v=>{v.kind!=="handle"&&a({code:"GeneralException",target:n}),h.hydrateAddress({kind:"handle",handle:v.handle});}),h}select(t){let e=`${this.path.label}.select`,n=Bt(t,e);this.requireAddressable(),this.internals.capabilities.selection||a({code:"NotSupported",target:e});let r=this.#r();this.command("select",()=>({op:"selectSpan",span:r,mode:n==="Select"?"select":n==="Start"?"start":"end"}));}onLoad(t){let e=this.selection(t,["text","style","hyperlink"]);if(e.includes("hyperlink")&&this.loadTextInto("hyperlink",()=>({op:"getHyperlink",span:this.#r()})),e.includes("text")){let r=`${this.path.label}.text`;this.read(r,()=>({op:"getSpanText",span:this.#r(),projection:this.revisionTextView()}),i=>{this.setLoadedProperty("text",P(i,r));});}if(!e.includes("style"))return;let n=`${this.path.label}.style`;this.requireUsablePath(),this.read(n,()=>({op:"getStyle",span:O(this.path,"span")}),r=>{this.setLoadedProperty("style",xt(r,n));});}#r(){return this.requireAddressable(),this.path.span()}};var ut=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get name(){return this.loadedProperty("name")}get range(){return this.#t??=this.#n(`${this.path.label}.range`),this.#t}select(t){let e=`${this.path.label}.select`,n=Bt(t,e);this.requireUsablePath(),this.internals.capabilities.selection||a({code:"NotSupported",target:e}),this.command("select",()=>({op:"selectBookmark",bookmark:this.#e(),mode:n==="Select"?"select":n==="Start"?"start":"end"}));}onLoad(t){if(!this.selection(t,["name"]).includes("name"))return;let e=`${this.path.label}.name`;this.read(e,()=>({op:"getBookmarkName",bookmark:this.#e()}),n=>{this.setLoadedProperty("name",P(n,e));});}#n(t){let e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getBookmarkRange",bookmark:this.#e()}),n=>{e.hydrateAddress({kind:"span",span:R(n,t)});}),e}#e(){return this.requireAddressable(),this.path.handle()}},X=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}listing(){return this.#t()}itemAt(t,e){return ut.at(this.context,t,e)}promised(t,e){return ut.promised(this.context,t,e)}};var I=class o extends p{#t;#n;#e;#o;#i;#s;#r;#a;#l;static main(t,e){return new o(t,c.of(e,J(t).roots().body))}static promisedStory(t,e){return new o(t,c.pending(e))}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}constructor(t,e){super(t,e);}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#o??=this.paragraphsUnder(`${this.path.label}.paragraphs`),this.#o}get bookmarks(){let t=this.#d();return this.#i??=X.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{body:t}})),this.#i}get font(){return this.#s??=E.of(this.context,`${this.path.label}.font`,this.path,"body"),this.#s}paragraphsUnder(t){return L.of(this.context,t,this.path)}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=at(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:O(this.path,"body"),name:n}));}get lists(){return this.#r??=ct.of(this.context,`${this.path.label}.lists`,this.path,this.#d()),this.#r}get contentControls(){return this.#a??=B.of(this.context,`${this.path.label}.contentControls`,this.path,{body:this.#d()}),this.#a}getComments(){let t=`${this.path.label}.getComments`,e=this.#d();return z.of(this.context,t,this.path,()=>({op:"getComments",scope:{body:e}}))}get revisions(){return this.#l??=Q.of(this.context,`${this.path.label}.revisions`,this.path,this.#d()),this.#l}getRange(t="Whole"){let e=`${this.path.label}.getRange`;this.requireUsablePath();let n=b.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{body:this.path.handle()},location:t}),r=>{n.hydrateAddress({kind:"span",span:R(r,e)});}),n}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&a({code:"InvalidArgument",target:n});let r=Mt(e,n),i=this.#d();return N.of(this.context,n,this.path,()=>({op:"search",scope:{body:i},text:t,options:{...r??{},projection:this.revisionTextView()}}))}clear(){let t=this.#d();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{body:t},text:""}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=be(e,n);this.requireUsablePath();let s=b.promised(this.context,n,false);return this.commandAnswering(n,()=>i==="Replace"?{op:"replaceSpan",span:{body:this.#d()},text:r}:{op:"insertText",at:{body:this.#d(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:R(d,n)});}),s}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n),i=ye(e,n),s=this.#d(),d=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{body:s,at:i==="Start"?"first":"last"},where:i==="Start"?"before":"after",text:r}),h=>{h.kind!=="handle"&&a({code:"GeneralException",target:n}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}onLoad(t){let e=this.selection(t,["text","style"]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#d(),projection:this.revisionTextView()})),e.includes("style")&&this.#c();}#c(){let t=`${this.path.label}.style`;this.requireUsablePath(),this.read(t,()=>({op:"getStyle",span:O(this.path,"body")}),e=>{this.setLoadedProperty("style",xt(e,t));});}get fields(){return this.requireUsablePath(),this.#n??=M.of(this.context,`${this.path.label}.fields`,this.path,"body")}get inlinePictures(){return this.requireUsablePath(),this.#e??=V.of(this.context,`${this.path.label}.inlinePictures`,this.path,"body")}get tables(){return this.requireUsablePath(),this.#t??=U.over(this.context,`${this.path.label}.tables`,this.path,()=>({body:this.#d()}))}#d(){return this.requireAddressable(),this.path.handle()}};function en(o){return o==="endnote"?"Endnote":"Footnote"}var mt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get type(){return this.loadedProperty("type")}get text(){return this.loadedProperty("text")}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=I.promisedStory(this.context,t);return this.read(t,()=>({op:"getNoteBody",note:this.#n()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),this.#t=e,e}delete(){this.command("delete",()=>({op:"deleteNote",note:this.#n()}));}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document,r=`${t}.type`,i="footnote",s=c.pending(r);return this.read(r,()=>({op:"getNoteKind",note:this.#n()}),d=>{i=P(d,r)==="endnote"?"endnote":"footnote",s.resolveTo(this.#n());}),this.enqueue({sort:"read",label:t,dependencies:[s],plan:()=>({op:"getNotes",document:n,noteKind:i}),settle:d=>{let h=A(d,t),v=h.findIndex(rt=>rt.ref===this.#n().ref),K=v<0?void 0:h[v+1];K||a({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:K});}}),e}onLoad(t){let e=this.selection(t,["text","type"]);if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getNoteText",note:this.#n(),projection:this.revisionTextView()})),e.includes("type")){let n=`${this.path.label}.type`;this.read(n,()=>({op:"getNoteKind",note:this.#n()}),r=>{this.setLoadedProperty("type",en(P(r,n)));});}}#n(){return this.requireAddressable(),this.path.handle()}},ot=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return mt.at(this.context,t,e)}promised(t,e){return mt.promised(this.context,t,e)}};var nn=Object.freeze({Primary:"default",FirstPage:"first",EvenPages:"even"}),on=["pageWidth","pageHeight","orientation","topMargin","rightMargin","bottomMargin","leftMargin"],kt=class o extends p{#t;static of(t,e,n){return new o(t,c.derived(e,n))}constructor(t,e){super(t,e);}get pageWidth(){return this.loadedProperty("pageWidth")}set pageWidth(t){this.#n("pageWidth",gt(t,`${this.path.label}.pageWidth`));}get pageHeight(){return this.loadedProperty("pageHeight")}set pageHeight(t){this.#n("pageHeight",gt(t,`${this.path.label}.pageHeight`));}get orientation(){return this.loadedProperty("orientation")}set orientation(t){let e=`${this.path.label}.orientation`;t!=="Portrait"&&t!=="Landscape"&&a({code:"InvalidArgument",target:e}),this.#n("orientation",t==="Portrait"?"portrait":"landscape");}get topMargin(){return this.loadedProperty("topMargin")}set topMargin(t){this.#n("topMargin",gt(t,`${this.path.label}.topMargin`));}get bottomMargin(){return this.loadedProperty("bottomMargin")}set bottomMargin(t){this.#n("bottomMargin",gt(t,`${this.path.label}.bottomMargin`));}get leftMargin(){return this.loadedProperty("leftMargin")}set leftMargin(t){this.#n("leftMargin",gt(t,`${this.path.label}.leftMargin`));}get rightMargin(){return this.loadedProperty("rightMargin")}set rightMargin(t){this.#n("rightMargin",gt(t,`${this.path.label}.rightMargin`));}onLoad(t){let e=this.selection(t,on);if(e.length===0)return;let n=`${this.path.label}.pageSetup`;this.read(n,()=>({op:"getPageSetup",section:this.#e()}),r=>{let i=Gt(r,n);for(let s of e)this.setLoadedProperty(s,s==="orientation"?i.orientation==="landscape"?"Landscape":"Portrait":i[s]);});}#n(t,e){if(this.requireUsablePath(),this.#t){this.#t[t]=e;return}let n={[t]:e};this.#t=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.pageSetup`,()=>({op:"setPageSetup",section:this.#e(),setup:n}),i=>{m(i,r);},()=>{this.#t===n&&(this.#t=void 0);});}#e(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},ft=class o extends p{#t;#n;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){return this.#n??=I.main(this.context,`${this.path.label}.body`),this.#n}get pageSetup(){return this.#t??=kt.of(this.context,`${this.path.label}.pageSetup`,this.path),this.#t}getHeader(t){return this.#e("header",t,"getHeader")}getFooter(t){return this.#e("footer",t,"getFooter")}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document;return this.read(t,()=>({op:"getSections",document:n}),r=>{let i=A(r,t),s=i.findIndex(h=>h.ref===this.#o().ref),d=s<0?void 0:i[s+1];d||a({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:d});}),e}onLoad(t){this.selection(t,[]);}#e(t,e,n){let r=`${this.path.label}.${n}`,i=nn[e];i===void 0&&a({code:"InvalidArgument",target:r});let s=I.promisedStory(this.context,r);return this.read(r,()=>({op:"getFurniture",section:this.#o(),kind:t,variant:i}),d=>{s.hydrateAddress({kind:"handle",handle:u(d,r)});}),s}#o(){return this.requireAddressable(),this.path.handle()}},bt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return ft.at(this.context,t,e)}promised(t,e){return ft.promised(this.context,t,e)}};function gt(o,t){return (typeof o!="number"||!Number.isFinite(o)||o<0)&&a({code:"InvalidArgument",target:t}),o}var yt=class o extends p{#t;#n;#e;#o;#i;#s;#r;#a;static open(t){return new o(t)}constructor(t){super(t,c.of("document",J(t).roots().document));}get changeTrackingMode(){return this.loadedProperty("changeTrackingMode")}set changeTrackingMode(t){["Off","TrackAll","TrackMineOnly"].includes(t)||a({code:"InvalidArgument",target:"document.changeTrackingMode"});let e=this.internals.author;this.commandAnswering("document.changeTrackingMode",()=>({op:"setChangeTrackingMode",mode:t,...e===void 0?{}:{author:e}}),()=>this.setLoadedProperty("changeTrackingMode",t));}get body(){return this.#t??=I.main(this.context,"document.body"),this.#t}get paragraphs(){return this.#n??=this.body.paragraphsUnder("document.paragraphs"),this.#n}get sections(){let t=this.path.handle();return this.#e??=bt.of(this.context,"document.sections",this.path,()=>({op:"getSections",document:t})),this.#e}get contentControls(){return this.#s??=B.of(this.context,"document.contentControls",this.path,{body:this.internals.roots().body}),this.#s}get comments(){return this.#o??=z.of(this.context,"document.comments",this.path,()=>({op:"getComments",scope:{body:this.internals.roots().body}})),this.#o}get revisions(){return this.#i??=Q.of(this.context,"document.revisions",this.path,this.internals.roots().body),this.#i}get footnotes(){let t=this.path.handle();return this.#r??=ot.of(this.context,"document.footnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"footnote"})),this.#r}get endnotes(){let t=this.path.handle();return this.#a??=ot.of(this.context,"document.endnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"endnote"})),this.#a}onLoad(t){if(t.select.length===0)return;this.selection(t,["changeTrackingMode"]).includes("changeTrackingMode")&&this.loadTextInto("changeTrackingMode",()=>({op:"getChangeTrackingMode"}));}};function Ft(o){let t=o.host,e=Object.freeze({...t.capabilities,save:o.save&&t.capabilities.save}),n=typeof o.author=="string"&&o.author.trim().length>0?o.author:void 0,r=o.revisionTextView??"allMarkup";r!=="allMarkup"&&r!=="original"&&a({code:"InvalidArgument",target:"revisionTextView"});let i=false,s=null,d=g=>{i&&a({code:"RuntimeDisposed",...g===void 0?{}:{target:g}});},h=()=>{if(s)return s;d("document");let g=Ie(t.execute({operations:[{op:"getDocument"}]}),"document"),Z=Ie(t.execute({operations:[{op:"getBody",document:g}]}),"document.body");return s={document:g,body:Z},s},v={host:t,capabilities:e,...n===void 0?{}:{author:n},revisionTextView:r,id:{},roots:h,assertLive:d,openDocument:g=>yt.open(g)};try{h();}catch{s=null;}async function K(g,Z){d();let it=typeof g=="function"?g:Z,Vt=typeof g=="function"?[]:Array.isArray(g)?g:[g];typeof it!="function"&&a({code:"InvalidArgument",target:"run"});let{context:wt,adopt:y,finish:Se}=vt.begin(v);try{return y(Vt),await it(wt)}finally{Se();}}let rt={capabilities:e,run:K,dispose(){i||(i=true,s=null,t.dispose());}};return o.save?{...rt,async save(){d("save"),e.save||a({code:"NotSupported",target:"save"});let g=t.save();if(!g.ok)throw Dt(g.error,{target:"save"});return g.bytes}}:rt}function Ie(o,t){let e=o.results[0];if(e?.status==="error")throw Dt(e.error,{target:t});if(e?.status!=="ok")throw new C({code:"GeneralException",target:t});return u(e.value,t)}function ke(o,t={}){return Ft({host:editor.createBrowserAutomationHost(o),save:false,...t.author===void 0?{}:{author:t.author},...t.revisionTextView===void 0?{}:{revisionTextView:t.revisionTextView}})}function Le(o){return automation.createAutomationPaginationProvider(o)}function dn(o){if(o){for(let t of o)if(t.collaboration)return t.collaboration}}function ln(o){let t=[o?.zip?.maxEntries,o?.zip?.maxTotalBytes,o?.xml?.maxBytes,o?.xml?.maxElements,o?.maxXmlParts,o?.maxRelationships],e=o?.zip?.maxRatio;(t.some(n=>n!==void 0&&(!Number.isInteger(n)||n<0))||e!==void 0&&(!Number.isFinite(e)||e<0))&&a({code:"InvalidArgument",target:"createServer"});}async function se(o,t={}){ln(t.limits);let e=dn(t.modules),n=automation.createServerAutomationHost(o,{...t.pagination?{pagination:Le(t.pagination)}:{},...t.limits===void 0?{}:{limits:t.limits},...e===void 0?{}:{collaborationModel:e}});if(!n.ok){let r={"too-many-entries":"zip.maxEntries","too-large":"xml.maxBytes","too-many-elements":"xml.maxElements","too-deep":"xml.maxDepth","too-many-xml-parts":"maxXmlParts","too-many-relationships":"maxRelationships"},i=n.limit??r[n.reason];a({code:i===void 0?"InvalidArgument":"ResourceLimitExceeded",target:"createServer",...i===void 0?{}:{limit:i}});}return Ft({host:n.host,save:true,...t.author===void 0?{}:{author:t.author},...t.revisionTextView===void 0?{}:{revisionTextView:t.revisionTextView}})}function we(o,t,e={}){return se(o,{...e,modules:[...e.modules??[],{id:"collaboration",collaboration:{session:t}}]})}var de=(l=>(l.addin="Addin",l.addressBlock="AddressBlock",l.advance="Advance",l.ask="Ask",l.author="Author",l.autoText="AutoText",l.autoTextList="AutoTextList",l.barCode="BarCode",l.bibliography="Bibliography",l.bidiOutline="BidiOutline",l.citation="Citation",l.comments="Comments",l.compare="Compare",l.createDate="CreateDate",l.data="Data",l.database="Database",l.date="Date",l.displayBarcode="DisplayBarcode",l.docProperty="DocProperty",l.docVariable="DocVariable",l.editTime="EditTime",l.embedded="Embedded",l.empty="Empty",l.eq="EQ",l.expression="Expression",l.fileName="FileName",l.fileSize="FileSize",l.fillIn="FillIn",l.formCheckbox="FormCheckbox",l.formDropdown="FormDropdown",l.formText="FormText",l.gotoButton="GotoButton",l.greetingLine="GreetingLine",l.hyperlink="Hyperlink",l.if="If",l.import="Import",l.include="Include",l.includePicture="IncludePicture",l.includeText="IncludeText",l.index="Index",l.info="Info",l.keywords="Keywords",l.lastSavedBy="LastSavedBy",l.link="Link",l.listNum="ListNum",l.macroButton="MacroButton",l.mergeBarcode="MergeBarcode",l.mergeField="MergeField",l.mergeRec="MergeRec",l.mergeSeq="MergeSeq",l.next="Next",l.nextIf="NextIf",l.noteRef="NoteRef",l.numChars="NumChars",l.numPages="NumPages",l.numWords="NumWords",l.ocx="OCX",l.others="Others",l.page="Page",l.pageRef="PageRef",l.print="Print",l.printDate="PrintDate",l.private="Private",l.quote="Quote",l.rd="RD",l.ref="Ref",l.revNum="RevNum",l.saveDate="SaveDate",l.section="Section",l.sectionPages="SectionPages",l.seq="Seq",l.set="Set",l.shape="Shape",l.skipIf="SkipIf",l.styleRef="StyleRef",l.subject="Subject",l.subscriber="Subscriber",l.symbol="Symbol",l.ta="TA",l.tc="TC",l.template="Template",l.time="Time",l.title="Title",l.toa="TOA",l.toc="TOC",l.undefined="Undefined",l.userAddress="UserAddress",l.userInitials="UserInitials",l.userName="UserName",l.xe="XE",l))(de||{});var Xi=Object.freeze({createBrowser:ke,createServer:se,createCollaborative:we});exports.Alignment=Zt;exports.Body=I;exports.Bookmark=ut;exports.BookmarkCollection=X;exports.BreakType=te;exports.ChangeTrackingMode=Jt;exports.ClientObject=$;exports.ClientResult=Tt;exports.Comment=G;exports.CommentCollection=z;exports.CommentReply=nt;exports.CommentReplyCollection=It;exports.ContentControl=q;exports.ContentControlCollection=B;exports.ContentControlType=ee;exports.Document=yt;exports.DocxEditor=Xi;exports.DocxEditorError=C;exports.Field=H;exports.FieldCollection=M;exports.FieldType=de;exports.Font=E;exports.InlinePicture=F;exports.InlinePictureCollection=V;exports.InsertLocation=Kt;exports.List=j;exports.ListBullet=oe;exports.ListCollection=ct;exports.ListItem=ht;exports.ListNumbering=re;exports.NoteItem=mt;exports.NoteItemCollection=ot;exports.PageOrientation=Yt;exports.PageSetup=kt;exports.Paragraph=w;exports.ParagraphCollection=L;exports.Range=b;exports.RangeCollection=N;exports.RequestContext=vt;exports.Revision=et;exports.RevisionCollection=Q;exports.Section=ft;exports.SectionCollection=bt;exports.Table=W;exports.TableCell=tt;exports.TableCellCollection=Rt;exports.TableCollection=U;exports.TableRow=st;exports.TableRowCollection=dt;exports.TrackedObjects=Ct;exports.UnderlineType=ie;exports.VerticalAlignment=_t;exports.isDocxEditorError=je;