@docx-editor.dev/editor-api 2.27.0 → 2.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OFFICE_JS_GUIDE.md +93 -11
- package/README.md +1 -1
- package/dist/browser.d.mts +3 -4
- package/dist/browser.d.ts +3 -4
- package/dist/browser.js +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{server-CK7TF4z-.d.mts → server-BHhcVU2-.d.mts} +331 -130
- package/dist/{server-CK7TF4z-.d.ts → server-BHhcVU2-.d.ts} +331 -130
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var automation=require('@docx-editor.dev/core/automation');function me(o){return automation.createAutomationPaginationProvider(o)}var ge=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."}),v=class extends Error{code;limit;target;expectedRevision;actualRevision;constructor(t){let e=t.target?`${ge[t.code]} (${t.target})`:ge[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 $e(o){return o instanceof v?true:typeof o=="object"&&o!==null&&o.name==="DocxEditorError"&&typeof o.code=="string"}function i(o){throw new v(o)}var tt=Symbol("docx-editor.runtime.internals"),Nt=Symbol("docx-editor.runtime.release"),qt=Symbol("docx-editor.runtime.rebind");function et(o){return o[tt]}var He=new Set(["select","expand","top","skip"]),Me=/^[A-Za-z][A-Za-z0-9]*$/;function fe(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):i({code:"InvalidArgument",target:t}),n=[];for(let r of e)(typeof r!="string"||!Me.test(r))&&i({code:"InvalidArgument",target:t}),n.includes(r)||n.push(r);return n.length===0&&i({code:"InvalidArgument",target:t}),n}function be(o,t){return (typeof o!="number"||!Number.isInteger(o)||o<0)&&i({code:"InvalidArgument",target:t}),o}function Fe(o,t){o===void 0||Array.isArray(o)&&o.length===0||i({code:"InvalidArgument",target:t});}function ye(o,t){if(o===void 0)return {select:[]};if(typeof o=="string"||Array.isArray(o))return {select:fe(o,t)};(typeof o!="object"||o===null)&&i({code:"InvalidArgument",target:t});let e=o;for(let n of Object.keys(e))He.has(n)||i({code:"InvalidArgument",target:`${t}.${n}`});return Fe(e.expand,`${t}.expand`),{select:fe(e.select,`${t}.select`),...e.top===void 0?{}:{top:be(e.top,`${t}.top`)},...e.skip===void 0?{}:{skip:be(e.skip,`${t}.skip`)}}}var M=class{#t;#e;#n;#o;#s=new Map;#a=false;constructor(t,e,n={}){this.#t=t,this.#e=t[tt],this.#n=e,this.#o=n.nullable===true,this.#e.register(this);}get context(){return this.#t}get isNullObject(){return this.#n.isReleased&&i({code:"InvalidObjectPath",target:this.#n.label}),this.#o?(this.#n.isPending&&i({code:"PropertyNotLoaded",target:`${this.#n.label}.isNullObject`}),this.#n.isNull):false}load(t){this.#a=true;try{return this.requireUsablePath(),this.onLoad(ye(t,this.#n.label)),this}finally{this.#a=false;}}get path(){return this.#n}get internals(){return this.#e}handle(){return this.#n.handle()}requireAddressable(){this.#n.isAddressable||i({code:"InvalidObjectPath",target:this.#n.label}),this.#e.assertUsable(this.#n.label);}requireUsablePath(){(this.#n.isReleased||this.#n.isNull&&!(this.#a&&this.#o))&&i({code:"InvalidObjectPath",target:this.#n.label}),this.#e.assertUsable(this.#n.label);}enqueue(t){this.requireUsablePath(),this.#e.queue.push({...t,dependencies:[...t.dependencies??[],this.#n],...this.#a&&this.#o&&t.sort==="read"?{nullableLoad:this.#n}:{}});}loadedProperty(t){return this.#n.isReleased&&!this.#s.has(t)&&i({code:"InvalidObjectPath",target:this.#n.label}),this.#s.has(t)||i({code:"PropertyNotLoaded",target:`${this.#n.label}.${t}`}),this.#s.get(t)}hasLoadedProperty(t){return this.#s.has(t)}setLoadedProperty(t,e){this.#s.set(t,e);}[Nt](){this.#n.release();}[qt](t){this.#t=t,this.#e=t[tt];}};var Dt=class o{#t=false;#e;#n;constructor(t){this.#n=t;}get value(){return this.#t||i({code:"ValueNotLoaded",target:this.#n}),this.#e}get isLoaded(){return this.#t}static create(t){let e=new o(t);return {result:e,fill(n){e.#t=true,e.#e=n;}}}};function xe(o){return Dt.create(o)}function j(o){return new v({code:"GeneralException",target:o})}function R(o,t){if(o.kind!=="text")throw j(t);return o.text}function u(o,t){if(o.kind!=="handle")throw j(t);return o.handle}function C(o,t){if(o.kind!=="handles")throw j(t);return o.handles}function O(o,t){if(o.kind!=="span")throw j(t);return o.span}function Bt(o,t){if(o.kind!=="spans")throw j(t);return o.spans}function Xt(o,t){if(o.kind!=="font")throw j(t);return o.font}function Kt(o,t){if(o.kind!=="paragraphFormat")throw j(t);return o.format}function Pt(o,t){if(o.kind!=="style")throw j(t);return o.name}function $t(o,t){if(o.kind!=="number")throw j(t);return o.value}function nt(o,t){if(o.kind!=="flag")throw j(t);return o.value}function Zt(o,t){if(o.kind!=="pageSetup")throw j(t);return o.setup}function m(o,t){if(o.kind!=="applied")throw j(t)}var c=class o{label;#t;#e;constructor(t,e,n=null){this.label=t,this.#t=e,this.#e=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.#e?this.#e.state:this.#t}get isAddressable(){return this.state.status==="resolved"}get isPending(){return this.state.status==="pending"}get isNull(){return this.state.status==="null"}get isReleased(){return this.state.status==="released"}address(){let t=this.state;if(t.status==="resolved")return t.address;i({code:"InvalidObjectPath",target:this.label});}handle(){let t=this.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.label}),t.handle}span(){let t=this.address();return t.kind!=="span"&&i({code:"InvalidObjectPath",target:this.label}),t.span}resolveTo(t){this.#n({kind:"handle",handle:t});}resolveToSpan(t){this.#n({kind:"span",span:t});}resolveNull(){this.#t.status!=="released"&&(this.#t={status:"null"});}release(){this.#e||(this.#t={status:"released"});}#n(t){this.#t.status!=="released"&&(this.#t={status:"resolved",address:t});}};function Ce(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 Ve=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 Ht(o,t={}){let e=Ve[o.code]??"GeneralException",n=e==="StaleDocument";return new v({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 Yt(o,t,e){for(let n=0;n<o.results.length;n+=1){let r=o.results[n];if(r?.status!=="error")continue;let s=t[n]?.label;return Ht(r.error,{...s===void 0?{}:{target:s},...e===void 0?{}:{expectedRevision:e},actualRevision:o.revision})}return new v({code:"GeneralException"})}function Jt(o,t){if(t.results.length!==o.length)throw new v({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 v({code:"GeneralException",target:r.label});r.settle(n.value);}}var Mt=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 Ae(o,t){if(Array.isArray(o)){for(let e of o)t(e);return}t(o);}var Rt=class{#t;#e;constructor(t,e){this.#t=t,this.#e=e;}add(t){this.#t.assertUsable(),Ae(t,e=>{this.#n(e),this.#t.track(e);});}remove(t){this.#t.assertUsable(),Ae(t,e=>{this.#n(e),this.#t.untrack(e);});}#n(t){this.#e(t)||i({code:"InvalidObjectPath"});}};var Ot=class o{#t;#e=new Mt;#n=new Set;#o=new Set;#s;#a;#i;#r=false;#d=null;#c=false;constructor(t){this.#t=t,this.#s={host:t.host,capabilities:t.capabilities,...t.author===void 0?{}:{author:t.author},revisionTextView:t.revisionTextView,queue:this.#e,session:t.id,roots:()=>t.roots(),assertUsable:e=>{this.#t.assertLive(e),this.#r&&i({code:"InvalidRequestContext",...e===void 0?{}:{target:e}});},isFinished:()=>this.#r,readRevision:()=>this.#d,register:e=>{this.#n.add(e);},track:e=>{this.#o.add(e);},untrack:e=>{this.#o.delete(e);},isTracked:e=>this.#o.has(e),disown:e=>{this.#n.delete(e),this.#o.delete(e);}},this.#a=new Rt(this.#s,e=>this.#n.has(e));}get document(){return this.#s.assertUsable("document"),this.#i??=this.#t.openDocument(this),this.#i}get capabilities(){return this.#t.capabilities}get trackedObjects(){return this.#a}async sync(){this.#s.assertUsable(),this.#c&&i({code:"InvalidRequestContext"});let t=this.#e.take();if(t.length!==0){this.#c=true;try{let e=t.filter(a=>!a.nullableLoad?.isNull),n=t.some(a=>a.sort==="write"),r,s=a=>a.dependencies?.some(d=>!d.isAddressable)??false;for(;e.some(s);){r??=n&&this.#d!==null?this.#d:this.#t.host.revision();let a=e.filter(h=>h.sort==="read"&&!s(h));a.length===0&&i({code:"InvalidObjectPath",target:e.find(s)?.label}),await this.#h(a,r);let d=new Set(a);e=e.filter(h=>!d.has(h)&&!h.nullableLoad?.isNull);}if(e.length){let a=r??(n&&this.#d!==null?this.#d:void 0);await this.#h(e,a);}}finally{for(let e of t)e.dispose?.();this.#c=false;}}}async#h(t,e){let n=Ce(t),r={operations:n.operations,...e===void 0?{}:{expectedRevision:e}};if(this.#t.host.prepare){let a={...r,expectedRevision:r.expectedRevision??this.#t.host.revision()};await this.#t.host.prepare(a);let d=this.#t.host.execute(a);if(!d.ok)throw Yt(d,t,a.expectedRevision);Jt(t,d),this.#d=d.revision;return}let s=this.#t.host.execute(r);if(!s.ok)throw Yt(s,t,e);Jt(t,s),(n.hasRead||n.hasWrite)&&(this.#d=s.revision);}get[tt](){return this.#s}static begin(t){let e=new o(t);return {context:e,adopt(n){for(let r of n)e.#p(r);},finish(){e.#l();}}}#p(t){let e=t.context;if(e===this)return;let n=e[tt];if(n.session!==this.#t.id)throw new v({code:"InvalidObjectPath"});if(!n.isFinished())throw new v({code:"ObjectInUse"});if(!n.isTracked(t))throw new v({code:"InvalidObjectPath"});let r=n.readRevision();n.disown(t),t[qt](this),this.#n.add(t),this.#o.add(t),r!==null&&this.#u(r);}#u(t){this.#d=this.#d===null?t:Math.min(this.#d,t);}#l(){if(!this.#r){this.#r=true,this.#e.clear();for(let t of this.#n)this.#o.has(t)||t[Nt]();this.#n.clear();}}};function kt(o,t,e){if(o.select.length===0)return t;for(let n of o.select)t.includes(n)||i({code:"InvalidArgument",target:`${e}.${n}`});return o.select}var p=class extends M{revisionTextView(){return et(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,R(r,n));}});}command(t,e,n){let r=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:r,plan:e,settle:s=>m(s,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 kt(t,e,this.path.label)}onLoad(t){this.selection(t,[]);}};var We=["author","title","subject","keywords","comments","category","lastAuthor"],lt=class o extends p{#t;static of(t,e){return new o(t,c.derived("document.properties",e))}constructor(t,e){super(t,e);}get lastAuthor(){return this.loadedProperty("lastAuthor")}get author(){return this.loadedProperty("author")}set author(t){this.#e("author",t);}get title(){return this.loadedProperty("title")}set title(t){this.#e("title",t);}get subject(){return this.loadedProperty("subject")}set subject(t){this.#e("subject",t);}get keywords(){return this.loadedProperty("keywords")}set keywords(t){this.#e("keywords",t);}get comments(){return this.loadedProperty("comments")}set comments(t){this.#e("comments",t);}get category(){return this.loadedProperty("category")}set category(t){this.#e("category",t);}onLoad(t){for(let e of this.selection(t,We))this.read(`${this.path.label}.${e}`,()=>({op:"getDocumentProperty",name:e}),n=>this.setLoadedProperty(e,R(n,this.path.label)));}#e(t,e){if(this.requireUsablePath(),(typeof e!="string"||e.length>4096)&&i({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#t){this.#t[t]=e;return}let n={[t]:e};this.#t=n,this.commandAnswering(this.path.label,()=>({op:"setDocumentProperties",values:n}),r=>{m(r,this.path.label);},()=>{this.#t===n&&(this.#t=void 0);});}};function k(o,t){let e=o.address();return t==="span"?(e.kind!=="span"&&i({code:"InvalidObjectPath",target:o.label}),{start:e.span.start,end:e.span.end}):(e.kind!=="handle"&&i({code:"InvalidObjectPath",target:o.label}),t==="body"?{body:e.handle}:{paragraph:e.handle})}function ct(o,t){return (typeof o!="string"||o.trim().length===0||o.length>255)&&i({code:"InvalidArgument",target:t}),o}var T=class extends M{#t;#e=[];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.#e.splice(0,this.#e.length);for(let r of n)this.#n(r,t);}onLoad(t){kt(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,s=t.top;this.enqueue({sort:"read",label:n,plan:()=>{let a=e??this.listing();return a||i({code:"InvalidObjectPath",target:this.path.label}),a},settle:a=>{this.setLoadedProperty("items",this.#o(a,n,r,s));}});}edge(t,e,n){let r=`${this.path.label}.${e}()`,s=this.promised(r,n),a=this.path.isPending?void 0:this.listing();if(a===null){let d={edge:t,target:r,nullable:n,item:s};return this.#t?this.#n(d,this.#t.value):this.#e.push(d),s}return this.enqueue({sort:"read",label:r,plan:()=>{let d=a??this.listing();return d||i({code:"InvalidObjectPath",target:this.path.label}),d},settle:d=>{this.#n({edge:t,target:r,nullable:n,item:s},d);}}),s}#n(t,e){let{edge:n,target:r,nullable:s,item:a}=t,d=this.size(e,r);if(d===0){s||i({code:"ItemNotFound",target:r}),a.hydrateNull();return}let h=this.addressAt(e,r,n==="first"?0:d-1);h||i({code:"ItemNotFound",target:r}),a.hydrateAddress(h);}#o(t,e,n,r){let s=this.size(t,e),a=r===void 0?s:Math.min(s,n+r),d=[];for(let h=n;h<a;h+=1){let P=this.addressAt(t,e,h);P&&d.push(this.itemAt(`${e}[${String(h)}]`,P));}return d}},A=class extends T{size(t,e){return C(t,e).length}addressAt(t,e,n){let r=C(t,e)[n];return r?{kind:"handle",handle:r}:void 0}};var Ft=(a=>(a.unsupported="Unsupported",a.textBox="TextBox",a.geometricShape="GeometricShape",a.group="Group",a.picture="Picture",a.canvas="Canvas",a))(Ft||{}),Ue=["id","name","type"],ve=new Set(Object.values(Ft)),ht=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({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 name(){return this.loadedProperty("name")}get type(){return this.loadedProperty("type")}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=I.promisedStory(this.context,t);return this.read(t,()=>({op:"getShapeBody",shape:this.#e()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),this.#t=e,e}onLoad(t){let e=this.selection(t,Ue);e.length&&this.read(this.path.label,()=>({op:"getShape",shape:this.#e()}),n=>{(n.kind!=="shape"||!ve.has(n.shape.type))&&i({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.shape[r]);});}#e(){return this.requireAddressable(),this.path.handle()}},F=class o extends T{#t;#e;static of(t,e,n,r,s){return new o(t,c.derived(e,n),r,s)}constructor(t,e,n,r){super(t,e),this.#t=n,this.#e=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getByTypes(t){let e=`${this.path.label}.getByTypes`;(!Array.isArray(t)||t.some(r=>!ve.has(r)))&&i({code:"InvalidArgument",target:e});let n=this.#e?this.#e.filter(r=>t.includes(r)):[...t];return o.of(this.context,e,this.path,this.#t,n)}listing(){let t=k(this.path,this.#t);return this.#e?{op:"getShapes",span:t,types:this.#e}:{op:"getShapes",span:t}}size(t,e){return C(t,e).length}addressAt(t,e,n){let r=C(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return ht.at(this.context,t,e)}promised(t,e){return ht.promised(this.context,t,e)}};function Ge(o){return o==="endnote"?"Endnote":"Footnote"}var pt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({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.#e()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),this.#t=e,e}delete(){this.command("delete",()=>({op:"deleteNote",note:this.#e()}));}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document,r=`${t}.type`,s="footnote",a=c.pending(r);return this.read(r,()=>({op:"getNoteKind",note:this.#e()}),d=>{s=R(d,r)==="endnote"?"endnote":"footnote",a.resolveTo(this.#e());}),this.enqueue({sort:"read",label:t,dependencies:[a],plan:()=>({op:"getNotes",document:n,noteKind:s}),settle:d=>{let h=C(d,t),P=h.findIndex(at=>at.ref===this.#e().ref),J=P<0?void 0:h[P+1];J||i({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:J});}}),e}onLoad(t){let e=this.selection(t,["text","type"]);if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getNoteText",note:this.#e(),projection:this.revisionTextView()})),e.includes("type")){let n=`${this.path.label}.type`;this.read(n,()=>({op:"getNoteKind",note:this.#e()}),r=>{this.setLoadedProperty("type",Ge(R(r,n)));});}}#e(){return this.requireAddressable(),this.path.handle()}},N=class o extends A{#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 pt.at(this.context,t,e)}promised(t,e){return pt.promised(this.context,t,e)}};var V=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({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)&&i({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.#n(),code:e.code}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}delete(){this.#e("deleteField");}updateResult(){this.#e("updateFieldResult");}#e(t){this.requireUsablePath(),this.commandAnswering(this.path.label,()=>({op:t,field:this.#n()}),e=>m(e,this.path.label));}onLoad(t){this.selection(t,["code"]).length!==0&&this.read(this.path.label,()=>({op:"getField",field:this.#n()}),e=>{e.kind!=="field"&&i({code:"GeneralException",target:this.path.label}),this.setLoadedProperty("code",e.field.code);});}#n(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.path.label}),t.handle}},W=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:k(this.path,this.#t)}}size(t,e){return C(t,e).length}addressAt(t,e,n){let r=C(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return V.at(this.context,t,e)}promised(t,e){return V.promised(this.context,t,e)}};var ze=["width","height","lockAspectRatio","altTextDescription"],U=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({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.#e("width",t);}get height(){return this.loadedProperty("height")}set height(t){this.#e("height",t);}get lockAspectRatio(){return this.loadedProperty("lockAspectRatio")}set lockAspectRatio(t){typeof t!="boolean"&&i({code:"InvalidArgument",target:`${this.path.label}.lockAspectRatio`}),this.#n({lockAspectRatio:t});}get altTextDescription(){return this.loadedProperty("altTextDescription")}set altTextDescription(t){typeof t!="string"&&i({code:"InvalidArgument",target:`${this.path.label}.altTextDescription`}),this.#n({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,ze);e.length&&this.read(this.path.label,()=>({op:"getInlinePicture",picture:this.#o()}),n=>{n.kind!=="inlinePicture"&&i({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.picture[r]);});}#e(t,e){(typeof e!="number"||!Number.isFinite(e)||e<=0)&&i({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#n({[t]:e});}#n(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"&&i({code:"InvalidObjectPath",target:this.path.label}),t.handle}},G=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:k(this.path,this.#t)}}size(t,e){return C(t,e).length}addressAt(t,e,n){let r=C(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return U.at(this.context,t,e)}promised(t,e){return U.promised(this.context,t,e)}};function q(o,t,e=0){return (!Number.isInteger(o)||o<e)&&i({code:"InvalidArgument",target:t}),o}function Vt(o,t){return (!Array.isArray(o)||o.some(e=>!Array.isArray(e)||e.some(n=>typeof n!="string")))&&i({code:"InvalidArgument",target:t}),o.map(e=>[...e])}function Pe(o,t){return o!=="Start"&&o!=="End"&&i({code:"InvalidArgument",target:t}),o==="Start"?"start":"end"}var z=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({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=Vt(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"&&i({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??=rt.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=ot.promised(this.context,n);return this.read(n,()=>({op:"getTableCell",table:this.path.handle(),rowIndex:t,cellIndex:e}),s=>r.hydrateAddress({kind:"handle",handle:u(s,n)})),r}addRows(t,e,n){let r=`${this.path.label}.addRows`,s=Pe(t,r);q(e,r,1);let a=n===void 0?void 0:Vt(n,r),d=rt.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addRows",location:s,count:e,...a?{values:a}:{}}}),h=>d.fill(h,r)),d}addColumns(t,e,n){let r=`${this.path.label}.addColumns`,s=Pe(t,r);q(e,r,1);let a=n===void 0?void 0:Vt(n,r);this.command("addColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addColumns",location:s,count:e,...a?{values:a}:{}}}));}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"&&i({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.table[r]);});}},ut=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({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();}insertRows(t,e,n){let r=`${this.path.label}.insertRows`;t!=="Before"&&t!=="After"&&i({code:"InvalidArgument",target:r}),q(e,r,1);let s=n===void 0?void 0:Vt(n,r),a=rt.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"insertTableRows",row:this.path.handle(),location:t==="Before"?"before":"after",count:e,...s?{values:s}:{}}),d=>a.fill(d,r)),a}get cells(){return this.#t??=It.of(this.context,`${this.path.label}.cells`,this.path,()=>({op:"getTableCells",row:this.path.handle()}))}},ot=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({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"&&i({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)&&i({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"&&i({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"&&i({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"&&i({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.cell[r]);});}},Q=class o extends A{#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 z.at(this.context,t,e)}promised(t,e){return z.promised(this.context,t,e)}},rt=class o extends A{#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 ut.at(this.context,t,e)}promised(t,e){return ut.promised(this.context,t,e)}},It=class o extends A{#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 ot.at(this.context,t,e)}promised(t,e){return ot.promised(this.context,t,e)}};var _t=(s=>(s.replace="Replace",s.start="Start",s.end="End",s.before="Before",s.after="After",s))(_t||{}),te=(a=>(a.mixed="Mixed",a.unknown="Unknown",a.left="Left",a.centered="Centered",a.right="Right",a.justified="Justified",a))(te||{}),ee=(e=>(e.portrait="Portrait",e.landscape="Landscape",e))(ee||{}),ne=(n=>(n.off="Off",n.trackAll="TrackAll",n.trackMineOnly="TrackMineOnly",n))(ne||{}),oe=(r=>(r.mixed="Mixed",r.top="Top",r.center="Center",r.bottom="Bottom",r))(oe||{}),re=(d=>(d.line="Line",d.page="Page",d.next="Next",d.sectionNext="SectionNext",d.sectionContinuous="SectionContinuous",d.sectionEven="SectionEven",d.sectionOdd="SectionOdd",d))(re||{}),ie=(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))(ie||{}),se=(x=>(x.all="All",x.atMentions="AtMentions",x.commentReactions="CommentReactions",x.comments="Comments",x.contentType="ContentType",x.documentIntelligence="DocumentIntelligence",x.documentManagementPolicy="DocumentManagementPolicy",x.documentProperties="DocumentProperties",x.documentServerProperties="DocumentServerProperties",x.documentTasks="DocumentTasks",x.documentWorkspace="DocumentWorkspace",x.emailHeader="EmailHeader",x.inkAnnotations="InkAnnotations",x.removePersonalInformation="RemovePersonalInformation",x.revisions="Revisions",x.routingSlip="RoutingSlip",x.sendForReview="SendForReview",x.taskpaneWebExtensions="TaskpaneWebExtensions",x.template="Template",x.versions="Versions",x))(se||{});var Qe=["Replace","Start","End"],Xe=["Start","End"],Ke=["Replace","Start","End"],Ze=["Before","After"],Ye=["Replace","Start","End","Before","After"],Je=["Select","Start","End"];function mt(o,t,e){return (typeof o!="string"||!t.includes(o))&&i({code:"InvalidArgument",target:e}),o}var Re=(o,t)=>mt(o,Qe,t),Oe=(o,t)=>mt(o,Xe,t),ke=(o,t)=>mt(o,Ke,t),Ie=(o,t)=>mt(o,Ze,t),St=(o,t)=>mt(o,Ye,t),Wt=(o,t)=>o===void 0?"Select":mt(o,Je,t);function S(o,t){return typeof o!="string"&&i({code:"InvalidArgument",target:t}),/[\r\n\f\u2028\u2029]/.test(o)&&i({code:"InvalidArgument",target:t}),o}var _e=8,de=(d=>(d.custom="Custom",d.solid="Solid",d.hollow="Hollow",d.square="Square",d.diamonds="Diamonds",d.arrow="Arrow",d.checkmark="Checkmark",d))(de||{}),le=(a=>(a.none="None",a.arabic="Arabic",a.upperRoman="UpperRoman",a.lowerRoman="LowerRoman",a.upperLetter="UpperLetter",a.lowerLetter="LowerLetter",a))(le||{}),E=class o extends p{#t;#e=new Map;static at(t,e,n){return n.kind!=="handle"&&i({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=ae(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=S(t,n);e!=="Start"&&e!=="End"&&e!=="Before"&&e!=="After"&&i({code:"InvalidArgument",target:n});let s=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertListParagraph",list:this.#o(),where:e==="Start"||e==="Before"?"start":"end",text:r}),a=>{s.hydrateAddress({kind:"handle",handle:u(a,n)});}),s}setLevelBullet(t,e,n,r){this.#n(t,{bullet:e,...n===void 0?{}:{charCode:n},...r===void 0?{}:{fontName:r}});}setLevelNumbering(t,e,n){this.#n(t,{numbering:e,...n===void 0?{}:{formatString:[...n]}});}setLevelStartingNumber(t,e){this.#n(t,{startingNumber:e});}setLevelIndents(t,e,n){this.#n(t,{textIndent:e,bulletNumberPictureIndent:n});}#n(t,e){let n=`${this.path.label}.levelFormat`,r=ae(t,n);this.requireUsablePath();let s=this.#e.get(r);if(s){Object.assign(s,e),"bullet"in e&&(delete s.numbering,delete s.formatString),"numbering"in e&&(delete s.bullet,delete s.charCode,delete s.fontName);return}let a={...e};this.#e.set(r,a),this.commandAnswering(n,()=>({op:"setListLevelFormat",list:this.#o(),level:r,format:a}),d=>{m(d,n);},()=>{this.#e.get(r)===a&&this.#e.delete(r);});}onLoad(t){if(!this.selection(t,["id"]).includes("id"))return;let e=`${this.path.label}.id`;this.read(e,()=>({op:"getListId",list:this.#o()}),n=>{this.setLoadedProperty("id",$t(n,e));});}#o(){return this.requireAddressable(),this.path.handle()}},gt=class o extends A{#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=tn(t,e),r=this.#t,s=E.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getListById",body:r,id:n}),settle:a=>{s.hydrateAddress({kind:"handle",handle:u(a,e)});}}),s}listing(){return {op:"getLists",body:this.#t}}itemAt(t,e){return E.at(this.context,t,e)}promised(t,e){return E.promised(this.context,t,e)}},ft=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=ae(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",$t(n,e));});}#t(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.path.label}),t.handle}};function ae(o,t){return (!Number.isInteger(o)||o<0||o>_e)&&i({code:"InvalidArgument",target:t}),o}function tn(o,t){return (!Number.isInteger(o)||o<=0)&&i({code:"InvalidArgument",target:t}),o}var ce=(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))(ce||{}),en=["bold","italic","color","name","size","underline","strikeThrough","highlightColor","subscript","superscript"],D=class o extends p{#t;#e;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.#n("bold",Lt(t,`${this.path.label}.bold`));}get italic(){return this.loadedProperty("italic")}set italic(t){this.#n("italic",Lt(t,`${this.path.label}.italic`));}get color(){return this.loadedProperty("color")}set color(t){this.#n("color",Ut(t,`${this.path.label}.color`));}get name(){return this.loadedProperty("name")}set name(t){this.#n("name",Ut(t,`${this.path.label}.name`));}get size(){return this.loadedProperty("size")}set size(t){this.#n("size",nn(t,`${this.path.label}.size`));}get underline(){return this.loadedProperty("underline")}set underline(t){this.#n("underline",Ut(t,`${this.path.label}.underline`));}get highlightColor(){return this.loadedProperty("highlightColor")}set highlightColor(t){this.#n("highlightColor",t===null?null:Ut(t,`${this.path.label}.highlightColor`));}get strikeThrough(){return this.loadedProperty("strikeThrough")}set strikeThrough(t){this.#n("strikeThrough",Lt(t,`${this.path.label}.strikeThrough`));}get subscript(){return this.loadedProperty("subscript")}set subscript(t){this.#n("subscript",Lt(t,`${this.path.label}.subscript`));}get superscript(){return this.loadedProperty("superscript")}set superscript(t){this.#n("superscript",Lt(t,`${this.path.label}.superscript`));}onLoad(t){let e=this.selection(t,en);if(e.length===0)return;let n=`${this.path.label}.font`;this.read(n,()=>({op:"getFont",span:this.#o()}),r=>{let s=Xt(r,n);for(let a of e)this.setLoadedProperty(a,s[a]);});}#n(t,e){if(this.requireUsablePath(),this.#e){this.#e[t]=e,t==="subscript"&&e===true&&(this.#e.superscript=false),t==="superscript"&&e===true&&(this.#e.subscript=false);return}let n={[t]:e};t==="subscript"&&e===true&&(n.superscript=false),t==="superscript"&&e===true&&(n.subscript=false),this.#e=n;let r=`${this.path.label}.${t}`;this.commandAnswering(this.path.label,()=>({op:"setFont",span:this.#o(),font:n}),s=>{m(s,r);},()=>{this.#e===n&&(this.#e=void 0);});}#o(){return this.requireAddressable(),k(this.path,this.#t)}};function Lt(o,t){return typeof o!="boolean"&&i({code:"InvalidArgument",target:t}),o}function nn(o,t){return (typeof o!="number"||!Number.isFinite(o))&&i({code:"InvalidArgument",target:t}),o}function Ut(o,t){return (typeof o!="string"||o.length===0)&&i({code:"InvalidArgument",target:t}),o}var on=16,w=class o extends p{#t;#e;#n;#o;#s;static at(t,e,n){return n.kind!=="handle"&&i({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.#a("style",ct(t,`${this.path.label}.style`));}get shapes(){return this.#e??=F.of(this.context,`${this.path.label}.shapes`,this.path,"paragraph"),this.#e}get font(){return this.#t??=D.of(this.context,`${this.path.label}.font`,this.path,"paragraph"),this.#t}get alignment(){return this.loadedProperty("alignment")}set alignment(t){this.#a("alignment",sn(t,`${this.path.label}.alignment`));}get firstLineIndent(){return this.loadedProperty("firstLineIndent")}set firstLineIndent(t){this.#a("firstLineIndent",bt(t,`${this.path.label}.firstLineIndent`));}get leftIndent(){return this.loadedProperty("leftIndent")}set leftIndent(t){this.#a("leftIndent",bt(t,`${this.path.label}.leftIndent`));}get rightIndent(){return this.loadedProperty("rightIndent")}set rightIndent(t){this.#a("rightIndent",bt(t,`${this.path.label}.rightIndent`));}get lineSpacing(){return this.loadedProperty("lineSpacing")}set lineSpacing(t){this.#a("lineSpacing",bt(t,`${this.path.label}.lineSpacing`));}get spaceBefore(){return this.loadedProperty("spaceBefore")}set spaceBefore(t){this.#a("spaceBefore",bt(t,`${this.path.label}.spaceBefore`));}get spaceAfter(){return this.loadedProperty("spaceAfter")}set spaceAfter(t){this.#a("spaceAfter",bt(t,`${this.path.label}.spaceAfter`));}get list(){return this.#n??=this.#i(`${this.path.label}.list`),this.#n}getRange(t="Whole"){let e=`${this.path.label}.getRange`;["Whole","Content","Start","End","Before","After"].includes(t)||i({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:O(r,e)});}),n}startNewList(){let t=`${this.path.label}.startNewList`,e=E.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)&&i({code:"InvalidArgument",target:n});let r=E.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"attachToList",paragraph:this.#r(),listId:t,level:e}),s=>{r.hydrateAddress({kind:"handle",handle:u(s,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.#o??=ft.of(this.context,`${this.path.label}.listItem`,this.path),this.#o}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=S(t,n),s=ke(e,n),a=b.promised(this.context,n,false);return this.commandAnswering(n,()=>s==="Replace"?{op:"replaceSpan",span:{paragraph:this.#r()},text:r}:{op:"insertText",at:{paragraph:this.#r(),at:s==="Start"?"start":"end"},text:r},d=>{a.hydrateAddress({kind:"span",span:O(d,n)});}),a}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=S(t,n),s=Ie(e,n),a=o.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:this.#r()},where:s==="Before"?"before":"after",text:r}),d=>{d.kind!=="handle"&&i({code:"GeneralException",target:n}),a.hydrateAddress({kind:"handle",handle:d.handle});}),a}split(t,e,n){let r=`${this.path.label}.split`,s=an(t,r),a=Le(e,`${r}.trimDelimiters`),d=Le(n,`${r}.trimSpacing`),h=B.answered(this.context,r,this.path);return this.commandAnswering(r,()=>({op:"splitParagraph",paragraph:this.#r(),delimiters:s,...a?{trimDelimiters:true}:{},...d?{trimSpacing:true}:{}}),P=>{h.fill(P,r);}),h}onLoad(t){let e=this.selection(t,["text","uniqueLocalId",...Se]);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=Se.filter(s=>e.includes(s));if(n.length===0)return;let r=`${this.path.label}.paragraphFormat`;this.read(r,()=>({op:"getParagraphFormat",paragraph:{paragraph:this.#r()}}),s=>{let a=Kt(s,r);for(let d of n)this.setLoadedProperty(d,a[d]);});}#a(t,e){if(this.requireUsablePath(),this.#s){this.#s[t]=e;return}let n={[t]:e};this.#s=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.paragraphFormat`,()=>({op:"setParagraphFormat",paragraph:{paragraph:this.#r()},format:n}),s=>{m(s,r);},()=>{this.#s===n&&(this.#s=void 0);});}#i(t){let e=E.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()}},Se=["style","alignment","firstLineIndent","leftIndent","rightIndent","lineSpacing","spaceBefore","spaceAfter"],rn=["Left","Centered","Right","Justified"];function sn(o,t){return rn.includes(o)||i({code:"InvalidArgument",target:t}),o}function bt(o,t){return (typeof o!="number"||!Number.isFinite(o))&&i({code:"InvalidArgument",target:t}),o}function an(o,t){(!Array.isArray(o)||o.length===0||o.length>on)&&i({code:"InvalidArgument",target:t});for(let e of o)(typeof e!="string"||e.length===0)&&i({code:"InvalidArgument",target:t});return [...o]}function Le(o,t){return o!==void 0&&typeof o!="boolean"&&i({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 C(t,e).length}addressAt(t,e,n){let r=C(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)}},B=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 Bt(t,e).length}addressAt(t,e,n){let r=Bt(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 je=4096,$=class o extends p{#t;#e=new Map;#n;#o;static at(t,e,n){return n.kind!=="handle"&&i({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.#a("tag",{tag:he(t,`${this.path.label}.tag`)});}get title(){return this.loadedProperty("title")}set title(t){this.#a("title",{title:he(t,`${this.path.label}.title`)});}get subtype(){return this.loadedProperty("subtype")}get isBound(){return this.loadedProperty("isBound")}get cannotDelete(){let t=this.loadedProperty("lock");return t==="sdtLocked"||t==="sdtContentLocked"}set cannotDelete(t){this.#i("cannotDelete",t);}get cannotEdit(){let t=this.loadedProperty("lock");return t==="contentLocked"||t==="sdtContentLocked"}set cannotEdit(t){this.#i("cannotEdit",t);}get placeholderShown(){return this.loadedProperty("placeholderShown")}get temporary(){return this.loadedProperty("temporary")}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#n??=L.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getContentControlParagraphs",contentControl:this.#r()})),this.#n}get contentControls(){return this.#o??=H.of(this.context,`${this.path.label}.contentControls`,this.path,{contentControl:this.#r()}),this.#o}getRange(t){let e=`${this.path.label}.getRange`,n=dn(t??"Whole",e),r=this.#e.get(n);if(r)return r;let s=this.#s(e,n);return this.#e.set(n,s),s}setValue(t){let e=`${this.path.label}.setValue`,n=ln(t,e);this.command("setValue",()=>({op:"setContentControlValue",contentControl:this.#r(),value:n}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=S(t,n),s=e==="Replace"?"replace":e==="Start"?"start":e==="End"?"end":i({code:"InvalidArgument",target:n}),a=b.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertContentControlText",contentControl:this.#r(),text:r,at:s}),d=>{a.hydrateAddress({kind:"span",span:O(d,n)});}),a}delete(t){let e=`${this.path.label}.delete`;typeof t!="boolean"&&i({code:"InvalidArgument",target:e}),this.command("delete",()=>({op:"deleteContentControl",contentControl:this.#r(),keepContent:t}));}onLoad(t){let e=this.selection(t,["id","tag","title","subtype","isBound","text","cannotDelete","cannotEdit","placeholderShown","temporary"]);if(e.includes("id")&&this.loadTextInto("id",()=>({op:"getContentControlFileId",contentControl:this.#r()})),e.includes("tag")&&this.loadTextInto("tag",()=>({op:"getContentControlTag",contentControl:this.#r()})),e.includes("title")&&this.loadTextInto("title",()=>({op:"getContentControlTitle",contentControl:this.#r()})),e.includes("subtype")&&this.loadTextInto("subtype",()=>({op:"getContentControlSubtype",contentControl:this.#r()})),e.includes("isBound")){let r=`${this.path.label}.isBound`;this.read(r,()=>({op:"getContentControlIsBound",contentControl:this.#r()}),s=>{this.setLoadedProperty("isBound",nt(s,r));});}if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getContentControlText",contentControl:this.#r(),projection:this.revisionTextView()})),e.includes("cannotDelete")||e.includes("cannotEdit")){let r=`${this.path.label}.lock`;this.read(r,()=>({op:"getContentControlLock",contentControl:this.#r()}),s=>{this.setLoadedProperty("lock",R(s,r));});}if(e.includes("placeholderShown")){let r=`${this.path.label}.placeholderShown`;this.read(r,()=>({op:"getContentControlPlaceholderShown",contentControl:this.#r()}),s=>{this.setLoadedProperty("placeholderShown",nt(s,r));});}if(!e.includes("temporary"))return;let n=`${this.path.label}.temporary`;this.read(n,()=>({op:"getContentControlTemporary",contentControl:this.#r()}),r=>{this.setLoadedProperty("temporary",nt(r,n));});}#s(t,e){let n=b.promised(this.context,t,false);return this.read(t,()=>({op:"getContentControlRange",contentControl:this.#r(),location:e}),r=>{n.hydrateAddress({kind:"span",span:O(r,t)});}),n}#a(t,e){this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#r(),...e}));}#i(t,e){let n=`${this.path.label}.${t}`;if(typeof e!="boolean"&&i({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.#r(),...r}),()=>{this.#t===r&&(this.#t=void 0);});}#r(){return this.requireAddressable(),this.path.handle()}},H=class o extends A{#t;#e;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.#e=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getById(t){let e=`${this.path.label}.getById`;Number.isInteger(t)||i({code:"InvalidArgument",target:e});let n=this.#t,r=$.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getContentControlById",scope:n,id:t}),settle:s=>{r.hydrateAddress({kind:"handle",handle:u(s,e)});}}),r}getByTag(t){let e=`${this.path.label}.getByTag`,n=we(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=we(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.#e()}itemAt(t,e){return $.at(this.context,t,e)}promised(t,e){return $.promised(this.context,t,e)}};function he(o,t){return (typeof o!="string"||o.length>je)&&i({code:"InvalidArgument",target:t}),o}function we(o,t){let e=he(o,t);return e.length===0&&i({code:"InvalidArgument",target:t}),e}function dn(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 i({code:"InvalidArgument",target:t})}}function ln(o,t){(typeof o!="object"||o===null)&&i({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>je)&&i({code:"InvalidArgument",target:t}),e.kind==="text"?{kind:"text",text:n}:{kind:"listItem",value:n}}if(e.kind==="checkbox")return typeof e.checked!="boolean"&&i({code:"InvalidArgument",target:t}),{kind:"checkbox",checked:e.checked};if(e.kind==="date")return (typeof e.iso!="string"||e.iso.length>64)&&i({code:"InvalidArgument",target:t}),{kind:"date",iso:e.iso};i({code:"InvalidArgument",target:t});}function cn(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 Te(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]),s=cn(e,n);if(e===0||s===0||r<1||r>s)return null;let a=Number(t[4]),d=Number(t[5]),h=Number(t[6]);if(a>23||d>59||h>59)return null;let P=t[7],J=P===void 0?0:Number(P.padEnd(3,"0").slice(0,3));if(Number.isNaN(J))return null;let at=`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}.${String(J).padStart(3,"0")}Z`,Tt=Date.parse(at);if(Number.isNaN(Tt))return null;let g=t[8];if(g==="Z")return new Date(Tt);let _=Number(g.slice(1,3)),dt=Number(g.slice(4,6));if(dt>59||_>14||_===14&&dt!==0)return null;let Qt=g[0]==="+"?1:-1,Et=new Date(Tt-Qt*(_*36e5+dt*6e4));return Number.isNaN(Et.getTime())?null:Et}var Gt=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 s=`${this.path.label}.creationDate`;this.read(s,()=>({op:"getCommentDate",comment:this.commentHandle()}),a=>{this.setLoadedProperty("creationDate",Te(R(a,s)));});}if(!n.includes("resolved"))return;let r=`${this.path.label}.resolved`;this.read(r,()=>({op:"getCommentResolved",comment:this.commentHandle()}),s=>{this.setLoadedProperty("resolved",nt(s,r));});}commentHandle(){return this.requireAddressable(),this.path.handle()}},st=class o extends Gt{static at(t,e,n){return n.kind!=="handle"&&i({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,[]);}},wt=class o extends A{#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 st.at(this.context,t,e)}promised(t,e){return st.promised(this.context,t,e)}},X=class o extends Gt{#t;static at(t,e,n){return n.kind!=="handle"&&i({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"&&i({code:"InvalidArgument",target:e}),this.commandAnswering(e,()=>({op:"setCommentResolved",comment:this.commentHandle(),resolved:t}),n=>{m(n,e);});}get replies(){return this.#t??=wt.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:O(n,t)});}),e}reply(t){let e=`${this.path.label}.reply`;(typeof t!="string"||t.length===0)&&i({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&i({code:"NotSupported",target:e});let r=st.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"replyToComment",comment:this.commentHandle(),text:t,author:n}),s=>{r.hydrateAddress({kind:"handle",handle:u(s,e)});}),r}onLoad(t){this.loadCommentFields(t,["resolved"]);}},K=class o extends A{#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 X.at(this.context,t,e)}promised(t,e){return X.promised(this.context,t,e)}},it=class o extends p{static at(t,e,n){return n.kind!=="handle"&&i({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:O(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",Te(R(r,n)));});}static batchHandle(t,e){return (!(t instanceof o)||t.context!==e)&&i({code:"InvalidArgument",target:"RevisionCollection.resolve"}),t.#t()}#t(){return this.requireAddressable(),this.path.handle()}},Z=class o extends A{#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))&&i({code:"InvalidArgument",target:n});let r=e===void 0?void 0:[...e],{result:s,fill:a}=xe(n);return this.enqueue({sort:"write",label:n,plan:()=>({op:"resolveRevisionBatch",body:this.#t,action:t,...r===void 0?{}:{revisions:r.map(d=>it.batchHandle(d,this.context))}}),settle:d=>{d.kind!=="revisionBatch"&&i({code:"GeneralException",target:n}),a(d.result);}}),s}listing(){return {op:"getRevisions",body:this.#t}}itemAt(t,e){return it.at(this.context,t,e)}promised(t,e){return it.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 hn=new Set(["matchCase","matchWholeWord","ignorePunct","ignoreSpace","matchWildcards"]);function zt(o,t){if(o===void 0)return;typeof o!="object"&&i({code:"InvalidArgument",target:t});for(let[n,r]of Object.entries(o))hn.has(n)||i({code:"InvalidArgument",target:`${t}.${n}`}),r!==void 0&&typeof r!="boolean"&&i({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;#e;#n;#o;#s;#a;static at(t,e,n){return n.kind!=="span"&&i({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.#s??=D.of(this.context,`${this.path.label}.font`,this.path,"span"),this.#s}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=ct(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:k(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)&&i({code:"InvalidArgument",target:e}),this.requireUsablePath(),this.command("hyperlink",()=>({op:"setHyperlink",span:this.#i(),target:t}));}get bookmarks(){let t=this.#i();return this.#a??=Y.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{start:t.start,end:t.end}})),this.#a}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&i({code:"InvalidArgument",target:n});let r=zt(e,n),s=this.#i();return B.of(this.context,n,this.path,()=>({op:"search",scope:s,text:t,options:{...r??{},projection:this.revisionTextView()}}))}insertText(t,e){let n=`${this.path.label}.insertText`,r=S(t,n),s=St(e,n);this.requireUsablePath();let a=o.promised(this.context,n,false);return this.commandAnswering(n,()=>{let d=this.#i();return s==="Replace"?{op:"replaceSpan",span:d,text:r}:{op:"insertText",at:s==="Start"||s==="Before"?d.start:d.end,text:r}},d=>{a.hydrateAddress({kind:"span",span:O(d,n)});}),a}delete(){this.requireUsablePath(),this.commandDiscarding("delete",()=>({op:"replaceSpan",span:this.#i(),text:""}));}clear(){let t=this.#i();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:t,text:""}));}insertComment(t){let e=`${this.path.label}.insertComment`;(typeof t!="string"||t.length===0)&&i({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&i({code:"NotSupported",target:e});let r=X.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertComment",span:this.#i(),text:t,author:n}),s=>{s.kind!=="handle"&&i({code:"GeneralException",target:e}),r.hydrateAddress(s);}),r}insertContentControl(t){let e=`${this.path.label}.insertContentControl`,n=t??"RichText";n!=="RichText"&&n!=="PlainText"&&n!=="DatePicker"&&i({code:"NotSupported",target:e});let r=$.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertContentControl",span:this.#i(),subtype:n==="DatePicker"?"date":n==="PlainText"?"plainText":"richText",returnHandle:true}),s=>{s.kind!=="handle"&&i({code:"GeneralException",target:e}),r.hydrateAddress(s);}),r}get tables(){return this.requireUsablePath(),this.#t??=Q.over(this.context,`${this.path.label}.tables`,this.path,()=>k(this.path,"span"))}get fields(){return this.requireUsablePath(),this.#e??=W.of(this.context,`${this.path.label}.fields`,this.path,"span")}insertField(t,e,n,r){let s=`${this.path.label}.insertField`;(e!==void 0&&typeof e!="string"||n!==void 0&&typeof n!="string"||r!==void 0&&typeof r!="boolean")&&i({code:"InvalidArgument",target:s});let a=St(t,s);this.requireUsablePath();let d=V.promised(this.context,s,false);return this.commandAnswering(s,()=>({op:"insertField",span:this.#i(),location:a,...e===void 0?{}:{fieldType:e},...n===void 0?{}:{text:n},...r===void 0?{}:{removeFormatting:r}}),h=>d.hydrateAddress({kind:"handle",handle:u(h,s)})),d}get inlinePictures(){return this.requireUsablePath(),this.#n??=G.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)&&i({code:"InvalidArgument",target:n});let r=St(e,n);this.requireUsablePath();let s=U.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertInlinePicture",span:this.#i(),base64:t,location:r}),a=>{s.hydrateAddress({kind:"handle",handle:u(a,n)});}),s}insertBreak(t,e){let n=`${this.path.label}.insertBreak`;e!=="Before"&&e!=="After"&&i({code:"InvalidArgument",target:n});let r=e;this.requireUsablePath(),this.commandAnswering(n,()=>({op:"insertBreak",span:this.#i(),breakType:t,location:r}),s=>m(s,n));}insertTable(t,e,n,r){let s=`${this.path.label}.insertTable`;(!Number.isInteger(t)||!Number.isInteger(e)||t<1||e<1||!["Before","After"].includes(n))&&i({code:"InvalidArgument",target:s}),r!==void 0&&(!Array.isArray(r)||r.some(h=>!Array.isArray(h)||h.some(P=>typeof P!="string")))&&i({code:"InvalidArgument",target:s});let a=r?.map(h=>[...h]),d=z.promised(this.context,s);return this.commandAnswering(s,()=>({op:"insertTable",span:k(this.path,"span"),location:n,rowCount:t,columnCount:e,...a?{values:a}:{}}),h=>{h.kind!=="handle"&&i({code:"GeneralException",target:s}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=S(t,n),s=St(e,n);s!=="Before"&&s!=="After"&&i({code:"InvalidArgument",target:n});let a=this.#i(),d=s==="Before"?a.start.paragraph:a.end.paragraph,h=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:d},where:s==="Before"?"before":"after",text:r}),P=>{P.kind!=="handle"&&i({code:"GeneralException",target:n}),h.hydrateAddress({kind:"handle",handle:P.handle});}),h}select(t){let e=`${this.path.label}.select`,n=Wt(t,e);this.requireAddressable(),this.internals.capabilities.selection||i({code:"NotSupported",target:e});let r=this.#i();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.#i()})),e.includes("text")){let r=`${this.path.label}.text`;this.read(r,()=>({op:"getSpanText",span:this.#i(),projection:this.revisionTextView()}),s=>{this.setLoadedProperty("text",R(s,r));});}if(!e.includes("style"))return;let n=`${this.path.label}.style`;this.requireUsablePath(),this.read(n,()=>({op:"getStyle",span:k(this.path,"span")}),r=>{this.setLoadedProperty("style",Pt(r,n));});}#i(){return this.requireAddressable(),this.path.span()}};var yt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({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.#e(`${this.path.label}.range`),this.#t}select(t){let e=`${this.path.label}.select`,n=Wt(t,e);this.requireUsablePath(),this.internals.capabilities.selection||i({code:"NotSupported",target:e}),this.command("select",()=>({op:"selectBookmark",bookmark:this.#n(),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.#n()}),n=>{this.setLoadedProperty("name",R(n,e));});}#e(t){let e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getBookmarkRange",bookmark:this.#n()}),n=>{e.hydrateAddress({kind:"span",span:O(n,t)});}),e}#n(){return this.requireAddressable(),this.path.handle()}},Y=class o extends A{#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 yt.at(this.context,t,e)}promised(t,e){return yt.promised(this.context,t,e)}};var I=class o extends p{#t;#e;get footnotes(){return this.#t??=N.of(this.context,`${this.path.label}.footnotes`,this.path,()=>({op:"getNotes",document:this.internals.roots().document,scope:this.#l(),noteKind:"footnote"}))}get endnotes(){return this.#e??=N.of(this.context,`${this.path.label}.endnotes`,this.path,()=>({op:"getNotes",document:this.internals.roots().document,scope:this.#l(),noteKind:"endnote"}))}#n;#o;#s;#a;#i;#r;#d;#c;#h;#p;static main(t,e){return new o(t,c.of(e,et(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.#i??=this.paragraphsUnder(`${this.path.label}.paragraphs`),this.#i}get bookmarks(){let t=this.#l();return this.#r??=Y.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{body:t}})),this.#r}get font(){return this.#d??=D.of(this.context,`${this.path.label}.font`,this.path,"body"),this.#d}paragraphsUnder(t){return L.of(this.context,t,this.path)}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=ct(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:k(this.path,"body"),name:n}));}get lists(){return this.#c??=gt.of(this.context,`${this.path.label}.lists`,this.path,this.#l()),this.#c}get contentControls(){return this.#h??=H.of(this.context,`${this.path.label}.contentControls`,this.path,{body:this.#l()}),this.#h}getComments(){let t=`${this.path.label}.getComments`,e=this.#l();return K.of(this.context,t,this.path,()=>({op:"getComments",scope:{body:e}}))}get revisions(){return this.#p??=Z.of(this.context,`${this.path.label}.revisions`,this.path,this.#l()),this.#p}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:O(r,e)});}),n}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&i({code:"InvalidArgument",target:n});let r=zt(e,n),s=this.#l();return B.of(this.context,n,this.path,()=>({op:"search",scope:{body:s},text:t,options:{...r??{},projection:this.revisionTextView()}}))}clear(){let t=this.#l();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{body:t},text:""}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=S(t,n),s=Re(e,n);this.requireUsablePath();let a=b.promised(this.context,n,false);return this.commandAnswering(n,()=>s==="Replace"?{op:"replaceSpan",span:{body:this.#l()},text:r}:{op:"insertText",at:{body:this.#l(),at:s==="Start"?"start":"end"},text:r},d=>{a.hydrateAddress({kind:"span",span:O(d,n)});}),a}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=S(t,n),s=Oe(e,n),a=this.#l(),d=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{body:a,at:s==="Start"?"first":"last"},where:s==="Start"?"before":"after",text:r}),h=>{h.kind!=="handle"&&i({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.#l(),projection:this.revisionTextView()})),e.includes("style")&&this.#u();}#u(){let t=`${this.path.label}.style`;this.requireUsablePath(),this.read(t,()=>({op:"getStyle",span:k(this.path,"body")}),e=>{this.setLoadedProperty("style",Pt(e,t));});}get fields(){return this.requireUsablePath(),this.#o??=W.of(this.context,`${this.path.label}.fields`,this.path,"body")}get inlinePictures(){return this.requireUsablePath(),this.#s??=G.of(this.context,`${this.path.label}.inlinePictures`,this.path,"body")}get shapes(){return this.requireUsablePath(),this.#a??=F.of(this.context,`${this.path.label}.shapes`,this.path,"body")}get tables(){return this.requireUsablePath(),this.#n??=Q.over(this.context,`${this.path.label}.tables`,this.path,()=>({body:this.#l()}))}#l(){return this.requireAddressable(),this.path.handle()}};var pn=Object.freeze({Primary:"default",FirstPage:"first",EvenPages:"even"}),un=["pageWidth","pageHeight","orientation","topMargin","rightMargin","bottomMargin","leftMargin"],jt=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.#e("pageWidth",xt(t,`${this.path.label}.pageWidth`));}get pageHeight(){return this.loadedProperty("pageHeight")}set pageHeight(t){this.#e("pageHeight",xt(t,`${this.path.label}.pageHeight`));}get orientation(){return this.loadedProperty("orientation")}set orientation(t){let e=`${this.path.label}.orientation`;t!=="Portrait"&&t!=="Landscape"&&i({code:"InvalidArgument",target:e}),this.#e("orientation",t==="Portrait"?"portrait":"landscape");}get topMargin(){return this.loadedProperty("topMargin")}set topMargin(t){this.#e("topMargin",xt(t,`${this.path.label}.topMargin`));}get bottomMargin(){return this.loadedProperty("bottomMargin")}set bottomMargin(t){this.#e("bottomMargin",xt(t,`${this.path.label}.bottomMargin`));}get leftMargin(){return this.loadedProperty("leftMargin")}set leftMargin(t){this.#e("leftMargin",xt(t,`${this.path.label}.leftMargin`));}get rightMargin(){return this.loadedProperty("rightMargin")}set rightMargin(t){this.#e("rightMargin",xt(t,`${this.path.label}.rightMargin`));}onLoad(t){let e=this.selection(t,un);if(e.length===0)return;let n=`${this.path.label}.pageSetup`;this.read(n,()=>({op:"getPageSetup",section:this.#n()}),r=>{let s=Zt(r,n);for(let a of e)this.setLoadedProperty(a,a==="orientation"?s.orientation==="landscape"?"Landscape":"Portrait":s[a]);});}#e(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.#n(),setup:n}),s=>{m(s,r);},()=>{this.#t===n&&(this.#t=void 0);});}#n(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.path.label}),t.handle}},Ct=class o extends p{#t;#e;static at(t,e,n){return n.kind!=="handle"&&i({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.#e??=I.main(this.context,`${this.path.label}.body`),this.#e}get pageSetup(){return this.#t??=jt.of(this.context,`${this.path.label}.pageSetup`,this.path),this.#t}getHeader(t){return this.#n("header",t,"getHeader")}getFooter(t){return this.#n("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 s=C(r,t),a=s.findIndex(h=>h.ref===this.#o().ref),d=a<0?void 0:s[a+1];d||i({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:d});}),e}onLoad(t){this.selection(t,[]);}#n(t,e,n){let r=`${this.path.label}.${n}`,s=pn[e];s===void 0&&i({code:"InvalidArgument",target:r});let a=I.promisedStory(this.context,r);return this.read(r,()=>({op:"getFurniture",section:this.#o(),kind:t,variant:s}),d=>{a.hydrateAddress({kind:"handle",handle:u(d,r)});}),a}#o(){return this.requireAddressable(),this.path.handle()}},At=class o extends A{#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 Ct.at(this.context,t,e)}promised(t,e){return Ct.promised(this.context,t,e)}};function xt(o,t){return (typeof o!="number"||!Number.isFinite(o)||o<0)&&i({code:"InvalidArgument",target:t}),o}var vt=class o extends p{#t;#e;#n;#o;#s;#a;#i;#r;#d;static open(t){return new o(t)}constructor(t){super(t,c.of("document",et(t).roots().document));}get changeTrackingMode(){return this.loadedProperty("changeTrackingMode")}set changeTrackingMode(t){["Off","TrackAll","TrackMineOnly"].includes(t)||i({code:"InvalidArgument",target:"document.changeTrackingMode"});let e=this.internals.author;this.commandAnswering("document.changeTrackingMode",()=>({op:"setChangeTrackingMode",mode:t,...e===void 0?{}:{author:e}}),()=>this.setLoadedProperty("changeTrackingMode",t));}get body(){return this.#e??=I.main(this.context,"document.body"),this.#e}removeDocumentInformation(t){this.command(`${this.path.label}.removeDocumentInformation`,()=>({op:"removeDocumentInformation",removeDocInfoType:t}));}get properties(){return this.#t??=lt.of(this.context,this.path),this.#t}get paragraphs(){return this.#n??=this.body.paragraphsUnder("document.paragraphs"),this.#n}get sections(){let t=this.path.handle();return this.#o??=At.of(this.context,"document.sections",this.path,()=>({op:"getSections",document:t})),this.#o}get contentControls(){return this.#i??=H.of(this.context,"document.contentControls",this.path,{body:this.internals.roots().body}),this.#i}get comments(){return this.#s??=K.of(this.context,"document.comments",this.path,()=>({op:"getComments",scope:{body:this.internals.roots().body}})),this.#s}get revisions(){return this.#a??=Z.of(this.context,"document.revisions",this.path,this.internals.roots().body),this.#a}get footnotes(){let t=this.path.handle();return this.#r??=N.of(this.context,"document.footnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"footnote"})),this.#r}get endnotes(){let t=this.path.handle();return this.#d??=N.of(this.context,"document.endnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"endnote"})),this.#d}onLoad(t){if(t.select.length===0)return;this.selection(t,["changeTrackingMode"]).includes("changeTrackingMode")&&this.loadTextInto("changeTrackingMode",()=>({op:"getChangeTrackingMode"}));}};function Ne(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"&&i({code:"InvalidArgument",target:"revisionTextView"});let s=false,a=null,d=g=>{s&&i({code:"RuntimeDisposed",...g===void 0?{}:{target:g}});},h=()=>{if(a)return a;d("document");let g=Ee(t.execute({operations:[{op:"getDocument"}]}),"document"),_=Ee(t.execute({operations:[{op:"getBody",document:g}]}),"document.body");return a={document:g,body:_},a},P={host:t,capabilities:e,...n===void 0?{}:{author:n},revisionTextView:r,id:{},roots:h,assertLive:d,openDocument:g=>vt.open(g)};try{h();}catch{a=null;}async function J(g,_){d();let dt=typeof g=="function"?g:_,Qt=typeof g=="function"?[]:Array.isArray(g)?g:[g];typeof dt!="function"&&i({code:"InvalidArgument",target:"run"});let{context:Et,adopt:y,finish:De}=Ot.begin(P);try{return y(Qt),await dt(Et)}finally{De();}}let at={capabilities:e,run:J,dispose(){s||(s=true,a=null,t.dispose());}};return o.save?{...at,async save(){d("save"),e.save||i({code:"NotSupported",target:"save"});let g=t.save();if(!g.ok)throw Ht(g.error,{target:"save"});return g.bytes}}:at}function Ee(o,t){let e=o.results[0];if(e?.status==="error")throw Ht(e.error,{target:t});if(e?.status!=="ok")throw new v({code:"GeneralException",target:t});return u(e.value,t)}function gn(o){if(o){for(let t of o)if(t.collaboration)return t.collaboration}}function fn(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))&&i({code:"InvalidArgument",target:"createServer"});}async function pe(o,t={}){fn(t.limits);let e=gn(t.modules),n=automation.createServerAutomationHost(o,{...t.pagination?{pagination:me(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"},s=n.limit??r[n.reason];i({code:s===void 0?"InvalidArgument":"ResourceLimitExceeded",target:"createServer",...s===void 0?{}:{limit:s}});}return Ne({host:n.host,save:true,...t.author===void 0?{}:{author:t.author},...t.revisionTextView===void 0?{}:{revisionTextView:t.revisionTextView}})}function qe(o,t,e={}){return pe(o,{...e,modules:[...e.modules??[],{id:"collaboration",collaboration:{session:t}}]})}var ue=(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))(ue||{});var ps=Object.freeze({createServer:pe,createCollaborative:qe});exports.Alignment=te;exports.Body=I;exports.Bookmark=yt;exports.BookmarkCollection=Y;exports.BreakType=re;exports.ChangeTrackingMode=ne;exports.ClientObject=M;exports.ClientResult=Dt;exports.Comment=X;exports.CommentCollection=K;exports.CommentReply=st;exports.CommentReplyCollection=wt;exports.ContentControl=$;exports.ContentControlCollection=H;exports.ContentControlType=ie;exports.Document=vt;exports.DocumentProperties=lt;exports.DocxEditor=ps;exports.DocxEditorError=v;exports.Field=V;exports.FieldCollection=W;exports.FieldType=ue;exports.Font=D;exports.InlinePicture=U;exports.InlinePictureCollection=G;exports.InsertLocation=_t;exports.List=E;exports.ListBullet=de;exports.ListCollection=gt;exports.ListItem=ft;exports.ListNumbering=le;exports.NoteItem=pt;exports.NoteItemCollection=N;exports.PageOrientation=ee;exports.PageSetup=jt;exports.Paragraph=w;exports.ParagraphCollection=L;exports.Range=b;exports.RangeCollection=B;exports.RemoveDocInfoType=se;exports.RequestContext=Ot;exports.Revision=it;exports.RevisionCollection=Z;exports.Section=Ct;exports.SectionCollection=At;exports.Shape=ht;exports.ShapeCollection=F;exports.ShapeType=Ft;exports.Table=z;exports.TableCell=ot;exports.TableCellCollection=It;exports.TableCollection=Q;exports.TableRow=ut;exports.TableRowCollection=rt;exports.TrackedObjects=Rt;exports.UnderlineType=ce;exports.VerticalAlignment=oe;exports.isDocxEditorError=$e;
|
|
1
|
+
'use strict';var automation=require('@docx-editor.dev/core/automation');function be(n){return automation.createAutomationPaginationProvider(n)}var ye=Object.freeze({PropertyNotLoaded:"the property has not been loaded. Call load(...) and await context.sync() before reading it.",ValueNotLoaded:"the result has not been filled in yet. Await context.sync() before reading it.",InvalidObjectPath:"the object cannot be addressed. Await context.sync() after creating an object with an edit. Keep proxies within their run, or use context.trackedObjects.add(...) before the run ends.",ObjectInUse:"the object still belongs to a run that has not finished. Await that run before passing the object to another one.",InvalidArgument:"the argument is not one this API accepts.",ResourceLimitExceeded:"the document exceeds a supported resource limit.",ItemNotFound:"the collection has no such item.",NotSupported:"the operation or argument is outside this document or host\u2019s supported capabilities.",NotImplemented:"this version does not implement that yet.",ConflictingChanges:"these operations cannot share one atomic batch. Split them across separate context.sync() calls.",InvalidRequestContext:"the request context has finished. Start another run to continue.",RuntimeDisposed:"the runtime has been disposed.",StaleDocument:"the document or a range changed after this context read it, so nothing was applied. The change can come from another writer or from an earlier sync of this context.",DocumentUnavailable:"the document is not available right now.",GeneralException:"the document could not complete the request."}),R=class extends Error{code;limit;target;expectedRevision;actualRevision;debugInfo;constructor(t){let e=t.target?`${ye[t.code]} (${t.target})`:ye[t.code];super(e),this.name="DocxEditorError",this.code=t.code,this.debugInfo=Object.freeze({code:t.code,message:e,...t.target===void 0?{}:{errorLocation:t.target},...t.diagnostic===void 0?{}:{innerError:Object.freeze({code:t.diagnostic,message:automation.explainDiagnostic(t.diagnostic).hint})}}),t.limit!==void 0&&(this.limit=t.limit),t.target!==void 0&&(this.target=t.target),t.expectedRevision!==void 0&&(this.expectedRevision=t.expectedRevision),t.actualRevision!==void 0&&(this.actualRevision=t.actualRevision);}};function Nt(n){return n instanceof R?true:typeof n=="object"&&n!==null&&n.name==="DocxEditorError"&&typeof n.code=="string"}function a(n){throw new R(n)}var rt=Symbol("docx-editor.runtime.internals"),qt=Symbol("docx-editor.runtime.release"),Bt=Symbol("docx-editor.runtime.rebind");function it(n){return n[rt]}var Qe=new Set(["select","expand","top","skip"]),Ke=/^[A-Za-z][A-Za-z0-9]*$/;function xe(n,t){if(n===void 0)return [];let e=typeof n=="string"?n.split(",").map(r=>r.trim()):Array.isArray(n)?n.map(r=>typeof r=="string"?r.trim():r):a({code:"InvalidArgument",target:t}),o=[];for(let r of e)(typeof r!="string"||!Ke.test(r))&&a({code:"InvalidArgument",target:t}),o.includes(r)||o.push(r);return o.length===0&&a({code:"InvalidArgument",target:t}),o}function Ae(n,t){return (typeof n!="number"||!Number.isInteger(n)||n<0)&&a({code:"InvalidArgument",target:t}),n}function Xe(n,t){n===void 0||Array.isArray(n)&&n.length===0||a({code:"InvalidArgument",target:t});}function ve(n,t){if(n===void 0)return {select:[]};if(typeof n=="string"||Array.isArray(n))return {select:xe(n,t)};(typeof n!="object"||n===null)&&a({code:"InvalidArgument",target:t});let e=n;for(let o of Object.keys(e))Qe.has(o)||a({code:"InvalidArgument",target:`${t}.${o}`});return Xe(e.expand,`${t}.expand`),{select:xe(e.select,`${t}.select`),...e.top===void 0?{}:{top:Ae(e.top,`${t}.top`)},...e.skip===void 0?{}:{skip:Ae(e.skip,`${t}.skip`)}}}var z=class{#t;#e;#o;#n;#s=new Map;#a=false;constructor(t,e,o={}){this.#t=t,this.#e=t[rt],this.#o=e,this.#n=o.nullable===true,this.#e.register(this);}get context(){return this.#t}get isNullObject(){return this.#o.isReleased&&a({code:"InvalidObjectPath",target:this.#o.label}),this.#n?(this.#o.isPending&&a({code:"PropertyNotLoaded",target:`${this.#o.label}.isNullObject`}),this.#o.isNull):false}load(t){this.#a=true;try{return this.requireUsablePath(),this.onLoad(ve(t,this.#o.label)),this}finally{this.#a=false;}}get path(){return this.#o}get internals(){return this.#e}handle(){return this.#o.handle()}requireAddressable(){this.#o.isAddressable||a({code:"InvalidObjectPath",target:this.#o.label}),this.#e.assertUsable(this.#o.label);}requireUsablePath(){(this.#o.isReleased||this.#o.isNull&&!(this.#a&&this.#n))&&a({code:"InvalidObjectPath",target:this.#o.label}),this.#e.assertUsable(this.#o.label);}enqueue(t){this.requireUsablePath(),this.#e.queue.push({...t,dependencies:[...t.dependencies??[],this.#o],...this.#a&&this.#n&&t.sort==="read"?{nullableLoad:this.#o}:{}});}loadedProperty(t){return this.#o.isReleased&&!this.#s.has(t)&&a({code:"InvalidObjectPath",target:this.#o.label}),this.#s.has(t)||a({code:"PropertyNotLoaded",target:`${this.#o.label}.${t}`}),this.#s.get(t)}hasLoadedProperty(t){return this.#s.has(t)}setLoadedProperty(t,e){this.#s.set(t,e);}[qt](){this.#o.release();}[Bt](t){this.#t=t,this.#e=t[rt];}};var $t=class n{#t=false;#e;#o;constructor(t){this.#o=t;}get value(){return this.#t||a({code:"ValueNotLoaded",target:this.#o}),this.#e}get isLoaded(){return this.#t}static create(t){let e=new n(t);return {result:e,fill(o){e.#t=true,e.#e=o;}}}};function Xt(n){return $t.create(n)}function E(n){return new R({code:"GeneralException",target:n})}function P(n,t){if(n.kind!=="text")throw E(t);return n.text}function m(n,t){if(n.kind!=="handle")throw E(t);return n.handle}function v(n,t){if(n.kind!=="handles")throw E(t);return n.handles}function O(n,t){if(n.kind!=="span")throw E(t);return n.span}function Ht(n,t){if(n.kind!=="spans")throw E(t);return n.spans}function Zt(n,t){if(n.kind!=="font")throw E(t);return n.font}function Yt(n,t){if(n.kind!=="paragraphFormat")throw E(t);return n.format}function Ot(n,t){if(n.kind!=="style")throw E(t);return n.name}function Mt(n,t){if(n.kind!=="number")throw E(t);return n.value}function at(n,t){if(n.kind!=="flag")throw E(t);return n.value}function Jt(n,t){if(n.kind!=="pageSetup")throw E(t);return n.setup}function g(n,t){if(n.kind!=="applied")throw E(t)}var c=class n{label;#t;#e;constructor(t,e,o=null){this.label=t,this.#t=e,this.#e=o;}static of(t,e){return new n(t,{status:"resolved",address:{kind:"handle",handle:e}})}static ofSpan(t,e){return new n(t,{status:"resolved",address:{kind:"span",span:e}})}static pending(t){return new n(t,{status:"pending"})}static derived(t,e){return new n(t,{status:"pending"},e)}get state(){return this.#e?this.#e.state:this.#t}get isAddressable(){return this.state.status==="resolved"}get isPending(){return this.state.status==="pending"}get isNull(){return this.state.status==="null"}get isReleased(){return this.state.status==="released"}address(){let t=this.state;if(t.status==="resolved")return t.address;a({code:"InvalidObjectPath",target:this.label});}handle(){let t=this.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.label}),t.handle}span(){let t=this.address();return t.kind!=="span"&&a({code:"InvalidObjectPath",target:this.label}),t.span}resolveTo(t){this.#o({kind:"handle",handle:t});}resolveToSpan(t){this.#o({kind:"span",span:t});}resolveNull(){this.#t.status!=="released"&&(this.#t={status:"null"});}release(){this.#e||(this.#t={status:"released"});}#o(t){this.#t.status!=="released"&&(this.#t={status:"resolved",address:t});}};function Ce(n){let t=[],e=false,o=false;for(let r of n)t.push(r.plan()),r.sort==="write"?o=true:e=true;return {operations:t,hasRead:e,hasWrite:o}}var Je=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 Ft(n,t={}){let e=Je[n.code]??"GeneralException",o=e==="StaleDocument",r=n.detail===void 0?null:automation.storeEditDiagnosticCode(n.detail),i=new R({code:e,...r===null?{}:{diagnostic:r},...t.target===void 0?{}:{target:t.target},...o&&t.expectedRevision!==void 0?{expectedRevision:t.expectedRevision}:{},...o&&t.actualRevision!==void 0?{actualRevision:t.actualRevision}:{}}),s=automation.diagnosticCause(n.detail);return s&&Re.set(i,s),i}var Re=new WeakMap;function Pe(n){return Re.get(n)}function _t(n,t,e){for(let o=0;o<n.results.length;o+=1){let r=n.results[o];if(r?.status!=="error")continue;let i=t[o]?.label;return Ft(r.error,{...i===void 0?{}:{target:i},...e===void 0?{}:{expectedRevision:e},actualRevision:n.revision})}return new R({code:"GeneralException"})}function te(n,t){if(t.results.length!==n.length)throw new R({code:"GeneralException"});for(let e=0;e<n.length;e+=1){let o=t.results[e],r=n[e];if(o.status!=="ok")throw new R({code:"GeneralException",target:r.label});r.settle(o.value);}}var Vt=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 Oe(n,t){if(Array.isArray(n)){for(let e of n)t(e);return}t(n);}var kt=class{#t;#e;constructor(t,e){this.#t=t,this.#e=e;}add(t){this.#t.assertUsable(),Oe(t,e=>{this.#o(e),this.#t.track(e);});}remove(t){this.#t.assertUsable(),Oe(t,e=>{this.#o(e),this.#t.untrack(e);});}#o(t){this.#e(t)||a({code:"InvalidObjectPath"});}};var It=class n{#t;#e=new Vt;#o=new Set;#n=new Set;#s;#a;#i;#r=false;#d=null;#c=false;constructor(t){this.#t=t,this.#s={host:t.host,capabilities:t.capabilities,...t.author===void 0?{}:{author:t.author},revisionTextView:t.revisionTextView,queue:this.#e,session:t.id,roots:()=>t.roots(),assertUsable:e=>{this.#t.assertLive(e),this.#r&&a({code:"InvalidRequestContext",...e===void 0?{}:{target:e}});},isFinished:()=>this.#r,readRevision:()=>this.#d,register:e=>{this.#o.add(e);},track:e=>{this.#n.add(e);},untrack:e=>{this.#n.delete(e);},isTracked:e=>this.#n.has(e),disown:e=>{this.#o.delete(e),this.#n.delete(e);}},this.#a=new kt(this.#s,e=>this.#o.has(e));}get document(){return this.#s.assertUsable("document"),this.#i??=this.#t.openDocument(this),this.#i}get capabilities(){return this.#t.capabilities}get trackedObjects(){return this.#a}async sync(){this.#s.assertUsable(),this.#c&&a({code:"InvalidRequestContext"});let t=this.#e.take();if(t.length!==0){this.#c=true;try{let e=t.filter(d=>!d.nullableLoad?.isNull),o=t.some(d=>d.sort==="write"),r,i=o&&this.#d!==null?this.#d:void 0,s=d=>d.dependencies?.some(h=>!h.isAddressable)??false;for(;e.some(s);){r??=o&&this.#d!==null?this.#d:this.#t.host.revision();let d=e.filter(u=>u.sort==="read"&&!s(u));d.length===0&&a({code:"InvalidObjectPath",target:e.find(s)?.label}),await this.#h(d,r,i);let h=new Set(d);e=e.filter(u=>!h.has(u)&&!u.nullableLoad?.isNull);}if(e.length){let d=r??(o&&this.#d!==null?this.#d:void 0);await this.#h(e,d,i);}}finally{for(let e of t)e.dispose?.();this.#c=false;}}}async#h(t,e,o){let r=Ce(t);try{await this.#u(t,r,e,o);}catch(i){if(!Nt(i))try{this.#t.onException?.(i,r.operations);}catch{}throw i}}async#u(t,e,o,r){let i={operations:e.operations,...o===void 0?{}:{expectedRevision:o}};if(this.#t.host.prepare){let d={...i,expectedRevision:i.expectedRevision??this.#t.host.revision()};try{await this.#t.host.prepare(d);}catch(u){throw Nt(u)?this.#p(u,e.operations):u}let h=this.#t.host.execute(d);if(!h.ok)throw this.#p(_t(h,t,r),e.operations);te(t,h),this.#d=h.revision;return}let s=this.#t.host.execute(i);if(!s.ok)throw this.#p(_t(s,t,r),e.operations);te(t,s),(e.hasRead||e.hasWrite)&&(this.#d=s.revision);}#p(t,e){try{this.#t.onRefusal?.(t,e);}catch{}return t}get[rt](){return this.#s}static begin(t){let e=new n(t);return {context:e,adopt(o){for(let r of o)e.#l(r);},finish(){e.#g();}}}#l(t){let e=t.context;if(e===this)return;let o=e[rt];if(o.session!==this.#t.id)throw new R({code:"InvalidObjectPath"});if(!o.isFinished())throw new R({code:"ObjectInUse"});if(!o.isTracked(t))throw new R({code:"InvalidObjectPath"});let r=o.readRevision();o.disown(t),t[Bt](this),this.#o.add(t),this.#n.add(t),r!==null&&this.#m(r);}#m(t){this.#d=this.#d===null?t:Math.min(this.#d,t);}#g(){if(!this.#r){this.#r=true,this.#e.clear();for(let t of this.#o)this.#n.has(t)||t[qt]();this.#o.clear();}}};function St(n,t,e){if(n.select.length===0)return t;for(let o of n.select)t.includes(o)||a({code:"InvalidArgument",target:`${e}.${o}`});return n.select}var p=class extends z{revisionTextView(){return it(this.context).revisionTextView}loadTextInto(t,e){let o=`${this.path.label}.${t}`;this.enqueue({sort:"read",label:o,plan:e,settle:r=>{this.setLoadedProperty(t,P(r,o));}});}command(t,e,o){let r=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:r,plan:e,settle:i=>g(i,r),...o?{capture:o,dispose:o}:{}});}commandDiscarding(t,e){let o=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:o,plan:e,settle:()=>{}});}commandAnswering(t,e,o,r){this.enqueue({sort:"write",label:t,plan:e,settle:o,...r?{capture:r,dispose:r}:{}});}read(t,e,o){this.enqueue({sort:"read",label:t,plan:e,settle:o});}selection(t,e){return St(t,e,this.path.label)}onLoad(t){this.selection(t,[]);}};var _e=["author","title","subject","keywords","comments","category","lastAuthor"],ht=class n extends p{#t;static of(t,e){return new n(t,c.derived("document.properties",e))}constructor(t,e){super(t,e);}get lastAuthor(){return this.loadedProperty("lastAuthor")}get author(){return this.loadedProperty("author")}set author(t){this.#e("author",t);}get title(){return this.loadedProperty("title")}set title(t){this.#e("title",t);}get subject(){return this.loadedProperty("subject")}set subject(t){this.#e("subject",t);}get keywords(){return this.loadedProperty("keywords")}set keywords(t){this.#e("keywords",t);}get comments(){return this.loadedProperty("comments")}set comments(t){this.#e("comments",t);}get category(){return this.loadedProperty("category")}set category(t){this.#e("category",t);}onLoad(t){for(let e of this.selection(t,_e))this.read(`${this.path.label}.${e}`,()=>({op:"getDocumentProperty",name:e}),o=>this.setLoadedProperty(e,P(o,this.path.label)));}#e(t,e){if(this.requireUsablePath(),(typeof e!="string"||e.length>4096)&&a({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#t){this.#t[t]=e;return}let o={[t]:e};this.#t=o,this.commandAnswering(this.path.label,()=>({op:"setDocumentProperties",values:o}),r=>{g(r,this.path.label);},()=>{this.#t===o&&(this.#t=void 0);});}};function I(n,t){let e=n.address();return t==="span"?(e.kind!=="span"&&a({code:"InvalidObjectPath",target:n.label}),{start:e.span.start,end:e.span.end}):(e.kind!=="handle"&&a({code:"InvalidObjectPath",target:n.label}),t==="body"?{body:e.handle}:{paragraph:e.handle})}function pt(n,t){return (typeof n!="string"||n.trim().length===0||n.length>255)&&a({code:"InvalidArgument",target:t}),n}var T=class extends z{#t;#e=[];constructor(t,e){super(t,e);}get items(){return this.loadedProperty("items")}fill(t,e){this.setLoadedProperty("items",this.#n(t,e,0,void 0)),this.#t={value:t,label:e};let o=this.#e.splice(0,this.#e.length);for(let r of o)this.#o(r,t);}onLoad(t){St(t,["items"],this.path.label);let e=this.path.isPending?void 0:this.listing();if(e===null)return;let o=`${this.path.label}.items`,r=t.skip??0,i=t.top;this.enqueue({sort:"read",label:o,plan:()=>{let s=e??this.listing();return s||a({code:"InvalidObjectPath",target:this.path.label}),s},settle:s=>{this.setLoadedProperty("items",this.#n(s,o,r,i));}});}edge(t,e,o){let r=`${this.path.label}.${e}()`,i=this.promised(r,o),s=this.path.isPending?void 0:this.listing();if(s===null){let d={edge:t,target:r,nullable:o,item:i};return this.#t?this.#o(d,this.#t.value):this.#e.push(d),i}return this.enqueue({sort:"read",label:r,plan:()=>{let d=s??this.listing();return d||a({code:"InvalidObjectPath",target:this.path.label}),d},settle:d=>{this.#o({edge:t,target:r,nullable:o,item:i},d);}}),i}#o(t,e){let{edge:o,target:r,nullable:i,item:s}=t,d=this.size(e,r);if(d===0){i||a({code:"ItemNotFound",target:r}),s.hydrateNull();return}let h=this.addressAt(e,r,o==="first"?0:d-1);h||a({code:"ItemNotFound",target:r}),s.hydrateAddress(h);}#n(t,e,o,r){let i=this.size(t,e),s=r===void 0?i:Math.min(i,o+r),d=[];for(let h=o;h<s;h+=1){let u=this.addressAt(t,e,h);u&&d.push(this.itemAt(`${e}[${String(h)}]`,u));}return d}},C=class extends T{size(t,e){return v(t,e).length}addressAt(t,e,o){let r=v(t,e)[o];return r?{kind:"handle",handle:r}:void 0}};var Wt=(s=>(s.unsupported="Unsupported",s.textBox="TextBox",s.geometricShape="GeometricShape",s.group="Group",s.picture="Picture",s.canvas="Canvas",s))(Wt||{}),to=["id","name","type"],ke=new Set(Object.values(Wt)),ut=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get name(){return this.loadedProperty("name")}get type(){return this.loadedProperty("type")}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=S.promisedStory(this.context,t);return this.read(t,()=>({op:"getShapeBody",shape:this.#e()}),o=>{e.hydrateAddress({kind:"handle",handle:m(o,t)});}),this.#t=e,e}onLoad(t){let e=this.selection(t,to);e.length&&this.read(this.path.label,()=>({op:"getShape",shape:this.#e()}),o=>{(o.kind!=="shape"||!ke.has(o.shape.type))&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,o.shape[r]);});}#e(){return this.requireAddressable(),this.path.handle()}},G=class n extends T{#t;#e;static of(t,e,o,r,i){return new n(t,c.derived(e,o),r,i)}constructor(t,e,o,r){super(t,e),this.#t=o,this.#e=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getByTypes(t){let e=`${this.path.label}.getByTypes`;(!Array.isArray(t)||t.some(r=>!ke.has(r)))&&a({code:"InvalidArgument",target:e});let o=this.#e?this.#e.filter(r=>t.includes(r)):[...t];return n.of(this.context,e,this.path,this.#t,o)}listing(){let t=I(this.path,this.#t);return this.#e?{op:"getShapes",span:t,types:this.#e}:{op:"getShapes",span:t}}size(t,e){return v(t,e).length}addressAt(t,e,o){let r=v(t,e)[o];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return ut.at(this.context,t,e)}promised(t,e){return ut.promised(this.context,t,e)}};function eo(n){return n==="endnote"?"Endnote":"Footnote"}var mt=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get type(){return this.loadedProperty("type")}get text(){return this.loadedProperty("text")}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=S.promisedStory(this.context,t);return this.read(t,()=>({op:"getNoteBody",note:this.#e()}),o=>{e.hydrateAddress({kind:"handle",handle:m(o,t)});}),this.#t=e,e}delete(){this.command("delete",()=>({op:"deleteNote",note:this.#e()}));}getNext(){let t=`${this.path.label}.getNext`,e=n.promised(this.context,t,false),o=this.internals.roots().document,r=`${t}.type`,i="footnote",s=c.pending(r);return this.read(r,()=>({op:"getNoteKind",note:this.#e()}),d=>{i=P(d,r)==="endnote"?"endnote":"footnote",s.resolveTo(this.#e());}),this.enqueue({sort:"read",label:t,dependencies:[s],plan:()=>({op:"getNotes",document:o,noteKind:i}),settle:d=>{let h=v(d,t),u=h.findIndex(k=>k.ref===this.#e().ref),H=u<0?void 0:h[u+1];H||a({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:H});}}),e}onLoad(t){let e=this.selection(t,["text","type"]);if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getNoteText",note:this.#e(),projection:this.revisionTextView()})),e.includes("type")){let o=`${this.path.label}.type`;this.read(o,()=>({op:"getNoteKind",note:this.#e()}),r=>{this.setLoadedProperty("type",eo(P(r,o)));});}}#e(){return this.requireAddressable(),this.path.handle()}},N=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return mt.at(this.context,t,e)}promised(t,e){return mt.promised(this.context,t,e)}};var Q=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get code(){return this.loadedProperty("code")}set code(t){if(this.requireUsablePath(),(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:`${this.path.label}.code`}),this.#t){this.#t.code=t;return}let e={code:t};this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setFieldCode",field:this.#o(),code:e.code}),o=>g(o,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}delete(){this.#e("deleteField");}updateResult(){this.#e("updateFieldResult");}#e(t){this.requireUsablePath(),this.commandAnswering(this.path.label,()=>({op:t,field:this.#o()}),e=>g(e,this.path.label));}onLoad(t){this.selection(t,["code"]).length!==0&&this.read(this.path.label,()=>({op:"getField",field:this.#o()}),e=>{e.kind!=="field"&&a({code:"GeneralException",target:this.path.label}),this.setLoadedProperty("code",e.field.code);});}#o(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},K=class n extends T{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getFields",span:I(this.path,this.#t)}}size(t,e){return v(t,e).length}addressAt(t,e,o){let r=v(t,e)[o];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return Q.at(this.context,t,e)}promised(t,e){return Q.promised(this.context,t,e)}};var oo=["width","height","lockAspectRatio","altTextDescription"],X=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get width(){return this.loadedProperty("width")}set width(t){this.#e("width",t);}get height(){return this.loadedProperty("height")}set height(t){this.#e("height",t);}get lockAspectRatio(){return this.loadedProperty("lockAspectRatio")}set lockAspectRatio(t){typeof t!="boolean"&&a({code:"InvalidArgument",target:`${this.path.label}.lockAspectRatio`}),this.#o({lockAspectRatio:t});}get altTextDescription(){return this.loadedProperty("altTextDescription")}set altTextDescription(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.altTextDescription`}),this.#o({altTextDescription:t});}delete(){let t=`${this.path.label}.delete`;this.commandAnswering(t,()=>({op:"deleteInlinePicture",picture:this.#n()}),e=>g(e,t));}onLoad(t){let e=this.selection(t,oo);e.length&&this.read(this.path.label,()=>({op:"getInlinePicture",picture:this.#n()}),o=>{o.kind!=="inlinePicture"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,o.picture[r]);});}#e(t,e){(typeof e!="number"||!Number.isFinite(e)||e<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#o({[t]:e});}#o(t){if(this.requireUsablePath(),this.#t){Object.assign(this.#t,t);return}let e=t;this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setInlinePicture",picture:this.#n(),properties:e}),o=>g(o,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}#n(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},Z=class n extends T{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getInlinePictures",span:I(this.path,this.#t)}}size(t,e){return v(t,e).length}addressAt(t,e,o){let r=v(t,e)[o];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return X.at(this.context,t,e)}promised(t,e){return X.promised(this.context,t,e)}};function q(n,t,e=0){return (!Number.isInteger(n)||n<e)&&a({code:"InvalidArgument",target:t}),n}function Ut(n,t){return (!Array.isArray(n)||n.some(e=>!Array.isArray(e)||e.some(o=>typeof o!="string")))&&a({code:"InvalidArgument",target:t}),n.map(e=>[...e])}function Ie(n,t){return n!=="Start"&&n!=="End"&&a({code:"InvalidArgument",target:t}),n==="Start"?"start":"end"}var Y=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o=false){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get values(){return this.loadedProperty("values")}set values(t){let e=Ut(t,`${this.path.label}.values`);this.command("values",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"values",values:e}}));}get style(){return this.loadedProperty("style")}set style(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.style`}),this.command("style",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"properties",styleId:t}}));}get headerRowCount(){return this.loadedProperty("headerRowCount")}set headerRowCount(t){q(t,`${this.path.label}.headerRowCount`),this.command("headerRowCount",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"properties",headerRowCount:t}}));}get rowCount(){return this.loadedProperty("rowCount")}get columnCount(){return this.loadedProperty("columnCount")}get rows(){return this.#t??=dt.of(this.context,`${this.path.label}.rows`,this.path,()=>({op:"getTableRows",table:this.path.handle()}))}getCell(t,e){let o=`${this.path.label}.getCell`;q(t,o),q(e,o);let r=st.promised(this.context,o);return this.read(o,()=>({op:"getTableCell",table:this.path.handle(),rowIndex:t,cellIndex:e}),i=>r.hydrateAddress({kind:"handle",handle:m(i,o)})),r}addRows(t,e,o){let r=`${this.path.label}.addRows`,i=Ie(t,r);q(e,r,1);let s=o===void 0?void 0:Ut(o,r),d=dt.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addRows",location:i,count:e,...s?{values:s}:{}}}),h=>d.fill(h,r)),d}addColumns(t,e,o){let r=`${this.path.label}.addColumns`,i=Ie(t,r);q(e,r,1);let s=o===void 0?void 0:Ut(o,r);this.command("addColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addColumns",location:i,count:e,...s?{values:s}:{}}}));}deleteRows(t,e){e===void 0&&(e=1),q(t,this.path.label),q(e,this.path.label,1),this.command("deleteRows",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"deleteRows",index:t,count:e}}));}deleteColumns(t,e){e===void 0&&(e=1),q(t,this.path.label),q(e,this.path.label,1),this.command("deleteColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"deleteColumns",index:t,count:e}}));}delete(){this.command("delete",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"delete"}}));}onLoad(t){let e=this.selection(t,["values","style","headerRowCount","rowCount","columnCount"]);this.read(this.path.label,()=>({op:"getTable",table:this.path.handle()}),o=>{o.kind!=="table"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,o.table[r]);});}},gt=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o=false){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}insertRows(t,e,o){let r=`${this.path.label}.insertRows`;t!=="Before"&&t!=="After"&&a({code:"InvalidArgument",target:r}),q(e,r,1);let i=o===void 0?void 0:Ut(o,r),s=dt.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"insertTableRows",row:this.path.handle(),location:t==="Before"?"before":"after",count:e,...i?{values:i}:{}}),d=>s.fill(d,r)),s}get cells(){return this.#t??=Lt.of(this.context,`${this.path.label}.cells`,this.path,()=>({op:"getTableCells",row:this.path.handle()}))}},st=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o=false){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=S.promisedStory(this.context,t);return this.read(t,()=>({op:"getTableCellBody",cell:this.path.handle()}),o=>e.hydrateAddress({kind:"handle",handle:m(o,t)})),this.#t=e,e}get value(){return this.loadedProperty("value")}set value(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.value`}),this.command("value",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{value:t}}));}get columnWidth(){return this.loadedProperty("columnWidth")}set columnWidth(t){(typeof t!="number"||!Number.isFinite(t)||t<=0)&&a({code:"InvalidArgument",target:`${this.path.label}.columnWidth`}),this.command("columnWidth",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{columnWidth:t}}));}get shadingColor(){return this.loadedProperty("shadingColor")}set shadingColor(t){typeof t!="string"&&a({code:"InvalidArgument",target:`${this.path.label}.shadingColor`}),this.command("shadingColor",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{shadingColor:t}}));}get verticalAlignment(){return this.loadedProperty("verticalAlignment")}set verticalAlignment(t){t!=="Top"&&t!=="Center"&&t!=="Bottom"&&a({code:"InvalidArgument",target:`${this.path.label}.verticalAlignment`}),this.command("verticalAlignment",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{verticalAlignment:t}}));}onLoad(t){let e=this.selection(t,["value","columnWidth","shadingColor","verticalAlignment"]);this.read(this.path.label,()=>({op:"getTableCellProperties",cell:this.path.handle()}),o=>{o.kind!=="tableCell"&&a({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,o.cell[r]);});}},J=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}static over(t,e,o,r){return n.of(t,e,o,()=>({op:"getTables",scope:r()}))}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return Y.at(this.context,t,e)}promised(t,e){return Y.promised(this.context,t,e)}},dt=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return gt.at(this.context,t,e)}promised(t,e){return gt.promised(this.context,t,e)}},Lt=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return st.at(this.context,t,e)}promised(t,e){return st.promised(this.context,t,e)}};var ee=(i=>(i.replace="Replace",i.start="Start",i.end="End",i.before="Before",i.after="After",i))(ee||{}),oe=(s=>(s.mixed="Mixed",s.unknown="Unknown",s.left="Left",s.centered="Centered",s.right="Right",s.justified="Justified",s))(oe||{}),ne=(e=>(e.portrait="Portrait",e.landscape="Landscape",e))(ne||{}),re=(o=>(o.off="Off",o.trackAll="TrackAll",o.trackMineOnly="TrackMineOnly",o))(re||{}),ie=(r=>(r.mixed="Mixed",r.top="Top",r.center="Center",r.bottom="Bottom",r))(ie||{}),ae=(d=>(d.line="Line",d.page="Page",d.next="Next",d.sectionNext="SectionNext",d.sectionContinuous="SectionContinuous",d.sectionEven="SectionEven",d.sectionOdd="SectionOdd",d))(ae||{}),se=(x=>(x.unknown="Unknown",x.richText="RichText",x.plainText="PlainText",x.picture="Picture",x.buildingBlockGallery="BuildingBlockGallery",x.checkBox="CheckBox",x.comboBox="ComboBox",x.datePicker="DatePicker",x.dropDownList="DropDownList",x.group="Group",x.repeatingSection="RepeatingSection",x.plainTextInline="PlainTextInline",x.plainTextParagraph="PlainTextParagraph",x.richTextInline="RichTextInline",x.richTextParagraphs="RichTextParagraphs",x.richTextTable="RichTextTable",x.richTextTableCell="RichTextTableCell",x.richTextTableRow="RichTextTableRow",x))(se||{}),de=(A=>(A.all="All",A.atMentions="AtMentions",A.commentReactions="CommentReactions",A.comments="Comments",A.contentType="ContentType",A.documentIntelligence="DocumentIntelligence",A.documentManagementPolicy="DocumentManagementPolicy",A.documentProperties="DocumentProperties",A.documentServerProperties="DocumentServerProperties",A.documentTasks="DocumentTasks",A.documentWorkspace="DocumentWorkspace",A.emailHeader="EmailHeader",A.inkAnnotations="InkAnnotations",A.removePersonalInformation="RemovePersonalInformation",A.revisions="Revisions",A.routingSlip="RoutingSlip",A.sendForReview="SendForReview",A.taskpaneWebExtensions="TaskpaneWebExtensions",A.template="Template",A.versions="Versions",A))(de||{});var no=["Replace","Start","End"],ro=["Start","End"],io=["Replace","Start","End"],ao=["Before","After"],so=["Replace","Start","End","Before","After"],lo=["Select","Start","End"];function ft(n,t,e){return (typeof n!="string"||!t.includes(n))&&a({code:"InvalidArgument",target:e}),n}var Se=(n,t)=>ft(n,no,t),Le=(n,t)=>ft(n,ro,t),we=(n,t)=>ft(n,io,t),je=(n,t)=>ft(n,ao,t),wt=(n,t)=>ft(n,so,t),zt=(n,t)=>n===void 0?"Select":ft(n,lo,t);function L(n,t){return typeof n!="string"&&a({code:"InvalidArgument",target:t}),/[\r\n\f\u2028\u2029]/.test(n)&&a({code:"InvalidArgument",target:t}),n}var co=8,ce=(d=>(d.custom="Custom",d.solid="Solid",d.hollow="Hollow",d.square="Square",d.diamonds="Diamonds",d.arrow="Arrow",d.checkmark="Checkmark",d))(ce||{}),he=(s=>(s.none="None",s.arabic="Arabic",s.upperRoman="UpperRoman",s.lowerRoman="LowerRoman",s.upperLetter="UpperLetter",s.lowerLetter="LowerLetter",s))(he||{}),D=class n extends p{#t;#e=new Map;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get paragraphs(){return this.#t??=w.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getListParagraphs",list:this.#n()})),this.#t}getLevelParagraphs(t){let e=`${this.path.label}.getLevelParagraphs`,o=le(t,e);return w.overListing(this.context,e,this.path,()=>({op:"getListParagraphs",list:this.#n(),level:o}))}insertParagraph(t,e){let o=`${this.path.label}.insertParagraph`,r=L(t,o);e!=="Start"&&e!=="End"&&e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:o});let i=j.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertListParagraph",list:this.#n(),where:e==="Start"||e==="Before"?"start":"end",text:r}),s=>{i.hydrateAddress({kind:"handle",handle:m(s,o)});}),i}setLevelBullet(t,e,o,r){this.#o(t,{bullet:e,...o===void 0?{}:{charCode:o},...r===void 0?{}:{fontName:r}});}setLevelNumbering(t,e,o){this.#o(t,{numbering:e,...o===void 0?{}:{formatString:[...o]}});}setLevelStartingNumber(t,e){this.#o(t,{startingNumber:e});}setLevelIndents(t,e,o){this.#o(t,{textIndent:e,bulletNumberPictureIndent:o});}#o(t,e){let o=`${this.path.label}.levelFormat`,r=le(t,o);this.requireUsablePath();let i=this.#e.get(r);if(i){Object.assign(i,e),"bullet"in e&&(delete i.numbering,delete i.formatString),"numbering"in e&&(delete i.bullet,delete i.charCode,delete i.fontName);return}let s={...e};this.#e.set(r,s),this.commandAnswering(o,()=>({op:"setListLevelFormat",list:this.#n(),level:r,format:s}),d=>{g(d,o);},()=>{this.#e.get(r)===s&&this.#e.delete(r);});}onLoad(t){if(!this.selection(t,["id"]).includes("id"))return;let e=`${this.path.label}.id`;this.read(e,()=>({op:"getListId",list:this.#n()}),o=>{this.setLoadedProperty("id",Mt(o,e));});}#n(){return this.requireAddressable(),this.path.handle()}},bt=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}getById(t){let e=`${this.path.label}.getById`,o=ho(t,e),r=this.#t,i=D.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getListById",body:r,id:o}),settle:s=>{i.hydrateAddress({kind:"handle",handle:m(s,e)});}}),i}listing(){return {op:"getLists",body:this.#t}}itemAt(t,e){return D.at(this.context,t,e)}promised(t,e){return D.promised(this.context,t,e)}},yt=class n extends p{static of(t,e,o){return new n(t,c.derived(e,o))}constructor(t,e){super(t,e);}get level(){return this.loadedProperty("level")}set level(t){let e=`${this.path.label}.level`,o=le(t,e);this.commandAnswering(e,()=>({op:"setListLevel",paragraph:this.#t(),level:o}),r=>{g(r,e);});}onLoad(t){if(!this.selection(t,["level"]).includes("level"))return;let e=`${this.path.label}.level`;this.read(e,()=>({op:"getListLevel",paragraph:this.#t()}),o=>{this.setLoadedProperty("level",Mt(o,e));});}#t(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}};function le(n,t){return (!Number.isInteger(n)||n<0||n>co)&&a({code:"InvalidArgument",target:t}),n}function ho(n,t){return (!Number.isInteger(n)||n<=0)&&a({code:"InvalidArgument",target:t}),n}var pe=(b=>(b.mixed="Mixed",b.none="None",b.hidden="Hidden",b.dotLine="DotLine",b.single="Single",b.word="Word",b.double="Double",b.thick="Thick",b.dotted="Dotted",b.dottedHeavy="DottedHeavy",b.dashLine="DashLine",b.dashLineHeavy="DashLineHeavy",b.dashLineLong="DashLineLong",b.dashLineLongHeavy="DashLineLongHeavy",b.dotDashLine="DotDashLine",b.dotDashLineHeavy="DotDashLineHeavy",b.twoDotDashLine="TwoDotDashLine",b.twoDotDashLineHeavy="TwoDotDashLineHeavy",b.wave="Wave",b.waveHeavy="WaveHeavy",b.waveDouble="WaveDouble",b))(pe||{}),po=["bold","italic","color","name","size","underline","strikeThrough","highlightColor","subscript","superscript"],B=class n extends p{#t;#e;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}get bold(){return this.loadedProperty("bold")}set bold(t){this.#o("bold",jt(t,`${this.path.label}.bold`));}get italic(){return this.loadedProperty("italic")}set italic(t){this.#o("italic",jt(t,`${this.path.label}.italic`));}get color(){return this.loadedProperty("color")}set color(t){this.#o("color",Gt(t,`${this.path.label}.color`));}get name(){return this.loadedProperty("name")}set name(t){this.#o("name",Gt(t,`${this.path.label}.name`));}get size(){return this.loadedProperty("size")}set size(t){this.#o("size",uo(t,`${this.path.label}.size`));}get underline(){return this.loadedProperty("underline")}set underline(t){this.#o("underline",Gt(t,`${this.path.label}.underline`));}get highlightColor(){return this.loadedProperty("highlightColor")}set highlightColor(t){this.#o("highlightColor",t===null?null:Gt(t,`${this.path.label}.highlightColor`));}get strikeThrough(){return this.loadedProperty("strikeThrough")}set strikeThrough(t){this.#o("strikeThrough",jt(t,`${this.path.label}.strikeThrough`));}get subscript(){return this.loadedProperty("subscript")}set subscript(t){this.#o("subscript",jt(t,`${this.path.label}.subscript`));}get superscript(){return this.loadedProperty("superscript")}set superscript(t){this.#o("superscript",jt(t,`${this.path.label}.superscript`));}onLoad(t){let e=this.selection(t,po);if(e.length===0)return;let o=`${this.path.label}.font`;this.read(o,()=>({op:"getFont",span:this.#n()}),r=>{let i=Zt(r,o);for(let s of e)this.setLoadedProperty(s,i[s]);});}#o(t,e){if(this.requireUsablePath(),this.#e){this.#e[t]=e,t==="subscript"&&e===true&&(this.#e.superscript=false),t==="superscript"&&e===true&&(this.#e.subscript=false);return}let o={[t]:e};t==="subscript"&&e===true&&(o.superscript=false),t==="superscript"&&e===true&&(o.subscript=false),this.#e=o;let r=`${this.path.label}.${t}`;this.commandAnswering(this.path.label,()=>({op:"setFont",span:this.#n(),font:o}),i=>{g(i,r);},()=>{this.#e===o&&(this.#e=void 0);});}#n(){return this.requireAddressable(),I(this.path,this.#t)}};function jt(n,t){return typeof n!="boolean"&&a({code:"InvalidArgument",target:t}),n}function uo(n,t){return (typeof n!="number"||!Number.isFinite(n))&&a({code:"InvalidArgument",target:t}),n}function Gt(n,t){return (typeof n!="string"||n.length===0)&&a({code:"InvalidArgument",target:t}),n}var mo=16,j=class n extends p{#t;#e;#o;#n;#s;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get uniqueLocalId(){return this.loadedProperty("uniqueLocalId")}get style(){return this.loadedProperty("style")}set style(t){this.#a("style",pt(t,`${this.path.label}.style`));}get shapes(){return this.#e??=G.of(this.context,`${this.path.label}.shapes`,this.path,"paragraph"),this.#e}get font(){return this.#t??=B.of(this.context,`${this.path.label}.font`,this.path,"paragraph"),this.#t}get alignment(){return this.loadedProperty("alignment")}set alignment(t){this.#a("alignment",fo(t,`${this.path.label}.alignment`));}get readingOrder(){return this.loadedProperty("readingOrder")}set readingOrder(t){this.#a("readingOrder",bo(t,`${this.path.label}.readingOrder`));}get firstLineIndent(){return this.loadedProperty("firstLineIndent")}set firstLineIndent(t){this.#a("firstLineIndent",xt(t,`${this.path.label}.firstLineIndent`));}get leftIndent(){return this.loadedProperty("leftIndent")}set leftIndent(t){this.#a("leftIndent",xt(t,`${this.path.label}.leftIndent`));}get rightIndent(){return this.loadedProperty("rightIndent")}set rightIndent(t){this.#a("rightIndent",xt(t,`${this.path.label}.rightIndent`));}get lineSpacing(){return this.loadedProperty("lineSpacing")}set lineSpacing(t){this.#a("lineSpacing",xt(t,`${this.path.label}.lineSpacing`));}get spaceBefore(){return this.loadedProperty("spaceBefore")}set spaceBefore(t){this.#a("spaceBefore",xt(t,`${this.path.label}.spaceBefore`));}get spaceAfter(){return this.loadedProperty("spaceAfter")}set spaceAfter(t){this.#a("spaceAfter",xt(t,`${this.path.label}.spaceAfter`));}get list(){return this.#o??=this.#i(`${this.path.label}.list`),this.#o}getRange(t="Whole"){let e=`${this.path.label}.getRange`;["Whole","Content","Start","End","Before","After"].includes(t)||a({code:"InvalidArgument",target:e});let o=y.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{paragraph:this.#r()},location:t}),r=>{o.hydrateAddress({kind:"span",span:O(r,e)});}),o}startNewList(){let t=`${this.path.label}.startNewList`,e=D.promised(this.context,t,false);return this.commandAnswering(t,()=>({op:"startNewList",paragraph:this.#r()}),o=>{e.hydrateAddress({kind:"handle",handle:m(o,t)});}),e}attachToList(t,e){let o=`${this.path.label}.attachToList`;(!Number.isSafeInteger(t)||t<=0||!Number.isInteger(e)||e<0||e>8)&&a({code:"InvalidArgument",target:o});let r=D.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"attachToList",paragraph:this.#r(),listId:t,level:e}),i=>{r.hydrateAddress({kind:"handle",handle:m(i,o)});}),r}detachFromList(){let t=`${this.path.label}.detachFromList`;this.commandAnswering(t,()=>({op:"detachFromList",paragraph:this.#r()}),e=>{g(e,t);});}get listItem(){return this.#n??=yt.of(this.context,`${this.path.label}.listItem`,this.path),this.#n}clear(){this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{paragraph:this.#r()},text:""}));}delete(){let t=`${this.path.label}.delete`;this.commandAnswering(t,()=>({op:"deleteParagraph",paragraph:this.#r()}),e=>{e.kind!=="applied"&&e.kind!=="span"&&a({code:"GeneralException",target:t});});}insertText(t,e){let o=`${this.path.label}.insertText`,r=L(t,o),i=we(e,o),s=y.promised(this.context,o,false);return this.commandAnswering(o,()=>i==="Replace"?{op:"replaceSpan",span:{paragraph:this.#r()},text:r}:{op:"insertText",at:{paragraph:this.#r(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:O(d,o)});}),s}insertParagraph(t,e){let o=`${this.path.label}.insertParagraph`,r=L(t,o),i=je(e,o),s=n.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertParagraph",anchor:{paragraph:this.#r()},where:i==="Before"?"before":"after",text:r}),d=>{d.kind!=="handle"&&a({code:"GeneralException",target:o}),s.hydrateAddress({kind:"handle",handle:d.handle});}),s}split(t,e,o){let r=`${this.path.label}.split`,i=yo(t,r),s=Te(e,`${r}.trimDelimiters`),d=Te(o,`${r}.trimSpacing`),h=$.answered(this.context,r,this.path);return this.commandAnswering(r,()=>({op:"splitParagraph",paragraph:this.#r(),delimiters:i,...s?{trimDelimiters:true}:{},...d?{trimSpacing:true}:{}}),u=>{h.fill(u,r);}),h}onLoad(t){let e=this.selection(t,["text","uniqueLocalId",...Ee]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#r(),projection:this.revisionTextView()})),e.includes("uniqueLocalId")&&this.loadTextInto("uniqueLocalId",()=>({op:"getParagraphId",paragraph:this.#r()}));let o=Ee.filter(i=>e.includes(i));if(o.length===0)return;let r=`${this.path.label}.paragraphFormat`;this.read(r,()=>({op:"getParagraphFormat",paragraph:{paragraph:this.#r()}}),i=>{let s=Yt(i,r);for(let d of o)this.setLoadedProperty(d,s[d]);});}#a(t,e){if(this.requireUsablePath(),this.#s){this.#s[t]=e;return}let o={[t]:e};this.#s=o;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.paragraphFormat`,()=>({op:"setParagraphFormat",paragraph:{paragraph:this.#r()},format:o}),i=>{g(i,r);},()=>{this.#s===o&&(this.#s=void 0);});}#i(t){let e=D.promised(this.context,t,false);return this.read(t,()=>({op:"getParagraphList",paragraph:this.#r()}),o=>{e.hydrateAddress({kind:"handle",handle:m(o,t)});}),e}#r(){return this.requireAddressable(),this.path.handle()}},Ee=["style","alignment","firstLineIndent","leftIndent","rightIndent","lineSpacing","spaceBefore","spaceAfter","readingOrder"],go=["Left","Centered","Right","Justified"];function fo(n,t){return go.includes(n)||a({code:"InvalidArgument",target:t}),n}function bo(n,t){return n!=="LeftToRight"&&n!=="RightToLeft"&&a({code:"InvalidArgument",target:t}),n}function xt(n,t){return (typeof n!="number"||!Number.isFinite(n))&&a({code:"InvalidArgument",target:t}),n}function yo(n,t){(!Array.isArray(n)||n.length===0||n.length>mo)&&a({code:"InvalidArgument",target:t});for(let e of n)(typeof e!="string"||e.length===0)&&a({code:"InvalidArgument",target:t});return [...n]}function Te(n,t){return n!==void 0&&typeof n!="boolean"&&a({code:"InvalidArgument",target:t}),n===true}var w=class n extends T{#t;static of(t,e,o){return new n(t,c.derived(e,o),null)}static overListing(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){if(this.#t)return this.#t();let t=this.path.address();return t.kind==="handle"?{op:"getParagraphs",body:t.handle}:{op:"getSpanParagraphs",span:t.span}}size(t,e){return v(t,e).length}addressAt(t,e,o){let r=v(t,e)[o];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return j.at(this.context,t,e)}promised(t,e){return j.promised(this.context,t,e)}},$=class n extends T{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}static answered(t,e,o){return new n(t,c.derived(e,o),null)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t?this.#t():null}size(t,e){return Ht(t,e).length}addressAt(t,e,o){let r=Ht(t,e)[o];return r?{kind:"span",span:r}:void 0}itemAt(t,e){return y.at(this.context,t,e)}promised(t,e){return y.promised(this.context,t,e)}};var Ne=4096,M=class n extends p{#t;#e=new Map;#o;#n;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get tag(){return this.loadedProperty("tag")}set tag(t){this.#a("tag",{tag:ue(t,`${this.path.label}.tag`)});}get title(){return this.loadedProperty("title")}set title(t){this.#a("title",{title:ue(t,`${this.path.label}.title`)});}get subtype(){return this.loadedProperty("subtype")}get isBound(){return this.loadedProperty("isBound")}get cannotDelete(){let t=this.loadedProperty("lock");return t==="sdtLocked"||t==="sdtContentLocked"}set cannotDelete(t){this.#i("cannotDelete",t);}get cannotEdit(){let t=this.loadedProperty("lock");return t==="contentLocked"||t==="sdtContentLocked"}set cannotEdit(t){this.#i("cannotEdit",t);}get placeholderShown(){return this.loadedProperty("placeholderShown")}get temporary(){return this.loadedProperty("temporary")}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#o??=w.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getContentControlParagraphs",contentControl:this.#r()})),this.#o}get contentControls(){return this.#n??=F.of(this.context,`${this.path.label}.contentControls`,this.path,{contentControl:this.#r()}),this.#n}getRange(t){let e=`${this.path.label}.getRange`,o=xo(t??"Whole",e),r=this.#e.get(o);if(r)return r;let i=this.#s(e,o);return this.#e.set(o,i),i}setValue(t){let e=`${this.path.label}.setValue`,o=Ao(t,e);this.command("setValue",()=>({op:"setContentControlValue",contentControl:this.#r(),value:o}));}insertText(t,e){let o=`${this.path.label}.insertText`,r=L(t,o),i=e==="Replace"?"replace":e==="Start"?"start":e==="End"?"end":a({code:"InvalidArgument",target:o}),s=y.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertContentControlText",contentControl:this.#r(),text:r,at:i}),d=>{s.hydrateAddress({kind:"span",span:O(d,o)});}),s}delete(t){let e=`${this.path.label}.delete`;typeof t!="boolean"&&a({code:"InvalidArgument",target:e}),this.command("delete",()=>({op:"deleteContentControl",contentControl:this.#r(),keepContent:t}));}onLoad(t){let e=this.selection(t,["id","tag","title","subtype","isBound","text","cannotDelete","cannotEdit","placeholderShown","temporary"]);if(e.includes("id")&&this.loadTextInto("id",()=>({op:"getContentControlFileId",contentControl:this.#r()})),e.includes("tag")&&this.loadTextInto("tag",()=>({op:"getContentControlTag",contentControl:this.#r()})),e.includes("title")&&this.loadTextInto("title",()=>({op:"getContentControlTitle",contentControl:this.#r()})),e.includes("subtype")&&this.loadTextInto("subtype",()=>({op:"getContentControlSubtype",contentControl:this.#r()})),e.includes("isBound")){let r=`${this.path.label}.isBound`;this.read(r,()=>({op:"getContentControlIsBound",contentControl:this.#r()}),i=>{this.setLoadedProperty("isBound",at(i,r));});}if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getContentControlText",contentControl:this.#r(),projection:this.revisionTextView()})),e.includes("cannotDelete")||e.includes("cannotEdit")){let r=`${this.path.label}.lock`;this.read(r,()=>({op:"getContentControlLock",contentControl:this.#r()}),i=>{this.setLoadedProperty("lock",P(i,r));});}if(e.includes("placeholderShown")){let r=`${this.path.label}.placeholderShown`;this.read(r,()=>({op:"getContentControlPlaceholderShown",contentControl:this.#r()}),i=>{this.setLoadedProperty("placeholderShown",at(i,r));});}if(!e.includes("temporary"))return;let o=`${this.path.label}.temporary`;this.read(o,()=>({op:"getContentControlTemporary",contentControl:this.#r()}),r=>{this.setLoadedProperty("temporary",at(r,o));});}#s(t,e){let o=y.promised(this.context,t,false);return this.read(t,()=>({op:"getContentControlRange",contentControl:this.#r(),location:e}),r=>{o.hydrateAddress({kind:"span",span:O(r,t)});}),o}#a(t,e){this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#r(),...e}));}#i(t,e){let o=`${this.path.label}.${t}`;if(typeof e!="boolean"&&a({code:"InvalidArgument",target:o}),this.requireUsablePath(),this.#t){this.#t[t]=e;return}let r={[t]:e};this.#t=r,this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#r(),...r}),()=>{this.#t===r&&(this.#t=void 0);});}#r(){return this.requireAddressable(),this.path.handle()}},F=class n extends C{#t;#e;static of(t,e,o,r){return new n(t,c.derived(e,o),r,()=>({op:"getContentControls",scope:r}))}constructor(t,e,o,r){super(t,e),this.#t=o,this.#e=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getById(t){let e=`${this.path.label}.getById`;Number.isInteger(t)||a({code:"InvalidArgument",target:e});let o=this.#t,r=M.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getContentControlById",scope:o,id:t}),settle:i=>{r.hydrateAddress({kind:"handle",handle:m(i,e)});}}),r}getByTag(t){let e=`${this.path.label}.getByTag`,o=De(t,e),r=this.#t;return new n(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTag",scope:r,tag:o}))}getByTitle(t){let e=`${this.path.label}.getByTitle`,o=De(t,e),r=this.#t;return new n(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTitle",scope:r,title:o}))}listing(){return this.#e()}itemAt(t,e){return M.at(this.context,t,e)}promised(t,e){return M.promised(this.context,t,e)}};function ue(n,t){return (typeof n!="string"||n.length>Ne)&&a({code:"InvalidArgument",target:t}),n}function De(n,t){let e=ue(n,t);return e.length===0&&a({code:"InvalidArgument",target:t}),e}function xo(n,t){switch(n){case "Whole":return "whole";case "Content":return "content";case "Start":return "start";case "End":return "end";case "Before":return "before";case "After":return "after";default:return a({code:"InvalidArgument",target:t})}}function Ao(n,t){(typeof n!="object"||n===null)&&a({code:"InvalidArgument",target:t});let e=n;if(e.kind==="text"||e.kind==="listItem"){let o=e.kind==="text"?e.text:e.value;return (typeof o!="string"||o.length>Ne)&&a({code:"InvalidArgument",target:t}),e.kind==="text"?{kind:"text",text:o}:{kind:"listItem",value:o}}if(e.kind==="checkbox")return typeof e.checked!="boolean"&&a({code:"InvalidArgument",target:t}),{kind:"checkbox",checked:e.checked};if(e.kind==="date")return (typeof e.iso!="string"||e.iso.length>64)&&a({code:"InvalidArgument",target:t}),{kind:"date",iso:e.iso};a({code:"InvalidArgument",target:t});}function vo(n,t){return t<1||t>12?0:t===2?n%4===0&&n%100!==0||n%400===0?29:28:t===4||t===6||t===9||t===11?30:31}function qe(n){if(n.length===0)return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/.exec(n.trim());if(!t)return null;let e=Number(t[1]),o=Number(t[2]),r=Number(t[3]),i=vo(e,o);if(e===0||i===0||r<1||r>i)return null;let s=Number(t[4]),d=Number(t[5]),h=Number(t[6]);if(s>23||d>59||h>59)return null;let u=t[7],H=u===void 0?0:Number(u.padEnd(3,"0").slice(0,3));if(Number.isNaN(H))return null;let k=`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}.${String(H).padStart(3,"0")}Z`,Dt=Date.parse(k);if(Number.isNaN(Dt))return null;let f=t[8];if(f==="Z")return new Date(Dt);let W=Number(f.slice(1,3)),U=Number(f.slice(4,6));if(U>59||W>14||W===14&&U!==0)return null;let ct=f[0]==="+"?1:-1,nt=new Date(Dt-ct*(W*36e5+U*6e4));return Number.isNaN(nt.getTime())?null:nt}var Qt=class extends p{hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get authorName(){return this.loadedProperty("authorName")}get creationDate(){return this.loadedProperty("creationDate")}get id(){return this.loadedProperty("id")}get text(){return this.loadedProperty("text")}delete(){this.command("delete",()=>({op:"deleteComment",comment:this.commentHandle()}));}loadCommentFields(t,e){let o=this.selection(t,["authorName","creationDate","id","text",...e]);if(o.includes("authorName")&&this.loadTextInto("authorName",()=>({op:"getCommentAuthor",comment:this.commentHandle()})),o.includes("text")&&this.loadTextInto("text",()=>({op:"getCommentText",comment:this.commentHandle()})),o.includes("id")&&this.loadTextInto("id",()=>({op:"getCommentId",comment:this.commentHandle()})),o.includes("creationDate")){let i=`${this.path.label}.creationDate`;this.read(i,()=>({op:"getCommentDate",comment:this.commentHandle()}),s=>{this.setLoadedProperty("creationDate",qe(P(s,i)));});}if(!o.includes("resolved"))return;let r=`${this.path.label}.resolved`;this.read(r,()=>({op:"getCommentResolved",comment:this.commentHandle()}),i=>{this.setLoadedProperty("resolved",at(i,r));});}commentHandle(){return this.requireAddressable(),this.path.handle()}},lt=class n extends Qt{static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}onLoad(t){this.loadCommentFields(t,[]);}},Et=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return lt.at(this.context,t,e)}promised(t,e){return lt.promised(this.context,t,e)}},_=class n extends Qt{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}get resolved(){return this.loadedProperty("resolved")}set resolved(t){let e=`${this.path.label}.resolved`;typeof t!="boolean"&&a({code:"InvalidArgument",target:e}),this.commandAnswering(e,()=>({op:"setCommentResolved",comment:this.commentHandle(),resolved:t}),o=>{g(o,e);});}get replies(){return this.#t??=Et.of(this.context,`${this.path.label}.replies`,this.path,()=>({op:"getCommentReplies",comment:this.commentHandle()})),this.#t}getRange(){let t=`${this.path.label}.getRange`,e=y.promised(this.context,t,false);return this.read(t,()=>({op:"getCommentRange",comment:this.commentHandle()}),o=>{e.hydrateAddress({kind:"span",span:O(o,t)});}),e}reply(t){let e=`${this.path.label}.reply`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:e});let o=this.internals.author;(typeof o!="string"||o.trim().length===0)&&a({code:"NotSupported",target:e});let r=lt.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"replyToComment",comment:this.commentHandle(),text:t,author:o}),i=>{r.hydrateAddress({kind:"handle",handle:m(i,e)});}),r}onLoad(t){this.loadCommentFields(t,["resolved"]);}},tt=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return _.at(this.context,t,e)}promised(t,e){return _.promised(this.context,t,e)}},V=class n extends p{static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get author(){return this.loadedProperty("author")}get date(){return this.loadedProperty("date")}get type(){return this.loadedProperty("type")}get range(){let t=`${this.path.label}.range`,e=y.promised(this.context,t,false);return this.read(t,()=>({op:"getRevisionRange",revision:this.#t()}),o=>{e.hydrateAddress({kind:"span",span:O(o,t)});}),e}accept(){this.command("accept",()=>({op:"acceptRevision",revision:this.#t()}));}reject(){this.command("reject",()=>({op:"rejectRevision",revision:this.#t()}));}onLoad(t){let e=this.selection(t,["author","date","type"]);if(e.includes("author")&&this.loadTextInto("author",()=>({op:"getRevisionAuthor",revision:this.#t()})),e.includes("type")&&this.loadTextInto("type",()=>({op:"getRevisionType",revision:this.#t()})),!e.includes("date"))return;let o=`${this.path.label}.date`;this.read(o,()=>({op:"getRevisionDate",revision:this.#t()}),r=>{this.setLoadedProperty("date",qe(P(r,o)));});}static batchHandle(t,e,o="RevisionCollection.resolve"){return (!(t instanceof n)||t.context!==e)&&a({code:"InvalidArgument",target:o}),t.#t()}#t(){return this.requireAddressable(),this.path.handle()}},et=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}acceptAll(){let t=this.#t;this.commandOn("acceptAll",()=>({op:"acceptAllRevisions",body:t}));}rejectAll(){let t=this.#t;this.commandOn("rejectAll",()=>({op:"rejectAllRevisions",body:t}));}resolve(t,e){let o=`${this.path.label}.resolve`;(!["accept","reject"].includes(t)||e!==void 0&&!Array.isArray(e))&&a({code:"InvalidArgument",target:o});let r=e===void 0?void 0:[...e],{result:i,fill:s}=Xt(o);return this.enqueue({sort:"write",label:o,plan:()=>({op:"resolveRevisionBatch",body:this.#t,action:t,...r===void 0?{}:{revisions:r.map(d=>V.batchHandle(d,this.context))}}),settle:d=>{d.kind!=="revisionBatch"&&a({code:"GeneralException",target:o}),s(d.result);}}),i}setAuthor(t,e,o){let r=`${this.path.label}.setAuthor`,i=o?.date,s=Array.isArray(e)?e:void 0,d=e!==void 0&&!Array.isArray(e)?e?.authors:void 0;(typeof t!="string"||t.trim().length===0||e!==void 0&&!Array.isArray(e)&&(typeof e!="object"||e===null||!Array.isArray(d)||d.some(k=>typeof k!="string"))||o!==void 0&&(typeof o!="object"||o===null)||i!==void 0&&(!(i instanceof Date)||Number.isNaN(i.getTime()))||s?.some(k=>!(k instanceof V)||k.context!==this.context))&&a({code:"InvalidArgument",target:r});let h=s===void 0?void 0:[...s],{result:u,fill:H}=Xt(r);return this.enqueue({sort:"write",label:r,plan:()=>({op:"setRevisionAuthorBatch",body:this.#t,author:t,...i===void 0?{}:{date:i.toISOString()},...d===void 0?{}:{authors:[...d]},...h===void 0?{}:{revisions:h.map(k=>V.batchHandle(k,this.context,r))}}),settle:k=>{k.kind!=="revisionAuthors"&&a({code:"GeneralException",target:r}),H(k.result);}}),u}listing(){return {op:"getRevisions",body:this.#t}}itemAt(t,e){return V.at(this.context,t,e)}promised(t,e){return V.promised(this.context,t,e)}commandOn(t,e){let o=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:o,plan:e,settle:r=>{g(r,o);}});}};var Co=new Set(["matchCase","matchWholeWord","ignorePunct","ignoreSpace","matchWildcards"]);function Kt(n,t){if(n===void 0)return;typeof n!="object"&&a({code:"InvalidArgument",target:t});for(let[o,r]of Object.entries(n))Co.has(o)||a({code:"InvalidArgument",target:`${t}.${o}`}),r!==void 0&&typeof r!="boolean"&&a({code:"InvalidArgument",target:`${t}.${o}`});let e={...n.matchCase===void 0?{}:{matchCase:n.matchCase},...n.matchWholeWord===void 0?{}:{matchWholeWord:n.matchWholeWord},...n.ignorePunct===void 0?{}:{ignorePunct:n.ignorePunct},...n.ignoreSpace===void 0?{}:{ignoreSpace:n.ignoreSpace},...n.matchWildcards===void 0?{}:{matchWildcards:n.matchWildcards}};return Object.keys(e).length===0?void 0:e}var y=class n extends p{#t;#e;#o;#n;#s;#a;static at(t,e,o){return o.kind!=="span"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.ofSpan(e,o.span),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="span"?this.path.resolveToSpan(t.span):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get font(){return this.#s??=B.of(this.context,`${this.path.label}.font`,this.path,"span"),this.#s}get paragraphs(){return this.#n??=w.of(this.context,`${this.path.label}.paragraphs`,this.path),this.#n}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,o=pt(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:I(this.path,"span"),name:o}));}get hyperlink(){return this.loadedProperty("hyperlink")}set hyperlink(t){let e=`${this.path.label}.hyperlink`;(typeof t!="string"||t.length>2048)&&a({code:"InvalidArgument",target:e}),this.requireUsablePath(),this.command("hyperlink",()=>({op:"setHyperlink",span:this.#i(),target:t}));}get bookmarks(){let t=this.#i();return this.#a??=ot.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{start:t.start,end:t.end}})),this.#a}search(t,e){let o=`${this.path.label}.search`;typeof t!="string"&&a({code:"InvalidArgument",target:o});let r=Kt(e,o),i=this.#i();return $.of(this.context,o,this.path,()=>({op:"search",scope:i,text:t,options:{...r??{},projection:this.revisionTextView()}}))}insertText(t,e){let o=`${this.path.label}.insertText`,r=L(t,o),i=wt(e,o);this.requireUsablePath();let s=n.promised(this.context,o,false);return this.commandAnswering(o,()=>{let d=this.#i();return i==="Replace"?{op:"replaceSpan",span:d,text:r}:{op:"insertText",at:i==="Start"||i==="Before"?d.start:d.end,text:r}},d=>{s.hydrateAddress({kind:"span",span:O(d,o)});}),s}delete(){this.requireUsablePath(),this.commandDiscarding("delete",()=>({op:"replaceSpan",span:this.#i(),text:""}));}clear(){let t=this.#i();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:t,text:""}));}insertComment(t){let e=`${this.path.label}.insertComment`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:e});let o=this.internals.author;(typeof o!="string"||o.trim().length===0)&&a({code:"NotSupported",target:e});let r=_.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertComment",span:this.#i(),text:t,author:o}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:e}),r.hydrateAddress(i);}),r}insertContentControl(t){let e=`${this.path.label}.insertContentControl`,o=t??"RichText";o!=="RichText"&&o!=="PlainText"&&o!=="DatePicker"&&a({code:"NotSupported",target:e});let r=M.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertContentControl",span:this.#i(),subtype:o==="DatePicker"?"date":o==="PlainText"?"plainText":"richText",returnHandle:true}),i=>{i.kind!=="handle"&&a({code:"GeneralException",target:e}),r.hydrateAddress(i);}),r}get tables(){return this.requireUsablePath(),this.#t??=J.over(this.context,`${this.path.label}.tables`,this.path,()=>I(this.path,"span"))}get fields(){return this.requireUsablePath(),this.#e??=K.of(this.context,`${this.path.label}.fields`,this.path,"span")}insertField(t,e,o,r){let i=`${this.path.label}.insertField`;(e!==void 0&&typeof e!="string"||o!==void 0&&typeof o!="string"||r!==void 0&&typeof r!="boolean")&&a({code:"InvalidArgument",target:i});let s=wt(t,i);this.requireUsablePath();let d=Q.promised(this.context,i,false);return this.commandAnswering(i,()=>({op:"insertField",span:this.#i(),location:s,...e===void 0?{}:{fieldType:e},...o===void 0?{}:{text:o},...r===void 0?{}:{removeFormatting:r}}),h=>d.hydrateAddress({kind:"handle",handle:m(h,i)})),d}get inlinePictures(){return this.requireUsablePath(),this.#o??=Z.of(this.context,`${this.path.label}.inlinePictures`,this.path,"span")}insertInlinePictureFromBase64(t,e){let o=`${this.path.label}.insertInlinePictureFromBase64`;(typeof t!="string"||t.length===0)&&a({code:"InvalidArgument",target:o});let r=wt(e,o);this.requireUsablePath();let i=X.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertInlinePicture",span:this.#i(),base64:t,location:r}),s=>{i.hydrateAddress({kind:"handle",handle:m(s,o)});}),i}insertBreak(t,e){let o=`${this.path.label}.insertBreak`;e!=="Before"&&e!=="After"&&a({code:"InvalidArgument",target:o});let r=e;this.requireUsablePath(),this.commandAnswering(o,()=>({op:"insertBreak",span:this.#i(),breakType:t,location:r}),i=>g(i,o));}insertTable(t,e,o,r){let i=`${this.path.label}.insertTable`;(!Number.isInteger(t)||!Number.isInteger(e)||t<1||e<1||!["Before","After"].includes(o))&&a({code:"InvalidArgument",target:i}),r!==void 0&&(!Array.isArray(r)||r.some(h=>!Array.isArray(h)||h.some(u=>typeof u!="string")))&&a({code:"InvalidArgument",target:i});let s=r?.map(h=>[...h]),d=Y.promised(this.context,i);return this.commandAnswering(i,()=>({op:"insertTable",span:I(this.path,"span"),location:o,rowCount:t,columnCount:e,...s?{values:s}:{}}),h=>{h.kind!=="handle"&&a({code:"GeneralException",target:i}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}insertParagraph(t,e){let o=`${this.path.label}.insertParagraph`,r=L(t,o),i=wt(e,o);i!=="Before"&&i!=="After"&&a({code:"InvalidArgument",target:o});let s=this.#i(),d=i==="Before"?s.start.paragraph:s.end.paragraph,h=j.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertParagraph",anchor:{paragraph:d},where:i==="Before"?"before":"after",text:r}),u=>{u.kind!=="handle"&&a({code:"GeneralException",target:o}),h.hydrateAddress({kind:"handle",handle:u.handle});}),h}select(t){let e=`${this.path.label}.select`,o=zt(t,e);this.requireAddressable(),this.internals.capabilities.selection||a({code:"NotSupported",target:e});let r=this.#i();this.command("select",()=>({op:"selectSpan",span:r,mode:o==="Select"?"select":o==="Start"?"start":"end"}));}onLoad(t){let e=this.selection(t,["text","style","hyperlink"]);if(e.includes("hyperlink")&&this.loadTextInto("hyperlink",()=>({op:"getHyperlink",span:this.#i()})),e.includes("text")){let r=`${this.path.label}.text`;this.read(r,()=>({op:"getSpanText",span:this.#i(),projection:this.revisionTextView()}),i=>{this.setLoadedProperty("text",P(i,r));});}if(!e.includes("style"))return;let o=`${this.path.label}.style`;this.requireUsablePath(),this.read(o,()=>({op:"getStyle",span:I(this.path,"span")}),r=>{this.setLoadedProperty("style",Ot(r,o));});}#i(){return this.requireAddressable(),this.path.span()}};var At=class n extends p{#t;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get name(){return this.loadedProperty("name")}get range(){return this.#t??=this.#e(`${this.path.label}.range`),this.#t}select(t){let e=`${this.path.label}.select`,o=zt(t,e);this.requireUsablePath(),this.internals.capabilities.selection||a({code:"NotSupported",target:e}),this.command("select",()=>({op:"selectBookmark",bookmark:this.#o(),mode:o==="Select"?"select":o==="Start"?"start":"end"}));}onLoad(t){if(!this.selection(t,["name"]).includes("name"))return;let e=`${this.path.label}.name`;this.read(e,()=>({op:"getBookmarkName",bookmark:this.#o()}),o=>{this.setLoadedProperty("name",P(o,e));});}#e(t){let e=y.promised(this.context,t,false);return this.read(t,()=>({op:"getBookmarkRange",bookmark:this.#o()}),o=>{e.hydrateAddress({kind:"span",span:O(o,t)});}),e}#o(){return this.requireAddressable(),this.path.handle()}},ot=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}listing(){return this.#t()}itemAt(t,e){return At.at(this.context,t,e)}promised(t,e){return At.promised(this.context,t,e)}};var S=class n extends p{#t;#e;get footnotes(){return this.#t??=N.of(this.context,`${this.path.label}.footnotes`,this.path,()=>({op:"getNotes",document:this.internals.roots().document,scope:this.#l(),noteKind:"footnote"}))}get endnotes(){return this.#e??=N.of(this.context,`${this.path.label}.endnotes`,this.path,()=>({op:"getNotes",document:this.internals.roots().document,scope:this.#l(),noteKind:"endnote"}))}#o;#n;#s;#a;#i;#r;#d;#c;#h;#u;static main(t,e){return new n(t,c.of(e,it(t).roots().body))}static promisedStory(t,e){return new n(t,c.pending(e))}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}constructor(t,e){super(t,e);}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#i??=this.paragraphsUnder(`${this.path.label}.paragraphs`),this.#i}get bookmarks(){let t=this.#l();return this.#r??=ot.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{body:t}})),this.#r}get font(){return this.#d??=B.of(this.context,`${this.path.label}.font`,this.path,"body"),this.#d}paragraphsUnder(t){return w.of(this.context,t,this.path)}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,o=pt(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:I(this.path,"body"),name:o}));}get lists(){return this.#c??=bt.of(this.context,`${this.path.label}.lists`,this.path,this.#l()),this.#c}get contentControls(){return this.#h??=F.of(this.context,`${this.path.label}.contentControls`,this.path,{body:this.#l()}),this.#h}getComments(){let t=`${this.path.label}.getComments`,e=this.#l();return tt.of(this.context,t,this.path,()=>({op:"getComments",scope:{body:e}}))}get revisions(){return this.#u??=et.of(this.context,`${this.path.label}.revisions`,this.path,this.#l()),this.#u}getRange(t="Whole"){let e=`${this.path.label}.getRange`;this.requireUsablePath();let o=y.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{body:this.path.handle()},location:t}),r=>{o.hydrateAddress({kind:"span",span:O(r,e)});}),o}search(t,e){let o=`${this.path.label}.search`;typeof t!="string"&&a({code:"InvalidArgument",target:o});let r=Kt(e,o),i=this.#l();return $.of(this.context,o,this.path,()=>({op:"search",scope:{body:i},text:t,options:{...r??{},projection:this.revisionTextView()}}))}clear(){let t=this.#l();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{body:t},text:""}));}insertText(t,e){let o=`${this.path.label}.insertText`,r=L(t,o),i=Se(e,o);this.requireUsablePath();let s=y.promised(this.context,o,false);return this.commandAnswering(o,()=>i==="Replace"?{op:"replaceSpan",span:{body:this.#l()},text:r}:{op:"insertText",at:{body:this.#l(),at:i==="Start"?"start":"end"},text:r},d=>{s.hydrateAddress({kind:"span",span:O(d,o)});}),s}insertParagraph(t,e){let o=`${this.path.label}.insertParagraph`,r=L(t,o),i=Le(e,o),s=this.#l(),d=j.promised(this.context,o,false);return this.commandAnswering(o,()=>({op:"insertParagraph",anchor:{body:s,at:i==="Start"?"first":"last"},where:i==="Start"?"before":"after",text:r}),h=>{h.kind!=="handle"&&a({code:"GeneralException",target:o}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}onLoad(t){let e=this.selection(t,["text","style"]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#l(),projection:this.revisionTextView()})),e.includes("style")&&this.#p();}#p(){let t=`${this.path.label}.style`;this.requireUsablePath(),this.read(t,()=>({op:"getStyle",span:I(this.path,"body")}),e=>{this.setLoadedProperty("style",Ot(e,t));});}get fields(){return this.requireUsablePath(),this.#n??=K.of(this.context,`${this.path.label}.fields`,this.path,"body")}get inlinePictures(){return this.requireUsablePath(),this.#s??=Z.of(this.context,`${this.path.label}.inlinePictures`,this.path,"body")}get shapes(){return this.requireUsablePath(),this.#a??=G.of(this.context,`${this.path.label}.shapes`,this.path,"body")}get tables(){return this.requireUsablePath(),this.#o??=J.over(this.context,`${this.path.label}.tables`,this.path,()=>({body:this.#l()}))}#l(){return this.requireAddressable(),this.path.handle()}};var Ro=Object.freeze({Primary:"default",FirstPage:"first",EvenPages:"even"}),Po=["pageWidth","pageHeight","orientation","topMargin","rightMargin","bottomMargin","leftMargin"],Tt=class n extends p{#t;static of(t,e,o){return new n(t,c.derived(e,o))}constructor(t,e){super(t,e);}get pageWidth(){return this.loadedProperty("pageWidth")}set pageWidth(t){this.#e("pageWidth",vt(t,`${this.path.label}.pageWidth`));}get pageHeight(){return this.loadedProperty("pageHeight")}set pageHeight(t){this.#e("pageHeight",vt(t,`${this.path.label}.pageHeight`));}get orientation(){return this.loadedProperty("orientation")}set orientation(t){let e=`${this.path.label}.orientation`;t!=="Portrait"&&t!=="Landscape"&&a({code:"InvalidArgument",target:e}),this.#e("orientation",t==="Portrait"?"portrait":"landscape");}get topMargin(){return this.loadedProperty("topMargin")}set topMargin(t){this.#e("topMargin",vt(t,`${this.path.label}.topMargin`));}get bottomMargin(){return this.loadedProperty("bottomMargin")}set bottomMargin(t){this.#e("bottomMargin",vt(t,`${this.path.label}.bottomMargin`));}get leftMargin(){return this.loadedProperty("leftMargin")}set leftMargin(t){this.#e("leftMargin",vt(t,`${this.path.label}.leftMargin`));}get rightMargin(){return this.loadedProperty("rightMargin")}set rightMargin(t){this.#e("rightMargin",vt(t,`${this.path.label}.rightMargin`));}onLoad(t){let e=this.selection(t,Po);if(e.length===0)return;let o=`${this.path.label}.pageSetup`;this.read(o,()=>({op:"getPageSetup",section:this.#o()}),r=>{let i=Jt(r,o);for(let s of e)this.setLoadedProperty(s,s==="orientation"?i.orientation==="landscape"?"Landscape":"Portrait":i[s]);});}#e(t,e){if(this.requireUsablePath(),this.#t){this.#t[t]=e;return}let o={[t]:e};this.#t=o;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.pageSetup`,()=>({op:"setPageSetup",section:this.#o(),setup:o}),i=>{g(i,r);},()=>{this.#t===o&&(this.#t=void 0);});}#o(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&a({code:"InvalidObjectPath",target:this.path.label}),t.handle}},Ct=class n extends p{#t;#e;static at(t,e,o){return o.kind!=="handle"&&a({code:"InvalidObjectPath",target:e}),new n(t,c.of(e,o.handle),false)}static promised(t,e,o){return new n(t,c.pending(e),o)}constructor(t,e,o){super(t,e,{nullable:o});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){return this.#e??=S.main(this.context,`${this.path.label}.body`),this.#e}get pageSetup(){return this.#t??=Tt.of(this.context,`${this.path.label}.pageSetup`,this.path),this.#t}getHeader(t){return this.#o("header",t,"getHeader")}getFooter(t){return this.#o("footer",t,"getFooter")}getNext(){let t=`${this.path.label}.getNext`,e=n.promised(this.context,t,false),o=this.internals.roots().document;return this.read(t,()=>({op:"getSections",document:o}),r=>{let i=v(r,t),s=i.findIndex(h=>h.ref===this.#n().ref),d=s<0?void 0:i[s+1];d||a({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:d});}),e}onLoad(t){this.selection(t,[]);}#o(t,e,o){let r=`${this.path.label}.${o}`,i=Ro[e];i===void 0&&a({code:"InvalidArgument",target:r});let s=S.promisedStory(this.context,r);return this.read(r,()=>({op:"getFurniture",section:this.#n(),kind:t,variant:i}),d=>{s.hydrateAddress({kind:"handle",handle:m(d,r)});}),s}#n(){return this.requireAddressable(),this.path.handle()}},Rt=class n extends C{#t;static of(t,e,o,r){return new n(t,c.derived(e,o),r)}constructor(t,e,o){super(t,e),this.#t=o;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return Ct.at(this.context,t,e)}promised(t,e){return Ct.promised(this.context,t,e)}};function vt(n,t){return (typeof n!="number"||!Number.isFinite(n)||n<0)&&a({code:"InvalidArgument",target:t}),n}var Pt=class n extends p{#t;#e;#o;#n;#s;#a;#i;#r;#d;static open(t){return new n(t)}constructor(t){super(t,c.of("document",it(t).roots().document));}get changeTrackingMode(){return this.loadedProperty("changeTrackingMode")}set changeTrackingMode(t){["Off","TrackAll","TrackMineOnly"].includes(t)||a({code:"InvalidArgument",target:"document.changeTrackingMode"});let e=this.internals.author;this.commandAnswering("document.changeTrackingMode",()=>({op:"setChangeTrackingMode",mode:t,...e===void 0?{}:{author:e}}),()=>this.setLoadedProperty("changeTrackingMode",t));}get body(){return this.#e??=S.main(this.context,"document.body"),this.#e}removeDocumentInformation(t){this.command(`${this.path.label}.removeDocumentInformation`,()=>({op:"removeDocumentInformation",removeDocInfoType:t}));}get properties(){return this.#t??=ht.of(this.context,this.path),this.#t}get paragraphs(){return this.#o??=this.body.paragraphsUnder("document.paragraphs"),this.#o}get sections(){let t=this.path.handle();return this.#n??=Rt.of(this.context,"document.sections",this.path,()=>({op:"getSections",document:t})),this.#n}get contentControls(){return this.#i??=F.of(this.context,"document.contentControls",this.path,{body:this.internals.roots().body}),this.#i}get comments(){return this.#s??=tt.of(this.context,"document.comments",this.path,()=>({op:"getComments",scope:{body:this.internals.roots().body}})),this.#s}get revisions(){return this.#a??=et.of(this.context,"document.revisions",this.path,this.internals.roots().body),this.#a}get footnotes(){let t=this.path.handle();return this.#r??=N.of(this.context,"document.footnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"footnote"})),this.#r}get endnotes(){let t=this.path.handle();return this.#d??=N.of(this.context,"document.endnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"endnote"})),this.#d}onLoad(t){if(t.select.length===0)return;this.selection(t,["changeTrackingMode"]).includes("changeTrackingMode")&&this.loadTextInto("changeTrackingMode",()=>({op:"getChangeTrackingMode"}));}};function $e(n){let t=n.host,e=Object.freeze({...t.capabilities,save:n.save&&t.capabilities.save}),o=typeof n.author=="string"&&n.author.trim().length>0?n.author:void 0,r=n.revisionTextView??"allMarkup";r!=="allMarkup"&&r!=="original"&&a({code:"InvalidArgument",target:"revisionTextView"});let i=false,s=null,d=f=>{i&&a({code:"RuntimeDisposed",...f===void 0?{}:{target:f}});},h=()=>{if(s)return s;d("document");let f=ct=>{try{return t.execute({operations:ct})}catch(nt){try{n.onException?.(nt,ct);}catch{}throw nt}},W=Be(f([{op:"getDocument"}]),"document"),U=Be(f([{op:"getBody",document:W}]),"document.body");return s={document:W,body:U},s},u={host:t,capabilities:e,...o===void 0?{}:{author:o},revisionTextView:r,...n.onRefusal?{onRefusal:n.onRefusal}:{},...n.onException?{onException:n.onException}:{},id:{},roots:h,assertLive:d,openDocument:f=>Pt.open(f)};try{h();}catch{s=null;}async function H(f,W){d();let U=typeof f=="function"?f:W,ct=typeof f=="function"?[]:Array.isArray(f)?f:[f];typeof U!="function"&&a({code:"InvalidArgument",target:"run"});let{context:nt,adopt:x,finish:Ue}=It.begin(u);try{return x(ct),await U(nt)}finally{Ue();}}let k={capabilities:e,run:H,dispose(){i||(i=true,s=null,t.dispose());}};return n.save?{...k,async save(){d("save"),e.save||a({code:"NotSupported",target:"save"});let f=t.save();if(!f.ok)throw Ft(f.error,{target:"save"});return f.bytes}}:k}function Be(n,t){let e=n.results[0];if(e?.status==="error")throw Ft(e.error,{target:t});if(e?.status!=="ok")throw new R({code:"GeneralException",target:t});return m(e.value,t)}var Lo={StaleDocument:"edit.stale-target",ItemNotFound:"edit.stale-target",InvalidObjectPath:"edit.stale-target",InvalidArgument:"edit.invalid-argument",ResourceLimitExceeded:"edit.resource-limit",NotSupported:"edit.operation-unsupported",NotImplemented:"edit.operation-unsupported"};function wo(n){try{let t=n.execute({operations:[{op:"getChangeTrackingMode"}]}),e=t.ok?t.results[0]:void 0;return e?.status==="ok"&&e.value.kind==="text"&&e.value.text!=="Off"}catch{return false}}function Fe(n,t){return t.some(o=>o.op==="setChangeTrackingMode"&&o.mode!=="Off")||wo(n)}function jo(n,t,e){let o=n.debugInfo.innerError?.code;return {code:o?.startsWith("edit.")?o:Lo[n.code]??"edit.refused",tracked:Fe(t,e)}}function Ve(n){if(n.length===0)return null;let{deliver:t}=automation.createDiagnosticEmitter(()=>n);return {openRejected(e,o,r,i){let s=automation.diagnosticCause(o),d=automation.documentPartKind(i);t({kind:"document.open",outcome:"rejected",code:automation.openDiagnosticCode(o,r),sizeBucket:automation.byteSizeBucket(e.byteLength),...s?{cause:s}:{},...d?{part:d}:{}});},openCrashed(e,o){t({kind:"document.open",outcome:"rejected",code:"open.failed",sizeBucket:automation.byteSizeBucket(e.byteLength),cause:automation.exceptionCause(),errorName:automation.diagnosticErrorName(o)});},opened(e,o){t({kind:"document.open",outcome:"opened",sizeBucket:automation.byteSizeBucket(e.byteLength),durationMs:Math.max(0,Math.round(o))});},crashed(e,o,r){t({kind:"edit.rejected",code:"edit.internal-invariant",origin:"automation",tracked:Fe(o,r),cause:automation.exceptionCause(),errorName:automation.diagnosticErrorName(e),stage:"automation"});},refused(e,o,r){let i=Pe(e);t({kind:"edit.rejected",origin:"automation",...jo(e,o,r),...i?{cause:i}:{}});}}}function Do(n){if(n){for(let t of n)if(t.collaboration)return t.collaboration}}function No(n){let t=[n?.zip?.maxEntries,n?.zip?.maxTotalBytes,n?.xml?.maxBytes,n?.xml?.maxElements,n?.maxXmlParts,n?.maxRelationships],e=n?.zip?.maxRatio;(t.some(o=>o!==void 0&&(!Number.isInteger(o)||o<0))||e!==void 0&&(!Number.isFinite(e)||e<0))&&a({code:"InvalidArgument",target:"createServer"});}async function ge(n,t={}){let e=Ve((t.modules??[]).flatMap(s=>s.onDiagnostic?[s.onDiagnostic]:[])),o=Date.now();try{No(t.limits);}catch(s){throw e?.openRejected(n,"invalid-limits"),s}let r=Do(t.modules),i;try{i=automation.createServerAutomationHost(n,{...t.pagination?{pagination:be(t.pagination)}:{},...t.limits===void 0?{}:{limits:t.limits},...r===void 0?{}:{collaborationModel:r}});}catch(s){throw e?.openCrashed(n,s),s}if(!i.ok){let s={"too-many-entries":"zip.maxEntries","too-large":"xml.maxBytes","too-many-elements":"xml.maxElements","too-deep":"xml.maxDepth","too-many-xml-parts":"maxXmlParts","too-many-relationships":"maxRelationships"},d=i.limit??s[i.reason];e?.openRejected(n,i.reason,i.limit,i.detail),a({code:d===void 0?"InvalidArgument":"ResourceLimitExceeded",target:"createServer",...d===void 0?{}:{limit:d},diagnostic:automation.openDiagnosticCode(i.reason,i.limit)});}return e?.opened(n,Date.now()-o),$e({host:i.host,save:true,...t.author===void 0?{}:{author:t.author},...t.revisionTextView===void 0?{}:{revisionTextView:t.revisionTextView},...e?{onRefusal:(s,d)=>e.refused(s,i.host,d),onException:(s,d)=>e.crashed(s,i.host,d)}:{}})}function We(n,t,e={}){return ge(n,{...e,modules:[...e.modules??[],{id:"collaboration",collaboration:{session:t}}]})}var fe=(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))(fe||{});var Ba=Object.freeze({createServer:ge,createCollaborative:We});exports.Alignment=oe;exports.Body=S;exports.Bookmark=At;exports.BookmarkCollection=ot;exports.BreakType=ae;exports.ChangeTrackingMode=re;exports.ClientObject=z;exports.ClientResult=$t;exports.Comment=_;exports.CommentCollection=tt;exports.CommentReply=lt;exports.CommentReplyCollection=Et;exports.ContentControl=M;exports.ContentControlCollection=F;exports.ContentControlType=se;exports.Document=Pt;exports.DocumentProperties=ht;exports.DocxEditor=Ba;exports.DocxEditorError=R;exports.Field=Q;exports.FieldCollection=K;exports.FieldType=fe;exports.Font=B;exports.InlinePicture=X;exports.InlinePictureCollection=Z;exports.InsertLocation=ee;exports.List=D;exports.ListBullet=ce;exports.ListCollection=bt;exports.ListItem=yt;exports.ListNumbering=he;exports.NoteItem=mt;exports.NoteItemCollection=N;exports.PageOrientation=ne;exports.PageSetup=Tt;exports.Paragraph=j;exports.ParagraphCollection=w;exports.Range=y;exports.RangeCollection=$;exports.RemoveDocInfoType=de;exports.RequestContext=It;exports.Revision=V;exports.RevisionCollection=et;exports.Section=Ct;exports.SectionCollection=Rt;exports.Shape=ut;exports.ShapeCollection=G;exports.ShapeType=Wt;exports.Table=Y;exports.TableCell=st;exports.TableCellCollection=Lt;exports.TableCollection=J;exports.TableRow=gt;exports.TableRowCollection=dt;exports.TrackedObjects=kt;exports.UnderlineType=pe;exports.VerticalAlignment=ie;exports.isDocxEditorError=Nt;
|