@vedivad/typst-web-service 0.14.4 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +25 -51
- package/dist/index.js +58 -131
- package/dist/index.js.map +1 -1
- package/dist/renderer-worker.js +5223 -0
- package/dist/renderer-worker.js.map +1 -0
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -19,6 +19,9 @@ function createWorker() {
|
|
|
19
19
|
function createAnalyzerWorker() {
|
|
20
20
|
return createBlobWorker('"use strict";(()=>{var $=Symbol("Comlink.proxy"),se=Symbol("Comlink.endpoint"),_e=Symbol("Comlink.releaseProxy"),W=Symbol("Comlink.finalizer"),L=Symbol("Comlink.thrown"),G=t=>typeof t=="object"&&t!==null||typeof t=="function",ce={canHandle:t=>G(t)&&t[$],serialize(t){let{port1:e,port2:n}=new MessageChannel;return z(t,e),[n,[n]]},deserialize(t){return t.start(),ge(t)}},ae={canHandle:t=>G(t)&&L in t,serialize({value:t}){let e;return t instanceof Error?e={isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:e={isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}},Y=new Map([["proxy",ce],["throw",ae]]);function fe(t,e){for(let n of t)if(e===n||n==="*"||n instanceof RegExp&&n.test(e))return!0;return!1}function z(t,e=globalThis,n=["*"]){e.addEventListener("message",function r(i){if(!i||!i.data)return;if(!fe(n,i.origin)){console.warn(`Invalid origin \'${i.origin}\' for comlink proxy`);return}let{id:s,type:_,path:c}=Object.assign({path:[]},i.data),a=(i.data.argumentList||[]).map(p),f;try{let u=c.slice(0,-1).reduce((g,A)=>g[A],t),d=c.reduce((g,A)=>g[A],t);switch(_){case"GET":f=d;break;case"SET":u[c.slice(-1)[0]]=p(i.data.value),f=!0;break;case"APPLY":f=d.apply(u,a);break;case"CONSTRUCT":{let g=new d(...a);f=ye(g)}break;case"ENDPOINT":{let{port1:g,port2:A}=new MessageChannel;z(t,A),f=we(g,[g])}break;case"RELEASE":f=void 0;break;default:return}}catch(u){f={value:u,[L]:0}}Promise.resolve(f).catch(u=>({value:u,[L]:0})).then(u=>{let[d,g]=D(u);e.postMessage(Object.assign(Object.assign({},d),{id:s}),g),_==="RELEASE"&&(e.removeEventListener("message",r),X(e),W in t&&typeof t[W]=="function"&&t[W]())}).catch(u=>{let[d,g]=D({value:new TypeError("Unserializable return value"),[L]:0});e.postMessage(Object.assign(Object.assign({},d),{id:s}),g)})}),e.start&&e.start()}function ue(t){return t.constructor.name==="MessagePort"}function X(t){ue(t)&&t.close()}function ge(t,e){let n=new Map;return t.addEventListener("message",function(i){let{data:s}=i;if(!s||!s.id)return;let _=n.get(s.id);if(_)try{_(s)}finally{n.delete(s.id)}}),N(t,n,[],e)}function k(t){if(t)throw new Error("Proxy has been released and is not useable")}function J(t){return h(t,new Map,{type:"RELEASE"}).then(()=>{X(t)})}var F=new WeakMap,C="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{let e=(F.get(t)||0)-1;F.set(t,e),e===0&&J(t)});function be(t,e){let n=(F.get(e)||0)+1;F.set(e,n),C&&C.register(t,e,t)}function le(t){C&&C.unregister(t)}function N(t,e,n=[],r=function(){}){let i=!1,s=new Proxy(r,{get(_,c){if(k(i),c===_e)return()=>{le(s),J(t),e.clear(),i=!0};if(c==="then"){if(n.length===0)return{then:()=>s};let a=h(t,e,{type:"GET",path:n.map(f=>f.toString())}).then(p);return a.then.bind(a)}return N(t,e,[...n,c])},set(_,c,a){k(i);let[f,u]=D(a);return h(t,e,{type:"SET",path:[...n,c].map(d=>d.toString()),value:f},u).then(p)},apply(_,c,a){k(i);let f=n[n.length-1];if(f===se)return h(t,e,{type:"ENDPOINT"}).then(p);if(f==="bind")return N(t,e,n.slice(0,-1));let[u,d]=V(a);return h(t,e,{type:"APPLY",path:n.map(g=>g.toString()),argumentList:u},d).then(p)},construct(_,c){k(i);let[a,f]=V(c);return h(t,e,{type:"CONSTRUCT",path:n.map(u=>u.toString()),argumentList:a},f).then(p)}});return be(s,t),s}function de(t){return Array.prototype.concat.apply([],t)}function V(t){let e=t.map(D);return[e.map(n=>n[0]),de(e.map(n=>n[1]))]}var K=new WeakMap;function we(t,e){return K.set(t,e),t}function ye(t){return Object.assign(t,{[$]:!0})}function D(t){for(let[e,n]of Y)if(n.canHandle(t)){let[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},K.get(t)||[]]}function p(t){switch(t.type){case"HANDLER":return Y.get(t.name).deserialize(t.value);case"RAW":return t.value}}function h(t,e,n,r){return new Promise(i=>{let s=pe();e.set(s,i),t.start&&t.start(),t.postMessage(Object.assign({id:s},n),r)})}function pe(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Te={},o;function R(t){let e=o.__externref_table_alloc();return o.__wbindgen_externrefs.set(e,t),e}var Q=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>t.dtor(t.a,t.b));function H(t){let e=typeof t;if(e=="number"||e=="boolean"||t==null)return`${t}`;if(e=="string")return`"${t}"`;if(e=="symbol"){let i=t.description;return i==null?"Symbol":`Symbol(${i})`}if(e=="function"){let i=t.name;return typeof i=="string"&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(t)){let i=t.length,s="[";i>0&&(s+=H(t[0]));for(let _=1;_<i;_++)s+=", "+H(t[_]);return s+="]",s}let n=/\\[object ([^\\]]+)\\]/.exec(toString.call(t)),r;if(n&&n.length>1)r=n[1];else return toString.call(t);if(r=="Object")try{return"Object("+JSON.stringify(t)+")"}catch{return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:r}function Z(t,e){return t=t>>>0,E().subarray(t/1,t/1+e)}var m=null;function l(){return(m===null||m.buffer.detached===!0||m.buffer.detached===void 0&&m.buffer!==o.memory.buffer)&&(m=new DataView(o.memory.buffer)),m}function b(t,e){return t=t>>>0,Ee(t,e)}var O=null;function E(){return(O===null||O.byteLength===0)&&(O=new Uint8Array(o.memory.buffer)),O}function x(t,e){try{return t.apply(this,e)}catch(n){let r=R(n);o.__wbindgen_exn_store(r)}}function w(t){return t==null}function he(t,e,n,r){let i={a:t,b:e,cnt:1,dtor:n},s=(..._)=>{i.cnt++;let c=i.a;i.a=0;try{return r(c,i.b,..._)}finally{i.a=c,s._wbg_cb_unref()}};return s._wbg_cb_unref=()=>{--i.cnt===0&&(i.dtor(i.a,i.b),i.a=0,Q.unregister(i))},Q.register(s,i,i),s}function xe(t,e){let n=e(t.length*1,1)>>>0;return E().set(t,n/1),y=t.length,n}function v(t,e,n){if(n===void 0){let c=M.encode(t),a=e(c.length,1)>>>0;return E().subarray(a,a+c.length).set(c),y=c.length,a}let r=t.length,i=e(r,1)>>>0,s=E(),_=0;for(;_<r;_++){let c=t.charCodeAt(_);if(c>127)break;s[i+_]=c}if(_!==r){_!==0&&(t=t.slice(_)),i=n(i,r,r=_+t.length*3,1)>>>0;let c=E().subarray(i+_,i+r),a=M.encodeInto(t,c);_+=a.written,i=n(i,r,_,1)>>>0}return y=_,i}function re(t){let e=o.__wbindgen_externrefs.get(t);return o.__externref_table_dealloc(t),e}var I=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});I.decode();var ve=2146435072,U=0;function Ee(t,e){return U+=e,U>=ve&&(I=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),I.decode(),U=e),I.decode(E().subarray(t,t+e))}var M=new TextEncoder;"encodeInto"in M||(M.encodeInto=function(t,e){let n=M.encode(t);return e.set(n),{read:t.length,written:n.length}});var y=0;function Se(t,e,n){o.wasm_bindgen__convert__closures_____invoke__h4b569589ab16bc8b(t,e,n)}function Ae(t,e,n,r){o.wasm_bindgen__convert__closures_____invoke__h298f91ca76697d7d(t,e,n,r)}var ee=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>o.__wbg_individuallanguages_free(t>>>0,1)),te=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>o.__wbg_languagecode_free(t>>>0,1)),q=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>o.__wbg_proxycontext_free(t>>>0,1)),ne=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>o.__wbg_tinymistlanguageserver_free(t>>>0,1)),P=class t{static __wrap(e){e=e>>>0;let n=Object.create(t.prototype);return n.__wbg_ptr=e,ee.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ee.unregister(this),e}free(){let e=this.__destroy_into_raw();o.__wbg_individuallanguages_free(e,0)}get name(){let e,n;try{let r=o.individuallanguages_name(this.__wbg_ptr);return e=r[0],n=r[1],b(r[0],r[1])}finally{o.__wbindgen_free(e,n,1)}}get code(){let e,n;try{let r=o.individuallanguages_code(this.__wbg_ptr);return e=r[0],n=r[1],b(r[0],r[1])}finally{o.__wbindgen_free(e,n,1)}}};Symbol.dispose&&(P.prototype[Symbol.dispose]=P.prototype.free);var j=class t{static __wrap(e){e=e>>>0;let n=Object.create(t.prototype);return n.__wbg_ptr=e,te.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,te.unregister(this),e}free(){let e=this.__destroy_into_raw();o.__wbg_languagecode_free(e,0)}get name(){let e,n;try{let r=o.languagecode_name(this.__wbg_ptr);return e=r[0],n=r[1],b(r[0],r[1])}finally{o.__wbindgen_free(e,n,1)}}get code(){let e,n;try{let r=o.languagecode_code(this.__wbg_ptr);return e=r[0],n=r[1],b(r[0],r[1])}finally{o.__wbindgen_free(e,n,1)}}get code_2t(){let e,n;try{let r=o.languagecode_code_2t(this.__wbg_ptr);return e=r[0],n=r[1],b(r[0],r[1])}finally{o.__wbindgen_free(e,n,1)}}get code_2b(){let e,n;try{let r=o.languagecode_code_2b(this.__wbg_ptr);return e=r[0],n=r[1],b(r[0],r[1])}finally{o.__wbindgen_free(e,n,1)}}get code_3(){let e,n;try{let r=o.languagecode_code_3(this.__wbg_ptr);return e=r[0],n=r[1],b(r[0],r[1])}finally{o.__wbindgen_free(e,n,1)}}get individual_languages(){return o.languagecode_individual_languages(this.__wbg_ptr)}};Symbol.dispose&&(j.prototype[Symbol.dispose]=j.prototype.free);var T=class t{static __wrap(e){e=e>>>0;let n=Object.create(t.prototype);return n.__wbg_ptr=e,q.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,q.unregister(this),e}free(){let e=this.__destroy_into_raw();o.__wbg_proxycontext_free(e,0)}constructor(e){let n=o.proxycontext_new(e);return this.__wbg_ptr=n>>>0,q.register(this,this.__wbg_ptr,this),this}get context(){return o.proxycontext_context(this.__wbg_ptr)}untar(e,n){let r=xe(e,o.__wbindgen_malloc),i=y,s=o.proxycontext_untar(this.__wbg_ptr,r,i,n);if(s[1])throw re(s[0])}};Symbol.dispose&&(T.prototype[Symbol.dispose]=T.prototype.free);var S=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ne.unregister(this),e}free(){let e=this.__destroy_into_raw();o.__wbg_tinymistlanguageserver_free(e,0)}constructor(e){let n=o.tinymistlanguageserver_new(e);if(n[2])throw re(n[1]);return this.__wbg_ptr=n[0]>>>0,ne.register(this,this.__wbg_ptr,this),this}on_event(e){o.tinymistlanguageserver_on_event(this.__wbg_ptr,e)}on_request(e,n){let r=v(e,o.__wbindgen_malloc,o.__wbindgen_realloc),i=y;return o.tinymistlanguageserver_on_request(this.__wbg_ptr,r,i,n)}on_notification(e,n){let r=v(e,o.__wbindgen_malloc,o.__wbindgen_realloc),i=y;o.tinymistlanguageserver_on_notification(this.__wbg_ptr,r,i,n)}on_response(e){o.tinymistlanguageserver_on_response(this.__wbg_ptr,e)}static version(){let e,n;try{let r=o.tinymistlanguageserver_version();return e=r[0],n=r[1],b(r[0],r[1])}finally{o.__wbindgen_free(e,n,1)}}};Symbol.dispose&&(S.prototype[Symbol.dispose]=S.prototype.free);var Re=new Set(["basic","cors","default"]);async function Oe(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(r){if(t.ok&&Re.has(t.type)&&t.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n",r);else throw r}let n=await t.arrayBuffer();return await WebAssembly.instantiate(n,e)}else{let n=await WebAssembly.instantiate(t,e);return n instanceof WebAssembly.Instance?{instance:n,module:t}:n}}function Me(){let t={};return t.wbg={},t.wbg.__wbg_Error_52673b7de5a0ca89=function(e,n){return Error(b(e,n))},t.wbg.__wbg_Number_2d1dcfcf4ec51736=function(e){return Number(e)},t.wbg.__wbg_String_8f0eb39a4a4c2f66=function(e,n){let r=String(n),i=v(r,o.__wbindgen_malloc,o.__wbindgen_realloc),s=y;l().setInt32(e+4,s,!0),l().setInt32(e+0,i,!0)},t.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d=function(e,n){let r=n,i=typeof r=="bigint"?r:void 0;l().setBigInt64(e+8,w(i)?BigInt(0):i,!0),l().setInt32(e+0,!w(i),!0)},t.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b=function(e){let n=e,r=typeof n=="boolean"?n:void 0;return w(r)?16777215:r?1:0},t.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6=function(e,n){let r=H(n),i=v(r,o.__wbindgen_malloc,o.__wbindgen_realloc),s=y;l().setInt32(e+4,s,!0),l().setInt32(e+0,i,!0)},t.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317=function(e,n){return e in n},t.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27=function(e){return typeof e=="bigint"},t.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd=function(e){return typeof e=="function"},t.wbg.__wbg___wbindgen_is_object_ce774f3490692386=function(e){let n=e;return typeof n=="object"&&n!==null},t.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030=function(e){return typeof e=="string"},t.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269=function(e){return e===void 0},t.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36=function(e,n){return e===n},t.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d=function(e,n){return e==n},t.wbg.__wbg___wbindgen_number_get_9619185a74197f95=function(e,n){let r=n,i=typeof r=="number"?r:void 0;l().setFloat64(e+8,w(i)?0:i,!0),l().setInt32(e+0,!w(i),!0)},t.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42=function(e,n){let r=n,i=typeof r=="string"?r:void 0;var s=w(i)?0:v(i,o.__wbindgen_malloc,o.__wbindgen_realloc),_=y;l().setInt32(e+4,_,!0),l().setInt32(e+0,s,!0)},t.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e=function(e,n){throw new Error(b(e,n))},t.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7=function(e){e._wbg_cb_unref()},t.wbg.__wbg_call_3020136f7a2d6e44=function(){return x(function(e,n,r){return e.call(n,r)},arguments)},t.wbg.__wbg_call_78f94eb02ec7f9b2=function(){return x(function(e,n,r,i,s){return e.call(n,r,i,s)},arguments)},t.wbg.__wbg_call_abb4ff46ce38be40=function(){return x(function(e,n){return e.call(n)},arguments)},t.wbg.__wbg_done_62ea16af4ce34b24=function(e){return e.done},t.wbg.__wbg_entries_83c79938054e065f=function(e){return Object.entries(e)},t.wbg.__wbg_error_7534b8e9a36f1ab4=function(e,n){let r,i;try{r=e,i=n,console.error(b(e,n))}finally{o.__wbindgen_free(r,i,1)}},t.wbg.__wbg_getTimezoneOffset_45389e26d6f46823=function(e){return e.getTimezoneOffset()},t.wbg.__wbg_get_6b7bd52aca3f9671=function(e,n){return e[n>>>0]},t.wbg.__wbg_get_af9dab7e9603ea93=function(){return x(function(e,n){return Reflect.get(e,n)},arguments)},t.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe=function(e,n){return e[n]},t.wbg.__wbg_individuallanguages_new=function(e){return P.__wrap(e)},t.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355=function(e){let n;try{n=e instanceof ArrayBuffer}catch{n=!1}return n},t.wbg.__wbg_instanceof_Map_084be8da74364158=function(e){let n;try{n=e instanceof Map}catch{n=!1}return n},t.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434=function(e){let n;try{n=e instanceof Uint8Array}catch{n=!1}return n},t.wbg.__wbg_isArray_51fd9e6422c0a395=function(e){return Array.isArray(e)},t.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16=function(e){return Number.isSafeInteger(e)},t.wbg.__wbg_iterator_27b7c8b35ab3e86b=function(){return Symbol.iterator},t.wbg.__wbg_length_22ac23eaec9d8053=function(e){return e.length},t.wbg.__wbg_length_d45040a40c570362=function(e){return e.length},t.wbg.__wbg_new_1ba21ce319a06297=function(){return new Object},t.wbg.__wbg_new_25f239778d6112b9=function(){return new Array},t.wbg.__wbg_new_6421f6084cc5bc5a=function(e){return new Uint8Array(e)},t.wbg.__wbg_new_8a6f238a6ece86ea=function(){return new Error},t.wbg.__wbg_new_b2db8aa2650f793a=function(e){return new Date(e)},t.wbg.__wbg_new_b546ae120718850e=function(){return new Map},t.wbg.__wbg_new_ff12d2b041fb48f1=function(e,n){try{var r={a:e,b:n},i=(_,c)=>{let a=r.a;r.a=0;try{return Ae(a,r.b,_,c)}finally{r.a=a}};return new Promise(i)}finally{r.a=r.b=0}},t.wbg.__wbg_new_from_slice_f9c22b9153b26992=function(e,n){return new Uint8Array(Z(e,n))},t.wbg.__wbg_new_no_args_cb138f77cf6151ee=function(e,n){return new Function(b(e,n))},t.wbg.__wbg_next_138a17bbf04e926c=function(e){return e.next},t.wbg.__wbg_next_3cfe5c0fe2a4cc53=function(){return x(function(e){return e.next()},arguments)},t.wbg.__wbg_now_2c95c9de01293173=function(e){return e.now()},t.wbg.__wbg_now_69d776cd24f5215b=function(){return Date.now()},t.wbg.__wbg_performance_7a3ffd0b17f663ad=function(e){return e.performance},t.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd=function(e,n,r){Uint8Array.prototype.set.call(Z(e,n),r)},t.wbg.__wbg_proxycontext_new=function(e){return T.__wrap(e)},t.wbg.__wbg_push_7d9be8f38fc13975=function(e,n){return e.push(n)},t.wbg.__wbg_queueMicrotask_9b549dfce8865860=function(e){return e.queueMicrotask},t.wbg.__wbg_queueMicrotask_fca69f5bfad613a5=function(e){queueMicrotask(e)},t.wbg.__wbg_resolve_fd5bfbaa4ce36e1e=function(e){return Promise.resolve(e)},t.wbg.__wbg_set_3f1d0b984ed272ed=function(e,n,r){e[n]=r},t.wbg.__wbg_set_781438a03c0c3c81=function(){return x(function(e,n,r){return Reflect.set(e,n,r)},arguments)},t.wbg.__wbg_set_7df433eea03a5c14=function(e,n,r){e[n>>>0]=r},t.wbg.__wbg_set_efaaf145b9377369=function(e,n,r){return e.set(n,r)},t.wbg.__wbg_stack_0ed75d68575b0f3c=function(e,n){let r=n.stack,i=v(r,o.__wbindgen_malloc,o.__wbindgen_realloc),s=y;l().setInt32(e+4,s,!0),l().setInt32(e+0,i,!0)},t.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335=function(){let e=typeof global>"u"?null:global;return w(e)?0:R(e)},t.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1=function(){let e=typeof globalThis>"u"?null:globalThis;return w(e)?0:R(e)},t.wbg.__wbg_static_accessor_SELF_08f5a74c69739274=function(){let e=typeof self>"u"?null:self;return w(e)?0:R(e)},t.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024=function(){let e=typeof window>"u"?null:window;return w(e)?0:R(e)},t.wbg.__wbg_then_4f95312d68691235=function(e,n){return e.then(n)},t.wbg.__wbg_value_57b7b035e117f7ee=function(e){return e.value},t.wbg.__wbindgen_cast_2241b6af4c4b2941=function(e,n){return b(e,n)},t.wbg.__wbindgen_cast_4625c577ab2ec9ee=function(e){return BigInt.asUintN(64,e)},t.wbg.__wbindgen_cast_9ae0607507abb057=function(e){return e},t.wbg.__wbindgen_cast_b5bc9a99b1b9b782=function(e,n){return he(e,n,o.wasm_bindgen__closure__destroy__h21ca932816a58917,Se)},t.wbg.__wbindgen_cast_d6cd19b81560fd6e=function(e){return e},t.wbg.__wbindgen_init_externref_table=function(){let e=o.__wbindgen_externrefs,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,!0),e.set(n+3,!1)},t}function Pe(t,e){return o=t.exports,ie.__wbindgen_wasm_module=e,m=null,O=null,o.__wbindgen_start(),o}async function ie(t){if(o!==void 0)return o;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof t>"u"&&(t=new URL("tinymist_bg.wasm",Te.url));let e=Me();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:n,module:r}=await Oe(await t,e);return Pe(n,r)}var oe=ie;var B=class{#e=null;#o=[];#n(){if(!this.#e)throw new Error("Analyzer not initialized");return this.#e}#r(e,n){this.#n().on_notification("textDocument/didOpen",{textDocument:{uri:e,languageId:"typst",version:1,text:n}})}#s(e){this.#n().on_notification("textDocument/didClose",{textDocument:{uri:e}})}#i(e,n,r){this.#n().on_notification("textDocument/didChange",{textDocument:{uri:e,version:n},contentChanges:[{text:r}]})}#t(){if(this.#e)for(;this.#o.length>0;)for(let e of this.#o.splice(0))this.#e.on_event(e)}async init(e){await oe({module_or_path:e}),this.#e=new S({sendEvent:r=>{this.#o.push(r)},sendRequest:({id:r})=>{this.#e.on_response({id:r,result:null})},sendNotification:()=>{},resolveFn:()=>{}});let n=this.#e.on_request("initialize",{capabilities:{textDocument:{completion:{completionItem:{snippetSupport:!0}},hover:{contentFormat:["markdown","plaintext"]}}},rootUri:"file:///"});n&&typeof n=="object"&&"then"in n&&await n,this.#t(),this.#e.on_notification("initialized",{}),this.#t()}async didOpen(e,n){this.#r(e,n),this.#t()}async didClose(e){this.#s(e),this.#t()}async didChange(e,n,r){this.#i(e,n,r),this.#t()}async didChangeMany(e,n){this.#n();for(let{uri:r,content:i}of e)this.#r(r,i);for(let{uri:r,version:i,content:s}of n)this.#i(r,i,s);this.#t()}async didCloseMany(e){this.#n();for(let n of e)this.#s(n);this.#t()}async completion(e,n){let r=await this.#n().on_request("textDocument/completion",{textDocument:{uri:e},position:n});return this.#t(),r??null}async hover(e,n){let r=await this.#n().on_request("textDocument/hover",{textDocument:{uri:e},position:n});return this.#t(),r??null}async completionWithDoc(e,n,r,i,s){return s==="open"?this.#r(e,r):this.#i(e,n,r),this.completion(e,i)}async hoverWithDoc(e,n,r,i,s){return s==="open"?this.#r(e,r):this.#i(e,n,r),this.hover(e,i)}destroy(){this.#e?.free(),this.#e=null}};z(new B);})();\n/*! Bundled license information:\n\ncomlink/dist/esm/comlink.mjs:\n (**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n *)\n*/\n');
|
|
21
21
|
}
|
|
22
|
+
function createRendererWorker() {
|
|
23
|
+
return createBlobWorker('"use strict";(()=>{var nn=Object.defineProperty;var z=(r,t)=>()=>(r&&(t=r(r=0)),t);var rt=(r,t)=>{for(var e in t)nn(r,e,{get:t[e],enumerable:!0})};function Ye(){return X([],{assets:!1})}function Qe(r){return X([],r)}function xn(r){let t=[];if(r&&r?.assets!==!1&&r?.assets?.length&&r?.assets?.length>0){let e={text:"https://cdn.jsdelivr.net/gh/typst/typst-assets@v0.13.1/files/fonts/",_:"https://cdn.jsdelivr.net/gh/typst/typst-dev-assets@v0.13.1/files/fonts/"},n=r.assetUrlPrefix??e;typeof n=="string"?n={_:n}:n={...e,...n};for(let o of Object.keys(n)){let s=n[o];s[s.length-1]!=="/"&&(n[o]=s+"/")}let i=(o,s)=>s.map(_=>(n[o]||n._)+_);for(let o of r.assets)switch(o){case"text":t.push(...i(o,mn));break;case"cjk":t.push(...i(o,yn));break;case"emoji":t.push(...i(o,vn));break}}return t}function X(r,t){let e=xn(t),n=async(i,{ref:o,builder:s})=>{t?.fetcher&&o.setFetcher(t.fetcher),await o.loadFonts(s,[...r,...e])};return n._preloadRemoteFontOptions=t,n._kind="fontLoader",n}function Jt(r){return async(t,{builder:e})=>new Promise(n=>{e.set_package_registry(r,function(i){return r.resolve(i,this)}),n()})}function ye(r){return async(t,e)=>{if(e.alreadySetAccessModel)throw new Error(`already set some assess model before: ${e.alreadySetAccessModel.constructor?.name}(${e.alreadySetAccessModel})`);return e.alreadySetAccessModel=r,new Promise(n=>{e.builder.set_access_model(r,i=>{let o=r.getMTime(i);return o?o.getTime():0},i=>r.isFile(i)||!1,i=>r.getRealPath(i)||i,i=>r.readAll(i)),n()})}}var mn,yn,vn,Et=z(()=>{mn=["DejaVuSansMono-Bold.ttf","DejaVuSansMono-BoldOblique.ttf","DejaVuSansMono-Oblique.ttf","DejaVuSansMono.ttf","LibertinusSerif-Bold.otf","LibertinusSerif-BoldItalic.otf","LibertinusSerif-Italic.otf","LibertinusSerif-Regular.otf","LibertinusSerif-Semibold.otf","LibertinusSerif-SemiboldItalic.otf","NewCM10-Bold.otf","NewCM10-BoldItalic.otf","NewCM10-Italic.otf","NewCM10-Regular.otf","NewCMMath-Bold.otf","NewCMMath-Book.otf","NewCMMath-Regular.otf"],yn=["InriaSerif-Bold.ttf","InriaSerif-BoldItalic.ttf","InriaSerif-Italic.ttf","InriaSerif-Regular.ttf","Roboto-Regular.ttf","NotoSerifCJKsc-Regular.otf"],vn=["TwitterColorEmoji.ttf","NotoColorEmoji-Regular-COLR.subset.ttf"]});var x,it,It=z(()=>{x=Symbol.for("reflexo-obj");(function(r){r[r.PIXEL_PER_PT=3]="PIXEL_PER_PT"})(it||(it={}))});var Gt,Ze=z(()=>{It();Gt=class{pageInfos;loadPageCount;imageScaleFactor;container;canvasList;textLayerList;commonList;textLayerParentList;semanticLayerList;constructor(t,e,n){this.pageInfos=t,this.imageScaleFactor=n.pixelPerPt??it.PIXEL_PER_PT,e.innerHTML="",e.style.width="100%",this.container=e,this.canvasList=new Array(this.loadPageCount),this.textLayerList=new Array(this.loadPageCount),this.commonList=new Array(this.loadPageCount),this.textLayerParentList=new Array(this.loadPageCount),this.semanticLayerList=new Array(this.loadPageCount);let i=(o,s,_)=>{let d=Math.ceil(s.width)*this.imageScaleFactor,l=Math.ceil(s.height)*this.imageScaleFactor,f=this.canvasList[o]=document.createElement("canvas"),v=this.semanticLayerList[o]=document.createElement("div"),S=this.textLayerList[o]=document.createElement("div"),I=this.textLayerParentList[o]=document.createElement("div");if(f.getContext("2d")){let j=document.createElement("div");f.width=d,f.height=l,j.appendChild(f),_.appendChild(j),j.style.position="absolute"}{I.appendChild(S),I.className="typst-html-semantics";let j=e.offsetWidth,T=j/s.width;I.style.width=`${j}px`,I.style.height=`${s.height*T}px`,I.style.setProperty("--data-text-width",`${T}px`),I.style.setProperty("--data-text-height",`${T}px`),_.classList.add("typst-page"),_.classList.add("canvas"),_.style.width=`${j}px`,_.style.height=`${l*T}px`,_.style.position="relative",v.appendChild(I),_.appendChild(v)}};for(let o=0;o<this.pageInfos.length;o++){let s=this.pageInfos[o],_;_=this.commonList[o]=document.createElement("div"),e.appendChild(_),i(o,s,_)}}resetLayout(){for(let t=0;t<this.pageInfos.length;t++){let e=this.pageInfos[t],n=Math.ceil(e.width)*this.imageScaleFactor,i=Math.ceil(e.height)*this.imageScaleFactor,o=this.canvasList[t].parentElement;if(!o)throw new Error(`canvasDiv is null for page ${t}, canvas list length ${this.canvasList.length}`);let s=this.commonList[t],_=this.textLayerParentList[t],d=this.container.offsetWidth,l=d/n;_.style.width=`${d}px`,_.style.height=`${i*l}px`,s.style.width=`${d}px`,s.style.height=`${i*l}px`;let f=this.container.offsetWidth/n;o.style.transformOrigin="0px 0px",o.style.transform=`scale(${f})`}}}});var kn,ot,ve=z(()=>{kn=r=>{let t=!1,e;return()=>t?e:(t=!0,e=r())},ot=class{wasmBin;initOnce;constructor(t){if(typeof t!="function")throw new Error("initFn is not a function");this.initOnce=kn(async()=>{await t(this.wasmBin)})}async init(t){this.wasmBin=t,await this.initOnce()}}});async function Xt(r,t,e,n){return await t.init(r?.getModule?.()),await new xe().build(r,new e,n)}function Se(r){return()=>{let t=new XMLHttpRequest;return t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",r.url,!1),t.send(null),t.status===200&&(t.response instanceof String||typeof t.response=="string")?Uint8Array.from(t.response,e=>e.charCodeAt(0)):new Uint8Array}}var xe,Kt=z(()=>{xe=class{loadedFonts=new Set;fetcher=fetch;setFetcher(t){this.fetcher=t}async loadFonts(t,e){let n=new Function("m","return import(m)"),i=this.fetcher||=await(async function(){let{fetchBuilder:_,FileSystemCache:d}=await n("node-fetch-cache"),l=new d({cacheDirectory:".cache/typst/fonts"}),f=_.withCache(l);return function(v,S){let I=setTimeout(()=>{console.warn("font fetching is stucking:",v)},15e3);return f(v,S).finally(()=>{clearTimeout(I)})}})(),o=e.filter(_=>_ instanceof Uint8Array||typeof _=="object"&&"info"in _?!0:this.loadedFonts.has(_)?!1:(this.loadedFonts.add(_),!0)),s=await Promise.all(o.map(async _=>{if(_ instanceof Uint8Array){await t.add_raw_font(_);return}if(typeof _=="object"&&"info"in _){await t.add_lazy_font(_,"blob"in _?_.blob:Se(_));return}return new Uint8Array(await(await i(_)).arrayBuffer())}));for(let _ of s)_&&await t.add_raw_font(_)}async build(t,e,n){let i={ref:this,builder:e,hooks:n};for(let o of t?.beforeBuild??[])await o(void 0,i);return n.latelyBuild&&n.latelyBuild(i),await e.build()}}});function tr(r){return class{impl;kModule;constructor(e){if(e.isContentPreview&&(e.renderMode="canvas"),this.kModule=e.kModule,this.impl=new r(e),!this.impl.r)throw new Error(`mode is not supported, ${e?.renderMode}`);e.isContentPreview&&(this.impl.partialRendering=!0,this.impl.pixelPerPt=1,this.impl.isMixinOutline=!0)}dispose(){this.impl.dispose()}reset(){this.impl.reset()}addChangement(e){this.impl.addChangement(e)}addViewportChange(){this.impl.addViewportChange()}setPageColor(e){this.impl.pageColor=e,this.addViewportChange()}setPartialRendering(e){this.impl.partialRendering=e}setCursor(e,n,i){this.impl.cursorPosition=[e,n,i]}setPartialPageNumber(e){return e<=0||e>this.kModule.retrievePagesInfo().length?!1:(this.impl.partialRenderPage=e-1,this.addViewportChange(),!0)}getPartialPageNumber(){return this.impl.partialRenderPage+1}setOutineData(e){this.impl.outline=e,this.addViewportChange()}}}function er(r,...t){return t.reduce((e,n)=>n(e),r)}var V,Yt,rr=z(()=>{(function(r){r[r.Doc=0]="Doc",r[r.Slide=1]="Slide"})(V||(V={}));Yt=class r{hookedElem;kModule;opts;modes=[];partialRendering=!0;renderMode="svg";r=void 0;previewMode=V.Doc;isContentPreview=!1;isMixinOutline=!1;backgroundColor="black";pageColor="white";pixelPerPt=3;retrieveDOMState;isRendering=!1;moduleInitialized=!1;patchQueue=[];disposeList=[];canvasRenderCToken;currentRealScale=1;currentScaleRatio=1;vpTimeout=void 0;sampledRenderTime=0;partialRenderPage=0;outline=void 0;cursorPosition=void 0;cachedDOMState={width:0,height:0,window:{innerWidth:0,innerHeight:0},boundingRect:{left:0,top:0,right:0}};constructor(t){this.hookedElem=t.hookedElem,this.kModule=t.kModule,this.opts=t||{};{let{renderMode:e,previewMode:n,isContentPreview:i,retrieveDOMState:o}=t||{};this.partialRendering=!1,this.renderMode=e??this.renderMode,this.previewMode=n??this.previewMode,this.isContentPreview=i||!1,this.retrieveDOMState=o??(()=>({width:this.hookedElem.offsetWidth,height:this.hookedElem.offsetHeight,window:{innerWidth:window.innerWidth,innerHeight:window.innerHeight},boundingRect:this.hookedElem.getBoundingClientRect()})),this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--typst-preview-background-color")}this.hookedElem.classList.add("hide-scrollbar-x"),this.hookedElem.parentElement?.classList.add("hide-scrollbar-x"),this.previewMode===V.Slide&&(this.hookedElem.classList.add("hide-scrollbar-y"),this.hookedElem.parentElement?.classList.add("hide-scrollbar-y")),this.installCtrlWheelHandler()}reset(){this.kModule.reset(),this.moduleInitialized=!1}dispose(){let t=this.disposeList;this.disposeList=[],t.forEach(e=>e())}static derive(t,e){return["rescale","rerender","postRender"].reduce((n,i)=>(n[i]=t[`${i}$${e}`].bind(t),console.assert(n[i]!==void 0,`${i}$${e} is undefined`),n),{})}registerMode(t){let e=r.derive(this,t);this.modes.push([t,e]),t===this.renderMode&&(this.r=e)}installCtrlWheelHandler(){let t=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.3,1.5,1.7,1.9,2.1,2.4,2.7,3,3.3,3.7,4.1,4.6,5.1,5.7,6.3,7,7.7,8.5,9.4,10],e=n=>{if(n.ctrlKey){n.preventDefault(),this.cachedDOMState=this.retrieveDOMState(),window.onresize!==null&&(window.onresize=null);let i=this.currentScaleRatio;if(n.deltaY<0){if(this.currentScaleRatio>=t.at(-1))return;this.currentScaleRatio=t.filter(l=>l>this.currentScaleRatio).at(0)}else if(n.deltaY>0){if(this.currentScaleRatio<=t.at(0))return;this.currentScaleRatio=t.filter(l=>l<this.currentScaleRatio).at(-1)}else return;let o=this.currentScaleRatio/i,s=n.pageX*(o-1),_=n.pageY*(o-1);Math.abs(this.currentScaleRatio-1)<1e-5?(this.hookedElem.classList.add("hide-scrollbar-x"),this.hookedElem.parentElement?.classList.add("hide-scrollbar-x"),this.previewMode===V.Slide&&(this.hookedElem.classList.add("hide-scrollbar-y"),this.hookedElem.parentElement?.classList.add("hide-scrollbar-y"))):(this.hookedElem.classList.remove("hide-scrollbar-x"),this.hookedElem.parentElement?.classList.remove("hide-scrollbar-x"),this.previewMode===V.Slide&&(this.hookedElem.classList.remove("hide-scrollbar-y"),this.hookedElem.parentElement?.classList.remove("hide-scrollbar-y")));let d=this.hookedElem.firstElementChild;if(d){let l=this.getSvgScaleRatio(),f=Number.parseFloat(d.getAttribute("data-height")),v=Math.ceil(f*l);this.hookedElem.style.height=`${v*2}px`}return window.scrollBy(s,_),this.addViewportChange(),!1}};this.renderMode!=="dom"&&(typeof acquireVsCodeApi<"u"?(window.addEventListener("wheel",e,{passive:!1}),this.disposeList.push(()=>{window.removeEventListener("wheel",e)})):(document.body.addEventListener("wheel",e,{passive:!1}),this.disposeList.push(()=>{document.body.removeEventListener("wheel",e)})))}getSvgScaleRatio(){let t=this.hookedElem.firstElementChild;if(!t)return 0;let e=this.cachedDOMState,n=Number.parseFloat(t.getAttribute("data-width")||t.getAttribute("width")||"1"),i=Number.parseFloat(t.getAttribute("data-height")||t.getAttribute("height")||"1");return this.currentRealScale=this.previewMode===V.Slide?Math.min(e.width/n,e.height/i):e.width/n,this.currentRealScale*this.currentScaleRatio}processQueue(t){let e=t[0];switch(e){case"new":case"diff-v1":return e==="new"&&this.reset(),this.kModule.manipulateData({action:"merge",data:t[1]}),this.moduleInitialized=!0,!0;case"viewport-change":return this.moduleInitialized?!0:(console.log("viewport-change before initialization"),!1);default:return console.log("svgUpdateEvent",t),!1}}triggerUpdate(){if(this.isRendering)return;this.isRendering=!0;let t=async()=>{if(this.cachedDOMState=this.retrieveDOMState(),this.patchQueue.length===0){this.isRendering=!1,this.postprocessChanges();return}try{let e=performance.now(),n=this.canvasRenderCToken;n&&(await n.cancel(),await n.wait(),this.canvasRenderCToken=void 0,console.log("cancel canvas rendering"));let i=!1;for(;this.patchQueue.length>0;)i=this.processQueue(this.patchQueue.shift())||i;let o=performance.now();i&&(this.r.rescale(),await this.r.rerender(),this.r.rescale());let s=performance.now(),_=(d,l,f)=>`${d} ${(f-l).toFixed(2)} ms`;this.sampledRenderTime=s-e,requestAnimationFrame(t)}catch(e){console.error(e),this.isRendering=!1,this.postprocessChanges()}};requestAnimationFrame(t)}postprocessChanges(){this.r.postRender(),this.previewMode===V.Slide&&document.querySelectorAll(".typst-page-number-indicator").forEach(t=>{t.textContent=`${this.kModule.retrievePagesInfo().length}`})}addChangement(t){t[0]==="new"&&this.patchQueue.splice(0,this.patchQueue.length);let e=()=>{this.vpTimeout=void 0,this.patchQueue.push(t),this.triggerUpdate()};this.vpTimeout!==void 0&&clearTimeout(this.vpTimeout),t[0]==="viewport-change"&&this.isRendering?this.vpTimeout=setTimeout(e,this.sampledRenderTime||100):e()}addViewportChange(){this.addChangement(["viewport-change",""])}}});var Qt,nr=z(()=>{Qt=class{isCancellationRequested=!1;_onCancelled;_onCancelledResolveResolved;constructor(){let t,e;this._onCancelled=new Promise(n=>{t=n,e&&e(n)}),this._onCancelledResolveResolved=new Promise(n=>{e=n,t&&n(t)})}async cancel(){await this._onCancelledResolveResolved,this.isCancellationRequested=!0}isCancelRequested(){return this.isCancellationRequested}async consume(){(await this._onCancelledResolveResolved)()}wait(){return this._onCancelled}}});function In(r){return class extends r{tmpl=document.createElement("template");stub=this.createElement("<stub></stub>");plugin;docKernel;resourceHeader=void 0;pages=[];domScale=1;track_mode=ke.Doc;current_task=void 0;viewport;constructor(...e){if(super(...e),this.registerMode("dom"),this.disposeList.push(()=>{this.dispose()}),this.plugin=this.opts.renderer,this.opts.domScale!==void 0){if(this.opts.domScale<=0)throw new Error("domScale must be positive");this.domScale=this.opts.domScale}}dispose(){for(let e of this.pages)e.dispose();this.docKernel&&this.docKernel.free()}createElement(e){return this.tmpl.innerHTML=e,this.tmpl.content.firstElementChild}async mountDom(e){if(this.docKernel)throw new Error("already mounted");this.hookedElem.innerHTML=\'<svg class="typst-svg-resources" viewBox="0 0 0 0" width="0" height="0" style="opacity: 0; position: absolute;"></svg>\',this.resourceHeader=this.hookedElem.querySelector(".typst-svg-resources"),this.docKernel=await this.plugin.renderer.mount_dom(this.kModule[x],this.hookedElem),this.docKernel.bind_functions({populateGlyphs:n=>{let o=this.createElement(n).firstElementChild;this.resourceHeader.append(o)}})}async cancelAnyway$dom(){if(this.current_task){let e=this.current_task;this.current_task=void 0,await e.cancel()}}retrieveDOMPages(){return Array.from(this.hookedElem.querySelectorAll(".typst-dom-page"))}postRender$dom(){}rescale$dom(){}getDomViewport(e,n){let i=n.left,o=-n.top,s=n.right,_=e.innerHeight-n.top,d={x:0,y:o/this.domScale,width:Math.max(s-i,0)/this.domScale,height:Math.max(_-o,0)/this.domScale};return(d.width<=0||d.height<=0)&&(d.x=d.y=d.width=d.height=0),d}async rerender$dom(){let e=this.retrieveDOMState(),{x:n,y:i,width:o,height:s}=this.getDomViewport(e.window,e.boundingRect);if(!await this.docKernel.relayout(n,i,o,s))return;let d=new Qt;this.doRender$dom(d),this.current_task=d}async doRender$dom(e){let n=(_,d)=>{if(_&&!e.isCancelRequested()&&d)return d()},i=this.retrieveDOMPages().map(_=>{let{innerWidth:d,innerHeight:l}=window,f=_.getBoundingClientRect();return{inWindow:!(f.left>d||f.right<0||f.top>l||f.bottom<0),page:_}}),o=async _=>{if(await En(),e.isCancelRequested())return;let d=i[_].page,l=d.getBoundingClientRect(),f=this.getDomViewport(window,l),v=T=>this.docKernel.need_repaint(_,f.x,f.y,f.width,f.height,T),S=T=>this.docKernel.repaint(_,f.x,f.y,f.width,f.height,T),I=T=>{if(!e.isCancelRequested())return n(v(T),()=>S(T))};await I(q.Layout);let B=(l.width?Number.parseFloat(d.getAttribute("data-width"))/l.width:1)*this.domScale,j=(l.height?Number.parseFloat(d.getAttribute("data-height"))/l.height:1)*this.domScale;f.x*=B,f.y*=j,f.y-=100,f.width*=B,f.height*=j,f.height+=200,await I(q.Svg),await I(q.Semantics),!e.isCancelRequested()&&(v(q.PrepareCanvas)?(async()=>{if(await S(q.PrepareCanvas),!e.isCancelRequested())return I(q.Canvas)})():await I(q.Canvas))},s=async _=>{for(let d=0;d<i.length;++d){if(e.isCancelRequested())return;i[d].inWindow===_&&await o(d)}};this.cancelAnyway$dom(),await s(!0),await s(!1),e.isCancelRequested()}}}var En,ke,q,Zt,ir=z(()=>{It();rr();nr();En=()=>new Promise(r=>requestAnimationFrame(r));(function(r){r[r.Doc=0]="Doc",r[r.Pages=1]="Pages"})(ke||(ke={}));(function(r){r[r.Layout=0]="Layout",r[r.Svg=1]="Svg",r[r.Semantics=2]="Semantics",r[r.PrepareCanvas=3]="PrepareCanvas",r[r.Canvas=4]="Canvas"})(q||(q={}));Zt=class extends tr(er(Yt,In)){}});function m(r){st===N.length&&N.push(N.length+1);let t=st;if(st=N[t],typeof st!="number")throw new Error("corrupt heap");return N[t]=r,t}function L(r){if(typeof r!="boolean")throw new Error(`expected a boolean argument, found ${typeof r}`)}function U(r,t){if(!(r instanceof t))throw new Error(`expected instance of ${t.name}`)}function w(r){if(typeof r!="number")throw new Error(`expected a number argument, found ${typeof r}`)}function Re(r){let t=typeof r;if(t=="number"||t=="boolean"||r==null)return`${r}`;if(t=="string")return`"${r}"`;if(t=="symbol"){let i=r.description;return i==null?"Symbol":`Symbol(${i})`}if(t=="function"){let i=r.name;return typeof i=="string"&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(r)){let i=r.length,o="[";i>0&&(o+=Re(r[0]));for(let s=1;s<i;s++)o+=", "+Re(r[s]);return o+="]",o}let e=/\\[object ([^\\]]+)\\]/.exec(toString.call(r)),n;if(e&&e.length>1)n=e[1];else return toString.call(r);if(n=="Object")try{return"Object("+JSON.stringify(r)+")"}catch{return"Object"}return r instanceof Error?`${r.name}: ${r.message}\n${r.stack}`:n}function Rn(r){r<132||(N[r]=st,st=r)}function or(r,t){return r=r>>>0,at().subarray(r/1,r/1+t)}function b(){return(K===null||K.buffer.detached===!0||K.buffer.detached===void 0&&K.buffer!==a.memory.buffer)&&(K=new DataView(a.memory.buffer)),K}function R(r,t){return r=r>>>0,On(r,t)}function Cn(){return(Rt===null||Rt.byteLength===0)&&(Rt=new Uint32Array(a.memory.buffer)),Rt}function at(){return(Ct===null||Ct.byteLength===0)&&(Ct=new Uint8Array(a.memory.buffer)),Ct}function u(r){return N[r]}function E(r,t){try{return r.apply(this,t)}catch(e){a.__wbindgen_export3(m(e))}}function A(r){return r==null}function g(r,t){try{return r.apply(this,t)}catch(e){let n=(function(){try{return e instanceof Error?`${e.message}\n\nStack:\n${e.stack}`:e.toString()}catch{return"<failed to stringify thrown value>"}})();throw console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:",n),e}}function sr(r,t,e,n){let i={a:r,b:t,cnt:1,dtor:e},o=(...s)=>{i.cnt++;try{return n(i.a,i.b,...s)}finally{o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{--i.cnt===0&&(i.dtor(i.a,i.b),i.a=0,ee.unregister(i))},ee.register(o,i,i),o}function An(r,t,e,n){let i={a:r,b:t,cnt:1,dtor:e},o=(...s)=>{i.cnt++;let _=i.a;i.a=0;try{return n(_,i.b,...s)}finally{i.a=_,o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{--i.cnt===0&&(i.dtor(i.a,i.b),i.a=0,ee.unregister(i))},ee.register(o,i,i),o}function Pn(r,t){let e=t(r.length*4,4)>>>0;return Cn().set(r,e/4),F=r.length,e}function re(r,t){let e=t(r.length*1,1)>>>0;return at().set(r,e/1),F=r.length,e}function ar(r,t){let e=t(r.length*4,4)>>>0,n=b();for(let i=0;i<r.length;i++)n.setUint32(e+4*i,m(r[i]),!0);return F=r.length,e}function D(r,t,e){if(typeof r!="string")throw new Error(`expected a string argument, found ${typeof r}`);if(e===void 0){let _=At.encode(r),d=t(_.length,1)>>>0;return at().subarray(d,d+_.length).set(_),F=_.length,d}let n=r.length,i=t(n,1)>>>0,o=at(),s=0;for(;s<n;s++){let _=r.charCodeAt(s);if(_>127)break;o[i+s]=_}if(s!==n){s!==0&&(r=r.slice(s)),i=e(i,n,n=s+r.length*3,1)>>>0;let _=at().subarray(i+s,i+n),d=At.encodeInto(r,_);if(d.read!==r.length)throw new Error("failed to pass whole string");s+=d.written,i=e(i,n,s,1)>>>0}return F=s,i}function P(r){let t=u(r);return Rn(r),t}function On(r,t){return Ee+=t,Ee>=Fn&&(te=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),te.decode(),Ee=t),te.decode(at().subarray(r,r+t))}function Mn(r,t){w(r),w(t),a.__wasm_bindgen_func_elem_1034(r,t)}function Tn(r,t,e){w(r),w(t),a.__wasm_bindgen_func_elem_1035(r,t,m(e))}function Ln(r,t,e){w(r),w(t),a.__wasm_bindgen_func_elem_1056(r,t,m(e))}function Dn(r,t,e,n){w(r),w(t),a.__wasm_bindgen_func_elem_3553(r,t,m(e),m(n))}function zn(){let r=a.renderer_build_info();return P(r)}async function Bn(r,t){if(typeof Response=="function"&&r instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(r,t)}catch(n){if(r.ok&&Wn.has(r.type)&&r.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n",n);else throw n}let e=await r.arrayBuffer();return await WebAssembly.instantiate(e,t)}else{let e=await WebAssembly.instantiate(r,t);return e instanceof WebAssembly.Instance?{instance:e,module:r}:e}}function hr(){let r={};return r.wbg={},r.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6=function(t,e){let n=Re(u(e)),i=D(n,a.__wbindgen_export,a.__wbindgen_export2),o=F;b().setInt32(t+4,o,!0),b().setInt32(t+0,i,!0)},r.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd=function(t){let e=typeof u(t)=="function";return L(e),e},r.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269=function(t){let e=u(t)===void 0;return L(e),e},r.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36=function(t,e){let n=u(t)===u(e);return L(n),n},r.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42=function(t,e){let n=u(e),i=typeof n=="string"?n:void 0;var o=A(i)?0:D(i,a.__wbindgen_export,a.__wbindgen_export2),s=F;b().setInt32(t+4,s,!0),b().setInt32(t+0,o,!0)},r.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e=function(t,e){throw new Error(R(t,e))},r.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7=function(){return g(function(t){u(t)._wbg_cb_unref()},arguments)},r.wbg.__wbg_appendChild_7465eba84213c75f=function(){return E(function(t,e){let n=u(t).appendChild(u(e));return m(n)},arguments)},r.wbg.__wbg_call_3020136f7a2d6e44=function(){return E(function(t,e,n){let i=u(t).call(u(e),u(n));return m(i)},arguments)},r.wbg.__wbg_call_78f94eb02ec7f9b2=function(){return E(function(t,e,n,i,o){let s=u(t).call(u(e),u(n),u(i),u(o));return m(s)},arguments)},r.wbg.__wbg_call_abb4ff46ce38be40=function(){return E(function(t,e){let n=u(t).call(u(e));return m(n)},arguments)},r.wbg.__wbg_call_c8baa5c5e72d274e=function(){return E(function(t,e,n,i){let o=u(t).call(u(e),u(n),u(i));return m(o)},arguments)},r.wbg.__wbg_clearRect_c2909c2f38887f82=function(){return g(function(t,e,n,i,o){u(t).clearRect(e,n,i,o)},arguments)},r.wbg.__wbg_clientWidth_dbc9540f4ebdce2a=function(){return g(function(t){let e=u(t).clientWidth;return w(e),e},arguments)},r.wbg.__wbg_clip_35de02bb25d222d9=function(){return g(function(t,e){u(t).clip(u(e))},arguments)},r.wbg.__wbg_clip_afc9a92171eee96e=function(){return g(function(t,e){u(t).clip(u(e))},arguments)},r.wbg.__wbg_cloneNode_c9c45b24b171a776=function(){return E(function(t){let e=u(t).cloneNode();return m(e)},arguments)},r.wbg.__wbg_content_ad90fa08b8c037c5=function(){return g(function(t){let e=u(t).content;return m(e)},arguments)},r.wbg.__wbg_createElement_da4ed2b219560fc6=function(){return E(function(t,e,n){let i=u(t).createElement(R(e,n));return m(i)},arguments)},r.wbg.__wbg_createImageBitmap_15b94d7a7277d0be=function(){return E(function(t,e){let n=u(t).createImageBitmap(u(e));return m(n)},arguments)},r.wbg.__wbg_createImageBitmap_4772db6cb0dff013=function(){return E(function(t,e){let n=u(t).createImageBitmap(u(e));return m(n)},arguments)},r.wbg.__wbg_createObjectURL_7d9f7f8f41373850=function(){return E(function(t,e){let n=URL.createObjectURL(u(e)),i=D(n,a.__wbindgen_export,a.__wbindgen_export2),o=F;b().setInt32(t+4,o,!0),b().setInt32(t+0,i,!0)},arguments)},r.wbg.__wbg_document_5b745e82ba551ca5=function(){return g(function(t){let e=u(t).document;return A(e)?0:m(e)},arguments)},r.wbg.__wbg_drawImage_2859dfb229439d8c=function(){return E(function(t,e,n,i,o,s){u(t).drawImage(u(e),n,i,o,s)},arguments)},r.wbg.__wbg_drawImage_6949f7679b2a9758=function(){return E(function(t,e,n,i,o,s){u(t).drawImage(u(e),n,i,o,s)},arguments)},r.wbg.__wbg_drawImage_c2aacfe3133aedb7=function(){return E(function(t,e,n,i){u(t).drawImage(u(e),n,i)},arguments)},r.wbg.__wbg_drawImage_c40aff4a38206f4a=function(){return E(function(t,e,n,i,o,s){u(t).drawImage(u(e),n,i,o,s)},arguments)},r.wbg.__wbg_drawImage_c4f2c6d2bcfa9463=function(){return E(function(t,e,n,i){u(t).drawImage(u(e),n,i)},arguments)},r.wbg.__wbg_drawImage_de5946f9cc23c2b9=function(){return E(function(t,e,n,i){u(t).drawImage(u(e),n,i)},arguments)},r.wbg.__wbg_drawImage_e2012c2a2d434ee2=function(){return E(function(t,e,n,i,o,s){u(t).drawImage(u(e),n,i,o,s)},arguments)},r.wbg.__wbg_error_7534b8e9a36f1ab4=function(){return g(function(t,e){let n,i;try{n=t,i=e,console.error(R(t,e))}finally{a.__wbindgen_export4(n,i,1)}},arguments)},r.wbg.__wbg_fillRect_84131220403e26a4=function(){return g(function(t,e,n,i,o){u(t).fillRect(e,n,i,o)},arguments)},r.wbg.__wbg_fillRect_e0efe328740308e7=function(){return g(function(t,e,n,i,o){u(t).fillRect(e,n,i,o)},arguments)},r.wbg.__wbg_fill_2f2cb4f3f75aadd4=function(){return g(function(t,e,n){u(t).fill(u(e),_r[n])},arguments)},r.wbg.__wbg_fill_38a7d7455451c001=function(){return g(function(t,e,n){u(t).fill(u(e),_r[n])},arguments)},r.wbg.__wbg_fill_3d82e52894462c95=function(){return g(function(t,e){u(t).fill(u(e))},arguments)},r.wbg.__wbg_fill_f1043be5324533f3=function(){return g(function(t,e){u(t).fill(u(e))},arguments)},r.wbg.__wbg_firstElementChild_54d515b19cee5ae7=function(){return g(function(t){let e=u(t).firstElementChild;return A(e)?0:m(e)},arguments)},r.wbg.__wbg_firstElementChild_e207b33aaa4a86df=function(){return g(function(t){let e=u(t).firstElementChild;return A(e)?0:m(e)},arguments)},r.wbg.__wbg_getAttribute_80900eec94cb3636=function(){return g(function(t,e,n,i){let o=u(e).getAttribute(R(n,i));var s=A(o)?0:D(o,a.__wbindgen_export,a.__wbindgen_export2),_=F;b().setInt32(t+4,_,!0),b().setInt32(t+0,s,!0)},arguments)},r.wbg.__wbg_getContext_01f42b234e833f0a=function(){return E(function(t,e,n){let i=u(t).getContext(R(e,n));return A(i)?0:m(i)},arguments)},r.wbg.__wbg_getContext_2f210d0a58d43d95=function(){return E(function(t,e,n){let i=u(t).getContext(R(e,n));return A(i)?0:m(i)},arguments)},r.wbg.__wbg_get_af9dab7e9603ea93=function(){return E(function(t,e){let n=Reflect.get(u(t),u(e));return m(n)},arguments)},r.wbg.__wbg_globalCompositeOperation_03e6a5201c8ee369=function(){return E(function(t,e){let n=u(e).globalCompositeOperation,i=D(n,a.__wbindgen_export,a.__wbindgen_export2),o=F;b().setInt32(t+4,o,!0),b().setInt32(t+0,i,!0)},arguments)},r.wbg.__wbg_globalCompositeOperation_d52c6e6666e4be00=function(){return E(function(t,e){let n=u(e).globalCompositeOperation,i=D(n,a.__wbindgen_export,a.__wbindgen_export2),o=F;b().setInt32(t+4,o,!0),b().setInt32(t+0,i,!0)},arguments)},r.wbg.__wbg_height_3a0b31e52a5b7f17=function(){return g(function(t){let e=u(t).height;return w(e),e},arguments)},r.wbg.__wbg_incrdomdocclient_new=function(){return g(function(t){let e=ct.__wrap(t);return m(e)},arguments)},r.wbg.__wbg_instanceof_CanvasRenderingContext2d_d070139aaac1459f=function(){return g(function(t){let e;try{e=u(t)instanceof CanvasRenderingContext2D}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_Element_6f7ba982258cfc0f=function(){return g(function(t){let e;try{e=u(t)instanceof Element}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_HtmlCanvasElement_c4251b1b6a15edcc=function(){return g(function(t){let e;try{e=u(t)instanceof HTMLCanvasElement}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_HtmlDivElement_a55b9d453d2d8037=function(){return g(function(t){let e;try{e=u(t)instanceof HTMLDivElement}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_HtmlElement_20a3acb594113d73=function(){return g(function(t){let e;try{e=u(t)instanceof HTMLElement}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_HtmlTemplateElement_702a22ea7e74d089=function(){return g(function(t){let e;try{e=u(t)instanceof HTMLTemplateElement}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_ImageBitmap_e44697c70dffc0fe=function(){return g(function(t){let e;try{e=u(t)instanceof ImageBitmap}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_OffscreenCanvasRenderingContext2d_52996da29a2bf2f5=function(){return g(function(t){let e;try{e=u(t)instanceof OffscreenCanvasRenderingContext2D}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_OffscreenCanvas_8fb961f5ea27473f=function(){return g(function(t){let e;try{e=u(t)instanceof OffscreenCanvas}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_Promise_eca6c43a2610558d=function(){return g(function(t){let e;try{e=u(t)instanceof Promise}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_SvgGraphicsElement_16c442d1a36270b3=function(){return g(function(t){let e;try{e=u(t)instanceof SVGGraphicsElement}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_SvgsvgElement_27a38efc9750b6fa=function(){return g(function(t){let e;try{e=u(t)instanceof SVGSVGElement}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_Window_b5cf7783caa68180=function(){return g(function(t){let e;try{e=u(t)instanceof Window}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_instanceof_WorkerGlobalScope_9a3411db21c65a54=function(){return g(function(t){let e;try{e=u(t)instanceof WorkerGlobalScope}catch{e=!1}let n=e;return L(n),n},arguments)},r.wbg.__wbg_lastElementChild_6b90fe10adf639a2=function(){return g(function(t){let e=u(t).lastElementChild;return A(e)?0:m(e)},arguments)},r.wbg.__wbg_length_22ac23eaec9d8053=function(){return g(function(t){let e=u(t).length;return w(e),e},arguments)},r.wbg.__wbg_log_1d990106d99dacb7=function(){return g(function(t){console.log(u(t))},arguments)},r.wbg.__wbg_log_fd6486c6d5396ce5=function(){return g(function(t,e){console.log(u(t),u(e))},arguments)},r.wbg.__wbg_measureText_a465ecc06491802d=function(){return E(function(t,e,n){let i=u(t).measureText(R(e,n));return m(i)},arguments)},r.wbg.__wbg_new_1ba21ce319a06297=function(){return g(function(){let t=new Object;return m(t)},arguments)},r.wbg.__wbg_new_25f239778d6112b9=function(){return g(function(){let t=new Array;return m(t)},arguments)},r.wbg.__wbg_new_2884ddbcda091bc1=function(){return E(function(){let t=new Image;return m(t)},arguments)},r.wbg.__wbg_new_8a6f238a6ece86ea=function(){return g(function(){let t=new Error;return m(t)},arguments)},r.wbg.__wbg_new_9468dd6e5df427f6=function(){return E(function(t,e){let n=new OffscreenCanvas(t>>>0,e>>>0);return m(n)},arguments)},r.wbg.__wbg_new_df1173567d5ff028=function(){return g(function(t,e){let n=new Error(R(t,e));return m(n)},arguments)},r.wbg.__wbg_new_ff12d2b041fb48f1=function(){return g(function(t,e){try{var n={a:t,b:e},i=(s,_)=>{let d=n.a;n.a=0;try{return Dn(d,n.b,s,_)}finally{n.a=d}};let o=new Promise(i);return m(o)}finally{n.a=n.b=0}},arguments)},r.wbg.__wbg_new_from_slice_f9c22b9153b26992=function(){return g(function(t,e){let n=new Uint8Array(or(t,e));return m(n)},arguments)},r.wbg.__wbg_new_no_args_cb138f77cf6151ee=function(){return g(function(t,e){let n=new Function(R(t,e));return m(n)},arguments)},r.wbg.__wbg_new_with_length_aa5eaf41d35235e5=function(){return g(function(t){let e=new Uint8Array(t>>>0);return m(e)},arguments)},r.wbg.__wbg_new_with_path_string_3aea637e78135c46=function(){return E(function(t,e){let n=new Path2D(R(t,e));return m(n)},arguments)},r.wbg.__wbg_new_with_u8_array_sequence_and_options_d4def9ec0588c7ec=function(){return E(function(t,e){let n=new Blob(u(t),u(e));return m(n)},arguments)},r.wbg.__wbg_nextElementSibling_c745ee48314963c0=function(){return g(function(t){let e=u(t).nextElementSibling;return A(e)?0:m(e)},arguments)},r.wbg.__wbg_push_7d9be8f38fc13975=function(){return g(function(t,e){let n=u(t).push(u(e));return w(n),n},arguments)},r.wbg.__wbg_putImageData_c280ca107c4b7828=function(){return E(function(t,e,n,i){u(t).putImageData(u(e),n,i)},arguments)},r.wbg.__wbg_putImageData_e96eabf0e9610ed3=function(){return E(function(t,e,n,i){u(t).putImageData(u(e),n,i)},arguments)},r.wbg.__wbg_queueMicrotask_9b549dfce8865860=function(){return g(function(t){let e=u(t).queueMicrotask;return m(e)},arguments)},r.wbg.__wbg_queueMicrotask_fca69f5bfad613a5=function(){return g(function(t){queueMicrotask(u(t))},arguments)},r.wbg.__wbg_removeProperty_c2e16faee2834bef=function(){return E(function(t,e,n,i){let o=u(e).removeProperty(R(n,i)),s=D(o,a.__wbindgen_export,a.__wbindgen_export2),_=F;b().setInt32(t+4,_,!0),b().setInt32(t+0,s,!0)},arguments)},r.wbg.__wbg_remove_32f69ffabcbc4072=function(){return g(function(t){u(t).remove()},arguments)},r.wbg.__wbg_renderpageimageoptions_unwrap=function(){return g(function(t){let e=Q.__unwrap(u(t));return w(e),e},arguments)},r.wbg.__wbg_replaceWith_923cfb1b2f584408=function(){return E(function(t,e){u(t).replaceWith(u(e))},arguments)},r.wbg.__wbg_resolve_fd5bfbaa4ce36e1e=function(){return g(function(t){let e=Promise.resolve(u(t));return m(e)},arguments)},r.wbg.__wbg_restore_352c39c9bbeedc91=function(){return g(function(t){u(t).restore()},arguments)},r.wbg.__wbg_restore_6486cb1a7aa3af7b=function(){return g(function(t){u(t).restore()},arguments)},r.wbg.__wbg_revokeObjectURL_88db3468842ff09e=function(){return E(function(t,e){URL.revokeObjectURL(R(t,e))},arguments)},r.wbg.__wbg_save_131c8dc648f702b6=function(){return g(function(t){u(t).save()},arguments)},r.wbg.__wbg_save_b8767cfd2ee7f600=function(){return g(function(t){u(t).save()},arguments)},r.wbg.__wbg_setAttribute_34747dd193f45828=function(){return E(function(t,e,n,i,o){u(t).setAttribute(R(e,n),R(i,o))},arguments)},r.wbg.__wbg_setLineDash_7e3aad159aa2710c=function(){return E(function(t,e){u(t).setLineDash(u(e))},arguments)},r.wbg.__wbg_setLineDash_cfbc3a6bfddeee62=function(){return E(function(t,e){u(t).setLineDash(u(e))},arguments)},r.wbg.__wbg_setProperty_f27b2c05323daf8a=function(){return E(function(t,e,n,i,o){u(t).setProperty(R(e,n),R(i,o))},arguments)},r.wbg.__wbg_setTransform_9de588d9f080f5bc=function(){return E(function(t,e,n,i,o,s,_){u(t).setTransform(e,n,i,o,s,_)},arguments)},r.wbg.__wbg_setTransform_c55eca1193bf5ea1=function(){return E(function(t,e,n,i,o,s,_){u(t).setTransform(e,n,i,o,s,_)},arguments)},r.wbg.__wbg_set_169e13b608078b7b=function(){return g(function(t,e,n){u(t).set(or(e,n))},arguments)},r.wbg.__wbg_set_781438a03c0c3c81=function(){return E(function(t,e,n){let i=Reflect.set(u(t),u(e),u(n));return L(i),i},arguments)},r.wbg.__wbg_set_7df433eea03a5c14=function(){return g(function(t,e,n){u(t)[e>>>0]=P(n)},arguments)},r.wbg.__wbg_set_fillStyle_b26e462a87b14315=function(){return g(function(t,e,n){u(t).fillStyle=R(e,n)},arguments)},r.wbg.__wbg_set_fillStyle_c9a0550307cd4671=function(){return g(function(t,e,n){u(t).fillStyle=R(e,n)},arguments)},r.wbg.__wbg_set_font_6d67b15564a1e344=function(){return g(function(t,e,n){u(t).font=R(e,n)},arguments)},r.wbg.__wbg_set_globalCompositeOperation_418a0b97ba91a947=function(){return E(function(t,e,n){u(t).globalCompositeOperation=R(e,n)},arguments)},r.wbg.__wbg_set_globalCompositeOperation_7e16c72877ba5f86=function(){return E(function(t,e,n){u(t).globalCompositeOperation=R(e,n)},arguments)},r.wbg.__wbg_set_height_6f8f8ef4cb40e496=function(){return g(function(t,e){u(t).height=e>>>0},arguments)},r.wbg.__wbg_set_innerHTML_f1d03f780518a596=function(){return g(function(t,e,n){u(t).innerHTML=R(e,n)},arguments)},r.wbg.__wbg_set_lineCap_74b37c7ff968f854=function(){return g(function(t,e,n){u(t).lineCap=R(e,n)},arguments)},r.wbg.__wbg_set_lineCap_791e7648138cc371=function(){return g(function(t,e,n){u(t).lineCap=R(e,n)},arguments)},r.wbg.__wbg_set_lineDashOffset_85f21a63ddf34d2c=function(){return g(function(t,e){u(t).lineDashOffset=e},arguments)},r.wbg.__wbg_set_lineDashOffset_f032b4e2a273a2f5=function(){return g(function(t,e){u(t).lineDashOffset=e},arguments)},r.wbg.__wbg_set_lineJoin_196c6ac02fd494c3=function(){return g(function(t,e,n){u(t).lineJoin=R(e,n)},arguments)},r.wbg.__wbg_set_lineJoin_a136f09dd803e0cc=function(){return g(function(t,e,n){u(t).lineJoin=R(e,n)},arguments)},r.wbg.__wbg_set_lineWidth_ed39767bf75d602d=function(){return g(function(t,e){u(t).lineWidth=e},arguments)},r.wbg.__wbg_set_lineWidth_feda4b79a15c660b=function(){return g(function(t,e){u(t).lineWidth=e},arguments)},r.wbg.__wbg_set_miterLimit_b12c03757937d228=function(){return g(function(t,e){u(t).miterLimit=e},arguments)},r.wbg.__wbg_set_miterLimit_d891f47e244a915c=function(){return g(function(t,e){u(t).miterLimit=e},arguments)},r.wbg.__wbg_set_onerror_e7e40c62a55a0770=function(){return g(function(t,e){u(t).onerror=u(e)},arguments)},r.wbg.__wbg_set_onload_5e2862e3453854de=function(){return g(function(t,e){u(t).onload=u(e)},arguments)},r.wbg.__wbg_set_src_84f27c5105946dce=function(){return g(function(t,e,n){u(t).src=R(e,n)},arguments)},r.wbg.__wbg_set_strokeStyle_25d5381be570e780=function(){return g(function(t,e,n){u(t).strokeStyle=R(e,n)},arguments)},r.wbg.__wbg_set_strokeStyle_697a576d2d3fbeaa=function(){return g(function(t,e,n){u(t).strokeStyle=R(e,n)},arguments)},r.wbg.__wbg_set_type_7ce650670a34c68f=function(){return g(function(t,e,n){u(t).type=R(e,n)},arguments)},r.wbg.__wbg_set_width_7ff7a22c6e9f423e=function(){return g(function(t,e){u(t).width=e>>>0},arguments)},r.wbg.__wbg_stack_0ed75d68575b0f3c=function(){return g(function(t,e){let n=u(e).stack,i=D(n,a.__wbindgen_export,a.__wbindgen_export2),o=F;b().setInt32(t+4,o,!0),b().setInt32(t+0,i,!0)},arguments)},r.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335=function(){return g(function(){let t=typeof global>"u"?null:global;return A(t)?0:m(t)},arguments)},r.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1=function(){return g(function(){let t=typeof globalThis>"u"?null:globalThis;return A(t)?0:m(t)},arguments)},r.wbg.__wbg_static_accessor_SELF_08f5a74c69739274=function(){return g(function(){let t=typeof self>"u"?null:self;return A(t)?0:m(t)},arguments)},r.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024=function(){return g(function(){let t=typeof window>"u"?null:window;return A(t)?0:m(t)},arguments)},r.wbg.__wbg_stringify_655a6390e1f5eb6b=function(){return E(function(t){let e=JSON.stringify(u(t));return m(e)},arguments)},r.wbg.__wbg_stroke_41b0736a6a0b61aa=function(){return g(function(t,e){u(t).stroke(u(e))},arguments)},r.wbg.__wbg_stroke_7cfe6d60a6c48303=function(){return g(function(t,e){u(t).stroke(u(e))},arguments)},r.wbg.__wbg_style_521a717da50e53c6=function(){return g(function(t){let e=u(t).style;return m(e)},arguments)},r.wbg.__wbg_then_429f7caf1026411d=function(){return g(function(t,e,n){let i=u(t).then(u(e),u(n));return m(i)},arguments)},r.wbg.__wbg_then_4f95312d68691235=function(){return g(function(t,e){let n=u(t).then(u(e));return m(n)},arguments)},r.wbg.__wbg_transferToImageBitmap_7048556ff33da7ed=function(){return E(function(t){let e=u(t).transferToImageBitmap();return m(e)},arguments)},r.wbg.__wbg_typstrenderer_new=function(){return g(function(t){let e=dt.__wrap(t);return m(e)},arguments)},r.wbg.__wbg_warn_6e567d0d926ff881=function(){return g(function(t){console.warn(u(t))},arguments)},r.wbg.__wbg_width_c3f96f2ca7ab208d=function(){return g(function(t){return u(t).width},arguments)},r.wbg.__wbg_width_f13d2e86324fc226=function(){return g(function(t){let e=u(t).width;return w(e),e},arguments)},r.wbg.__wbindgen_cast_034b33c9b274ad29=function(){return g(function(t,e){let n=sr(t,e,a.__wasm_bindgen_func_elem_1022,Mn);return m(n)},arguments)},r.wbg.__wbindgen_cast_2241b6af4c4b2941=function(){return g(function(t,e){let n=R(t,e);return m(n)},arguments)},r.wbg.__wbindgen_cast_aa4fe27cfdb2d557=function(){return g(function(t,e){let n=sr(t,e,a.__wasm_bindgen_func_elem_1022,Tn);return m(n)},arguments)},r.wbg.__wbindgen_cast_b2e692da0ea8478a=function(){return g(function(t,e){let n=An(t,e,a.__wasm_bindgen_func_elem_1077,Ln);return m(n)},arguments)},r.wbg.__wbindgen_cast_d6cd19b81560fd6e=function(){return g(function(t){return m(t)},arguments)},r.wbg.__wbindgen_object_clone_ref=function(t){let e=u(t);return m(e)},r.wbg.__wbindgen_object_drop_ref=function(t){P(t)},r}function mr(r,t){return a=r.exports,yr.__wbindgen_wasm_module=t,K=null,Rt=null,Ct=null,a}function $n(r){if(a!==void 0)return a;typeof r<"u"&&(Object.getPrototypeOf(r)===Object.prototype?{module:r}=r:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=hr();r instanceof WebAssembly.Module||(r=new WebAssembly.Module(r));let e=new WebAssembly.Instance(r,t);return mr(e,r)}async function yr(r){if(a!==void 0)return a;typeof r<"u"&&(Object.getPrototypeOf(r)===Object.prototype?{module_or_path:r}=r:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof r>"u"&&(r=xr("typst_ts_renderer_bg.wasm",Un.url));let t=hr();(typeof r=="string"||typeof Request=="function"&&r instanceof Request||typeof URL=="function"&&r instanceof URL)&&(r=fetch(r));let{instance:e,module:n}=await Bn(await r,t);return mr(e,n)}function Ce(r){xr=r}var Un,a,ee,K,Rt,Ct,N,st,te,Fn,Ee,At,F,_r,cr,ur,dr,fr,lr,gr,wr,Ie,pr,jn,br,_t,ct,Y,ut,Q,W,Pt,dt,Ft,Ot,ft,Wn,vr,xr,ne=z(()=>{Un={};ee=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>r.dtor(r.a,r.b));K=null;Rt=null;Ct=null;N=new Array(128).fill(void 0);N.push(void 0,null,!0,!1);st=N.length;te=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});te.decode();Fn=2146435072,Ee=0;At=new TextEncoder;"encodeInto"in At||(At.encodeInto=function(r,t){let e=At.encode(r);return t.set(e),{read:r.length,written:e.length}});F=0;_r=["nonzero","evenodd"],cr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>a.__wbg_createsessionoptions_free(r>>>0,1)),ur=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>a.__wbg_incrdomdocclient_free(r>>>0,1)),dr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>a.__wbg_pageinfo_free(r>>>0,1)),fr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>a.__wbg_pagesinfo_free(r>>>0,1)),lr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>a.__wbg_renderpageimageoptions_free(r>>>0,1)),gr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>a.__wbg_rendersession_free(r>>>0,1)),wr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>a.__wbg_rendersessionoptions_free(r>>>0,1)),Ie=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>a.__wbg_typstrenderer_free(r>>>0,1)),pr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>a.__wbg_typstrendererbuilder_free(r>>>0,1)),jn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>a.__wbg_typstworker_free(r>>>0,1)),br=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>a.__wbg_workerbridge_free(r>>>0,1)),_t=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,cr.unregister(this),t}free(){let t=this.__destroy_into_raw();a.__wbg_createsessionoptions_free(t,0)}constructor(){let t=a.createsessionoptions_new();return this.__wbg_ptr=t>>>0,cr.register(this,this.__wbg_ptr,this),this}set format(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let e=D(t,a.__wbindgen_export,a.__wbindgen_export2),n=F;a.createsessionoptions_set_format(this.__wbg_ptr,e,n)}set artifact_content(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let e=re(t,a.__wbindgen_export),n=F;a.createsessionoptions_set_artifact_content(this.__wbg_ptr,e,n)}};Symbol.dispose&&(_t.prototype[Symbol.dispose]=_t.prototype.free);ct=class r{constructor(){throw new Error("cannot invoke `new` directly")}static __wrap(t){t=t>>>0;let e=Object.create(r.prototype);return e.__wbg_ptr=t,ur.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,ur.unregister(this),t}free(){let t=this.__destroy_into_raw();a.__wbg_incrdomdocclient_free(t,0)}bind_functions(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr),a.incrdomdocclient_bind_functions(this.__wbg_ptr,m(t))}relayout(t,e,n,i){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let o=a.incrdomdocclient_relayout(this.__wbg_ptr,t,e,n,i);return P(o)}need_repaint(t,e,n,i,o,s){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let f=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr),w(t),w(s),a.incrdomdocclient_need_repaint(f,this.__wbg_ptr,t,e,n,i,o,s);var _=b().getInt32(f+0,!0),d=b().getInt32(f+4,!0),l=b().getInt32(f+8,!0);if(l)throw P(d);return _!==0}finally{a.__wbindgen_add_to_stack_pointer(16)}}repaint(t,e,n,i,o,s){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let f=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr),w(t),w(s),a.incrdomdocclient_repaint(f,this.__wbg_ptr,t,e,n,i,o,s);var _=b().getInt32(f+0,!0),d=b().getInt32(f+4,!0),l=b().getInt32(f+8,!0);if(l)throw P(d);return P(_)}finally{a.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(ct.prototype[Symbol.dispose]=ct.prototype.free);Y=class r{constructor(){throw new Error("cannot invoke `new` directly")}static __wrap(t){t=t>>>0;let e=Object.create(r.prototype);return e.__wbg_ptr=t,dr.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,dr.unregister(this),t}free(){let t=this.__destroy_into_raw();a.__wbg_pageinfo_free(t,0)}get page_off(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");return w(this.__wbg_ptr),a.pageinfo_page_off(this.__wbg_ptr)>>>0}get width_pt(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");return w(this.__wbg_ptr),a.pageinfo_width_pt(this.__wbg_ptr)}get height_pt(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");return w(this.__wbg_ptr),a.pageinfo_height_pt(this.__wbg_ptr)}};Symbol.dispose&&(Y.prototype[Symbol.dispose]=Y.prototype.free);ut=class r{constructor(){throw new Error("cannot invoke `new` directly")}static __wrap(t){t=t>>>0;let e=Object.create(r.prototype);return e.__wbg_ptr=t,fr.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,fr.unregister(this),t}free(){let t=this.__destroy_into_raw();a.__wbg_pagesinfo_free(t,0)}get page_count(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");return w(this.__wbg_ptr),a.pagesinfo_page_count(this.__wbg_ptr)>>>0}page_by_number(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr),w(t);let e=a.pagesinfo_page_by_number(this.__wbg_ptr,t);return e===0?void 0:Y.__wrap(e)}page(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr),w(t);let e=a.pagesinfo_page(this.__wbg_ptr,t);return Y.__wrap(e)}width(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");return w(this.__wbg_ptr),a.pagesinfo_width(this.__wbg_ptr)}height(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");return w(this.__wbg_ptr),a.pagesinfo_height(this.__wbg_ptr)}};Symbol.dispose&&(ut.prototype[Symbol.dispose]=ut.prototype.free);Q=class r{static __unwrap(t){return t instanceof r?t.__destroy_into_raw():0}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,lr.unregister(this),t}free(){let t=this.__destroy_into_raw();a.__wbg_renderpageimageoptions_free(t,0)}constructor(){let t=a.renderpageimageoptions_new();return this.__wbg_ptr=t>>>0,lr.register(this,this.__wbg_ptr,this),this}get pixel_per_pt(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let t=a.renderpageimageoptions_pixel_per_pt(this.__wbg_ptr);return t===4294967297?void 0:t}set pixel_per_pt(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr),A(t)||w(t),a.renderpageimageoptions_set_pixel_per_pt(this.__wbg_ptr,A(t)?4294967297:Math.fround(t))}get background_color(){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let n=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr),a.renderpageimageoptions_background_color(n,this.__wbg_ptr);var t=b().getInt32(n+0,!0),e=b().getInt32(n+4,!0);let i;return t!==0&&(i=R(t,e).slice(),a.__wbindgen_export4(t,e*1,1)),i}finally{a.__wbindgen_add_to_stack_pointer(16)}}set background_color(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);var e=A(t)?0:D(t,a.__wbindgen_export,a.__wbindgen_export2),n=F;a.renderpageimageoptions_set_background_color(this.__wbg_ptr,e,n)}get page_off(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");return w(this.__wbg_ptr),a.renderpageimageoptions_page_off(this.__wbg_ptr)>>>0}set page_off(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr),w(t),a.renderpageimageoptions_set_page_off(this.__wbg_ptr,t)}get cache_key(){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let n=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr),a.renderpageimageoptions_cache_key(n,this.__wbg_ptr);var t=b().getInt32(n+0,!0),e=b().getInt32(n+4,!0);let i;return t!==0&&(i=R(t,e).slice(),a.__wbindgen_export4(t,e*1,1)),i}finally{a.__wbindgen_add_to_stack_pointer(16)}}set cache_key(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);var e=A(t)?0:D(t,a.__wbindgen_export,a.__wbindgen_export2),n=F;a.renderpageimageoptions_set_cache_key(this.__wbg_ptr,e,n)}get data_selection(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let t=a.renderpageimageoptions_data_selection(this.__wbg_ptr);return t===4294967297?void 0:t}set data_selection(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr),A(t)||w(t),a.renderpageimageoptions_set_data_selection(this.__wbg_ptr,A(t)?4294967297:t>>>0)}};Symbol.dispose&&(Q.prototype[Symbol.dispose]=Q.prototype.free);W=class r{constructor(){throw new Error("cannot invoke `new` directly")}static __wrap(t){t=t>>>0;let e=Object.create(r.prototype);return e.__wbg_ptr=t,gr.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,gr.unregister(this),t}free(){let t=this.__destroy_into_raw();a.__wbg_rendersession_free(t,0)}render_in_window(t,e,n,i){let o,s;try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let l=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr),a.rendersession_render_in_window(l,this.__wbg_ptr,t,e,n,i);var _=b().getInt32(l+0,!0),d=b().getInt32(l+4,!0);return o=_,s=d,R(_,d)}finally{a.__wbindgen_add_to_stack_pointer(16),a.__wbindgen_export4(o,s,1)}}get pixel_per_pt(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let t=a.rendersession_pixel_per_pt(this.__wbg_ptr);return t===4294967297?void 0:t}set pixel_per_pt(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr),A(t)||w(t),a.rendersession_set_pixel_per_pt(this.__wbg_ptr,A(t)?4294967297:Math.fround(t))}get background_color(){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let n=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr),a.rendersession_background_color(n,this.__wbg_ptr);var t=b().getInt32(n+0,!0),e=b().getInt32(n+4,!0);let i;return t!==0&&(i=R(t,e).slice(),a.__wbindgen_export4(t,e*1,1)),i}finally{a.__wbindgen_add_to_stack_pointer(16)}}set background_color(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);var e=A(t)?0:D(t,a.__wbindgen_export,a.__wbindgen_export2),n=F;a.rendersession_set_background_color(this.__wbg_ptr,e,n)}get pages_info(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let t=a.rendersession_pages_info(this.__wbg_ptr);return ut.__wrap(t)}get doc_width(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");return w(this.__wbg_ptr),a.rendersession_doc_width(this.__wbg_ptr)}get doc_height(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");return w(this.__wbg_ptr),a.rendersession_doc_height(this.__wbg_ptr)}source_span(t){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let s=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr);let _=Pn(t,a.__wbindgen_export),d=F;a.rendersession_source_span(s,this.__wbg_ptr,_,d);var e=b().getInt32(s+0,!0),n=b().getInt32(s+4,!0),i=b().getInt32(s+8,!0),o=b().getInt32(s+12,!0);if(o)throw P(i);let l;return e!==0&&(l=R(e,n).slice(),a.__wbindgen_export4(e,n*1,1)),l}finally{a.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(W.prototype[Symbol.dispose]=W.prototype.free);Pt=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,wr.unregister(this),t}free(){let t=this.__destroy_into_raw();a.__wbg_rendersessionoptions_free(t,0)}constructor(){let t=a.rendersessionoptions_new();return this.__wbg_ptr=t>>>0,wr.register(this,this.__wbg_ptr,this),this}get pixel_per_pt(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let t=a.rendersession_pixel_per_pt(this.__wbg_ptr);return t===4294967297?void 0:t}set pixel_per_pt(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr),A(t)||w(t),a.rendersession_set_pixel_per_pt(this.__wbg_ptr,A(t)?4294967297:Math.fround(t))}get background_color(){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let n=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr),a.rendersessionoptions_background_color(n,this.__wbg_ptr);var t=b().getInt32(n+0,!0),e=b().getInt32(n+4,!0);let i;return t!==0&&(i=R(t,e).slice(),a.__wbindgen_export4(t,e*1,1)),i}finally{a.__wbindgen_add_to_stack_pointer(16)}}set background_color(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);var e=A(t)?0:D(t,a.__wbindgen_export,a.__wbindgen_export2),n=F;a.rendersessionoptions_set_background_color(this.__wbg_ptr,e,n)}get format(){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let n=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr),a.rendersessionoptions_format(n,this.__wbg_ptr);var t=b().getInt32(n+0,!0),e=b().getInt32(n+4,!0);let i;return t!==0&&(i=R(t,e).slice(),a.__wbindgen_export4(t,e*1,1)),i}finally{a.__wbindgen_add_to_stack_pointer(16)}}set format(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);var e=A(t)?0:D(t,a.__wbindgen_export,a.__wbindgen_export2),n=F;a.rendersessionoptions_set_format(this.__wbg_ptr,e,n)}};Symbol.dispose&&(Pt.prototype[Symbol.dispose]=Pt.prototype.free);dt=class r{static __wrap(t){t=t>>>0;let e=Object.create(r.prototype);return e.__wbg_ptr=t,Ie.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Ie.unregister(this),t}free(){let t=this.__destroy_into_raw();a.__wbg_typstrenderer_free(t,0)}constructor(){let t=a.typstrenderer_new();return this.__wbg_ptr=t>>>0,Ie.register(this,this.__wbg_ptr,this),this}create_session(t){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let o=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr);let s=0;if(!A(t)){if(U(t,_t),t.__wbg_ptr===0)throw new Error("Attempt to use a moved value");s=t.__destroy_into_raw()}a.typstrenderer_create_session(o,this.__wbg_ptr,s);var e=b().getInt32(o+0,!0),n=b().getInt32(o+4,!0),i=b().getInt32(o+8,!0);if(i)throw P(n);return W.__wrap(e)}finally{a.__wbindgen_add_to_stack_pointer(16)}}reset(t){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let i=a.__wbindgen_add_to_stack_pointer(-16);if(w(this.__wbg_ptr),U(t,W),t.__wbg_ptr===0)throw new Error("Attempt to use a moved value");a.typstrenderer_reset(i,this.__wbg_ptr,t.__wbg_ptr);var e=b().getInt32(i+0,!0),n=b().getInt32(i+4,!0);if(n)throw P(e)}finally{a.__wbindgen_add_to_stack_pointer(16)}}manipulate_data(t,e,n){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let s=a.__wbindgen_add_to_stack_pointer(-16);if(w(this.__wbg_ptr),U(t,W),t.__wbg_ptr===0)throw new Error("Attempt to use a moved value");let _=D(e,a.__wbindgen_export,a.__wbindgen_export2),d=F,l=re(n,a.__wbindgen_export),f=F;a.typstrenderer_manipulate_data(s,this.__wbg_ptr,t.__wbg_ptr,_,d,l,f);var i=b().getInt32(s+0,!0),o=b().getInt32(s+4,!0);if(o)throw P(i)}finally{a.__wbindgen_add_to_stack_pointer(16)}}session_from_artifact(t,e){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let s=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr);let _=re(t,a.__wbindgen_export),d=F,l=D(e,a.__wbindgen_export,a.__wbindgen_export2),f=F;a.typstrenderer_session_from_artifact(s,this.__wbg_ptr,_,d,l,f);var n=b().getInt32(s+0,!0),i=b().getInt32(s+4,!0),o=b().getInt32(s+8,!0);if(o)throw P(i);return W.__wrap(n)}finally{a.__wbindgen_add_to_stack_pointer(16)}}load_glyph_pack(t){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let i=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr),a.typstrenderer_load_glyph_pack(i,this.__wbg_ptr,m(t));var e=b().getInt32(i+0,!0),n=b().getInt32(i+4,!0);if(n)throw P(e)}finally{a.__wbindgen_add_to_stack_pointer(16)}}render_svg_diff(t,e,n,i,o){let s,_;try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let f=a.__wbindgen_add_to_stack_pointer(-16);if(w(this.__wbg_ptr),U(t,W),t.__wbg_ptr===0)throw new Error("Attempt to use a moved value");a.typstrenderer_render_svg_diff(f,this.__wbg_ptr,t.__wbg_ptr,e,n,i,o);var d=b().getInt32(f+0,!0),l=b().getInt32(f+4,!0);return s=d,_=l,R(d,l)}finally{a.__wbindgen_add_to_stack_pointer(16),a.__wbindgen_export4(s,_,1)}}svg_data(t,e){let n,i;try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let v=a.__wbindgen_add_to_stack_pointer(-16);if(w(this.__wbg_ptr),U(t,W),t.__wbg_ptr===0)throw new Error("Attempt to use a moved value");A(e)||w(e),a.typstrenderer_svg_data(v,this.__wbg_ptr,t.__wbg_ptr,A(e)?4294967297:e>>>0);var o=b().getInt32(v+0,!0),s=b().getInt32(v+4,!0),_=b().getInt32(v+8,!0),d=b().getInt32(v+12,!0),l=o,f=s;if(d)throw l=0,f=0,P(_);return n=l,i=f,R(l,f)}finally{a.__wbindgen_add_to_stack_pointer(16),a.__wbindgen_export4(n,i,1)}}get_customs(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");if(w(this.__wbg_ptr),U(t,W),t.__wbg_ptr===0)throw new Error("Attempt to use a moved value");let e=a.typstrenderer_get_customs(this.__wbg_ptr,t.__wbg_ptr);return P(e)}render_svg(t,e){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let s=a.__wbindgen_add_to_stack_pointer(-16);if(w(this.__wbg_ptr),U(t,W),t.__wbg_ptr===0)throw new Error("Attempt to use a moved value");a.typstrenderer_render_svg(s,this.__wbg_ptr,t.__wbg_ptr,m(e));var n=b().getInt32(s+0,!0),i=b().getInt32(s+4,!0),o=b().getInt32(s+8,!0);if(o)throw P(i);return n!==0}finally{a.__wbindgen_add_to_stack_pointer(16)}}create_worker(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let e=a.typstrenderer_create_worker(this.__wbg_ptr,m(t));return P(e)}create_worker_bridge(){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let i=this.__destroy_into_raw(),o=a.__wbindgen_add_to_stack_pointer(-16);w(i),a.typstrenderer_create_worker_bridge(o,i);var t=b().getInt32(o+0,!0),e=b().getInt32(o+4,!0),n=b().getInt32(o+8,!0);if(n)throw P(e);return ft.__wrap(t)}finally{a.__wbindgen_add_to_stack_pointer(16)}}render_page_to_canvas(t,e,n){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");if(w(this.__wbg_ptr),U(t,W),t.__wbg_ptr===0)throw new Error("Attempt to use a moved value");let i=0;if(!A(n)){if(U(n,Q),n.__wbg_ptr===0)throw new Error("Attempt to use a moved value");i=n.__destroy_into_raw()}let o=a.typstrenderer_render_page_to_canvas(this.__wbg_ptr,t.__wbg_ptr,m(e),i);return P(o)}mount_dom(t,e){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");if(w(this.__wbg_ptr),U(t,W),t.__wbg_ptr===0)throw new Error("Attempt to use a moved value");let n=a.typstrenderer_mount_dom(this.__wbg_ptr,t.__wbg_ptr,m(e));return P(n)}};Symbol.dispose&&(dt.prototype[Symbol.dispose]=dt.prototype.free);Ft=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,pr.unregister(this),t}free(){let t=this.__destroy_into_raw();a.__wbg_typstrendererbuilder_free(t,0)}constructor(){try{let i=a.__wbindgen_add_to_stack_pointer(-16);a.typstrendererbuilder_new(i);var t=b().getInt32(i+0,!0),e=b().getInt32(i+4,!0),n=b().getInt32(i+8,!0);if(n)throw P(e);return this.__wbg_ptr=t>>>0,pr.register(this,this.__wbg_ptr,this),this}finally{a.__wbindgen_add_to_stack_pointer(16)}}build(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let t=this.__destroy_into_raw();w(t);let e=a.typstrendererbuilder_build(t);return P(e)}add_glyph_pack(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let e=a.typstrendererbuilder_add_glyph_pack(this.__wbg_ptr,m(t));return P(e)}add_raw_font(t){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let e=a.typstrendererbuilder_add_raw_font(this.__wbg_ptr,m(t));return P(e)}add_lazy_font(t,e){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let n=a.typstrendererbuilder_add_lazy_font(this.__wbg_ptr,m(t),m(e));return P(n)}};Symbol.dispose&&(Ft.prototype[Symbol.dispose]=Ft.prototype.free);Ot=class{constructor(){throw new Error("cannot invoke `new` directly")}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,jn.unregister(this),t}free(){let t=this.__destroy_into_raw();a.__wbg_typstworker_free(t,0)}manipulate_data(t,e){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let s=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr);let _=D(t,a.__wbindgen_export,a.__wbindgen_export2),d=F;a.typstworker_manipulate_data(s,this.__wbg_ptr,_,d,m(e));var n=b().getInt32(s+0,!0),i=b().getInt32(s+4,!0),o=b().getInt32(s+8,!0);if(o)throw P(i);return P(n)}finally{a.__wbindgen_add_to_stack_pointer(16)}}get_pages_info(){if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");w(this.__wbg_ptr);let t=a.typstworker_get_pages_info(this.__wbg_ptr);return P(t)}render_canvas(t,e,n){try{if(this.__wbg_ptr==0)throw new Error("Attempt to use a moved value");let _=a.__wbindgen_add_to_stack_pointer(-16);w(this.__wbg_ptr);let d=re(t,a.__wbindgen_export),l=F,f=ar(e,a.__wbindgen_export),v=F,S=ar(n,a.__wbindgen_export),I=F;a.typstworker_render_canvas(_,this.__wbg_ptr,d,l,f,v,S,I);var i=b().getInt32(_+0,!0),o=b().getInt32(_+4,!0),s=b().getInt32(_+8,!0);if(s)throw P(o);return P(i)}finally{a.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(Ot.prototype[Symbol.dispose]=Ot.prototype.free);ft=class r{constructor(){throw new Error("cannot invoke `new` directly")}static __wrap(t){t=t>>>0;let e=Object.create(r.prototype);return e.__wbg_ptr=t,br.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,br.unregister(this),t}free(){let t=this.__destroy_into_raw();a.__wbg_workerbridge_free(t,0)}};Symbol.dispose&&(ft.prototype[Symbol.dispose]=ft.prototype.free);Wn=new Set(["basic","cors","default"]);vr=yr,xr=async function(r,t){throw new Error("Cannot import wasm module without importer: "+r+" "+t)}});var Mt={};rt(Mt,{CreateSessionOptions:()=>_t,IncrDomDocClient:()=>ct,PageInfo:()=>Y,PagesInfo:()=>ut,RenderPageImageOptions:()=>Q,RenderSession:()=>W,RenderSessionOptions:()=>Pt,TypstRenderer:()=>dt,TypstRendererBuilder:()=>Ft,TypstWorker:()=>Ot,WorkerBridge:()=>ft,default:()=>qn,initSync:()=>$n,renderer_build_info:()=>zn,setImportWasmModule:()=>Ce});var qn,Nn,Hn,ie=z(()=>{ne();ne();ne();qn=vr,Nn=async function(r,t){let e=new Function("m","return import(m)"),{readFileSync:n}=await e("fs"),i=new URL(r,t);return await n(i).buffer},Hn=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;Hn&&Ce(Nn)});var Ae={};rt(Ae,{RenderSession:()=>gt,TypstRendererDriver:()=>se,TypstWorker:()=>oe,createTypstRenderer:()=>ae,rendererBuildInfo:()=>kr});function ae(){return new se}async function kr(){return(await Promise.resolve().then(()=>(ie(),Mt))).renderer_build_info()}var gt,lt,oe,Vn,Sr,se,_e=z(()=>{It();Ze();ve();Kt();ir();gt=class{plugin;[x];constructor(t,e){this.plugin=t,this[x]=e}set backgroundColor(t){t!==void 0&&(this[x].background_color=t)}get backgroundColor(){return this[x].background_color}set pixelPerPt(t){t!==void 0&&(this[x].pixel_per_pt=t)}get pixelPerPt(){return this[x].pixel_per_pt}reset(){this.plugin.resetSession(this)}get doc_width(){return this[x].doc_width}get docWidth(){return this[x].doc_width}get doc_height(){return this[x].doc_height}get docHeight(){return this[x].doc_height}retrievePagesInfo(){let t=this[x].pages_info,e=[],n=t.page_count;for(let i=0;i<n;i++){let o=t.page(i);e.push({pageOffset:o.page_off,width:o.width_pt,height:o.height_pt})}return e}getSourceLoc(t){return this[x].source_span(t)}renderSvg(t){return this.plugin.renderSvg({renderSession:this,...t})}renderToSvg(t){return this.plugin.renderToSvg({renderSession:this,...t})}renderCanvas(t){return this.plugin.renderCanvas({renderSession:this,...t})}manipulateData(t){this.plugin.manipulateData({renderSession:this,...t})}renderSvgDiff(t){return this.plugin.renderSvgDiff({renderSession:this,...t})}get_source_loc(t){return this[x].source_span(t)}render_in_window(t,e,n,i){return this[x].render_in_window(t,e,n,i)}merge_delta(t){this.plugin.manipulateData({renderSession:this,action:"merge",data:t})}};(function(r){r[r.Delete=0]="Delete",r[r.New=1]="New",r[r.Update=2]="Update"})(lt||(lt={}));oe=class{plugin;[x];constructor(t,e){this.plugin=t,this[x]=e}manipulateData(t,e){return this[x].manipulate_data(t,e)}managedCanvasElemList=new Map;canvasCounter=Math.random();renderCanvas(t){let e=this.managedCanvasElemList;for(let[_,d]of e)d[0]=lt.Delete;for(let _ of t){let d=_.canvas,l=d.dataset.manageId,f=lt.Update;l||(l=this.canvasCounter.toFixed(5),this.canvasCounter+=1,d.dataset.manageId=l,f=lt.New);let v=e.get(l);if(v&&v[0]!==lt.Delete)throw new Error("cannot update a canvas for two times in batch");e.set(l,[f,{..._}])}let n=Array.from(e.entries()),i=new Uint8Array(n.length),o=new Array(n.length),s=n.map(([_,[d,l]],f)=>(d||e.delete(_),i[f]=d,o[f]=l.canvas,this.plugin.canvasOptionsToRust(l)));return this[x].render_canvas(i,o,s)}async retrievePagesInfo(){let t=await this[x].get_pages_info();console.log(t);let e=[],n=t.page_count;for(let i=0;i<n;i++){let o=t.page(i);e.push({pageOffset:o.page_off,width:o.width_pt,height:o.height_pt})}return e}},Vn=r=>new ot(async t=>await r.default(t));Sr=!0,se=class{renderer;rendererJs;constructor(){}async init(t){this.rendererJs=await(t?.getWrapper?.()||Promise.resolve().then(()=>(ie(),Mt)));let e=this.rendererJs.TypstRendererBuilder;this.renderer=await Xt(t,Vn(this.rendererJs),e,{})}loadGlyphPack(t){return Promise.resolve()}createOptionsToRust(t){let e=new this.rendererJs.CreateSessionOptions;return t.format!==void 0&&(e.format=t.format),t.artifactContent!==void 0&&(e.artifact_content=t.artifactContent),e}canvasOptionsToRust(t){let e=new this.rendererJs.RenderPageImageOptions;if(t.pageOffset===void 0)throw new Error("pageOffset is required in reflexo v0.5.0");if(e.page_off=t.pageOffset,t.cacheKey!==void 0&&(e.cache_key=t.cacheKey),t.backgroundColor!==void 0&&(e.background_color=t.backgroundColor),t.pixelPerPt!==void 0&&(e.pixel_per_pt=t.pixelPerPt),t.dataSelection!==void 0){let n=0;t.dataSelection.body?n|=1:t.canvas&&Sr&&(Sr=!1,console.warn("dataSelection.body is not set but providing canvas for body")),(t.dataSelection.text||t.dataSelection.annotation)&&console.error("dataSelection.text and dataSelection.annotation are deprecated"),t.dataSelection.semantics&&(n|=8),e.data_selection=n}return e}retrievePagesInfoFromSession(t){return t.retrievePagesInfo()}renderCanvas(t){return this.withinOptionSession(t,async e=>this.renderer.render_page_to_canvas(e[x],t.canvas||void 0,this.canvasOptionsToRust(t)))}async inAnimationFrame(t){return new Promise((e,n)=>{requestAnimationFrame(()=>{try{e(t())}catch(i){n(i)}})})}async renderDisplayLayer(t,e,n){let o=t[x].pages_info.page_count,s=async(f,v)=>{let I=e[f].getContext("2d");if(!I)throw new Error("canvas context is null");return await this.renderCanvas({...n,canvas:I,renderSession:t,pageOffset:v})},_=performance.now(),d=await(async()=>{let f=[];for(let v=0;v<o;v++)f.push(await this.inAnimationFrame(()=>s(v,v)));return f})(),l=performance.now();return console.log(`display layer used: render = ${(l-_).toFixed(1)}ms`),d}renderTextLayer(t,e){let n=performance.now();t.forEach((o,s)=>{o.innerHTML=e[s].htmlSemantics[0]});let i=performance.now();console.log(`text layer used: render = ${(i-n).toFixed(1)}ms`)}async render(t){if("format"in t&&t.format!=="vector"&&["serde_json","js","ir"].includes(t.format))throw new Error(`deprecated format ${t.format}, please use vector format`);return this.renderToCanvas(t)}async renderDom(t){if("format"in t&&t.format!=="vector"&&["serde_json","js","ir"].includes(t.format))throw new Error(`deprecated format ${t.format}, please use vector format`);return this.withinOptionSession(t,async e=>{let n=new Zt({...t,renderMode:"dom",hookedElem:t.container,kModule:e,renderer:this});return await n.impl.mountDom(t.pixelPerPt),n})}async renderToCanvas(t){let e,n,i=t.container;i.style.visibility="hidden";let o=async(s,_)=>{try{n=await this.renderDisplayLayer(e,s,t),_()}finally{i.style.visibility="visible"}};return this.withinOptionSession(t,async s=>{if(e=s,e[x].pages_info.page_count===0)throw new Error("No page found in session");if(t.pixelPerPt!==void 0&&t.pixelPerPt<=0)throw new Error("Invalid typst.RenderOptions.pixelPerPt, should be a positive number "+t.pixelPerPt);let _=t.backgroundColor;if(_!==void 0&&!/^#[0-9a-f]{6}$/.test(_))throw new Error("Invalid typst.backgroundColor color for matching ^#?[0-9a-f]{6}$ "+_);e.pixelPerPt=t.pixelPerPt??it.PIXEL_PER_PT,e.backgroundColor=_??"#ffffff";let d=performance.now(),l=new Gt(this.retrievePagesInfoFromSession(e),i,t),f=performance.now();console.log(`layer used: retrieve = ${(f-d).toFixed(1)}ms`),await o(l.canvasList,()=>l.resetLayout()),this.renderTextLayer(l.textLayerList,n)})}createModule(t){return Promise.resolve(new gt(this,this.renderer.create_session(t&&this.createOptionsToRust({format:"vector",artifactContent:t}))))}async createWorkerV0(t){return new oe(this,await this.renderer.create_worker(t))}workerBridge(){return this.renderer.create_worker_bridge()}renderSvg(t,e){if(t instanceof gt||e)throw new Error("removed api, please use renderToSvg({ renderSession, container }) instead");return this.withinOptionSession(t,async n=>{let i;return t.data_selection&&(i=0,t.data_selection.body&&(i|=1),t.data_selection.defs&&(i|=2),t.data_selection.css&&(i|=4),t.data_selection.js&&(i|=8)),Promise.resolve(this.renderer.svg_data(n[x],i))})}renderSvgDiff(t){return t.window?this.renderer.render_svg_diff(t.renderSession[x],t.window.lo.x,t.window.lo.y,t.window.hi.x,t.window.hi.y):this.renderer.render_svg_diff(t.renderSession[x],0,0,1e33,1e33)}renderToSvg(t){return this.withinOptionSession(t,async e=>Promise.resolve(this.renderer.render_svg(e[x],t.container)))}getCustomV1(t){return Promise.resolve(this.renderer.get_customs(t.renderSession[x]))}resetSession(t){return this.renderer.reset(t[x])}manipulateData(t){return this.renderer.manipulate_data(t.renderSession[x],t.action??"reset",t.data)}withinOptionSession(t,e){function n(i){return"artifactContent"in i}if("renderSession"in t)return e(t.renderSession);if(n(t))return this.runWithSession(t,e);throw new Error("Invalid render options, should be one of RenderByContentOptions|RenderBySessionOptions")}async runWithSession(t,e){let n=t,i=e;e||(n=void 0,i=t);let o=this.renderer.create_session(n&&this.createOptionsToRust(n));try{let s=await i(new gt(this,o));return o.free(),s}catch(s){throw o.free(),s}}}});function y(r){Dt===H.length&&H.push(H.length+1);let t=Dt;return Dt=H[t],H[t]=r,t}function Oe(r,t){if(!(r instanceof t))throw new Error(`expected instance of ${t.name}`)}function Me(r){let t=typeof r;if(t=="number"||t=="boolean"||r==null)return`${r}`;if(t=="string")return`"${r}"`;if(t=="symbol"){let i=r.description;return i==null?"Symbol":`Symbol(${i})`}if(t=="function"){let i=r.name;return typeof i=="string"&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(r)){let i=r.length,o="[";i>0&&(o+=Me(r[0]));for(let s=1;s<i;s++)o+=", "+Me(r[s]);return o+="]",o}let e=/\\[object ([^\\]]+)\\]/.exec(toString.call(r)),n;if(e&&e.length>1)n=e[1];else return toString.call(r);if(n=="Object")try{return"Object("+JSON.stringify(r)+")"}catch{return"Object"}return r instanceof Error?`${r.name}: ${r.message}\n${r.stack}`:n}function Gn(r){r<132||(H[r]=Dt,Dt=r)}function Xn(r,t){r=r>>>0;let e=p(),n=[];for(let i=r;i<r+4*t;i+=4)n.push(k(e.getUint32(i,!0)));return n}function Kn(r,t){return r=r>>>0,Yn().subarray(r/4,r/4+t)}function Te(r,t){return r=r>>>0,bt().subarray(r/1,r/1+t)}function p(){return(tt===null||tt.buffer.detached===!0||tt.buffer.detached===void 0&&tt.buffer!==c.memory.buffer)&&(tt=new DataView(c.memory.buffer)),tt}function $(r,t){return r=r>>>0,ti(r,t)}function Yn(){return(Tt===null||Tt.byteLength===0)&&(Tt=new Uint32Array(c.memory.buffer)),Tt}function bt(){return(Lt===null||Lt.byteLength===0)&&(Lt=new Uint8Array(c.memory.buffer)),Lt}function h(r){return H[r]}function pt(r,t){try{return r.apply(this,t)}catch(e){c.__wbindgen_export3(y(e))}}function M(r){return r==null}function Qn(r,t,e,n){let i={a:r,b:t,cnt:1,dtor:e},o=(...s)=>{i.cnt++;let _=i.a;i.a=0;try{return n(_,i.b,...s)}finally{i.a=_,o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{--i.cnt===0&&(i.dtor(i.a,i.b),i.a=0,Er.unregister(i))},Er.register(o,i,i),o}function Or(r,t){let e=t(r.length*1,1)>>>0;return bt().set(r,e/1),C=r.length,e}function ce(r,t){let e=t(r.length*4,4)>>>0,n=p();for(let i=0;i<r.length;i++)n.setUint32(e+4*i,y(r[i]),!0);return C=r.length,e}function O(r,t,e){if(e===void 0){let _=jt.encode(r),d=t(_.length,1)>>>0;return bt().subarray(d,d+_.length).set(_),C=_.length,d}let n=r.length,i=t(n,1)>>>0,o=bt(),s=0;for(;s<n;s++){let _=r.charCodeAt(s);if(_>127)break;o[i+s]=_}if(s!==n){s!==0&&(r=r.slice(s)),i=e(i,n,n=s+r.length*3,1)>>>0;let _=bt().subarray(i+s,i+n),d=jt.encodeInto(r,_);s+=d.written,i=e(i,n,s,1)>>>0}return C=s,i}function k(r){let t=h(r);return Gn(r),t}function ti(r,t){return Pe+=t,Pe>=Zn&&(ue=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),ue.decode(),Pe=t),ue.decode(bt().subarray(r,r+t))}function ei(r,t,e){c.__wasm_bindgen_func_elem_944(r,t,y(e))}function ri(r,t,e,n){c.__wasm_bindgen_func_elem_37348(r,t,y(e),y(n))}function ni(r){let t=c.get_font_info(y(r));return k(t)}async function oi(r,t){if(typeof Response=="function"&&r instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(r,t)}catch(n){if(r.ok&&ii.has(r.type)&&r.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n",n);else throw n}let e=await r.arrayBuffer();return await WebAssembly.instantiate(e,t)}else{let e=await WebAssembly.instantiate(r,t);return e instanceof WebAssembly.Instance?{instance:e,module:r}:e}}function Mr(){let r={};return r.wbg={},r.wbg.__wbg_Error_52673b7de5a0ca89=function(t,e){let n=Error($(t,e));return y(n)},r.wbg.__wbg_Number_2d1dcfcf4ec51736=function(t){return Number(h(t))},r.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d=function(t,e){let n=h(e),i=typeof n=="bigint"?n:void 0;p().setBigInt64(t+8,M(i)?BigInt(0):i,!0),p().setInt32(t+0,!M(i),!0)},r.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b=function(t){let e=h(t),n=typeof e=="boolean"?e:void 0;return M(n)?16777215:n?1:0},r.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6=function(t,e){let n=Me(h(e)),i=O(n,c.__wbindgen_export,c.__wbindgen_export2),o=C;p().setInt32(t+4,o,!0),p().setInt32(t+0,i,!0)},r.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317=function(t,e){return h(t)in h(e)},r.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27=function(t){return typeof h(t)=="bigint"},r.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd=function(t){return typeof h(t)=="function"},r.wbg.__wbg___wbindgen_is_object_ce774f3490692386=function(t){let e=h(t);return typeof e=="object"&&e!==null},r.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030=function(t){return typeof h(t)=="string"},r.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269=function(t){return h(t)===void 0},r.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36=function(t,e){return h(t)===h(e)},r.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d=function(t,e){return h(t)==h(e)},r.wbg.__wbg___wbindgen_number_get_9619185a74197f95=function(t,e){let n=h(e),i=typeof n=="number"?n:void 0;p().setFloat64(t+8,M(i)?0:i,!0),p().setInt32(t+0,!M(i),!0)},r.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42=function(t,e){let n=h(e),i=typeof n=="string"?n:void 0;var o=M(i)?0:O(i,c.__wbindgen_export,c.__wbindgen_export2),s=C;p().setInt32(t+4,s,!0),p().setInt32(t+0,o,!0)},r.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e=function(t,e){throw new Error($(t,e))},r.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7=function(t){h(t)._wbg_cb_unref()},r.wbg.__wbg_call_3020136f7a2d6e44=function(){return pt(function(t,e,n){let i=h(t).call(h(e),h(n));return y(i)},arguments)},r.wbg.__wbg_call_78f94eb02ec7f9b2=function(){return pt(function(t,e,n,i,o){let s=h(t).call(h(e),h(n),h(i),h(o));return y(s)},arguments)},r.wbg.__wbg_call_abb4ff46ce38be40=function(){return pt(function(t,e){let n=h(t).call(h(e));return y(n)},arguments)},r.wbg.__wbg_done_62ea16af4ce34b24=function(t){return h(t).done},r.wbg.__wbg_entries_83c79938054e065f=function(t){let e=Object.entries(h(t));return y(e)},r.wbg.__wbg_error_7534b8e9a36f1ab4=function(t,e){let n,i;try{n=t,i=e,console.error($(t,e))}finally{c.__wbindgen_export4(n,i,1)}},r.wbg.__wbg_error_85faeb8919b11cc6=function(t,e,n){console.error(h(t),h(e),h(n))},r.wbg.__wbg_getTimezoneOffset_45389e26d6f46823=function(t){return h(t).getTimezoneOffset()},r.wbg.__wbg_get_6b7bd52aca3f9671=function(t,e){let n=h(t)[e>>>0];return y(n)},r.wbg.__wbg_get_af9dab7e9603ea93=function(){return pt(function(t,e){let n=Reflect.get(h(t),h(e));return y(n)},arguments)},r.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe=function(t,e){let n=h(t)[h(e)];return y(n)},r.wbg.__wbg_info_ce6bcc489c22f6f0=function(t){console.info(h(t))},r.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355=function(t){let e;try{e=h(t)instanceof ArrayBuffer}catch{e=!1}return e},r.wbg.__wbg_instanceof_Map_084be8da74364158=function(t){let e;try{e=h(t)instanceof Map}catch{e=!1}return e},r.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434=function(t){let e;try{e=h(t)instanceof Uint8Array}catch{e=!1}return e},r.wbg.__wbg_isArray_51fd9e6422c0a395=function(t){return Array.isArray(h(t))},r.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16=function(t){return Number.isSafeInteger(h(t))},r.wbg.__wbg_iterator_27b7c8b35ab3e86b=function(){return y(Symbol.iterator)},r.wbg.__wbg_length_22ac23eaec9d8053=function(t){return h(t).length},r.wbg.__wbg_length_d45040a40c570362=function(t){return h(t).length},r.wbg.__wbg_new_1ba21ce319a06297=function(){let t=new Object;return y(t)},r.wbg.__wbg_new_25f239778d6112b9=function(){let t=new Array;return y(t)},r.wbg.__wbg_new_6421f6084cc5bc5a=function(t){let e=new Uint8Array(h(t));return y(e)},r.wbg.__wbg_new_8a6f238a6ece86ea=function(){let t=new Error;return y(t)},r.wbg.__wbg_new_b2db8aa2650f793a=function(t){let e=new Date(h(t));return y(e)},r.wbg.__wbg_new_df1173567d5ff028=function(t,e){let n=new Error($(t,e));return y(n)},r.wbg.__wbg_new_ff12d2b041fb48f1=function(t,e){try{var n={a:t,b:e},i=(s,_)=>{let d=n.a;n.a=0;try{return ri(d,n.b,s,_)}finally{n.a=d}};let o=new Promise(i);return y(o)}finally{n.a=n.b=0}},r.wbg.__wbg_new_from_slice_db0691b69e9d3891=function(t,e){let n=new Uint32Array(Kn(t,e));return y(n)},r.wbg.__wbg_new_from_slice_f9c22b9153b26992=function(t,e){let n=new Uint8Array(Te(t,e));return y(n)},r.wbg.__wbg_new_no_args_cb138f77cf6151ee=function(t,e){let n=new Function($(t,e));return y(n)},r.wbg.__wbg_new_with_args_df9e7125ffe55248=function(t,e,n,i){let o=new Function($(t,e),$(n,i));return y(o)},r.wbg.__wbg_next_138a17bbf04e926c=function(t){let e=h(t).next;return y(e)},r.wbg.__wbg_next_3cfe5c0fe2a4cc53=function(){return pt(function(t){let e=h(t).next();return y(e)},arguments)},r.wbg.__wbg_now_69d776cd24f5215b=function(){return Date.now()},r.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd=function(t,e,n){Uint8Array.prototype.set.call(Te(t,e),h(n))},r.wbg.__wbg_proxycontext_new=function(t){let e=ht.__wrap(t);return y(e)},r.wbg.__wbg_push_7d9be8f38fc13975=function(t,e){return h(t).push(h(e))},r.wbg.__wbg_queueMicrotask_9b549dfce8865860=function(t){let e=h(t).queueMicrotask;return y(e)},r.wbg.__wbg_queueMicrotask_fca69f5bfad613a5=function(t){queueMicrotask(h(t))},r.wbg.__wbg_resolve_fd5bfbaa4ce36e1e=function(t){let e=Promise.resolve(h(t));return y(e)},r.wbg.__wbg_set_3f1d0b984ed272ed=function(t,e,n){h(t)[k(e)]=k(n)},r.wbg.__wbg_set_781438a03c0c3c81=function(){return pt(function(t,e,n){return Reflect.set(h(t),h(e),h(n))},arguments)},r.wbg.__wbg_set_7df433eea03a5c14=function(t,e,n){h(t)[e>>>0]=k(n)},r.wbg.__wbg_stack_0ed75d68575b0f3c=function(t,e){let n=h(e).stack,i=O(n,c.__wbindgen_export,c.__wbindgen_export2),o=C;p().setInt32(t+4,o,!0),p().setInt32(t+0,i,!0)},r.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335=function(){let t=typeof global>"u"?null:global;return M(t)?0:y(t)},r.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1=function(){let t=typeof globalThis>"u"?null:globalThis;return M(t)?0:y(t)},r.wbg.__wbg_static_accessor_SELF_08f5a74c69739274=function(){let t=typeof self>"u"?null:self;return M(t)?0:y(t)},r.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024=function(){let t=typeof window>"u"?null:window;return M(t)?0:y(t)},r.wbg.__wbg_then_4f95312d68691235=function(t,e){let n=h(t).then(h(e));return y(n)},r.wbg.__wbg_typstcompiler_new=function(t){let e=yt.__wrap(t);return y(e)},r.wbg.__wbg_typstfontresolver_new=function(t){let e=et.__wrap(t);return y(e)},r.wbg.__wbg_value_57b7b035e117f7ee=function(t){let e=h(t).value;return y(e)},r.wbg.__wbindgen_cast_2241b6af4c4b2941=function(t,e){let n=$(t,e);return y(n)},r.wbg.__wbindgen_cast_3334ea73b4b28ba3=function(t,e){let n=Qn(t,e,c.__wasm_bindgen_func_elem_957,ei);return y(n)},r.wbg.__wbindgen_cast_4625c577ab2ec9ee=function(t){let e=BigInt.asUintN(64,t);return y(e)},r.wbg.__wbindgen_cast_9ae0607507abb057=function(t){return y(t)},r.wbg.__wbindgen_cast_d6cd19b81560fd6e=function(t){return y(t)},r.wbg.__wbindgen_object_clone_ref=function(t){let e=h(t);return y(e)},r.wbg.__wbindgen_object_drop_ref=function(t){k(t)},r}function Tr(r,t){return c=r.exports,Lr.__wbindgen_wasm_module=t,tt=null,Tt=null,Lt=null,c}function si(r){if(c!==void 0)return c;typeof r<"u"&&(Object.getPrototypeOf(r)===Object.prototype?{module:r}=r:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=Mr();r instanceof WebAssembly.Module||(r=new WebAssembly.Module(r));let e=new WebAssembly.Instance(r,t);return Tr(e,r)}async function Lr(r){if(c!==void 0)return c;typeof r<"u"&&(Object.getPrototypeOf(r)===Object.prototype?{module_or_path:r}=r:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof r>"u"&&(r=jr("typst_ts_web_compiler_bg.wasm",ai.url));let t=Mr();(typeof r=="string"||typeof Request=="function"&&r instanceof Request||typeof URL=="function"&&r instanceof URL)&&(r=fetch(r));let{instance:e,module:n}=await oi(await r,t);return Tr(e,n)}function Le(r){jr=r}var ai,c,Er,tt,Tt,Lt,H,Dt,ue,Zn,Pe,jt,C,Ir,Fe,Rr,Cr,Ar,Pr,Fr,J,ht,mt,yt,zt,et,Wt,ii,Dr,jr,de=z(()=>{ai={};Er=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>r.dtor(r.a,r.b));tt=null;Tt=null;Lt=null;H=new Array(128).fill(void 0);H.push(void 0,null,!0,!1);Dt=H.length;ue=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});ue.decode();Zn=2146435072,Pe=0;jt=new TextEncoder;"encodeInto"in jt||(jt.encodeInto=function(r,t){let e=jt.encode(r);return t.set(e),{read:r.length,written:e.length}});C=0;Ir=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>c.__wbg_incrserver_free(r>>>0,1)),Fe=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>c.__wbg_proxycontext_free(r>>>0,1)),Rr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>c.__wbg_typstcompileworld_free(r>>>0,1)),Cr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>c.__wbg_typstcompiler_free(r>>>0,1)),Ar=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>c.__wbg_typstcompilerbuilder_free(r>>>0,1)),Pr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>c.__wbg_typstfontresolver_free(r>>>0,1)),Fr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>c.__wbg_typstfontresolverbuilder_free(r>>>0,1)),J=class r{static __wrap(t){t=t>>>0;let e=Object.create(r.prototype);return e.__wbg_ptr=t,Ir.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Ir.unregister(this),t}free(){let t=this.__destroy_into_raw();c.__wbg_incrserver_free(t,0)}set_attach_debug_info(t){c.incrserver_set_attach_debug_info(this.__wbg_ptr,t)}current(){try{let n=c.__wbindgen_add_to_stack_pointer(-16);c.incrserver_current(n,this.__wbg_ptr);var t=p().getInt32(n+0,!0),e=p().getInt32(n+4,!0);let i;return t!==0&&(i=Te(t,e).slice(),c.__wbindgen_export4(t,e*1,1)),i}finally{c.__wbindgen_add_to_stack_pointer(16)}}reset(){c.incrserver_reset(this.__wbg_ptr)}};Symbol.dispose&&(J.prototype[Symbol.dispose]=J.prototype.free);ht=class r{static __wrap(t){t=t>>>0;let e=Object.create(r.prototype);return e.__wbg_ptr=t,Fe.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Fe.unregister(this),t}free(){let t=this.__destroy_into_raw();c.__wbg_proxycontext_free(t,0)}constructor(t){let e=c.proxycontext_new(y(t));return this.__wbg_ptr=e>>>0,Fe.register(this,this.__wbg_ptr,this),this}get context(){let t=c.proxycontext_context(this.__wbg_ptr);return k(t)}untar(t,e){try{let o=c.__wbindgen_add_to_stack_pointer(-16),s=Or(t,c.__wbindgen_export),_=C;c.proxycontext_untar(o,this.__wbg_ptr,s,_,y(e));var n=p().getInt32(o+0,!0),i=p().getInt32(o+4,!0);if(i)throw k(n)}finally{c.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(ht.prototype[Symbol.dispose]=ht.prototype.free);mt=class r{static __wrap(t){t=t>>>0;let e=Object.create(r.prototype);return e.__wbg_ptr=t,Rr.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Rr.unregister(this),t}free(){let t=this.__destroy_into_raw();c.__wbg_typstcompileworld_free(t,0)}compile(t,e){try{let s=c.__wbindgen_add_to_stack_pointer(-16);c.typstcompileworld_compile(s,this.__wbg_ptr,t,e);var n=p().getInt32(s+0,!0),i=p().getInt32(s+4,!0),o=p().getInt32(s+8,!0);if(o)throw k(i);return k(n)}finally{c.__wbindgen_add_to_stack_pointer(16)}}title(t){try{let s=c.__wbindgen_add_to_stack_pointer(-16);c.typstcompileworld_title(s,this.__wbg_ptr,t);var e=p().getInt32(s+0,!0),n=p().getInt32(s+4,!0),i=p().getInt32(s+8,!0),o=p().getInt32(s+12,!0);if(o)throw k(i);let _;return e!==0&&(_=$(e,n).slice(),c.__wbindgen_export4(e,n*1,1)),_}finally{c.__wbindgen_add_to_stack_pointer(16)}}get_artifact(t,e){try{let s=c.__wbindgen_add_to_stack_pointer(-16);c.typstcompileworld_get_artifact(s,this.__wbg_ptr,t,e);var n=p().getInt32(s+0,!0),i=p().getInt32(s+4,!0),o=p().getInt32(s+8,!0);if(o)throw k(i);return k(n)}finally{c.__wbindgen_add_to_stack_pointer(16)}}query(t,e,n){let i,o;try{let B=c.__wbindgen_add_to_stack_pointer(-16),j=O(e,c.__wbindgen_export,c.__wbindgen_export2),T=C;var s=M(n)?0:O(n,c.__wbindgen_export,c.__wbindgen_export2),_=C;c.typstcompileworld_query(B,this.__wbg_ptr,t,j,T,s,_);var d=p().getInt32(B+0,!0),l=p().getInt32(B+4,!0),f=p().getInt32(B+8,!0),v=p().getInt32(B+12,!0),S=d,I=l;if(v)throw S=0,I=0,k(f);return i=S,o=I,$(S,I)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export4(i,o,1)}}incr_compile(t,e){try{let s=c.__wbindgen_add_to_stack_pointer(-16);Oe(t,J),c.typstcompileworld_incr_compile(s,this.__wbg_ptr,t.__wbg_ptr,e);var n=p().getInt32(s+0,!0),i=p().getInt32(s+4,!0),o=p().getInt32(s+8,!0);if(o)throw k(i);return k(n)}finally{c.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(mt.prototype[Symbol.dispose]=mt.prototype.free);yt=class r{static __wrap(t){t=t>>>0;let e=Object.create(r.prototype);return e.__wbg_ptr=t,Cr.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Cr.unregister(this),t}free(){let t=this.__destroy_into_raw();c.__wbg_typstcompiler_free(t,0)}reset(){try{let n=c.__wbindgen_add_to_stack_pointer(-16);c.typstcompiler_reset(n,this.__wbg_ptr);var t=p().getInt32(n+0,!0),e=p().getInt32(n+4,!0);if(e)throw k(t)}finally{c.__wbindgen_add_to_stack_pointer(16)}}set_fonts(t){try{let i=c.__wbindgen_add_to_stack_pointer(-16);Oe(t,et),c.typstcompiler_set_fonts(i,this.__wbg_ptr,t.__wbg_ptr);var e=p().getInt32(i+0,!0),n=p().getInt32(i+4,!0);if(n)throw k(e)}finally{c.__wbindgen_add_to_stack_pointer(16)}}set_inputs(t){try{let i=c.__wbindgen_add_to_stack_pointer(-16);c.typstcompiler_set_inputs(i,this.__wbg_ptr,y(t));var e=p().getInt32(i+0,!0),n=p().getInt32(i+4,!0);if(n)throw k(e)}finally{c.__wbindgen_add_to_stack_pointer(16)}}add_source(t,e){let n=O(t,c.__wbindgen_export,c.__wbindgen_export2),i=C,o=O(e,c.__wbindgen_export,c.__wbindgen_export2),s=C;return c.typstcompiler_add_source(this.__wbg_ptr,n,i,o,s)!==0}map_shadow(t,e){let n=O(t,c.__wbindgen_export,c.__wbindgen_export2),i=C,o=Or(e,c.__wbindgen_export),s=C;return c.typstcompiler_map_shadow(this.__wbg_ptr,n,i,o,s)!==0}unmap_shadow(t){let e=O(t,c.__wbindgen_export,c.__wbindgen_export2),n=C;return c.typstcompiler_unmap_shadow(this.__wbg_ptr,e,n)!==0}reset_shadow(){c.typstcompiler_reset_shadow(this.__wbg_ptr)}get_loaded_fonts(){try{let i=c.__wbindgen_add_to_stack_pointer(-16);c.typstcompiler_get_loaded_fonts(i,this.__wbg_ptr);var t=p().getInt32(i+0,!0),e=p().getInt32(i+4,!0),n=Xn(t,e).slice();return c.__wbindgen_export4(t,e*4,4),n}finally{c.__wbindgen_add_to_stack_pointer(16)}}get_ast(t){let e,n;try{let f=c.__wbindgen_add_to_stack_pointer(-16),v=O(t,c.__wbindgen_export,c.__wbindgen_export2),S=C;c.typstcompiler_get_ast(f,this.__wbg_ptr,v,S);var i=p().getInt32(f+0,!0),o=p().getInt32(f+4,!0),s=p().getInt32(f+8,!0),_=p().getInt32(f+12,!0),d=i,l=o;if(_)throw d=0,l=0,k(s);return e=d,n=l,$(d,l)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export4(e,n,1)}}get_semantic_token_legend(){try{let i=c.__wbindgen_add_to_stack_pointer(-16);c.typstcompiler_get_semantic_token_legend(i,this.__wbg_ptr);var t=p().getInt32(i+0,!0),e=p().getInt32(i+4,!0),n=p().getInt32(i+8,!0);if(n)throw k(e);return k(t)}finally{c.__wbindgen_add_to_stack_pointer(16)}}get_semantic_tokens(t,e,n){try{let v=c.__wbindgen_add_to_stack_pointer(-16),S=O(t,c.__wbindgen_export,c.__wbindgen_export2),I=C;var i=M(e)?0:O(e,c.__wbindgen_export,c.__wbindgen_export2),o=C,s=M(n)?0:O(n,c.__wbindgen_export,c.__wbindgen_export2),_=C;c.typstcompiler_get_semantic_tokens(v,this.__wbg_ptr,S,I,i,o,s,_);var d=p().getInt32(v+0,!0),l=p().getInt32(v+4,!0),f=p().getInt32(v+8,!0);if(f)throw k(l);return k(d)}finally{c.__wbindgen_add_to_stack_pointer(16)}}snapshot(t,e,n){try{let I=c.__wbindgen_add_to_stack_pointer(-16);var i=M(t)?0:O(t,c.__wbindgen_export,c.__wbindgen_export2),o=C,s=M(e)?0:O(e,c.__wbindgen_export,c.__wbindgen_export2),_=C,d=M(n)?0:ce(n,c.__wbindgen_export),l=C;c.typstcompiler_snapshot(I,this.__wbg_ptr,i,o,s,_,d,l);var f=p().getInt32(I+0,!0),v=p().getInt32(I+4,!0),S=p().getInt32(I+8,!0);if(S)throw k(v);return mt.__wrap(f)}finally{c.__wbindgen_add_to_stack_pointer(16)}}get_artifact(t,e){try{let s=c.__wbindgen_add_to_stack_pointer(-16),_=O(t,c.__wbindgen_export,c.__wbindgen_export2),d=C;c.typstcompiler_get_artifact(s,this.__wbg_ptr,_,d,e);var n=p().getInt32(s+0,!0),i=p().getInt32(s+4,!0),o=p().getInt32(s+8,!0);if(o)throw k(i);return k(n)}finally{c.__wbindgen_add_to_stack_pointer(16)}}compile(t,e,n,i){try{let S=c.__wbindgen_add_to_stack_pointer(-16);var o=M(t)?0:O(t,c.__wbindgen_export,c.__wbindgen_export2),s=C,_=M(e)?0:ce(e,c.__wbindgen_export),d=C;let I=O(n,c.__wbindgen_export,c.__wbindgen_export2),B=C;c.typstcompiler_compile(S,this.__wbg_ptr,o,s,_,d,I,B,i);var l=p().getInt32(S+0,!0),f=p().getInt32(S+4,!0),v=p().getInt32(S+8,!0);if(v)throw k(f);return k(l)}finally{c.__wbindgen_add_to_stack_pointer(16)}}query(t,e,n,i){let o,s;try{let kt=c.__wbindgen_add_to_stack_pointer(-16),Zr=O(t,c.__wbindgen_export,c.__wbindgen_export2),tn=C;var _=M(e)?0:ce(e,c.__wbindgen_export),d=C;let en=O(n,c.__wbindgen_export,c.__wbindgen_export2),rn=C;var l=M(i)?0:O(i,c.__wbindgen_export,c.__wbindgen_export2),f=C;c.typstcompiler_query(kt,this.__wbg_ptr,Zr,tn,_,d,en,rn,l,f);var v=p().getInt32(kt+0,!0),S=p().getInt32(kt+4,!0),I=p().getInt32(kt+8,!0),B=p().getInt32(kt+12,!0),j=v,T=S;if(B)throw j=0,T=0,k(I);return o=j,s=T,$(j,T)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export4(o,s,1)}}create_incr_server(){try{let i=c.__wbindgen_add_to_stack_pointer(-16);c.typstcompiler_create_incr_server(i,this.__wbg_ptr);var t=p().getInt32(i+0,!0),e=p().getInt32(i+4,!0),n=p().getInt32(i+8,!0);if(n)throw k(e);return J.__wrap(t)}finally{c.__wbindgen_add_to_stack_pointer(16)}}incr_compile(t,e,n,i){try{let f=c.__wbindgen_add_to_stack_pointer(-16),v=O(t,c.__wbindgen_export,c.__wbindgen_export2),S=C;var o=M(e)?0:ce(e,c.__wbindgen_export),s=C;Oe(n,J),c.typstcompiler_incr_compile(f,this.__wbg_ptr,v,S,o,s,n.__wbg_ptr,i);var _=p().getInt32(f+0,!0),d=p().getInt32(f+4,!0),l=p().getInt32(f+8,!0);if(l)throw k(d);return k(_)}finally{c.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(yt.prototype[Symbol.dispose]=yt.prototype.free);zt=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Ar.unregister(this),t}free(){let t=this.__destroy_into_raw();c.__wbg_typstcompilerbuilder_free(t,0)}constructor(){try{let i=c.__wbindgen_add_to_stack_pointer(-16);c.typstcompilerbuilder_new(i);var t=p().getInt32(i+0,!0),e=p().getInt32(i+4,!0),n=p().getInt32(i+8,!0);if(n)throw k(e);return this.__wbg_ptr=t>>>0,Ar.register(this,this.__wbg_ptr,this),this}finally{c.__wbindgen_add_to_stack_pointer(16)}}set_dummy_access_model(){try{let n=c.__wbindgen_add_to_stack_pointer(-16);c.typstcompilerbuilder_set_dummy_access_model(n,this.__wbg_ptr);var t=p().getInt32(n+0,!0),e=p().getInt32(n+4,!0);if(e)throw k(t)}finally{c.__wbindgen_add_to_stack_pointer(16)}}set_access_model(t,e,n,i,o){let s=c.typstcompilerbuilder_set_access_model(this.__wbg_ptr,y(t),y(e),y(n),y(i),y(o));return k(s)}set_package_registry(t,e){let n=c.typstcompilerbuilder_set_package_registry(this.__wbg_ptr,y(t),y(e));return k(n)}add_raw_font(t){let e=c.typstcompilerbuilder_add_raw_font(this.__wbg_ptr,y(t));return k(e)}add_lazy_font(t,e){let n=c.typstcompilerbuilder_add_lazy_font(this.__wbg_ptr,y(t),y(e));return k(n)}build(){let t=this.__destroy_into_raw(),e=c.typstcompilerbuilder_build(t);return k(e)}};Symbol.dispose&&(zt.prototype[Symbol.dispose]=zt.prototype.free);et=class r{static __wrap(t){t=t>>>0;let e=Object.create(r.prototype);return e.__wbg_ptr=t,Pr.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Pr.unregister(this),t}free(){let t=this.__destroy_into_raw();c.__wbg_typstfontresolver_free(t,0)}};Symbol.dispose&&(et.prototype[Symbol.dispose]=et.prototype.free);Wt=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Fr.unregister(this),t}free(){let t=this.__destroy_into_raw();c.__wbg_typstfontresolverbuilder_free(t,0)}constructor(){try{let i=c.__wbindgen_add_to_stack_pointer(-16);c.typstfontresolverbuilder_new(i);var t=p().getInt32(i+0,!0),e=p().getInt32(i+4,!0),n=p().getInt32(i+8,!0);if(n)throw k(e);return this.__wbg_ptr=t>>>0,Fr.register(this,this.__wbg_ptr,this),this}finally{c.__wbindgen_add_to_stack_pointer(16)}}get_font_info(t){try{let o=c.__wbindgen_add_to_stack_pointer(-16);c.typstfontresolverbuilder_get_font_info(o,this.__wbg_ptr,y(t));var e=p().getInt32(o+0,!0),n=p().getInt32(o+4,!0),i=p().getInt32(o+8,!0);if(i)throw k(n);return k(e)}finally{c.__wbindgen_add_to_stack_pointer(16)}}add_raw_font(t){try{let i=c.__wbindgen_add_to_stack_pointer(-16);c.typstfontresolverbuilder_add_raw_font(i,this.__wbg_ptr,y(t));var e=p().getInt32(i+0,!0),n=p().getInt32(i+4,!0);if(n)throw k(e)}finally{c.__wbindgen_add_to_stack_pointer(16)}}add_lazy_font(t,e){try{let o=c.__wbindgen_add_to_stack_pointer(-16);c.typstfontresolverbuilder_add_lazy_font(o,this.__wbg_ptr,y(t),y(e));var n=p().getInt32(o+0,!0),i=p().getInt32(o+4,!0);if(i)throw k(n)}finally{c.__wbindgen_add_to_stack_pointer(16)}}build(){let t=this.__destroy_into_raw(),e=c.typstfontresolverbuilder_build(t);return k(e)}};Symbol.dispose&&(Wt.prototype[Symbol.dispose]=Wt.prototype.free);ii=new Set(["basic","cors","default"]);Dr=Lr,jr=async function(r,t){throw new Error("Cannot import wasm module without importer: "+r+" "+t)}});var De={};rt(De,{IncrServer:()=>J,ProxyContext:()=>ht,TypstCompileWorld:()=>mt,TypstCompiler:()=>yt,TypstCompilerBuilder:()=>zt,TypstFontResolver:()=>et,TypstFontResolverBuilder:()=>Wt,default:()=>_i,get_font_info:()=>ni,initSync:()=>si,setImportWasmModule:()=>Le});var _i,ci,ui,je=z(()=>{de();de();de();_i=Dr,ci=async function(r,t){let e=new Function("m","return import(m)"),{readFileSync:n}=await e("fs"),i=new URL(r,t);return await n(i).buffer},ui=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;ui&&Le(ci)});var pe={};rt(pe,{CompileFormatEnum:()=>xt,IncrementalServer:()=>fe,TypstFontBuilderDriver:()=>ge,TypstWorld:()=>le,createTypstCompiler:()=>ze,createTypstFontBuilder:()=>Br});function Br(){return new ge}function ze(){return new we}function Wr(r){return r?Object.entries(r):void 0}function vt(r){switch(r){case"none":return 1;case"unix":return 2;default:return 3}}var xt,fe,zr,le,$r,ge,we,St=z(()=>{Kt();It();Et();ve();(function(r){r[r.vector=0]="vector",r[r.pdf=1]="pdf",r[r._dummy=2]="_dummy"})(xt||(xt={}));fe=class{[x];constructor(t){this[x]=t}reset(){this[x].reset()}current(){return this[x].current()}setAttachDebugInfo(t){this[x].set_attach_debug_info(t)}};zr||(zr={});le=class{[x];constructor(t){this[x]=t}compile(t){return this[x].compile(0,vt(t?.diagnostics))}compileHtml(t){return this[x].compile(1,vt(t?.diagnostics))}async query(t){return JSON.parse(this[x].query(0,t.selector,t.field))}title(){return this[x].title(0)}vector(t){return this[x].get_artifact(0,vt(t?.diagnostics))||{}}pdf(t){return this[x].get_artifact(1,vt(t?.diagnostics))||{}}},$r=r=>new ot(async t=>await r.default(t));ge=class{fontBuilderJs;fontBuilder;async init(t){this.fontBuilderJs=await(t?.getWrapper?.()||Promise.resolve().then(()=>(je(),De))),await $r(this.fontBuilderJs).init(t?.getModule?.()),this.fontBuilder=new this.fontBuilderJs.TypstFontResolverBuilder}async getFontInfo(t){return this.fontBuilder.get_font_info(t)}async addFontData(t){this.fontBuilder.add_raw_font(t)}async addLazyFont(t,e){return this.fontBuilder.add_lazy_font(t,e)}async build(t){let e=await this.fontBuilder.build(),n=await t(e);return e.free(),n}},we=class r{compiler;compilerJs;static defaultAssets=["text"];constructor(){}async init(t){this.compilerJs=await(t?.getWrapper?.()||Promise.resolve().then(()=>(je(),De)));let e=this.compilerJs.TypstCompilerBuilder,n={...t||{}},i=n.beforeBuild??=[],o=i.some(l=>l._preloadRemoteFontOptions!==void 0),s=i.some(l=>l._preloadRemoteFontOptions?.assets!==void 0),_=i.some(l=>l._preloadRemoteFontOptions?.assets===!1);if((!o||!s&&!_)&&i.push(X([],{assets:r.defaultAssets})),!i.some(l=>l._kind==="fontLoader"))throw new Error("TypstCompiler: no font loader found, please use font loaders, e.g. loadFonts or preloadSystemFonts");this.compiler=await Xt(t,$r(this.compilerJs),e,{})}setFonts(t){this.compiler.set_fonts(t)}compile(t){return new Promise(e=>{let n=this.compiler.snapshot(t.root,t.mainFilePath,Wr(t.inputs));if("incrementalServer"in t){e(n.incr_compile(t.incrementalServer[x],vt(t.diagnostics)));return}e(n.get_artifact(t.format||xt.vector,vt(t.diagnostics)))})}async runWithWorld(t,e){let n=this.compiler.snapshot(t.root,t.mainFilePath,Wr(t.inputs)),i=await e(new le(n));return n.free(),i}query(t){return this.runWithWorld(t,async e=>JSON.parse(await e.query(t)))}getSemanticTokenLegend(){return new Promise(t=>{t(this.compiler.get_semantic_token_legend())})}getSemanticTokens(t){return new Promise(e=>{this.compiler.reset(),e(this.compiler.get_semantic_tokens(t.offsetEncoding||"utf-16",t.mainFilePath,t.resultId))})}async withIncrementalServer(t){let e=new fe(this.compiler.create_incr_server());try{return await t(e)}finally{e[x].free()}}async getAst(t){return this.compiler.get_ast(t)}async reset(){await new Promise(t=>{this.compiler.reset(),t(void 0)})}addSource(t,e){if(arguments.length>2)throw new Error("use of addSource(path, source, isMain) is deprecated, please use addSource(path, source) instead");this.compiler.add_source(t,e)}mapShadow(t,e){this.compiler.map_shadow(t,e)}unmapShadow(t){this.compiler.unmap_shadow(t)}resetShadow(){this.compiler.reset_shadow()}renderPageToCanvas(){throw new Error("Please use the api TypstRenderer.renderToCanvas in v0.4.0")}};ze._impl=we});var Vr={};rt(Vr,{createGlobalCompiler:()=>Hr,getGlobalCompiler:()=>Nr,withGlobalCompiler:()=>di});function Nr(){return qr?Be:void 0}function Hr(r,t){let e=Be||r();return We!==void 0?We:We=(async()=>(qr=!0,await e.init(t),Be=e))()}function di(r,t,e,n){let i=Nr();if(i){e(i);return}Hr(r,t).then(e).catch(n)}var Be,We,qr,Jr=z(()=>{qr=!1});var Yr={};rt(Yr,{createGlobalRenderer:()=>Kr,getGlobalRenderer:()=>Xr,withGlobalRenderer:()=>fi});function Xr(){return Gr?Ue:void 0}function Kr(r,t){let e=Ue||r();return $e!==void 0?$e:$e=(async()=>(Gr=!0,await e.init(t),Ue=e))()}function fi(r,t,e,n){let i=Xr();if(i){e(i);return}Kr(r,t).then(e).catch(n)}var Ue,$e,Gr,Qr=z(()=>{Gr=!1});var He=Symbol("Comlink.proxy"),on=Symbol("Comlink.endpoint"),sn=Symbol("Comlink.releaseProxy"),he=Symbol("Comlink.finalizer"),Ut=Symbol("Comlink.thrown"),Ve=r=>typeof r=="object"&&r!==null||typeof r=="function",an={canHandle:r=>Ve(r)&&r[He],serialize(r){let{port1:t,port2:e}=new MessageChannel;return Vt(r,t),[e,[e]]},deserialize(r){return r.start(),dn(r)}},_n={canHandle:r=>Ve(r)&&Ut in r,serialize({value:r}){let t;return r instanceof Error?t={isError:!0,value:{message:r.message,name:r.name,stack:r.stack}}:t={isError:!1,value:r},[t,[]]},deserialize(r){throw r.isError?Object.assign(new Error(r.value.message),r.value):r.value}},Je=new Map([["proxy",an],["throw",_n]]);function cn(r,t){for(let e of r)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function Vt(r,t=globalThis,e=["*"]){t.addEventListener("message",function n(i){if(!i||!i.data)return;if(!cn(e,i.origin)){console.warn(`Invalid origin \'${i.origin}\' for comlink proxy`);return}let{id:o,type:s,path:_}=Object.assign({path:[]},i.data),d=(i.data.argumentList||[]).map(G),l;try{let f=_.slice(0,-1).reduce((S,I)=>S[I],r),v=_.reduce((S,I)=>S[I],r);switch(s){case"GET":l=v;break;case"SET":f[_.slice(-1)[0]]=G(i.data.value),l=!0;break;case"APPLY":l=v.apply(f,d);break;case"CONSTRUCT":{let S=new v(...d);l=pn(S)}break;case"ENDPOINT":{let{port1:S,port2:I}=new MessageChannel;Vt(r,I),l=wn(S,[S])}break;case"RELEASE":l=void 0;break;default:return}}catch(f){l={value:f,[Ut]:0}}Promise.resolve(l).catch(f=>({value:f,[Ut]:0})).then(f=>{let[v,S]=Ht(f);t.postMessage(Object.assign(Object.assign({},v),{id:o}),S),s==="RELEASE"&&(t.removeEventListener("message",n),Ge(t),he in r&&typeof r[he]=="function"&&r[he]())}).catch(f=>{let[v,S]=Ht({value:new TypeError("Unserializable return value"),[Ut]:0});t.postMessage(Object.assign(Object.assign({},v),{id:o}),S)})}),t.start&&t.start()}function un(r){return r.constructor.name==="MessagePort"}function Ge(r){un(r)&&r.close()}function dn(r,t){let e=new Map;return r.addEventListener("message",function(i){let{data:o}=i;if(!o||!o.id)return;let s=e.get(o.id);if(s)try{s(o)}finally{e.delete(o.id)}}),me(r,e,[],t)}function $t(r){if(r)throw new Error("Proxy has been released and is not useable")}function Xe(r){return nt(r,new Map,{type:"RELEASE"}).then(()=>{Ge(r)})}var qt=new WeakMap,Nt="FinalizationRegistry"in globalThis&&new FinalizationRegistry(r=>{let t=(qt.get(r)||0)-1;qt.set(r,t),t===0&&Xe(r)});function fn(r,t){let e=(qt.get(t)||0)+1;qt.set(t,e),Nt&&Nt.register(r,t,r)}function ln(r){Nt&&Nt.unregister(r)}function me(r,t,e=[],n=function(){}){let i=!1,o=new Proxy(n,{get(s,_){if($t(i),_===sn)return()=>{ln(o),Xe(r),t.clear(),i=!0};if(_==="then"){if(e.length===0)return{then:()=>o};let d=nt(r,t,{type:"GET",path:e.map(l=>l.toString())}).then(G);return d.then.bind(d)}return me(r,t,[...e,_])},set(s,_,d){$t(i);let[l,f]=Ht(d);return nt(r,t,{type:"SET",path:[...e,_].map(v=>v.toString()),value:l},f).then(G)},apply(s,_,d){$t(i);let l=e[e.length-1];if(l===on)return nt(r,t,{type:"ENDPOINT"}).then(G);if(l==="bind")return me(r,t,e.slice(0,-1));let[f,v]=Ne(d);return nt(r,t,{type:"APPLY",path:e.map(S=>S.toString()),argumentList:f},v).then(G)},construct(s,_){$t(i);let[d,l]=Ne(_);return nt(r,t,{type:"CONSTRUCT",path:e.map(f=>f.toString()),argumentList:d},l).then(G)}});return fn(o,r),o}function gn(r){return Array.prototype.concat.apply([],r)}function Ne(r){let t=r.map(Ht);return[t.map(e=>e[0]),gn(t.map(e=>e[1]))]}var Ke=new WeakMap;function wn(r,t){return Ke.set(r,t),r}function pn(r){return Object.assign(r,{[He]:!0})}function Ht(r){for(let[t,e]of Je)if(e.canHandle(r)){let[n,i]=e.serialize(r);return[{type:"HANDLER",name:t,value:n},i]}return[{type:"RAW",value:r},Ke.get(r)||[]]}function G(r){switch(r.type){case"HANDLER":return Je.get(r.name).deserialize(r.value);case"RAW":return r.value}}function nt(r,t,e,n){return new Promise(i=>{let o=bn();t.set(o,i),r.start&&r.start(),r.postMessage(Object.assign({id:o},e),n)})}function bn(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}Et();Et();_e();var Z=class{mTimes=new Map;mData=new Map;constructor(){}reset(){this.mTimes.clear(),this.mData.clear()}insertFile(t,e,n){this.mTimes.set(t,n),this.mData.set(t,e)}removeFile(t){this.mTimes.delete(t),this.mData.delete(t)}getMTime(t){if(t.startsWith("/@memory/")&&this.mTimes.has(t))return this.mTimes.get(t)}isFile(){return!0}getRealPath(t){return t}readAll(t){if(t.startsWith("/@memory/")&&this.mData.has(t))return this.mData.get(t)}};var wt=class{am;cache=new Map;constructor(t){this.am=t}resolvePath(t){return`https://packages.typst.org/preview/${t.name}-${t.version}.tar.gz`}pullPackageData(t){let e=new XMLHttpRequest;if(e.overrideMimeType("text/plain; charset=x-user-defined"),e.open("GET",this.resolvePath(t),!1),e.send(null),e.status===200&&(e.response instanceof String||typeof e.response=="string"))return Uint8Array.from(e.response,n=>n.charCodeAt(0))}resolve(t,e){if(t.namespace!=="preview")return;let n=this.resolvePath(t);if(this.cache.has(n))return this.cache.get(n)();let i=this.pullPackageData(t);if(!i)return;let o=`/@memory/fetch/packages/${t.namespace}/${t.name}/${t.version}`,s=[];e.untar(i,(d,l,f)=>{s.push([o+"/"+d,l,new Date(f)])});let _=()=>{for(let[d,l,f]of s)this.am.insertFile(d,l,f);return o};return this.cache.set(n,_),_()}};St();Et();Kt();function Ur(r){return Math.random().toString(36).replace("0.",r||"")}St();var li=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,Bt=class r{mainFilePath;cc;fr;ex;constructor(t){this.cc=t?.compiler||r.buildLocalCompiler,this.fr=t?.fontResolver||r.buildLocalFontResolver,this.ex=t?.renderer||r.buildLocalRenderer,this.mainFilePath="/main.typ",this.providers=[]}setCompiler(t){this.cc=t}async getFontResolver(){return typeof this.fr=="function"?this.fr=await this.fr():this.fr}async getCompiler(){return typeof this.cc=="function"?this.cc=await this.cc():this.cc}async getCompilerReset(){let t=await this.getCompiler();return await t.reset(),t}setRenderer(t){this.ex=t}async getRenderer(){return typeof this.ex=="function"?this.ex=await this.ex():this.ex}providers;use(...t){if(!this.providers)throw new Error("already prepare uses for instances");this.providers.push(...t)}static preloadFontFromUrl(t){return r.preloadFonts([t])}static preloadFontData(t){return r.preloadFonts([t])}static preloadFonts(t){return{key:"access-model",forRoles:["compiler"],provides:[X(t)]}}static disableDefaultFontAssets(){return{key:"access-model",forRoles:["compiler"],provides:[Ye()]}}static preloadFontAssets(t){return{key:"access-model",forRoles:["compiler"],provides:[Qe(t)]}}static withAccessModel(t){return{key:"access-model",forRoles:["compiler"],provides:[ye(t)]}}static withPackageRegistry(t){return{key:"package-registry",forRoles:["compiler"],provides:[Jt(t)]}}static fetchPackageRegistry(t){let e=t||new Z,n=[...t?[]:[ye(e)],Jt(new wt(e))];return{key:"package-registry$fetch",forRoles:["compiler"],provides:n}}static fetchPackageBy(t,e){class n extends wt{pullPackageData(o){return e(o,this.resolvePath(o))}}return{key:"package-registry$lambda",forRoles:["compiler"],provides:[Jt(new n(t))]}}ccOptions;setCompilerInitOptions(t){this.requireIsUninitialized("compiler",this.cc),this.ccOptions=t}exOptions;setRendererInitOptions(t){this.requireIsUninitialized("renderer",this.ex),this.exOptions=t}setMainFilePath(t){this.mainFilePath=t}getMainFilePath(){return this.mainFilePath}removeTmp(t){return t.mainFilePath.startsWith("/tmp/")?this.unmapShadow(t.mainFilePath):Promise.resolve()}async setFonts(t){let e=await this.getFontResolver();for(let i of t)await e.addLazyFont(i,"blob"in i?i.blob:Se(i),i);let n=await this.getCompiler();await e.build(async i=>n.setFonts(i))}async addSource(t,e){(await this.getCompiler()).addSource(t,e)}async resetShadow(){(await this.getCompiler()).resetShadow()}async mapShadow(t,e){(await this.getCompiler()).mapShadow(t,e)}async unmapShadow(t){(await this.getCompiler()).unmapShadow(t)}async vector(t){let e=await this.getCompileOptions(t);return(await this.getCompilerReset()).compile(e).then(i=>i.result).finally(()=>this.removeTmp(e))}async pdf(t){let e=await this.getCompileOptions(t);return e.format=xt.pdf,(await this.getCompilerReset()).compile(e).then(i=>i.result).finally(()=>this.removeTmp(e))}async svg(t){return this.transientRender(t,(e,n)=>e.renderSvg({...t,renderSession:n}))}async canvas(t,e){return this.transientRender(e,(n,i)=>n.renderToCanvas({container:t,...e,renderSession:i}))}async query(t){let e=await this.getCompileOptions(t);return(await this.getCompilerReset()).query({...t,...e}).finally(()=>this.removeTmp(e))}async getSemanticTokenLegend(){return(await this.getCompilerReset()).getSemanticTokenLegend()}async getSemanticTokens(t){let e=await this.getCompileOptions(t);return(await this.getCompilerReset()).getSemanticTokens({mainFilePath:e.mainFilePath,resultId:t.resultId}).finally(()=>this.removeTmp(e))}async getCompileOptions(t){if(t===void 0)return{mainFilePath:this.mainFilePath,diagnostics:"none"};if(typeof t=="string")throw new Error("please specify opts as {mainContent: \'...\'} or {mainFilePath: \'...\'}");if("mainFilePath"in t)return{...t,diagnostics:"none"};{let e=`/tmp/${Ur()}.typ`;return await this.addSource(e,t.mainContent),{mainFilePath:e,inputs:t.inputs,diagnostics:"none"}}}async getVector(t){if(t&&"vectorData"in t)return t.vectorData;let e=await this.getCompileOptions(t);return(await this.getCompiler()).compile(e).then(n=>n.result).finally(()=>this.removeTmp(e))}async transientRender(t,e){let n=await this.getRenderer();if(!n)throw new Error("does not provide renderer instance");let i=await this.getVector(t);return await n.runWithSession(async o=>(n.manipulateData({renderSession:o,action:"reset",data:i}),e(n,o)))}prepareUseOnce=void 0;async prepareUse(){return this.prepareUseOnce?this.prepareUseOnce:this.prepareUseOnce=this.doPrepareUse()}async doPrepareUse(){if(!this.providers)return;let t=await Promise.all(this.providers.map(_=>typeof _=="function"?_():_));if(this.providers=[],be==this&&!t.some(_=>_.key.includes("package-registry")||_.key.includes("access-model")))if(li){let _=new Function("m","return import(m)");try{let d=new Z,{default:l}=await _("sync-request");be.use(r.withAccessModel(d),r.fetchPackageBy(d,(f,v)=>{let S=l("GET",v);if(S.statusCode===200)return S.getBody(void 0)}))}catch{}}else be.use(r.fetchPackageRegistry());let e=await Promise.all(this.providers.map(_=>typeof _=="function"?_():_)),n=this.ccOptions||={},i=n.beforeBuild||=[],o=this.exOptions||={},s=o.beforeBuild||=[];for(let _ of[...t,...e])_.forRoles.includes("compiler")&&(this.requireIsUninitialized("compiler",this.cc),i.push(..._.provides)),_.forRoles.includes("renderer")&&(this.requireIsUninitialized("renderer",this.ex),s.push(..._.provides));this.providers=void 0}requireIsUninitialized(t,e,n){if(e&&typeof e!="function")throw new Error(`${t} has been initialized: ${e}`)}static async buildLocalCompiler(){let{createTypstCompiler:t}=await Promise.resolve().then(()=>(St(),pe));await this.prepareUse();let e=t();return await e.init(this.ccOptions),e}static async buildLocalFontResolver(){let{createTypstFontBuilder:t}=await Promise.resolve().then(()=>(St(),pe));await this.prepareUse();let e=t();return await e.init(this.ccOptions),e}static async buildGlobalCompiler(){let{createGlobalCompiler:t}=await Promise.resolve().then(()=>(Jr(),Vr)),{createTypstCompiler:e}=await Promise.resolve().then(()=>(St(),pe));return await this.prepareUse(),t(e,this.ccOptions)}static async buildLocalRenderer(){let{createTypstRenderer:t}=await Promise.resolve().then(()=>(_e(),Ae));await this.prepareUse();let e=t();return await e.init(this.exOptions),e}static async buildGlobalRenderer(){let{createGlobalRenderer:t}=await Promise.resolve().then(()=>(Qr(),Yr)),{createTypstRenderer:e}=await Promise.resolve().then(()=>(_e(),Ae));return await this.prepareUse(),t(e,this.exOptions)}},be=new Bt({compiler:Bt.buildGlobalCompiler,renderer:Bt.buildGlobalRenderer});ie();var qe=class{#t=null;#e=null;#r=null;#n(){if(!this.#t)throw new Error("Renderer not initialized");return this.#t}#i(){if(!this.#e)throw new Error("Renderer not initialized");return this.#e}async init(t){this.#t=ae(),await this.#t.init({getModule:()=>t,getWrapper:()=>Promise.resolve(Mt)});let{session:e,close:n}=await gi(this.#t);this.#e=e,this.#r=n}async renderSvg(t){let e=this.#i();return e.manipulateData({action:"reset",data:t}),this.#n().renderSvg({renderSession:e})}destroy(){this.#r?.(),this.#r=null,this.#e=null,this.#t=null}};async function gi(r){let t,e=new Promise(i=>{t=i}),n;return await new Promise((i,o)=>{r.runWithSession(async s=>{n=s,i(),await e}).catch(o)}),{session:n,close:t}}Vt(new qe);})();\n/*! Bundled license information:\n\ncomlink/dist/esm/comlink.mjs:\n (**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n *)\n*/\n');
|
|
24
|
+
}
|
|
22
25
|
|
|
23
26
|
// src/analyzer.ts
|
|
24
27
|
var TypstAnalyzer = class _TypstAnalyzer {
|
|
@@ -671,46 +674,73 @@ var TypstProject = class {
|
|
|
671
674
|
};
|
|
672
675
|
|
|
673
676
|
// src/renderer.ts
|
|
674
|
-
import
|
|
675
|
-
createTypstRenderer
|
|
676
|
-
} from "@myriaddreamin/typst.ts";
|
|
677
|
+
import * as Comlink3 from "comlink";
|
|
677
678
|
var DEFAULT_RENDERER_WASM_URL = `https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-renderer@${"0.7.0-rc2"}/pkg/typst_ts_renderer_bg.wasm`;
|
|
678
679
|
var TypstRenderer = class _TypstRenderer {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
680
|
+
#proxy;
|
|
681
|
+
#worker;
|
|
682
|
+
#wasmUrl;
|
|
683
|
+
#initPromise = null;
|
|
684
|
+
#pending = null;
|
|
685
|
+
#inflight = null;
|
|
686
|
+
constructor(worker, proxy, wasmUrl) {
|
|
687
|
+
this.#worker = worker;
|
|
688
|
+
this.#proxy = proxy;
|
|
689
|
+
this.#wasmUrl = wasmUrl;
|
|
690
|
+
void this.#ensureInit();
|
|
684
691
|
}
|
|
685
692
|
static create(options = {}) {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
693
|
+
const worker = options.worker ?? createRendererWorker();
|
|
694
|
+
const proxy = Comlink3.wrap(worker);
|
|
695
|
+
return new _TypstRenderer(worker, proxy, options.wasmUrl ?? DEFAULT_RENDERER_WASM_URL);
|
|
696
|
+
}
|
|
697
|
+
#ensureInit() {
|
|
698
|
+
if (!this.#initPromise) {
|
|
699
|
+
this.#initPromise = this.#proxy.init(this.#wasmUrl).catch((err) => {
|
|
700
|
+
this.#initPromise = null;
|
|
692
701
|
throw err;
|
|
693
702
|
});
|
|
694
703
|
}
|
|
695
|
-
return this
|
|
704
|
+
return this.#initPromise;
|
|
696
705
|
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
706
|
+
/** Terminate the worker. The instance is unusable afterwards. */
|
|
707
|
+
destroy() {
|
|
708
|
+
this.#proxy[Comlink3.releaseProxy]();
|
|
709
|
+
this.#worker.terminate();
|
|
701
710
|
}
|
|
702
711
|
/**
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
*
|
|
712
|
+
* Render a Typst vector artifact to a single merged SVG string.
|
|
713
|
+
*
|
|
714
|
+
* Ownership of `vector.buffer` transfers to the worker (zero-copy).
|
|
715
|
+
* Don't reuse the vector after passing it in — accessing its bytes from
|
|
716
|
+
* the main thread after this call is undefined behavior.
|
|
717
|
+
*
|
|
718
|
+
* Concurrent calls are serialized in the worker: while a render is in
|
|
719
|
+
* flight, the most recent `vector` becomes the next render and any
|
|
720
|
+
* intermediate calls are dropped. All overlapping callers share one
|
|
721
|
+
* returned promise that resolves with the LAST rendered SVG — your
|
|
722
|
+
* specific vector may have been superseded.
|
|
706
723
|
*/
|
|
707
|
-
|
|
708
|
-
this
|
|
724
|
+
renderSvg(vector) {
|
|
725
|
+
this.#pending = vector;
|
|
726
|
+
this.#inflight ??= this.#drain();
|
|
727
|
+
return this.#inflight;
|
|
709
728
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
729
|
+
async #drain() {
|
|
730
|
+
try {
|
|
731
|
+
await this.#ensureInit();
|
|
732
|
+
let result = "";
|
|
733
|
+
while (this.#pending) {
|
|
734
|
+
const vector = this.#pending;
|
|
735
|
+
this.#pending = null;
|
|
736
|
+
result = await this.#proxy.renderSvg(
|
|
737
|
+
Comlink3.transfer(vector, [vector.buffer])
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
return result;
|
|
741
|
+
} finally {
|
|
742
|
+
this.#inflight = null;
|
|
743
|
+
}
|
|
714
744
|
}
|
|
715
745
|
/**
|
|
716
746
|
* Render a Typst vector artifact into one self-contained SVG string per
|
|
@@ -723,109 +753,6 @@ var TypstRenderer = class _TypstRenderer {
|
|
|
723
753
|
async renderSvgPages(vector) {
|
|
724
754
|
return splitMergedSvgPages(await this.renderSvg(vector));
|
|
725
755
|
}
|
|
726
|
-
/**
|
|
727
|
-
* Mount an incremental canvas renderer into `root`. Each `update(vector)`
|
|
728
|
-
* call repaints the canvases in place. The win for image-heavy docs comes
|
|
729
|
-
* from the persistent WASM session: decoded image bitmaps are cached in
|
|
730
|
-
* the renderer, so subsequent paints skip the decode step. Canvas elements
|
|
731
|
-
* are recreated each update (typst.ts manages the DOM inside `root`), but
|
|
732
|
-
* canvas creation is cheap — the bottleneck the SVG path was solving was
|
|
733
|
-
* `<image>` data-URL decode, not DOM construction.
|
|
734
|
-
*
|
|
735
|
-
* Call `reset()` when switching to an unrelated document (next `update`
|
|
736
|
-
* starts fresh from the session). Call `dispose()` to free the session.
|
|
737
|
-
*
|
|
738
|
-
* Trade-off vs the SVG paths: output is rasterized — text in the rendered
|
|
739
|
-
* canvas isn't selectable, and zoom past `pixelPerPt` needs a re-render to
|
|
740
|
-
* stay crisp. typst.ts builds a `<canvas>` per page inside `root` and adds
|
|
741
|
-
* a text-semantic layer alongside it for screen readers / a11y.
|
|
742
|
-
*/
|
|
743
|
-
createIncrementalCanvasRenderer(root, options = {}) {
|
|
744
|
-
return new IncrementalCanvasImpl(root, () => this.getInner(), options);
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
async function openSession(inner) {
|
|
748
|
-
let close;
|
|
749
|
-
const closed = new Promise((resolve) => {
|
|
750
|
-
close = resolve;
|
|
751
|
-
});
|
|
752
|
-
let session;
|
|
753
|
-
await new Promise((ready, reject) => {
|
|
754
|
-
void inner.runWithSession(async (s) => {
|
|
755
|
-
session = s;
|
|
756
|
-
ready();
|
|
757
|
-
await closed;
|
|
758
|
-
}).catch(reject);
|
|
759
|
-
});
|
|
760
|
-
return { session, close };
|
|
761
|
-
}
|
|
762
|
-
function defaultPixelPerPt() {
|
|
763
|
-
const dpr = typeof globalThis !== "undefined" && typeof globalThis.devicePixelRatio === "number" ? globalThis.devicePixelRatio : 1;
|
|
764
|
-
return Math.max(dpr * 1.5, 3);
|
|
765
|
-
}
|
|
766
|
-
var IncrementalCanvasImpl = class {
|
|
767
|
-
constructor(root, getInner, options) {
|
|
768
|
-
this.root = root;
|
|
769
|
-
this.getInner = getInner;
|
|
770
|
-
this.options = options;
|
|
771
|
-
}
|
|
772
|
-
opened = null;
|
|
773
|
-
inflight = null;
|
|
774
|
-
pending = null;
|
|
775
|
-
disposed = false;
|
|
776
|
-
getOpened() {
|
|
777
|
-
this.opened ??= this.getInner().then(async (inner) => ({
|
|
778
|
-
...await openSession(inner),
|
|
779
|
-
inner
|
|
780
|
-
}));
|
|
781
|
-
return this.opened;
|
|
782
|
-
}
|
|
783
|
-
update(vector) {
|
|
784
|
-
if (this.disposed) return Promise.resolve();
|
|
785
|
-
this.pending = vector;
|
|
786
|
-
this.inflight ??= this.drain();
|
|
787
|
-
return this.inflight;
|
|
788
|
-
}
|
|
789
|
-
async drain() {
|
|
790
|
-
try {
|
|
791
|
-
while (this.pending && !this.disposed) {
|
|
792
|
-
const vector = this.pending;
|
|
793
|
-
this.pending = null;
|
|
794
|
-
await this.paint(vector);
|
|
795
|
-
}
|
|
796
|
-
} finally {
|
|
797
|
-
this.inflight = null;
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
async paint(vector) {
|
|
801
|
-
const { session, inner } = await this.getOpened();
|
|
802
|
-
if (this.disposed) return;
|
|
803
|
-
session.manipulateData({ action: "reset", data: vector });
|
|
804
|
-
const previousHeight = this.root.offsetHeight;
|
|
805
|
-
const hadLock = previousHeight > 0;
|
|
806
|
-
if (hadLock) {
|
|
807
|
-
this.root.style.height = `${previousHeight}px`;
|
|
808
|
-
}
|
|
809
|
-
try {
|
|
810
|
-
await inner.renderToCanvas({
|
|
811
|
-
container: this.root,
|
|
812
|
-
renderSession: session,
|
|
813
|
-
pixelPerPt: this.options.pixelPerPt ?? defaultPixelPerPt(),
|
|
814
|
-
backgroundColor: this.options.backgroundColor ?? "#ffffff"
|
|
815
|
-
});
|
|
816
|
-
} finally {
|
|
817
|
-
if (hadLock) {
|
|
818
|
-
this.root.style.height = "";
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
reset() {
|
|
823
|
-
}
|
|
824
|
-
dispose() {
|
|
825
|
-
if (this.disposed) return;
|
|
826
|
-
this.disposed = true;
|
|
827
|
-
void this.opened?.then(({ close }) => close());
|
|
828
|
-
}
|
|
829
756
|
};
|
|
830
757
|
function splitMergedSvgPages(svg) {
|
|
831
758
|
const doc = new DOMParser().parseFromString(svg, "text/html");
|