@docx-editor.dev/editor-api 2.19.1 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import {createServerAutomationHost,createAutomationPaginationProvider}from'@docx-editor.dev/core/automation';function de(o){return createAutomationPaginationProvider(o)}var le=Object.freeze({PropertyNotLoaded:"the property has not been loaded. Call load(...) and await context.sync() before reading it.",ValueNotLoaded:"the result has not been filled in yet. Await context.sync() before reading it.",InvalidObjectPath:"the object cannot be addressed. Await context.sync() after creating an object with an edit. Keep proxies within their run, or use context.trackedObjects.add(...) before the run ends.",ObjectInUse:"the object still belongs to a run that has not finished. Await that run before passing the object to another one.",InvalidArgument:"the argument is not one this API accepts.",ResourceLimitExceeded:"the document exceeds a supported resource limit.",ItemNotFound:"the collection has no such item.",NotSupported:"the operation or argument is outside this document or host\u2019s supported capabilities.",NotImplemented:"this version does not implement that yet.",ConflictingChanges:"these operations cannot share one atomic batch. Split them across separate context.sync() calls.",InvalidRequestContext:"the request context has finished. Start another run to continue.",RuntimeDisposed:"the runtime has been disposed.",StaleDocument:"the document changed after this context read it, so nothing was applied.",DocumentUnavailable:"the document is not available right now.",GeneralException:"the document could not complete the request."}),C=class extends Error{code;limit;target;expectedRevision;actualRevision;constructor(t){let e=t.target?`${le[t.code]} (${t.target})`:le[t.code];super(e),this.name="DocxEditorError",this.code=t.code,t.limit!==void 0&&(this.limit=t.limit),t.target!==void 0&&(this.target=t.target),t.expectedRevision!==void 0&&(this.expectedRevision=t.expectedRevision),t.actualRevision!==void 0&&(this.actualRevision=t.actualRevision);}};function Se(o){return o instanceof C?true:typeof o=="object"&&o!==null&&o.name==="DocxEditorError"&&typeof o.code=="string"}function a(o){throw new C(o)}var Y=Symbol("docx-editor.runtime.internals"),St=Symbol("docx-editor.runtime.release"),jt=Symbol("docx-editor.runtime.rebind");function J(o){return o[Y]}var je=new Set(["select","expand","top","skip"]),Te=/^[A-Za-z][A-Za-z0-9]*$/;function ce(o,t){if(o===void 0)return [];let e=typeof o=="string"?o.split(",").map(r=>r.trim()):Array.isArray(o)?o.map(r=>typeof r=="string"?r.trim():r):a({code:"InvalidArgument",target:t}),n=[];for(let r of e)(typeof r!="string"||!Te.test(r))&&a({code:"InvalidArgument",target:t}),n.includes(r)||n.push(r);return n.length===0&&a({code:"InvalidArgument",target:t}),n}function he(o,t){return (typeof o!="number"||!Number.isInteger(o)||o<0)&&a({code:"InvalidArgument",target:t}),o}function Ne(o,t){o===void 0||Array.isArray(o)&&o.length===0||a({code:"InvalidArgument",target:t});}function pe(o,t){if(o===void 0)return {select:[]};if(typeof o=="string"||Array.isArray(o))return {select:ce(o,t)};(typeof o!="object"||o===null)&&a({code:"InvalidArgument",target:t});let e=o;for(let n of Object.keys(e))je.has(n)||a({code:"InvalidArgument",target:`${t}.${n}`});return Ne(e.expand,`${t}.expand`),{select:ce(e.select,`${t}.select`),...e.top===void 0?{}:{top:he(e.top,`${t}.top`)},...e.skip===void 0?{}:{skip:he(e.skip,`${t}.skip`)}}}var B=class{#t;#n;#e;#o;#i=new Map;#s=false;constructor(t,e,n={}){this.#t=t,this.#n=t[Y],this.#e=e,this.#o=n.nullable===true,this.#n.register(this);}get context(){return this.#t}get isNullObject(){return this.#e.isReleased&&a({code:"InvalidObjectPath",target:this.#e.label}),this.#o?(this.#e.isPending&&a({code:"PropertyNotLoaded",target:`${this.#e.label}.isNullObject`}),this.#e.isNull):false}load(t){this.#s=true;try{return this.requireUsablePath(),this.onLoad(pe(t,this.#e.label)),this}finally{this.#s=false;}}get path(){return this.#e}get internals(){return this.#n}handle(){return this.#e.handle()}requireAddressable(){this.#e.isAddressable||a({code:"InvalidObjectPath",target:this.#e.label}),this.#n.assertUsable(this.#e.label);}requireUsablePath(){(this.#e.isReleased||this.#e.isNull&&!(this.#s&&this.#o))&&a({code:"InvalidObjectPath",target:this.#e.label}),this.#n.assertUsable(this.#e.label);}enqueue(t){this.requireUsablePath(),this.#n.queue.push({...t,dependencies:[...t.dependencies??[],this.#e],...this.#s&&this.#o&&t.sort==="read"?{nullableLoad:this.#e}:{}});}loadedProperty(t){return this.#e.isReleased&&!this.#i.has(t)&&a({code:"InvalidObjectPath",target:this.#e.label}),this.#i.has(t)||a({code:"PropertyNotLoaded",target:`${this.#e.label}.${t}`}),this.#i.get(t)}hasLoadedProperty(t){return this.#i.has(t)}setLoadedProperty(t,e){this.#i.set(t,e);}[St](){this.#e.release();}[jt](t){this.#t=t,this.#n=t[Y];}};var Ft=class o{#t=false;#n;#e;constructor(t){this.#e=t;}get value(){return this.#t||a({code:"ValueNotLoaded",target:this.#e}),this.#n}get isLoaded(){return this.#t}static create(t){let e=new o(t);return {result:e,fill(n){e.#t=true,e.#n=n;}}}};function S(o){return new C({code:"GeneralException",target:o})}function O(o,t){if(o.kind!=="text")throw S(t);return o.text}function u(o,t){if(o.kind!=="handle")throw S(t);return o.handle}function v(o,t){if(o.kind!=="handles")throw S(t);return o.handles}function P(o,t){if(o.kind!=="span")throw S(t);return o.span}function Tt(o,t){if(o.kind!=="spans")throw S(t);return o.spans}function Vt(o,t){if(o.kind!=="font")throw S(t);return o.font}function Wt(o,t){if(o.kind!=="paragraphFormat")throw S(t);return o.format}function xt(o,t){if(o.kind!=="style")throw S(t);return o.name}function Nt(o,t){if(o.kind!=="number")throw S(t);return o.value}function _(o,t){if(o.kind!=="flag")throw S(t);return o.value}function Ut(o,t){if(o.kind!=="pageSetup")throw S(t);return o.setup}function m(o,t){if(o.kind!=="applied")throw S(t)}var c=class o{label;#t;#n;constructor(t,e,n=null){this.label=t,this.#t=e,this.#n=n;}static of(t,e){return new o(t,{status:"resolved",address:{kind:"handle",handle:e}})}static ofSpan(t,e){return new o(t,{status:"resolved",address:{kind:"span",span:e}})}static pending(t){return new o(t,{status:"pending"})}static derived(t,e){return new o(t,{status:"pending"},e)}get state(){return this.#n?this.#n.state:this.#t}get isAddressable(){return this.state.status==="resolved"}get isPending(){return this.state.status==="pending"}get isNull(){return this.state.status==="null"}get isReleased(){return this.state.status==="released"}address(){let t=this.state;if(t.status==="resolved")return t.address;a({code:"InvalidObjectPath",target:this.label});}handle(){let t=this.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.label}),t.handle}span(){let t=this.address();return t.kind!=="span"&&a({code:"InvalidObjectPath",target:this.label}),t.span}resolveTo(t){this.#e({kind:"handle",handle:t});}resolveToSpan(t){this.#e({kind:"span",span:t});}resolveNull(){this.#t.status!=="released"&&(this.#t={status:"null"});}release(){this.#n||(this.#t={status:"released"});}#e(t){this.#t.status!=="released"&&(this.#t={status:"resolved",address:t});}};function ue(o){let t=[],e=false,n=false;for(let r of o)t.push(r.plan()),r.sort==="write"?n=true:e=true;return {operations:t,hasRead:e,hasWrite:n}}var Ee=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 Et(o,t={}){let e=Ee[o.code]??"GeneralException",n=e==="StaleDocument";return new C({code:e,...t.target===void 0?{}:{target:t.target},...n&&t.expectedRevision!==void 0?{expectedRevision:t.expectedRevision}:{},...n&&t.actualRevision!==void 0?{actualRevision:t.actualRevision}:{}})}function Gt(o,t,e){for(let n=0;n<o.results.length;n+=1){let r=o.results[n];if(r?.status!=="error")continue;let i=t[n]?.label;return Et(r.error,{...i===void 0?{}:{target:i},...e===void 0?{}:{expectedRevision:e},actualRevision:o.revision})}return new C({code:"GeneralException"})}function zt(o,t){if(t.results.length!==o.length)throw new C({code:"GeneralException"});for(let e=0;e<o.length;e+=1){let n=t.results[e],r=o[e];if(n.status!=="ok")throw new C({code:"GeneralException",target:r.label});r.settle(n.value);}}var qt=class{#t=[];get size(){return this.#t.length}get pending(){return this.#t}push(t){this.#t.push(t);}take(){let t=this.#t;this.#t=[];for(let e of t)e.capture?.();return t}clear(){for(let t of this.#t)t.dispose?.();this.#t=[];}};function me(o,t){if(Array.isArray(o)){for(let e of o)t(e);return}t(o);}var Ct=class{#t;#n;constructor(t,e){this.#t=t,this.#n=e;}add(t){this.#t.assertUsable(),me(t,e=>{this.#e(e),this.#t.track(e);});}remove(t){this.#t.assertUsable(),me(t,e=>{this.#e(e),this.#t.untrack(e);});}#e(t){this.#n(t)||a({code:"InvalidObjectPath"});}};var At=class o{#t;#n=new qt;#e=new Set;#o=new Set;#i;#s;#r;#a=false;#l=null;#c=false;constructor(t){this.#t=t,this.#i={host:t.host,capabilities:t.capabilities,...t.author===void 0?{}:{author:t.author},revisionTextView:t.revisionTextView,queue:this.#n,session:t.id,roots:()=>t.roots(),assertUsable:e=>{this.#t.assertLive(e),this.#a&&a({code:"InvalidRequestContext",...e===void 0?{}:{target:e}});},isFinished:()=>this.#a,readRevision:()=>this.#l,register:e=>{this.#e.add(e);},track:e=>{this.#o.add(e);},untrack:e=>{this.#o.delete(e);},isTracked:e=>this.#o.has(e),disown:e=>{this.#e.delete(e),this.#o.delete(e);}},this.#s=new Ct(this.#i,e=>this.#e.has(e));}get document(){return this.#i.assertUsable("document"),this.#r??=this.#t.openDocument(this),this.#r}get capabilities(){return this.#t.capabilities}get trackedObjects(){return this.#s}async sync(){this.#i.assertUsable(),this.#c&&a({code:"InvalidRequestContext"});let t=this.#n.take();if(t.length!==0){this.#c=true;try{let e=t.filter(s=>!s.nullableLoad?.isNull),n=t.some(s=>s.sort==="write"),r,i=s=>s.dependencies?.some(d=>!d.isAddressable)??false;for(;e.some(i);){r??=n&&this.#l!==null?this.#l:this.#t.host.revision();let s=e.filter(h=>h.sort==="read"&&!i(h));s.length===0&&a({code:"InvalidObjectPath",target:e.find(i)?.label}),await this.#d(s,r);let d=new Set(s);e=e.filter(h=>!d.has(h)&&!h.nullableLoad?.isNull);}if(e.length){let s=r??(n&&this.#l!==null?this.#l:void 0);await this.#d(e,s);}}finally{for(let e of t)e.dispose?.();this.#c=false;}}}async#d(t,e){let n=ue(t),r={operations:n.operations,...e===void 0?{}:{expectedRevision:e}};if(this.#t.host.prepare){let s={...r,expectedRevision:r.expectedRevision??this.#t.host.revision()};await this.#t.host.prepare(s);let d=this.#t.host.execute(s);if(!d.ok)throw Gt(d,t,s.expectedRevision);zt(t,d),this.#l=d.revision;return}let i=this.#t.host.execute(r);if(!i.ok)throw Gt(i,t,e);zt(t,i),(n.hasRead||n.hasWrite)&&(this.#l=i.revision);}get[Y](){return this.#i}static begin(t){let e=new o(t);return {context:e,adopt(n){for(let r of n)e.#h(r);},finish(){e.#u();}}}#h(t){let e=t.context;if(e===this)return;let n=e[Y];if(n.session!==this.#t.id)throw new C({code:"InvalidObjectPath"});if(!n.isFinished())throw new C({code:"ObjectInUse"});if(!n.isTracked(t))throw new C({code:"InvalidObjectPath"});let r=n.readRevision();n.disown(t),t[jt](this),this.#e.add(t),this.#o.add(t),r!==null&&this.#p(r);}#p(t){this.#l=this.#l===null?t:Math.min(this.#l,t);}#u(){if(!this.#a){this.#a=true,this.#n.clear();for(let t of this.#e)this.#o.has(t)||t[St]();this.#e.clear();}}};function vt(o,t,e){if(o.select.length===0)return t;for(let n of o.select)t.includes(n)||a({code:"InvalidArgument",target:`${e}.${n}`});return o.select}function R(o,t){let e=o.address();return t==="span"?(e.kind!=="span"&&a({code:"InvalidObjectPath",target:o.label}),{start:e.span.start,end:e.span.end}):(e.kind!=="handle"&&a({code:"InvalidObjectPath",target:o.label}),t==="body"?{body:e.handle}:{paragraph:e.handle})}function it(o,t){return (typeof o!="string"||o.trim().length===0||o.length>255)&&a({code:"InvalidArgument",target:t}),o}var p=class extends B{revisionTextView(){return J(this.context).revisionTextView}loadTextInto(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"read",label:n,plan:e,settle:r=>{this.setLoadedProperty(t,O(r,n));}});}command(t,e,n){let r=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:r,plan:e,settle:i=>m(i,r),...n?{capture:n,dispose:n}:{}});}commandDiscarding(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:n,plan:e,settle:()=>{}});}commandAnswering(t,e,n,r){this.enqueue({sort:"write",label:t,plan:e,settle:n,...r?{capture:r,dispose:r}:{}});}read(t,e,n){this.enqueue({sort:"read",label:t,plan:e,settle:n});}selection(t,e){return vt(t,e,this.path.label)}onLoad(t){this.selection(t,[]);}};var T=class extends B{#t;#n=[];constructor(t,e){super(t,e);}get items(){return this.loadedProperty("items")}fill(t,e){this.setLoadedProperty("items",this.#o(t,e,0,void 0)),this.#t={value:t,label:e};let n=this.#n.splice(0,this.#n.length);for(let r of n)this.#e(r,t);}onLoad(t){vt(t,["items"],this.path.label);let e=this.path.isPending?void 0:this.listing();if(e===null)return;let n=`${this.path.label}.items`,r=t.skip??0,i=t.top;this.enqueue({sort:"read",label:n,plan:()=>{let s=e??this.listing();return s||a({code:"InvalidObjectPath",target:this.path.label}),s},settle:s=>{this.setLoadedProperty("items",this.#o(s,n,r,i));}});}edge(t,e,n){let r=`${this.path.label}.${e}()`,i=this.promised(r,n),s=this.path.isPending?void 0:this.listing();if(s===null){let d={edge:t,target:r,nullable:n,item:i};return this.#t?this.#e(d,this.#t.value):this.#n.push(d),i}return this.enqueue({sort:"read",label:r,plan:()=>{let d=s??this.listing();return d||a({code:"InvalidObjectPath",target:this.path.label}),d},settle:d=>{this.#e({edge:t,target:r,nullable:n,item:i},d);}}),i}#e(t,e){let{edge:n,target:r,nullable:i,item:s}=t,d=this.size(e,r);if(d===0){i||a({code:"ItemNotFound",target:r}),s.hydrateNull();return}let h=this.addressAt(e,r,n==="first"?0:d-1);h||a({code:"ItemNotFound",target:r}),s.hydrateAddress(h);}#o(t,e,n,r){let i=this.size(t,e),s=r===void 0?i:Math.min(i,n+r),d=[];for(let h=n;h<s;h+=1){let A=this.addressAt(t,e,h);A&&d.push(this.itemAt(`${e}[${String(h)}]`,A));}return d}},x=class extends T{size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}};var H=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get code(){return this.loadedProperty("code")}set code(t){if(this.requireUsablePath(),(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:`${this.path.label}.code`}),this.#t){this.#t.code=t;return}let e={code:t};this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setFieldCode",field:this.#e(),code:e.code}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}delete(){this.#n("deleteField");}updateResult(){this.#n("updateFieldResult");}#n(t){this.requireUsablePath(),this.commandAnswering(this.path.label,()=>({op:t,field:this.#e()}),e=>m(e,this.path.label));}onLoad(t){this.selection(t,["code"]).length!==0&&this.read(this.path.label,()=>({op:"getField",field:this.#e()}),e=>{e.kind!=="field"&&a({code:"GeneralException",target:this.path.label}),this.setLoadedProperty("code",e.field.code);});}#e(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},M=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getFields",span:R(this.path,this.#t)}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return H.at(this.context,t,e)}promised(t,e){return H.promised(this.context,t,e)}};var qe=["width","height","lockAspectRatio","altTextDescription"],F=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get width(){return this.loadedProperty("width")}set width(t){this.#n("width",t);}get height(){return this.loadedProperty("height")}set height(t){this.#n("height",t);}get lockAspectRatio(){return this.loadedProperty("lockAspectRatio")}set lockAspectRatio(t){typeof t!="boolean"&&a({code:"InvalidArgument",target:`${this.path.label}.lockAspectRatio`}),this.#e({lockAspectRatio:t});}get altTextDescription(){return this.loadedProperty("altTextDescription")}set altTextDescription(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.altTextDescription`}),this.#e({altTextDescription:t});}delete(){let t=`${this.path.label}.delete`;this.commandAnswering(t,()=>({op:"deleteInlinePicture",picture:this.#o()}),e=>m(e,t));}onLoad(t){let e=this.selection(t,qe);e.length&&this.read(this.path.label,()=>({op:"getInlinePicture",picture:this.#o()}),n=>{n.kind!=="inlinePicture"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.picture[r]);});}#n(t,e){(typeof e!="number"||!Number.isFinite(e)||e<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#e({[t]:e});}#e(t){if(this.requireUsablePath(),this.#t){Object.assign(this.#t,t);return}let e=t;this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setInlinePicture",picture:this.#o(),properties:e}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}#o(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},V=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getInlinePictures",span:R(this.path,this.#t)}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return F.at(this.context,t,e)}promised(t,e){return F.promised(this.context,t,e)}};function q(o,t,e=0){return (!Number.isInteger(o)||o<e)&&a({code:"InvalidArgument",target:t}),o}function Qt(o,t){return (!Array.isArray(o)||o.some(e=>!Array.isArray(e)||e.some(n=>typeof n!="string")))&&a({code:"InvalidArgument",target:t}),o.map(e=>[...e])}function ge(o,t){return o!=="Start"&&o!=="End"&&a({code:"InvalidArgument",target:t}),o==="Start"?"start":"end"}var W=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get values(){return this.loadedProperty("values")}set values(t){let e=Qt(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??=st.of(this.context,`${this.path.label}.rows`,this.path,()=>({op:"getTableRows",table:this.path.handle()}))}getCell(t,e){let n=`${this.path.label}.getCell`;q(t,n),q(e,n);let r=tt.promised(this.context,n);return this.read(n,()=>({op:"getTableCell",table:this.path.handle(),rowIndex:t,cellIndex:e}),i=>r.hydrateAddress({kind:"handle",handle:u(i,n)})),r}addRows(t,e,n){let r=`${this.path.label}.addRows`,i=ge(t,r);q(e,r,1);let s=n===void 0?void 0:Qt(n,r),d=st.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addRows",location:i,count:e,...s?{values:s}:{}}}),h=>d.fill(h,r)),d}addColumns(t,e,n){let r=`${this.path.label}.addColumns`,i=ge(t,r);q(e,r,1);let s=n===void 0?void 0:Qt(n,r);this.command("addColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addColumns",location:i,count:e,...s?{values:s}:{}}}));}deleteRows(t,e){e===void 0&&(e=1),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()}),n=>{n.kind!=="table"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.table[r]);});}},at=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get cells(){return this.#t??=Pt.of(this.context,`${this.path.label}.cells`,this.path,()=>({op:"getTableCells",row:this.path.handle()}))}},tt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=I.promisedStory(this.context,t);return this.read(t,()=>({op:"getTableCellBody",cell:this.path.handle()}),n=>e.hydrateAddress({kind:"handle",handle:u(n,t)})),this.#t=e,e}get value(){return this.loadedProperty("value")}set value(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.value`}),this.command("value",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{value:t}}));}get columnWidth(){return this.loadedProperty("columnWidth")}set columnWidth(t){(typeof t!="number"||!Number.isFinite(t)||t<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.columnWidth`}),this.command("columnWidth",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{columnWidth:t}}));}get shadingColor(){return this.loadedProperty("shadingColor")}set shadingColor(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.shadingColor`}),this.command("shadingColor",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{shadingColor:t}}));}get verticalAlignment(){return this.loadedProperty("verticalAlignment")}set verticalAlignment(t){t!=="Top"&&t!=="Center"&&t!=="Bottom"&&a({code:"InvalidArgument",target:`${this.path.label}.verticalAlignment`}),this.command("verticalAlignment",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{verticalAlignment:t}}));}onLoad(t){let e=this.selection(t,["value","columnWidth","shadingColor","verticalAlignment"]);this.read(this.path.label,()=>({op:"getTableCellProperties",cell:this.path.handle()}),n=>{n.kind!=="tableCell"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.cell[r]);});}},U=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}static over(t,e,n,r){return o.of(t,e,n,()=>({op:"getTables",scope:r()}))}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return W.at(this.context,t,e)}promised(t,e){return W.promised(this.context,t,e)}},st=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return at.at(this.context,t,e)}promised(t,e){return at.promised(this.context,t,e)}},Pt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return tt.at(this.context,t,e)}promised(t,e){return tt.promised(this.context,t,e)}};var Xt=(i=>(i.replace="Replace",i.start="Start",i.end="End",i.before="Before",i.after="After",i))(Xt||{}),Kt=(s=>(s.mixed="Mixed",s.unknown="Unknown",s.left="Left",s.centered="Centered",s.right="Right",s.justified="Justified",s))(Kt||{}),Zt=(e=>(e.portrait="Portrait",e.landscape="Landscape",e))(Zt||{}),Yt=(n=>(n.off="Off",n.trackAll="TrackAll",n.trackMineOnly="TrackMineOnly",n))(Yt||{}),Jt=(r=>(r.mixed="Mixed",r.top="Top",r.center="Center",r.bottom="Bottom",r))(Jt||{}),_t=(d=>(d.line="Line",d.page="Page",d.next="Next",d.sectionNext="SectionNext",d.sectionContinuous="SectionContinuous",d.sectionEven="SectionEven",d.sectionOdd="SectionOdd",d))(_t||{}),te=(y=>(y.unknown="Unknown",y.richText="RichText",y.plainText="PlainText",y.picture="Picture",y.buildingBlockGallery="BuildingBlockGallery",y.checkBox="CheckBox",y.comboBox="ComboBox",y.datePicker="DatePicker",y.dropDownList="DropDownList",y.group="Group",y.repeatingSection="RepeatingSection",y.plainTextInline="PlainTextInline",y.plainTextParagraph="PlainTextParagraph",y.richTextInline="RichTextInline",y.richTextParagraphs="RichTextParagraphs",y.richTextTable="RichTextTable",y.richTextTableCell="RichTextTableCell",y.richTextTableRow="RichTextTableRow",y))(te||{});var De=["Replace","Start","End"],$e=["Start","End"],Be=["Replace","Start","End"],He=["Before","After"],Me=["Replace","Start","End","Before","After"],Fe=["Select","Start","End"];function dt(o,t,e){return (typeof o!="string"||!t.includes(o))&&a({code:"InvalidArgument",target:e}),o}var fe=(o,t)=>dt(o,De,t),be=(o,t)=>dt(o,$e,t),ye=(o,t)=>dt(o,Be,t),xe=(o,t)=>dt(o,He,t),Ot=(o,t)=>dt(o,Me,t),Dt=(o,t)=>o===void 0?"Select":dt(o,Fe,t);function k(o,t){return typeof o!="string"&&a({code:"InvalidArgument",target:t}),/[\r\n\v\f\u2028\u2029]/.test(o)&&a({code:"InvalidArgument",target:t}),o}var Ve=8,ne=(d=>(d.custom="Custom",d.solid="Solid",d.hollow="Hollow",d.square="Square",d.diamonds="Diamonds",d.arrow="Arrow",d.checkmark="Checkmark",d))(ne||{}),oe=(s=>(s.none="None",s.arabic="Arabic",s.upperRoman="UpperRoman",s.lowerRoman="LowerRoman",s.upperLetter="UpperLetter",s.lowerLetter="LowerLetter",s))(oe||{}),j=class o extends p{#t;#n=new Map;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get paragraphs(){return this.#t??=L.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getListParagraphs",list:this.#o()})),this.#t}getLevelParagraphs(t){let e=`${this.path.label}.getLevelParagraphs`,n=ee(t,e);return L.overListing(this.context,e,this.path,()=>({op:"getListParagraphs",list:this.#o(),level:n}))}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n);e!=="Start"&&e!=="End"&&e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:n});let i=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertListParagraph",list:this.#o(),where:e==="Start"||e==="Before"?"start":"end",text:r}),s=>{i.hydrateAddress({kind:"handle",handle:u(s,n)});}),i}setLevelBullet(t,e,n,r){this.#e(t,{bullet:e,...n===void 0?{}:{charCode:n},...r===void 0?{}:{fontName:r}});}setLevelNumbering(t,e,n){this.#e(t,{numbering:e,...n===void 0?{}:{formatString:[...n]}});}setLevelStartingNumber(t,e){this.#e(t,{startingNumber:e});}setLevelIndents(t,e,n){this.#e(t,{textIndent:e,bulletNumberPictureIndent:n});}#e(t,e){let n=`${this.path.label}.levelFormat`,r=ee(t,n);this.requireUsablePath();let i=this.#n.get(r);if(i){Object.assign(i,e),"bullet"in e&&(delete i.numbering,delete i.formatString),"numbering"in e&&(delete i.bullet,delete i.charCode,delete i.fontName);return}let s={...e};this.#n.set(r,s),this.commandAnswering(n,()=>({op:"setListLevelFormat",list:this.#o(),level:r,format:s}),d=>{m(d,n);},()=>{this.#n.get(r)===s&&this.#n.delete(r);});}onLoad(t){if(!this.selection(t,["id"]).includes("id"))return;let e=`${this.path.label}.id`;this.read(e,()=>({op:"getListId",list:this.#o()}),n=>{this.setLoadedProperty("id",Nt(n,e));});}#o(){return this.requireAddressable(),this.path.handle()}},lt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getById(t){let e=`${this.path.label}.getById`,n=We(t,e),r=this.#t,i=j.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getListById",body:r,id:n}),settle:s=>{i.hydrateAddress({kind:"handle",handle:u(s,e)});}}),i}listing(){return {op:"getLists",body:this.#t}}itemAt(t,e){return j.at(this.context,t,e)}promised(t,e){return j.promised(this.context,t,e)}},ct=class o extends p{static of(t,e,n){return new o(t,c.derived(e,n))}constructor(t,e){super(t,e);}get level(){return this.loadedProperty("level")}set level(t){let e=`${this.path.label}.level`,n=ee(t,e);this.commandAnswering(e,()=>({op:"setListLevel",paragraph:this.#t(),level:n}),r=>{m(r,e);});}onLoad(t){if(!this.selection(t,["level"]).includes("level"))return;let e=`${this.path.label}.level`;this.read(e,()=>({op:"getListLevel",paragraph:this.#t()}),n=>{this.setLoadedProperty("level",Nt(n,e));});}#t(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}};function ee(o,t){return (!Number.isInteger(o)||o<0||o>Ve)&&a({code:"InvalidArgument",target:t}),o}function We(o,t){return (!Number.isInteger(o)||o<=0)&&a({code:"InvalidArgument",target:t}),o}var re=(f=>(f.mixed="Mixed",f.none="None",f.hidden="Hidden",f.dotLine="DotLine",f.single="Single",f.word="Word",f.double="Double",f.thick="Thick",f.dotted="Dotted",f.dottedHeavy="DottedHeavy",f.dashLine="DashLine",f.dashLineHeavy="DashLineHeavy",f.dashLineLong="DashLineLong",f.dashLineLongHeavy="DashLineLongHeavy",f.dotDashLine="DotDashLine",f.dotDashLineHeavy="DotDashLineHeavy",f.twoDotDashLine="TwoDotDashLine",f.twoDotDashLineHeavy="TwoDotDashLineHeavy",f.wave="Wave",f.waveHeavy="WaveHeavy",f.waveDouble="WaveDouble",f))(re||{}),Ue=["bold","italic","color","name","size","underline","strikeThrough","highlightColor","subscript","superscript"],N=class o extends p{#t;#n;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}get bold(){return this.loadedProperty("bold")}set bold(t){this.#e("bold",Rt(t,`${this.path.label}.bold`));}get italic(){return this.loadedProperty("italic")}set italic(t){this.#e("italic",Rt(t,`${this.path.label}.italic`));}get color(){return this.loadedProperty("color")}set color(t){this.#e("color",$t(t,`${this.path.label}.color`));}get name(){return this.loadedProperty("name")}set name(t){this.#e("name",$t(t,`${this.path.label}.name`));}get size(){return this.loadedProperty("size")}set size(t){this.#e("size",Ge(t,`${this.path.label}.size`));}get underline(){return this.loadedProperty("underline")}set underline(t){this.#e("underline",$t(t,`${this.path.label}.underline`));}get highlightColor(){return this.loadedProperty("highlightColor")}set highlightColor(t){this.#e("highlightColor",t===null?null:$t(t,`${this.path.label}.highlightColor`));}get strikeThrough(){return this.loadedProperty("strikeThrough")}set strikeThrough(t){this.#e("strikeThrough",Rt(t,`${this.path.label}.strikeThrough`));}get subscript(){return this.loadedProperty("subscript")}set subscript(t){this.#e("subscript",Rt(t,`${this.path.label}.subscript`));}get superscript(){return this.loadedProperty("superscript")}set superscript(t){this.#e("superscript",Rt(t,`${this.path.label}.superscript`));}onLoad(t){let e=this.selection(t,Ue);if(e.length===0)return;let n=`${this.path.label}.font`;this.read(n,()=>({op:"getFont",span:this.#o()}),r=>{let i=Vt(r,n);for(let s of e)this.setLoadedProperty(s,i[s]);});}#e(t,e){if(this.requireUsablePath(),this.#n){this.#n[t]=e,t==="subscript"&&e===true&&(this.#n.superscript=false),t==="superscript"&&e===true&&(this.#n.subscript=false);return}let n={[t]:e};t==="subscript"&&e===true&&(n.superscript=false),t==="superscript"&&e===true&&(n.subscript=false),this.#n=n;let r=`${this.path.label}.${t}`;this.commandAnswering(this.path.label,()=>({op:"setFont",span:this.#o(),font:n}),i=>{m(i,r);},()=>{this.#n===n&&(this.#n=void 0);});}#o(){return this.requireAddressable(),R(this.path,this.#t)}};function Rt(o,t){return typeof o!="boolean"&&a({code:"InvalidArgument",target:t}),o}function Ge(o,t){return (typeof o!="number"||!Number.isFinite(o))&&a({code:"InvalidArgument",target:t}),o}function $t(o,t){return (typeof o!="string"||o.length===0)&&a({code:"InvalidArgument",target:t}),o}var ze=16,w=class o extends p{#t;#n;#e;#o;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get uniqueLocalId(){return this.loadedProperty("uniqueLocalId")}get style(){return this.loadedProperty("style")}set style(t){this.#i("style",it(t,`${this.path.label}.style`));}get font(){return this.#t??=N.of(this.context,`${this.path.label}.font`,this.path,"paragraph"),this.#t}get alignment(){return this.loadedProperty("alignment")}set alignment(t){this.#i("alignment",Xe(t,`${this.path.label}.alignment`));}get firstLineIndent(){return this.loadedProperty("firstLineIndent")}set firstLineIndent(t){this.#i("firstLineIndent",ht(t,`${this.path.label}.firstLineIndent`));}get leftIndent(){return this.loadedProperty("leftIndent")}set leftIndent(t){this.#i("leftIndent",ht(t,`${this.path.label}.leftIndent`));}get rightIndent(){return this.loadedProperty("rightIndent")}set rightIndent(t){this.#i("rightIndent",ht(t,`${this.path.label}.rightIndent`));}get lineSpacing(){return this.loadedProperty("lineSpacing")}set lineSpacing(t){this.#i("lineSpacing",ht(t,`${this.path.label}.lineSpacing`));}get spaceBefore(){return this.loadedProperty("spaceBefore")}set spaceBefore(t){this.#i("spaceBefore",ht(t,`${this.path.label}.spaceBefore`));}get spaceAfter(){return this.loadedProperty("spaceAfter")}set spaceAfter(t){this.#i("spaceAfter",ht(t,`${this.path.label}.spaceAfter`));}get list(){return this.#n??=this.#s(`${this.path.label}.list`),this.#n}getRange(t="Whole"){let e=`${this.path.label}.getRange`;["Whole","Content","Start","End","Before","After"].includes(t)||a({code:"InvalidArgument",target:e});let n=b.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{paragraph:this.#r()},location:t}),r=>{n.hydrateAddress({kind:"span",span:P(r,e)});}),n}startNewList(){let t=`${this.path.label}.startNewList`,e=j.promised(this.context,t,false);return this.commandAnswering(t,()=>({op:"startNewList",paragraph:this.#r()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),e}attachToList(t,e){let n=`${this.path.label}.attachToList`;(!Number.isSafeInteger(t)||t<=0||!Number.isInteger(e)||e<0||e>8)&&a({code:"InvalidArgument",target:n});let r=j.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"attachToList",paragraph:this.#r(),listId:t,level:e}),i=>{r.hydrateAddress({kind:"handle",handle:u(i,n)});}),r}detachFromList(){let t=`${this.path.label}.detachFromList`;this.commandAnswering(t,()=>({op:"detachFromList",paragraph:this.#r()}),e=>{m(e,t);});}get listItem(){return this.#e??=ct.of(this.context,`${this.path.label}.listItem`,this.path),this.#e}clear(){this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{paragraph:this.#r()},text:""}));}delete(){this.command("delete",()=>({op:"deleteParagraph",paragraph:this.#r()}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=ye(e,n),s=b.promised(this.context,n,false);return this.commandAnswering(n,()=>i==="Replace"?{op:"replaceSpan",span:{paragraph:this.#r()},text:r}:{op:"insertText",at:{paragraph:this.#r(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:P(d,n)});}),s}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n),i=xe(e,n),s=o.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:this.#r()},where:i==="Before"?"before":"after",text:r}),d=>{d.kind!=="handle"&&a({code:"GeneralException",target:n}),s.hydrateAddress({kind:"handle",handle:d.handle});}),s}split(t,e,n){let r=`${this.path.label}.split`,i=Ke(t,r),s=Ae(e,`${r}.trimDelimiters`),d=Ae(n,`${r}.trimSpacing`),h=E.answered(this.context,r,this.path);return this.commandAnswering(r,()=>({op:"splitParagraph",paragraph:this.#r(),delimiters:i,...s?{trimDelimiters:true}:{},...d?{trimSpacing:true}:{}}),A=>{h.fill(A,r);}),h}onLoad(t){let e=this.selection(t,["text","uniqueLocalId",...Ce]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#r(),projection:this.revisionTextView()})),e.includes("uniqueLocalId")&&this.loadTextInto("uniqueLocalId",()=>({op:"getParagraphId",paragraph:this.#r()}));let n=Ce.filter(i=>e.includes(i));if(n.length===0)return;let r=`${this.path.label}.paragraphFormat`;this.read(r,()=>({op:"getParagraphFormat",paragraph:{paragraph:this.#r()}}),i=>{let s=Wt(i,r);for(let d of n)this.setLoadedProperty(d,s[d]);});}#i(t,e){if(this.requireUsablePath(),this.#o){this.#o[t]=e;return}let n={[t]:e};this.#o=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.paragraphFormat`,()=>({op:"setParagraphFormat",paragraph:{paragraph:this.#r()},format:n}),i=>{m(i,r);},()=>{this.#o===n&&(this.#o=void 0);});}#s(t){let e=j.promised(this.context,t,false);return this.read(t,()=>({op:"getParagraphList",paragraph:this.#r()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),e}#r(){return this.requireAddressable(),this.path.handle()}},Ce=["style","alignment","firstLineIndent","leftIndent","rightIndent","lineSpacing","spaceBefore","spaceAfter"],Qe=["Left","Centered","Right","Justified"];function Xe(o,t){return Qe.includes(o)||a({code:"InvalidArgument",target:t}),o}function ht(o,t){return (typeof o!="number"||!Number.isFinite(o))&&a({code:"InvalidArgument",target:t}),o}function Ke(o,t){(!Array.isArray(o)||o.length===0||o.length>ze)&&a({code:"InvalidArgument",target:t});for(let e of o)(typeof e!="string"||e.length===0)&&a({code:"InvalidArgument",target:t});return [...o]}function Ae(o,t){return o!==void 0&&typeof o!="boolean"&&a({code:"InvalidArgument",target:t}),o===true}var L=class o extends T{#t;static of(t,e,n){return new o(t,c.derived(e,n),null)}static overListing(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){if(this.#t)return this.#t();let t=this.path.address();return t.kind==="handle"?{op:"getParagraphs",body:t.handle}:{op:"getSpanParagraphs",span:t.span}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return w.at(this.context,t,e)}promised(t,e){return w.promised(this.context,t,e)}},E=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}static answered(t,e,n){return new o(t,c.derived(e,n),null)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t?this.#t():null}size(t,e){return Tt(t,e).length}addressAt(t,e,n){let r=Tt(t,e)[n];return r?{kind:"span",span:r}:void 0}itemAt(t,e){return b.at(this.context,t,e)}promised(t,e){return b.promised(this.context,t,e)}};var Pe=4096,D=class o extends p{#t;#n=new Map;#e;#o;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get tag(){return this.loadedProperty("tag")}set tag(t){this.#s("tag",{tag:ie(t,`${this.path.label}.tag`)});}get title(){return this.loadedProperty("title")}set title(t){this.#s("title",{title:ie(t,`${this.path.label}.title`)});}get subtype(){return this.loadedProperty("subtype")}get isBound(){return this.loadedProperty("isBound")}get cannotDelete(){let t=this.loadedProperty("lock");return t==="sdtLocked"||t==="sdtContentLocked"}set cannotDelete(t){this.#r("cannotDelete",t);}get cannotEdit(){let t=this.loadedProperty("lock");return t==="contentLocked"||t==="sdtContentLocked"}set cannotEdit(t){this.#r("cannotEdit",t);}get placeholderShown(){return this.loadedProperty("placeholderShown")}get temporary(){return this.loadedProperty("temporary")}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#e??=L.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getContentControlParagraphs",contentControl:this.#a()})),this.#e}get contentControls(){return this.#o??=$.of(this.context,`${this.path.label}.contentControls`,this.path,{contentControl:this.#a()}),this.#o}getRange(t){let e=`${this.path.label}.getRange`,n=Ze(t??"Whole",e),r=this.#n.get(n);if(r)return r;let i=this.#i(e,n);return this.#n.set(n,i),i}setValue(t){let e=`${this.path.label}.setValue`,n=Ye(t,e);this.command("setValue",()=>({op:"setContentControlValue",contentControl:this.#a(),value:n}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=e==="Replace"?"replace":e==="Start"?"start":e==="End"?"end":a({code:"InvalidArgument",target:n}),s=b.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertContentControlText",contentControl:this.#a(),text:r,at:i}),d=>{s.hydrateAddress({kind:"span",span:P(d,n)});}),s}delete(t){let e=`${this.path.label}.delete`;typeof t!="boolean"&&a({code:"InvalidArgument",target:e}),this.command("delete",()=>({op:"deleteContentControl",contentControl:this.#a(),keepContent:t}));}onLoad(t){let e=this.selection(t,["id","tag","title","subtype","isBound","text","cannotDelete","cannotEdit","placeholderShown","temporary"]);if(e.includes("id")&&this.loadTextInto("id",()=>({op:"getContentControlFileId",contentControl:this.#a()})),e.includes("tag")&&this.loadTextInto("tag",()=>({op:"getContentControlTag",contentControl:this.#a()})),e.includes("title")&&this.loadTextInto("title",()=>({op:"getContentControlTitle",contentControl:this.#a()})),e.includes("subtype")&&this.loadTextInto("subtype",()=>({op:"getContentControlSubtype",contentControl:this.#a()})),e.includes("isBound")){let r=`${this.path.label}.isBound`;this.read(r,()=>({op:"getContentControlIsBound",contentControl:this.#a()}),i=>{this.setLoadedProperty("isBound",_(i,r));});}if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getContentControlText",contentControl:this.#a(),projection:this.revisionTextView()})),e.includes("cannotDelete")||e.includes("cannotEdit")){let r=`${this.path.label}.lock`;this.read(r,()=>({op:"getContentControlLock",contentControl:this.#a()}),i=>{this.setLoadedProperty("lock",O(i,r));});}if(e.includes("placeholderShown")){let r=`${this.path.label}.placeholderShown`;this.read(r,()=>({op:"getContentControlPlaceholderShown",contentControl:this.#a()}),i=>{this.setLoadedProperty("placeholderShown",_(i,r));});}if(!e.includes("temporary"))return;let n=`${this.path.label}.temporary`;this.read(n,()=>({op:"getContentControlTemporary",contentControl:this.#a()}),r=>{this.setLoadedProperty("temporary",_(r,n));});}#i(t,e){let n=b.promised(this.context,t,false);return this.read(t,()=>({op:"getContentControlRange",contentControl:this.#a(),location:e}),r=>{n.hydrateAddress({kind:"span",span:P(r,t)});}),n}#s(t,e){this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#a(),...e}));}#r(t,e){let n=`${this.path.label}.${t}`;if(typeof e!="boolean"&&a({code:"InvalidArgument",target:n}),this.requireUsablePath(),this.#t){this.#t[t]=e;return}let r={[t]:e};this.#t=r,this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#a(),...r}),()=>{this.#t===r&&(this.#t=void 0);});}#a(){return this.requireAddressable(),this.path.handle()}},$=class o extends x{#t;#n;static of(t,e,n,r){return new o(t,c.derived(e,n),r,()=>({op:"getContentControls",scope:r}))}constructor(t,e,n,r){super(t,e),this.#t=n,this.#n=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getById(t){let e=`${this.path.label}.getById`;Number.isInteger(t)||a({code:"InvalidArgument",target:e});let n=this.#t,r=D.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getContentControlById",scope:n,id:t}),settle:i=>{r.hydrateAddress({kind:"handle",handle:u(i,e)});}}),r}getByTag(t){let e=`${this.path.label}.getByTag`,n=ve(t,e),r=this.#t;return new o(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTag",scope:r,tag:n}))}getByTitle(t){let e=`${this.path.label}.getByTitle`,n=ve(t,e),r=this.#t;return new o(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTitle",scope:r,title:n}))}listing(){return this.#n()}itemAt(t,e){return D.at(this.context,t,e)}promised(t,e){return D.promised(this.context,t,e)}};function ie(o,t){return (typeof o!="string"||o.length>Pe)&&a({code:"InvalidArgument",target:t}),o}function ve(o,t){let e=ie(o,t);return e.length===0&&a({code:"InvalidArgument",target:t}),e}function Ze(o,t){switch(o){case "Whole":return "whole";case "Content":return "content";case "Start":return "start";case "End":return "end";case "Before":return "before";case "After":return "after";default:return a({code:"InvalidArgument",target:t})}}function Ye(o,t){(typeof o!="object"||o===null)&&a({code:"InvalidArgument",target:t});let e=o;if(e.kind==="text"||e.kind==="listItem"){let n=e.kind==="text"?e.text:e.value;return (typeof n!="string"||n.length>Pe)&&a({code:"InvalidArgument",target:t}),e.kind==="text"?{kind:"text",text:n}:{kind:"listItem",value:n}}if(e.kind==="checkbox")return typeof e.checked!="boolean"&&a({code:"InvalidArgument",target:t}),{kind:"checkbox",checked:e.checked};if(e.kind==="date")return (typeof e.iso!="string"||e.iso.length>64)&&a({code:"InvalidArgument",target:t}),{kind:"date",iso:e.iso};a({code:"InvalidArgument",target:t});}function Je(o,t){return t<1||t>12?0:t===2?o%4===0&&o%100!==0||o%400===0?29:28:t===4||t===6||t===9||t===11?30:31}function Oe(o){if(o.length===0)return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/.exec(o.trim());if(!t)return null;let e=Number(t[1]),n=Number(t[2]),r=Number(t[3]),i=Je(e,n);if(e===0||i===0||r<1||r>i)return null;let s=Number(t[4]),d=Number(t[5]),h=Number(t[6]);if(s>23||d>59||h>59)return null;let A=t[7],K=A===void 0?0:Number(A.padEnd(3,"0").slice(0,3));if(Number.isNaN(K))return null;let ot=`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}.${String(K).padStart(3,"0")}Z`,Lt=Date.parse(ot);if(Number.isNaN(Lt))return null;let g=t[8];if(g==="Z")return new Date(Lt);let Z=Number(g.slice(1,3)),rt=Number(g.slice(4,6));if(rt>59||Z>14||Z===14&&rt!==0)return null;let Mt=g[0]==="+"?1:-1,wt=new Date(Lt-Mt*(Z*36e5+rt*6e4));return Number.isNaN(wt.getTime())?null:wt}var Bt=class extends p{hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get authorName(){return this.loadedProperty("authorName")}get creationDate(){return this.loadedProperty("creationDate")}get id(){return this.loadedProperty("id")}get text(){return this.loadedProperty("text")}delete(){this.command("delete",()=>({op:"deleteComment",comment:this.commentHandle()}));}loadCommentFields(t,e){let n=this.selection(t,["authorName","creationDate","id","text",...e]);if(n.includes("authorName")&&this.loadTextInto("authorName",()=>({op:"getCommentAuthor",comment:this.commentHandle()})),n.includes("text")&&this.loadTextInto("text",()=>({op:"getCommentText",comment:this.commentHandle()})),n.includes("id")&&this.loadTextInto("id",()=>({op:"getCommentId",comment:this.commentHandle()})),n.includes("creationDate")){let i=`${this.path.label}.creationDate`;this.read(i,()=>({op:"getCommentDate",comment:this.commentHandle()}),s=>{this.setLoadedProperty("creationDate",Oe(O(s,i)));});}if(!n.includes("resolved"))return;let r=`${this.path.label}.resolved`;this.read(r,()=>({op:"getCommentResolved",comment:this.commentHandle()}),i=>{this.setLoadedProperty("resolved",_(i,r));});}commentHandle(){return this.requireAddressable(),this.path.handle()}},et=class o extends Bt{static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}onLoad(t){this.loadCommentFields(t,[]);}},It=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return et.at(this.context,t,e)}promised(t,e){return et.promised(this.context,t,e)}},G=class o extends Bt{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}get resolved(){return this.loadedProperty("resolved")}set resolved(t){let e=`${this.path.label}.resolved`;typeof t!="boolean"&&a({code:"InvalidArgument",target:e}),this.commandAnswering(e,()=>({op:"setCommentResolved",comment:this.commentHandle(),resolved:t}),n=>{m(n,e);});}get replies(){return this.#t??=It.of(this.context,`${this.path.label}.replies`,this.path,()=>({op:"getCommentReplies",comment:this.commentHandle()})),this.#t}getRange(){let t=`${this.path.label}.getRange`,e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getCommentRange",comment:this.commentHandle()}),n=>{e.hydrateAddress({kind:"span",span:P(n,t)});}),e}reply(t){let e=`${this.path.label}.reply`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&a({code:"NotSupported",target:e});let r=et.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"replyToComment",comment:this.commentHandle(),text:t,author:n}),i=>{r.hydrateAddress({kind:"handle",handle:u(i,e)});}),r}onLoad(t){this.loadCommentFields(t,["resolved"]);}},z=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return G.at(this.context,t,e)}promised(t,e){return G.promised(this.context,t,e)}},pt=class o extends p{static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get author(){return this.loadedProperty("author")}get date(){return this.loadedProperty("date")}get type(){return this.loadedProperty("type")}get range(){let t=`${this.path.label}.range`,e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getRevisionRange",revision:this.#t()}),n=>{e.hydrateAddress({kind:"span",span:P(n,t)});}),e}accept(){this.command("accept",()=>({op:"acceptRevision",revision:this.#t()}));}reject(){this.command("reject",()=>({op:"rejectRevision",revision:this.#t()}));}onLoad(t){let e=this.selection(t,["author","date","type"]);if(e.includes("author")&&this.loadTextInto("author",()=>({op:"getRevisionAuthor",revision:this.#t()})),e.includes("type")&&this.loadTextInto("type",()=>({op:"getRevisionType",revision:this.#t()})),!e.includes("date"))return;let n=`${this.path.label}.date`;this.read(n,()=>({op:"getRevisionDate",revision:this.#t()}),r=>{this.setLoadedProperty("date",Oe(O(r,n)));});}#t(){return this.requireAddressable(),this.path.handle()}},Q=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}acceptAll(){let t=this.#t;this.commandOn("acceptAll",()=>({op:"acceptAllRevisions",body:t}));}rejectAll(){let t=this.#t;this.commandOn("rejectAll",()=>({op:"rejectAllRevisions",body:t}));}listing(){return {op:"getRevisions",body:this.#t}}itemAt(t,e){return pt.at(this.context,t,e)}promised(t,e){return pt.promised(this.context,t,e)}commandOn(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:n,plan:e,settle:r=>{m(r,n);}});}};var _e=new Set(["matchCase","matchWholeWord","ignorePunct","ignoreSpace","matchWildcards"]);function Ht(o,t){if(o===void 0)return;typeof o!="object"&&a({code:"InvalidArgument",target:t});for(let[n,r]of Object.entries(o))_e.has(n)||a({code:"InvalidArgument",target:`${t}.${n}`}),r!==void 0&&typeof r!="boolean"&&a({code:"InvalidArgument",target:`${t}.${n}`});let e={...o.matchCase===void 0?{}:{matchCase:o.matchCase},...o.matchWholeWord===void 0?{}:{matchWholeWord:o.matchWholeWord},...o.ignorePunct===void 0?{}:{ignorePunct:o.ignorePunct},...o.ignoreSpace===void 0?{}:{ignoreSpace:o.ignoreSpace},...o.matchWildcards===void 0?{}:{matchWildcards:o.matchWildcards}};return Object.keys(e).length===0?void 0:e}var b=class o extends p{#t;#n;#e;#o;#i;#s;static at(t,e,n){return n.kind!=="span"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.ofSpan(e,n.span),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="span"?this.path.resolveToSpan(t.span):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get font(){return this.#i??=N.of(this.context,`${this.path.label}.font`,this.path,"span"),this.#i}get paragraphs(){return this.#o??=L.of(this.context,`${this.path.label}.paragraphs`,this.path),this.#o}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=it(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:R(this.path,"span"),name:n}));}get hyperlink(){return this.loadedProperty("hyperlink")}set hyperlink(t){let e=`${this.path.label}.hyperlink`;(typeof t!="string"||t.length>2048)&&a({code:"InvalidArgument",target:e}),this.requireUsablePath(),this.command("hyperlink",()=>({op:"setHyperlink",span:this.#r(),target:t}));}get bookmarks(){let t=this.#r();return this.#s??=X.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{start:t.start,end:t.end}})),this.#s}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&a({code:"InvalidArgument",target:n});let r=Ht(e,n),i=this.#r();return E.of(this.context,n,this.path,()=>({op:"search",scope:i,text:t,options:{...r??{},projection:this.revisionTextView()}}))}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=Ot(e,n);this.requireUsablePath();let s=o.promised(this.context,n,false);return this.commandAnswering(n,()=>{let d=this.#r();return i==="Replace"?{op:"replaceSpan",span:d,text:r}:{op:"insertText",at:i==="Start"||i==="Before"?d.start:d.end,text:r}},d=>{s.hydrateAddress({kind:"span",span:P(d,n)});}),s}delete(){this.requireUsablePath(),this.commandDiscarding("delete",()=>({op:"replaceSpan",span:this.#r(),text:""}));}clear(){let t=this.#r();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:t,text:""}));}insertComment(t){let e=`${this.path.label}.insertComment`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&a({code:"NotSupported",target:e});let r=G.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertComment",span:this.#r(),text:t,author:n}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:e}),r.hydrateAddress(i);}),r}insertContentControl(t){let e=`${this.path.label}.insertContentControl`,n=t??"RichText";n!=="RichText"&&n!=="PlainText"&&a({code:"NotSupported",target:e});let r=D.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertContentControl",span:this.#r(),subtype:n==="PlainText"?"plainText":"richText",returnHandle:true}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:e}),r.hydrateAddress(i);}),r}get tables(){return this.requireUsablePath(),this.#t??=U.over(this.context,`${this.path.label}.tables`,this.path,()=>R(this.path,"span"))}get fields(){return this.requireUsablePath(),this.#n??=M.of(this.context,`${this.path.label}.fields`,this.path,"span")}insertField(t,e,n,r){let i=`${this.path.label}.insertField`;(e!==void 0&&typeof e!="string"||n!==void 0&&typeof n!="string"||r!==void 0&&typeof r!="boolean")&&a({code:"InvalidArgument",target:i});let s=Ot(t,i);this.requireUsablePath();let d=H.promised(this.context,i,false);return this.commandAnswering(i,()=>({op:"insertField",span:this.#r(),location:s,...e===void 0?{}:{fieldType:e},...n===void 0?{}:{text:n},...r===void 0?{}:{removeFormatting:r}}),h=>d.hydrateAddress({kind:"handle",handle:u(h,i)})),d}get inlinePictures(){return this.requireUsablePath(),this.#e??=V.of(this.context,`${this.path.label}.inlinePictures`,this.path,"span")}insertInlinePictureFromBase64(t,e){let n=`${this.path.label}.insertInlinePictureFromBase64`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:n});let r=Ot(e,n);this.requireUsablePath();let i=F.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertInlinePicture",span:this.#r(),base64:t,location:r}),s=>{i.hydrateAddress({kind:"handle",handle:u(s,n)});}),i}insertBreak(t,e){let n=`${this.path.label}.insertBreak`;e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:n});let r=e;this.requireUsablePath(),this.commandAnswering(n,()=>({op:"insertBreak",span:this.#r(),breakType:t,location:r}),i=>m(i,n));}insertTable(t,e,n,r){let i=`${this.path.label}.insertTable`;(!Number.isInteger(t)||!Number.isInteger(e)||t<1||e<1||!["Before","After"].includes(n))&&a({code:"InvalidArgument",target:i}),r!==void 0&&(!Array.isArray(r)||r.some(h=>!Array.isArray(h)||h.some(A=>typeof A!="string")))&&a({code:"InvalidArgument",target:i});let s=r?.map(h=>[...h]),d=W.promised(this.context,i);return this.commandAnswering(i,()=>({op:"insertTable",span:R(this.path,"span"),location:n,rowCount:t,columnCount:e,...s?{values:s}:{}}),h=>{h.kind!=="handle"&&a({code:"GeneralException",target:i}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n),i=Ot(e,n);i!=="Before"&&i!=="After"&&a({code:"InvalidArgument",target:n});let s=this.#r(),d=i==="Before"?s.start.paragraph:s.end.paragraph,h=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:d},where:i==="Before"?"before":"after",text:r}),A=>{A.kind!=="handle"&&a({code:"GeneralException",target:n}),h.hydrateAddress({kind:"handle",handle:A.handle});}),h}select(t){let e=`${this.path.label}.select`,n=Dt(t,e);this.requireAddressable(),this.internals.capabilities.selection||a({code:"NotSupported",target:e});let r=this.#r();this.command("select",()=>({op:"selectSpan",span:r,mode:n==="Select"?"select":n==="Start"?"start":"end"}));}onLoad(t){let e=this.selection(t,["text","style","hyperlink"]);if(e.includes("hyperlink")&&this.loadTextInto("hyperlink",()=>({op:"getHyperlink",span:this.#r()})),e.includes("text")){let r=`${this.path.label}.text`;this.read(r,()=>({op:"getSpanText",span:this.#r(),projection:this.revisionTextView()}),i=>{this.setLoadedProperty("text",O(i,r));});}if(!e.includes("style"))return;let n=`${this.path.label}.style`;this.requireUsablePath(),this.read(n,()=>({op:"getStyle",span:R(this.path,"span")}),r=>{this.setLoadedProperty("style",xt(r,n));});}#r(){return this.requireAddressable(),this.path.span()}};var ut=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get name(){return this.loadedProperty("name")}get range(){return this.#t??=this.#n(`${this.path.label}.range`),this.#t}select(t){let e=`${this.path.label}.select`,n=Dt(t,e);this.requireUsablePath(),this.internals.capabilities.selection||a({code:"NotSupported",target:e}),this.command("select",()=>({op:"selectBookmark",bookmark:this.#e(),mode:n==="Select"?"select":n==="Start"?"start":"end"}));}onLoad(t){if(!this.selection(t,["name"]).includes("name"))return;let e=`${this.path.label}.name`;this.read(e,()=>({op:"getBookmarkName",bookmark:this.#e()}),n=>{this.setLoadedProperty("name",O(n,e));});}#n(t){let e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getBookmarkRange",bookmark:this.#e()}),n=>{e.hydrateAddress({kind:"span",span:P(n,t)});}),e}#e(){return this.requireAddressable(),this.path.handle()}},X=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}listing(){return this.#t()}itemAt(t,e){return ut.at(this.context,t,e)}promised(t,e){return ut.promised(this.context,t,e)}};var I=class o extends p{#t;#n;#e;#o;#i;#s;#r;#a;#l;static main(t,e){return new o(t,c.of(e,J(t).roots().body))}static promisedStory(t,e){return new o(t,c.pending(e))}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}constructor(t,e){super(t,e);}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#o??=this.paragraphsUnder(`${this.path.label}.paragraphs`),this.#o}get bookmarks(){let t=this.#d();return this.#i??=X.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{body:t}})),this.#i}get font(){return this.#s??=N.of(this.context,`${this.path.label}.font`,this.path,"body"),this.#s}paragraphsUnder(t){return L.of(this.context,t,this.path)}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=it(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:R(this.path,"body"),name:n}));}get lists(){return this.#r??=lt.of(this.context,`${this.path.label}.lists`,this.path,this.#d()),this.#r}get contentControls(){return this.#a??=$.of(this.context,`${this.path.label}.contentControls`,this.path,{body:this.#d()}),this.#a}getComments(){let t=`${this.path.label}.getComments`,e=this.#d();return z.of(this.context,t,this.path,()=>({op:"getComments",scope:{body:e}}))}get revisions(){return this.#l??=Q.of(this.context,`${this.path.label}.revisions`,this.path,this.#d()),this.#l}getRange(t="Whole"){let e=`${this.path.label}.getRange`;this.requireUsablePath();let n=b.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{body:this.path.handle()},location:t}),r=>{n.hydrateAddress({kind:"span",span:P(r,e)});}),n}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&a({code:"InvalidArgument",target:n});let r=Ht(e,n),i=this.#d();return E.of(this.context,n,this.path,()=>({op:"search",scope:{body:i},text:t,options:{...r??{},projection:this.revisionTextView()}}))}clear(){let t=this.#d();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{body:t},text:""}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=fe(e,n);this.requireUsablePath();let s=b.promised(this.context,n,false);return this.commandAnswering(n,()=>i==="Replace"?{op:"replaceSpan",span:{body:this.#d()},text:r}:{op:"insertText",at:{body:this.#d(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:P(d,n)});}),s}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n),i=be(e,n),s=this.#d(),d=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{body:s,at:i==="Start"?"first":"last"},where:i==="Start"?"before":"after",text:r}),h=>{h.kind!=="handle"&&a({code:"GeneralException",target:n}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}onLoad(t){let e=this.selection(t,["text","style"]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#d(),projection:this.revisionTextView()})),e.includes("style")&&this.#c();}#c(){let t=`${this.path.label}.style`;this.requireUsablePath(),this.read(t,()=>({op:"getStyle",span:R(this.path,"body")}),e=>{this.setLoadedProperty("style",xt(e,t));});}get fields(){return this.requireUsablePath(),this.#n??=M.of(this.context,`${this.path.label}.fields`,this.path,"body")}get inlinePictures(){return this.requireUsablePath(),this.#e??=V.of(this.context,`${this.path.label}.inlinePictures`,this.path,"body")}get tables(){return this.requireUsablePath(),this.#t??=U.over(this.context,`${this.path.label}.tables`,this.path,()=>({body:this.#d()}))}#d(){return this.requireAddressable(),this.path.handle()}};function tn(o){return o==="endnote"?"Endnote":"Footnote"}var mt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get type(){return this.loadedProperty("type")}get text(){return this.loadedProperty("text")}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=I.promisedStory(this.context,t);return this.read(t,()=>({op:"getNoteBody",note:this.#n()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),this.#t=e,e}delete(){this.command("delete",()=>({op:"deleteNote",note:this.#n()}));}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document,r=`${t}.type`,i="footnote",s=c.pending(r);return this.read(r,()=>({op:"getNoteKind",note:this.#n()}),d=>{i=O(d,r)==="endnote"?"endnote":"footnote",s.resolveTo(this.#n());}),this.enqueue({sort:"read",label:t,dependencies:[s],plan:()=>({op:"getNotes",document:n,noteKind:i}),settle:d=>{let h=v(d,t),A=h.findIndex(ot=>ot.ref===this.#n().ref),K=A<0?void 0:h[A+1];K||a({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:K});}}),e}onLoad(t){let e=this.selection(t,["text","type"]);if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getNoteText",note:this.#n(),projection:this.revisionTextView()})),e.includes("type")){let n=`${this.path.label}.type`;this.read(n,()=>({op:"getNoteKind",note:this.#n()}),r=>{this.setLoadedProperty("type",tn(O(r,n)));});}}#n(){return this.requireAddressable(),this.path.handle()}},nt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return mt.at(this.context,t,e)}promised(t,e){return mt.promised(this.context,t,e)}};var en=Object.freeze({Primary:"default",FirstPage:"first",EvenPages:"even"}),nn=["pageWidth","pageHeight","orientation","topMargin","rightMargin","bottomMargin","leftMargin"],kt=class o extends p{#t;static of(t,e,n){return new o(t,c.derived(e,n))}constructor(t,e){super(t,e);}get pageWidth(){return this.loadedProperty("pageWidth")}set pageWidth(t){this.#n("pageWidth",gt(t,`${this.path.label}.pageWidth`));}get pageHeight(){return this.loadedProperty("pageHeight")}set pageHeight(t){this.#n("pageHeight",gt(t,`${this.path.label}.pageHeight`));}get orientation(){return this.loadedProperty("orientation")}set orientation(t){let e=`${this.path.label}.orientation`;t!=="Portrait"&&t!=="Landscape"&&a({code:"InvalidArgument",target:e}),this.#n("orientation",t==="Portrait"?"portrait":"landscape");}get topMargin(){return this.loadedProperty("topMargin")}set topMargin(t){this.#n("topMargin",gt(t,`${this.path.label}.topMargin`));}get bottomMargin(){return this.loadedProperty("bottomMargin")}set bottomMargin(t){this.#n("bottomMargin",gt(t,`${this.path.label}.bottomMargin`));}get leftMargin(){return this.loadedProperty("leftMargin")}set leftMargin(t){this.#n("leftMargin",gt(t,`${this.path.label}.leftMargin`));}get rightMargin(){return this.loadedProperty("rightMargin")}set rightMargin(t){this.#n("rightMargin",gt(t,`${this.path.label}.rightMargin`));}onLoad(t){let e=this.selection(t,nn);if(e.length===0)return;let n=`${this.path.label}.pageSetup`;this.read(n,()=>({op:"getPageSetup",section:this.#e()}),r=>{let i=Ut(r,n);for(let s of e)this.setLoadedProperty(s,s==="orientation"?i.orientation==="landscape"?"Landscape":"Portrait":i[s]);});}#n(t,e){if(this.requireUsablePath(),this.#t){this.#t[t]=e;return}let n={[t]:e};this.#t=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.pageSetup`,()=>({op:"setPageSetup",section:this.#e(),setup:n}),i=>{m(i,r);},()=>{this.#t===n&&(this.#t=void 0);});}#e(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},ft=class o extends p{#t;#n;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){return this.#n??=I.main(this.context,`${this.path.label}.body`),this.#n}get pageSetup(){return this.#t??=kt.of(this.context,`${this.path.label}.pageSetup`,this.path),this.#t}getHeader(t){return this.#e("header",t,"getHeader")}getFooter(t){return this.#e("footer",t,"getFooter")}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document;return this.read(t,()=>({op:"getSections",document:n}),r=>{let i=v(r,t),s=i.findIndex(h=>h.ref===this.#o().ref),d=s<0?void 0:i[s+1];d||a({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:d});}),e}onLoad(t){this.selection(t,[]);}#e(t,e,n){let r=`${this.path.label}.${n}`,i=en[e];i===void 0&&a({code:"InvalidArgument",target:r});let s=I.promisedStory(this.context,r);return this.read(r,()=>({op:"getFurniture",section:this.#o(),kind:t,variant:i}),d=>{s.hydrateAddress({kind:"handle",handle:u(d,r)});}),s}#o(){return this.requireAddressable(),this.path.handle()}},bt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return ft.at(this.context,t,e)}promised(t,e){return ft.promised(this.context,t,e)}};function gt(o,t){return (typeof o!="number"||!Number.isFinite(o)||o<0)&&a({code:"InvalidArgument",target:t}),o}var yt=class o extends p{#t;#n;#e;#o;#i;#s;#r;#a;static open(t){return new o(t)}constructor(t){super(t,c.of("document",J(t).roots().document));}get changeTrackingMode(){return this.loadedProperty("changeTrackingMode")}set changeTrackingMode(t){["Off","TrackAll","TrackMineOnly"].includes(t)||a({code:"InvalidArgument",target:"document.changeTrackingMode"});let e=this.internals.author;this.commandAnswering("document.changeTrackingMode",()=>({op:"setChangeTrackingMode",mode:t,...e===void 0?{}:{author:e}}),()=>this.setLoadedProperty("changeTrackingMode",t));}get body(){return this.#t??=I.main(this.context,"document.body"),this.#t}get paragraphs(){return this.#n??=this.body.paragraphsUnder("document.paragraphs"),this.#n}get sections(){let t=this.path.handle();return this.#e??=bt.of(this.context,"document.sections",this.path,()=>({op:"getSections",document:t})),this.#e}get contentControls(){return this.#s??=$.of(this.context,"document.contentControls",this.path,{body:this.internals.roots().body}),this.#s}get comments(){return this.#o??=z.of(this.context,"document.comments",this.path,()=>({op:"getComments",scope:{body:this.internals.roots().body}})),this.#o}get revisions(){return this.#i??=Q.of(this.context,"document.revisions",this.path,this.internals.roots().body),this.#i}get footnotes(){let t=this.path.handle();return this.#r??=nt.of(this.context,"document.footnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"footnote"})),this.#r}get endnotes(){let t=this.path.handle();return this.#a??=nt.of(this.context,"document.endnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"endnote"})),this.#a}onLoad(t){if(t.select.length===0)return;this.selection(t,["changeTrackingMode"]).includes("changeTrackingMode")&&this.loadTextInto("changeTrackingMode",()=>({op:"getChangeTrackingMode"}));}};function Ie(o){let t=o.host,e=Object.freeze({...t.capabilities,save:o.save&&t.capabilities.save}),n=typeof o.author=="string"&&o.author.trim().length>0?o.author:void 0,r=o.revisionTextView??"allMarkup";r!=="allMarkup"&&r!=="original"&&a({code:"InvalidArgument",target:"revisionTextView"});let i=false,s=null,d=g=>{i&&a({code:"RuntimeDisposed",...g===void 0?{}:{target:g}});},h=()=>{if(s)return s;d("document");let g=Re(t.execute({operations:[{op:"getDocument"}]}),"document"),Z=Re(t.execute({operations:[{op:"getBody",document:g}]}),"document.body");return s={document:g,body:Z},s},A={host:t,capabilities:e,...n===void 0?{}:{author:n},revisionTextView:r,id:{},roots:h,assertLive:d,openDocument:g=>yt.open(g)};try{h();}catch{s=null;}async function K(g,Z){d();let rt=typeof g=="function"?g:Z,Mt=typeof g=="function"?[]:Array.isArray(g)?g:[g];typeof rt!="function"&&a({code:"InvalidArgument",target:"run"});let{context:wt,adopt:y,finish:Le}=At.begin(A);try{return y(Mt),await rt(wt)}finally{Le();}}let ot={capabilities:e,run:K,dispose(){i||(i=true,s=null,t.dispose());}};return o.save?{...ot,async save(){d("save"),e.save||a({code:"NotSupported",target:"save"});let g=t.save();if(!g.ok)throw Et(g.error,{target:"save"});return g.bytes}}:ot}function Re(o,t){let e=o.results[0];if(e?.status==="error")throw Et(e.error,{target:t});if(e?.status!=="ok")throw new C({code:"GeneralException",target:t});return u(e.value,t)}function rn(o){if(o){for(let t of o)if(t.collaboration)return t.collaboration}}function an(o){let t=[o?.zip?.maxEntries,o?.zip?.maxTotalBytes,o?.xml?.maxBytes,o?.xml?.maxElements,o?.maxXmlParts,o?.maxRelationships],e=o?.zip?.maxRatio;(t.some(n=>n!==void 0&&(!Number.isInteger(n)||n<0))||e!==void 0&&(!Number.isFinite(e)||e<0))&&a({code:"InvalidArgument",target:"createServer"});}async function ae(o,t={}){an(t.limits);let e=rn(t.modules),n=createServerAutomationHost(o,{...t.pagination?{pagination:de(t.pagination)}:{},...t.limits===void 0?{}:{limits:t.limits},...e===void 0?{}:{collaborationModel:e}});if(!n.ok){let r={"too-many-entries":"zip.maxEntries","too-large":"xml.maxBytes","too-many-elements":"xml.maxElements","too-deep":"xml.maxDepth","too-many-xml-parts":"maxXmlParts","too-many-relationships":"maxRelationships"},i=n.limit??r[n.reason];a({code:i===void 0?"InvalidArgument":"ResourceLimitExceeded",target:"createServer",...i===void 0?{}:{limit:i}});}return Ie({host:n.host,save:true,...t.author===void 0?{}:{author:t.author},...t.revisionTextView===void 0?{}:{revisionTextView:t.revisionTextView}})}function ke(o,t,e={}){return ae(o,{...e,modules:[...e.modules??[],{id:"collaboration",collaboration:{session:t}}]})}var se=(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))(se||{});var Mi=Object.freeze({createServer:ae,createCollaborative:ke});export{Kt as Alignment,I as Body,ut as Bookmark,X as BookmarkCollection,_t as BreakType,Yt as ChangeTrackingMode,B as ClientObject,Ft as ClientResult,G as Comment,z as CommentCollection,et as CommentReply,It as CommentReplyCollection,D as ContentControl,$ as ContentControlCollection,te as ContentControlType,yt as Document,Mi as DocxEditor,C as DocxEditorError,H as Field,M as FieldCollection,se as FieldType,N as Font,F as InlinePicture,V as InlinePictureCollection,Xt as InsertLocation,j as List,ne as ListBullet,lt as ListCollection,ct as ListItem,oe as ListNumbering,mt as NoteItem,nt as NoteItemCollection,Zt as PageOrientation,kt as PageSetup,w as Paragraph,L as ParagraphCollection,b as Range,E as RangeCollection,At as RequestContext,pt as Revision,Q as RevisionCollection,ft as Section,bt as SectionCollection,W as Table,tt as TableCell,Pt as TableCellCollection,U as TableCollection,at as TableRow,st as TableRowCollection,Ct as TrackedObjects,re as UnderlineType,Jt as VerticalAlignment,Se as isDocxEditorError};
1
+ import {createServerAutomationHost,createAutomationPaginationProvider}from'@docx-editor.dev/core/automation';function de(o){return createAutomationPaginationProvider(o)}var le=Object.freeze({PropertyNotLoaded:"the property has not been loaded. Call load(...) and await context.sync() before reading it.",ValueNotLoaded:"the result has not been filled in yet. Await context.sync() before reading it.",InvalidObjectPath:"the object cannot be addressed. Await context.sync() after creating an object with an edit. Keep proxies within their run, or use context.trackedObjects.add(...) before the run ends.",ObjectInUse:"the object still belongs to a run that has not finished. Await that run before passing the object to another one.",InvalidArgument:"the argument is not one this API accepts.",ResourceLimitExceeded:"the document exceeds a supported resource limit.",ItemNotFound:"the collection has no such item.",NotSupported:"the operation or argument is outside this document or host\u2019s supported capabilities.",NotImplemented:"this version does not implement that yet.",ConflictingChanges:"these operations cannot share one atomic batch. Split them across separate context.sync() calls.",InvalidRequestContext:"the request context has finished. Start another run to continue.",RuntimeDisposed:"the runtime has been disposed.",StaleDocument:"the document changed after this context read it, so nothing was applied.",DocumentUnavailable:"the document is not available right now.",GeneralException:"the document could not complete the request."}),C=class extends Error{code;limit;target;expectedRevision;actualRevision;constructor(t){let e=t.target?`${le[t.code]} (${t.target})`:le[t.code];super(e),this.name="DocxEditorError",this.code=t.code,t.limit!==void 0&&(this.limit=t.limit),t.target!==void 0&&(this.target=t.target),t.expectedRevision!==void 0&&(this.expectedRevision=t.expectedRevision),t.actualRevision!==void 0&&(this.actualRevision=t.actualRevision);}};function je(o){return o instanceof C?true:typeof o=="object"&&o!==null&&o.name==="DocxEditorError"&&typeof o.code=="string"}function a(o){throw new C(o)}var Y=Symbol("docx-editor.runtime.internals"),St=Symbol("docx-editor.runtime.release"),jt=Symbol("docx-editor.runtime.rebind");function J(o){return o[Y]}var Te=new Set(["select","expand","top","skip"]),Ee=/^[A-Za-z][A-Za-z0-9]*$/;function ce(o,t){if(o===void 0)return [];let e=typeof o=="string"?o.split(",").map(r=>r.trim()):Array.isArray(o)?o.map(r=>typeof r=="string"?r.trim():r):a({code:"InvalidArgument",target:t}),n=[];for(let r of e)(typeof r!="string"||!Ee.test(r))&&a({code:"InvalidArgument",target:t}),n.includes(r)||n.push(r);return n.length===0&&a({code:"InvalidArgument",target:t}),n}function he(o,t){return (typeof o!="number"||!Number.isInteger(o)||o<0)&&a({code:"InvalidArgument",target:t}),o}function Ne(o,t){o===void 0||Array.isArray(o)&&o.length===0||a({code:"InvalidArgument",target:t});}function pe(o,t){if(o===void 0)return {select:[]};if(typeof o=="string"||Array.isArray(o))return {select:ce(o,t)};(typeof o!="object"||o===null)&&a({code:"InvalidArgument",target:t});let e=o;for(let n of Object.keys(e))Te.has(n)||a({code:"InvalidArgument",target:`${t}.${n}`});return Ne(e.expand,`${t}.expand`),{select:ce(e.select,`${t}.select`),...e.top===void 0?{}:{top:he(e.top,`${t}.top`)},...e.skip===void 0?{}:{skip:he(e.skip,`${t}.skip`)}}}var $=class{#t;#n;#e;#o;#i=new Map;#s=false;constructor(t,e,n={}){this.#t=t,this.#n=t[Y],this.#e=e,this.#o=n.nullable===true,this.#n.register(this);}get context(){return this.#t}get isNullObject(){return this.#e.isReleased&&a({code:"InvalidObjectPath",target:this.#e.label}),this.#o?(this.#e.isPending&&a({code:"PropertyNotLoaded",target:`${this.#e.label}.isNullObject`}),this.#e.isNull):false}load(t){this.#s=true;try{return this.requireUsablePath(),this.onLoad(pe(t,this.#e.label)),this}finally{this.#s=false;}}get path(){return this.#e}get internals(){return this.#n}handle(){return this.#e.handle()}requireAddressable(){this.#e.isAddressable||a({code:"InvalidObjectPath",target:this.#e.label}),this.#n.assertUsable(this.#e.label);}requireUsablePath(){(this.#e.isReleased||this.#e.isNull&&!(this.#s&&this.#o))&&a({code:"InvalidObjectPath",target:this.#e.label}),this.#n.assertUsable(this.#e.label);}enqueue(t){this.requireUsablePath(),this.#n.queue.push({...t,dependencies:[...t.dependencies??[],this.#e],...this.#s&&this.#o&&t.sort==="read"?{nullableLoad:this.#e}:{}});}loadedProperty(t){return this.#e.isReleased&&!this.#i.has(t)&&a({code:"InvalidObjectPath",target:this.#e.label}),this.#i.has(t)||a({code:"PropertyNotLoaded",target:`${this.#e.label}.${t}`}),this.#i.get(t)}hasLoadedProperty(t){return this.#i.has(t)}setLoadedProperty(t,e){this.#i.set(t,e);}[St](){this.#e.release();}[jt](t){this.#t=t,this.#n=t[Y];}};var Tt=class o{#t=false;#n;#e;constructor(t){this.#e=t;}get value(){return this.#t||a({code:"ValueNotLoaded",target:this.#e}),this.#n}get isLoaded(){return this.#t}static create(t){let e=new o(t);return {result:e,fill(n){e.#t=true,e.#n=n;}}}};function ue(o){return Tt.create(o)}function S(o){return new C({code:"GeneralException",target:o})}function P(o,t){if(o.kind!=="text")throw S(t);return o.text}function u(o,t){if(o.kind!=="handle")throw S(t);return o.handle}function v(o,t){if(o.kind!=="handles")throw S(t);return o.handles}function R(o,t){if(o.kind!=="span")throw S(t);return o.span}function Et(o,t){if(o.kind!=="spans")throw S(t);return o.spans}function Vt(o,t){if(o.kind!=="font")throw S(t);return o.font}function Wt(o,t){if(o.kind!=="paragraphFormat")throw S(t);return o.format}function xt(o,t){if(o.kind!=="style")throw S(t);return o.name}function Nt(o,t){if(o.kind!=="number")throw S(t);return o.value}function _(o,t){if(o.kind!=="flag")throw S(t);return o.value}function Ut(o,t){if(o.kind!=="pageSetup")throw S(t);return o.setup}function m(o,t){if(o.kind!=="applied")throw S(t)}var c=class o{label;#t;#n;constructor(t,e,n=null){this.label=t,this.#t=e,this.#n=n;}static of(t,e){return new o(t,{status:"resolved",address:{kind:"handle",handle:e}})}static ofSpan(t,e){return new o(t,{status:"resolved",address:{kind:"span",span:e}})}static pending(t){return new o(t,{status:"pending"})}static derived(t,e){return new o(t,{status:"pending"},e)}get state(){return this.#n?this.#n.state:this.#t}get isAddressable(){return this.state.status==="resolved"}get isPending(){return this.state.status==="pending"}get isNull(){return this.state.status==="null"}get isReleased(){return this.state.status==="released"}address(){let t=this.state;if(t.status==="resolved")return t.address;a({code:"InvalidObjectPath",target:this.label});}handle(){let t=this.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.label}),t.handle}span(){let t=this.address();return t.kind!=="span"&&a({code:"InvalidObjectPath",target:this.label}),t.span}resolveTo(t){this.#e({kind:"handle",handle:t});}resolveToSpan(t){this.#e({kind:"span",span:t});}resolveNull(){this.#t.status!=="released"&&(this.#t={status:"null"});}release(){this.#n||(this.#t={status:"released"});}#e(t){this.#t.status!=="released"&&(this.#t={status:"resolved",address:t});}};function me(o){let t=[],e=false,n=false;for(let r of o)t.push(r.plan()),r.sort==="write"?n=true:e=true;return {operations:t,hasRead:e,hasWrite:n}}var qe=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(o,t={}){let e=qe[o.code]??"GeneralException",n=e==="StaleDocument";return new C({code:e,...t.target===void 0?{}:{target:t.target},...n&&t.expectedRevision!==void 0?{expectedRevision:t.expectedRevision}:{},...n&&t.actualRevision!==void 0?{actualRevision:t.actualRevision}:{}})}function Gt(o,t,e){for(let n=0;n<o.results.length;n+=1){let r=o.results[n];if(r?.status!=="error")continue;let i=t[n]?.label;return qt(r.error,{...i===void 0?{}:{target:i},...e===void 0?{}:{expectedRevision:e},actualRevision:o.revision})}return new C({code:"GeneralException"})}function zt(o,t){if(t.results.length!==o.length)throw new C({code:"GeneralException"});for(let e=0;e<o.length;e+=1){let n=t.results[e],r=o[e];if(n.status!=="ok")throw new C({code:"GeneralException",target:r.label});r.settle(n.value);}}var Dt=class{#t=[];get size(){return this.#t.length}get pending(){return this.#t}push(t){this.#t.push(t);}take(){let t=this.#t;this.#t=[];for(let e of t)e.capture?.();return t}clear(){for(let t of this.#t)t.dispose?.();this.#t=[];}};function ge(o,t){if(Array.isArray(o)){for(let e of o)t(e);return}t(o);}var Ct=class{#t;#n;constructor(t,e){this.#t=t,this.#n=e;}add(t){this.#t.assertUsable(),ge(t,e=>{this.#e(e),this.#t.track(e);});}remove(t){this.#t.assertUsable(),ge(t,e=>{this.#e(e),this.#t.untrack(e);});}#e(t){this.#n(t)||a({code:"InvalidObjectPath"});}};var At=class o{#t;#n=new Dt;#e=new Set;#o=new Set;#i;#s;#r;#a=false;#l=null;#c=false;constructor(t){this.#t=t,this.#i={host:t.host,capabilities:t.capabilities,...t.author===void 0?{}:{author:t.author},revisionTextView:t.revisionTextView,queue:this.#n,session:t.id,roots:()=>t.roots(),assertUsable:e=>{this.#t.assertLive(e),this.#a&&a({code:"InvalidRequestContext",...e===void 0?{}:{target:e}});},isFinished:()=>this.#a,readRevision:()=>this.#l,register:e=>{this.#e.add(e);},track:e=>{this.#o.add(e);},untrack:e=>{this.#o.delete(e);},isTracked:e=>this.#o.has(e),disown:e=>{this.#e.delete(e),this.#o.delete(e);}},this.#s=new Ct(this.#i,e=>this.#e.has(e));}get document(){return this.#i.assertUsable("document"),this.#r??=this.#t.openDocument(this),this.#r}get capabilities(){return this.#t.capabilities}get trackedObjects(){return this.#s}async sync(){this.#i.assertUsable(),this.#c&&a({code:"InvalidRequestContext"});let t=this.#n.take();if(t.length!==0){this.#c=true;try{let e=t.filter(s=>!s.nullableLoad?.isNull),n=t.some(s=>s.sort==="write"),r,i=s=>s.dependencies?.some(d=>!d.isAddressable)??false;for(;e.some(i);){r??=n&&this.#l!==null?this.#l:this.#t.host.revision();let s=e.filter(h=>h.sort==="read"&&!i(h));s.length===0&&a({code:"InvalidObjectPath",target:e.find(i)?.label}),await this.#d(s,r);let d=new Set(s);e=e.filter(h=>!d.has(h)&&!h.nullableLoad?.isNull);}if(e.length){let s=r??(n&&this.#l!==null?this.#l:void 0);await this.#d(e,s);}}finally{for(let e of t)e.dispose?.();this.#c=false;}}}async#d(t,e){let n=me(t),r={operations:n.operations,...e===void 0?{}:{expectedRevision:e}};if(this.#t.host.prepare){let s={...r,expectedRevision:r.expectedRevision??this.#t.host.revision()};await this.#t.host.prepare(s);let d=this.#t.host.execute(s);if(!d.ok)throw Gt(d,t,s.expectedRevision);zt(t,d),this.#l=d.revision;return}let i=this.#t.host.execute(r);if(!i.ok)throw Gt(i,t,e);zt(t,i),(n.hasRead||n.hasWrite)&&(this.#l=i.revision);}get[Y](){return this.#i}static begin(t){let e=new o(t);return {context:e,adopt(n){for(let r of n)e.#h(r);},finish(){e.#u();}}}#h(t){let e=t.context;if(e===this)return;let n=e[Y];if(n.session!==this.#t.id)throw new C({code:"InvalidObjectPath"});if(!n.isFinished())throw new C({code:"ObjectInUse"});if(!n.isTracked(t))throw new C({code:"InvalidObjectPath"});let r=n.readRevision();n.disown(t),t[jt](this),this.#e.add(t),this.#o.add(t),r!==null&&this.#p(r);}#p(t){this.#l=this.#l===null?t:Math.min(this.#l,t);}#u(){if(!this.#a){this.#a=true,this.#n.clear();for(let t of this.#e)this.#o.has(t)||t[St]();this.#e.clear();}}};function vt(o,t,e){if(o.select.length===0)return t;for(let n of o.select)t.includes(n)||a({code:"InvalidArgument",target:`${e}.${n}`});return o.select}function O(o,t){let e=o.address();return t==="span"?(e.kind!=="span"&&a({code:"InvalidObjectPath",target:o.label}),{start:e.span.start,end:e.span.end}):(e.kind!=="handle"&&a({code:"InvalidObjectPath",target:o.label}),t==="body"?{body:e.handle}:{paragraph:e.handle})}function at(o,t){return (typeof o!="string"||o.trim().length===0||o.length>255)&&a({code:"InvalidArgument",target:t}),o}var p=class extends ${revisionTextView(){return J(this.context).revisionTextView}loadTextInto(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"read",label:n,plan:e,settle:r=>{this.setLoadedProperty(t,P(r,n));}});}command(t,e,n){let r=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:r,plan:e,settle:i=>m(i,r),...n?{capture:n,dispose:n}:{}});}commandDiscarding(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:n,plan:e,settle:()=>{}});}commandAnswering(t,e,n,r){this.enqueue({sort:"write",label:t,plan:e,settle:n,...r?{capture:r,dispose:r}:{}});}read(t,e,n){this.enqueue({sort:"read",label:t,plan:e,settle:n});}selection(t,e){return vt(t,e,this.path.label)}onLoad(t){this.selection(t,[]);}};var T=class extends ${#t;#n=[];constructor(t,e){super(t,e);}get items(){return this.loadedProperty("items")}fill(t,e){this.setLoadedProperty("items",this.#o(t,e,0,void 0)),this.#t={value:t,label:e};let n=this.#n.splice(0,this.#n.length);for(let r of n)this.#e(r,t);}onLoad(t){vt(t,["items"],this.path.label);let e=this.path.isPending?void 0:this.listing();if(e===null)return;let n=`${this.path.label}.items`,r=t.skip??0,i=t.top;this.enqueue({sort:"read",label:n,plan:()=>{let s=e??this.listing();return s||a({code:"InvalidObjectPath",target:this.path.label}),s},settle:s=>{this.setLoadedProperty("items",this.#o(s,n,r,i));}});}edge(t,e,n){let r=`${this.path.label}.${e}()`,i=this.promised(r,n),s=this.path.isPending?void 0:this.listing();if(s===null){let d={edge:t,target:r,nullable:n,item:i};return this.#t?this.#e(d,this.#t.value):this.#n.push(d),i}return this.enqueue({sort:"read",label:r,plan:()=>{let d=s??this.listing();return d||a({code:"InvalidObjectPath",target:this.path.label}),d},settle:d=>{this.#e({edge:t,target:r,nullable:n,item:i},d);}}),i}#e(t,e){let{edge:n,target:r,nullable:i,item:s}=t,d=this.size(e,r);if(d===0){i||a({code:"ItemNotFound",target:r}),s.hydrateNull();return}let h=this.addressAt(e,r,n==="first"?0:d-1);h||a({code:"ItemNotFound",target:r}),s.hydrateAddress(h);}#o(t,e,n,r){let i=this.size(t,e),s=r===void 0?i:Math.min(i,n+r),d=[];for(let h=n;h<s;h+=1){let A=this.addressAt(t,e,h);A&&d.push(this.itemAt(`${e}[${String(h)}]`,A));}return d}},x=class extends T{size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}};var H=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get code(){return this.loadedProperty("code")}set code(t){if(this.requireUsablePath(),(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:`${this.path.label}.code`}),this.#t){this.#t.code=t;return}let e={code:t};this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setFieldCode",field:this.#e(),code:e.code}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}delete(){this.#n("deleteField");}updateResult(){this.#n("updateFieldResult");}#n(t){this.requireUsablePath(),this.commandAnswering(this.path.label,()=>({op:t,field:this.#e()}),e=>m(e,this.path.label));}onLoad(t){this.selection(t,["code"]).length!==0&&this.read(this.path.label,()=>({op:"getField",field:this.#e()}),e=>{e.kind!=="field"&&a({code:"GeneralException",target:this.path.label}),this.setLoadedProperty("code",e.field.code);});}#e(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},M=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getFields",span:O(this.path,this.#t)}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return H.at(this.context,t,e)}promised(t,e){return H.promised(this.context,t,e)}};var De=["width","height","lockAspectRatio","altTextDescription"],F=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get width(){return this.loadedProperty("width")}set width(t){this.#n("width",t);}get height(){return this.loadedProperty("height")}set height(t){this.#n("height",t);}get lockAspectRatio(){return this.loadedProperty("lockAspectRatio")}set lockAspectRatio(t){typeof t!="boolean"&&a({code:"InvalidArgument",target:`${this.path.label}.lockAspectRatio`}),this.#e({lockAspectRatio:t});}get altTextDescription(){return this.loadedProperty("altTextDescription")}set altTextDescription(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.altTextDescription`}),this.#e({altTextDescription:t});}delete(){let t=`${this.path.label}.delete`;this.commandAnswering(t,()=>({op:"deleteInlinePicture",picture:this.#o()}),e=>m(e,t));}onLoad(t){let e=this.selection(t,De);e.length&&this.read(this.path.label,()=>({op:"getInlinePicture",picture:this.#o()}),n=>{n.kind!=="inlinePicture"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.picture[r]);});}#n(t,e){(typeof e!="number"||!Number.isFinite(e)||e<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#e({[t]:e});}#e(t){if(this.requireUsablePath(),this.#t){Object.assign(this.#t,t);return}let e=t;this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setInlinePicture",picture:this.#o(),properties:e}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}#o(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},V=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getInlinePictures",span:O(this.path,this.#t)}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return F.at(this.context,t,e)}promised(t,e){return F.promised(this.context,t,e)}};function q(o,t,e=0){return (!Number.isInteger(o)||o<e)&&a({code:"InvalidArgument",target:t}),o}function Qt(o,t){return (!Array.isArray(o)||o.some(e=>!Array.isArray(e)||e.some(n=>typeof n!="string")))&&a({code:"InvalidArgument",target:t}),o.map(e=>[...e])}function fe(o,t){return o!=="Start"&&o!=="End"&&a({code:"InvalidArgument",target:t}),o==="Start"?"start":"end"}var W=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get values(){return this.loadedProperty("values")}set values(t){let e=Qt(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 n=`${this.path.label}.getCell`;q(t,n),q(e,n);let r=tt.promised(this.context,n);return this.read(n,()=>({op:"getTableCell",table:this.path.handle(),rowIndex:t,cellIndex:e}),i=>r.hydrateAddress({kind:"handle",handle:u(i,n)})),r}addRows(t,e,n){let r=`${this.path.label}.addRows`,i=fe(t,r);q(e,r,1);let s=n===void 0?void 0:Qt(n,r),d=dt.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addRows",location:i,count:e,...s?{values:s}:{}}}),h=>d.fill(h,r)),d}addColumns(t,e,n){let r=`${this.path.label}.addColumns`,i=fe(t,r);q(e,r,1);let s=n===void 0?void 0:Qt(n,r);this.command("addColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addColumns",location:i,count:e,...s?{values:s}:{}}}));}deleteRows(t,e){e===void 0&&(e=1),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()}),n=>{n.kind!=="table"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.table[r]);});}},st=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get cells(){return this.#t??=Rt.of(this.context,`${this.path.label}.cells`,this.path,()=>({op:"getTableCells",row:this.path.handle()}))}},tt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=I.promisedStory(this.context,t);return this.read(t,()=>({op:"getTableCellBody",cell:this.path.handle()}),n=>e.hydrateAddress({kind:"handle",handle:u(n,t)})),this.#t=e,e}get value(){return this.loadedProperty("value")}set value(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.value`}),this.command("value",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{value:t}}));}get columnWidth(){return this.loadedProperty("columnWidth")}set columnWidth(t){(typeof t!="number"||!Number.isFinite(t)||t<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.columnWidth`}),this.command("columnWidth",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{columnWidth:t}}));}get shadingColor(){return this.loadedProperty("shadingColor")}set shadingColor(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.shadingColor`}),this.command("shadingColor",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{shadingColor:t}}));}get verticalAlignment(){return this.loadedProperty("verticalAlignment")}set verticalAlignment(t){t!=="Top"&&t!=="Center"&&t!=="Bottom"&&a({code:"InvalidArgument",target:`${this.path.label}.verticalAlignment`}),this.command("verticalAlignment",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{verticalAlignment:t}}));}onLoad(t){let e=this.selection(t,["value","columnWidth","shadingColor","verticalAlignment"]);this.read(this.path.label,()=>({op:"getTableCellProperties",cell:this.path.handle()}),n=>{n.kind!=="tableCell"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.cell[r]);});}},U=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}static over(t,e,n,r){return o.of(t,e,n,()=>({op:"getTables",scope:r()}))}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return W.at(this.context,t,e)}promised(t,e){return W.promised(this.context,t,e)}},dt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return st.at(this.context,t,e)}promised(t,e){return st.promised(this.context,t,e)}},Rt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return tt.at(this.context,t,e)}promised(t,e){return tt.promised(this.context,t,e)}};var Xt=(i=>(i.replace="Replace",i.start="Start",i.end="End",i.before="Before",i.after="After",i))(Xt||{}),Kt=(s=>(s.mixed="Mixed",s.unknown="Unknown",s.left="Left",s.centered="Centered",s.right="Right",s.justified="Justified",s))(Kt||{}),Zt=(e=>(e.portrait="Portrait",e.landscape="Landscape",e))(Zt||{}),Yt=(n=>(n.off="Off",n.trackAll="TrackAll",n.trackMineOnly="TrackMineOnly",n))(Yt||{}),Jt=(r=>(r.mixed="Mixed",r.top="Top",r.center="Center",r.bottom="Bottom",r))(Jt||{}),_t=(d=>(d.line="Line",d.page="Page",d.next="Next",d.sectionNext="SectionNext",d.sectionContinuous="SectionContinuous",d.sectionEven="SectionEven",d.sectionOdd="SectionOdd",d))(_t||{}),te=(y=>(y.unknown="Unknown",y.richText="RichText",y.plainText="PlainText",y.picture="Picture",y.buildingBlockGallery="BuildingBlockGallery",y.checkBox="CheckBox",y.comboBox="ComboBox",y.datePicker="DatePicker",y.dropDownList="DropDownList",y.group="Group",y.repeatingSection="RepeatingSection",y.plainTextInline="PlainTextInline",y.plainTextParagraph="PlainTextParagraph",y.richTextInline="RichTextInline",y.richTextParagraphs="RichTextParagraphs",y.richTextTable="RichTextTable",y.richTextTableCell="RichTextTableCell",y.richTextTableRow="RichTextTableRow",y))(te||{});var Be=["Replace","Start","End"],$e=["Start","End"],He=["Replace","Start","End"],Me=["Before","After"],Fe=["Replace","Start","End","Before","After"],Ve=["Select","Start","End"];function lt(o,t,e){return (typeof o!="string"||!t.includes(o))&&a({code:"InvalidArgument",target:e}),o}var be=(o,t)=>lt(o,Be,t),ye=(o,t)=>lt(o,$e,t),xe=(o,t)=>lt(o,He,t),Ce=(o,t)=>lt(o,Me,t),Pt=(o,t)=>lt(o,Fe,t),Bt=(o,t)=>o===void 0?"Select":lt(o,Ve,t);function k(o,t){return typeof o!="string"&&a({code:"InvalidArgument",target:t}),/[\r\n\v\f\u2028\u2029]/.test(o)&&a({code:"InvalidArgument",target:t}),o}var We=8,ne=(d=>(d.custom="Custom",d.solid="Solid",d.hollow="Hollow",d.square="Square",d.diamonds="Diamonds",d.arrow="Arrow",d.checkmark="Checkmark",d))(ne||{}),oe=(s=>(s.none="None",s.arabic="Arabic",s.upperRoman="UpperRoman",s.lowerRoman="LowerRoman",s.upperLetter="UpperLetter",s.lowerLetter="LowerLetter",s))(oe||{}),j=class o extends p{#t;#n=new Map;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get paragraphs(){return this.#t??=L.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getListParagraphs",list:this.#o()})),this.#t}getLevelParagraphs(t){let e=`${this.path.label}.getLevelParagraphs`,n=ee(t,e);return L.overListing(this.context,e,this.path,()=>({op:"getListParagraphs",list:this.#o(),level:n}))}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n);e!=="Start"&&e!=="End"&&e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:n});let i=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertListParagraph",list:this.#o(),where:e==="Start"||e==="Before"?"start":"end",text:r}),s=>{i.hydrateAddress({kind:"handle",handle:u(s,n)});}),i}setLevelBullet(t,e,n,r){this.#e(t,{bullet:e,...n===void 0?{}:{charCode:n},...r===void 0?{}:{fontName:r}});}setLevelNumbering(t,e,n){this.#e(t,{numbering:e,...n===void 0?{}:{formatString:[...n]}});}setLevelStartingNumber(t,e){this.#e(t,{startingNumber:e});}setLevelIndents(t,e,n){this.#e(t,{textIndent:e,bulletNumberPictureIndent:n});}#e(t,e){let n=`${this.path.label}.levelFormat`,r=ee(t,n);this.requireUsablePath();let i=this.#n.get(r);if(i){Object.assign(i,e),"bullet"in e&&(delete i.numbering,delete i.formatString),"numbering"in e&&(delete i.bullet,delete i.charCode,delete i.fontName);return}let s={...e};this.#n.set(r,s),this.commandAnswering(n,()=>({op:"setListLevelFormat",list:this.#o(),level:r,format:s}),d=>{m(d,n);},()=>{this.#n.get(r)===s&&this.#n.delete(r);});}onLoad(t){if(!this.selection(t,["id"]).includes("id"))return;let e=`${this.path.label}.id`;this.read(e,()=>({op:"getListId",list:this.#o()}),n=>{this.setLoadedProperty("id",Nt(n,e));});}#o(){return this.requireAddressable(),this.path.handle()}},ct=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getById(t){let e=`${this.path.label}.getById`,n=Ue(t,e),r=this.#t,i=j.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getListById",body:r,id:n}),settle:s=>{i.hydrateAddress({kind:"handle",handle:u(s,e)});}}),i}listing(){return {op:"getLists",body:this.#t}}itemAt(t,e){return j.at(this.context,t,e)}promised(t,e){return j.promised(this.context,t,e)}},ht=class o extends p{static of(t,e,n){return new o(t,c.derived(e,n))}constructor(t,e){super(t,e);}get level(){return this.loadedProperty("level")}set level(t){let e=`${this.path.label}.level`,n=ee(t,e);this.commandAnswering(e,()=>({op:"setListLevel",paragraph:this.#t(),level:n}),r=>{m(r,e);});}onLoad(t){if(!this.selection(t,["level"]).includes("level"))return;let e=`${this.path.label}.level`;this.read(e,()=>({op:"getListLevel",paragraph:this.#t()}),n=>{this.setLoadedProperty("level",Nt(n,e));});}#t(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}};function ee(o,t){return (!Number.isInteger(o)||o<0||o>We)&&a({code:"InvalidArgument",target:t}),o}function Ue(o,t){return (!Number.isInteger(o)||o<=0)&&a({code:"InvalidArgument",target:t}),o}var re=(f=>(f.mixed="Mixed",f.none="None",f.hidden="Hidden",f.dotLine="DotLine",f.single="Single",f.word="Word",f.double="Double",f.thick="Thick",f.dotted="Dotted",f.dottedHeavy="DottedHeavy",f.dashLine="DashLine",f.dashLineHeavy="DashLineHeavy",f.dashLineLong="DashLineLong",f.dashLineLongHeavy="DashLineLongHeavy",f.dotDashLine="DotDashLine",f.dotDashLineHeavy="DotDashLineHeavy",f.twoDotDashLine="TwoDotDashLine",f.twoDotDashLineHeavy="TwoDotDashLineHeavy",f.wave="Wave",f.waveHeavy="WaveHeavy",f.waveDouble="WaveDouble",f))(re||{}),Ge=["bold","italic","color","name","size","underline","strikeThrough","highlightColor","subscript","superscript"],E=class o extends p{#t;#n;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}get bold(){return this.loadedProperty("bold")}set bold(t){this.#e("bold",Ot(t,`${this.path.label}.bold`));}get italic(){return this.loadedProperty("italic")}set italic(t){this.#e("italic",Ot(t,`${this.path.label}.italic`));}get color(){return this.loadedProperty("color")}set color(t){this.#e("color",$t(t,`${this.path.label}.color`));}get name(){return this.loadedProperty("name")}set name(t){this.#e("name",$t(t,`${this.path.label}.name`));}get size(){return this.loadedProperty("size")}set size(t){this.#e("size",ze(t,`${this.path.label}.size`));}get underline(){return this.loadedProperty("underline")}set underline(t){this.#e("underline",$t(t,`${this.path.label}.underline`));}get highlightColor(){return this.loadedProperty("highlightColor")}set highlightColor(t){this.#e("highlightColor",t===null?null:$t(t,`${this.path.label}.highlightColor`));}get strikeThrough(){return this.loadedProperty("strikeThrough")}set strikeThrough(t){this.#e("strikeThrough",Ot(t,`${this.path.label}.strikeThrough`));}get subscript(){return this.loadedProperty("subscript")}set subscript(t){this.#e("subscript",Ot(t,`${this.path.label}.subscript`));}get superscript(){return this.loadedProperty("superscript")}set superscript(t){this.#e("superscript",Ot(t,`${this.path.label}.superscript`));}onLoad(t){let e=this.selection(t,Ge);if(e.length===0)return;let n=`${this.path.label}.font`;this.read(n,()=>({op:"getFont",span:this.#o()}),r=>{let i=Vt(r,n);for(let s of e)this.setLoadedProperty(s,i[s]);});}#e(t,e){if(this.requireUsablePath(),this.#n){this.#n[t]=e,t==="subscript"&&e===true&&(this.#n.superscript=false),t==="superscript"&&e===true&&(this.#n.subscript=false);return}let n={[t]:e};t==="subscript"&&e===true&&(n.superscript=false),t==="superscript"&&e===true&&(n.subscript=false),this.#n=n;let r=`${this.path.label}.${t}`;this.commandAnswering(this.path.label,()=>({op:"setFont",span:this.#o(),font:n}),i=>{m(i,r);},()=>{this.#n===n&&(this.#n=void 0);});}#o(){return this.requireAddressable(),O(this.path,this.#t)}};function Ot(o,t){return typeof o!="boolean"&&a({code:"InvalidArgument",target:t}),o}function ze(o,t){return (typeof o!="number"||!Number.isFinite(o))&&a({code:"InvalidArgument",target:t}),o}function $t(o,t){return (typeof o!="string"||o.length===0)&&a({code:"InvalidArgument",target:t}),o}var Qe=16,w=class o extends p{#t;#n;#e;#o;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get uniqueLocalId(){return this.loadedProperty("uniqueLocalId")}get style(){return this.loadedProperty("style")}set style(t){this.#i("style",at(t,`${this.path.label}.style`));}get font(){return this.#t??=E.of(this.context,`${this.path.label}.font`,this.path,"paragraph"),this.#t}get alignment(){return this.loadedProperty("alignment")}set alignment(t){this.#i("alignment",Ke(t,`${this.path.label}.alignment`));}get firstLineIndent(){return this.loadedProperty("firstLineIndent")}set firstLineIndent(t){this.#i("firstLineIndent",pt(t,`${this.path.label}.firstLineIndent`));}get leftIndent(){return this.loadedProperty("leftIndent")}set leftIndent(t){this.#i("leftIndent",pt(t,`${this.path.label}.leftIndent`));}get rightIndent(){return this.loadedProperty("rightIndent")}set rightIndent(t){this.#i("rightIndent",pt(t,`${this.path.label}.rightIndent`));}get lineSpacing(){return this.loadedProperty("lineSpacing")}set lineSpacing(t){this.#i("lineSpacing",pt(t,`${this.path.label}.lineSpacing`));}get spaceBefore(){return this.loadedProperty("spaceBefore")}set spaceBefore(t){this.#i("spaceBefore",pt(t,`${this.path.label}.spaceBefore`));}get spaceAfter(){return this.loadedProperty("spaceAfter")}set spaceAfter(t){this.#i("spaceAfter",pt(t,`${this.path.label}.spaceAfter`));}get list(){return this.#n??=this.#s(`${this.path.label}.list`),this.#n}getRange(t="Whole"){let e=`${this.path.label}.getRange`;["Whole","Content","Start","End","Before","After"].includes(t)||a({code:"InvalidArgument",target:e});let n=b.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{paragraph:this.#r()},location:t}),r=>{n.hydrateAddress({kind:"span",span:R(r,e)});}),n}startNewList(){let t=`${this.path.label}.startNewList`,e=j.promised(this.context,t,false);return this.commandAnswering(t,()=>({op:"startNewList",paragraph:this.#r()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),e}attachToList(t,e){let n=`${this.path.label}.attachToList`;(!Number.isSafeInteger(t)||t<=0||!Number.isInteger(e)||e<0||e>8)&&a({code:"InvalidArgument",target:n});let r=j.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"attachToList",paragraph:this.#r(),listId:t,level:e}),i=>{r.hydrateAddress({kind:"handle",handle:u(i,n)});}),r}detachFromList(){let t=`${this.path.label}.detachFromList`;this.commandAnswering(t,()=>({op:"detachFromList",paragraph:this.#r()}),e=>{m(e,t);});}get listItem(){return this.#e??=ht.of(this.context,`${this.path.label}.listItem`,this.path),this.#e}clear(){this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{paragraph:this.#r()},text:""}));}delete(){this.command("delete",()=>({op:"deleteParagraph",paragraph:this.#r()}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=xe(e,n),s=b.promised(this.context,n,false);return this.commandAnswering(n,()=>i==="Replace"?{op:"replaceSpan",span:{paragraph:this.#r()},text:r}:{op:"insertText",at:{paragraph:this.#r(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:R(d,n)});}),s}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n),i=Ce(e,n),s=o.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:this.#r()},where:i==="Before"?"before":"after",text:r}),d=>{d.kind!=="handle"&&a({code:"GeneralException",target:n}),s.hydrateAddress({kind:"handle",handle:d.handle});}),s}split(t,e,n){let r=`${this.path.label}.split`,i=Ze(t,r),s=ve(e,`${r}.trimDelimiters`),d=ve(n,`${r}.trimSpacing`),h=N.answered(this.context,r,this.path);return this.commandAnswering(r,()=>({op:"splitParagraph",paragraph:this.#r(),delimiters:i,...s?{trimDelimiters:true}:{},...d?{trimSpacing:true}:{}}),A=>{h.fill(A,r);}),h}onLoad(t){let e=this.selection(t,["text","uniqueLocalId",...Ae]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#r(),projection:this.revisionTextView()})),e.includes("uniqueLocalId")&&this.loadTextInto("uniqueLocalId",()=>({op:"getParagraphId",paragraph:this.#r()}));let n=Ae.filter(i=>e.includes(i));if(n.length===0)return;let r=`${this.path.label}.paragraphFormat`;this.read(r,()=>({op:"getParagraphFormat",paragraph:{paragraph:this.#r()}}),i=>{let s=Wt(i,r);for(let d of n)this.setLoadedProperty(d,s[d]);});}#i(t,e){if(this.requireUsablePath(),this.#o){this.#o[t]=e;return}let n={[t]:e};this.#o=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.paragraphFormat`,()=>({op:"setParagraphFormat",paragraph:{paragraph:this.#r()},format:n}),i=>{m(i,r);},()=>{this.#o===n&&(this.#o=void 0);});}#s(t){let e=j.promised(this.context,t,false);return this.read(t,()=>({op:"getParagraphList",paragraph:this.#r()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),e}#r(){return this.requireAddressable(),this.path.handle()}},Ae=["style","alignment","firstLineIndent","leftIndent","rightIndent","lineSpacing","spaceBefore","spaceAfter"],Xe=["Left","Centered","Right","Justified"];function Ke(o,t){return Xe.includes(o)||a({code:"InvalidArgument",target:t}),o}function pt(o,t){return (typeof o!="number"||!Number.isFinite(o))&&a({code:"InvalidArgument",target:t}),o}function Ze(o,t){(!Array.isArray(o)||o.length===0||o.length>Qe)&&a({code:"InvalidArgument",target:t});for(let e of o)(typeof e!="string"||e.length===0)&&a({code:"InvalidArgument",target:t});return [...o]}function ve(o,t){return o!==void 0&&typeof o!="boolean"&&a({code:"InvalidArgument",target:t}),o===true}var L=class o extends T{#t;static of(t,e,n){return new o(t,c.derived(e,n),null)}static overListing(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){if(this.#t)return this.#t();let t=this.path.address();return t.kind==="handle"?{op:"getParagraphs",body:t.handle}:{op:"getSpanParagraphs",span:t.span}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return w.at(this.context,t,e)}promised(t,e){return w.promised(this.context,t,e)}},N=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}static answered(t,e,n){return new o(t,c.derived(e,n),null)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t?this.#t():null}size(t,e){return Et(t,e).length}addressAt(t,e,n){let r=Et(t,e)[n];return r?{kind:"span",span:r}:void 0}itemAt(t,e){return b.at(this.context,t,e)}promised(t,e){return b.promised(this.context,t,e)}};var Pe=4096,D=class o extends p{#t;#n=new Map;#e;#o;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get tag(){return this.loadedProperty("tag")}set tag(t){this.#s("tag",{tag:ie(t,`${this.path.label}.tag`)});}get title(){return this.loadedProperty("title")}set title(t){this.#s("title",{title:ie(t,`${this.path.label}.title`)});}get subtype(){return this.loadedProperty("subtype")}get isBound(){return this.loadedProperty("isBound")}get cannotDelete(){let t=this.loadedProperty("lock");return t==="sdtLocked"||t==="sdtContentLocked"}set cannotDelete(t){this.#r("cannotDelete",t);}get cannotEdit(){let t=this.loadedProperty("lock");return t==="contentLocked"||t==="sdtContentLocked"}set cannotEdit(t){this.#r("cannotEdit",t);}get placeholderShown(){return this.loadedProperty("placeholderShown")}get temporary(){return this.loadedProperty("temporary")}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#e??=L.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getContentControlParagraphs",contentControl:this.#a()})),this.#e}get contentControls(){return this.#o??=B.of(this.context,`${this.path.label}.contentControls`,this.path,{contentControl:this.#a()}),this.#o}getRange(t){let e=`${this.path.label}.getRange`,n=Ye(t??"Whole",e),r=this.#n.get(n);if(r)return r;let i=this.#i(e,n);return this.#n.set(n,i),i}setValue(t){let e=`${this.path.label}.setValue`,n=Je(t,e);this.command("setValue",()=>({op:"setContentControlValue",contentControl:this.#a(),value:n}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=e==="Replace"?"replace":e==="Start"?"start":e==="End"?"end":a({code:"InvalidArgument",target:n}),s=b.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertContentControlText",contentControl:this.#a(),text:r,at:i}),d=>{s.hydrateAddress({kind:"span",span:R(d,n)});}),s}delete(t){let e=`${this.path.label}.delete`;typeof t!="boolean"&&a({code:"InvalidArgument",target:e}),this.command("delete",()=>({op:"deleteContentControl",contentControl:this.#a(),keepContent:t}));}onLoad(t){let e=this.selection(t,["id","tag","title","subtype","isBound","text","cannotDelete","cannotEdit","placeholderShown","temporary"]);if(e.includes("id")&&this.loadTextInto("id",()=>({op:"getContentControlFileId",contentControl:this.#a()})),e.includes("tag")&&this.loadTextInto("tag",()=>({op:"getContentControlTag",contentControl:this.#a()})),e.includes("title")&&this.loadTextInto("title",()=>({op:"getContentControlTitle",contentControl:this.#a()})),e.includes("subtype")&&this.loadTextInto("subtype",()=>({op:"getContentControlSubtype",contentControl:this.#a()})),e.includes("isBound")){let r=`${this.path.label}.isBound`;this.read(r,()=>({op:"getContentControlIsBound",contentControl:this.#a()}),i=>{this.setLoadedProperty("isBound",_(i,r));});}if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getContentControlText",contentControl:this.#a(),projection:this.revisionTextView()})),e.includes("cannotDelete")||e.includes("cannotEdit")){let r=`${this.path.label}.lock`;this.read(r,()=>({op:"getContentControlLock",contentControl:this.#a()}),i=>{this.setLoadedProperty("lock",P(i,r));});}if(e.includes("placeholderShown")){let r=`${this.path.label}.placeholderShown`;this.read(r,()=>({op:"getContentControlPlaceholderShown",contentControl:this.#a()}),i=>{this.setLoadedProperty("placeholderShown",_(i,r));});}if(!e.includes("temporary"))return;let n=`${this.path.label}.temporary`;this.read(n,()=>({op:"getContentControlTemporary",contentControl:this.#a()}),r=>{this.setLoadedProperty("temporary",_(r,n));});}#i(t,e){let n=b.promised(this.context,t,false);return this.read(t,()=>({op:"getContentControlRange",contentControl:this.#a(),location:e}),r=>{n.hydrateAddress({kind:"span",span:R(r,t)});}),n}#s(t,e){this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#a(),...e}));}#r(t,e){let n=`${this.path.label}.${t}`;if(typeof e!="boolean"&&a({code:"InvalidArgument",target:n}),this.requireUsablePath(),this.#t){this.#t[t]=e;return}let r={[t]:e};this.#t=r,this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#a(),...r}),()=>{this.#t===r&&(this.#t=void 0);});}#a(){return this.requireAddressable(),this.path.handle()}},B=class o extends x{#t;#n;static of(t,e,n,r){return new o(t,c.derived(e,n),r,()=>({op:"getContentControls",scope:r}))}constructor(t,e,n,r){super(t,e),this.#t=n,this.#n=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getById(t){let e=`${this.path.label}.getById`;Number.isInteger(t)||a({code:"InvalidArgument",target:e});let n=this.#t,r=D.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getContentControlById",scope:n,id:t}),settle:i=>{r.hydrateAddress({kind:"handle",handle:u(i,e)});}}),r}getByTag(t){let e=`${this.path.label}.getByTag`,n=Re(t,e),r=this.#t;return new o(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTag",scope:r,tag:n}))}getByTitle(t){let e=`${this.path.label}.getByTitle`,n=Re(t,e),r=this.#t;return new o(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTitle",scope:r,title:n}))}listing(){return this.#n()}itemAt(t,e){return D.at(this.context,t,e)}promised(t,e){return D.promised(this.context,t,e)}};function ie(o,t){return (typeof o!="string"||o.length>Pe)&&a({code:"InvalidArgument",target:t}),o}function Re(o,t){let e=ie(o,t);return e.length===0&&a({code:"InvalidArgument",target:t}),e}function Ye(o,t){switch(o){case "Whole":return "whole";case "Content":return "content";case "Start":return "start";case "End":return "end";case "Before":return "before";case "After":return "after";default:return a({code:"InvalidArgument",target:t})}}function Je(o,t){(typeof o!="object"||o===null)&&a({code:"InvalidArgument",target:t});let e=o;if(e.kind==="text"||e.kind==="listItem"){let n=e.kind==="text"?e.text:e.value;return (typeof n!="string"||n.length>Pe)&&a({code:"InvalidArgument",target:t}),e.kind==="text"?{kind:"text",text:n}:{kind:"listItem",value:n}}if(e.kind==="checkbox")return typeof e.checked!="boolean"&&a({code:"InvalidArgument",target:t}),{kind:"checkbox",checked:e.checked};if(e.kind==="date")return (typeof e.iso!="string"||e.iso.length>64)&&a({code:"InvalidArgument",target:t}),{kind:"date",iso:e.iso};a({code:"InvalidArgument",target:t});}function _e(o,t){return t<1||t>12?0:t===2?o%4===0&&o%100!==0||o%400===0?29:28:t===4||t===6||t===9||t===11?30:31}function Oe(o){if(o.length===0)return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/.exec(o.trim());if(!t)return null;let e=Number(t[1]),n=Number(t[2]),r=Number(t[3]),i=_e(e,n);if(e===0||i===0||r<1||r>i)return null;let s=Number(t[4]),d=Number(t[5]),h=Number(t[6]);if(s>23||d>59||h>59)return null;let A=t[7],K=A===void 0?0:Number(A.padEnd(3,"0").slice(0,3));if(Number.isNaN(K))return null;let rt=`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}.${String(K).padStart(3,"0")}Z`,Lt=Date.parse(rt);if(Number.isNaN(Lt))return null;let g=t[8];if(g==="Z")return new Date(Lt);let Z=Number(g.slice(1,3)),it=Number(g.slice(4,6));if(it>59||Z>14||Z===14&&it!==0)return null;let Ft=g[0]==="+"?1:-1,wt=new Date(Lt-Ft*(Z*36e5+it*6e4));return Number.isNaN(wt.getTime())?null:wt}var Ht=class extends p{hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get authorName(){return this.loadedProperty("authorName")}get creationDate(){return this.loadedProperty("creationDate")}get id(){return this.loadedProperty("id")}get text(){return this.loadedProperty("text")}delete(){this.command("delete",()=>({op:"deleteComment",comment:this.commentHandle()}));}loadCommentFields(t,e){let n=this.selection(t,["authorName","creationDate","id","text",...e]);if(n.includes("authorName")&&this.loadTextInto("authorName",()=>({op:"getCommentAuthor",comment:this.commentHandle()})),n.includes("text")&&this.loadTextInto("text",()=>({op:"getCommentText",comment:this.commentHandle()})),n.includes("id")&&this.loadTextInto("id",()=>({op:"getCommentId",comment:this.commentHandle()})),n.includes("creationDate")){let i=`${this.path.label}.creationDate`;this.read(i,()=>({op:"getCommentDate",comment:this.commentHandle()}),s=>{this.setLoadedProperty("creationDate",Oe(P(s,i)));});}if(!n.includes("resolved"))return;let r=`${this.path.label}.resolved`;this.read(r,()=>({op:"getCommentResolved",comment:this.commentHandle()}),i=>{this.setLoadedProperty("resolved",_(i,r));});}commentHandle(){return this.requireAddressable(),this.path.handle()}},nt=class o extends Ht{static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}onLoad(t){this.loadCommentFields(t,[]);}},It=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return nt.at(this.context,t,e)}promised(t,e){return nt.promised(this.context,t,e)}},G=class o extends Ht{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}get resolved(){return this.loadedProperty("resolved")}set resolved(t){let e=`${this.path.label}.resolved`;typeof t!="boolean"&&a({code:"InvalidArgument",target:e}),this.commandAnswering(e,()=>({op:"setCommentResolved",comment:this.commentHandle(),resolved:t}),n=>{m(n,e);});}get replies(){return this.#t??=It.of(this.context,`${this.path.label}.replies`,this.path,()=>({op:"getCommentReplies",comment:this.commentHandle()})),this.#t}getRange(){let t=`${this.path.label}.getRange`,e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getCommentRange",comment:this.commentHandle()}),n=>{e.hydrateAddress({kind:"span",span:R(n,t)});}),e}reply(t){let e=`${this.path.label}.reply`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&a({code:"NotSupported",target:e});let r=nt.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"replyToComment",comment:this.commentHandle(),text:t,author:n}),i=>{r.hydrateAddress({kind:"handle",handle:u(i,e)});}),r}onLoad(t){this.loadCommentFields(t,["resolved"]);}},z=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return G.at(this.context,t,e)}promised(t,e){return G.promised(this.context,t,e)}},et=class o extends p{static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get author(){return this.loadedProperty("author")}get date(){return this.loadedProperty("date")}get type(){return this.loadedProperty("type")}get range(){let t=`${this.path.label}.range`,e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getRevisionRange",revision:this.#t()}),n=>{e.hydrateAddress({kind:"span",span:R(n,t)});}),e}accept(){this.command("accept",()=>({op:"acceptRevision",revision:this.#t()}));}reject(){this.command("reject",()=>({op:"rejectRevision",revision:this.#t()}));}onLoad(t){let e=this.selection(t,["author","date","type"]);if(e.includes("author")&&this.loadTextInto("author",()=>({op:"getRevisionAuthor",revision:this.#t()})),e.includes("type")&&this.loadTextInto("type",()=>({op:"getRevisionType",revision:this.#t()})),!e.includes("date"))return;let n=`${this.path.label}.date`;this.read(n,()=>({op:"getRevisionDate",revision:this.#t()}),r=>{this.setLoadedProperty("date",Oe(P(r,n)));});}static batchHandle(t,e){return (!(t instanceof o)||t.context!==e)&&a({code:"InvalidArgument",target:"RevisionCollection.resolve"}),t.#t()}#t(){return this.requireAddressable(),this.path.handle()}},Q=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}acceptAll(){let t=this.#t;this.commandOn("acceptAll",()=>({op:"acceptAllRevisions",body:t}));}rejectAll(){let t=this.#t;this.commandOn("rejectAll",()=>({op:"rejectAllRevisions",body:t}));}resolve(t,e){let n=`${this.path.label}.resolve`;(!["accept","reject"].includes(t)||e!==void 0&&!Array.isArray(e))&&a({code:"InvalidArgument",target:n});let r=e===void 0?void 0:[...e],{result:i,fill:s}=ue(n);return this.enqueue({sort:"write",label:n,plan:()=>({op:"resolveRevisionBatch",body:this.#t,action:t,...r===void 0?{}:{revisions:r.map(d=>et.batchHandle(d,this.context))}}),settle:d=>{d.kind!=="revisionBatch"&&a({code:"GeneralException",target:n}),s(d.result);}}),i}listing(){return {op:"getRevisions",body:this.#t}}itemAt(t,e){return et.at(this.context,t,e)}promised(t,e){return et.promised(this.context,t,e)}commandOn(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:n,plan:e,settle:r=>{m(r,n);}});}};var tn=new Set(["matchCase","matchWholeWord","ignorePunct","ignoreSpace","matchWildcards"]);function Mt(o,t){if(o===void 0)return;typeof o!="object"&&a({code:"InvalidArgument",target:t});for(let[n,r]of Object.entries(o))tn.has(n)||a({code:"InvalidArgument",target:`${t}.${n}`}),r!==void 0&&typeof r!="boolean"&&a({code:"InvalidArgument",target:`${t}.${n}`});let e={...o.matchCase===void 0?{}:{matchCase:o.matchCase},...o.matchWholeWord===void 0?{}:{matchWholeWord:o.matchWholeWord},...o.ignorePunct===void 0?{}:{ignorePunct:o.ignorePunct},...o.ignoreSpace===void 0?{}:{ignoreSpace:o.ignoreSpace},...o.matchWildcards===void 0?{}:{matchWildcards:o.matchWildcards}};return Object.keys(e).length===0?void 0:e}var b=class o extends p{#t;#n;#e;#o;#i;#s;static at(t,e,n){return n.kind!=="span"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.ofSpan(e,n.span),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="span"?this.path.resolveToSpan(t.span):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get font(){return this.#i??=E.of(this.context,`${this.path.label}.font`,this.path,"span"),this.#i}get paragraphs(){return this.#o??=L.of(this.context,`${this.path.label}.paragraphs`,this.path),this.#o}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=at(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:O(this.path,"span"),name:n}));}get hyperlink(){return this.loadedProperty("hyperlink")}set hyperlink(t){let e=`${this.path.label}.hyperlink`;(typeof t!="string"||t.length>2048)&&a({code:"InvalidArgument",target:e}),this.requireUsablePath(),this.command("hyperlink",()=>({op:"setHyperlink",span:this.#r(),target:t}));}get bookmarks(){let t=this.#r();return this.#s??=X.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{start:t.start,end:t.end}})),this.#s}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&a({code:"InvalidArgument",target:n});let r=Mt(e,n),i=this.#r();return N.of(this.context,n,this.path,()=>({op:"search",scope:i,text:t,options:{...r??{},projection:this.revisionTextView()}}))}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=Pt(e,n);this.requireUsablePath();let s=o.promised(this.context,n,false);return this.commandAnswering(n,()=>{let d=this.#r();return i==="Replace"?{op:"replaceSpan",span:d,text:r}:{op:"insertText",at:i==="Start"||i==="Before"?d.start:d.end,text:r}},d=>{s.hydrateAddress({kind:"span",span:R(d,n)});}),s}delete(){this.requireUsablePath(),this.commandDiscarding("delete",()=>({op:"replaceSpan",span:this.#r(),text:""}));}clear(){let t=this.#r();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:t,text:""}));}insertComment(t){let e=`${this.path.label}.insertComment`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&a({code:"NotSupported",target:e});let r=G.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertComment",span:this.#r(),text:t,author:n}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:e}),r.hydrateAddress(i);}),r}insertContentControl(t){let e=`${this.path.label}.insertContentControl`,n=t??"RichText";n!=="RichText"&&n!=="PlainText"&&a({code:"NotSupported",target:e});let r=D.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertContentControl",span:this.#r(),subtype:n==="PlainText"?"plainText":"richText",returnHandle:true}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:e}),r.hydrateAddress(i);}),r}get tables(){return this.requireUsablePath(),this.#t??=U.over(this.context,`${this.path.label}.tables`,this.path,()=>O(this.path,"span"))}get fields(){return this.requireUsablePath(),this.#n??=M.of(this.context,`${this.path.label}.fields`,this.path,"span")}insertField(t,e,n,r){let i=`${this.path.label}.insertField`;(e!==void 0&&typeof e!="string"||n!==void 0&&typeof n!="string"||r!==void 0&&typeof r!="boolean")&&a({code:"InvalidArgument",target:i});let s=Pt(t,i);this.requireUsablePath();let d=H.promised(this.context,i,false);return this.commandAnswering(i,()=>({op:"insertField",span:this.#r(),location:s,...e===void 0?{}:{fieldType:e},...n===void 0?{}:{text:n},...r===void 0?{}:{removeFormatting:r}}),h=>d.hydrateAddress({kind:"handle",handle:u(h,i)})),d}get inlinePictures(){return this.requireUsablePath(),this.#e??=V.of(this.context,`${this.path.label}.inlinePictures`,this.path,"span")}insertInlinePictureFromBase64(t,e){let n=`${this.path.label}.insertInlinePictureFromBase64`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:n});let r=Pt(e,n);this.requireUsablePath();let i=F.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertInlinePicture",span:this.#r(),base64:t,location:r}),s=>{i.hydrateAddress({kind:"handle",handle:u(s,n)});}),i}insertBreak(t,e){let n=`${this.path.label}.insertBreak`;e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:n});let r=e;this.requireUsablePath(),this.commandAnswering(n,()=>({op:"insertBreak",span:this.#r(),breakType:t,location:r}),i=>m(i,n));}insertTable(t,e,n,r){let i=`${this.path.label}.insertTable`;(!Number.isInteger(t)||!Number.isInteger(e)||t<1||e<1||!["Before","After"].includes(n))&&a({code:"InvalidArgument",target:i}),r!==void 0&&(!Array.isArray(r)||r.some(h=>!Array.isArray(h)||h.some(A=>typeof A!="string")))&&a({code:"InvalidArgument",target:i});let s=r?.map(h=>[...h]),d=W.promised(this.context,i);return this.commandAnswering(i,()=>({op:"insertTable",span:O(this.path,"span"),location:n,rowCount:t,columnCount:e,...s?{values:s}:{}}),h=>{h.kind!=="handle"&&a({code:"GeneralException",target:i}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n),i=Pt(e,n);i!=="Before"&&i!=="After"&&a({code:"InvalidArgument",target:n});let s=this.#r(),d=i==="Before"?s.start.paragraph:s.end.paragraph,h=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:d},where:i==="Before"?"before":"after",text:r}),A=>{A.kind!=="handle"&&a({code:"GeneralException",target:n}),h.hydrateAddress({kind:"handle",handle:A.handle});}),h}select(t){let e=`${this.path.label}.select`,n=Bt(t,e);this.requireAddressable(),this.internals.capabilities.selection||a({code:"NotSupported",target:e});let r=this.#r();this.command("select",()=>({op:"selectSpan",span:r,mode:n==="Select"?"select":n==="Start"?"start":"end"}));}onLoad(t){let e=this.selection(t,["text","style","hyperlink"]);if(e.includes("hyperlink")&&this.loadTextInto("hyperlink",()=>({op:"getHyperlink",span:this.#r()})),e.includes("text")){let r=`${this.path.label}.text`;this.read(r,()=>({op:"getSpanText",span:this.#r(),projection:this.revisionTextView()}),i=>{this.setLoadedProperty("text",P(i,r));});}if(!e.includes("style"))return;let n=`${this.path.label}.style`;this.requireUsablePath(),this.read(n,()=>({op:"getStyle",span:O(this.path,"span")}),r=>{this.setLoadedProperty("style",xt(r,n));});}#r(){return this.requireAddressable(),this.path.span()}};var ut=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get name(){return this.loadedProperty("name")}get range(){return this.#t??=this.#n(`${this.path.label}.range`),this.#t}select(t){let e=`${this.path.label}.select`,n=Bt(t,e);this.requireUsablePath(),this.internals.capabilities.selection||a({code:"NotSupported",target:e}),this.command("select",()=>({op:"selectBookmark",bookmark:this.#e(),mode:n==="Select"?"select":n==="Start"?"start":"end"}));}onLoad(t){if(!this.selection(t,["name"]).includes("name"))return;let e=`${this.path.label}.name`;this.read(e,()=>({op:"getBookmarkName",bookmark:this.#e()}),n=>{this.setLoadedProperty("name",P(n,e));});}#n(t){let e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getBookmarkRange",bookmark:this.#e()}),n=>{e.hydrateAddress({kind:"span",span:R(n,t)});}),e}#e(){return this.requireAddressable(),this.path.handle()}},X=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}listing(){return this.#t()}itemAt(t,e){return ut.at(this.context,t,e)}promised(t,e){return ut.promised(this.context,t,e)}};var I=class o extends p{#t;#n;#e;#o;#i;#s;#r;#a;#l;static main(t,e){return new o(t,c.of(e,J(t).roots().body))}static promisedStory(t,e){return new o(t,c.pending(e))}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}constructor(t,e){super(t,e);}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#o??=this.paragraphsUnder(`${this.path.label}.paragraphs`),this.#o}get bookmarks(){let t=this.#d();return this.#i??=X.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{body:t}})),this.#i}get font(){return this.#s??=E.of(this.context,`${this.path.label}.font`,this.path,"body"),this.#s}paragraphsUnder(t){return L.of(this.context,t,this.path)}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=at(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:O(this.path,"body"),name:n}));}get lists(){return this.#r??=ct.of(this.context,`${this.path.label}.lists`,this.path,this.#d()),this.#r}get contentControls(){return this.#a??=B.of(this.context,`${this.path.label}.contentControls`,this.path,{body:this.#d()}),this.#a}getComments(){let t=`${this.path.label}.getComments`,e=this.#d();return z.of(this.context,t,this.path,()=>({op:"getComments",scope:{body:e}}))}get revisions(){return this.#l??=Q.of(this.context,`${this.path.label}.revisions`,this.path,this.#d()),this.#l}getRange(t="Whole"){let e=`${this.path.label}.getRange`;this.requireUsablePath();let n=b.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{body:this.path.handle()},location:t}),r=>{n.hydrateAddress({kind:"span",span:R(r,e)});}),n}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&a({code:"InvalidArgument",target:n});let r=Mt(e,n),i=this.#d();return N.of(this.context,n,this.path,()=>({op:"search",scope:{body:i},text:t,options:{...r??{},projection:this.revisionTextView()}}))}clear(){let t=this.#d();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{body:t},text:""}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=k(t,n),i=be(e,n);this.requireUsablePath();let s=b.promised(this.context,n,false);return this.commandAnswering(n,()=>i==="Replace"?{op:"replaceSpan",span:{body:this.#d()},text:r}:{op:"insertText",at:{body:this.#d(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:R(d,n)});}),s}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=k(t,n),i=ye(e,n),s=this.#d(),d=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{body:s,at:i==="Start"?"first":"last"},where:i==="Start"?"before":"after",text:r}),h=>{h.kind!=="handle"&&a({code:"GeneralException",target:n}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}onLoad(t){let e=this.selection(t,["text","style"]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#d(),projection:this.revisionTextView()})),e.includes("style")&&this.#c();}#c(){let t=`${this.path.label}.style`;this.requireUsablePath(),this.read(t,()=>({op:"getStyle",span:O(this.path,"body")}),e=>{this.setLoadedProperty("style",xt(e,t));});}get fields(){return this.requireUsablePath(),this.#n??=M.of(this.context,`${this.path.label}.fields`,this.path,"body")}get inlinePictures(){return this.requireUsablePath(),this.#e??=V.of(this.context,`${this.path.label}.inlinePictures`,this.path,"body")}get tables(){return this.requireUsablePath(),this.#t??=U.over(this.context,`${this.path.label}.tables`,this.path,()=>({body:this.#d()}))}#d(){return this.requireAddressable(),this.path.handle()}};function en(o){return o==="endnote"?"Endnote":"Footnote"}var mt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get type(){return this.loadedProperty("type")}get text(){return this.loadedProperty("text")}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=I.promisedStory(this.context,t);return this.read(t,()=>({op:"getNoteBody",note:this.#n()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),this.#t=e,e}delete(){this.command("delete",()=>({op:"deleteNote",note:this.#n()}));}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document,r=`${t}.type`,i="footnote",s=c.pending(r);return this.read(r,()=>({op:"getNoteKind",note:this.#n()}),d=>{i=P(d,r)==="endnote"?"endnote":"footnote",s.resolveTo(this.#n());}),this.enqueue({sort:"read",label:t,dependencies:[s],plan:()=>({op:"getNotes",document:n,noteKind:i}),settle:d=>{let h=v(d,t),A=h.findIndex(rt=>rt.ref===this.#n().ref),K=A<0?void 0:h[A+1];K||a({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:K});}}),e}onLoad(t){let e=this.selection(t,["text","type"]);if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getNoteText",note:this.#n(),projection:this.revisionTextView()})),e.includes("type")){let n=`${this.path.label}.type`;this.read(n,()=>({op:"getNoteKind",note:this.#n()}),r=>{this.setLoadedProperty("type",en(P(r,n)));});}}#n(){return this.requireAddressable(),this.path.handle()}},ot=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return mt.at(this.context,t,e)}promised(t,e){return mt.promised(this.context,t,e)}};var nn=Object.freeze({Primary:"default",FirstPage:"first",EvenPages:"even"}),on=["pageWidth","pageHeight","orientation","topMargin","rightMargin","bottomMargin","leftMargin"],kt=class o extends p{#t;static of(t,e,n){return new o(t,c.derived(e,n))}constructor(t,e){super(t,e);}get pageWidth(){return this.loadedProperty("pageWidth")}set pageWidth(t){this.#n("pageWidth",gt(t,`${this.path.label}.pageWidth`));}get pageHeight(){return this.loadedProperty("pageHeight")}set pageHeight(t){this.#n("pageHeight",gt(t,`${this.path.label}.pageHeight`));}get orientation(){return this.loadedProperty("orientation")}set orientation(t){let e=`${this.path.label}.orientation`;t!=="Portrait"&&t!=="Landscape"&&a({code:"InvalidArgument",target:e}),this.#n("orientation",t==="Portrait"?"portrait":"landscape");}get topMargin(){return this.loadedProperty("topMargin")}set topMargin(t){this.#n("topMargin",gt(t,`${this.path.label}.topMargin`));}get bottomMargin(){return this.loadedProperty("bottomMargin")}set bottomMargin(t){this.#n("bottomMargin",gt(t,`${this.path.label}.bottomMargin`));}get leftMargin(){return this.loadedProperty("leftMargin")}set leftMargin(t){this.#n("leftMargin",gt(t,`${this.path.label}.leftMargin`));}get rightMargin(){return this.loadedProperty("rightMargin")}set rightMargin(t){this.#n("rightMargin",gt(t,`${this.path.label}.rightMargin`));}onLoad(t){let e=this.selection(t,on);if(e.length===0)return;let n=`${this.path.label}.pageSetup`;this.read(n,()=>({op:"getPageSetup",section:this.#e()}),r=>{let i=Ut(r,n);for(let s of e)this.setLoadedProperty(s,s==="orientation"?i.orientation==="landscape"?"Landscape":"Portrait":i[s]);});}#n(t,e){if(this.requireUsablePath(),this.#t){this.#t[t]=e;return}let n={[t]:e};this.#t=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.pageSetup`,()=>({op:"setPageSetup",section:this.#e(),setup:n}),i=>{m(i,r);},()=>{this.#t===n&&(this.#t=void 0);});}#e(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},ft=class o extends p{#t;#n;static at(t,e,n){return n.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){return this.#n??=I.main(this.context,`${this.path.label}.body`),this.#n}get pageSetup(){return this.#t??=kt.of(this.context,`${this.path.label}.pageSetup`,this.path),this.#t}getHeader(t){return this.#e("header",t,"getHeader")}getFooter(t){return this.#e("footer",t,"getFooter")}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document;return this.read(t,()=>({op:"getSections",document:n}),r=>{let i=v(r,t),s=i.findIndex(h=>h.ref===this.#o().ref),d=s<0?void 0:i[s+1];d||a({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:d});}),e}onLoad(t){this.selection(t,[]);}#e(t,e,n){let r=`${this.path.label}.${n}`,i=nn[e];i===void 0&&a({code:"InvalidArgument",target:r});let s=I.promisedStory(this.context,r);return this.read(r,()=>({op:"getFurniture",section:this.#o(),kind:t,variant:i}),d=>{s.hydrateAddress({kind:"handle",handle:u(d,r)});}),s}#o(){return this.requireAddressable(),this.path.handle()}},bt=class o extends x{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return ft.at(this.context,t,e)}promised(t,e){return ft.promised(this.context,t,e)}};function gt(o,t){return (typeof o!="number"||!Number.isFinite(o)||o<0)&&a({code:"InvalidArgument",target:t}),o}var yt=class o extends p{#t;#n;#e;#o;#i;#s;#r;#a;static open(t){return new o(t)}constructor(t){super(t,c.of("document",J(t).roots().document));}get changeTrackingMode(){return this.loadedProperty("changeTrackingMode")}set changeTrackingMode(t){["Off","TrackAll","TrackMineOnly"].includes(t)||a({code:"InvalidArgument",target:"document.changeTrackingMode"});let e=this.internals.author;this.commandAnswering("document.changeTrackingMode",()=>({op:"setChangeTrackingMode",mode:t,...e===void 0?{}:{author:e}}),()=>this.setLoadedProperty("changeTrackingMode",t));}get body(){return this.#t??=I.main(this.context,"document.body"),this.#t}get paragraphs(){return this.#n??=this.body.paragraphsUnder("document.paragraphs"),this.#n}get sections(){let t=this.path.handle();return this.#e??=bt.of(this.context,"document.sections",this.path,()=>({op:"getSections",document:t})),this.#e}get contentControls(){return this.#s??=B.of(this.context,"document.contentControls",this.path,{body:this.internals.roots().body}),this.#s}get comments(){return this.#o??=z.of(this.context,"document.comments",this.path,()=>({op:"getComments",scope:{body:this.internals.roots().body}})),this.#o}get revisions(){return this.#i??=Q.of(this.context,"document.revisions",this.path,this.internals.roots().body),this.#i}get footnotes(){let t=this.path.handle();return this.#r??=ot.of(this.context,"document.footnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"footnote"})),this.#r}get endnotes(){let t=this.path.handle();return this.#a??=ot.of(this.context,"document.endnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"endnote"})),this.#a}onLoad(t){if(t.select.length===0)return;this.selection(t,["changeTrackingMode"]).includes("changeTrackingMode")&&this.loadTextInto("changeTrackingMode",()=>({op:"getChangeTrackingMode"}));}};function ke(o){let t=o.host,e=Object.freeze({...t.capabilities,save:o.save&&t.capabilities.save}),n=typeof o.author=="string"&&o.author.trim().length>0?o.author:void 0,r=o.revisionTextView??"allMarkup";r!=="allMarkup"&&r!=="original"&&a({code:"InvalidArgument",target:"revisionTextView"});let i=false,s=null,d=g=>{i&&a({code:"RuntimeDisposed",...g===void 0?{}:{target:g}});},h=()=>{if(s)return s;d("document");let g=Ie(t.execute({operations:[{op:"getDocument"}]}),"document"),Z=Ie(t.execute({operations:[{op:"getBody",document:g}]}),"document.body");return s={document:g,body:Z},s},A={host:t,capabilities:e,...n===void 0?{}:{author:n},revisionTextView:r,id:{},roots:h,assertLive:d,openDocument:g=>yt.open(g)};try{h();}catch{s=null;}async function K(g,Z){d();let it=typeof g=="function"?g:Z,Ft=typeof g=="function"?[]:Array.isArray(g)?g:[g];typeof it!="function"&&a({code:"InvalidArgument",target:"run"});let{context:wt,adopt:y,finish:we}=At.begin(A);try{return y(Ft),await it(wt)}finally{we();}}let rt={capabilities:e,run:K,dispose(){i||(i=true,s=null,t.dispose());}};return o.save?{...rt,async save(){d("save"),e.save||a({code:"NotSupported",target:"save"});let g=t.save();if(!g.ok)throw qt(g.error,{target:"save"});return g.bytes}}:rt}function Ie(o,t){let e=o.results[0];if(e?.status==="error")throw qt(e.error,{target:t});if(e?.status!=="ok")throw new C({code:"GeneralException",target:t});return u(e.value,t)}function an(o){if(o){for(let t of o)if(t.collaboration)return t.collaboration}}function sn(o){let t=[o?.zip?.maxEntries,o?.zip?.maxTotalBytes,o?.xml?.maxBytes,o?.xml?.maxElements,o?.maxXmlParts,o?.maxRelationships],e=o?.zip?.maxRatio;(t.some(n=>n!==void 0&&(!Number.isInteger(n)||n<0))||e!==void 0&&(!Number.isFinite(e)||e<0))&&a({code:"InvalidArgument",target:"createServer"});}async function ae(o,t={}){sn(t.limits);let e=an(t.modules),n=createServerAutomationHost(o,{...t.pagination?{pagination:de(t.pagination)}:{},...t.limits===void 0?{}:{limits:t.limits},...e===void 0?{}:{collaborationModel:e}});if(!n.ok){let r={"too-many-entries":"zip.maxEntries","too-large":"xml.maxBytes","too-many-elements":"xml.maxElements","too-deep":"xml.maxDepth","too-many-xml-parts":"maxXmlParts","too-many-relationships":"maxRelationships"},i=n.limit??r[n.reason];a({code:i===void 0?"InvalidArgument":"ResourceLimitExceeded",target:"createServer",...i===void 0?{}:{limit:i}});}return ke({host:n.host,save:true,...t.author===void 0?{}:{author:t.author},...t.revisionTextView===void 0?{}:{revisionTextView:t.revisionTextView}})}function Le(o,t,e={}){return ae(o,{...e,modules:[...e.modules??[],{id:"collaboration",collaboration:{session:t}}]})}var se=(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))(se||{});var Vi=Object.freeze({createServer:ae,createCollaborative:Le});export{Kt as Alignment,I as Body,ut as Bookmark,X as BookmarkCollection,_t as BreakType,Yt as ChangeTrackingMode,$ as ClientObject,Tt as ClientResult,G as Comment,z as CommentCollection,nt as CommentReply,It as CommentReplyCollection,D as ContentControl,B as ContentControlCollection,te as ContentControlType,yt as Document,Vi as DocxEditor,C as DocxEditorError,H as Field,M as FieldCollection,se as FieldType,E as Font,F as InlinePicture,V as InlinePictureCollection,Xt as InsertLocation,j as List,ne as ListBullet,ct as ListCollection,ht as ListItem,oe as ListNumbering,mt as NoteItem,ot as NoteItemCollection,Zt as PageOrientation,kt as PageSetup,w as Paragraph,L as ParagraphCollection,b as Range,N as RangeCollection,At as RequestContext,et as Revision,Q as RevisionCollection,ft as Section,bt as SectionCollection,W as Table,tt as TableCell,Rt as TableCellCollection,U as TableCollection,st as TableRow,dt as TableRowCollection,Ct as TrackedObjects,re as UnderlineType,Jt as VerticalAlignment,je as isDocxEditorError};
@@ -1,4 +1,4 @@
1
- import { AutomationHandle, AutomationSpan, AutomationOperation, AutomationValue, AutomationSpanRef, AutomationHost, AutomationCapabilities, AutomationPaginationOptions } from '@docx-editor.dev/core/automation';
1
+ import { AutomationHandle, AutomationSpan, AutomationOperation, AutomationValue, AutomationSpanRef, RevisionBatchResult, AutomationHost, AutomationCapabilities, AutomationPaginationOptions } from '@docx-editor.dev/core/automation';
2
2
  import { CollaborationModuleContribution } from '@docx-editor.dev/core/collaboration';
3
3
 
4
4
  /** Locations used by Office-shaped insertion calls. Each call validates its allowed subset. @public */
@@ -1025,6 +1025,39 @@ declare class ContentControlCollection extends HandleCollection<ContentControl>
1025
1025
  protected promised(label: string, nullable: boolean): ContentControl & PromisedItem;
1026
1026
  }
1027
1027
 
1028
+ /**
1029
+ * A value a queued method promised to produce, readable after the next `sync()`.
1030
+ *
1031
+ * Deliberately not a `Promise`. A method call inside a batch has not been sent yet, so there is
1032
+ * no pending work to await and nothing that could resolve on its own — awaiting one would
1033
+ * deadlock a consumer who then never calls `sync()`. A result is a box that stays EMPTY until the
1034
+ * sync fills it, and reading it early is `ValueNotLoaded` rather than `undefined` flowing onwards
1035
+ * into something that misinterprets it.
1036
+ *
1037
+ * RevisionCollection.resolve returns a ClientResult with the resolved and skipped decisions.
1038
+ *
1039
+ * @public
1040
+ */
1041
+ declare class ClientResult<T> {
1042
+ #private;
1043
+ /** @internal Use `clientResult()`; only the creator gets the filling half. */
1044
+ private constructor();
1045
+ /**
1046
+ * The value, once a `sync()` has filled it in.
1047
+ *
1048
+ * Reading before then is `ValueNotLoaded` rather than `undefined`, so a mistake surfaces at the
1049
+ * read instead of flowing onwards into something that misinterprets it.
1050
+ */
1051
+ get value(): T;
1052
+ /** Whether the sync that fills this has happened. */
1053
+ get isLoaded(): boolean;
1054
+ /** @internal The box and the way to fill it, so only the creator can settle it. */
1055
+ static create<T>(target: string): {
1056
+ result: ClientResult<T>;
1057
+ fill: (value: T) => void;
1058
+ };
1059
+ }
1060
+
1028
1061
  /**
1029
1062
  * Word's own names for a kind of change.
1030
1063
  *
@@ -1202,6 +1235,8 @@ declare class Revision extends ModelObject implements PromisedItem {
1202
1235
  reject(): void;
1203
1236
  /** @internal Plan the read this object's `load(...)` asked for. */
1204
1237
  protected onLoad(request: ResolvedLoadOptions): void;
1238
+ /** @internal Capture a batch target without exposing engine identity. */
1239
+ static batchHandle(revision: Revision, context: RequestContext): AutomationHandle;
1205
1240
  }
1206
1241
  /**
1207
1242
  * The tracked changes on a document, story or range, as of the batch that loaded them.
@@ -1228,6 +1263,22 @@ declare class RevisionCollection extends HandleCollection<Revision> {
1228
1263
  acceptAll(): void;
1229
1264
  /** Undo every change, likewise as one decision. */
1230
1265
  rejectAll(): void;
1266
+ /**
1267
+ * Resolve eligible revisions in this story and report skipped decisions after sync.
1268
+ * Omit revisions to include unsupported and structural decisions absent from items.
1269
+ * Pass an empty array to select nothing. Duplicate objects resolve once; stale targets
1270
+ * are reported as unknown-revision. This must be the only write in its sync batch.
1271
+ * Unlike acceptAll/rejectAll, unsupported decisions do not block independent changes.
1272
+ *
1273
+ * @example
1274
+ * ```ts
1275
+ * const result = context.document.revisions.resolve('accept');
1276
+ * await context.sync();
1277
+ * console.log(result.value.resolved.length, result.value.remaining);
1278
+ * for (const skipped of result.value.skipped) console.log(skipped.reason);
1279
+ * ```
1280
+ */
1281
+ resolve(action: 'accept' | 'reject', revisions?: readonly Revision[]): ClientResult<RevisionBatchResult>;
1231
1282
  /** @internal The read that answers this collection's members. */
1232
1283
  protected listing(): AutomationOperation;
1233
1284
  /** @internal Build one member from an address the listing answered. */
@@ -2208,40 +2259,6 @@ declare abstract class ClientObject implements RuntimeManagedObject {
2208
2259
  [REBIND](context: RequestContext): void;
2209
2260
  }
2210
2261
 
2211
- /**
2212
- * A value a queued method promised to produce, readable after the next `sync()`.
2213
- *
2214
- * Deliberately not a `Promise`. A method call inside a batch has not been sent yet, so there is
2215
- * no pending work to await and nothing that could resolve on its own — awaiting one would
2216
- * deadlock a consumer who then never calls `sync()`. A result is a box that stays EMPTY until the
2217
- * sync fills it, and reading it early is `ValueNotLoaded` rather than `undefined` flowing onwards
2218
- * into something that misinterprets it.
2219
- *
2220
- * This is a support type. No current public document method produces a ClientResult.
2221
- * Document collections expose loaded `items`; read their length after `load('items')` and `sync()`.
2222
- *
2223
- * @public
2224
- */
2225
- declare class ClientResult<T> {
2226
- #private;
2227
- /** @internal Use `clientResult()`; only the creator gets the filling half. */
2228
- private constructor();
2229
- /**
2230
- * The value, once a `sync()` has filled it in.
2231
- *
2232
- * Reading before then is `ValueNotLoaded` rather than `undefined`, so a mistake surfaces at the
2233
- * read instead of flowing onwards into something that misinterprets it.
2234
- */
2235
- get value(): T;
2236
- /** Whether the sync that fills this has happened. */
2237
- get isLoaded(): boolean;
2238
- /** @internal The box and the way to fill it, so only the creator can settle it. */
2239
- static create<T>(target: string): {
2240
- result: ClientResult<T>;
2241
- fill: (value: T) => void;
2242
- };
2243
- }
2244
-
2245
2262
  /** What went wrong, as a value a consumer may branch on. */
2246
2263
  type DocxEditorErrorCode =
2247
2264
  /** A property was read before a `load(...)` for it completed in a `sync()`. */