@docx-editor.dev/editor-api 2.30.0 → 2.31.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/OFFICE_JS_GUIDE.md +164 -3
- package/dist/browser.d.mts +3 -3
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{server-BHhcVU2-.d.mts → server-Dw4k9h0p.d.mts} +642 -19
- package/dist/{server-BHhcVU2-.d.ts → server-Dw4k9h0p.d.ts} +642 -19
- package/package.json +2 -2
package/dist/browser.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {createBrowserAutomationHost,reportAutomationException,reportAutomationRefusal}from'@docx-editor.dev/core/editor';import {explainDiagnostic,createServerAutomationHost,openDiagnosticCode,storeEditDiagnosticCode,diagnosticCause,createDiagnosticEmitter,diagnosticErrorName,exceptionCause,byteSizeBucket,documentPartKind,createAutomationPaginationProvider}from'@docx-editor.dev/core/automation';var ve=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 or a range changed after this context read it, so nothing was applied. The change can come from another writer or from an earlier sync of this context.",DocumentUnavailable:"the document is not available right now.",GeneralException:"the document could not complete the request."}),R=class extends Error{code;limit;target;expectedRevision;actualRevision;debugInfo;constructor(t){let e=t.target?`${ve[t.code]} (${t.target})`:ve[t.code];super(e),this.name="DocxEditorError",this.code=t.code,this.debugInfo=Object.freeze({code:t.code,message:e,...t.target===void 0?{}:{errorLocation:t.target},...t.diagnostic===void 0?{}:{innerError:Object.freeze({code:t.diagnostic,message:explainDiagnostic(t.diagnostic).hint})}}),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 Nt(n){return n instanceof R?true:typeof n=="object"&&n!==null&&n.name==="DocxEditorError"&&typeof n.code=="string"}function a(n){throw new R(n)}function Ce(n){let t=[],e=false,o=false;for(let r of n)t.push(r.plan()),r.sort==="write"?o=true:e=true;return {operations:t,hasRead:e,hasWrite:o}}var Ze=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 qt(n,t={}){let e=Ze[n.code]??"GeneralException",o=e==="StaleDocument",r=n.detail===void 0?null:storeEditDiagnosticCode(n.detail),i=new R({code:e,...r===null?{}:{diagnostic:r},...t.target===void 0?{}:{target:t.target},...o&&t.expectedRevision!==void 0?{expectedRevision:t.expectedRevision}:{},...o&&t.actualRevision!==void 0?{actualRevision:t.actualRevision}:{}}),s=diagnosticCause(n.detail);return s&&Re.set(i,s),i}var Re=new WeakMap;function Bt(n){return Re.get(n)}function Jt(n,t,e){for(let o=0;o<n.results.length;o+=1){let r=n.results[o];if(r?.status!=="error")continue;let i=t[o]?.label;return qt(r.error,{...i===void 0?{}:{target:i},...e===void 0?{}:{expectedRevision:e},actualRevision:n.revision})}return new R({code:"GeneralException"})}function _t(n,t){if(t.results.length!==n.length)throw new R({code:"GeneralException"});for(let e=0;e<n.length;e+=1){let o=t.results[e],r=n[e];if(o.status!=="ok")throw new R({code:"GeneralException",target:r.label});r.settle(o.value);}}var eo={StaleDocument:"edit.stale-target",ItemNotFound:"edit.stale-target",InvalidObjectPath:"edit.stale-target",InvalidArgument:"edit.invalid-argument",ResourceLimitExceeded:"edit.resource-limit",NotSupported:"edit.operation-unsupported",NotImplemented:"edit.operation-unsupported"};function oo(n){try{let t=n.execute({operations:[{op:"getChangeTrackingMode"}]}),e=t.ok?t.results[0]:void 0;return e?.status==="ok"&&e.value.kind==="text"&&e.value.text!=="Off"}catch{return false}}function $t(n,t){return t.some(o=>o.op==="setChangeTrackingMode"&&o.mode!=="Off")||oo(n)}function ee(n,t,e){let o=n.debugInfo.innerError?.code;return {code:o?.startsWith("edit.")?o:eo[n.code]??"edit.refused",tracked:$t(t,e)}}function ke(n){if(n.length===0)return null;let{deliver:t}=createDiagnosticEmitter(()=>n);return {openRejected(e,o,r,i){let s=diagnosticCause(o),d=documentPartKind(i);t({kind:"document.open",outcome:"rejected",code:openDiagnosticCode(o,r),sizeBucket:byteSizeBucket(e.byteLength),...s?{cause:s}:{},...d?{part:d}:{}});},openCrashed(e,o){t({kind:"document.open",outcome:"rejected",code:"open.failed",sizeBucket:byteSizeBucket(e.byteLength),cause:exceptionCause(),errorName:diagnosticErrorName(o)});},opened(e,o){t({kind:"document.open",outcome:"opened",sizeBucket:byteSizeBucket(e.byteLength),durationMs:Math.max(0,Math.round(o))});},crashed(e,o,r){t({kind:"edit.rejected",code:"edit.internal-invariant",origin:"automation",tracked:$t(o,r),cause:exceptionCause(),errorName:diagnosticErrorName(e),stage:"automation"});},refused(e,o,r){let i=Bt(e);t({kind:"edit.rejected",origin:"automation",...ee(e,o,r),...i?{cause:i}:{}});}}}var rt=Symbol("docx-editor.runtime.internals"),Ht=Symbol("docx-editor.runtime.release"),Mt=Symbol("docx-editor.runtime.rebind");function it(n){return n[rt]}var no=new Set(["select","expand","top","skip"]),ro=/^[A-Za-z][A-Za-z0-9]*$/;function Ie(n,t){if(n===void 0)return [];let e=typeof n=="string"?n.split(",").map(r=>r.trim()):Array.isArray(n)?n.map(r=>typeof r=="string"?r.trim():r):a({code:"InvalidArgument",target:t}),o=[];for(let r of e)(typeof r!="string"||!ro.test(r))&&a({code:"InvalidArgument",target:t}),o.includes(r)||o.push(r);return o.length===0&&a({code:"InvalidArgument",target:t}),o}function Se(n,t){return (typeof n!="number"||!Number.isInteger(n)||n<0)&&a({code:"InvalidArgument",target:t}),n}function io(n,t){n===void 0||Array.isArray(n)&&n.length===0||a({code:"InvalidArgument",target:t});}function we(n,t){if(n===void 0)return {select:[]};if(typeof n=="string"||Array.isArray(n))return {select:Ie(n,t)};(typeof n!="object"||n===null)&&a({code:"InvalidArgument",target:t});let e=n;for(let o of Object.keys(e))no.has(o)||a({code:"InvalidArgument",target:`${t}.${o}`});return io(e.expand,`${t}.expand`),{select:Ie(e.select,`${t}.select`),...e.top===void 0?{}:{top:Se(e.top,`${t}.top`)},...e.skip===void 0?{}:{skip:Se(e.skip,`${t}.skip`)}}}var z=class{#t;#e;#o;#n;#s=new Map;#a=false;constructor(t,e,o={}){this.#t=t,this.#e=t[rt],this.#o=e,this.#n=o.nullable===true,this.#e.register(this);}get context(){return this.#t}get isNullObject(){return this.#o.isReleased&&a({code:"InvalidObjectPath",target:this.#o.label}),this.#n?(this.#o.isPending&&a({code:"PropertyNotLoaded",target:`${this.#o.label}.isNullObject`}),this.#o.isNull):false}load(t){this.#a=true;try{return this.requireUsablePath(),this.onLoad(we(t,this.#o.label)),this}finally{this.#a=false;}}get path(){return this.#o}get internals(){return this.#e}handle(){return this.#o.handle()}requireAddressable(){this.#o.isAddressable||a({code:"InvalidObjectPath",target:this.#o.label}),this.#e.assertUsable(this.#o.label);}requireUsablePath(){(this.#o.isReleased||this.#o.isNull&&!(this.#a&&this.#n))&&a({code:"InvalidObjectPath",target:this.#o.label}),this.#e.assertUsable(this.#o.label);}enqueue(t){this.requireUsablePath(),this.#e.queue.push({...t,dependencies:[...t.dependencies??[],this.#o],...this.#a&&this.#n&&t.sort==="read"?{nullableLoad:this.#o}:{}});}loadedProperty(t){return this.#o.isReleased&&!this.#s.has(t)&&a({code:"InvalidObjectPath",target:this.#o.label}),this.#s.has(t)||a({code:"PropertyNotLoaded",target:`${this.#o.label}.${t}`}),this.#s.get(t)}hasLoadedProperty(t){return this.#s.has(t)}setLoadedProperty(t,e){this.#s.set(t,e);}[Ht](){this.#o.release();}[Mt](t){this.#t=t,this.#e=t[rt];}};var Ft=class n{#t=false;#e;#o;constructor(t){this.#o=t;}get value(){return this.#t||a({code:"ValueNotLoaded",target:this.#o}),this.#e}get isLoaded(){return this.#t}static create(t){let e=new n(t);return {result:e,fill(o){e.#t=true,e.#e=o;}}}};function oe(n){return Ft.create(n)}function E(n){return new R({code:"GeneralException",target:n})}function P(n,t){if(n.kind!=="text")throw E(t);return n.text}function m(n,t){if(n.kind!=="handle")throw E(t);return n.handle}function v(n,t){if(n.kind!=="handles")throw E(t);return n.handles}function O(n,t){if(n.kind!=="span")throw E(t);return n.span}function Vt(n,t){if(n.kind!=="spans")throw E(t);return n.spans}function ne(n,t){if(n.kind!=="font")throw E(t);return n.font}function re(n,t){if(n.kind!=="paragraphFormat")throw E(t);return n.format}function Ot(n,t){if(n.kind!=="style")throw E(t);return n.name}function Wt(n,t){if(n.kind!=="number")throw E(t);return n.value}function at(n,t){if(n.kind!=="flag")throw E(t);return n.value}function ie(n,t){if(n.kind!=="pageSetup")throw E(t);return n.setup}function g(n,t){if(n.kind!=="applied")throw E(t)}var c=class n{label;#t;#e;constructor(t,e,o=null){this.label=t,this.#t=e,this.#e=o;}static of(t,e){return new n(t,{status:"resolved",address:{kind:"handle",handle:e}})}static ofSpan(t,e){return new n(t,{status:"resolved",address:{kind:"span",span:e}})}static pending(t){return new n(t,{status:"pending"})}static derived(t,e){return new n(t,{status:"pending"},e)}get state(){return this.#e?this.#e.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.#o({kind:"handle",handle:t});}resolveToSpan(t){this.#o({kind:"span",span:t});}resolveNull(){this.#t.status!=="released"&&(this.#t={status:"null"});}release(){this.#e||(this.#t={status:"released"});}#o(t){this.#t.status!=="released"&&(this.#t={status:"resolved",address:t});}};var Ut=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 Le(n,t){if(Array.isArray(n)){for(let e of n)t(e);return}t(n);}var kt=class{#t;#e;constructor(t,e){this.#t=t,this.#e=e;}add(t){this.#t.assertUsable(),Le(t,e=>{this.#o(e),this.#t.track(e);});}remove(t){this.#t.assertUsable(),Le(t,e=>{this.#o(e),this.#t.untrack(e);});}#o(t){this.#e(t)||a({code:"InvalidObjectPath"});}};var It=class n{#t;#e=new Ut;#o=new Set;#n=new Set;#s;#a;#i;#r=false;#d=null;#c=false;constructor(t){this.#t=t,this.#s={host:t.host,capabilities:t.capabilities,...t.author===void 0?{}:{author:t.author},revisionTextView:t.revisionTextView,queue:this.#e,session:t.id,roots:()=>t.roots(),assertUsable:e=>{this.#t.assertLive(e),this.#r&&a({code:"InvalidRequestContext",...e===void 0?{}:{target:e}});},isFinished:()=>this.#r,readRevision:()=>this.#d,register:e=>{this.#o.add(e);},track:e=>{this.#n.add(e);},untrack:e=>{this.#n.delete(e);},isTracked:e=>this.#n.has(e),disown:e=>{this.#o.delete(e),this.#n.delete(e);}},this.#a=new kt(this.#s,e=>this.#o.has(e));}get document(){return this.#s.assertUsable("document"),this.#i??=this.#t.openDocument(this),this.#i}get capabilities(){return this.#t.capabilities}get trackedObjects(){return this.#a}async sync(){this.#s.assertUsable(),this.#c&&a({code:"InvalidRequestContext"});let t=this.#e.take();if(t.length!==0){this.#c=true;try{let e=t.filter(d=>!d.nullableLoad?.isNull),o=t.some(d=>d.sort==="write"),r,i=o&&this.#d!==null?this.#d:void 0,s=d=>d.dependencies?.some(h=>!h.isAddressable)??false;for(;e.some(s);){r??=o&&this.#d!==null?this.#d:this.#t.host.revision();let d=e.filter(u=>u.sort==="read"&&!s(u));d.length===0&&a({code:"InvalidObjectPath",target:e.find(s)?.label}),await this.#h(d,r,i);let h=new Set(d);e=e.filter(u=>!h.has(u)&&!u.nullableLoad?.isNull);}if(e.length){let d=r??(o&&this.#d!==null?this.#d:void 0);await this.#h(e,d,i);}}finally{for(let e of t)e.dispose?.();this.#c=false;}}}async#h(t,e,o){let r=Ce(t);try{await this.#u(t,r,e,o);}catch(i){if(!Nt(i))try{this.#t.onException?.(i,r.operations);}catch{}throw i}}async#u(t,e,o,r){let i={operations:e.operations,...o===void 0?{}:{expectedRevision:o}};if(this.#t.host.prepare){let d={...i,expectedRevision:i.expectedRevision??this.#t.host.revision()};try{await this.#t.host.prepare(d);}catch(u){throw Nt(u)?this.#p(u,e.operations):u}let h=this.#t.host.execute(d);if(!h.ok)throw this.#p(Jt(h,t,r),e.operations);_t(t,h),this.#d=h.revision;return}let s=this.#t.host.execute(i);if(!s.ok)throw this.#p(Jt(s,t,r),e.operations);_t(t,s),(e.hasRead||e.hasWrite)&&(this.#d=s.revision);}#p(t,e){try{this.#t.onRefusal?.(t,e);}catch{}return t}get[rt](){return this.#s}static begin(t){let e=new n(t);return {context:e,adopt(o){for(let r of o)e.#l(r);},finish(){e.#g();}}}#l(t){let e=t.context;if(e===this)return;let o=e[rt];if(o.session!==this.#t.id)throw new R({code:"InvalidObjectPath"});if(!o.isFinished())throw new R({code:"ObjectInUse"});if(!o.isTracked(t))throw new R({code:"InvalidObjectPath"});let r=o.readRevision();o.disown(t),t[Mt](this),this.#o.add(t),this.#n.add(t),r!==null&&this.#m(r);}#m(t){this.#d=this.#d===null?t:Math.min(this.#d,t);}#g(){if(!this.#r){this.#r=true,this.#e.clear();for(let t of this.#o)this.#n.has(t)||t[Ht]();this.#o.clear();}}};function St(n,t,e){if(n.select.length===0)return t;for(let o of n.select)t.includes(o)||a({code:"InvalidArgument",target:`${e}.${o}`});return n.select}var p=class extends z{revisionTextView(){return it(this.context).revisionTextView}loadTextInto(t,e){let o=`${this.path.label}.${t}`;this.enqueue({sort:"read",label:o,plan:e,settle:r=>{this.setLoadedProperty(t,P(r,o));}});}command(t,e,o){let r=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:r,plan:e,settle:i=>g(i,r),...o?{capture:o,dispose:o}:{}});}commandDiscarding(t,e){let o=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:o,plan:e,settle:()=>{}});}commandAnswering(t,e,o,r){this.enqueue({sort:"write",label:t,plan:e,settle:o,...r?{capture:r,dispose:r}:{}});}read(t,e,o){this.enqueue({sort:"read",label:t,plan:e,settle:o});}selection(t,e){return St(t,e,this.path.label)}onLoad(t){this.selection(t,[]);}};var ao=["author","title","subject","keywords","comments","category","lastAuthor"],ht=class n extends p{#t;static of(t,e){return new n(t,c.derived("document.properties",e))}constructor(t,e){super(t,e);}get lastAuthor(){return this.loadedProperty("lastAuthor")}get author(){return this.loadedProperty("author")}set author(t){this.#e("author",t);}get title(){return this.loadedProperty("title")}set title(t){this.#e("title",t);}get subject(){return this.loadedProperty("subject")}set subject(t){this.#e("subject",t);}get keywords(){return this.loadedProperty("keywords")}set keywords(t){this.#e("keywords",t);}get comments(){return this.loadedProperty("comments")}set comments(t){this.#e("comments",t);}get category(){return this.loadedProperty("category")}set category(t){this.#e("category",t);}onLoad(t){for(let e of this.selection(t,ao))this.read(`${this.path.label}.${e}`,()=>({op:"getDocumentProperty",name:e}),o=>this.setLoadedProperty(e,P(o,this.path.label)));}#e(t,e){if(this.requireUsablePath(),(typeof e!="string"||e.length>4096)&&a({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#t){this.#t[t]=e;return}let o={[t]:e};this.#t=o,this.commandAnswering(this.path.label,()=>({op:"setDocumentProperties",values:o}),r=>{g(r,this.path.label);},()=>{this.#t===o&&(this.#t=void 0);});}};function I(n,t){let e=n.address();return t==="span"?(e.kind!=="span"&&a({code:"InvalidObjectPath",target:n.label}),{start:e.span.start,end:e.span.end}):(e.kind!=="handle"&&a({code:"InvalidObjectPath",target:n.label}),t==="body"?{body:e.handle}:{paragraph:e.handle})}function pt(n,t){return (typeof n!="string"||n.trim().length===0||n.length>255)&&a({code:"InvalidArgument",target:t}),n}var D=class extends z{#t;#e=[];constructor(t,e){super(t,e);}get items(){return this.loadedProperty("items")}fill(t,e){this.setLoadedProperty("items",this.#n(t,e,0,void 0)),this.#t={value:t,label:e};let o=this.#e.splice(0,this.#e.length);for(let r of o)this.#o(r,t);}onLoad(t){St(t,["items"],this.path.label);let e=this.path.isPending?void 0:this.listing();if(e===null)return;let o=`${this.path.label}.items`,r=t.skip??0,i=t.top;this.enqueue({sort:"read",label:o,plan:()=>{let s=e??this.listing();return s||a({code:"InvalidObjectPath",target:this.path.label}),s},settle:s=>{this.setLoadedProperty("items",this.#n(s,o,r,i));}});}edge(t,e,o){let r=`${this.path.label}.${e}()`,i=this.promised(r,o),s=this.path.isPending?void 0:this.listing();if(s===null){let d={edge:t,target:r,nullable:o,item:i};return this.#t?this.#o(d,this.#t.value):this.#e.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.#o({edge:t,target:r,nullable:o,item:i},d);}}),i}#o(t,e){let{edge:o,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,o==="first"?0:d-1);h||a({code:"ItemNotFound",target:r}),s.hydrateAddress(h);}#n(t,e,o,r){let i=this.size(t,e),s=r===void 0?i:Math.min(i,o+r),d=[];for(let h=o;h<s;h+=1){let u=this.addressAt(t,e,h);u&&d.push(this.itemAt(`${e}[${String(h)}]`,u));}return d}},C=class extends D{size(t,e){return v(t,e).length}addressAt(t,e,o){let r=v(t,e)[o];return r?{kind:"handle",handle:r}:void 0}};var zt=(s=>(s.unsupported="Unsupported",s.textBox="TextBox",s.geometricShape="GeometricShape",s.group="Group",s.picture="Picture",s.canvas="Canvas",s))(zt||{}),so=["id","name","type"],je=new Set(Object.values(zt)),ut=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get name(){return this.loadedProperty("name")}get type(){return this.loadedProperty("type")}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=S.promisedStory(this.context,t);return this.read(t,()=>({op:"getShapeBody",shape:this.#e()}),o=>{e.hydrateAddress({kind:"handle",handle:m(o,t)});}),this.#t=e,e}onLoad(t){let e=this.selection(t,so);e.length&&this.read(this.path.label,()=>({op:"getShape",shape:this.#e()}),o=>{(o.kind!=="shape"||!je.has(o.shape.type))&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,o.shape[r]);});}#e(){return this.requireAddressable(),this.path.handle()}},G=class n extends D{#t;#e;static of(t,e,o,r,i){return new n(t,c.derived(e,o),r,i)}constructor(t,e,o,r){super(t,e),this.#t=o,this.#e=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getByTypes(t){let e=`${this.path.label}.getByTypes`;(!Array.isArray(t)||t.some(r=>!je.has(r)))&&a({code:"InvalidArgument",target:e});let o=this.#e?this.#e.filter(r=>t.includes(r)):[...t];return n.of(this.context,e,this.path,this.#t,o)}listing(){let t=I(this.path,this.#t);return this.#e?{op:"getShapes",span:t,types:this.#e}:{op:"getShapes",span:t}}size(t,e){return v(t,e).length}addressAt(t,e,o){let r=v(t,e)[o];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return ut.at(this.context,t,e)}promised(t,e){return ut.promised(this.context,t,e)}};function lo(n){return n==="endnote"?"Endnote":"Footnote"}var mt=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}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=S.promisedStory(this.context,t);return this.read(t,()=>({op:"getNoteBody",note:this.#e()}),o=>{e.hydrateAddress({kind:"handle",handle:m(o,t)});}),this.#t=e,e}delete(){this.command("delete",()=>({op:"deleteNote",note:this.#e()}));}getNext(){let t=`${this.path.label}.getNext`,e=n.promised(this.context,t,false),o=this.internals.roots().document,r=`${t}.type`,i="footnote",s=c.pending(r);return this.read(r,()=>({op:"getNoteKind",note:this.#e()}),d=>{i=P(d,r)==="endnote"?"endnote":"footnote",s.resolveTo(this.#e());}),this.enqueue({sort:"read",label:t,dependencies:[s],plan:()=>({op:"getNotes",document:o,noteKind:i}),settle:d=>{let h=v(d,t),u=h.findIndex(k=>k.ref===this.#e().ref),H=u<0?void 0:h[u+1];H||a({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:H});}}),e}onLoad(t){let e=this.selection(t,["text","type"]);if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getNoteText",note:this.#e(),projection:this.revisionTextView()})),e.includes("type")){let o=`${this.path.label}.type`;this.read(o,()=>({op:"getNoteKind",note:this.#e()}),r=>{this.setLoadedProperty("type",lo(P(r,o)));});}}#e(){return this.requireAddressable(),this.path.handle()}},N=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}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 Q=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}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.#o(),code:e.code}),o=>g(o,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}delete(){this.#e("deleteField");}updateResult(){this.#e("updateFieldResult");}#e(t){this.requireUsablePath(),this.commandAnswering(this.path.label,()=>({op:t,field:this.#o()}),e=>g(e,this.path.label));}onLoad(t){this.selection(t,["code"]).length!==0&&this.read(this.path.label,()=>({op:"getField",field:this.#o()}),e=>{e.kind!=="field"&&a({code:"GeneralException",target:this.path.label}),this.setLoadedProperty("code",e.field.code);});}#o(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},K=class n extends D{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}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:I(this.path,this.#t)}}size(t,e){return v(t,e).length}addressAt(t,e,o){let r=v(t,e)[o];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return Q.at(this.context,t,e)}promised(t,e){return Q.promised(this.context,t,e)}};var co=["width","height","lockAspectRatio","altTextDescription"],X=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}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.#e("width",t);}get height(){return this.loadedProperty("height")}set height(t){this.#e("height",t);}get lockAspectRatio(){return this.loadedProperty("lockAspectRatio")}set lockAspectRatio(t){typeof t!="boolean"&&a({code:"InvalidArgument",target:`${this.path.label}.lockAspectRatio`}),this.#o({lockAspectRatio:t});}get altTextDescription(){return this.loadedProperty("altTextDescription")}set altTextDescription(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.altTextDescription`}),this.#o({altTextDescription:t});}delete(){let t=`${this.path.label}.delete`;this.commandAnswering(t,()=>({op:"deleteInlinePicture",picture:this.#n()}),e=>g(e,t));}onLoad(t){let e=this.selection(t,co);e.length&&this.read(this.path.label,()=>({op:"getInlinePicture",picture:this.#n()}),o=>{o.kind!=="inlinePicture"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,o.picture[r]);});}#e(t,e){(typeof e!="number"||!Number.isFinite(e)||e<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#o({[t]:e});}#o(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.#n(),properties:e}),o=>g(o,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}#n(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},Z=class n extends D{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}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:I(this.path,this.#t)}}size(t,e){return v(t,e).length}addressAt(t,e,o){let r=v(t,e)[o];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return X.at(this.context,t,e)}promised(t,e){return X.promised(this.context,t,e)}};function q(n,t,e=0){return (!Number.isInteger(n)||n<e)&&a({code:"InvalidArgument",target:t}),n}function Gt(n,t){return (!Array.isArray(n)||n.some(e=>!Array.isArray(e)||e.some(o=>typeof o!="string")))&&a({code:"InvalidArgument",target:t}),n.map(e=>[...e])}function Ee(n,t){return n!=="Start"&&n!=="End"&&a({code:"InvalidArgument",target:t}),n==="Start"?"start":"end"}var Y=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o=false){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}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=Gt(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){q(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 o=`${this.path.label}.getCell`;q(t,o),q(e,o);let r=st.promised(this.context,o);return this.read(o,()=>({op:"getTableCell",table:this.path.handle(),rowIndex:t,cellIndex:e}),i=>r.hydrateAddress({kind:"handle",handle:m(i,o)})),r}addRows(t,e,o){let r=`${this.path.label}.addRows`,i=Ee(t,r);q(e,r,1);let s=o===void 0?void 0:Gt(o,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,o){let r=`${this.path.label}.addColumns`,i=Ee(t,r);q(e,r,1);let s=o===void 0?void 0:Gt(o,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),q(t,this.path.label),q(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),q(t,this.path.label),q(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()}),o=>{o.kind!=="table"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,o.table[r]);});}},gt=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o=false){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}insertRows(t,e,o){let r=`${this.path.label}.insertRows`;t!=="Before"&&t!=="After"&&a({code:"InvalidArgument",target:r}),q(e,r,1);let i=o===void 0?void 0:Gt(o,r),s=dt.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"insertTableRows",row:this.path.handle(),location:t==="Before"?"before":"after",count:e,...i?{values:i}:{}}),d=>s.fill(d,r)),s}get cells(){return this.#t??=wt.of(this.context,`${this.path.label}.cells`,this.path,()=>({op:"getTableCells",row:this.path.handle()}))}},st=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o=false){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}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=S.promisedStory(this.context,t);return this.read(t,()=>({op:"getTableCellBody",cell:this.path.handle()}),o=>e.hydrateAddress({kind:"handle",handle:m(o,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()}),o=>{o.kind!=="tableCell"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,o.cell[r]);});}},J=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}static over(t,e,o,r){return n.of(t,e,o,()=>({op:"getTables",scope:r()}))}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return Y.at(this.context,t,e)}promised(t,e){return Y.promised(this.context,t,e)}},dt=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return gt.at(this.context,t,e)}promised(t,e){return gt.promised(this.context,t,e)}},wt=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}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)}};var ae=(i=>(i.replace="Replace",i.start="Start",i.end="End",i.before="Before",i.after="After",i))(ae||{}),se=(s=>(s.mixed="Mixed",s.unknown="Unknown",s.left="Left",s.centered="Centered",s.right="Right",s.justified="Justified",s))(se||{}),de=(e=>(e.portrait="Portrait",e.landscape="Landscape",e))(de||{}),le=(o=>(o.off="Off",o.trackAll="TrackAll",o.trackMineOnly="TrackMineOnly",o))(le||{}),ce=(r=>(r.mixed="Mixed",r.top="Top",r.center="Center",r.bottom="Bottom",r))(ce||{}),he=(d=>(d.line="Line",d.page="Page",d.next="Next",d.sectionNext="SectionNext",d.sectionContinuous="SectionContinuous",d.sectionEven="SectionEven",d.sectionOdd="SectionOdd",d))(he||{}),pe=(x=>(x.unknown="Unknown",x.richText="RichText",x.plainText="PlainText",x.picture="Picture",x.buildingBlockGallery="BuildingBlockGallery",x.checkBox="CheckBox",x.comboBox="ComboBox",x.datePicker="DatePicker",x.dropDownList="DropDownList",x.group="Group",x.repeatingSection="RepeatingSection",x.plainTextInline="PlainTextInline",x.plainTextParagraph="PlainTextParagraph",x.richTextInline="RichTextInline",x.richTextParagraphs="RichTextParagraphs",x.richTextTable="RichTextTable",x.richTextTableCell="RichTextTableCell",x.richTextTableRow="RichTextTableRow",x))(pe||{}),ue=(A=>(A.all="All",A.atMentions="AtMentions",A.commentReactions="CommentReactions",A.comments="Comments",A.contentType="ContentType",A.documentIntelligence="DocumentIntelligence",A.documentManagementPolicy="DocumentManagementPolicy",A.documentProperties="DocumentProperties",A.documentServerProperties="DocumentServerProperties",A.documentTasks="DocumentTasks",A.documentWorkspace="DocumentWorkspace",A.emailHeader="EmailHeader",A.inkAnnotations="InkAnnotations",A.removePersonalInformation="RemovePersonalInformation",A.revisions="Revisions",A.routingSlip="RoutingSlip",A.sendForReview="SendForReview",A.taskpaneWebExtensions="TaskpaneWebExtensions",A.template="Template",A.versions="Versions",A))(ue||{});var ho=["Replace","Start","End"],po=["Start","End"],uo=["Replace","Start","End"],mo=["Before","After"],go=["Replace","Start","End","Before","After"],fo=["Select","Start","End"];function ft(n,t,e){return (typeof n!="string"||!t.includes(n))&&a({code:"InvalidArgument",target:e}),n}var De=(n,t)=>ft(n,ho,t),Te=(n,t)=>ft(n,po,t),Ne=(n,t)=>ft(n,uo,t),qe=(n,t)=>ft(n,mo,t),Lt=(n,t)=>ft(n,go,t),Qt=(n,t)=>n===void 0?"Select":ft(n,fo,t);function w(n,t){return typeof n!="string"&&a({code:"InvalidArgument",target:t}),/[\r\n\f\u2028\u2029]/.test(n)&&a({code:"InvalidArgument",target:t}),n}var bo=8,ge=(d=>(d.custom="Custom",d.solid="Solid",d.hollow="Hollow",d.square="Square",d.diamonds="Diamonds",d.arrow="Arrow",d.checkmark="Checkmark",d))(ge||{}),fe=(s=>(s.none="None",s.arabic="Arabic",s.upperRoman="UpperRoman",s.lowerRoman="LowerRoman",s.upperLetter="UpperLetter",s.lowerLetter="LowerLetter",s))(fe||{}),T=class n extends p{#t;#e=new Map;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}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.#n()})),this.#t}getLevelParagraphs(t){let e=`${this.path.label}.getLevelParagraphs`,o=me(t,e);return L.overListing(this.context,e,this.path,()=>({op:"getListParagraphs",list:this.#n(),level:o}))}insertParagraph(t,e){let o=`${this.path.label}.insertParagraph`,r=w(t,o);e!=="Start"&&e!=="End"&&e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:o});let i=j.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertListParagraph",list:this.#n(),where:e==="Start"||e==="Before"?"start":"end",text:r}),s=>{i.hydrateAddress({kind:"handle",handle:m(s,o)});}),i}setLevelBullet(t,e,o,r){this.#o(t,{bullet:e,...o===void 0?{}:{charCode:o},...r===void 0?{}:{fontName:r}});}setLevelNumbering(t,e,o){this.#o(t,{numbering:e,...o===void 0?{}:{formatString:[...o]}});}setLevelStartingNumber(t,e){this.#o(t,{startingNumber:e});}setLevelIndents(t,e,o){this.#o(t,{textIndent:e,bulletNumberPictureIndent:o});}#o(t,e){let o=`${this.path.label}.levelFormat`,r=me(t,o);this.requireUsablePath();let i=this.#e.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.#e.set(r,s),this.commandAnswering(o,()=>({op:"setListLevelFormat",list:this.#n(),level:r,format:s}),d=>{g(d,o);},()=>{this.#e.get(r)===s&&this.#e.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.#n()}),o=>{this.setLoadedProperty("id",Wt(o,e));});}#n(){return this.requireAddressable(),this.path.handle()}},bt=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}getById(t){let e=`${this.path.label}.getById`,o=yo(t,e),r=this.#t,i=T.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getListById",body:r,id:o}),settle:s=>{i.hydrateAddress({kind:"handle",handle:m(s,e)});}}),i}listing(){return {op:"getLists",body:this.#t}}itemAt(t,e){return T.at(this.context,t,e)}promised(t,e){return T.promised(this.context,t,e)}},yt=class n extends p{static of(t,e,o){return new n(t,c.derived(e,o))}constructor(t,e){super(t,e);}get level(){return this.loadedProperty("level")}set level(t){let e=`${this.path.label}.level`,o=me(t,e);this.commandAnswering(e,()=>({op:"setListLevel",paragraph:this.#t(),level:o}),r=>{g(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()}),o=>{this.setLoadedProperty("level",Wt(o,e));});}#t(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}};function me(n,t){return (!Number.isInteger(n)||n<0||n>bo)&&a({code:"InvalidArgument",target:t}),n}function yo(n,t){return (!Number.isInteger(n)||n<=0)&&a({code:"InvalidArgument",target:t}),n}var be=(b=>(b.mixed="Mixed",b.none="None",b.hidden="Hidden",b.dotLine="DotLine",b.single="Single",b.word="Word",b.double="Double",b.thick="Thick",b.dotted="Dotted",b.dottedHeavy="DottedHeavy",b.dashLine="DashLine",b.dashLineHeavy="DashLineHeavy",b.dashLineLong="DashLineLong",b.dashLineLongHeavy="DashLineLongHeavy",b.dotDashLine="DotDashLine",b.dotDashLineHeavy="DotDashLineHeavy",b.twoDotDashLine="TwoDotDashLine",b.twoDotDashLineHeavy="TwoDotDashLineHeavy",b.wave="Wave",b.waveHeavy="WaveHeavy",b.waveDouble="WaveDouble",b))(be||{}),xo=["bold","italic","color","name","size","underline","strikeThrough","highlightColor","subscript","superscript"],B=class n extends p{#t;#e;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}get bold(){return this.loadedProperty("bold")}set bold(t){this.#o("bold",jt(t,`${this.path.label}.bold`));}get italic(){return this.loadedProperty("italic")}set italic(t){this.#o("italic",jt(t,`${this.path.label}.italic`));}get color(){return this.loadedProperty("color")}set color(t){this.#o("color",Kt(t,`${this.path.label}.color`));}get name(){return this.loadedProperty("name")}set name(t){this.#o("name",Kt(t,`${this.path.label}.name`));}get size(){return this.loadedProperty("size")}set size(t){this.#o("size",Ao(t,`${this.path.label}.size`));}get underline(){return this.loadedProperty("underline")}set underline(t){this.#o("underline",Kt(t,`${this.path.label}.underline`));}get highlightColor(){return this.loadedProperty("highlightColor")}set highlightColor(t){this.#o("highlightColor",t===null?null:Kt(t,`${this.path.label}.highlightColor`));}get strikeThrough(){return this.loadedProperty("strikeThrough")}set strikeThrough(t){this.#o("strikeThrough",jt(t,`${this.path.label}.strikeThrough`));}get subscript(){return this.loadedProperty("subscript")}set subscript(t){this.#o("subscript",jt(t,`${this.path.label}.subscript`));}get superscript(){return this.loadedProperty("superscript")}set superscript(t){this.#o("superscript",jt(t,`${this.path.label}.superscript`));}onLoad(t){let e=this.selection(t,xo);if(e.length===0)return;let o=`${this.path.label}.font`;this.read(o,()=>({op:"getFont",span:this.#n()}),r=>{let i=ne(r,o);for(let s of e)this.setLoadedProperty(s,i[s]);});}#o(t,e){if(this.requireUsablePath(),this.#e){this.#e[t]=e,t==="subscript"&&e===true&&(this.#e.superscript=false),t==="superscript"&&e===true&&(this.#e.subscript=false);return}let o={[t]:e};t==="subscript"&&e===true&&(o.superscript=false),t==="superscript"&&e===true&&(o.subscript=false),this.#e=o;let r=`${this.path.label}.${t}`;this.commandAnswering(this.path.label,()=>({op:"setFont",span:this.#n(),font:o}),i=>{g(i,r);},()=>{this.#e===o&&(this.#e=void 0);});}#n(){return this.requireAddressable(),I(this.path,this.#t)}};function jt(n,t){return typeof n!="boolean"&&a({code:"InvalidArgument",target:t}),n}function Ao(n,t){return (typeof n!="number"||!Number.isFinite(n))&&a({code:"InvalidArgument",target:t}),n}function Kt(n,t){return (typeof n!="string"||n.length===0)&&a({code:"InvalidArgument",target:t}),n}var vo=16,j=class n extends p{#t;#e;#o;#n;#s;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}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.#a("style",pt(t,`${this.path.label}.style`));}get shapes(){return this.#e??=G.of(this.context,`${this.path.label}.shapes`,this.path,"paragraph"),this.#e}get font(){return this.#t??=B.of(this.context,`${this.path.label}.font`,this.path,"paragraph"),this.#t}get alignment(){return this.loadedProperty("alignment")}set alignment(t){this.#a("alignment",Ro(t,`${this.path.label}.alignment`));}get readingOrder(){return this.loadedProperty("readingOrder")}set readingOrder(t){this.#a("readingOrder",Po(t,`${this.path.label}.readingOrder`));}get firstLineIndent(){return this.loadedProperty("firstLineIndent")}set firstLineIndent(t){this.#a("firstLineIndent",xt(t,`${this.path.label}.firstLineIndent`));}get leftIndent(){return this.loadedProperty("leftIndent")}set leftIndent(t){this.#a("leftIndent",xt(t,`${this.path.label}.leftIndent`));}get rightIndent(){return this.loadedProperty("rightIndent")}set rightIndent(t){this.#a("rightIndent",xt(t,`${this.path.label}.rightIndent`));}get lineSpacing(){return this.loadedProperty("lineSpacing")}set lineSpacing(t){this.#a("lineSpacing",xt(t,`${this.path.label}.lineSpacing`));}get spaceBefore(){return this.loadedProperty("spaceBefore")}set spaceBefore(t){this.#a("spaceBefore",xt(t,`${this.path.label}.spaceBefore`));}get spaceAfter(){return this.loadedProperty("spaceAfter")}set spaceAfter(t){this.#a("spaceAfter",xt(t,`${this.path.label}.spaceAfter`));}get list(){return this.#o??=this.#i(`${this.path.label}.list`),this.#o}getRange(t="Whole"){let e=`${this.path.label}.getRange`;["Whole","Content","Start","End","Before","After"].includes(t)||a({code:"InvalidArgument",target:e});let o=y.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{paragraph:this.#r()},location:t}),r=>{o.hydrateAddress({kind:"span",span:O(r,e)});}),o}startNewList(){let t=`${this.path.label}.startNewList`,e=T.promised(this.context,t,false);return this.commandAnswering(t,()=>({op:"startNewList",paragraph:this.#r()}),o=>{e.hydrateAddress({kind:"handle",handle:m(o,t)});}),e}attachToList(t,e){let o=`${this.path.label}.attachToList`;(!Number.isSafeInteger(t)||t<=0||!Number.isInteger(e)||e<0||e>8)&&a({code:"InvalidArgument",target:o});let r=T.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"attachToList",paragraph:this.#r(),listId:t,level:e}),i=>{r.hydrateAddress({kind:"handle",handle:m(i,o)});}),r}detachFromList(){let t=`${this.path.label}.detachFromList`;this.commandAnswering(t,()=>({op:"detachFromList",paragraph:this.#r()}),e=>{g(e,t);});}get listItem(){return this.#n??=yt.of(this.context,`${this.path.label}.listItem`,this.path),this.#n}clear(){this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{paragraph:this.#r()},text:""}));}delete(){let t=`${this.path.label}.delete`;this.commandAnswering(t,()=>({op:"deleteParagraph",paragraph:this.#r()}),e=>{e.kind!=="applied"&&e.kind!=="span"&&a({code:"GeneralException",target:t});});}insertText(t,e){let o=`${this.path.label}.insertText`,r=w(t,o),i=Ne(e,o),s=y.promised(this.context,o,false);return this.commandAnswering(o,()=>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:O(d,o)});}),s}insertParagraph(t,e){let o=`${this.path.label}.insertParagraph`,r=w(t,o),i=qe(e,o),s=n.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertParagraph",anchor:{paragraph:this.#r()},where:i==="Before"?"before":"after",text:r}),d=>{d.kind!=="handle"&&a({code:"GeneralException",target:o}),s.hydrateAddress({kind:"handle",handle:d.handle});}),s}split(t,e,o){let r=`${this.path.label}.split`,i=Oo(t,r),s=$e(e,`${r}.trimDelimiters`),d=$e(o,`${r}.trimSpacing`),h=$.answered(this.context,r,this.path);return this.commandAnswering(r,()=>({op:"splitParagraph",paragraph:this.#r(),delimiters:i,...s?{trimDelimiters:true}:{},...d?{trimSpacing:true}:{}}),u=>{h.fill(u,r);}),h}onLoad(t){let e=this.selection(t,["text","uniqueLocalId",...Be]);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 o=Be.filter(i=>e.includes(i));if(o.length===0)return;let r=`${this.path.label}.paragraphFormat`;this.read(r,()=>({op:"getParagraphFormat",paragraph:{paragraph:this.#r()}}),i=>{let s=re(i,r);for(let d of o)this.setLoadedProperty(d,s[d]);});}#a(t,e){if(this.requireUsablePath(),this.#s){this.#s[t]=e;return}let o={[t]:e};this.#s=o;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.paragraphFormat`,()=>({op:"setParagraphFormat",paragraph:{paragraph:this.#r()},format:o}),i=>{g(i,r);},()=>{this.#s===o&&(this.#s=void 0);});}#i(t){let e=T.promised(this.context,t,false);return this.read(t,()=>({op:"getParagraphList",paragraph:this.#r()}),o=>{e.hydrateAddress({kind:"handle",handle:m(o,t)});}),e}#r(){return this.requireAddressable(),this.path.handle()}},Be=["style","alignment","firstLineIndent","leftIndent","rightIndent","lineSpacing","spaceBefore","spaceAfter","readingOrder"],Co=["Left","Centered","Right","Justified"];function Ro(n,t){return Co.includes(n)||a({code:"InvalidArgument",target:t}),n}function Po(n,t){return n!=="LeftToRight"&&n!=="RightToLeft"&&a({code:"InvalidArgument",target:t}),n}function xt(n,t){return (typeof n!="number"||!Number.isFinite(n))&&a({code:"InvalidArgument",target:t}),n}function Oo(n,t){(!Array.isArray(n)||n.length===0||n.length>vo)&&a({code:"InvalidArgument",target:t});for(let e of n)(typeof e!="string"||e.length===0)&&a({code:"InvalidArgument",target:t});return [...n]}function $e(n,t){return n!==void 0&&typeof n!="boolean"&&a({code:"InvalidArgument",target:t}),n===true}var L=class n extends D{#t;static of(t,e,o){return new n(t,c.derived(e,o),null)}static overListing(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}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,o){let r=v(t,e)[o];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return j.at(this.context,t,e)}promised(t,e){return j.promised(this.context,t,e)}},$=class n extends D{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}static answered(t,e,o){return new n(t,c.derived(e,o),null)}constructor(t,e,o){super(t,e),this.#t=o;}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 Vt(t,e).length}addressAt(t,e,o){let r=Vt(t,e)[o];return r?{kind:"span",span:r}:void 0}itemAt(t,e){return y.at(this.context,t,e)}promised(t,e){return y.promised(this.context,t,e)}};var Me=4096,M=class n extends p{#t;#e=new Map;#o;#n;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}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.#a("tag",{tag:ye(t,`${this.path.label}.tag`)});}get title(){return this.loadedProperty("title")}set title(t){this.#a("title",{title:ye(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.#i("cannotDelete",t);}get cannotEdit(){let t=this.loadedProperty("lock");return t==="contentLocked"||t==="sdtContentLocked"}set cannotEdit(t){this.#i("cannotEdit",t);}get placeholderShown(){return this.loadedProperty("placeholderShown")}get temporary(){return this.loadedProperty("temporary")}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#o??=L.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getContentControlParagraphs",contentControl:this.#r()})),this.#o}get contentControls(){return this.#n??=F.of(this.context,`${this.path.label}.contentControls`,this.path,{contentControl:this.#r()}),this.#n}getRange(t){let e=`${this.path.label}.getRange`,o=ko(t??"Whole",e),r=this.#e.get(o);if(r)return r;let i=this.#s(e,o);return this.#e.set(o,i),i}setValue(t){let e=`${this.path.label}.setValue`,o=Io(t,e);this.command("setValue",()=>({op:"setContentControlValue",contentControl:this.#r(),value:o}));}insertText(t,e){let o=`${this.path.label}.insertText`,r=w(t,o),i=e==="Replace"?"replace":e==="Start"?"start":e==="End"?"end":a({code:"InvalidArgument",target:o}),s=y.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertContentControlText",contentControl:this.#r(),text:r,at:i}),d=>{s.hydrateAddress({kind:"span",span:O(d,o)});}),s}delete(t){let e=`${this.path.label}.delete`;typeof t!="boolean"&&a({code:"InvalidArgument",target:e}),this.command("delete",()=>({op:"deleteContentControl",contentControl:this.#r(),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.#r()})),e.includes("tag")&&this.loadTextInto("tag",()=>({op:"getContentControlTag",contentControl:this.#r()})),e.includes("title")&&this.loadTextInto("title",()=>({op:"getContentControlTitle",contentControl:this.#r()})),e.includes("subtype")&&this.loadTextInto("subtype",()=>({op:"getContentControlSubtype",contentControl:this.#r()})),e.includes("isBound")){let r=`${this.path.label}.isBound`;this.read(r,()=>({op:"getContentControlIsBound",contentControl:this.#r()}),i=>{this.setLoadedProperty("isBound",at(i,r));});}if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getContentControlText",contentControl:this.#r(),projection:this.revisionTextView()})),e.includes("cannotDelete")||e.includes("cannotEdit")){let r=`${this.path.label}.lock`;this.read(r,()=>({op:"getContentControlLock",contentControl:this.#r()}),i=>{this.setLoadedProperty("lock",P(i,r));});}if(e.includes("placeholderShown")){let r=`${this.path.label}.placeholderShown`;this.read(r,()=>({op:"getContentControlPlaceholderShown",contentControl:this.#r()}),i=>{this.setLoadedProperty("placeholderShown",at(i,r));});}if(!e.includes("temporary"))return;let o=`${this.path.label}.temporary`;this.read(o,()=>({op:"getContentControlTemporary",contentControl:this.#r()}),r=>{this.setLoadedProperty("temporary",at(r,o));});}#s(t,e){let o=y.promised(this.context,t,false);return this.read(t,()=>({op:"getContentControlRange",contentControl:this.#r(),location:e}),r=>{o.hydrateAddress({kind:"span",span:O(r,t)});}),o}#a(t,e){this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#r(),...e}));}#i(t,e){let o=`${this.path.label}.${t}`;if(typeof e!="boolean"&&a({code:"InvalidArgument",target:o}),this.requireUsablePath(),this.#t){this.#t[t]=e;return}let r={[t]:e};this.#t=r,this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#r(),...r}),()=>{this.#t===r&&(this.#t=void 0);});}#r(){return this.requireAddressable(),this.path.handle()}},F=class n extends C{#t;#e;static of(t,e,o,r){return new n(t,c.derived(e,o),r,()=>({op:"getContentControls",scope:r}))}constructor(t,e,o,r){super(t,e),this.#t=o,this.#e=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 o=this.#t,r=M.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getContentControlById",scope:o,id:t}),settle:i=>{r.hydrateAddress({kind:"handle",handle:m(i,e)});}}),r}getByTag(t){let e=`${this.path.label}.getByTag`,o=He(t,e),r=this.#t;return new n(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTag",scope:r,tag:o}))}getByTitle(t){let e=`${this.path.label}.getByTitle`,o=He(t,e),r=this.#t;return new n(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTitle",scope:r,title:o}))}listing(){return this.#e()}itemAt(t,e){return M.at(this.context,t,e)}promised(t,e){return M.promised(this.context,t,e)}};function ye(n,t){return (typeof n!="string"||n.length>Me)&&a({code:"InvalidArgument",target:t}),n}function He(n,t){let e=ye(n,t);return e.length===0&&a({code:"InvalidArgument",target:t}),e}function ko(n,t){switch(n){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 Io(n,t){(typeof n!="object"||n===null)&&a({code:"InvalidArgument",target:t});let e=n;if(e.kind==="text"||e.kind==="listItem"){let o=e.kind==="text"?e.text:e.value;return (typeof o!="string"||o.length>Me)&&a({code:"InvalidArgument",target:t}),e.kind==="text"?{kind:"text",text:o}:{kind:"listItem",value:o}}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 So(n,t){return t<1||t>12?0:t===2?n%4===0&&n%100!==0||n%400===0?29:28:t===4||t===6||t===9||t===11?30:31}function Fe(n){if(n.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(n.trim());if(!t)return null;let e=Number(t[1]),o=Number(t[2]),r=Number(t[3]),i=So(e,o);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 u=t[7],H=u===void 0?0:Number(u.padEnd(3,"0").slice(0,3));if(Number.isNaN(H))return null;let k=`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}.${String(H).padStart(3,"0")}Z`,Tt=Date.parse(k);if(Number.isNaN(Tt))return null;let f=t[8];if(f==="Z")return new Date(Tt);let W=Number(f.slice(1,3)),U=Number(f.slice(4,6));if(U>59||W>14||W===14&&U!==0)return null;let ct=f[0]==="+"?1:-1,nt=new Date(Tt-ct*(W*36e5+U*6e4));return Number.isNaN(nt.getTime())?null:nt}var Xt=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 o=this.selection(t,["authorName","creationDate","id","text",...e]);if(o.includes("authorName")&&this.loadTextInto("authorName",()=>({op:"getCommentAuthor",comment:this.commentHandle()})),o.includes("text")&&this.loadTextInto("text",()=>({op:"getCommentText",comment:this.commentHandle()})),o.includes("id")&&this.loadTextInto("id",()=>({op:"getCommentId",comment:this.commentHandle()})),o.includes("creationDate")){let i=`${this.path.label}.creationDate`;this.read(i,()=>({op:"getCommentDate",comment:this.commentHandle()}),s=>{this.setLoadedProperty("creationDate",Fe(P(s,i)));});}if(!o.includes("resolved"))return;let r=`${this.path.label}.resolved`;this.read(r,()=>({op:"getCommentResolved",comment:this.commentHandle()}),i=>{this.setLoadedProperty("resolved",at(i,r));});}commentHandle(){return this.requireAddressable(),this.path.handle()}},lt=class n extends Xt{static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}onLoad(t){this.loadCommentFields(t,[]);}},Et=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return lt.at(this.context,t,e)}promised(t,e){return lt.promised(this.context,t,e)}},_=class n extends Xt{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}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}),o=>{g(o,e);});}get replies(){return this.#t??=Et.of(this.context,`${this.path.label}.replies`,this.path,()=>({op:"getCommentReplies",comment:this.commentHandle()})),this.#t}getRange(){let t=`${this.path.label}.getRange`,e=y.promised(this.context,t,false);return this.read(t,()=>({op:"getCommentRange",comment:this.commentHandle()}),o=>{e.hydrateAddress({kind:"span",span:O(o,t)});}),e}reply(t){let e=`${this.path.label}.reply`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:e});let o=this.internals.author;(typeof o!="string"||o.trim().length===0)&&a({code:"NotSupported",target:e});let r=lt.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"replyToComment",comment:this.commentHandle(),text:t,author:o}),i=>{r.hydrateAddress({kind:"handle",handle:m(i,e)});}),r}onLoad(t){this.loadCommentFields(t,["resolved"]);}},tt=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return _.at(this.context,t,e)}promised(t,e){return _.promised(this.context,t,e)}},V=class n extends p{static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}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=y.promised(this.context,t,false);return this.read(t,()=>({op:"getRevisionRange",revision:this.#t()}),o=>{e.hydrateAddress({kind:"span",span:O(o,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 o=`${this.path.label}.date`;this.read(o,()=>({op:"getRevisionDate",revision:this.#t()}),r=>{this.setLoadedProperty("date",Fe(P(r,o)));});}static batchHandle(t,e,o="RevisionCollection.resolve"){return (!(t instanceof n)||t.context!==e)&&a({code:"InvalidArgument",target:o}),t.#t()}#t(){return this.requireAddressable(),this.path.handle()}},et=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}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 o=`${this.path.label}.resolve`;(!["accept","reject"].includes(t)||e!==void 0&&!Array.isArray(e))&&a({code:"InvalidArgument",target:o});let r=e===void 0?void 0:[...e],{result:i,fill:s}=oe(o);return this.enqueue({sort:"write",label:o,plan:()=>({op:"resolveRevisionBatch",body:this.#t,action:t,...r===void 0?{}:{revisions:r.map(d=>V.batchHandle(d,this.context))}}),settle:d=>{d.kind!=="revisionBatch"&&a({code:"GeneralException",target:o}),s(d.result);}}),i}setAuthor(t,e,o){let r=`${this.path.label}.setAuthor`,i=o?.date,s=Array.isArray(e)?e:void 0,d=e!==void 0&&!Array.isArray(e)?e?.authors:void 0;(typeof t!="string"||t.trim().length===0||e!==void 0&&!Array.isArray(e)&&(typeof e!="object"||e===null||!Array.isArray(d)||d.some(k=>typeof k!="string"))||o!==void 0&&(typeof o!="object"||o===null)||i!==void 0&&(!(i instanceof Date)||Number.isNaN(i.getTime()))||s?.some(k=>!(k instanceof V)||k.context!==this.context))&&a({code:"InvalidArgument",target:r});let h=s===void 0?void 0:[...s],{result:u,fill:H}=oe(r);return this.enqueue({sort:"write",label:r,plan:()=>({op:"setRevisionAuthorBatch",body:this.#t,author:t,...i===void 0?{}:{date:i.toISOString()},...d===void 0?{}:{authors:[...d]},...h===void 0?{}:{revisions:h.map(k=>V.batchHandle(k,this.context,r))}}),settle:k=>{k.kind!=="revisionAuthors"&&a({code:"GeneralException",target:r}),H(k.result);}}),u}listing(){return {op:"getRevisions",body:this.#t}}itemAt(t,e){return V.at(this.context,t,e)}promised(t,e){return V.promised(this.context,t,e)}commandOn(t,e){let o=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:o,plan:e,settle:r=>{g(r,o);}});}};var wo=new Set(["matchCase","matchWholeWord","ignorePunct","ignoreSpace","matchWildcards"]);function Zt(n,t){if(n===void 0)return;typeof n!="object"&&a({code:"InvalidArgument",target:t});for(let[o,r]of Object.entries(n))wo.has(o)||a({code:"InvalidArgument",target:`${t}.${o}`}),r!==void 0&&typeof r!="boolean"&&a({code:"InvalidArgument",target:`${t}.${o}`});let e={...n.matchCase===void 0?{}:{matchCase:n.matchCase},...n.matchWholeWord===void 0?{}:{matchWholeWord:n.matchWholeWord},...n.ignorePunct===void 0?{}:{ignorePunct:n.ignorePunct},...n.ignoreSpace===void 0?{}:{ignoreSpace:n.ignoreSpace},...n.matchWildcards===void 0?{}:{matchWildcards:n.matchWildcards}};return Object.keys(e).length===0?void 0:e}var y=class n extends p{#t;#e;#o;#n;#s;#a;static at(t,e,o){return o.kind!=="span"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.ofSpan(e,o.span),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}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.#s??=B.of(this.context,`${this.path.label}.font`,this.path,"span"),this.#s}get paragraphs(){return this.#n??=L.of(this.context,`${this.path.label}.paragraphs`,this.path),this.#n}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,o=pt(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:I(this.path,"span"),name:o}));}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.#i(),target:t}));}get bookmarks(){let t=this.#i();return this.#a??=ot.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{start:t.start,end:t.end}})),this.#a}search(t,e){let o=`${this.path.label}.search`;typeof t!="string"&&a({code:"InvalidArgument",target:o});let r=Zt(e,o),i=this.#i();return $.of(this.context,o,this.path,()=>({op:"search",scope:i,text:t,options:{...r??{},projection:this.revisionTextView()}}))}insertText(t,e){let o=`${this.path.label}.insertText`,r=w(t,o),i=Lt(e,o);this.requireUsablePath();let s=n.promised(this.context,o,false);return this.commandAnswering(o,()=>{let d=this.#i();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:O(d,o)});}),s}delete(){this.requireUsablePath(),this.commandDiscarding("delete",()=>({op:"replaceSpan",span:this.#i(),text:""}));}clear(){let t=this.#i();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 o=this.internals.author;(typeof o!="string"||o.trim().length===0)&&a({code:"NotSupported",target:e});let r=_.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertComment",span:this.#i(),text:t,author:o}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:e}),r.hydrateAddress(i);}),r}insertContentControl(t){let e=`${this.path.label}.insertContentControl`,o=t??"RichText";o!=="RichText"&&o!=="PlainText"&&o!=="DatePicker"&&a({code:"NotSupported",target:e});let r=M.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertContentControl",span:this.#i(),subtype:o==="DatePicker"?"date":o==="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??=J.over(this.context,`${this.path.label}.tables`,this.path,()=>I(this.path,"span"))}get fields(){return this.requireUsablePath(),this.#e??=K.of(this.context,`${this.path.label}.fields`,this.path,"span")}insertField(t,e,o,r){let i=`${this.path.label}.insertField`;(e!==void 0&&typeof e!="string"||o!==void 0&&typeof o!="string"||r!==void 0&&typeof r!="boolean")&&a({code:"InvalidArgument",target:i});let s=Lt(t,i);this.requireUsablePath();let d=Q.promised(this.context,i,false);return this.commandAnswering(i,()=>({op:"insertField",span:this.#i(),location:s,...e===void 0?{}:{fieldType:e},...o===void 0?{}:{text:o},...r===void 0?{}:{removeFormatting:r}}),h=>d.hydrateAddress({kind:"handle",handle:m(h,i)})),d}get inlinePictures(){return this.requireUsablePath(),this.#o??=Z.of(this.context,`${this.path.label}.inlinePictures`,this.path,"span")}insertInlinePictureFromBase64(t,e){let o=`${this.path.label}.insertInlinePictureFromBase64`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:o});let r=Lt(e,o);this.requireUsablePath();let i=X.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertInlinePicture",span:this.#i(),base64:t,location:r}),s=>{i.hydrateAddress({kind:"handle",handle:m(s,o)});}),i}insertBreak(t,e){let o=`${this.path.label}.insertBreak`;e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:o});let r=e;this.requireUsablePath(),this.commandAnswering(o,()=>({op:"insertBreak",span:this.#i(),breakType:t,location:r}),i=>g(i,o));}insertTable(t,e,o,r){let i=`${this.path.label}.insertTable`;(!Number.isInteger(t)||!Number.isInteger(e)||t<1||e<1||!["Before","After"].includes(o))&&a({code:"InvalidArgument",target:i}),r!==void 0&&(!Array.isArray(r)||r.some(h=>!Array.isArray(h)||h.some(u=>typeof u!="string")))&&a({code:"InvalidArgument",target:i});let s=r?.map(h=>[...h]),d=Y.promised(this.context,i);return this.commandAnswering(i,()=>({op:"insertTable",span:I(this.path,"span"),location:o,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 o=`${this.path.label}.insertParagraph`,r=w(t,o),i=Lt(e,o);i!=="Before"&&i!=="After"&&a({code:"InvalidArgument",target:o});let s=this.#i(),d=i==="Before"?s.start.paragraph:s.end.paragraph,h=j.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertParagraph",anchor:{paragraph:d},where:i==="Before"?"before":"after",text:r}),u=>{u.kind!=="handle"&&a({code:"GeneralException",target:o}),h.hydrateAddress({kind:"handle",handle:u.handle});}),h}select(t){let e=`${this.path.label}.select`,o=Qt(t,e);this.requireAddressable(),this.internals.capabilities.selection||a({code:"NotSupported",target:e});let r=this.#i();this.command("select",()=>({op:"selectSpan",span:r,mode:o==="Select"?"select":o==="Start"?"start":"end"}));}onLoad(t){let e=this.selection(t,["text","style","hyperlink"]);if(e.includes("hyperlink")&&this.loadTextInto("hyperlink",()=>({op:"getHyperlink",span:this.#i()})),e.includes("text")){let r=`${this.path.label}.text`;this.read(r,()=>({op:"getSpanText",span:this.#i(),projection:this.revisionTextView()}),i=>{this.setLoadedProperty("text",P(i,r));});}if(!e.includes("style"))return;let o=`${this.path.label}.style`;this.requireUsablePath(),this.read(o,()=>({op:"getStyle",span:I(this.path,"span")}),r=>{this.setLoadedProperty("style",Ot(r,o));});}#i(){return this.requireAddressable(),this.path.span()}};var At=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}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.#e(`${this.path.label}.range`),this.#t}select(t){let e=`${this.path.label}.select`,o=Qt(t,e);this.requireUsablePath(),this.internals.capabilities.selection||a({code:"NotSupported",target:e}),this.command("select",()=>({op:"selectBookmark",bookmark:this.#o(),mode:o==="Select"?"select":o==="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.#o()}),o=>{this.setLoadedProperty("name",P(o,e));});}#e(t){let e=y.promised(this.context,t,false);return this.read(t,()=>({op:"getBookmarkRange",bookmark:this.#o()}),o=>{e.hydrateAddress({kind:"span",span:O(o,t)});}),e}#o(){return this.requireAddressable(),this.path.handle()}},ot=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}listing(){return this.#t()}itemAt(t,e){return At.at(this.context,t,e)}promised(t,e){return At.promised(this.context,t,e)}};var S=class n extends p{#t;#e;get footnotes(){return this.#t??=N.of(this.context,`${this.path.label}.footnotes`,this.path,()=>({op:"getNotes",document:this.internals.roots().document,scope:this.#l(),noteKind:"footnote"}))}get endnotes(){return this.#e??=N.of(this.context,`${this.path.label}.endnotes`,this.path,()=>({op:"getNotes",document:this.internals.roots().document,scope:this.#l(),noteKind:"endnote"}))}#o;#n;#s;#a;#i;#r;#d;#c;#h;#u;static main(t,e){return new n(t,c.of(e,it(t).roots().body))}static promisedStory(t,e){return new n(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.#i??=this.paragraphsUnder(`${this.path.label}.paragraphs`),this.#i}get bookmarks(){let t=this.#l();return this.#r??=ot.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{body:t}})),this.#r}get font(){return this.#d??=B.of(this.context,`${this.path.label}.font`,this.path,"body"),this.#d}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`,o=pt(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:I(this.path,"body"),name:o}));}get lists(){return this.#c??=bt.of(this.context,`${this.path.label}.lists`,this.path,this.#l()),this.#c}get contentControls(){return this.#h??=F.of(this.context,`${this.path.label}.contentControls`,this.path,{body:this.#l()}),this.#h}getComments(){let t=`${this.path.label}.getComments`,e=this.#l();return tt.of(this.context,t,this.path,()=>({op:"getComments",scope:{body:e}}))}get revisions(){return this.#u??=et.of(this.context,`${this.path.label}.revisions`,this.path,this.#l()),this.#u}getRange(t="Whole"){let e=`${this.path.label}.getRange`;this.requireUsablePath();let o=y.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{body:this.path.handle()},location:t}),r=>{o.hydrateAddress({kind:"span",span:O(r,e)});}),o}search(t,e){let o=`${this.path.label}.search`;typeof t!="string"&&a({code:"InvalidArgument",target:o});let r=Zt(e,o),i=this.#l();return $.of(this.context,o,this.path,()=>({op:"search",scope:{body:i},text:t,options:{...r??{},projection:this.revisionTextView()}}))}clear(){let t=this.#l();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{body:t},text:""}));}insertText(t,e){let o=`${this.path.label}.insertText`,r=w(t,o),i=De(e,o);this.requireUsablePath();let s=y.promised(this.context,o,false);return this.commandAnswering(o,()=>i==="Replace"?{op:"replaceSpan",span:{body:this.#l()},text:r}:{op:"insertText",at:{body:this.#l(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:O(d,o)});}),s}insertParagraph(t,e){let o=`${this.path.label}.insertParagraph`,r=w(t,o),i=Te(e,o),s=this.#l(),d=j.promised(this.context,o,false);return this.commandAnswering(o,()=>({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:o}),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.#l(),projection:this.revisionTextView()})),e.includes("style")&&this.#p();}#p(){let t=`${this.path.label}.style`;this.requireUsablePath(),this.read(t,()=>({op:"getStyle",span:I(this.path,"body")}),e=>{this.setLoadedProperty("style",Ot(e,t));});}get fields(){return this.requireUsablePath(),this.#n??=K.of(this.context,`${this.path.label}.fields`,this.path,"body")}get inlinePictures(){return this.requireUsablePath(),this.#s??=Z.of(this.context,`${this.path.label}.inlinePictures`,this.path,"body")}get shapes(){return this.requireUsablePath(),this.#a??=G.of(this.context,`${this.path.label}.shapes`,this.path,"body")}get tables(){return this.requireUsablePath(),this.#o??=J.over(this.context,`${this.path.label}.tables`,this.path,()=>({body:this.#l()}))}#l(){return this.requireAddressable(),this.path.handle()}};var Lo=Object.freeze({Primary:"default",FirstPage:"first",EvenPages:"even"}),jo=["pageWidth","pageHeight","orientation","topMargin","rightMargin","bottomMargin","leftMargin"],Dt=class n extends p{#t;static of(t,e,o){return new n(t,c.derived(e,o))}constructor(t,e){super(t,e);}get pageWidth(){return this.loadedProperty("pageWidth")}set pageWidth(t){this.#e("pageWidth",vt(t,`${this.path.label}.pageWidth`));}get pageHeight(){return this.loadedProperty("pageHeight")}set pageHeight(t){this.#e("pageHeight",vt(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.#e("orientation",t==="Portrait"?"portrait":"landscape");}get topMargin(){return this.loadedProperty("topMargin")}set topMargin(t){this.#e("topMargin",vt(t,`${this.path.label}.topMargin`));}get bottomMargin(){return this.loadedProperty("bottomMargin")}set bottomMargin(t){this.#e("bottomMargin",vt(t,`${this.path.label}.bottomMargin`));}get leftMargin(){return this.loadedProperty("leftMargin")}set leftMargin(t){this.#e("leftMargin",vt(t,`${this.path.label}.leftMargin`));}get rightMargin(){return this.loadedProperty("rightMargin")}set rightMargin(t){this.#e("rightMargin",vt(t,`${this.path.label}.rightMargin`));}onLoad(t){let e=this.selection(t,jo);if(e.length===0)return;let o=`${this.path.label}.pageSetup`;this.read(o,()=>({op:"getPageSetup",section:this.#o()}),r=>{let i=ie(r,o);for(let s of e)this.setLoadedProperty(s,s==="orientation"?i.orientation==="landscape"?"Landscape":"Portrait":i[s]);});}#e(t,e){if(this.requireUsablePath(),this.#t){this.#t[t]=e;return}let o={[t]:e};this.#t=o;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.pageSetup`,()=>({op:"setPageSetup",section:this.#o(),setup:o}),i=>{g(i,r);},()=>{this.#t===o&&(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}},Ct=class n extends p{#t;#e;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){return this.#e??=S.main(this.context,`${this.path.label}.body`),this.#e}get pageSetup(){return this.#t??=Dt.of(this.context,`${this.path.label}.pageSetup`,this.path),this.#t}getHeader(t){return this.#o("header",t,"getHeader")}getFooter(t){return this.#o("footer",t,"getFooter")}getNext(){let t=`${this.path.label}.getNext`,e=n.promised(this.context,t,false),o=this.internals.roots().document;return this.read(t,()=>({op:"getSections",document:o}),r=>{let i=v(r,t),s=i.findIndex(h=>h.ref===this.#n().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,[]);}#o(t,e,o){let r=`${this.path.label}.${o}`,i=Lo[e];i===void 0&&a({code:"InvalidArgument",target:r});let s=S.promisedStory(this.context,r);return this.read(r,()=>({op:"getFurniture",section:this.#n(),kind:t,variant:i}),d=>{s.hydrateAddress({kind:"handle",handle:m(d,r)});}),s}#n(){return this.requireAddressable(),this.path.handle()}},Rt=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return Ct.at(this.context,t,e)}promised(t,e){return Ct.promised(this.context,t,e)}};function vt(n,t){return (typeof n!="number"||!Number.isFinite(n)||n<0)&&a({code:"InvalidArgument",target:t}),n}var Pt=class n extends p{#t;#e;#o;#n;#s;#a;#i;#r;#d;static open(t){return new n(t)}constructor(t){super(t,c.of("document",it(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.#e??=S.main(this.context,"document.body"),this.#e}removeDocumentInformation(t){this.command(`${this.path.label}.removeDocumentInformation`,()=>({op:"removeDocumentInformation",removeDocInfoType:t}));}get properties(){return this.#t??=ht.of(this.context,this.path),this.#t}get paragraphs(){return this.#o??=this.body.paragraphsUnder("document.paragraphs"),this.#o}get sections(){let t=this.path.handle();return this.#n??=Rt.of(this.context,"document.sections",this.path,()=>({op:"getSections",document:t})),this.#n}get contentControls(){return this.#i??=F.of(this.context,"document.contentControls",this.path,{body:this.internals.roots().body}),this.#i}get comments(){return this.#s??=tt.of(this.context,"document.comments",this.path,()=>({op:"getComments",scope:{body:this.internals.roots().body}})),this.#s}get revisions(){return this.#a??=et.of(this.context,"document.revisions",this.path,this.internals.roots().body),this.#a}get footnotes(){let t=this.path.handle();return this.#r??=N.of(this.context,"document.footnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"footnote"})),this.#r}get endnotes(){let t=this.path.handle();return this.#d??=N.of(this.context,"document.endnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"endnote"})),this.#d}onLoad(t){if(t.select.length===0)return;this.selection(t,["changeTrackingMode"]).includes("changeTrackingMode")&&this.loadTextInto("changeTrackingMode",()=>({op:"getChangeTrackingMode"}));}};function Yt(n){let t=n.host,e=Object.freeze({...t.capabilities,save:n.save&&t.capabilities.save}),o=typeof n.author=="string"&&n.author.trim().length>0?n.author:void 0,r=n.revisionTextView??"allMarkup";r!=="allMarkup"&&r!=="original"&&a({code:"InvalidArgument",target:"revisionTextView"});let i=false,s=null,d=f=>{i&&a({code:"RuntimeDisposed",...f===void 0?{}:{target:f}});},h=()=>{if(s)return s;d("document");let f=ct=>{try{return t.execute({operations:ct})}catch(nt){try{n.onException?.(nt,ct);}catch{}throw nt}},W=Ve(f([{op:"getDocument"}]),"document"),U=Ve(f([{op:"getBody",document:W}]),"document.body");return s={document:W,body:U},s},u={host:t,capabilities:e,...o===void 0?{}:{author:o},revisionTextView:r,...n.onRefusal?{onRefusal:n.onRefusal}:{},...n.onException?{onException:n.onException}:{},id:{},roots:h,assertLive:d,openDocument:f=>Pt.open(f)};try{h();}catch{s=null;}async function H(f,W){d();let U=typeof f=="function"?f:W,ct=typeof f=="function"?[]:Array.isArray(f)?f:[f];typeof U!="function"&&a({code:"InvalidArgument",target:"run"});let{context:nt,adopt:x,finish:Ge}=It.begin(u);try{return x(ct),await U(nt)}finally{Ge();}}let k={capabilities:e,run:H,dispose(){i||(i=true,s=null,t.dispose());}};return n.save?{...k,async save(){d("save"),e.save||a({code:"NotSupported",target:"save"});let f=t.save();if(!f.ok)throw qt(f.error,{target:"save"});return f.bytes}}:k}function Ve(n,t){let e=n.results[0];if(e?.status==="error")throw qt(e.error,{target:t});if(e?.status!=="ok")throw new R({code:"GeneralException",target:t});return m(e.value,t)}function We(n,t={}){let e=createBrowserAutomationHost(n);return Yt({host:e,save:false,onRefusal:(o,r)=>{let{code:i,tracked:s}=ee(o,e,r);reportAutomationRefusal(n,i,s,Bt(o));},onException:(o,r)=>reportAutomationException(n,o,$t(e,r)),...t.author===void 0?{}:{author:t.author},...t.revisionTextView===void 0?{}:{revisionTextView:t.revisionTextView}})}function Ue(n){return createAutomationPaginationProvider(n)}function $o(n){if(n){for(let t of n)if(t.collaboration)return t.collaboration}}function Ho(n){let t=[n?.zip?.maxEntries,n?.zip?.maxTotalBytes,n?.xml?.maxBytes,n?.xml?.maxElements,n?.maxXmlParts,n?.maxRelationships],e=n?.zip?.maxRatio;(t.some(o=>o!==void 0&&(!Number.isInteger(o)||o<0))||e!==void 0&&(!Number.isFinite(e)||e<0))&&a({code:"InvalidArgument",target:"createServer"});}async function xe(n,t={}){let e=ke((t.modules??[]).flatMap(s=>s.onDiagnostic?[s.onDiagnostic]:[])),o=Date.now();try{Ho(t.limits);}catch(s){throw e?.openRejected(n,"invalid-limits"),s}let r=$o(t.modules),i;try{i=createServerAutomationHost(n,{...t.pagination?{pagination:Ue(t.pagination)}:{},...t.limits===void 0?{}:{limits:t.limits},...r===void 0?{}:{collaborationModel:r}});}catch(s){throw e?.openCrashed(n,s),s}if(!i.ok){let s={"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"},d=i.limit??s[i.reason];e?.openRejected(n,i.reason,i.limit,i.detail),a({code:d===void 0?"InvalidArgument":"ResourceLimitExceeded",target:"createServer",...d===void 0?{}:{limit:d},diagnostic:openDiagnosticCode(i.reason,i.limit)});}return e?.opened(n,Date.now()-o),Yt({host:i.host,save:true,...t.author===void 0?{}:{author:t.author},...t.revisionTextView===void 0?{}:{revisionTextView:t.revisionTextView},...e?{onRefusal:(s,d)=>e.refused(s,i.host,d),onException:(s,d)=>e.crashed(s,i.host,d)}:{}})}function ze(n,t,e={}){return xe(n,{...e,modules:[...e.modules??[],{id:"collaboration",collaboration:{session:t}}]})}var Ae=(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))(Ae||{});var Qa=Object.freeze({createBrowser:We,createServer:xe,createCollaborative:ze});export{se as Alignment,S as Body,At as Bookmark,ot as BookmarkCollection,he as BreakType,le as ChangeTrackingMode,z as ClientObject,Ft as ClientResult,_ as Comment,tt as CommentCollection,lt as CommentReply,Et as CommentReplyCollection,M as ContentControl,F as ContentControlCollection,pe as ContentControlType,Pt as Document,ht as DocumentProperties,Qa as DocxEditor,R as DocxEditorError,Q as Field,K as FieldCollection,Ae as FieldType,B as Font,X as InlinePicture,Z as InlinePictureCollection,ae as InsertLocation,T as List,ge as ListBullet,bt as ListCollection,yt as ListItem,fe as ListNumbering,mt as NoteItem,N as NoteItemCollection,de as PageOrientation,Dt as PageSetup,j as Paragraph,L as ParagraphCollection,y as Range,$ as RangeCollection,ue as RemoveDocInfoType,It as RequestContext,V as Revision,et as RevisionCollection,Ct as Section,Rt as SectionCollection,ut as Shape,G as ShapeCollection,zt as ShapeType,Y as Table,st as TableCell,wt as TableCellCollection,J as TableCollection,gt as TableRow,dt as TableRowCollection,kt as TrackedObjects,be as UnderlineType,ce as VerticalAlignment,Nt as isDocxEditorError};
|
|
1
|
+
import {createBrowserAutomationHost,editorPreviewActive,beginEditorPreview,reportAutomationException,reportAutomationRefusal}from'@docx-editor.dev/core/editor';import {explainDiagnostic,createServerAutomationHost,openDiagnosticCode,storeEditDiagnosticCode,diagnosticCause,createDiagnosticEmitter,diagnosticErrorName,exceptionCause,byteSizeBucket,documentPartKind,createAutomationPaginationProvider,isAutomationCommand}from'@docx-editor.dev/core/automation';var vo=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 or a range changed after this context read it, so nothing was applied. The change can come from another writer or from an earlier sync of this context.",DocumentUnavailable:"the document is not available right now.",PreviewActive:"a preview is open over the document. Commit or discard it before writing or opening another.",PreviewEnded:"the preview has ended. Start another preview to show other wording.",GeneralException:"the document could not complete the request."}),Ao="the object no longer exists in the document. An edit removed or merged it. Read the document again to get a fresh object.";function Ro(n,e){return n==="InvalidObjectPath"&&e==="edit.stale-target"?Ao:vo[n]}var f=class extends Error{code;limit;target;expectedRevision;actualRevision;debugInfo;constructor(e){let t=Ro(e.code,e.diagnostic),o=e.target?`${t} (${e.target})`:t;super(o),this.name="DocxEditorError",this.code=e.code,this.debugInfo=Object.freeze({code:e.code,message:o,...e.target===void 0?{}:{errorLocation:e.target},...e.diagnostic===void 0?{}:{innerError:Object.freeze({code:e.diagnostic,message:explainDiagnostic(e.diagnostic).hint})}}),e.limit!==void 0&&(this.limit=e.limit),e.target!==void 0&&(this.target=e.target),e.expectedRevision!==void 0&&(this.expectedRevision=e.expectedRevision),e.actualRevision!==void 0&&(this.actualRevision=e.actualRevision);}};function Ue(n){return n instanceof f?true:typeof n=="object"&&n!==null&&n.name==="DocxEditorError"&&typeof n.code=="string"}function a(n){throw new f(n)}function jt(n){let e=[],t=false,o=false;for(let r of n)e.push(r.plan()),r.sort==="write"?o=true:t=true;return {operations:e,hasRead:t,hasWrite:o}}var Oo=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 ge(n,e={}){let t=Oo[n.code]??"GeneralException",o=t==="StaleDocument",r=n.detail===void 0?null:storeEditDiagnosticCode(n.detail),i=new f({code:t,...r===null?{}:{diagnostic:r},...e.target===void 0?{}:{target:e.target},...o&&e.expectedRevision!==void 0?{expectedRevision:e.expectedRevision}:{},...o&&e.actualRevision!==void 0?{actualRevision:e.actualRevision}:{}}),s=diagnosticCause(n.detail);return s&&Et.set(i,s),i}var Et=new WeakMap;function ze(n){return Et.get(n)}function st(n,e,t){for(let o=0;o<n.results.length;o+=1){let r=n.results[o];if(r?.status!=="error")continue;let i=e[o]?.label;return ge(r.error,{...i===void 0?{}:{target:i},...t===void 0?{}:{expectedRevision:t},actualRevision:n.revision})}return new f({code:"GeneralException"})}function at(n,e){if(e.results.length!==n.length)throw new f({code:"GeneralException"});for(let t=0;t<n.length;t+=1){let o=e.results[t],r=n[t];if(o.status!=="ok")throw new f({code:"GeneralException",target:r.label});r.settle(o.value);}}var Lo={StaleDocument:"edit.stale-target",ItemNotFound:"edit.stale-target",InvalidObjectPath:"edit.stale-target",InvalidArgument:"edit.invalid-argument",ResourceLimitExceeded:"edit.resource-limit",NotSupported:"edit.operation-unsupported",NotImplemented:"edit.operation-unsupported"};function jo(n){try{let e=n.execute({operations:[{op:"getChangeTrackingMode"}]}),t=e.ok?e.results[0]:void 0;return t?.status==="ok"&&t.value.kind==="text"&&t.value.text!=="Off"}catch{return false}}function Qe(n,e){return e.some(o=>o.op==="setChangeTrackingMode"&&o.mode!=="Off")||jo(n)}function lt(n,e,t){let o=n.debugInfo.innerError?.code;return {code:o?.startsWith("edit.")?o:Lo[n.code]??"edit.refused",tracked:Qe(e,t)}}function Nt(n){if(n.length===0)return null;let{deliver:e}=createDiagnosticEmitter(()=>n);return {openRejected(t,o,r,i){let s=diagnosticCause(o),d=documentPartKind(i);e({kind:"document.open",outcome:"rejected",code:openDiagnosticCode(o,r),sizeBucket:byteSizeBucket(t.byteLength),...s?{cause:s}:{},...d?{part:d}:{}});},openCrashed(t,o){e({kind:"document.open",outcome:"rejected",code:"open.failed",sizeBucket:byteSizeBucket(t.byteLength),cause:exceptionCause(),errorName:diagnosticErrorName(o)});},opened(t,o){e({kind:"document.open",outcome:"opened",sizeBucket:byteSizeBucket(t.byteLength),durationMs:Math.max(0,Math.round(o))});},crashed(t,o,r){e({kind:"edit.rejected",code:"edit.internal-invariant",origin:"automation",tracked:Qe(o,r),cause:exceptionCause(),errorName:diagnosticErrorName(t),stage:"automation"});},refused(t,o,r){let i=ze(t);e({kind:"edit.rejected",origin:"automation",...lt(t,o,r),...i?{cause:i}:{}});}}}var le=Symbol("docx-editor.runtime.internals"),Ke=Symbol("docx-editor.runtime.release"),Xe=Symbol("docx-editor.runtime.rebind");function U(n){return n[le]}var Eo=new Set(["select","expand","top","skip"]),qt=/^[A-Za-z][A-Za-z0-9]*$/,To="items/",Bt=4,Do=64;function No(n,e){if(typeof n!="string"&&a({code:"InvalidArgument",target:e}),qt.test(n))return {own:n};let t=n.split("/",Bt+1);if(t.length<=Bt&&t.every(r=>r.length<=Do&&qt.test(r))||a({code:"InvalidArgument",target:e}),t.length===2&&n.startsWith(To))return {item:t[1]};a({code:"InvalidArgument",target:`${e}.${n}`});}function $t(n,e){if(n===void 0)return {own:[],items:[]};let t=typeof n=="string"?n.split(",").map(i=>i.trim()):Array.isArray(n)?n.map(i=>typeof i=="string"?i.trim():i):a({code:"InvalidArgument",target:e}),o=[],r=[];for(let i of t){let s=No(i,e);s.own!==void 0&&!o.includes(s.own)&&o.push(s.own),s.item!==void 0&&!r.includes(s.item)&&r.push(s.item);}return o.length===0&&r.length===0&&a({code:"InvalidArgument",target:e}),{own:o,items:r}}function Ht(n){return {select:n.own,itemSelect:n.items}}function Mt(n,e){return (typeof n!="number"||!Number.isInteger(n)||n<0)&&a({code:"InvalidArgument",target:e}),n}function qo(n,e){n===void 0||Array.isArray(n)&&n.length===0||a({code:"InvalidArgument",target:e});}function Ft(n,e){if(n===void 0)return {select:[],itemSelect:[]};if(typeof n=="string"||Array.isArray(n))return Ht($t(n,e));(typeof n!="object"||n===null)&&a({code:"InvalidArgument",target:e});let t=n;for(let o of Object.keys(t))Eo.has(o)||a({code:"InvalidArgument",target:`${e}.${o}`});return qo(t.expand,`${e}.expand`),{...Ht($t(t.select,`${e}.select`)),...t.top===void 0?{}:{top:Mt(t.top,`${e}.top`)},...t.skip===void 0?{}:{skip:Mt(t.skip,`${e}.skip`)}}}var M=class{#e;#t;#o;#r;#i=new Map;#s=false;constructor(e,t,o={}){this.#e=e,this.#t=e[le],this.#o=t,this.#r=o.nullable===true,this.#t.register(this);}get context(){return this.#e}get isNullObject(){return this.#o.isReleased&&a({code:"InvalidObjectPath",target:this.#o.label}),this.#r?(this.#o.isPending&&a({code:"PropertyNotLoaded",target:`${this.#o.label}.isNullObject`}),this.#o.isNull):false}load(e){this.#s=true;try{this.requireUsablePath();let t=Ft(e,this.#o.label),o=t.itemSelect[0];return o!==void 0&&!this.loadsItemPaths&&a({code:"InvalidArgument",target:`${this.#o.label}.items/${o}`}),this.onLoad(t),this}finally{this.#s=false;}}get loadsItemPaths(){return false}get path(){return this.#o}get internals(){return this.#t}handle(){return this.#o.handle()}requireAddressable(){this.#o.isAddressable||a({code:"InvalidObjectPath",target:this.#o.label}),this.#t.assertUsable(this.#o.label);}requireUsablePath(){(this.#o.isReleased||this.#o.isNull&&!(this.#s&&this.#r))&&a({code:"InvalidObjectPath",target:this.#o.label}),this.#t.assertUsable(this.#o.label);}enqueue(e){this.requireUsablePath(),this.#t.queue.push({...e,dependencies:[...e.dependencies??[],this.#o],...this.#s&&this.#r&&e.sort==="read"?{nullableLoad:this.#o}:{}});}loadedProperty(e){return this.#o.isReleased&&!this.#i.has(e)&&a({code:"InvalidObjectPath",target:this.#o.label}),this.#i.has(e)||a({code:"PropertyNotLoaded",target:`${this.#o.label}.${e}`}),this.#i.get(e)}hasLoadedProperty(e){return this.#i.has(e)}setLoadedProperty(e,t){this.#i.set(e,t);}[Ke](){this.#o.release();}[Xe](e){this.#e=e,this.#t=e[le];}};var Ze=class n{#e=false;#t;#o;constructor(e){this.#o=e;}get value(){return this.#e||a({code:"ValueNotLoaded",target:this.#o}),this.#t}get isLoaded(){return this.#e}static create(e){let t=new n(e);return {result:t,fill(o){t.#e=true,t.#t=o;}}}};function Ne(n){return Ze.create(n)}function D(n){return new f({code:"GeneralException",target:n})}function w(n,e){if(n.kind!=="text")throw D(e);return n.text}function y(n,e){if(n.kind!=="handle")throw D(e);return n.handle}function R(n,e){if(n.kind!=="handles")throw D(e);return n.handles}function k(n,e){if(n.kind!=="span")throw D(e);return n.span}function Z(n,e){if(n.kind!=="spans")throw D(e);return n.spans}function ct(n,e){if(n.kind!=="font")throw D(e);return n.font}function ut(n,e){if(n.kind!=="paragraphFormat")throw D(e);return n.format}function qe(n,e){if(n.kind!=="style")throw D(e);return n.name}function Ye(n,e){if(n.kind!=="number")throw D(e);return n.value}function ce(n,e){if(n.kind!=="flag")throw D(e);return n.value}function pt(n,e){if(n.kind!=="pageSetup")throw D(e);return n.setup}function x(n,e){if(n.kind!=="applied")throw D(e)}var u=class n{label;#e;#t;constructor(e,t,o=null){this.label=e,this.#e=t,this.#t=o;}static of(e,t){return new n(e,{status:"resolved",address:{kind:"handle",handle:t}})}static ofSpan(e,t){return new n(e,{status:"resolved",address:{kind:"span",span:t}})}static pending(e){return new n(e,{status:"pending"})}static derived(e,t){return new n(e,{status:"pending"},t)}get state(){return this.#t?this.#t.state:this.#e}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 e=this.state;if(e.status==="resolved")return e.address;a({code:"InvalidObjectPath",target:this.label});}handle(){let e=this.address();return e.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.label}),e.handle}span(){let e=this.address();return e.kind!=="span"&&a({code:"InvalidObjectPath",target:this.label}),e.span}resolveTo(e){this.#o({kind:"handle",handle:e});}resolveToSpan(e){this.#o({kind:"span",span:e});}resolveNull(){this.#e.status!=="released"&&(this.#e={status:"null"});}release(){this.#t||(this.#e={status:"released"});}#o(e){this.#e.status!=="released"&&(this.#e={status:"resolved",address:e});}};var Je=class{#e=[];#t=null;#o=[];get size(){return this.#e.length}get pending(){return this.#e}push(e){(this.#t??this.#e).push(e);}collect(e){let t=this.#t,o=[];this.#t=o;try{e();}finally{this.#t=t;}return o}continuing(e){this.#o.push(...this.collect(e));}takeContinuations(){let e=this.#o;this.#o=[];for(let t of e)t.capture?.();return e}take(){let e=this.#e;this.#e=[];for(let t of e)t.capture?.();return e}clear(){for(let e of this.#e)e.dispose?.();for(let e of this.#o)e.dispose?.();this.#e=[],this.#o=[];}};function Vt(n,e){if(Array.isArray(n)){for(let t of n)e(t);return}e(n);}var Be=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t;}add(e){this.#e.assertUsable(),Vt(e,t=>{this.#o(t),this.#e.track(t);});}remove(e){this.#e.assertUsable(),Vt(e,t=>{this.#o(t),this.#e.untrack(t);});}#o(e){this.#t(e)||a({code:"InvalidObjectPath"});}};var fe=class n{#e;#t=new Je;#o=new Set;#r=new Set;#i;#s;#d;#n=false;#a=null;#c=false;constructor(e){this.#e=e,this.#i={host:e.host,capabilities:e.capabilities,...e.author===void 0?{}:{author:e.author},revisionTextView:e.revisionTextView,queue:this.#t,session:e.id,roots:()=>e.roots(),assertUsable:t=>{this.#e.assertLive(t),this.#n&&a({code:"InvalidRequestContext",...t===void 0?{}:{target:t}});},isFinished:()=>this.#n,readRevision:()=>this.#a,register:t=>{this.#o.add(t);},track:t=>{this.#r.add(t);},untrack:t=>{this.#r.delete(t);},isTracked:t=>this.#r.has(t),disown:t=>{this.#o.delete(t),this.#r.delete(t);}},this.#s=new Be(this.#i,t=>this.#o.has(t));}get document(){return this.#i.assertUsable("document"),this.#d??=this.#e.openDocument(this),this.#d}get capabilities(){return this.#e.capabilities}get trackedObjects(){return this.#s}async sync(){this.#i.assertUsable(),this.#c&&a({code:"InvalidRequestContext"});let e=this.#t.take();if(e.length!==0){this.#c=true;try{let t=e.filter(l=>!l.nullableLoad?.isNull),o=e.some(l=>l.sort==="write"),r,i=o&&this.#a!==null?this.#a:void 0,s=l=>l.dependencies?.some(p=>!p.isAddressable)??false;for(;t.some(s);){r??=o&&this.#a!==null?this.#a:this.#e.host.revision();let l=t.filter(b=>b.sort==="read"&&!s(b));l.length===0&&a({code:"InvalidObjectPath",target:t.find(s)?.label}),await this.#p(l,r,i),await this.#u(r,i);let p=new Set(l);t=t.filter(b=>!p.has(b)&&!b.nullableLoad?.isNull);}let d=o?t.filter(l=>l.continues===true):[];if(d.length){r??=this.#a!==null?this.#a:this.#e.host.revision(),await this.#p(d,r,i),await this.#u(r,i);let l=new Set(d);t=t.filter(p=>!l.has(p)&&!p.nullableLoad?.isNull);}if(t.length){let l=r??(o&&this.#a!==null?this.#a:void 0);await this.#p(t,l,i),await this.#u(this.#a??void 0,i);}}finally{for(let t of e)t.dispose?.();for(let t of this.#t.takeContinuations())t.dispose?.();this.#c=false;}}}async#u(e,t){let o=this.#t.takeContinuations();if(o.length!==0)try{await this.#p(o,e,t);}finally{for(let r of o)r.dispose?.();}}async#p(e,t,o){let r=jt(e);try{await this.#h(e,r,t,o);}catch(i){if(!Ue(i))try{this.#e.onException?.(i,r.operations);}catch{}throw i}}async#h(e,t,o,r){let i={operations:t.operations,...o===void 0?{}:{expectedRevision:o}};if(this.#e.host.prepare){let d={...i,expectedRevision:i.expectedRevision??this.#e.host.revision()};try{await this.#e.host.prepare(d);}catch(p){throw Ue(p)?this.#l(p,t.operations):p}let l=this.#e.host.execute(d);if(!l.ok)throw this.#l(st(l,e,r),t.operations);at(e,l),this.#a=l.revision;return}let s=this.#e.host.execute(i);if(!s.ok)throw this.#l(st(s,e,r),t.operations);at(e,s),(t.hasRead||t.hasWrite)&&(this.#a=s.revision);}#l(e,t){try{this.#e.onRefusal?.(e,t);}catch{}return e}get[le](){return this.#i}static begin(e){let t=new n(e);return {context:t,adopt(o){for(let r of o)t.#m(r);},finish(){t.#f();}}}#m(e){let t=e.context;if(t===this)return;let o=t[le];if(o.session!==this.#e.id)throw new f({code:"InvalidObjectPath"});if(!o.isFinished())throw new f({code:"ObjectInUse"});if(!o.isTracked(e))throw new f({code:"InvalidObjectPath"});let r=o.readRevision();o.disown(e),e[Xe](this),this.#o.add(e),this.#r.add(e),r!==null&&this.#g(r);}#g(e){this.#a=this.#a===null?e:Math.min(this.#a,e);}#f(){if(!this.#n){this.#n=true,this.#t.clear();for(let e of this.#o)this.#r.has(e)||e[Ke]();this.#o.clear();}}};function $e(n,e,t){if(n.select.length===0)return e;for(let o of n.select)e.includes(o)||a({code:"InvalidArgument",target:`${t}.${o}`});return n.select}var h=class extends M{revisionTextView(){return U(this.context).revisionTextView}loadTextInto(e,t){let o=`${this.path.label}.${e}`;this.enqueue({sort:"read",label:o,plan:t,settle:r=>{this.setLoadedProperty(e,w(r,o));}});}command(e,t,o){let r=`${this.path.label}.${e}`;this.enqueue({sort:"write",label:r,plan:t,settle:i=>x(i,r),...o?{capture:o,dispose:o}:{}});}commandDiscarding(e,t){let o=`${this.path.label}.${e}`;this.enqueue({sort:"write",label:o,plan:t,settle:()=>{}});}commandAnswering(e,t,o,r){this.enqueue({sort:"write",label:e,plan:t,settle:o,...r?{capture:r,dispose:r}:{}});}read(e,t,o){this.enqueue({sort:"read",label:e,plan:t,settle:o});}selection(e,t){return $e(e,t,this.path.label)}onLoad(e){this.selection(e,[]);}};var Bo=["author","title","subject","keywords","comments","category","lastAuthor"],be=class n extends h{#e;static of(e,t){return new n(e,u.derived("document.properties",t))}constructor(e,t){super(e,t);}get lastAuthor(){return this.loadedProperty("lastAuthor")}get author(){return this.loadedProperty("author")}set author(e){this.#t("author",e);}get title(){return this.loadedProperty("title")}set title(e){this.#t("title",e);}get subject(){return this.loadedProperty("subject")}set subject(e){this.#t("subject",e);}get keywords(){return this.loadedProperty("keywords")}set keywords(e){this.#t("keywords",e);}get comments(){return this.loadedProperty("comments")}set comments(e){this.#t("comments",e);}get category(){return this.loadedProperty("category")}set category(e){this.#t("category",e);}onLoad(e){for(let t of this.selection(e,Bo))this.read(`${this.path.label}.${t}`,()=>({op:"getDocumentProperty",name:t}),o=>this.setLoadedProperty(t,w(o,this.path.label)));}#t(e,t){if(this.requireUsablePath(),(typeof t!="string"||t.length>4096)&&a({code:"InvalidArgument",target:`${this.path.label}.${e}`}),this.#e){this.#e[e]=t;return}let o={[e]:t};this.#e=o,this.commandAnswering(this.path.label,()=>({op:"setDocumentProperties",values:o}),r=>{x(r,this.path.label);},()=>{this.#e===o&&(this.#e=void 0);});}};function S(n,e){let t=n.address();return e==="span"?(t.kind!=="span"&&a({code:"InvalidObjectPath",target:n.label}),{start:t.span.start,end:t.span.end}):(t.kind!=="handle"&&a({code:"InvalidObjectPath",target:n.label}),e==="body"?{body:t.handle}:{paragraph:t.handle})}function ye(n,e){return (typeof n!="string"||n.trim().length===0||n.length>255)&&a({code:"InvalidArgument",target:e}),n}var N=class extends M{#e;#t=[];constructor(e,t){super(e,t);}get items(){return this.loadedProperty("items")}fill(e,t){this.setLoadedProperty("items",this.#i(e,t,0,void 0)),this.#e={value:e,label:t};let o=this.#t.splice(0,this.#t.length);for(let r of o)this.#r(r,e);}get loadsItemPaths(){return true}onLoad(e){let t=[...new Set([...e.select.filter(l=>l!=="items"),...e.itemSelect])];$e({select:e.select.filter(l=>l==="items")},["items"],this.path.label),t.length>0&&this.#o(t);let o=this.path.isPending?void 0:this.listing(),r=`${this.path.label}.items`,i=e.skip??0,s=e.top,d=e.skip!==void 0||s!==void 0;if(o===null){if(t.length===0&&!d)return;let l=this.#e;l||a({code:"NotImplemented",target:r});let p=this.#i(l.value,l.label,i,s);if(this.setLoadedProperty("items",p),t.length>0)for(let b of p)b.load(t);return}this.enqueue({sort:"read",label:r,...t.length>0?{continues:true}:{},plan:()=>{let l=o??this.listing();return l||a({code:"InvalidObjectPath",target:this.path.label}),l},settle:l=>{let p=this.#i(l,r,i,s);this.setLoadedProperty("items",p),t.length!==0&&this.internals.queue.continuing(()=>{for(let b of p)b.load(t);});}});}#o(e){let t=this.promised(`${this.path.label}.items`,false),o=this.internals.queue.collect(()=>{try{t.load(e);}catch(r){if(r.code==="InvalidArgument")throw r}});for(let r of o)r.dispose?.();}edge(e,t,o){let r=`${this.path.label}.${t}()`,i=this.promised(r,o),s=this.path.isPending?void 0:this.listing();if(s===null){let d={edge:e,target:r,nullable:o,item:i};return this.#e?this.#r(d,this.#e.value):this.#t.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.#r({edge:e,target:r,nullable:o,item:i},d);}}),i}#r(e,t){let{edge:o,target:r,nullable:i,item:s}=e,d=this.size(t,r);if(d===0){i||a({code:"ItemNotFound",target:r}),s.hydrateNull();return}let l=this.addressAt(t,r,o==="first"?0:d-1);l||a({code:"ItemNotFound",target:r}),s.hydrateAddress(l);}#i(e,t,o,r){let i=this.size(e,t),s=r===void 0?i:Math.min(i,o+r),d=[];for(let l=o;l<s;l+=1){let p=this.addressAt(e,t,l);p&&d.push(this.itemAt(`${t}[${String(l)}]`,p));}return d}},C=class extends N{size(e,t){return R(e,t).length}addressAt(e,t,o){let r=R(e,t)[o];return r?{kind:"handle",handle:r}:void 0}};var _e=(s=>(s.unsupported="Unsupported",s.textBox="TextBox",s.geometricShape="GeometricShape",s.group="Group",s.picture="Picture",s.canvas="Canvas",s))(_e||{}),$o=["id","name","type"],Gt=new Set(Object.values(_e)),xe=class n extends h{#e;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get name(){return this.loadedProperty("name")}get type(){return this.loadedProperty("type")}get body(){if(this.#e)return this.#e;let e=`${this.path.label}.body`,t=L.promisedStory(this.context,e);return this.read(e,()=>({op:"getShapeBody",shape:this.#t()}),o=>{t.hydrateAddress({kind:"handle",handle:y(o,e)});}),this.#e=t,t}onLoad(e){let t=this.selection(e,$o);t.length&&this.read(this.path.label,()=>({op:"getShape",shape:this.#t()}),o=>{(o.kind!=="shape"||!Gt.has(o.shape.type))&&a({code:"GeneralException",target:this.path.label});for(let r of t)this.setLoadedProperty(r,o.shape[r]);});}#t(){return this.requireAddressable(),this.path.handle()}},Y=class n extends N{#e;#t;static of(e,t,o,r,i){return new n(e,u.derived(t,o),r,i)}constructor(e,t,o,r){super(e,t),this.#e=o,this.#t=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getByTypes(e){let t=`${this.path.label}.getByTypes`;(!Array.isArray(e)||e.some(r=>!Gt.has(r)))&&a({code:"InvalidArgument",target:t});let o=this.#t?this.#t.filter(r=>e.includes(r)):[...e];return n.of(this.context,t,this.path,this.#e,o)}listing(){let e=S(this.path,this.#e);return this.#t?{op:"getShapes",span:e,types:this.#t}:{op:"getShapes",span:e}}size(e,t){return R(e,t).length}addressAt(e,t,o){let r=R(e,t)[o];return r?{kind:"handle",handle:r}:void 0}itemAt(e,t){return xe.at(this.context,e,t)}promised(e,t){return xe.promised(this.context,e,t)}};function Ho(n){return n==="endnote"?"Endnote":"Footnote"}var ve=class n extends h{#e;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get type(){return this.loadedProperty("type")}get text(){return this.loadedProperty("text")}get body(){if(this.#e)return this.#e;let e=`${this.path.label}.body`,t=L.promisedStory(this.context,e);return this.read(e,()=>({op:"getNoteBody",note:this.#t()}),o=>{t.hydrateAddress({kind:"handle",handle:y(o,e)});}),this.#e=t,t}delete(){this.command("delete",()=>({op:"deleteNote",note:this.#t()}));}getNext(){let e=`${this.path.label}.getNext`,t=n.promised(this.context,e,false),o=this.internals.roots().document,r=`${e}.type`,i="footnote",s=u.pending(r);return this.read(r,()=>({op:"getNoteKind",note:this.#t()}),d=>{i=w(d,r)==="endnote"?"endnote":"footnote",s.resolveTo(this.#t());}),this.enqueue({sort:"read",label:e,dependencies:[s],plan:()=>({op:"getNotes",document:o,noteKind:i}),settle:d=>{let l=R(d,e),p=l.findIndex(X=>X.ref===this.#t().ref),b=p<0?void 0:l[p+1];b||a({code:"ItemNotFound",target:e}),t.hydrateAddress({kind:"handle",handle:b});}}),t}onLoad(e){let t=this.selection(e,["text","type"]);if(t.includes("text")&&this.loadTextInto("text",()=>({op:"getNoteText",note:this.#t(),projection:this.revisionTextView()})),t.includes("type")){let o=`${this.path.label}.type`;this.read(o,()=>({op:"getNoteKind",note:this.#t()}),r=>{this.setLoadedProperty("type",Ho(w(r,o)));});}}#t(){return this.requireAddressable(),this.path.handle()}},F=class n extends C{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}constructor(e,t,o){super(e,t),this.#e=o;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#e()}itemAt(e,t){return ve.at(this.context,e,t)}promised(e,t){return ve.promised(this.context,e,t)}};var J=class n extends h{#e;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get code(){return this.loadedProperty("code")}set code(e){if(this.requireUsablePath(),(typeof e!="string"||e.length===0)&&a({code:"InvalidArgument",target:`${this.path.label}.code`}),this.#e){this.#e.code=e;return}let t={code:e};this.#e=t,this.commandAnswering(this.path.label,()=>({op:"setFieldCode",field:this.#o(),code:t.code}),o=>x(o,this.path.label),()=>{this.#e===t&&(this.#e=void 0);});}delete(){this.#t("deleteField");}updateResult(){this.#t("updateFieldResult");}#t(e){this.requireUsablePath(),this.commandAnswering(this.path.label,()=>({op:e,field:this.#o()}),t=>x(t,this.path.label));}onLoad(e){this.selection(e,["code"]).length!==0&&this.read(this.path.label,()=>({op:"getField",field:this.#o()}),t=>{t.kind!=="field"&&a({code:"GeneralException",target:this.path.label}),this.setLoadedProperty("code",t.field.code);});}#o(){this.requireAddressable();let e=this.path.address();return e.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),e.handle}},_=class n extends N{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}constructor(e,t,o){super(e,t),this.#e=o;}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:S(this.path,this.#e)}}size(e,t){return R(e,t).length}addressAt(e,t,o){let r=R(e,t)[o];return r?{kind:"handle",handle:r}:void 0}itemAt(e,t){return J.at(this.context,e,t)}promised(e,t){return J.promised(this.context,e,t)}};var Mo=["width","height","lockAspectRatio","altTextDescription"],ee=class n extends h{#e;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get width(){return this.loadedProperty("width")}set width(e){this.#t("width",e);}get height(){return this.loadedProperty("height")}set height(e){this.#t("height",e);}get lockAspectRatio(){return this.loadedProperty("lockAspectRatio")}set lockAspectRatio(e){typeof e!="boolean"&&a({code:"InvalidArgument",target:`${this.path.label}.lockAspectRatio`}),this.#o({lockAspectRatio:e});}get altTextDescription(){return this.loadedProperty("altTextDescription")}set altTextDescription(e){typeof e!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.altTextDescription`}),this.#o({altTextDescription:e});}delete(){let e=`${this.path.label}.delete`;this.commandAnswering(e,()=>({op:"deleteInlinePicture",picture:this.#r()}),t=>x(t,e));}onLoad(e){let t=this.selection(e,Mo);t.length&&this.read(this.path.label,()=>({op:"getInlinePicture",picture:this.#r()}),o=>{o.kind!=="inlinePicture"&&a({code:"GeneralException",target:this.path.label});for(let r of t)this.setLoadedProperty(r,o.picture[r]);});}#t(e,t){(typeof t!="number"||!Number.isFinite(t)||t<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.${e}`}),this.#o({[e]:t});}#o(e){if(this.requireUsablePath(),this.#e){Object.assign(this.#e,e);return}let t=e;this.#e=t,this.commandAnswering(this.path.label,()=>({op:"setInlinePicture",picture:this.#r(),properties:t}),o=>x(o,this.path.label),()=>{this.#e===t&&(this.#e=void 0);});}#r(){this.requireAddressable();let e=this.path.address();return e.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),e.handle}},te=class n extends N{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}constructor(e,t,o){super(e,t),this.#e=o;}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:S(this.path,this.#e)}}size(e,t){return R(e,t).length}addressAt(e,t,o){let r=R(e,t)[o];return r?{kind:"handle",handle:r}:void 0}itemAt(e,t){return ee.at(this.context,e,t)}promised(e,t){return ee.promised(this.context,e,t)}};function V(n,e,t=0){return (!Number.isInteger(n)||n<t)&&a({code:"InvalidArgument",target:e}),n}function et(n,e){return (!Array.isArray(n)||n.some(t=>!Array.isArray(t)||t.some(o=>typeof o!="string")))&&a({code:"InvalidArgument",target:e}),n.map(t=>[...t])}function Wt(n,e){return n!=="Start"&&n!=="End"&&a({code:"InvalidArgument",target:e}),n==="Start"?"start":"end"}var oe=class n extends h{#e;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o=false){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get values(){return this.loadedProperty("values")}set values(e){let t=et(e,`${this.path.label}.values`);this.command("values",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"values",values:t}}));}get style(){return this.loadedProperty("style")}set style(e){typeof e!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.style`}),this.command("style",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"properties",styleId:e}}));}get headerRowCount(){return this.loadedProperty("headerRowCount")}set headerRowCount(e){V(e,`${this.path.label}.headerRowCount`),this.command("headerRowCount",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"properties",headerRowCount:e}}));}get rowCount(){return this.loadedProperty("rowCount")}get columnCount(){return this.loadedProperty("columnCount")}get rows(){return this.#e??=pe.of(this.context,`${this.path.label}.rows`,this.path,()=>({op:"getTableRows",table:this.path.handle()}))}getCell(e,t){let o=`${this.path.label}.getCell`;V(e,o),V(t,o);let r=ue.promised(this.context,o);return this.read(o,()=>({op:"getTableCell",table:this.path.handle(),rowIndex:e,cellIndex:t}),i=>r.hydrateAddress({kind:"handle",handle:y(i,o)})),r}addRows(e,t,o){let r=`${this.path.label}.addRows`,i=Wt(e,r);V(t,r,1);let s=o===void 0?void 0:et(o,r),d=pe.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addRows",location:i,count:t,...s?{values:s}:{}}}),l=>d.fill(l,r)),d}addColumns(e,t,o){let r=`${this.path.label}.addColumns`,i=Wt(e,r);V(t,r,1);let s=o===void 0?void 0:et(o,r);this.command("addColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addColumns",location:i,count:t,...s?{values:s}:{}}}));}deleteRows(e,t){t===void 0&&(t=1),V(e,this.path.label),V(t,this.path.label,1),this.command("deleteRows",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"deleteRows",index:e,count:t}}));}deleteColumns(e,t){t===void 0&&(t=1),V(e,this.path.label),V(t,this.path.label,1),this.command("deleteColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"deleteColumns",index:e,count:t}}));}delete(){this.command("delete",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"delete"}}));}onLoad(e){let t=this.selection(e,["values","style","headerRowCount","rowCount","columnCount"]);this.read(this.path.label,()=>({op:"getTable",table:this.path.handle()}),o=>{o.kind!=="table"&&a({code:"GeneralException",target:this.path.label});for(let r of t)this.setLoadedProperty(r,o.table[r]);});}},Ae=class n extends h{#e;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o=false){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}insertRows(e,t,o){let r=`${this.path.label}.insertRows`;e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:r}),V(t,r,1);let i=o===void 0?void 0:et(o,r),s=pe.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"insertTableRows",row:this.path.handle(),location:e==="Before"?"before":"after",count:t,...i?{values:i}:{}}),d=>s.fill(d,r)),s}get cells(){return this.#e??=He.of(this.context,`${this.path.label}.cells`,this.path,()=>({op:"getTableCells",row:this.path.handle()}))}},ue=class n extends h{#e;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o=false){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){if(this.#e)return this.#e;let e=`${this.path.label}.body`,t=L.promisedStory(this.context,e);return this.read(e,()=>({op:"getTableCellBody",cell:this.path.handle()}),o=>t.hydrateAddress({kind:"handle",handle:y(o,e)})),this.#e=t,t}get value(){return this.loadedProperty("value")}set value(e){typeof e!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.value`}),this.command("value",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{value:e}}));}get columnWidth(){return this.loadedProperty("columnWidth")}set columnWidth(e){(typeof e!="number"||!Number.isFinite(e)||e<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.columnWidth`}),this.command("columnWidth",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{columnWidth:e}}));}get shadingColor(){return this.loadedProperty("shadingColor")}set shadingColor(e){typeof e!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.shadingColor`}),this.command("shadingColor",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{shadingColor:e}}));}get verticalAlignment(){return this.loadedProperty("verticalAlignment")}set verticalAlignment(e){e!=="Top"&&e!=="Center"&&e!=="Bottom"&&a({code:"InvalidArgument",target:`${this.path.label}.verticalAlignment`}),this.command("verticalAlignment",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{verticalAlignment:e}}));}onLoad(e){let t=this.selection(e,["value","columnWidth","shadingColor","verticalAlignment"]);this.read(this.path.label,()=>({op:"getTableCellProperties",cell:this.path.handle()}),o=>{o.kind!=="tableCell"&&a({code:"GeneralException",target:this.path.label});for(let r of t)this.setLoadedProperty(r,o.cell[r]);});}},ne=class n extends C{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}static over(e,t,o,r){return n.of(e,t,o,()=>({op:"getTables",scope:r()}))}constructor(e,t,o){super(e,t),this.#e=o;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#e()}itemAt(e,t){return oe.at(this.context,e,t)}promised(e,t){return oe.promised(this.context,e,t)}},pe=class n extends C{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}constructor(e,t,o){super(e,t),this.#e=o;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#e()}itemAt(e,t){return Ae.at(this.context,e,t)}promised(e,t){return Ae.promised(this.context,e,t)}},He=class n extends C{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}constructor(e,t,o){super(e,t),this.#e=o;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#e()}itemAt(e,t){return ue.at(this.context,e,t)}promised(e,t){return ue.promised(this.context,e,t)}};var ht=(i=>(i.replace="Replace",i.start="Start",i.end="End",i.before="Before",i.after="After",i))(ht||{}),mt=(s=>(s.mixed="Mixed",s.unknown="Unknown",s.left="Left",s.centered="Centered",s.right="Right",s.justified="Justified",s))(mt||{}),gt=(t=>(t.portrait="Portrait",t.landscape="Landscape",t))(gt||{}),ft=(o=>(o.off="Off",o.trackAll="TrackAll",o.trackMineOnly="TrackMineOnly",o))(ft||{}),bt=(r=>(r.mixed="Mixed",r.top="Top",r.center="Center",r.bottom="Bottom",r))(bt||{}),yt=(d=>(d.line="Line",d.page="Page",d.next="Next",d.sectionNext="SectionNext",d.sectionContinuous="SectionContinuous",d.sectionEven="SectionEven",d.sectionOdd="SectionOdd",d))(yt||{}),xt=(P=>(P.unknown="Unknown",P.richText="RichText",P.plainText="PlainText",P.picture="Picture",P.buildingBlockGallery="BuildingBlockGallery",P.checkBox="CheckBox",P.comboBox="ComboBox",P.datePicker="DatePicker",P.dropDownList="DropDownList",P.group="Group",P.repeatingSection="RepeatingSection",P.plainTextInline="PlainTextInline",P.plainTextParagraph="PlainTextParagraph",P.richTextInline="RichTextInline",P.richTextParagraphs="RichTextParagraphs",P.richTextTable="RichTextTable",P.richTextTableCell="RichTextTableCell",P.richTextTableRow="RichTextTableRow",P))(xt||{}),vt=(g=>(g.all="All",g.atMentions="AtMentions",g.commentReactions="CommentReactions",g.comments="Comments",g.contentType="ContentType",g.documentIntelligence="DocumentIntelligence",g.documentManagementPolicy="DocumentManagementPolicy",g.documentProperties="DocumentProperties",g.documentServerProperties="DocumentServerProperties",g.documentTasks="DocumentTasks",g.documentWorkspace="DocumentWorkspace",g.emailHeader="EmailHeader",g.inkAnnotations="InkAnnotations",g.removePersonalInformation="RemovePersonalInformation",g.revisions="Revisions",g.routingSlip="RoutingSlip",g.sendForReview="SendForReview",g.taskpaneWebExtensions="TaskpaneWebExtensions",g.template="Template",g.versions="Versions",g))(vt||{});var Fo=["Replace","Start","End"],Vo=["Start","End"],Go=["Replace","Start","End"],Wo=["Before","After"],Uo=["Replace","Start","End","Before","After"],zo=["Select","Start","End"];function Re(n,e,t){return (typeof n!="string"||!e.includes(n))&&a({code:"InvalidArgument",target:t}),n}var Ut=(n,e)=>Re(n,Fo,e),zt=(n,e)=>Re(n,Vo,e),Qt=(n,e)=>Re(n,Go,e),Kt=(n,e)=>Re(n,Wo,e),Me=(n,e)=>Re(n,Uo,e),tt=(n,e)=>n===void 0?"Select":Re(n,zo,e);function j(n,e){return typeof n!="string"&&a({code:"InvalidArgument",target:e}),/[\r\n\f\u2028\u2029]/.test(n)&&a({code:"InvalidArgument",target:e}),n}var Qo=8,Rt=(d=>(d.custom="Custom",d.solid="Solid",d.hollow="Hollow",d.square="Square",d.diamonds="Diamonds",d.arrow="Arrow",d.checkmark="Checkmark",d))(Rt||{}),Ct=(s=>(s.none="None",s.arabic="Arabic",s.upperRoman="UpperRoman",s.lowerRoman="LowerRoman",s.upperLetter="UpperLetter",s.lowerLetter="LowerLetter",s))(Ct||{}),$=class n extends h{#e;#t=new Map;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get paragraphs(){return this.#e??=E.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getListParagraphs",list:this.#r()})),this.#e}getLevelParagraphs(e){let t=`${this.path.label}.getLevelParagraphs`,o=At(e,t);return E.overListing(this.context,t,this.path,()=>({op:"getListParagraphs",list:this.#r(),level:o}))}insertParagraph(e,t){let o=`${this.path.label}.insertParagraph`,r=j(e,o);t!=="Start"&&t!=="End"&&t!=="Before"&&t!=="After"&&a({code:"InvalidArgument",target:o});let i=T.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertListParagraph",list:this.#r(),where:t==="Start"||t==="Before"?"start":"end",text:r}),s=>{i.hydrateAddress({kind:"handle",handle:y(s,o)});}),i}setLevelBullet(e,t,o,r){this.#o(e,{bullet:t,...o===void 0?{}:{charCode:o},...r===void 0?{}:{fontName:r}});}setLevelNumbering(e,t,o){this.#o(e,{numbering:t,...o===void 0?{}:{formatString:[...o]}});}setLevelStartingNumber(e,t){this.#o(e,{startingNumber:t});}setLevelIndents(e,t,o){this.#o(e,{textIndent:t,bulletNumberPictureIndent:o});}#o(e,t){let o=`${this.path.label}.levelFormat`,r=At(e,o);this.requireUsablePath();let i=this.#t.get(r);if(i){Object.assign(i,t),"bullet"in t&&(delete i.numbering,delete i.formatString),"numbering"in t&&(delete i.bullet,delete i.charCode,delete i.fontName);return}let s={...t};this.#t.set(r,s),this.commandAnswering(o,()=>({op:"setListLevelFormat",list:this.#r(),level:r,format:s}),d=>{x(d,o);},()=>{this.#t.get(r)===s&&this.#t.delete(r);});}onLoad(e){if(!this.selection(e,["id"]).includes("id"))return;let t=`${this.path.label}.id`;this.read(t,()=>({op:"getListId",list:this.#r()}),o=>{this.setLoadedProperty("id",Ye(o,t));});}#r(){return this.requireAddressable(),this.path.handle()}},Ce=class n extends C{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}constructor(e,t,o){super(e,t),this.#e=o;}getFirst(){return this.edge("first","getFirst",false)}getById(e){let t=`${this.path.label}.getById`,o=Ko(e,t),r=this.#e,i=$.promised(this.context,t,false);return this.enqueue({sort:"read",label:t,plan:()=>({op:"getListById",body:r,id:o}),settle:s=>{i.hydrateAddress({kind:"handle",handle:y(s,t)});}}),i}listing(){return {op:"getLists",body:this.#e}}itemAt(e,t){return $.at(this.context,e,t)}promised(e,t){return $.promised(this.context,e,t)}},Pe=class n extends h{static of(e,t,o){return new n(e,u.derived(t,o))}constructor(e,t){super(e,t);}get level(){return this.loadedProperty("level")}set level(e){let t=`${this.path.label}.level`,o=At(e,t);this.commandAnswering(t,()=>({op:"setListLevel",paragraph:this.#e(),level:o}),r=>{x(r,t);});}onLoad(e){if(!this.selection(e,["level"]).includes("level"))return;let t=`${this.path.label}.level`;this.read(t,()=>({op:"getListLevel",paragraph:this.#e()}),o=>{this.setLoadedProperty("level",Ye(o,t));});}#e(){this.requireAddressable();let e=this.path.address();return e.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),e.handle}};function At(n,e){return (!Number.isInteger(n)||n<0||n>Qo)&&a({code:"InvalidArgument",target:e}),n}function Ko(n,e){return (!Number.isInteger(n)||n<=0)&&a({code:"InvalidArgument",target:e}),n}var Pt=(m=>(m.mixed="Mixed",m.none="None",m.hidden="Hidden",m.dotLine="DotLine",m.single="Single",m.word="Word",m.double="Double",m.thick="Thick",m.dotted="Dotted",m.dottedHeavy="DottedHeavy",m.dashLine="DashLine",m.dashLineHeavy="DashLineHeavy",m.dashLineLong="DashLineLong",m.dashLineLongHeavy="DashLineLongHeavy",m.dotDashLine="DotDashLine",m.dotDashLineHeavy="DotDashLineHeavy",m.twoDotDashLine="TwoDotDashLine",m.twoDotDashLineHeavy="TwoDotDashLineHeavy",m.wave="Wave",m.waveHeavy="WaveHeavy",m.waveDouble="WaveDouble",m))(Pt||{}),Xo=["bold","italic","color","name","size","underline","strikeThrough","highlightColor","subscript","superscript"],G=class n extends h{#e;#t;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}constructor(e,t,o){super(e,t),this.#e=o;}get bold(){return this.loadedProperty("bold")}set bold(e){this.#o("bold",Fe(e,`${this.path.label}.bold`));}get italic(){return this.loadedProperty("italic")}set italic(e){this.#o("italic",Fe(e,`${this.path.label}.italic`));}get color(){return this.loadedProperty("color")}set color(e){this.#o("color",ot(e,`${this.path.label}.color`));}get name(){return this.loadedProperty("name")}set name(e){this.#o("name",ot(e,`${this.path.label}.name`));}get size(){return this.loadedProperty("size")}set size(e){this.#o("size",Zo(e,`${this.path.label}.size`));}get underline(){return this.loadedProperty("underline")}set underline(e){this.#o("underline",ot(e,`${this.path.label}.underline`));}get highlightColor(){return this.loadedProperty("highlightColor")}set highlightColor(e){this.#o("highlightColor",e===null?null:ot(e,`${this.path.label}.highlightColor`));}get strikeThrough(){return this.loadedProperty("strikeThrough")}set strikeThrough(e){this.#o("strikeThrough",Fe(e,`${this.path.label}.strikeThrough`));}get subscript(){return this.loadedProperty("subscript")}set subscript(e){this.#o("subscript",Fe(e,`${this.path.label}.subscript`));}get superscript(){return this.loadedProperty("superscript")}set superscript(e){this.#o("superscript",Fe(e,`${this.path.label}.superscript`));}onLoad(e){let t=this.selection(e,Xo);if(t.length===0)return;let o=`${this.path.label}.font`;this.read(o,()=>({op:"getFont",span:this.#r()}),r=>{let i=ct(r,o);for(let s of t)this.setLoadedProperty(s,i[s]);});}#o(e,t){if(this.requireUsablePath(),this.#t){this.#t[e]=t,e==="subscript"&&t===true&&(this.#t.superscript=false),e==="superscript"&&t===true&&(this.#t.subscript=false);return}let o={[e]:t};e==="subscript"&&t===true&&(o.superscript=false),e==="superscript"&&t===true&&(o.subscript=false),this.#t=o;let r=`${this.path.label}.${e}`;this.commandAnswering(this.path.label,()=>({op:"setFont",span:this.#r(),font:o}),i=>{x(i,r);},()=>{this.#t===o&&(this.#t=void 0);});}#r(){return this.requireAddressable(),S(this.path,this.#e)}};function Fe(n,e){return typeof n!="boolean"&&a({code:"InvalidArgument",target:e}),n}function Zo(n,e){return (typeof n!="number"||!Number.isFinite(n))&&a({code:"InvalidArgument",target:e}),n}function ot(n,e){return (typeof n!="string"||n.length===0)&&a({code:"InvalidArgument",target:e}),n}var Yo=new Set(["matchCase","matchWholeWord","ignorePunct","ignoreSpace","matchWildcards"]);function Oe(n,e){if(n===void 0)return;typeof n!="object"&&a({code:"InvalidArgument",target:e});for(let[o,r]of Object.entries(n))Yo.has(o)||a({code:"InvalidArgument",target:`${e}.${o}`}),r!==void 0&&typeof r!="boolean"&&a({code:"InvalidArgument",target:`${e}.${o}`});let t={...n.matchCase===void 0?{}:{matchCase:n.matchCase},...n.matchWholeWord===void 0?{}:{matchWholeWord:n.matchWholeWord},...n.ignorePunct===void 0?{}:{ignorePunct:n.ignorePunct},...n.ignoreSpace===void 0?{}:{ignoreSpace:n.ignoreSpace},...n.matchWildcards===void 0?{}:{matchWildcards:n.matchWildcards}};return Object.keys(t).length===0?void 0:t}var Jo=16,T=class n extends h{#e;#t;#o;#r;#i;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.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(e){this.#s("style",ye(e,`${this.path.label}.style`));}get shapes(){return this.#t??=Y.of(this.context,`${this.path.label}.shapes`,this.path,"paragraph"),this.#t}get font(){return this.#e??=G.of(this.context,`${this.path.label}.font`,this.path,"paragraph"),this.#e}get alignment(){return this.loadedProperty("alignment")}set alignment(e){this.#s("alignment",en(e,`${this.path.label}.alignment`));}get readingOrder(){return this.loadedProperty("readingOrder")}set readingOrder(e){this.#s("readingOrder",tn(e,`${this.path.label}.readingOrder`));}get firstLineIndent(){return this.loadedProperty("firstLineIndent")}set firstLineIndent(e){this.#s("firstLineIndent",we(e,`${this.path.label}.firstLineIndent`));}get leftIndent(){return this.loadedProperty("leftIndent")}set leftIndent(e){this.#s("leftIndent",we(e,`${this.path.label}.leftIndent`));}get rightIndent(){return this.loadedProperty("rightIndent")}set rightIndent(e){this.#s("rightIndent",we(e,`${this.path.label}.rightIndent`));}get lineSpacing(){return this.loadedProperty("lineSpacing")}set lineSpacing(e){this.#s("lineSpacing",we(e,`${this.path.label}.lineSpacing`));}get spaceBefore(){return this.loadedProperty("spaceBefore")}set spaceBefore(e){this.#s("spaceBefore",we(e,`${this.path.label}.spaceBefore`));}get spaceAfter(){return this.loadedProperty("spaceAfter")}set spaceAfter(e){this.#s("spaceAfter",we(e,`${this.path.label}.spaceAfter`));}get list(){return this.#o??=this.#d(`${this.path.label}.list`),this.#o}getRange(e="Whole"){let t=`${this.path.label}.getRange`;["Whole","Content","Start","End","Before","After"].includes(e)||a({code:"InvalidArgument",target:t});let o=A.promised(this.context,t,false);return this.read(t,()=>({op:"getRange",span:{paragraph:this.#n()},location:e}),r=>{o.hydrateAddress({kind:"span",span:k(r,t)});}),o}search(e,t){let o=`${this.path.label}.search`;typeof e!="string"&&a({code:"InvalidArgument",target:o});let r=Oe(t,o);return this.requireUsablePath(),H.of(this.context,o,this.path,()=>({op:"search",scope:{paragraph:this.#n()},text:e,options:{...r??{},projection:this.revisionTextView()}}))}startNewList(){let e=`${this.path.label}.startNewList`,t=$.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"startNewList",paragraph:this.#n()}),o=>{t.hydrateAddress({kind:"handle",handle:y(o,e)});}),t}attachToList(e,t){let o=`${this.path.label}.attachToList`;(!Number.isSafeInteger(e)||e<=0||!Number.isInteger(t)||t<0||t>8)&&a({code:"InvalidArgument",target:o});let r=$.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"attachToList",paragraph:this.#n(),listId:e,level:t}),i=>{r.hydrateAddress({kind:"handle",handle:y(i,o)});}),r}detachFromList(){let e=`${this.path.label}.detachFromList`;this.commandAnswering(e,()=>({op:"detachFromList",paragraph:this.#n()}),t=>{x(t,e);});}get listItem(){return this.#r??=Pe.of(this.context,`${this.path.label}.listItem`,this.path),this.#r}clear(){this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{paragraph:this.#n()},text:""}));}delete(){let e=`${this.path.label}.delete`;this.commandAnswering(e,()=>({op:"deleteParagraph",paragraph:this.#n()}),t=>{t.kind!=="applied"&&t.kind!=="span"&&a({code:"GeneralException",target:e});});}insertText(e,t){let o=`${this.path.label}.insertText`,r=j(e,o),i=Qt(t,o),s=A.promised(this.context,o,false);return this.commandAnswering(o,()=>i==="Replace"?{op:"replaceSpan",span:{paragraph:this.#n()},text:r}:{op:"insertText",at:{paragraph:this.#n(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:k(d,o)});}),s}insertParagraph(e,t){let o=`${this.path.label}.insertParagraph`,r=j(e,o),i=Kt(t,o),s=n.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertParagraph",anchor:{paragraph:this.#n()},where:i==="Before"?"before":"after",text:r}),d=>{d.kind!=="handle"&&a({code:"GeneralException",target:o}),s.hydrateAddress({kind:"handle",handle:d.handle});}),s}split(e,t,o){let r=`${this.path.label}.split`,i=on(e,r),s=Zt(t,`${r}.trimDelimiters`),d=Zt(o,`${r}.trimSpacing`),l=H.answered(this.context,r,this.path);return this.commandAnswering(r,()=>({op:"splitParagraph",paragraph:this.#n(),delimiters:i,...s?{trimDelimiters:true}:{},...d?{trimSpacing:true}:{}}),p=>{l.fill(p,r);}),l}onLoad(e){let t=this.selection(e,["text","uniqueLocalId",...Xt]);t.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#n(),projection:this.revisionTextView()})),t.includes("uniqueLocalId")&&this.loadTextInto("uniqueLocalId",()=>({op:"getParagraphId",paragraph:this.#n()}));let o=Xt.filter(i=>t.includes(i));if(o.length===0)return;let r=`${this.path.label}.paragraphFormat`;this.read(r,()=>({op:"getParagraphFormat",paragraph:{paragraph:this.#n()}}),i=>{let s=ut(i,r);for(let d of o)this.setLoadedProperty(d,s[d]);});}#s(e,t){if(this.requireUsablePath(),this.#i){this.#i[e]=t;return}let o={[e]:t};this.#i=o;let r=`${this.path.label}.${e}`;this.commandAnswering(`${this.path.label}.paragraphFormat`,()=>({op:"setParagraphFormat",paragraph:{paragraph:this.#n()},format:o}),i=>{x(i,r);},()=>{this.#i===o&&(this.#i=void 0);});}#d(e){let t=$.promised(this.context,e,false);return this.read(e,()=>({op:"getParagraphList",paragraph:this.#n()}),o=>{t.hydrateAddress({kind:"handle",handle:y(o,e)});}),t}#n(){return this.requireAddressable(),this.path.handle()}},Xt=["style","alignment","firstLineIndent","leftIndent","rightIndent","lineSpacing","spaceBefore","spaceAfter","readingOrder"],_o=["Left","Centered","Right","Justified"];function en(n,e){return _o.includes(n)||a({code:"InvalidArgument",target:e}),n}function tn(n,e){return n!=="LeftToRight"&&n!=="RightToLeft"&&a({code:"InvalidArgument",target:e}),n}function we(n,e){return (typeof n!="number"||!Number.isFinite(n))&&a({code:"InvalidArgument",target:e}),n}function on(n,e){(!Array.isArray(n)||n.length===0||n.length>Jo)&&a({code:"InvalidArgument",target:e});for(let t of n)(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:e});return [...n]}function Zt(n,e){return n!==void 0&&typeof n!="boolean"&&a({code:"InvalidArgument",target:e}),n===true}var E=class n extends N{#e;static of(e,t,o){return new n(e,u.derived(t,o),null)}static overListing(e,t,o,r){return new n(e,u.derived(t,o),r)}constructor(e,t,o){super(e,t),this.#e=o;}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.#e)return this.#e();let e=this.path.address();return e.kind==="handle"?{op:"getParagraphs",body:e.handle}:{op:"getSpanParagraphs",span:e.span}}size(e,t){return R(e,t).length}addressAt(e,t,o){let r=R(e,t)[o];return r?{kind:"handle",handle:r}:void 0}itemAt(e,t){return T.at(this.context,e,t)}promised(e,t){return T.promised(this.context,e,t)}},H=class n extends N{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}static answered(e,t,o){return new n(e,u.derived(t,o),null)}constructor(e,t,o){super(e,t),this.#e=o;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#e?this.#e():null}size(e,t){return Z(e,t).length}addressAt(e,t,o){let r=Z(e,t)[o];return r?{kind:"span",span:r}:void 0}itemAt(e,t){return A.at(this.context,e,t)}promised(e,t){return A.promised(this.context,e,t)}};var Jt=4096,z=class n extends h{#e;#t=new Map;#o;#r;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get tag(){return this.loadedProperty("tag")}set tag(e){this.#s("tag",{tag:Ot(e,`${this.path.label}.tag`)});}get title(){return this.loadedProperty("title")}set title(e){this.#s("title",{title:Ot(e,`${this.path.label}.title`)});}get subtype(){return this.loadedProperty("subtype")}get isBound(){return this.loadedProperty("isBound")}get cannotDelete(){let e=this.loadedProperty("lock");return e==="sdtLocked"||e==="sdtContentLocked"}set cannotDelete(e){this.#d("cannotDelete",e);}get cannotEdit(){let e=this.loadedProperty("lock");return e==="contentLocked"||e==="sdtContentLocked"}set cannotEdit(e){this.#d("cannotEdit",e);}get placeholderShown(){return this.loadedProperty("placeholderShown")}get temporary(){return this.loadedProperty("temporary")}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#o??=E.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getContentControlParagraphs",contentControl:this.#n()})),this.#o}get contentControls(){return this.#r??=Q.of(this.context,`${this.path.label}.contentControls`,this.path,{contentControl:this.#n()}),this.#r}getRange(e){let t=`${this.path.label}.getRange`,o=nn(e??"Whole",t),r=this.#t.get(o);if(r)return r;let i=this.#i(t,o);return this.#t.set(o,i),i}setValue(e){let t=`${this.path.label}.setValue`,o=rn(e,t);this.command("setValue",()=>({op:"setContentControlValue",contentControl:this.#n(),value:o}));}insertText(e,t){let o=`${this.path.label}.insertText`,r=j(e,o),i=t==="Replace"?"replace":t==="Start"?"start":t==="End"?"end":a({code:"InvalidArgument",target:o}),s=A.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertContentControlText",contentControl:this.#n(),text:r,at:i}),d=>{s.hydrateAddress({kind:"span",span:k(d,o)});}),s}delete(e){let t=`${this.path.label}.delete`;typeof e!="boolean"&&a({code:"InvalidArgument",target:t}),this.command("delete",()=>({op:"deleteContentControl",contentControl:this.#n(),keepContent:e}));}onLoad(e){let t=this.selection(e,["id","tag","title","subtype","isBound","text","cannotDelete","cannotEdit","placeholderShown","temporary"]);if(t.includes("id")&&this.loadTextInto("id",()=>({op:"getContentControlFileId",contentControl:this.#n()})),t.includes("tag")&&this.loadTextInto("tag",()=>({op:"getContentControlTag",contentControl:this.#n()})),t.includes("title")&&this.loadTextInto("title",()=>({op:"getContentControlTitle",contentControl:this.#n()})),t.includes("subtype")&&this.loadTextInto("subtype",()=>({op:"getContentControlSubtype",contentControl:this.#n()})),t.includes("isBound")){let r=`${this.path.label}.isBound`;this.read(r,()=>({op:"getContentControlIsBound",contentControl:this.#n()}),i=>{this.setLoadedProperty("isBound",ce(i,r));});}if(t.includes("text")&&this.loadTextInto("text",()=>({op:"getContentControlText",contentControl:this.#n(),projection:this.revisionTextView()})),t.includes("cannotDelete")||t.includes("cannotEdit")){let r=`${this.path.label}.lock`;this.read(r,()=>({op:"getContentControlLock",contentControl:this.#n()}),i=>{this.setLoadedProperty("lock",w(i,r));});}if(t.includes("placeholderShown")){let r=`${this.path.label}.placeholderShown`;this.read(r,()=>({op:"getContentControlPlaceholderShown",contentControl:this.#n()}),i=>{this.setLoadedProperty("placeholderShown",ce(i,r));});}if(!t.includes("temporary"))return;let o=`${this.path.label}.temporary`;this.read(o,()=>({op:"getContentControlTemporary",contentControl:this.#n()}),r=>{this.setLoadedProperty("temporary",ce(r,o));});}#i(e,t){let o=A.promised(this.context,e,false);return this.read(e,()=>({op:"getContentControlRange",contentControl:this.#n(),location:t}),r=>{o.hydrateAddress({kind:"span",span:k(r,e)});}),o}#s(e,t){this.command(e,()=>({op:"setContentControlProperties",contentControl:this.#n(),...t}));}#d(e,t){let o=`${this.path.label}.${e}`;if(typeof t!="boolean"&&a({code:"InvalidArgument",target:o}),this.requireUsablePath(),this.#e){this.#e[e]=t;return}let r={[e]:t};this.#e=r,this.command(e,()=>({op:"setContentControlProperties",contentControl:this.#n(),...r}),()=>{this.#e===r&&(this.#e=void 0);});}#n(){return this.requireAddressable(),this.path.handle()}},Q=class n extends C{#e;#t;static of(e,t,o,r){return new n(e,u.derived(t,o),r,()=>({op:"getContentControls",scope:r}))}constructor(e,t,o,r){super(e,t),this.#e=o,this.#t=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getById(e){let t=`${this.path.label}.getById`;Number.isInteger(e)||a({code:"InvalidArgument",target:t});let o=this.#e,r=z.promised(this.context,t,false);return this.enqueue({sort:"read",label:t,plan:()=>({op:"getContentControlById",scope:o,id:e}),settle:i=>{r.hydrateAddress({kind:"handle",handle:y(i,t)});}}),r}getByTag(e){let t=`${this.path.label}.getByTag`,o=Yt(e,t),r=this.#e;return new n(this.context,u.derived(t,this.path),r,()=>({op:"getContentControlsByTag",scope:r,tag:o}))}getByTitle(e){let t=`${this.path.label}.getByTitle`,o=Yt(e,t),r=this.#e;return new n(this.context,u.derived(t,this.path),r,()=>({op:"getContentControlsByTitle",scope:r,title:o}))}listing(){return this.#t()}itemAt(e,t){return z.at(this.context,e,t)}promised(e,t){return z.promised(this.context,e,t)}};function Ot(n,e){return (typeof n!="string"||n.length>Jt)&&a({code:"InvalidArgument",target:e}),n}function Yt(n,e){let t=Ot(n,e);return t.length===0&&a({code:"InvalidArgument",target:e}),t}function nn(n,e){switch(n){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:e})}}function rn(n,e){(typeof n!="object"||n===null)&&a({code:"InvalidArgument",target:e});let t=n;if(t.kind==="text"||t.kind==="listItem"){let o=t.kind==="text"?t.text:t.value;return (typeof o!="string"||o.length>Jt)&&a({code:"InvalidArgument",target:e}),t.kind==="text"?{kind:"text",text:o}:{kind:"listItem",value:o}}if(t.kind==="checkbox")return typeof t.checked!="boolean"&&a({code:"InvalidArgument",target:e}),{kind:"checkbox",checked:t.checked};if(t.kind==="date")return (typeof t.iso!="string"||t.iso.length>64)&&a({code:"InvalidArgument",target:e}),{kind:"date",iso:t.iso};a({code:"InvalidArgument",target:e});}function sn(n,e){return e<1||e>12?0:e===2?n%4===0&&n%100!==0||n%400===0?29:28:e===4||e===6||e===9||e===11?30:31}function _t(n){if(n.length===0)return null;let e=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/.exec(n.trim());if(!e)return null;let t=Number(e[1]),o=Number(e[2]),r=Number(e[3]),i=sn(t,o);if(t===0||i===0||r<1||r>i)return null;let s=Number(e[4]),d=Number(e[5]),l=Number(e[6]);if(s>23||d>59||l>59)return null;let p=e[7],b=p===void 0?0:Number(p.padEnd(3,"0").slice(0,3));if(Number.isNaN(b))return null;let X=`${e[1]}-${e[2]}-${e[3]}T${e[4]}:${e[5]}:${e[6]}.${String(b).padStart(3,"0")}Z`,I=Date.parse(X);if(Number.isNaN(I))return null;let me=e[8];if(me==="Z")return new Date(I);let ae=Number(me.slice(1,3)),Ee=Number(me.slice(4,6));if(Ee>59||ae>14||ae===14&&Ee!==0)return null;let it=me[0]==="+"?1:-1,Te=new Date(I-it*(ae*36e5+Ee*6e4));return Number.isNaN(Te.getTime())?null:Te}var nt=class extends h{hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.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(e,t){let o=this.selection(e,["authorName","creationDate","id","text",...t]);if(o.includes("authorName")&&this.loadTextInto("authorName",()=>({op:"getCommentAuthor",comment:this.commentHandle()})),o.includes("text")&&this.loadTextInto("text",()=>({op:"getCommentText",comment:this.commentHandle()})),o.includes("id")&&this.loadTextInto("id",()=>({op:"getCommentId",comment:this.commentHandle()})),o.includes("creationDate")){let i=`${this.path.label}.creationDate`;this.read(i,()=>({op:"getCommentDate",comment:this.commentHandle()}),s=>{this.setLoadedProperty("creationDate",_t(w(s,i)));});}if(!o.includes("resolved"))return;let r=`${this.path.label}.resolved`;this.read(r,()=>({op:"getCommentResolved",comment:this.commentHandle()}),i=>{this.setLoadedProperty("resolved",ce(i,r));});}commentHandle(){return this.requireAddressable(),this.path.handle()}},he=class n extends nt{static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}onLoad(e){this.loadCommentFields(e,[]);}},Ve=class n extends C{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}constructor(e,t,o){super(e,t),this.#e=o;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#e()}itemAt(e,t){return he.at(this.context,e,t)}promised(e,t){return he.promised(this.context,e,t)}},re=class n extends nt{#e;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}get resolved(){return this.loadedProperty("resolved")}set resolved(e){let t=`${this.path.label}.resolved`;typeof e!="boolean"&&a({code:"InvalidArgument",target:t}),this.commandAnswering(t,()=>({op:"setCommentResolved",comment:this.commentHandle(),resolved:e}),o=>{x(o,t);});}get replies(){return this.#e??=Ve.of(this.context,`${this.path.label}.replies`,this.path,()=>({op:"getCommentReplies",comment:this.commentHandle()})),this.#e}getRange(){let e=`${this.path.label}.getRange`,t=A.promised(this.context,e,false);return this.read(e,()=>({op:"getCommentRange",comment:this.commentHandle()}),o=>{t.hydrateAddress({kind:"span",span:k(o,e)});}),t}reply(e){let t=`${this.path.label}.reply`;(typeof e!="string"||e.length===0)&&a({code:"InvalidArgument",target:t});let o=this.internals.author;(typeof o!="string"||o.trim().length===0)&&a({code:"NotSupported",target:t});let r=he.promised(this.context,t,false);return this.commandAnswering(t,()=>({op:"replyToComment",comment:this.commentHandle(),text:e,author:o}),i=>{r.hydrateAddress({kind:"handle",handle:y(i,t)});}),r}onLoad(e){this.loadCommentFields(e,["resolved"]);}},ie=class n extends C{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}constructor(e,t,o){super(e,t),this.#e=o;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#e()}itemAt(e,t){return re.at(this.context,e,t)}promised(e,t){return re.promised(this.context,e,t)}},K=class n extends h{static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.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 e=`${this.path.label}.range`,t=A.promised(this.context,e,false);return this.read(e,()=>({op:"getRevisionRange",revision:this.#e()}),o=>{t.hydrateAddress({kind:"span",span:k(o,e)});}),t}accept(){this.command("accept",()=>({op:"acceptRevision",revision:this.#e()}));}reject(){this.command("reject",()=>({op:"rejectRevision",revision:this.#e()}));}onLoad(e){let t=this.selection(e,["author","date","type"]);if(t.includes("author")&&this.loadTextInto("author",()=>({op:"getRevisionAuthor",revision:this.#e()})),t.includes("type")&&this.loadTextInto("type",()=>({op:"getRevisionType",revision:this.#e()})),!t.includes("date"))return;let o=`${this.path.label}.date`;this.read(o,()=>({op:"getRevisionDate",revision:this.#e()}),r=>{this.setLoadedProperty("date",_t(w(r,o)));});}static batchHandle(e,t,o="RevisionCollection.resolve"){return (!(e instanceof n)||e.context!==t)&&a({code:"InvalidArgument",target:o}),e.#e()}#e(){return this.requireAddressable(),this.path.handle()}},q=class n extends C{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),{body:r})}static inSpan(e,t,o,r){return new n(e,u.derived(t,o),{span:r})}static ofReviewKey(e,t,o,r){return new n(e,u.derived(t,o),{key:r})}constructor(e,t,o){super(e,t),this.#e=o;}acceptAll(){this.commandOn("acceptAll",()=>this.#t("acceptAllRevisions"));}rejectAll(){this.commandOn("rejectAll",()=>this.#t("rejectAllRevisions"));}#t(e){return {op:e,...this.#o()}}#o(){let e=this.#e;return "span"in e?{scope:e.span()}:"key"in e?{key:e.key}:{body:e.body}}#r(e){let t=this.#e;return "body"in t||a({code:"NotSupported",target:`${this.path.label}.${e}`}),t.body}resolve(e,t){let o=`${this.path.label}.resolve`;(!["accept","reject"].includes(e)||t!==void 0&&!Array.isArray(t))&&a({code:"InvalidArgument",target:o});let r=this.#r("resolve"),i=t===void 0?void 0:[...t],{result:s,fill:d}=Ne(o);return this.enqueue({sort:"write",label:o,plan:()=>({op:"resolveRevisionBatch",body:r,action:e,...i===void 0?{}:{revisions:i.map(l=>K.batchHandle(l,this.context))}}),settle:l=>{l.kind!=="revisionBatch"&&a({code:"GeneralException",target:o}),d(l.result);}}),s}setAuthor(e,t,o){let r=`${this.path.label}.setAuthor`,i=o?.date,s=Array.isArray(t)?t:void 0,d=t!==void 0&&!Array.isArray(t)?t?.authors:void 0;(typeof e!="string"||e.trim().length===0||t!==void 0&&!Array.isArray(t)&&(typeof t!="object"||t===null||!Array.isArray(d)||d.some(I=>typeof I!="string"))||o!==void 0&&(typeof o!="object"||o===null)||i!==void 0&&(!(i instanceof Date)||Number.isNaN(i.getTime()))||s?.some(I=>!(I instanceof K)||I.context!==this.context))&&a({code:"InvalidArgument",target:r});let l=this.#r("setAuthor"),p=s===void 0?void 0:[...s],{result:b,fill:X}=Ne(r);return this.enqueue({sort:"write",label:r,plan:()=>({op:"setRevisionAuthorBatch",body:l,author:e,...i===void 0?{}:{date:i.toISOString()},...d===void 0?{}:{authors:[...d]},...p===void 0?{}:{revisions:p.map(I=>K.batchHandle(I,this.context,r))}}),settle:I=>{I.kind!=="revisionAuthors"&&a({code:"GeneralException",target:r}),X(I.result);}}),b}listing(){return {op:"getRevisions",...this.#o()}}itemAt(e,t){return K.at(this.context,e,t)}promised(e,t){return K.promised(this.context,e,t)}commandOn(e,t){let o=`${this.path.label}.${e}`;this.enqueue({sort:"write",label:o,plan:t,settle:r=>{x(r,o);}});}};var A=class n extends h{#e;#t;#o;#r;#i;#s;#d;static at(e,t,o){return o.kind!=="span"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.ofSpan(t,o.span),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="span"?this.path.resolveToSpan(e.span):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get font(){return this.#i??=G.of(this.context,`${this.path.label}.font`,this.path,"span"),this.#i}get paragraphs(){return this.#r??=E.of(this.context,`${this.path.label}.paragraphs`,this.path),this.#r}get style(){return this.loadedProperty("style")}set style(e){let t=`${this.path.label}.style`,o=ye(e,t);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:S(this.path,"span"),name:o}));}get hyperlink(){return this.loadedProperty("hyperlink")}set hyperlink(e){let t=`${this.path.label}.hyperlink`;(typeof e!="string"||e.length>2048)&&a({code:"InvalidArgument",target:t}),this.requireUsablePath(),this.command("hyperlink",()=>({op:"setHyperlink",span:this.#n(),target:e}));}get bookmarks(){let e=this.#n();return this.#s??=se.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{start:e.start,end:e.end}})),this.#s}insertBookmark(e){let t=`${this.path.label}.insertBookmark`;this.requireUsablePath(),this.command("insertBookmark",()=>((typeof e!="string"||e.length===0)&&a({code:"InvalidArgument",target:t}),{op:"insertBookmark",span:this.#n(),name:e}));}getBookmarks(e,t){let o=`${this.path.label}.getBookmarks`,{result:r,fill:i}=Ne(o);return this.read(o,()=>((e!==void 0&&typeof e!="boolean"||t!==void 0&&typeof t!="boolean")&&a({code:"InvalidArgument",target:o}),{op:"getBookmarkNames",scope:this.#n(),includeHidden:e===true,includeAdjacent:t===true}),s=>{s.kind!=="texts"&&a({code:"GeneralException",target:o}),i([...s.texts]);}),r}get revisions(){return this.#d??=q.inSpan(this.context,`${this.path.label}.revisions`,this.path,()=>S(this.path,"span")),this.#d}search(e,t){let o=`${this.path.label}.search`;typeof e!="string"&&a({code:"InvalidArgument",target:o});let r=Oe(t,o),i=this.#n();return H.of(this.context,o,this.path,()=>({op:"search",scope:i,text:e,options:{...r??{},projection:this.revisionTextView()}}))}insertText(e,t){let o=`${this.path.label}.insertText`,r=j(e,o),i=Me(t,o);this.requireUsablePath();let s=n.promised(this.context,o,false);return this.commandAnswering(o,()=>{let d=this.#n();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:k(d,o)});}),s}delete(){this.requireUsablePath(),this.commandDiscarding("delete",()=>({op:"replaceSpan",span:this.#n(),text:""}));}clear(){let e=this.#n();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:e,text:""}));}insertComment(e){let t=`${this.path.label}.insertComment`;(typeof e!="string"||e.length===0)&&a({code:"InvalidArgument",target:t});let o=this.internals.author;(typeof o!="string"||o.trim().length===0)&&a({code:"NotSupported",target:t});let r=re.promised(this.context,t,false);return this.commandAnswering(t,()=>({op:"insertComment",span:this.#n(),text:e,author:o}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:t}),r.hydrateAddress(i);}),r}insertContentControl(e){let t=`${this.path.label}.insertContentControl`,o=e??"RichText";o!=="RichText"&&o!=="PlainText"&&o!=="DatePicker"&&a({code:"NotSupported",target:t});let r=z.promised(this.context,t,false);return this.commandAnswering(t,()=>({op:"insertContentControl",span:this.#n(),subtype:o==="DatePicker"?"date":o==="PlainText"?"plainText":"richText",returnHandle:true}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:t}),r.hydrateAddress(i);}),r}get tables(){return this.requireUsablePath(),this.#e??=ne.over(this.context,`${this.path.label}.tables`,this.path,()=>S(this.path,"span"))}get fields(){return this.requireUsablePath(),this.#t??=_.of(this.context,`${this.path.label}.fields`,this.path,"span")}insertField(e,t,o,r){let i=`${this.path.label}.insertField`;(t!==void 0&&typeof t!="string"||o!==void 0&&typeof o!="string"||r!==void 0&&typeof r!="boolean")&&a({code:"InvalidArgument",target:i});let s=Me(e,i);this.requireUsablePath();let d=J.promised(this.context,i,false);return this.commandAnswering(i,()=>({op:"insertField",span:this.#n(),location:s,...t===void 0?{}:{fieldType:t},...o===void 0?{}:{text:o},...r===void 0?{}:{removeFormatting:r}}),l=>d.hydrateAddress({kind:"handle",handle:y(l,i)})),d}get inlinePictures(){return this.requireUsablePath(),this.#o??=te.of(this.context,`${this.path.label}.inlinePictures`,this.path,"span")}insertInlinePictureFromBase64(e,t){let o=`${this.path.label}.insertInlinePictureFromBase64`;(typeof e!="string"||e.length===0)&&a({code:"InvalidArgument",target:o});let r=Me(t,o);this.requireUsablePath();let i=ee.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertInlinePicture",span:this.#n(),base64:e,location:r}),s=>{i.hydrateAddress({kind:"handle",handle:y(s,o)});}),i}insertBreak(e,t){let o=`${this.path.label}.insertBreak`;t!=="Before"&&t!=="After"&&a({code:"InvalidArgument",target:o});let r=t;this.requireUsablePath(),this.commandAnswering(o,()=>({op:"insertBreak",span:this.#n(),breakType:e,location:r}),i=>x(i,o));}insertTable(e,t,o,r){let i=`${this.path.label}.insertTable`;(!Number.isInteger(e)||!Number.isInteger(t)||e<1||t<1||!["Before","After"].includes(o))&&a({code:"InvalidArgument",target:i}),r!==void 0&&(!Array.isArray(r)||r.some(l=>!Array.isArray(l)||l.some(p=>typeof p!="string")))&&a({code:"InvalidArgument",target:i});let s=r?.map(l=>[...l]),d=oe.promised(this.context,i);return this.commandAnswering(i,()=>({op:"insertTable",span:S(this.path,"span"),location:o,rowCount:e,columnCount:t,...s?{values:s}:{}}),l=>{l.kind!=="handle"&&a({code:"GeneralException",target:i}),d.hydrateAddress({kind:"handle",handle:l.handle});}),d}insertParagraph(e,t){let o=`${this.path.label}.insertParagraph`,r=j(e,o),i=Me(t,o);i!=="Before"&&i!=="After"&&a({code:"InvalidArgument",target:o});let s=this.#n(),d=i==="Before"?s.start.paragraph:s.end.paragraph,l=T.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertParagraph",anchor:{paragraph:d},where:i==="Before"?"before":"after",text:r}),p=>{p.kind!=="handle"&&a({code:"GeneralException",target:o}),l.hydrateAddress({kind:"handle",handle:p.handle});}),l}select(e){let t=`${this.path.label}.select`,o=tt(e,t);this.requireAddressable(),this.internals.capabilities.selection||a({code:"NotSupported",target:t});let r=this.#n();this.command("select",()=>({op:"selectSpan",span:r,mode:o==="Select"?"select":o==="Start"?"start":"end"}));}onLoad(e){let t=this.selection(e,["text","style","hyperlink"]);if(t.includes("hyperlink")&&this.loadTextInto("hyperlink",()=>({op:"getHyperlink",span:this.#n()})),t.includes("text")){let r=`${this.path.label}.text`;this.read(r,()=>({op:"getSpanText",span:this.#n(),projection:this.revisionTextView()}),i=>{this.setLoadedProperty("text",w(i,r));});}if(!t.includes("style"))return;let o=`${this.path.label}.style`;this.requireUsablePath(),this.read(o,()=>({op:"getStyle",span:S(this.path,"span")}),r=>{this.setLoadedProperty("style",qe(r,o));});}#n(){return this.requireAddressable(),this.path.span()}};var ke=class n extends h{#e;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get name(){return this.loadedProperty("name")}get range(){return this.#e??=this.#t(`${this.path.label}.range`),this.#e}select(e){let t=`${this.path.label}.select`,o=tt(e,t);this.requireUsablePath(),this.internals.capabilities.selection||a({code:"NotSupported",target:t}),this.command("select",()=>({op:"selectBookmark",bookmark:this.#o(),mode:o==="Select"?"select":o==="Start"?"start":"end"}));}delete(){this.requireUsablePath(),this.command("delete",()=>({op:"deleteBookmark",target:{bookmark:this.#o()}}));}onLoad(e){if(!this.selection(e,["name"]).includes("name"))return;let t=`${this.path.label}.name`;this.read(t,()=>({op:"getBookmarkName",bookmark:this.#o()}),o=>{this.setLoadedProperty("name",w(o,t));});}#t(e){let t=A.promised(this.context,e,false);return this.read(e,()=>({op:"getBookmarkRange",bookmark:this.#o()}),o=>{t.hydrateAddress({kind:"span",span:k(o,e)});}),t}#o(){return this.requireAddressable(),this.path.handle()}},se=class n extends C{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}constructor(e,t,o){super(e,t),this.#e=o;}listing(){return this.#e()}itemAt(e,t){return ke.at(this.context,e,t)}promised(e,t){return ke.promised(this.context,e,t)}};var L=class n extends h{#e;#t;get footnotes(){return this.#e??=F.of(this.context,`${this.path.label}.footnotes`,this.path,()=>({op:"getNotes",document:this.internals.roots().document,scope:this.#l(),noteKind:"footnote"}))}get endnotes(){return this.#t??=F.of(this.context,`${this.path.label}.endnotes`,this.path,()=>({op:"getNotes",document:this.internals.roots().document,scope:this.#l(),noteKind:"endnote"}))}#o;#r;#i;#s;#d;#n;#a;#c;#u;#p;static main(e,t){return new n(e,u.of(t,U(e).roots().body))}static promisedStory(e,t){return new n(e,u.pending(t))}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.handle):this.path.resolveNull();}constructor(e,t){super(e,t);}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#d??=this.paragraphsUnder(`${this.path.label}.paragraphs`),this.#d}get bookmarks(){let e=this.#l();return this.#n??=se.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{body:e}})),this.#n}get font(){return this.#a??=G.of(this.context,`${this.path.label}.font`,this.path,"body"),this.#a}paragraphsUnder(e){return E.of(this.context,e,this.path)}get style(){return this.loadedProperty("style")}set style(e){let t=`${this.path.label}.style`,o=ye(e,t);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:S(this.path,"body"),name:o}));}get lists(){return this.#c??=Ce.of(this.context,`${this.path.label}.lists`,this.path,this.#l()),this.#c}get contentControls(){return this.#u??=Q.of(this.context,`${this.path.label}.contentControls`,this.path,{body:this.#l()}),this.#u}getComments(){let e=`${this.path.label}.getComments`,t=this.#l();return ie.of(this.context,e,this.path,()=>({op:"getComments",scope:{body:t}}))}get revisions(){return this.#p??=q.of(this.context,`${this.path.label}.revisions`,this.path,this.#l()),this.#p}getRange(e="Whole"){let t=`${this.path.label}.getRange`;this.requireUsablePath();let o=A.promised(this.context,t,false);return this.read(t,()=>({op:"getRange",span:{body:this.path.handle()},location:e}),r=>{o.hydrateAddress({kind:"span",span:k(r,t)});}),o}search(e,t){let o=`${this.path.label}.search`;typeof e!="string"&&a({code:"InvalidArgument",target:o});let r=Oe(t,o),i=this.#l();return H.of(this.context,o,this.path,()=>({op:"search",scope:{body:i},text:e,options:{...r??{},projection:this.revisionTextView()}}))}clear(){let e=this.#l();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{body:e},text:""}));}insertText(e,t){let o=`${this.path.label}.insertText`,r=j(e,o),i=Ut(t,o);this.requireUsablePath();let s=A.promised(this.context,o,false);return this.commandAnswering(o,()=>i==="Replace"?{op:"replaceSpan",span:{body:this.#l()},text:r}:{op:"insertText",at:{body:this.#l(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:k(d,o)});}),s}insertParagraph(e,t){let o=`${this.path.label}.insertParagraph`,r=j(e,o),i=zt(t,o),s=this.#l(),d=T.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertParagraph",anchor:{body:s,at:i==="Start"?"first":"last"},where:i==="Start"?"before":"after",text:r}),l=>{l.kind!=="handle"&&a({code:"GeneralException",target:o}),d.hydrateAddress({kind:"handle",handle:l.handle});}),d}onLoad(e){let t=this.selection(e,["text","style"]);t.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#l(),projection:this.revisionTextView()})),t.includes("style")&&this.#h();}#h(){let e=`${this.path.label}.style`;this.requireUsablePath(),this.read(e,()=>({op:"getStyle",span:S(this.path,"body")}),t=>{this.setLoadedProperty("style",qe(t,e));});}get fields(){return this.requireUsablePath(),this.#r??=_.of(this.context,`${this.path.label}.fields`,this.path,"body")}get inlinePictures(){return this.requireUsablePath(),this.#i??=te.of(this.context,`${this.path.label}.inlinePictures`,this.path,"body")}get shapes(){return this.requireUsablePath(),this.#s??=Y.of(this.context,`${this.path.label}.shapes`,this.path,"body")}get tables(){return this.requireUsablePath(),this.#o??=ne.over(this.context,`${this.path.label}.tables`,this.path,()=>({body:this.#l()}))}#l(){return this.requireAddressable(),this.path.handle()}};var an=Object.freeze({Primary:"default",FirstPage:"first",EvenPages:"even"}),dn=["pageWidth","pageHeight","orientation","topMargin","rightMargin","bottomMargin","leftMargin"],Ge=class n extends h{#e;static of(e,t,o){return new n(e,u.derived(t,o))}constructor(e,t){super(e,t);}get pageWidth(){return this.loadedProperty("pageWidth")}set pageWidth(e){this.#t("pageWidth",Se(e,`${this.path.label}.pageWidth`));}get pageHeight(){return this.loadedProperty("pageHeight")}set pageHeight(e){this.#t("pageHeight",Se(e,`${this.path.label}.pageHeight`));}get orientation(){return this.loadedProperty("orientation")}set orientation(e){let t=`${this.path.label}.orientation`;e!=="Portrait"&&e!=="Landscape"&&a({code:"InvalidArgument",target:t}),this.#t("orientation",e==="Portrait"?"portrait":"landscape");}get topMargin(){return this.loadedProperty("topMargin")}set topMargin(e){this.#t("topMargin",Se(e,`${this.path.label}.topMargin`));}get bottomMargin(){return this.loadedProperty("bottomMargin")}set bottomMargin(e){this.#t("bottomMargin",Se(e,`${this.path.label}.bottomMargin`));}get leftMargin(){return this.loadedProperty("leftMargin")}set leftMargin(e){this.#t("leftMargin",Se(e,`${this.path.label}.leftMargin`));}get rightMargin(){return this.loadedProperty("rightMargin")}set rightMargin(e){this.#t("rightMargin",Se(e,`${this.path.label}.rightMargin`));}onLoad(e){let t=this.selection(e,dn);if(t.length===0)return;let o=`${this.path.label}.pageSetup`;this.read(o,()=>({op:"getPageSetup",section:this.#o()}),r=>{let i=pt(r,o);for(let s of t)this.setLoadedProperty(s,s==="orientation"?i.orientation==="landscape"?"Landscape":"Portrait":i[s]);});}#t(e,t){if(this.requireUsablePath(),this.#e){this.#e[e]=t;return}let o={[e]:t};this.#e=o;let r=`${this.path.label}.${e}`;this.commandAnswering(`${this.path.label}.pageSetup`,()=>({op:"setPageSetup",section:this.#o(),setup:o}),i=>{x(i,r);},()=>{this.#e===o&&(this.#e=void 0);});}#o(){this.requireAddressable();let e=this.path.address();return e.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),e.handle}},Ie=class n extends h{#e;#t;static at(e,t,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:t}),new n(e,u.of(t,o.handle),false)}static promised(e,t,o){return new n(e,u.pending(t),o)}constructor(e,t,o){super(e,t,{nullable:o});}hydrateAddress(e){e.kind==="handle"?this.path.resolveTo(e.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){return this.#t??=L.main(this.context,`${this.path.label}.body`),this.#t}get pageSetup(){return this.#e??=Ge.of(this.context,`${this.path.label}.pageSetup`,this.path),this.#e}getHeader(e){return this.#o("header",e,"getHeader")}getFooter(e){return this.#o("footer",e,"getFooter")}getNext(){let e=`${this.path.label}.getNext`,t=n.promised(this.context,e,false),o=this.internals.roots().document;return this.read(e,()=>({op:"getSections",document:o}),r=>{let i=R(r,e),s=i.findIndex(l=>l.ref===this.#r().ref),d=s<0?void 0:i[s+1];d||a({code:"ItemNotFound",target:e}),t.hydrateAddress({kind:"handle",handle:d});}),t}onLoad(e){this.selection(e,[]);}#o(e,t,o){let r=`${this.path.label}.${o}`,i=an[t];i===void 0&&a({code:"InvalidArgument",target:r});let s=L.promisedStory(this.context,r);return this.read(r,()=>({op:"getFurniture",section:this.#r(),kind:e,variant:i}),d=>{s.hydrateAddress({kind:"handle",handle:y(d,r)});}),s}#r(){return this.requireAddressable(),this.path.handle()}},Le=class n extends C{#e;static of(e,t,o,r){return new n(e,u.derived(t,o),r)}constructor(e,t,o){super(e,t),this.#e=o;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#e()}itemAt(e,t){return Ie.at(this.context,e,t)}promised(e,t){return Ie.promised(this.context,e,t)}};function Se(n,e){return (typeof n!="number"||!Number.isFinite(n)||n<0)&&a({code:"InvalidArgument",target:e}),n}var je=class n extends h{#e;#t;#o;#r;#i;#s;#d;#n;#a;static open(e){return new n(e)}constructor(e){super(e,u.of("document",U(e).roots().document));}get changeTrackingMode(){return this.loadedProperty("changeTrackingMode")}set changeTrackingMode(e){["Off","TrackAll","TrackMineOnly"].includes(e)||a({code:"InvalidArgument",target:"document.changeTrackingMode"});let t=this.internals.author;this.commandAnswering("document.changeTrackingMode",()=>({op:"setChangeTrackingMode",mode:e,...t===void 0?{}:{author:t}}),()=>this.setLoadedProperty("changeTrackingMode",e));}get body(){return this.#t??=L.main(this.context,"document.body"),this.#t}removeDocumentInformation(e){this.command(`${this.path.label}.removeDocumentInformation`,()=>({op:"removeDocumentInformation",removeDocInfoType:e}));}get properties(){return this.#e??=be.of(this.context,this.path),this.#e}get paragraphs(){return this.#o??=this.body.paragraphsUnder("document.paragraphs"),this.#o}get sections(){let e=this.path.handle();return this.#r??=Le.of(this.context,"document.sections",this.path,()=>({op:"getSections",document:e})),this.#r}get contentControls(){return this.#d??=Q.of(this.context,"document.contentControls",this.path,{body:this.internals.roots().body}),this.#d}get comments(){return this.#i??=ie.of(this.context,"document.comments",this.path,()=>({op:"getComments",scope:{body:this.internals.roots().body}})),this.#i}get revisions(){return this.#s??=q.of(this.context,"document.revisions",this.path,this.internals.roots().body),this.#s}get footnotes(){let e=this.path.handle();return this.#n??=F.of(this.context,"document.footnotes",this.path,()=>({op:"getNotes",document:e,noteKind:"footnote"})),this.#n}get endnotes(){let e=this.path.handle();return this.#a??=F.of(this.context,"document.endnotes",this.path,()=>({op:"getNotes",document:e,noteKind:"endnote"})),this.#a}deleteBookmark(e){let t=`${this.path.label}.deleteBookmark`,o=this.path.handle();this.command("deleteBookmark",()=>(typeof e!="string"&&a({code:"InvalidArgument",target:t}),{op:"deleteBookmark",target:{document:o,name:e}}));}getBookmarkRange(e){return this.#c(e,"getBookmarkRange",false)}getBookmarkRangeOrNullObject(e){return this.#c(e,"getBookmarkRangeOrNullObject",true)}#c(e,t,o){let r=`${this.path.label}.${t}`,i=this.path.handle(),s=A.promised(this.context,r,o);return this.read(r,()=>(typeof e!="string"&&a({code:"InvalidArgument",target:r}),{op:"getBookmarkRangeByName",document:i,name:e}),d=>{let p=Z(d,r)[0];if(!p){o||a({code:"ItemNotFound",target:r}),s.hydrateNull();return}s.hydrateAddress({kind:"span",span:p});}),s}onLoad(e){if(e.select.length===0)return;this.selection(e,["changeTrackingMode"]).includes("changeTrackingMode")&&this.loadTextInto("changeTrackingMode",()=>({op:"getChangeTrackingMode"}));}};var eo=n=>typeof n=="object"&&n!==null&&typeof n.kind=="string"&&typeof n.ref=="string";function oo(n){let e=[],t=o=>{if(Array.isArray(o))return o.forEach(t);if(o===null||typeof o!="object")return;let r=o;if(W(o))return;let i=Object.keys(r),s=i.length===1&&(i[0]==="paragraph"||i[0]==="body")&&eo(r[i[0]]),d=typeof r.start=="object"&&r.start!==null&&W(r.start)&&typeof r.end=="object"&&r.end!==null&&W(r.end);if(s||d){e.push({op:"getSpanText",span:d?{start:r.start,end:r.end}:o,projection:"model"});return}if(eo(o)&&o.kind==="paragraph"){e.push({op:"getText",target:o,projection:"model"});return}Object.values(r).forEach(t);};for(let o of n){if(!isAutomationCommand(o)||o.op==="setChangeTrackingMode")continue;let r=o.key;typeof r=="string"&&e.push({op:"getReviewItemRange",key:r}),t(o);}return e}var cn=new Set(["getRevisionDate","getCommentDate","getCommentId","getParagraphId"]),O=class extends Error{};function kt(n,e,t,o){let r=new wt(t,o),i=false;try{for(let s of n){if(!s.response.ok)continue;if(r.revision(s.before,e.revision()),s.guards){let l=e.execute(r.translate(s.guards.request));if(l===null||l.ok!==s.guards.response.ok)throw new O;if(l.results.length!==s.guards.response.results.length)throw new O;s.guards.response.results.forEach((p,b)=>r.agree(p,l.results[b],false));}let d=e.execute(r.translate(s.request));if(d===null)throw new O;if(!d.ok){let l=d.results.find(p=>p.status==="error");throw l?.status==="error"?ge(l.error,{target:"preview"}):new f({code:"GeneralException",target:"preview"})}if(d.changed&&(i=true),d.results.length!==s.response.results.length)throw new O;s.request.operations.forEach((l,p)=>r.agree(s.response.results[p],d.results[p],cn.has(l.op))),r.revision(s.response.revision,d.revision);}}catch(s){if(s instanceof f)return {ok:false,refusal:s,wrote:i};if(s instanceof O)return {ok:false,refusal:null,wrote:i};throw s}return {ok:true}}function W(n){let e=n;return typeof e.offset=="number"&&typeof e.paragraph=="object"&&e.paragraph!==null&&typeof e.paragraph.ref=="string"}var to=n=>`${n.paragraph.ref}\0${n.offset}\0${n.readAt??""}`,wt=class{#e=new Map;#t=new Map;#o=new Map;#r=new Map;constructor(e,t){this.#o.set(e,t);}revision(e,t){let o=this.#o.get(e);if(o!==void 0&&o!==t)throw new O;this.#o.set(e,t);}translate(e){if(Array.isArray(e))return e.map(r=>this.translate(r));if(e===null||typeof e!="object")return e;let t=W(e)?this.#n(e):void 0,o={};for(let[r,i]of Object.entries(e))if(r==="ref"&&typeof i=="string"){let s=this.#e.get(i);if(s===void 0)throw new O;o[r]=s;}else if((r==="readAt"||r==="expectedRevision")&&typeof i=="number"){let s=this.#o.get(i);if(s===void 0)throw new O;o[r]=s;}else r==="offset"&&t!==void 0?o[r]=t:o[r]=this.translate(i);return o}agree(e,t,o){if(Array.isArray(e)){if(!Array.isArray(t)||t.length!==e.length)throw new O;e.forEach((s,d)=>this.agree(s,t[d],o));return}if(e===null||typeof e!="object"){if(!o&&e!==t)throw new O;return}if(t===null||typeof t!="object"||Array.isArray(t))throw new O;let r=t,i=W(e);if(i){if(!W(r))throw new O;this.#d(e,r.offset);}this.#i(e,r);for(let[s,d]of Object.entries(e))if(s==="ref"&&typeof d=="string"){let l=r[s];if(typeof l!="string")throw new O;this.#s(d,l);}else {if(s==="readAt"||s==="date"||s==="offset"&&i)continue;this.agree(d,r[s],o);}}#i(e,t){let[o,r,i,s]=[e.start,e.end,t.start,t.end];if(!(typeof o!="object"||o===null||!W(o))&&!(typeof r!="object"||r===null||!W(r))&&o.paragraph.ref===r.paragraph.ref&&!(typeof i!="object"||i===null||!W(i))&&!(typeof s!="object"||s===null||!W(s))&&s.offset-i.offset!==r.offset-o.offset)throw new O}#s(e,t){let o=this.#e.get(e),r=this.#t.get(t);if(o!==void 0&&o!==t||r!==void 0&&r!==e)throw new O;this.#e.set(e,t),this.#t.set(t,e);}#d(e,t){let o=to(e),r=this.#r.get(o);if(r!==void 0&&r!==t)throw new O;this.#r.set(o,t);}#n(e){let t=this.#r.get(to(e));if(t!==void 0)return t;if(e.readAt!==void 0)throw new O;return e.offset}};var pn=new Set(["setChangeTrackingMode","insertText","replaceSpan","insertParagraph","splitParagraph","deleteParagraph","setFont","setParagraphFormat","setStyle","proposeInsertion","proposeDeletion","proposeReplacement","insertComment","replyToComment","setCommentResolved","deleteComment","acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions","resolveRevisionBatch","setRevisionAuthorBatch"]);function hn(n){return isAutomationCommand(n)?n.op==="insertBreak"?n.breakType==="Line":pn.has(n.op):true}function mn(n,e){return {...n,execute(t){let o=Array.isArray(t?.operations)?t.operations:[],r=o.findIndex(p=>!hn(p));if(r>=0)return {ok:false,results:o.map((p,b)=>b===r?{status:"error",error:{code:"unsupported-capability",message:"a preview cannot show this operation",detail:"preview-operation-unsupported"}}:{status:"skipped"}),revision:n.revision(),changed:false};let i=n.revision(),s=oo(o),d=s.length>0?{request:{operations:s},response:n.execute({operations:s})}:void 0,l=n.execute(t);return e.push({request:t,response:l,before:i,...d?{guards:d}:{}}),l}}}function no(n){switch(n){case "preview-active":return new f({code:"PreviewActive",diagnostic:"edit.preview-active"});case "no-document":return new f({code:"DocumentUnavailable"});case "viewing":return new f({code:"NotSupported",target:"preview",diagnostic:"edit.read-only"});case "blocked":return new f({code:"NotSupported",target:"preview",diagnostic:"edit.refresh-in-progress"});case "composing":return new f({code:"NotSupported",target:"preview",diagnostic:"edit.preview-composing"})}}async function ro(n,e){let t=n.port.begin();if(!t.ok)throw no(t.reason);let o=t.fork;try{let r=n.host.revision();io(n,o.host);let i=o.host.revision(),s=[],d=await n.runOn(mn(o.host,s),e);return o.ended&&a({code:"PreviewEnded",target:"preview"}),o.show()||a({code:"GeneralException",target:"preview"}),new St(n,o,s,r,i,d)}catch(r){throw o.end(),r}}function io(n,e){let o=n.host.execute({operations:[{op:"getChangeTrackingMode"}]}).results[0];o?.status!=="ok"||o.value.kind!=="text"||o.value.text!=="TrackMineOnly"||n.author===void 0||e.execute({operations:[{op:"setChangeTrackingMode",mode:"TrackMineOnly",author:n.author}]});}var St=class{constructor(e,t,o,r,i,s){this.runtime=e;this.fork=t;this.log=o;this.base=r;this.forkBase=i;this.result=s;this.#i=e.host.subscribe(d=>{this.#e==="active"&&d.revision!==r&&this.#c("stale");}),this.#s=t.onEnd(()=>this.#u()),e.host.revision()!==r&&this.#c("stale");}runtime;fork;log;base;forkBase;result;#e="active";#t=false;#o=[];#r=new Set;#i;#s;get status(){return this.#e}onStatusChanged(e){return this.#r.add(e),()=>this.#r.delete(e)}discard(){this.#u();}reveal(){return this.#e!=="ended"&&this.fork.reveal()}async commit(e={}){this.#e==="ended"&&a({code:"PreviewEnded",target:"preview"}),this.#t=true;try{let t=e?.rebase===true,o=this.runtime.host.revision(),r=o!==this.base;r&&this.#c("stale"),r&&!t&&a({code:"StaleDocument",target:"preview",expectedRevision:this.base,actualRevision:o}),this.fork.deferEvents(()=>{this.#u(),this.#d(o,r),this.#n(o,r);});}finally{this.#t=false;for(let t of this.#o.splice(0))t();}}#d(e,t){let o=this.runtime.port.begin();if(!o.ok)throw no(o.reason);let r=o.fork;try{io(this.runtime,r.host);let i=kt(this.log,{execute:s=>r.host.execute(s),revision:()=>r.host.revision()},this.forkBase,r.host.revision());i.ok||this.#a(i.refusal,e,t);}finally{r.end();}}#n(e,t){let{runtime:o}=this,r=o.port.beginHistoryGroup(),i=o.groupRun(r),s;try{s=kt(this.log,{execute:d=>i?i.execute(d):o.host.execute(d),revision:()=>o.host.revision()},this.forkBase,e);}finally{i?.finish(),r.end();}s.ok||(s.wrote&&!o.port.undo()&&a({code:"GeneralException",target:"preview.rollback"}),this.#a(s.refusal,e,t));}#a(e,t,o){if(e)throw e;a(o?{code:"StaleDocument",target:"preview",expectedRevision:this.base,actualRevision:t,diagnostic:"edit.preview-diverged"}:{code:"GeneralException",target:"preview",diagnostic:"edit.preview-diverged"});}#c(e){if(!(this.#e===e||this.#e==="ended")){this.#e=e;for(let t of [...this.#r]){let o=()=>{try{t(e);}catch{}};this.#t?this.#o.push(o):o();}}}#u(){this.#e!=="ended"&&(this.#i?.(),this.#s?.(),this.fork.end(),this.#c("ended"),this.#r.clear());}};function fn(n,e){let t=r=>r===void 0?[]:Array.isArray(r)?r:[r];if(typeof n=="function")return {callback:n,adopted:[],historyGroup:void 0};if(n instanceof M||Array.isArray(n))return {callback:e,adopted:t(n),historyGroup:void 0};(n===null||typeof n!="object")&&a({code:"InvalidArgument",target:"run"});let o=n;return {callback:e,adopted:t(o.previousObjects),historyGroup:o.historyGroup}}function bn(n,e){return {...n,execute(t){let o=e.execute(t);return o===null&&a({code:"InvalidArgument",target:"historyGroup"}),o}}}function rt(n){let e=n.host,t=Object.freeze({...e.capabilities,save:n.save&&e.capabilities.save,preview:n.preview!==void 0}),o=typeof n.author=="string"&&n.author.trim().length>0?n.author:void 0,r=n.revisionTextView??"allMarkup";r!=="allMarkup"&&r!=="original"&&a({code:"InvalidArgument",target:"revisionTextView"});let i=false,s=null,d=v=>{i&&a({code:"RuntimeDisposed",...v===void 0?{}:{target:v}});},l=()=>s||(d("document"),s=p(e),s),p=v=>{let g=de=>{try{return v.execute({operations:de})}catch(De){try{n.onException?.(De,de);}catch{}throw De}},m=so(g([{op:"getDocument"}]),"document"),B=so(g([{op:"getBody",document:m}]),"document.body");return {document:m,body:B}},b={host:e,capabilities:t,...o===void 0?{}:{author:o},revisionTextView:r,...n.onRefusal?{onRefusal:n.onRefusal}:{},...n.onException?{onException:n.onException}:{},id:{},roots:l,assertLive:d,openDocument:v=>je.open(v)},X=v=>{let g=n.preview;return g?{...v,execute(m){return g.active()&&m.operations.some(B=>isAutomationCommand(B))&&a({code:"PreviewActive",diagnostic:"edit.preview-active"}),v.execute(m)}}:v},I=n.preview?{...b,host:X(e)}:b,me=async(v,g)=>{let m=null,{context:B,finish:de}=fe.begin({...b,host:v,capabilities:Object.freeze({...v.capabilities,preview:false}),id:{},roots:()=>m??=p(v)});try{return await g(B)}finally{de();}},ae=new Set;async function Ee(v){d("preview"),typeof v!="function"&&a({code:"InvalidArgument",target:"preview"});let g=n.preview;g||a({code:"NotSupported",target:"preview"});let m=await ro({port:g,host:e,...o===void 0?{}:{author:o},groupRun:B=>n.historyGroups?.begin(B)??null,runOn:me},v);return ae.add(m),m.onStatusChanged(B=>{B==="ended"&&ae.delete(m);}),m}try{l();}catch{s=null;}async function it(v,g){d();let{callback:m,adopted:B,historyGroup:de}=fn(v,g);typeof m!="function"&&a({code:"InvalidArgument",target:"run"});let De=I,We=null;de!==void 0&&(n.historyGroups||a({code:"NotSupported",target:"historyGroup"}),We=n.historyGroups.begin(de),We===null&&a({code:"InvalidArgument",target:"historyGroup"}),De={...b,host:X(bn(e,We))});let{context:fo,adopt:bo,finish:yo}=fe.begin(De);try{return bo(B),await m(fo)}finally{yo(),We?.finish();}}let Te={capabilities:t,run:it,preview:Ee,dispose(){if(!i){i=true,s=null;for(let v of [...ae])v.discard();e.dispose();}}};return n.save?{...Te,async save(){d("save"),t.save||a({code:"NotSupported",target:"save"});let v=e.save();if(!v.ok)throw ge(v.error,{target:"save"});return v.bytes}}:Te}function so(n,e){let t=n.results[0];if(t?.status==="error")throw ge(t.error,{target:e});if(t?.status!=="ok")throw new f({code:"GeneralException",target:e});return y(t.value,e)}function ao(n,e={}){let t=createBrowserAutomationHost(n);return rt({host:t,save:false,onRefusal:(o,r)=>{let{code:i,tracked:s}=lt(o,t,r);reportAutomationRefusal(n,i,s,ze(o));},onException:(o,r)=>reportAutomationException(n,o,Qe(t,r)),historyGroups:{begin:o=>t.beginHistoryGroupRun(o)},preview:{begin:()=>beginEditorPreview(n),active:()=>editorPreviewActive(n),beginHistoryGroup:()=>n.beginHistoryGroup(),undo:()=>n.exec({type:"undo"}).ok},...e.author===void 0?{}:{author:e.author},...e.revisionTextView===void 0?{}:{revisionTextView:e.revisionTextView}})}function lo(n){return createAutomationPaginationProvider(n)}function wn(n){if(n){for(let e of n)if(e.collaboration)return e.collaboration}}function kn(n){let e=[n?.zip?.maxEntries,n?.zip?.maxTotalBytes,n?.xml?.maxBytes,n?.xml?.maxElements,n?.maxXmlParts,n?.maxRelationships],t=n?.zip?.maxRatio;(e.some(o=>o!==void 0&&(!Number.isInteger(o)||o<0))||t!==void 0&&(!Number.isFinite(t)||t<0))&&a({code:"InvalidArgument",target:"createServer"});}async function It(n,e={}){let t=Nt((e.modules??[]).flatMap(s=>s.onDiagnostic?[s.onDiagnostic]:[])),o=Date.now();try{kn(e.limits);}catch(s){throw t?.openRejected(n,"invalid-limits"),s}let r=wn(e.modules),i;try{i=createServerAutomationHost(n,{...e.pagination?{pagination:lo(e.pagination)}:{},...e.limits===void 0?{}:{limits:e.limits},...r===void 0?{}:{collaborationModel:r}});}catch(s){throw t?.openCrashed(n,s),s}if(!i.ok){let s={"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"},d=i.limit??s[i.reason];t?.openRejected(n,i.reason,i.limit,i.detail),a({code:d===void 0?"InvalidArgument":"ResourceLimitExceeded",target:"createServer",...d===void 0?{}:{limit:d},diagnostic:openDiagnosticCode(i.reason,i.limit)});}return t?.opened(n,Date.now()-o),rt({host:i.host,save:true,...e.author===void 0?{}:{author:e.author},...e.revisionTextView===void 0?{}:{revisionTextView:e.revisionTextView},...t?{onRefusal:(s,d)=>t.refused(s,i.host,d),onException:(s,d)=>t.crashed(s,i.host,d)}:{}})}function co(n,e,t={}){return It(n,{...t,modules:[...t.modules??[],{id:"collaboration",collaboration:{session:e}}]})}function uo(n,e,t,o){let r=typeof n=="object"&&n!==null?U(n):void 0;return r||a({code:"InvalidArgument",target:t}),(typeof e!="string"||e.length===0)&&a({code:"InvalidArgument",target:t}),o.some(i=>e.startsWith(i))&&a({code:"NotSupported",target:t}),r.assertUsable(t),r}function po(n,e,t){let o=t?"getReviewItemRangeOrNullObject":"getReviewItemRange",r=uo(n,e,o,["custom-"]),i=A.promised(n,o,t);return r.queue.push({sort:"read",label:o,plan:()=>({op:"getReviewItemRange",key:e}),settle:s=>{let[d]=Z(s,o);d?i.hydrateAddress({kind:"span",span:d}):t?i.hydrateNull():a({code:"ItemNotFound",target:o});}}),i}function ho(n,e){let t="getReviewItemRevisions",o=uo(n,e,t,["custom-","comment-"]);return q.ofReviewKey(n,t,u.of("document",o.roots().document),e)}function mo(n,e){return po(n,e,false)}function go(n,e){return po(n,e,true)}var Lt=(c=>(c.addin="Addin",c.addressBlock="AddressBlock",c.advance="Advance",c.ask="Ask",c.author="Author",c.autoText="AutoText",c.autoTextList="AutoTextList",c.barCode="BarCode",c.bibliography="Bibliography",c.bidiOutline="BidiOutline",c.citation="Citation",c.comments="Comments",c.compare="Compare",c.createDate="CreateDate",c.data="Data",c.database="Database",c.date="Date",c.displayBarcode="DisplayBarcode",c.docProperty="DocProperty",c.docVariable="DocVariable",c.editTime="EditTime",c.embedded="Embedded",c.empty="Empty",c.eq="EQ",c.expression="Expression",c.fileName="FileName",c.fileSize="FileSize",c.fillIn="FillIn",c.formCheckbox="FormCheckbox",c.formDropdown="FormDropdown",c.formText="FormText",c.gotoButton="GotoButton",c.greetingLine="GreetingLine",c.hyperlink="Hyperlink",c.if="If",c.import="Import",c.include="Include",c.includePicture="IncludePicture",c.includeText="IncludeText",c.index="Index",c.info="Info",c.keywords="Keywords",c.lastSavedBy="LastSavedBy",c.link="Link",c.listNum="ListNum",c.macroButton="MacroButton",c.mergeBarcode="MergeBarcode",c.mergeField="MergeField",c.mergeRec="MergeRec",c.mergeSeq="MergeSeq",c.next="Next",c.nextIf="NextIf",c.noteRef="NoteRef",c.numChars="NumChars",c.numPages="NumPages",c.numWords="NumWords",c.ocx="OCX",c.others="Others",c.page="Page",c.pageRef="PageRef",c.print="Print",c.printDate="PrintDate",c.private="Private",c.quote="Quote",c.rd="RD",c.ref="Ref",c.revNum="RevNum",c.saveDate="SaveDate",c.section="Section",c.sectionPages="SectionPages",c.seq="Seq",c.set="Set",c.shape="Shape",c.skipIf="SkipIf",c.styleRef="StyleRef",c.subject="Subject",c.subscriber="Subscriber",c.symbol="Symbol",c.ta="TA",c.tc="TC",c.template="Template",c.time="Time",c.title="Title",c.toa="TOA",c.toc="TOC",c.undefined="Undefined",c.userAddress="UserAddress",c.userInitials="UserInitials",c.userName="UserName",c.xe="XE",c))(Lt||{});var _a=Object.freeze({createBrowser:ao,createServer:It,createCollaborative:co});export{mt as Alignment,L as Body,ke as Bookmark,se as BookmarkCollection,yt as BreakType,ft as ChangeTrackingMode,M as ClientObject,Ze as ClientResult,re as Comment,ie as CommentCollection,he as CommentReply,Ve as CommentReplyCollection,z as ContentControl,Q as ContentControlCollection,xt as ContentControlType,je as Document,be as DocumentProperties,_a as DocxEditor,f as DocxEditorError,J as Field,_ as FieldCollection,Lt as FieldType,G as Font,ee as InlinePicture,te as InlinePictureCollection,ht as InsertLocation,$ as List,Rt as ListBullet,Ce as ListCollection,Pe as ListItem,Ct as ListNumbering,ve as NoteItem,F as NoteItemCollection,gt as PageOrientation,Ge as PageSetup,T as Paragraph,E as ParagraphCollection,A as Range,H as RangeCollection,vt as RemoveDocInfoType,fe as RequestContext,K as Revision,q as RevisionCollection,Ie as Section,Le as SectionCollection,xe as Shape,Y as ShapeCollection,_e as ShapeType,oe as Table,ue as TableCell,He as TableCellCollection,ne as TableCollection,Ae as TableRow,pe as TableRowCollection,Be as TrackedObjects,Pt as UnderlineType,bt as VerticalAlignment,mo as getReviewItemRange,go as getReviewItemRangeOrNullObject,ho as getReviewItemRevisions,Ue as isDocxEditorError};
|
package/dist/index.d.mts
CHANGED
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
* @public
|
|
59
59
|
*/
|
|
60
60
|
import { EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
|
|
61
|
-
import { C as CreateServerOptions, D as DocxEditorServerRuntime, a as CreateCollaborativeOptions } from './server-
|
|
62
|
-
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
|
|
63
|
-
export { RevisionAuthorEntry, RevisionAuthorResult, RevisionAuthorSkipReason, RevisionBatchEntry, RevisionBatchResult, RevisionBatchSkipReason } from '@docx-editor.dev/core/automation';
|
|
61
|
+
import { C as CreateServerOptions, D as DocxEditorServerRuntime, a as CreateCollaborativeOptions } from './server-Dw4k9h0p.mjs';
|
|
62
|
+
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 CommitPreviewOptions, p as ContentControl, q as ContentControlCollection, r as ContentControlLockState, s as ContentControlSubtype, t as ContentControlType, u as ContentControlValue, v as Document, w as DocumentCapabilities, x as DocumentLimits, y as DocumentPreview, z as DocumentPreviewStatus, E as DocumentProperties, F as DocumentXmlLimits, G as DocumentZipLimits, H as DocxEditorDebugInfo, I as DocxEditorError, J as DocxEditorErrorCode, K as DocxEditorErrorInit, L as DocxEditorInnerError, M as DocxEditorRuntime, N as EditorModule, O as Field, P as FieldCollection, Q as FieldType, R as FieldTypeLiteral, S as Font, T as HeaderFooterType, U as InlinePicture, V as InlinePictureCollection, W as InsertLocation, X as List, Y as ListBullet, Z as ListCollection, _ as ListItem, $ as ListNumbering, a0 as LoadOption, a1 as LoadQueryOptions, a2 as NoteItem, a3 as NoteItemCollection, a4 as NoteItemType, a5 as PageOrientation, a6 as PageSetup, a7 as Paragraph, a8 as ParagraphAlignment, a9 as ParagraphCollection, aa as ParagraphInsertTextLocation, ab as ParagraphReadingOrder, ac as PreviewCallback, ad as Range, ae as RangeCollection, af as RangeInsertTextLocation, ag as RemoveDocInfoType, ah as RequestContext, ai as Revision, aj as RevisionAuthorOptions, ak as RevisionAuthorSelection, al as RevisionCollection, am as RevisionTextView, an as RevisionType, ao as RunCallback, ap as RunOptions, aq as RuntimeDiagnostic, ar as SearchOptions, as as Section, at as SectionCollection, au as SelectionMode, av as ServerPaginationOptions, aw as Shape, ax as ShapeCollection, ay as ShapeType, az as Table, aA as TableCell, aB as TableCellCollection, aC as TableCollection, aD as TableRow, aE as TableRowCollection, aF as TrackedObjects, aG as UnderlineType, aH as VerticalAlignment, aI as getReviewItemRange, aJ as getReviewItemRangeOrNullObject, aK as getReviewItemRevisions, aL as isDocxEditorError } from './server-Dw4k9h0p.mjs';
|
|
63
|
+
export { HistoryGroup, HistoryGroupOutcome, RevisionAuthorEntry, RevisionAuthorResult, RevisionAuthorSkipReason, RevisionBatchEntry, RevisionBatchResult, RevisionBatchSkipReason } from '@docx-editor.dev/core/automation';
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Document automation for DOCX: a batching object model over the DocxEditor engine.
|