@vedivad/typst-web-service 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14,10 +14,10 @@ function createBlobWorker(code) {
14
14
  return worker;
15
15
  }
16
16
  function createWorker() {
17
- return createBlobWorker('"use strict";(()=>{var re=Object.defineProperty;var vt=(e,t)=>()=>(e&&(t=e(e=0)),t);var ne=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})};function f(e){N===S.length&&S.push(S.length+1);let t=N;return N=S[t],S[t]=e,t}function lt(e,t){if(!(e instanceof t))throw new Error(`expected instance of ${t.name}`)}function gt(e){let t=typeof e;if(t=="number"||t=="boolean"||e==null)return`${e}`;if(t=="string")return`"${e}"`;if(t=="symbol"){let o=e.description;return o==null?"Symbol":`Symbol(${o})`}if(t=="function"){let o=e.name;return typeof o=="string"&&o.length>0?`Function(${o})`:"Function"}if(Array.isArray(e)){let o=e.length,s="[";o>0&&(s+=gt(e[0]));for(let _=1;_<o;_++)s+=", "+gt(e[_]);return s+="]",s}let r=/\\[object ([^\\]]+)\\]/.exec(toString.call(e)),n;if(r&&r.length>1)n=r[1];else return toString.call(e);if(n=="Object")try{return"Object("+JSON.stringify(e)+")"}catch{return"Object"}return e instanceof Error?`${e.name}: ${e.message}\n${e.stack}`:n}function Ie(e){e<132||(S[e]=N,N=e)}function ke(e,t){e=e>>>0;let r=c(),n=[];for(let o=e;o<e+4*t;o+=4)n.push(l(r.getUint32(o,!0)));return n}function Se(e,t){return e=e>>>0,Fe().subarray(e/4,e/4+t)}function wt(e,t){return e=e>>>0,T().subarray(e/1,e/1+t)}function c(){return(M===null||M.buffer.detached===!0||M.buffer.detached===void 0&&M.buffer!==i.memory.buffer)&&(M=new DataView(i.memory.buffer)),M}function I(e,t){return e=e>>>0,Ee(e,t)}function Fe(){return(U===null||U.byteLength===0)&&(U=new Uint32Array(i.memory.buffer)),U}function T(){return(W===null||W.byteLength===0)&&(W=new Uint8Array(i.memory.buffer)),W}function u(e){return S[e]}function O(e,t){try{return e.apply(this,t)}catch(r){i.__wbindgen_export3(f(r))}}function v(e){return e==null}function Ae(e,t,r,n){let o={a:e,b:t,cnt:1,dtor:r},s=(..._)=>{o.cnt++;let a=o.a;o.a=0;try{return n(a,o.b,..._)}finally{o.a=a,s._wbg_cb_unref()}};return s._wbg_cb_unref=()=>{--o.cnt===0&&(o.dtor(o.a,o.b),o.a=0,Ct.unregister(o))},Ct.register(s,o,o),s}function Ut(e,t){let r=t(e.length*1,1)>>>0;return T().set(e,r/1),b=e.length,r}function rt(e,t){let r=t(e.length*4,4)>>>0,n=c();for(let o=0;o<e.length;o++)n.setUint32(r+4*o,f(e[o]),!0);return b=e.length,r}function h(e,t,r){if(r===void 0){let a=q.encode(e),g=t(a.length,1)>>>0;return T().subarray(g,g+a.length).set(a),b=a.length,g}let n=e.length,o=t(n,1)>>>0,s=T(),_=0;for(;_<n;_++){let a=e.charCodeAt(_);if(a>127)break;s[o+_]=a}if(_!==n){_!==0&&(e=e.slice(_)),o=r(o,n,n=_+e.length*3,1)>>>0;let a=T().subarray(o+_,o+n),g=q.encodeInto(e,a);_+=g.written,o=r(o,n,_,1)>>>0}return b=_,o}function l(e){let t=u(e);return Ie(e),t}function Ee(e,t){return ft+=t,ft>=Me&&(nt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),nt.decode(),ft=t),nt.decode(T().subarray(e,e+t))}function Re(e,t,r){i.__wasm_bindgen_func_elem_944(e,t,f(r))}function Oe(e,t,r,n){i.__wasm_bindgen_func_elem_37348(e,t,f(r),f(n))}function Te(e){let t=i.get_font_info(f(e));return l(t)}async function Pe(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(n){if(e.ok&&Ce.has(e.type)&&e.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 r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}}function Wt(){let e={};return e.wbg={},e.wbg.__wbg_Error_52673b7de5a0ca89=function(t,r){let n=Error(I(t,r));return f(n)},e.wbg.__wbg_Number_2d1dcfcf4ec51736=function(t){return Number(u(t))},e.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d=function(t,r){let n=u(r),o=typeof n=="bigint"?n:void 0;c().setBigInt64(t+8,v(o)?BigInt(0):o,!0),c().setInt32(t+0,!v(o),!0)},e.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b=function(t){let r=u(t),n=typeof r=="boolean"?r:void 0;return v(n)?16777215:n?1:0},e.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6=function(t,r){let n=gt(u(r)),o=h(n,i.__wbindgen_export,i.__wbindgen_export2),s=b;c().setInt32(t+4,s,!0),c().setInt32(t+0,o,!0)},e.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317=function(t,r){return u(t)in u(r)},e.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27=function(t){return typeof u(t)=="bigint"},e.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd=function(t){return typeof u(t)=="function"},e.wbg.__wbg___wbindgen_is_object_ce774f3490692386=function(t){let r=u(t);return typeof r=="object"&&r!==null},e.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030=function(t){return typeof u(t)=="string"},e.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269=function(t){return u(t)===void 0},e.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36=function(t,r){return u(t)===u(r)},e.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d=function(t,r){return u(t)==u(r)},e.wbg.__wbg___wbindgen_number_get_9619185a74197f95=function(t,r){let n=u(r),o=typeof n=="number"?n:void 0;c().setFloat64(t+8,v(o)?0:o,!0),c().setInt32(t+0,!v(o),!0)},e.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42=function(t,r){let n=u(r),o=typeof n=="string"?n:void 0;var s=v(o)?0:h(o,i.__wbindgen_export,i.__wbindgen_export2),_=b;c().setInt32(t+4,_,!0),c().setInt32(t+0,s,!0)},e.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e=function(t,r){throw new Error(I(t,r))},e.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7=function(t){u(t)._wbg_cb_unref()},e.wbg.__wbg_call_3020136f7a2d6e44=function(){return O(function(t,r,n){let o=u(t).call(u(r),u(n));return f(o)},arguments)},e.wbg.__wbg_call_78f94eb02ec7f9b2=function(){return O(function(t,r,n,o,s){let _=u(t).call(u(r),u(n),u(o),u(s));return f(_)},arguments)},e.wbg.__wbg_call_abb4ff46ce38be40=function(){return O(function(t,r){let n=u(t).call(u(r));return f(n)},arguments)},e.wbg.__wbg_done_62ea16af4ce34b24=function(t){return u(t).done},e.wbg.__wbg_entries_83c79938054e065f=function(t){let r=Object.entries(u(t));return f(r)},e.wbg.__wbg_error_7534b8e9a36f1ab4=function(t,r){let n,o;try{n=t,o=r,console.error(I(t,r))}finally{i.__wbindgen_export4(n,o,1)}},e.wbg.__wbg_error_85faeb8919b11cc6=function(t,r,n){console.error(u(t),u(r),u(n))},e.wbg.__wbg_getTimezoneOffset_45389e26d6f46823=function(t){return u(t).getTimezoneOffset()},e.wbg.__wbg_get_6b7bd52aca3f9671=function(t,r){let n=u(t)[r>>>0];return f(n)},e.wbg.__wbg_get_af9dab7e9603ea93=function(){return O(function(t,r){let n=Reflect.get(u(t),u(r));return f(n)},arguments)},e.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe=function(t,r){let n=u(t)[u(r)];return f(n)},e.wbg.__wbg_info_ce6bcc489c22f6f0=function(t){console.info(u(t))},e.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355=function(t){let r;try{r=u(t)instanceof ArrayBuffer}catch{r=!1}return r},e.wbg.__wbg_instanceof_Map_084be8da74364158=function(t){let r;try{r=u(t)instanceof Map}catch{r=!1}return r},e.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434=function(t){let r;try{r=u(t)instanceof Uint8Array}catch{r=!1}return r},e.wbg.__wbg_isArray_51fd9e6422c0a395=function(t){return Array.isArray(u(t))},e.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16=function(t){return Number.isSafeInteger(u(t))},e.wbg.__wbg_iterator_27b7c8b35ab3e86b=function(){return f(Symbol.iterator)},e.wbg.__wbg_length_22ac23eaec9d8053=function(t){return u(t).length},e.wbg.__wbg_length_d45040a40c570362=function(t){return u(t).length},e.wbg.__wbg_new_1ba21ce319a06297=function(){let t=new Object;return f(t)},e.wbg.__wbg_new_25f239778d6112b9=function(){let t=new Array;return f(t)},e.wbg.__wbg_new_6421f6084cc5bc5a=function(t){let r=new Uint8Array(u(t));return f(r)},e.wbg.__wbg_new_8a6f238a6ece86ea=function(){let t=new Error;return f(t)},e.wbg.__wbg_new_b2db8aa2650f793a=function(t){let r=new Date(u(t));return f(r)},e.wbg.__wbg_new_df1173567d5ff028=function(t,r){let n=new Error(I(t,r));return f(n)},e.wbg.__wbg_new_ff12d2b041fb48f1=function(t,r){try{var n={a:t,b:r},o=(_,a)=>{let g=n.a;n.a=0;try{return Oe(g,n.b,_,a)}finally{n.a=g}};let s=new Promise(o);return f(s)}finally{n.a=n.b=0}},e.wbg.__wbg_new_from_slice_db0691b69e9d3891=function(t,r){let n=new Uint32Array(Se(t,r));return f(n)},e.wbg.__wbg_new_from_slice_f9c22b9153b26992=function(t,r){let n=new Uint8Array(wt(t,r));return f(n)},e.wbg.__wbg_new_no_args_cb138f77cf6151ee=function(t,r){let n=new Function(I(t,r));return f(n)},e.wbg.__wbg_new_with_args_df9e7125ffe55248=function(t,r,n,o){let s=new Function(I(t,r),I(n,o));return f(s)},e.wbg.__wbg_next_138a17bbf04e926c=function(t){let r=u(t).next;return f(r)},e.wbg.__wbg_next_3cfe5c0fe2a4cc53=function(){return O(function(t){let r=u(t).next();return f(r)},arguments)},e.wbg.__wbg_now_69d776cd24f5215b=function(){return Date.now()},e.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd=function(t,r,n){Uint8Array.prototype.set.call(wt(t,r),u(n))},e.wbg.__wbg_proxycontext_new=function(t){let r=C.__wrap(t);return f(r)},e.wbg.__wbg_push_7d9be8f38fc13975=function(t,r){return u(t).push(u(r))},e.wbg.__wbg_queueMicrotask_9b549dfce8865860=function(t){let r=u(t).queueMicrotask;return f(r)},e.wbg.__wbg_queueMicrotask_fca69f5bfad613a5=function(t){queueMicrotask(u(t))},e.wbg.__wbg_resolve_fd5bfbaa4ce36e1e=function(t){let r=Promise.resolve(u(t));return f(r)},e.wbg.__wbg_set_3f1d0b984ed272ed=function(t,r,n){u(t)[l(r)]=l(n)},e.wbg.__wbg_set_781438a03c0c3c81=function(){return O(function(t,r,n){return Reflect.set(u(t),u(r),u(n))},arguments)},e.wbg.__wbg_set_7df433eea03a5c14=function(t,r,n){u(t)[r>>>0]=l(n)},e.wbg.__wbg_stack_0ed75d68575b0f3c=function(t,r){let n=u(r).stack,o=h(n,i.__wbindgen_export,i.__wbindgen_export2),s=b;c().setInt32(t+4,s,!0),c().setInt32(t+0,o,!0)},e.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335=function(){let t=typeof global>"u"?null:global;return v(t)?0:f(t)},e.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1=function(){let t=typeof globalThis>"u"?null:globalThis;return v(t)?0:f(t)},e.wbg.__wbg_static_accessor_SELF_08f5a74c69739274=function(){let t=typeof self>"u"?null:self;return v(t)?0:f(t)},e.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024=function(){let t=typeof window>"u"?null:window;return v(t)?0:f(t)},e.wbg.__wbg_then_4f95312d68691235=function(t,r){let n=u(t).then(u(r));return f(n)},e.wbg.__wbg_typstcompiler_new=function(t){let r=j.__wrap(t);return f(r)},e.wbg.__wbg_typstfontresolver_new=function(t){let r=E.__wrap(t);return f(r)},e.wbg.__wbg_value_57b7b035e117f7ee=function(t){let r=u(t).value;return f(r)},e.wbg.__wbindgen_cast_2241b6af4c4b2941=function(t,r){let n=I(t,r);return f(n)},e.wbg.__wbindgen_cast_3334ea73b4b28ba3=function(t,r){let n=Ae(t,r,i.__wasm_bindgen_func_elem_957,Re);return f(n)},e.wbg.__wbindgen_cast_4625c577ab2ec9ee=function(t){let r=BigInt.asUintN(64,t);return f(r)},e.wbg.__wbindgen_cast_9ae0607507abb057=function(t){return f(t)},e.wbg.__wbindgen_cast_d6cd19b81560fd6e=function(t){return f(t)},e.wbg.__wbindgen_object_clone_ref=function(t){let r=u(t);return f(r)},e.wbg.__wbindgen_object_drop_ref=function(t){l(t)},e}function Nt(e,t){return i=e.exports,qt.__wbindgen_wasm_module=t,M=null,U=null,W=null,i}function je(e){if(i!==void 0)return i;typeof e<"u"&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=Wt();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));let r=new WebAssembly.Instance(e,t);return Nt(r,e)}async function qt(e){if(i!==void 0)return i;typeof e<"u"&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof e>"u"&&(e=$t("typst_ts_web_compiler_bg.wasm",ze.url));let t=Wt();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:r,module:n}=await Pe(await e,t);return Nt(r,n)}function pt(e){$t=e}var ze,i,Ct,M,U,W,S,N,nt,Me,ft,q,b,Pt,dt,jt,zt,Bt,Lt,Dt,F,C,P,j,V,E,$,Ce,Vt,$t,ot=vt(()=>{ze={};Ct=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>e.dtor(e.a,e.b));M=null;U=null;W=null;S=new Array(128).fill(void 0);S.push(void 0,null,!0,!1);N=S.length;nt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});nt.decode();Me=2146435072,ft=0;q=new TextEncoder;"encodeInto"in q||(q.encodeInto=function(e,t){let r=q.encode(e);return t.set(r),{read:e.length,written:r.length}});b=0;Pt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_incrserver_free(e>>>0,1)),dt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_proxycontext_free(e>>>0,1)),jt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_typstcompileworld_free(e>>>0,1)),zt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_typstcompiler_free(e>>>0,1)),Bt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_typstcompilerbuilder_free(e>>>0,1)),Lt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_typstfontresolver_free(e>>>0,1)),Dt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_typstfontresolverbuilder_free(e>>>0,1)),F=class e{static __wrap(t){t=t>>>0;let r=Object.create(e.prototype);return r.__wbg_ptr=t,Pt.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Pt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_incrserver_free(t,0)}set_attach_debug_info(t){i.incrserver_set_attach_debug_info(this.__wbg_ptr,t)}current(){try{let n=i.__wbindgen_add_to_stack_pointer(-16);i.incrserver_current(n,this.__wbg_ptr);var t=c().getInt32(n+0,!0),r=c().getInt32(n+4,!0);let o;return t!==0&&(o=wt(t,r).slice(),i.__wbindgen_export4(t,r*1,1)),o}finally{i.__wbindgen_add_to_stack_pointer(16)}}reset(){i.incrserver_reset(this.__wbg_ptr)}};Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);C=class e{static __wrap(t){t=t>>>0;let r=Object.create(e.prototype);return r.__wbg_ptr=t,dt.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,dt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_proxycontext_free(t,0)}constructor(t){let r=i.proxycontext_new(f(t));return this.__wbg_ptr=r>>>0,dt.register(this,this.__wbg_ptr,this),this}get context(){let t=i.proxycontext_context(this.__wbg_ptr);return l(t)}untar(t,r){try{let s=i.__wbindgen_add_to_stack_pointer(-16),_=Ut(t,i.__wbindgen_export),a=b;i.proxycontext_untar(s,this.__wbg_ptr,_,a,f(r));var n=c().getInt32(s+0,!0),o=c().getInt32(s+4,!0);if(o)throw l(n)}finally{i.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(C.prototype[Symbol.dispose]=C.prototype.free);P=class e{static __wrap(t){t=t>>>0;let r=Object.create(e.prototype);return r.__wbg_ptr=t,jt.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,jt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstcompileworld_free(t,0)}compile(t,r){try{let _=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompileworld_compile(_,this.__wbg_ptr,t,r);var n=c().getInt32(_+0,!0),o=c().getInt32(_+4,!0),s=c().getInt32(_+8,!0);if(s)throw l(o);return l(n)}finally{i.__wbindgen_add_to_stack_pointer(16)}}title(t){try{let _=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompileworld_title(_,this.__wbg_ptr,t);var r=c().getInt32(_+0,!0),n=c().getInt32(_+4,!0),o=c().getInt32(_+8,!0),s=c().getInt32(_+12,!0);if(s)throw l(o);let a;return r!==0&&(a=I(r,n).slice(),i.__wbindgen_export4(r,n*1,1)),a}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_artifact(t,r){try{let _=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompileworld_get_artifact(_,this.__wbg_ptr,t,r);var n=c().getInt32(_+0,!0),o=c().getInt32(_+4,!0),s=c().getInt32(_+8,!0);if(s)throw l(o);return l(n)}finally{i.__wbindgen_add_to_stack_pointer(16)}}query(t,r,n){let o,s;try{let k=i.__wbindgen_add_to_stack_pointer(-16),B=h(r,i.__wbindgen_export,i.__wbindgen_export2),L=b;var _=v(n)?0:h(n,i.__wbindgen_export,i.__wbindgen_export2),a=b;i.typstcompileworld_query(k,this.__wbg_ptr,t,B,L,_,a);var g=c().getInt32(k+0,!0),d=c().getInt32(k+4,!0),w=c().getInt32(k+8,!0),y=c().getInt32(k+12,!0),p=g,m=d;if(y)throw p=0,m=0,l(w);return o=p,s=m,I(p,m)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export4(o,s,1)}}incr_compile(t,r){try{let _=i.__wbindgen_add_to_stack_pointer(-16);lt(t,F),i.typstcompileworld_incr_compile(_,this.__wbg_ptr,t.__wbg_ptr,r);var n=c().getInt32(_+0,!0),o=c().getInt32(_+4,!0),s=c().getInt32(_+8,!0);if(s)throw l(o);return l(n)}finally{i.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(P.prototype[Symbol.dispose]=P.prototype.free);j=class e{static __wrap(t){t=t>>>0;let r=Object.create(e.prototype);return r.__wbg_ptr=t,zt.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,zt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstcompiler_free(t,0)}reset(){try{let n=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_reset(n,this.__wbg_ptr);var t=c().getInt32(n+0,!0),r=c().getInt32(n+4,!0);if(r)throw l(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_fonts(t){try{let o=i.__wbindgen_add_to_stack_pointer(-16);lt(t,E),i.typstcompiler_set_fonts(o,this.__wbg_ptr,t.__wbg_ptr);var r=c().getInt32(o+0,!0),n=c().getInt32(o+4,!0);if(n)throw l(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_inputs(t){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_set_inputs(o,this.__wbg_ptr,f(t));var r=c().getInt32(o+0,!0),n=c().getInt32(o+4,!0);if(n)throw l(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}add_source(t,r){let n=h(t,i.__wbindgen_export,i.__wbindgen_export2),o=b,s=h(r,i.__wbindgen_export,i.__wbindgen_export2),_=b;return i.typstcompiler_add_source(this.__wbg_ptr,n,o,s,_)!==0}map_shadow(t,r){let n=h(t,i.__wbindgen_export,i.__wbindgen_export2),o=b,s=Ut(r,i.__wbindgen_export),_=b;return i.typstcompiler_map_shadow(this.__wbg_ptr,n,o,s,_)!==0}unmap_shadow(t){let r=h(t,i.__wbindgen_export,i.__wbindgen_export2),n=b;return i.typstcompiler_unmap_shadow(this.__wbg_ptr,r,n)!==0}reset_shadow(){i.typstcompiler_reset_shadow(this.__wbg_ptr)}get_loaded_fonts(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_get_loaded_fonts(o,this.__wbg_ptr);var t=c().getInt32(o+0,!0),r=c().getInt32(o+4,!0),n=ke(t,r).slice();return i.__wbindgen_export4(t,r*4,4),n}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_ast(t){let r,n;try{let w=i.__wbindgen_add_to_stack_pointer(-16),y=h(t,i.__wbindgen_export,i.__wbindgen_export2),p=b;i.typstcompiler_get_ast(w,this.__wbg_ptr,y,p);var o=c().getInt32(w+0,!0),s=c().getInt32(w+4,!0),_=c().getInt32(w+8,!0),a=c().getInt32(w+12,!0),g=o,d=s;if(a)throw g=0,d=0,l(_);return r=g,n=d,I(g,d)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export4(r,n,1)}}get_semantic_token_legend(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_get_semantic_token_legend(o,this.__wbg_ptr);var t=c().getInt32(o+0,!0),r=c().getInt32(o+4,!0),n=c().getInt32(o+8,!0);if(n)throw l(r);return l(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_semantic_tokens(t,r,n){try{let y=i.__wbindgen_add_to_stack_pointer(-16),p=h(t,i.__wbindgen_export,i.__wbindgen_export2),m=b;var o=v(r)?0:h(r,i.__wbindgen_export,i.__wbindgen_export2),s=b,_=v(n)?0:h(n,i.__wbindgen_export,i.__wbindgen_export2),a=b;i.typstcompiler_get_semantic_tokens(y,this.__wbg_ptr,p,m,o,s,_,a);var g=c().getInt32(y+0,!0),d=c().getInt32(y+4,!0),w=c().getInt32(y+8,!0);if(w)throw l(d);return l(g)}finally{i.__wbindgen_add_to_stack_pointer(16)}}snapshot(t,r,n){try{let m=i.__wbindgen_add_to_stack_pointer(-16);var o=v(t)?0:h(t,i.__wbindgen_export,i.__wbindgen_export2),s=b,_=v(r)?0:h(r,i.__wbindgen_export,i.__wbindgen_export2),a=b,g=v(n)?0:rt(n,i.__wbindgen_export),d=b;i.typstcompiler_snapshot(m,this.__wbg_ptr,o,s,_,a,g,d);var w=c().getInt32(m+0,!0),y=c().getInt32(m+4,!0),p=c().getInt32(m+8,!0);if(p)throw l(y);return P.__wrap(w)}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_artifact(t,r){try{let _=i.__wbindgen_add_to_stack_pointer(-16),a=h(t,i.__wbindgen_export,i.__wbindgen_export2),g=b;i.typstcompiler_get_artifact(_,this.__wbg_ptr,a,g,r);var n=c().getInt32(_+0,!0),o=c().getInt32(_+4,!0),s=c().getInt32(_+8,!0);if(s)throw l(o);return l(n)}finally{i.__wbindgen_add_to_stack_pointer(16)}}compile(t,r,n,o){try{let p=i.__wbindgen_add_to_stack_pointer(-16);var s=v(t)?0:h(t,i.__wbindgen_export,i.__wbindgen_export2),_=b,a=v(r)?0:rt(r,i.__wbindgen_export),g=b;let m=h(n,i.__wbindgen_export,i.__wbindgen_export2),k=b;i.typstcompiler_compile(p,this.__wbg_ptr,s,_,a,g,m,k,o);var d=c().getInt32(p+0,!0),w=c().getInt32(p+4,!0),y=c().getInt32(p+8,!0);if(y)throw l(w);return l(d)}finally{i.__wbindgen_add_to_stack_pointer(16)}}query(t,r,n,o){let s,_;try{let D=i.__wbindgen_add_to_stack_pointer(-16),Qt=h(t,i.__wbindgen_export,i.__wbindgen_export2),Zt=b;var a=v(r)?0:rt(r,i.__wbindgen_export),g=b;let te=h(n,i.__wbindgen_export,i.__wbindgen_export2),ee=b;var d=v(o)?0:h(o,i.__wbindgen_export,i.__wbindgen_export2),w=b;i.typstcompiler_query(D,this.__wbg_ptr,Qt,Zt,a,g,te,ee,d,w);var y=c().getInt32(D+0,!0),p=c().getInt32(D+4,!0),m=c().getInt32(D+8,!0),k=c().getInt32(D+12,!0),B=y,L=p;if(k)throw B=0,L=0,l(m);return s=B,_=L,I(B,L)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export4(s,_,1)}}create_incr_server(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_create_incr_server(o,this.__wbg_ptr);var t=c().getInt32(o+0,!0),r=c().getInt32(o+4,!0),n=c().getInt32(o+8,!0);if(n)throw l(r);return F.__wrap(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}incr_compile(t,r,n,o){try{let w=i.__wbindgen_add_to_stack_pointer(-16),y=h(t,i.__wbindgen_export,i.__wbindgen_export2),p=b;var s=v(r)?0:rt(r,i.__wbindgen_export),_=b;lt(n,F),i.typstcompiler_incr_compile(w,this.__wbg_ptr,y,p,s,_,n.__wbg_ptr,o);var a=c().getInt32(w+0,!0),g=c().getInt32(w+4,!0),d=c().getInt32(w+8,!0);if(d)throw l(g);return l(a)}finally{i.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(j.prototype[Symbol.dispose]=j.prototype.free);V=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Bt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstcompilerbuilder_free(t,0)}constructor(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompilerbuilder_new(o);var t=c().getInt32(o+0,!0),r=c().getInt32(o+4,!0),n=c().getInt32(o+8,!0);if(n)throw l(r);return this.__wbg_ptr=t>>>0,Bt.register(this,this.__wbg_ptr,this),this}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_dummy_access_model(){try{let n=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompilerbuilder_set_dummy_access_model(n,this.__wbg_ptr);var t=c().getInt32(n+0,!0),r=c().getInt32(n+4,!0);if(r)throw l(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_access_model(t,r,n,o,s){let _=i.typstcompilerbuilder_set_access_model(this.__wbg_ptr,f(t),f(r),f(n),f(o),f(s));return l(_)}set_package_registry(t,r){let n=i.typstcompilerbuilder_set_package_registry(this.__wbg_ptr,f(t),f(r));return l(n)}add_raw_font(t){let r=i.typstcompilerbuilder_add_raw_font(this.__wbg_ptr,f(t));return l(r)}add_lazy_font(t,r){let n=i.typstcompilerbuilder_add_lazy_font(this.__wbg_ptr,f(t),f(r));return l(n)}build(){let t=this.__destroy_into_raw(),r=i.typstcompilerbuilder_build(t);return l(r)}};Symbol.dispose&&(V.prototype[Symbol.dispose]=V.prototype.free);E=class e{static __wrap(t){t=t>>>0;let r=Object.create(e.prototype);return r.__wbg_ptr=t,Lt.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Lt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstfontresolver_free(t,0)}};Symbol.dispose&&(E.prototype[Symbol.dispose]=E.prototype.free);$=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Dt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstfontresolverbuilder_free(t,0)}constructor(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_new(o);var t=c().getInt32(o+0,!0),r=c().getInt32(o+4,!0),n=c().getInt32(o+8,!0);if(n)throw l(r);return this.__wbg_ptr=t>>>0,Dt.register(this,this.__wbg_ptr,this),this}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_font_info(t){try{let s=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_get_font_info(s,this.__wbg_ptr,f(t));var r=c().getInt32(s+0,!0),n=c().getInt32(s+4,!0),o=c().getInt32(s+8,!0);if(o)throw l(n);return l(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}add_raw_font(t){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_add_raw_font(o,this.__wbg_ptr,f(t));var r=c().getInt32(o+0,!0),n=c().getInt32(o+4,!0);if(n)throw l(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}add_lazy_font(t,r){try{let s=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_add_lazy_font(s,this.__wbg_ptr,f(t),f(r));var n=c().getInt32(s+0,!0),o=c().getInt32(s+4,!0);if(o)throw l(n)}finally{i.__wbindgen_add_to_stack_pointer(16)}}build(){let t=this.__destroy_into_raw(),r=i.typstfontresolverbuilder_build(t);return l(r)}};Symbol.dispose&&($.prototype[Symbol.dispose]=$.prototype.free);Ce=new Set(["basic","cors","default"]);Vt=qt,$t=async function(e,t){throw new Error("Cannot import wasm module without importer: "+e+" "+t)}});var Jt={};ne(Jt,{IncrServer:()=>F,ProxyContext:()=>C,TypstCompileWorld:()=>P,TypstCompiler:()=>j,TypstCompilerBuilder:()=>V,TypstFontResolver:()=>E,TypstFontResolverBuilder:()=>$,default:()=>Be,get_font_info:()=>Te,initSync:()=>je,setImportWasmModule:()=>pt});var Be,Le,De,Ht=vt(()=>{ot();ot();ot();Be=Vt,Le=async function(e,t){let r=new Function("m","return import(m)"),{readFileSync:n}=await r("fs"),o=new URL(e,t);return await n(o).buffer},De=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;De&&pt(Le)});var It=Symbol("Comlink.proxy"),oe=Symbol("Comlink.endpoint"),ie=Symbol("Comlink.releaseProxy"),at=Symbol("Comlink.finalizer"),G=Symbol("Comlink.thrown"),kt=e=>typeof e=="object"&&e!==null||typeof e=="function",se={canHandle:e=>kt(e)&&e[It],serialize(e){let{port1:t,port2:r}=new MessageChannel;return Q(e,t),[r,[r]]},deserialize(e){return e.start(),ue(e)}},_e={canHandle:e=>kt(e)&&G in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},St=new Map([["proxy",se],["throw",_e]]);function ae(e,t){for(let r of e)if(t===r||r==="*"||r instanceof RegExp&&r.test(t))return!0;return!1}function Q(e,t=globalThis,r=["*"]){t.addEventListener("message",function n(o){if(!o||!o.data)return;if(!ae(r,o.origin)){console.warn(`Invalid origin \'${o.origin}\' for comlink proxy`);return}let{id:s,type:_,path:a}=Object.assign({path:[]},o.data),g=(o.data.argumentList||[]).map(A),d;try{let w=a.slice(0,-1).reduce((p,m)=>p[m],e),y=a.reduce((p,m)=>p[m],e);switch(_){case"GET":d=y;break;case"SET":w[a.slice(-1)[0]]=A(o.data.value),d=!0;break;case"APPLY":d=y.apply(w,g);break;case"CONSTRUCT":{let p=new y(...g);d=ge(p)}break;case"ENDPOINT":{let{port1:p,port2:m}=new MessageChannel;Q(e,m),d=Z(p,[p])}break;case"RELEASE":d=void 0;break;default:return}}catch(w){d={value:w,[G]:0}}Promise.resolve(d).catch(w=>({value:w,[G]:0})).then(w=>{let[y,p]=K(w);t.postMessage(Object.assign(Object.assign({},y),{id:s}),p),_==="RELEASE"&&(t.removeEventListener("message",n),Ft(t),at in e&&typeof e[at]=="function"&&e[at]())}).catch(w=>{let[y,p]=K({value:new TypeError("Unserializable return value"),[G]:0});t.postMessage(Object.assign(Object.assign({},y),{id:s}),p)})}),t.start&&t.start()}function ce(e){return e.constructor.name==="MessagePort"}function Ft(e){ce(e)&&e.close()}function ue(e,t){let r=new Map;return e.addEventListener("message",function(o){let{data:s}=o;if(!s||!s.id)return;let _=r.get(s.id);if(_)try{_(s)}finally{r.delete(s.id)}}),ct(e,r,[],t)}function H(e){if(e)throw new Error("Proxy has been released and is not useable")}function At(e){return R(e,new Map,{type:"RELEASE"}).then(()=>{Ft(e)})}var X=new WeakMap,Y="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{let t=(X.get(e)||0)-1;X.set(e,t),t===0&&At(e)});function fe(e,t){let r=(X.get(t)||0)+1;X.set(t,r),Y&&Y.register(e,t,e)}function de(e){Y&&Y.unregister(e)}function ct(e,t,r=[],n=function(){}){let o=!1,s=new Proxy(n,{get(_,a){if(H(o),a===ie)return()=>{de(s),At(e),t.clear(),o=!0};if(a==="then"){if(r.length===0)return{then:()=>s};let g=R(e,t,{type:"GET",path:r.map(d=>d.toString())}).then(A);return g.then.bind(g)}return ct(e,t,[...r,a])},set(_,a,g){H(o);let[d,w]=K(g);return R(e,t,{type:"SET",path:[...r,a].map(y=>y.toString()),value:d},w).then(A)},apply(_,a,g){H(o);let d=r[r.length-1];if(d===oe)return R(e,t,{type:"ENDPOINT"}).then(A);if(d==="bind")return ct(e,t,r.slice(0,-1));let[w,y]=xt(g);return R(e,t,{type:"APPLY",path:r.map(p=>p.toString()),argumentList:w},y).then(A)},construct(_,a){H(o);let[g,d]=xt(a);return R(e,t,{type:"CONSTRUCT",path:r.map(w=>w.toString()),argumentList:g},d).then(A)}});return fe(s,e),s}function le(e){return Array.prototype.concat.apply([],e)}function xt(e){let t=e.map(K);return[t.map(r=>r[0]),le(t.map(r=>r[1]))]}var Mt=new WeakMap;function Z(e,t){return Mt.set(e,t),e}function ge(e){return Object.assign(e,{[It]:!0})}function K(e){for(let[t,r]of St)if(r.canHandle(e)){let[n,o]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},o]}return[{type:"RAW",value:e},Mt.get(e)||[]]}function A(e){switch(e.type){case"HANDLER":return St.get(e.name).deserialize(e.value);case"RAW":return e.value}}function R(e,t,r,n){return new Promise(o=>{let s=we();t.set(s,o),e.start&&e.start(),e.postMessage(Object.assign({id:s},r),n)})}function we(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var ut=class{loadedFonts=new Set;fetcher=fetch;setFetcher(t){this.fetcher=t}async loadFonts(t,r){let n=new Function("m","return import(m)"),o=this.fetcher||=await(async function(){let{fetchBuilder:a,FileSystemCache:g}=await n("node-fetch-cache"),d=new g({cacheDirectory:".cache/typst/fonts"}),w=a.withCache(d);return function(y,p){let m=setTimeout(()=>{console.warn("font fetching is stucking:",y)},15e3);return w(y,p).finally(()=>{clearTimeout(m)})}})(),s=r.filter(a=>a instanceof Uint8Array||typeof a=="object"&&"info"in a?!0:this.loadedFonts.has(a)?!1:(this.loadedFonts.add(a),!0)),_=await Promise.all(s.map(async a=>{if(a instanceof Uint8Array){await t.add_raw_font(a);return}if(typeof a=="object"&&"info"in a){await t.add_lazy_font(a,"blob"in a?a.blob:be(a));return}return new Uint8Array(await(await o(a)).arrayBuffer())}));for(let a of _)a&&await t.add_raw_font(a)}async build(t,r,n){let o={ref:this,builder:r,hooks:n};for(let s of t?.beforeBuild??[])await s(void 0,o);return n.latelyBuild&&n.latelyBuild(o),await r.build()}};async function Et(e,t,r,n){return await t.init(e?.getModule?.()),await new ut().build(e,new r,n)}function be(e){return()=>{let t=new XMLHttpRequest;return t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",e.url,!1),t.send(null),t.status===200&&(t.response instanceof String||typeof t.response=="string")?Uint8Array.from(t.response,r=>r.charCodeAt(0)):new Uint8Array}}var x=Symbol.for("reflexo-obj");var Rt;(function(e){e[e.PIXEL_PER_PT=3]="PIXEL_PER_PT"})(Rt||(Rt={}));var ye=["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"],me=["InriaSerif-Bold.ttf","InriaSerif-BoldItalic.ttf","InriaSerif-Italic.ttf","InriaSerif-Regular.ttf","Roboto-Regular.ttf","NotoSerifCJKsc-Regular.otf"],he=["TwitterColorEmoji.ttf","NotoColorEmoji-Regular-COLR.subset.ttf"];function ve(e){let t=[];if(e&&e?.assets!==!1&&e?.assets?.length&&e?.assets?.length>0){let r={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=e.assetUrlPrefix??r;typeof n=="string"?n={_:n}:n={...r,...n};for(let s of Object.keys(n)){let _=n[s];_[_.length-1]!=="/"&&(n[s]=_+"/")}let o=(s,_)=>_.map(a=>(n[s]||n._)+a);for(let s of e.assets)switch(s){case"text":t.push(...o(s,ye));break;case"cjk":t.push(...o(s,me));break;case"emoji":t.push(...o(s,he));break}}return t}function tt(e,t){let r=ve(t),n=async(o,{ref:s,builder:_})=>{t?.fetcher&&s.setFetcher(t.fetcher),await s.loadFonts(_,[...e,...r])};return n._preloadRemoteFontOptions=t,n._kind="fontLoader",n}function Ot(e){return async(t,{builder:r})=>new Promise(n=>{r.set_package_registry(e,function(o){return e.resolve(o,this)}),n()})}function Tt(e){return async(t,r)=>{if(r.alreadySetAccessModel)throw new Error(`already set some assess model before: ${r.alreadySetAccessModel.constructor?.name}(${r.alreadySetAccessModel})`);return r.alreadySetAccessModel=e,new Promise(n=>{r.builder.set_access_model(e,o=>{let s=e.getMTime(o);return s?s.getTime():0},o=>e.isFile(o)||!1,o=>e.getRealPath(o)||o,o=>e.readAll(o)),n()})}}var xe=e=>{let t=!1,r;return()=>t?r:(t=!0,r=e())},et=class{wasmBin;initOnce;constructor(t){if(typeof t!="function")throw new Error("initFn is not a function");this.initOnce=xe(async()=>{await t(this.wasmBin)})}async init(t){this.wasmBin=t,await this.initOnce()}};var J;(function(e){e[e.vector=0]="vector",e[e.pdf=1]="pdf",e[e._dummy=2]="_dummy"})(J||(J={}));var bt=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)}},Gt;Gt||(Gt={});var yt=class{[x];constructor(t){this[x]=t}compile(t){return this[x].compile(0,z(t?.diagnostics))}compileHtml(t){return this[x].compile(1,z(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,z(t?.diagnostics))||{}}pdf(t){return this[x].get_artifact(1,z(t?.diagnostics))||{}}},Ue=e=>new et(async t=>await e.default(t));function mt(){return new it}var it=class e{compiler;compilerJs;static defaultAssets=["text"];constructor(){}async init(t){this.compilerJs=await(t?.getWrapper?.()||Promise.resolve().then(()=>(Ht(),Jt)));let r=this.compilerJs.TypstCompilerBuilder,n={...t||{}},o=n.beforeBuild??=[],s=o.some(d=>d._preloadRemoteFontOptions!==void 0),_=o.some(d=>d._preloadRemoteFontOptions?.assets!==void 0),a=o.some(d=>d._preloadRemoteFontOptions?.assets===!1);if((!s||!_&&!a)&&o.push(tt([],{assets:e.defaultAssets})),!o.some(d=>d._kind==="fontLoader"))throw new Error("TypstCompiler: no font loader found, please use font loaders, e.g. loadFonts or preloadSystemFonts");this.compiler=await Et(t,Ue(this.compilerJs),r,{})}setFonts(t){this.compiler.set_fonts(t)}compile(t){return new Promise(r=>{let n=this.compiler.snapshot(t.root,t.mainFilePath,Xt(t.inputs));if("incrementalServer"in t){r(n.incr_compile(t.incrementalServer[x],z(t.diagnostics)));return}r(n.get_artifact(t.format||J.vector,z(t.diagnostics)))})}async runWithWorld(t,r){let n=this.compiler.snapshot(t.root,t.mainFilePath,Xt(t.inputs)),o=await r(new yt(n));return n.free(),o}query(t){return this.runWithWorld(t,async r=>JSON.parse(await r.query(t)))}getSemanticTokenLegend(){return new Promise(t=>{t(this.compiler.get_semantic_token_legend())})}getSemanticTokens(t){return new Promise(r=>{this.compiler.reset(),r(this.compiler.get_semantic_tokens(t.offsetEncoding||"utf-16",t.mainFilePath,t.resultId))})}async withIncrementalServer(t){let r=new bt(this.compiler.create_incr_server());try{return await t(r)}finally{r[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,r){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,r)}mapShadow(t,r){this.compiler.map_shadow(t,r)}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")}};mt._impl=it;function Xt(e){return e?Object.entries(e):void 0}function z(e){switch(e){case"none":return 1;case"unix":return 2;default:return 3}}var st=class{mTimes=new Map;mData=new Map;constructor(){}reset(){this.mTimes.clear(),this.mData.clear()}insertFile(t,r,n){this.mTimes.set(t,n),this.mData.set(t,r)}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 _t=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 r=new XMLHttpRequest;if(r.overrideMimeType("text/plain; charset=x-user-defined"),r.open("GET",this.resolvePath(t),!1),r.send(null),r.status===200&&(r.response instanceof String||typeof r.response=="string"))return Uint8Array.from(r.response,n=>n.charCodeAt(0))}resolve(t,r){if(t.namespace!=="preview")return;let n=this.resolvePath(t);if(this.cache.has(n))return this.cache.get(n)();let o=this.pullPackageData(t);if(!o)return;let s=`/@memory/fetch/packages/${t.namespace}/${t.name}/${t.version}`,_=[];r.untar(o,(g,d,w)=>{_.push([s+"/"+g,d,new Date(w)])});let a=()=>{for(let[g,d,w]of _)this.am.insertFile(g,d,w);return s};return this.cache.set(n,a),a()}};function Yt(e){return[...e].sort((t,r)=>t.path.localeCompare(r.path)||t.range.startLine-r.range.startLine||t.range.startCol-r.range.startCol||t.range.endLine-r.range.endLine||t.range.endCol-r.range.endCol||t.message.localeCompare(r.message))}var Kt="/main.typ",ht=class{compiler=null;accessModel=new st;packageRegistry;constructor(){this.packageRegistry=new _t(this.accessModel)}async init(t,r,n){this.compiler=mt(),await this.compiler.init({getModule:()=>t,beforeBuild:[tt(r),...n?[Tt(this.accessModel),Ot(this.packageRegistry)]:[]]})}async compile(t,r){if(!this.compiler)throw new Error("Compiler not initialized");if(t)for(let[_,a]of Object.entries(t))this.compiler.addSource(_,a);let n=await this.compiler.compile({mainFilePath:r??Kt,diagnostics:"full"}),o=Yt((n.diagnostics??[]).flatMap(_=>{let a=_.range.match(/(\\d+):(\\d+)-(\\d+):(\\d+)/);return a?[{..._,severity:_.severity,range:{startLine:+a[1],startCol:+a[2],endLine:+a[3],endCol:+a[4]}}]:(console.warn(`[typst-web-service] Skipping diagnostic with unrecognized range format: ${JSON.stringify(_.range)}`),[])})),s=n.result??void 0;return s?Z({diagnostics:o,vector:s},[s.buffer]):{diagnostics:o}}async compilePdf(t,r){if(!this.compiler)throw new Error("Compiler not initialized");if(t)for(let[o,s]of Object.entries(t))this.compiler.addSource(o,s);let n=await this.compiler.compile({mainFilePath:r??Kt,format:J.pdf,diagnostics:"none"});if(!n.result)throw new Error("Compilation produced no output");return Z(n.result,[n.result.buffer])}mapShadow(t,r){if(!this.compiler)throw new Error("Compiler not initialized");this.compiler.mapShadow(t,r)}mapShadowMany(t){if(!this.compiler)throw new Error("Compiler not initialized");for(let[r,n]of Object.entries(t))this.compiler.mapShadow(r,n)}unmapShadow(t){if(!this.compiler)throw new Error("Compiler not initialized");this.compiler.unmapShadow(t)}resetShadow(){if(!this.compiler)throw new Error("Compiler not initialized");this.compiler.resetShadow()}destroy(){this.compiler=null}};Q(new ht);})();\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');
17
+ return createBlobWorker('"use strict";(()=>{var ne=Object.defineProperty;var vt=(e,t)=>()=>(e&&(t=e(e=0)),t);var re=(e,t)=>{for(var n in t)ne(e,n,{get:t[n],enumerable:!0})};function f(e){N===S.length&&S.push(S.length+1);let t=N;return N=S[t],S[t]=e,t}function gt(e,t){if(!(e instanceof t))throw new Error(`expected instance of ${t.name}`)}function lt(e){let t=typeof e;if(t=="number"||t=="boolean"||e==null)return`${e}`;if(t=="string")return`"${e}"`;if(t=="symbol"){let o=e.description;return o==null?"Symbol":`Symbol(${o})`}if(t=="function"){let o=e.name;return typeof o=="string"&&o.length>0?`Function(${o})`:"Function"}if(Array.isArray(e)){let o=e.length,s="[";o>0&&(s+=lt(e[0]));for(let _=1;_<o;_++)s+=", "+lt(e[_]);return s+="]",s}let n=/\\[object ([^\\]]+)\\]/.exec(toString.call(e)),r;if(n&&n.length>1)r=n[1];else return toString.call(e);if(r=="Object")try{return"Object("+JSON.stringify(e)+")"}catch{return"Object"}return e instanceof Error?`${e.name}: ${e.message}\n${e.stack}`:r}function Ie(e){e<132||(S[e]=N,N=e)}function ke(e,t){e=e>>>0;let n=a(),r=[];for(let o=e;o<e+4*t;o+=4)r.push(g(n.getUint32(o,!0)));return r}function Se(e,t){return e=e>>>0,Fe().subarray(e/4,e/4+t)}function wt(e,t){return e=e>>>0,O().subarray(e/1,e/1+t)}function a(){return(M===null||M.buffer.detached===!0||M.buffer.detached===void 0&&M.buffer!==i.memory.buffer)&&(M=new DataView(i.memory.buffer)),M}function I(e,t){return e=e>>>0,Re(e,t)}function Fe(){return(U===null||U.byteLength===0)&&(U=new Uint32Array(i.memory.buffer)),U}function O(){return(W===null||W.byteLength===0)&&(W=new Uint8Array(i.memory.buffer)),W}function u(e){return S[e]}function T(e,t){try{return e.apply(this,t)}catch(n){i.__wbindgen_export3(f(n))}}function v(e){return e==null}function Ae(e,t,n,r){let o={a:e,b:t,cnt:1,dtor:n},s=(..._)=>{o.cnt++;let c=o.a;o.a=0;try{return r(c,o.b,..._)}finally{o.a=c,s._wbg_cb_unref()}};return s._wbg_cb_unref=()=>{--o.cnt===0&&(o.dtor(o.a,o.b),o.a=0,Ct.unregister(o))},Ct.register(s,o,o),s}function Ut(e,t){let n=t(e.length*1,1)>>>0;return O().set(e,n/1),b=e.length,n}function nt(e,t){let n=t(e.length*4,4)>>>0,r=a();for(let o=0;o<e.length;o++)r.setUint32(n+4*o,f(e[o]),!0);return b=e.length,n}function h(e,t,n){if(n===void 0){let c=q.encode(e),l=t(c.length,1)>>>0;return O().subarray(l,l+c.length).set(c),b=c.length,l}let r=e.length,o=t(r,1)>>>0,s=O(),_=0;for(;_<r;_++){let c=e.charCodeAt(_);if(c>127)break;s[o+_]=c}if(_!==r){_!==0&&(e=e.slice(_)),o=n(o,r,r=_+e.length*3,1)>>>0;let c=O().subarray(o+_,o+r),l=q.encodeInto(e,c);_+=l.written,o=n(o,r,_,1)>>>0}return b=_,o}function g(e){let t=u(e);return Ie(e),t}function Re(e,t){return ft+=t,ft>=Me&&(rt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),rt.decode(),ft=t),rt.decode(O().subarray(e,e+t))}function Ee(e,t,n){i.__wasm_bindgen_func_elem_944(e,t,f(n))}function Te(e,t,n,r){i.__wasm_bindgen_func_elem_37348(e,t,f(n),f(r))}function Oe(e){let t=i.get_font_info(f(e));return g(t)}async function Pe(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(r){if(e.ok&&Ce.has(e.type)&&e.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 e.arrayBuffer();return await WebAssembly.instantiate(n,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}}function Wt(){let e={};return e.wbg={},e.wbg.__wbg_Error_52673b7de5a0ca89=function(t,n){let r=Error(I(t,n));return f(r)},e.wbg.__wbg_Number_2d1dcfcf4ec51736=function(t){return Number(u(t))},e.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d=function(t,n){let r=u(n),o=typeof r=="bigint"?r:void 0;a().setBigInt64(t+8,v(o)?BigInt(0):o,!0),a().setInt32(t+0,!v(o),!0)},e.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b=function(t){let n=u(t),r=typeof n=="boolean"?n:void 0;return v(r)?16777215:r?1:0},e.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6=function(t,n){let r=lt(u(n)),o=h(r,i.__wbindgen_export,i.__wbindgen_export2),s=b;a().setInt32(t+4,s,!0),a().setInt32(t+0,o,!0)},e.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317=function(t,n){return u(t)in u(n)},e.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27=function(t){return typeof u(t)=="bigint"},e.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd=function(t){return typeof u(t)=="function"},e.wbg.__wbg___wbindgen_is_object_ce774f3490692386=function(t){let n=u(t);return typeof n=="object"&&n!==null},e.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030=function(t){return typeof u(t)=="string"},e.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269=function(t){return u(t)===void 0},e.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36=function(t,n){return u(t)===u(n)},e.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d=function(t,n){return u(t)==u(n)},e.wbg.__wbg___wbindgen_number_get_9619185a74197f95=function(t,n){let r=u(n),o=typeof r=="number"?r:void 0;a().setFloat64(t+8,v(o)?0:o,!0),a().setInt32(t+0,!v(o),!0)},e.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42=function(t,n){let r=u(n),o=typeof r=="string"?r:void 0;var s=v(o)?0:h(o,i.__wbindgen_export,i.__wbindgen_export2),_=b;a().setInt32(t+4,_,!0),a().setInt32(t+0,s,!0)},e.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e=function(t,n){throw new Error(I(t,n))},e.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7=function(t){u(t)._wbg_cb_unref()},e.wbg.__wbg_call_3020136f7a2d6e44=function(){return T(function(t,n,r){let o=u(t).call(u(n),u(r));return f(o)},arguments)},e.wbg.__wbg_call_78f94eb02ec7f9b2=function(){return T(function(t,n,r,o,s){let _=u(t).call(u(n),u(r),u(o),u(s));return f(_)},arguments)},e.wbg.__wbg_call_abb4ff46ce38be40=function(){return T(function(t,n){let r=u(t).call(u(n));return f(r)},arguments)},e.wbg.__wbg_done_62ea16af4ce34b24=function(t){return u(t).done},e.wbg.__wbg_entries_83c79938054e065f=function(t){let n=Object.entries(u(t));return f(n)},e.wbg.__wbg_error_7534b8e9a36f1ab4=function(t,n){let r,o;try{r=t,o=n,console.error(I(t,n))}finally{i.__wbindgen_export4(r,o,1)}},e.wbg.__wbg_error_85faeb8919b11cc6=function(t,n,r){console.error(u(t),u(n),u(r))},e.wbg.__wbg_getTimezoneOffset_45389e26d6f46823=function(t){return u(t).getTimezoneOffset()},e.wbg.__wbg_get_6b7bd52aca3f9671=function(t,n){let r=u(t)[n>>>0];return f(r)},e.wbg.__wbg_get_af9dab7e9603ea93=function(){return T(function(t,n){let r=Reflect.get(u(t),u(n));return f(r)},arguments)},e.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe=function(t,n){let r=u(t)[u(n)];return f(r)},e.wbg.__wbg_info_ce6bcc489c22f6f0=function(t){console.info(u(t))},e.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355=function(t){let n;try{n=u(t)instanceof ArrayBuffer}catch{n=!1}return n},e.wbg.__wbg_instanceof_Map_084be8da74364158=function(t){let n;try{n=u(t)instanceof Map}catch{n=!1}return n},e.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434=function(t){let n;try{n=u(t)instanceof Uint8Array}catch{n=!1}return n},e.wbg.__wbg_isArray_51fd9e6422c0a395=function(t){return Array.isArray(u(t))},e.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16=function(t){return Number.isSafeInteger(u(t))},e.wbg.__wbg_iterator_27b7c8b35ab3e86b=function(){return f(Symbol.iterator)},e.wbg.__wbg_length_22ac23eaec9d8053=function(t){return u(t).length},e.wbg.__wbg_length_d45040a40c570362=function(t){return u(t).length},e.wbg.__wbg_new_1ba21ce319a06297=function(){let t=new Object;return f(t)},e.wbg.__wbg_new_25f239778d6112b9=function(){let t=new Array;return f(t)},e.wbg.__wbg_new_6421f6084cc5bc5a=function(t){let n=new Uint8Array(u(t));return f(n)},e.wbg.__wbg_new_8a6f238a6ece86ea=function(){let t=new Error;return f(t)},e.wbg.__wbg_new_b2db8aa2650f793a=function(t){let n=new Date(u(t));return f(n)},e.wbg.__wbg_new_df1173567d5ff028=function(t,n){let r=new Error(I(t,n));return f(r)},e.wbg.__wbg_new_ff12d2b041fb48f1=function(t,n){try{var r={a:t,b:n},o=(_,c)=>{let l=r.a;r.a=0;try{return Te(l,r.b,_,c)}finally{r.a=l}};let s=new Promise(o);return f(s)}finally{r.a=r.b=0}},e.wbg.__wbg_new_from_slice_db0691b69e9d3891=function(t,n){let r=new Uint32Array(Se(t,n));return f(r)},e.wbg.__wbg_new_from_slice_f9c22b9153b26992=function(t,n){let r=new Uint8Array(wt(t,n));return f(r)},e.wbg.__wbg_new_no_args_cb138f77cf6151ee=function(t,n){let r=new Function(I(t,n));return f(r)},e.wbg.__wbg_new_with_args_df9e7125ffe55248=function(t,n,r,o){let s=new Function(I(t,n),I(r,o));return f(s)},e.wbg.__wbg_next_138a17bbf04e926c=function(t){let n=u(t).next;return f(n)},e.wbg.__wbg_next_3cfe5c0fe2a4cc53=function(){return T(function(t){let n=u(t).next();return f(n)},arguments)},e.wbg.__wbg_now_69d776cd24f5215b=function(){return Date.now()},e.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd=function(t,n,r){Uint8Array.prototype.set.call(wt(t,n),u(r))},e.wbg.__wbg_proxycontext_new=function(t){let n=C.__wrap(t);return f(n)},e.wbg.__wbg_push_7d9be8f38fc13975=function(t,n){return u(t).push(u(n))},e.wbg.__wbg_queueMicrotask_9b549dfce8865860=function(t){let n=u(t).queueMicrotask;return f(n)},e.wbg.__wbg_queueMicrotask_fca69f5bfad613a5=function(t){queueMicrotask(u(t))},e.wbg.__wbg_resolve_fd5bfbaa4ce36e1e=function(t){let n=Promise.resolve(u(t));return f(n)},e.wbg.__wbg_set_3f1d0b984ed272ed=function(t,n,r){u(t)[g(n)]=g(r)},e.wbg.__wbg_set_781438a03c0c3c81=function(){return T(function(t,n,r){return Reflect.set(u(t),u(n),u(r))},arguments)},e.wbg.__wbg_set_7df433eea03a5c14=function(t,n,r){u(t)[n>>>0]=g(r)},e.wbg.__wbg_stack_0ed75d68575b0f3c=function(t,n){let r=u(n).stack,o=h(r,i.__wbindgen_export,i.__wbindgen_export2),s=b;a().setInt32(t+4,s,!0),a().setInt32(t+0,o,!0)},e.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335=function(){let t=typeof global>"u"?null:global;return v(t)?0:f(t)},e.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1=function(){let t=typeof globalThis>"u"?null:globalThis;return v(t)?0:f(t)},e.wbg.__wbg_static_accessor_SELF_08f5a74c69739274=function(){let t=typeof self>"u"?null:self;return v(t)?0:f(t)},e.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024=function(){let t=typeof window>"u"?null:window;return v(t)?0:f(t)},e.wbg.__wbg_then_4f95312d68691235=function(t,n){let r=u(t).then(u(n));return f(r)},e.wbg.__wbg_typstcompiler_new=function(t){let n=j.__wrap(t);return f(n)},e.wbg.__wbg_typstfontresolver_new=function(t){let n=R.__wrap(t);return f(n)},e.wbg.__wbg_value_57b7b035e117f7ee=function(t){let n=u(t).value;return f(n)},e.wbg.__wbindgen_cast_2241b6af4c4b2941=function(t,n){let r=I(t,n);return f(r)},e.wbg.__wbindgen_cast_3334ea73b4b28ba3=function(t,n){let r=Ae(t,n,i.__wasm_bindgen_func_elem_957,Ee);return f(r)},e.wbg.__wbindgen_cast_4625c577ab2ec9ee=function(t){let n=BigInt.asUintN(64,t);return f(n)},e.wbg.__wbindgen_cast_9ae0607507abb057=function(t){return f(t)},e.wbg.__wbindgen_cast_d6cd19b81560fd6e=function(t){return f(t)},e.wbg.__wbindgen_object_clone_ref=function(t){let n=u(t);return f(n)},e.wbg.__wbindgen_object_drop_ref=function(t){g(t)},e}function Nt(e,t){return i=e.exports,qt.__wbindgen_wasm_module=t,M=null,U=null,W=null,i}function je(e){if(i!==void 0)return i;typeof e<"u"&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=Wt();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));let n=new WebAssembly.Instance(e,t);return Nt(n,e)}async function qt(e){if(i!==void 0)return i;typeof e<"u"&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof e>"u"&&(e=$t("typst_ts_web_compiler_bg.wasm",Be.url));let t=Wt();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await Pe(await e,t);return Nt(n,r)}function pt(e){$t=e}var Be,i,Ct,M,U,W,S,N,rt,Me,ft,q,b,Pt,dt,jt,Bt,Lt,zt,Dt,F,C,P,j,V,R,$,Ce,Vt,$t,ot=vt(()=>{Be={};Ct=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>e.dtor(e.a,e.b));M=null;U=null;W=null;S=new Array(128).fill(void 0);S.push(void 0,null,!0,!1);N=S.length;rt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});rt.decode();Me=2146435072,ft=0;q=new TextEncoder;"encodeInto"in q||(q.encodeInto=function(e,t){let n=q.encode(e);return t.set(n),{read:e.length,written:n.length}});b=0;Pt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_incrserver_free(e>>>0,1)),dt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_proxycontext_free(e>>>0,1)),jt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_typstcompileworld_free(e>>>0,1)),Bt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_typstcompiler_free(e>>>0,1)),Lt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_typstcompilerbuilder_free(e>>>0,1)),zt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_typstfontresolver_free(e>>>0,1)),Dt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>i.__wbg_typstfontresolverbuilder_free(e>>>0,1)),F=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,Pt.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Pt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_incrserver_free(t,0)}set_attach_debug_info(t){i.incrserver_set_attach_debug_info(this.__wbg_ptr,t)}current(){try{let r=i.__wbindgen_add_to_stack_pointer(-16);i.incrserver_current(r,this.__wbg_ptr);var t=a().getInt32(r+0,!0),n=a().getInt32(r+4,!0);let o;return t!==0&&(o=wt(t,n).slice(),i.__wbindgen_export4(t,n*1,1)),o}finally{i.__wbindgen_add_to_stack_pointer(16)}}reset(){i.incrserver_reset(this.__wbg_ptr)}};Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);C=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,dt.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,dt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_proxycontext_free(t,0)}constructor(t){let n=i.proxycontext_new(f(t));return this.__wbg_ptr=n>>>0,dt.register(this,this.__wbg_ptr,this),this}get context(){let t=i.proxycontext_context(this.__wbg_ptr);return g(t)}untar(t,n){try{let s=i.__wbindgen_add_to_stack_pointer(-16),_=Ut(t,i.__wbindgen_export),c=b;i.proxycontext_untar(s,this.__wbg_ptr,_,c,f(n));var r=a().getInt32(s+0,!0),o=a().getInt32(s+4,!0);if(o)throw g(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(C.prototype[Symbol.dispose]=C.prototype.free);P=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,jt.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,jt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstcompileworld_free(t,0)}compile(t,n){try{let _=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompileworld_compile(_,this.__wbg_ptr,t,n);var r=a().getInt32(_+0,!0),o=a().getInt32(_+4,!0),s=a().getInt32(_+8,!0);if(s)throw g(o);return g(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}title(t){try{let _=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompileworld_title(_,this.__wbg_ptr,t);var n=a().getInt32(_+0,!0),r=a().getInt32(_+4,!0),o=a().getInt32(_+8,!0),s=a().getInt32(_+12,!0);if(s)throw g(o);let c;return n!==0&&(c=I(n,r).slice(),i.__wbindgen_export4(n,r*1,1)),c}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_artifact(t,n){try{let _=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompileworld_get_artifact(_,this.__wbg_ptr,t,n);var r=a().getInt32(_+0,!0),o=a().getInt32(_+4,!0),s=a().getInt32(_+8,!0);if(s)throw g(o);return g(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}query(t,n,r){let o,s;try{let k=i.__wbindgen_add_to_stack_pointer(-16),L=h(n,i.__wbindgen_export,i.__wbindgen_export2),z=b;var _=v(r)?0:h(r,i.__wbindgen_export,i.__wbindgen_export2),c=b;i.typstcompileworld_query(k,this.__wbg_ptr,t,L,z,_,c);var l=a().getInt32(k+0,!0),d=a().getInt32(k+4,!0),w=a().getInt32(k+8,!0),y=a().getInt32(k+12,!0),p=l,m=d;if(y)throw p=0,m=0,g(w);return o=p,s=m,I(p,m)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export4(o,s,1)}}incr_compile(t,n){try{let _=i.__wbindgen_add_to_stack_pointer(-16);gt(t,F),i.typstcompileworld_incr_compile(_,this.__wbg_ptr,t.__wbg_ptr,n);var r=a().getInt32(_+0,!0),o=a().getInt32(_+4,!0),s=a().getInt32(_+8,!0);if(s)throw g(o);return g(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(P.prototype[Symbol.dispose]=P.prototype.free);j=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,Bt.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Bt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstcompiler_free(t,0)}reset(){try{let r=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_reset(r,this.__wbg_ptr);var t=a().getInt32(r+0,!0),n=a().getInt32(r+4,!0);if(n)throw g(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_fonts(t){try{let o=i.__wbindgen_add_to_stack_pointer(-16);gt(t,R),i.typstcompiler_set_fonts(o,this.__wbg_ptr,t.__wbg_ptr);var n=a().getInt32(o+0,!0),r=a().getInt32(o+4,!0);if(r)throw g(n)}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_inputs(t){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_set_inputs(o,this.__wbg_ptr,f(t));var n=a().getInt32(o+0,!0),r=a().getInt32(o+4,!0);if(r)throw g(n)}finally{i.__wbindgen_add_to_stack_pointer(16)}}add_source(t,n){let r=h(t,i.__wbindgen_export,i.__wbindgen_export2),o=b,s=h(n,i.__wbindgen_export,i.__wbindgen_export2),_=b;return i.typstcompiler_add_source(this.__wbg_ptr,r,o,s,_)!==0}map_shadow(t,n){let r=h(t,i.__wbindgen_export,i.__wbindgen_export2),o=b,s=Ut(n,i.__wbindgen_export),_=b;return i.typstcompiler_map_shadow(this.__wbg_ptr,r,o,s,_)!==0}unmap_shadow(t){let n=h(t,i.__wbindgen_export,i.__wbindgen_export2),r=b;return i.typstcompiler_unmap_shadow(this.__wbg_ptr,n,r)!==0}reset_shadow(){i.typstcompiler_reset_shadow(this.__wbg_ptr)}get_loaded_fonts(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_get_loaded_fonts(o,this.__wbg_ptr);var t=a().getInt32(o+0,!0),n=a().getInt32(o+4,!0),r=ke(t,n).slice();return i.__wbindgen_export4(t,n*4,4),r}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_ast(t){let n,r;try{let w=i.__wbindgen_add_to_stack_pointer(-16),y=h(t,i.__wbindgen_export,i.__wbindgen_export2),p=b;i.typstcompiler_get_ast(w,this.__wbg_ptr,y,p);var o=a().getInt32(w+0,!0),s=a().getInt32(w+4,!0),_=a().getInt32(w+8,!0),c=a().getInt32(w+12,!0),l=o,d=s;if(c)throw l=0,d=0,g(_);return n=l,r=d,I(l,d)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export4(n,r,1)}}get_semantic_token_legend(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_get_semantic_token_legend(o,this.__wbg_ptr);var t=a().getInt32(o+0,!0),n=a().getInt32(o+4,!0),r=a().getInt32(o+8,!0);if(r)throw g(n);return g(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_semantic_tokens(t,n,r){try{let y=i.__wbindgen_add_to_stack_pointer(-16),p=h(t,i.__wbindgen_export,i.__wbindgen_export2),m=b;var o=v(n)?0:h(n,i.__wbindgen_export,i.__wbindgen_export2),s=b,_=v(r)?0:h(r,i.__wbindgen_export,i.__wbindgen_export2),c=b;i.typstcompiler_get_semantic_tokens(y,this.__wbg_ptr,p,m,o,s,_,c);var l=a().getInt32(y+0,!0),d=a().getInt32(y+4,!0),w=a().getInt32(y+8,!0);if(w)throw g(d);return g(l)}finally{i.__wbindgen_add_to_stack_pointer(16)}}snapshot(t,n,r){try{let m=i.__wbindgen_add_to_stack_pointer(-16);var o=v(t)?0:h(t,i.__wbindgen_export,i.__wbindgen_export2),s=b,_=v(n)?0:h(n,i.__wbindgen_export,i.__wbindgen_export2),c=b,l=v(r)?0:nt(r,i.__wbindgen_export),d=b;i.typstcompiler_snapshot(m,this.__wbg_ptr,o,s,_,c,l,d);var w=a().getInt32(m+0,!0),y=a().getInt32(m+4,!0),p=a().getInt32(m+8,!0);if(p)throw g(y);return P.__wrap(w)}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_artifact(t,n){try{let _=i.__wbindgen_add_to_stack_pointer(-16),c=h(t,i.__wbindgen_export,i.__wbindgen_export2),l=b;i.typstcompiler_get_artifact(_,this.__wbg_ptr,c,l,n);var r=a().getInt32(_+0,!0),o=a().getInt32(_+4,!0),s=a().getInt32(_+8,!0);if(s)throw g(o);return g(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}compile(t,n,r,o){try{let p=i.__wbindgen_add_to_stack_pointer(-16);var s=v(t)?0:h(t,i.__wbindgen_export,i.__wbindgen_export2),_=b,c=v(n)?0:nt(n,i.__wbindgen_export),l=b;let m=h(r,i.__wbindgen_export,i.__wbindgen_export2),k=b;i.typstcompiler_compile(p,this.__wbg_ptr,s,_,c,l,m,k,o);var d=a().getInt32(p+0,!0),w=a().getInt32(p+4,!0),y=a().getInt32(p+8,!0);if(y)throw g(w);return g(d)}finally{i.__wbindgen_add_to_stack_pointer(16)}}query(t,n,r,o){let s,_;try{let D=i.__wbindgen_add_to_stack_pointer(-16),Qt=h(t,i.__wbindgen_export,i.__wbindgen_export2),Zt=b;var c=v(n)?0:nt(n,i.__wbindgen_export),l=b;let te=h(r,i.__wbindgen_export,i.__wbindgen_export2),ee=b;var d=v(o)?0:h(o,i.__wbindgen_export,i.__wbindgen_export2),w=b;i.typstcompiler_query(D,this.__wbg_ptr,Qt,Zt,c,l,te,ee,d,w);var y=a().getInt32(D+0,!0),p=a().getInt32(D+4,!0),m=a().getInt32(D+8,!0),k=a().getInt32(D+12,!0),L=y,z=p;if(k)throw L=0,z=0,g(m);return s=L,_=z,I(L,z)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export4(s,_,1)}}create_incr_server(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_create_incr_server(o,this.__wbg_ptr);var t=a().getInt32(o+0,!0),n=a().getInt32(o+4,!0),r=a().getInt32(o+8,!0);if(r)throw g(n);return F.__wrap(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}incr_compile(t,n,r,o){try{let w=i.__wbindgen_add_to_stack_pointer(-16),y=h(t,i.__wbindgen_export,i.__wbindgen_export2),p=b;var s=v(n)?0:nt(n,i.__wbindgen_export),_=b;gt(r,F),i.typstcompiler_incr_compile(w,this.__wbg_ptr,y,p,s,_,r.__wbg_ptr,o);var c=a().getInt32(w+0,!0),l=a().getInt32(w+4,!0),d=a().getInt32(w+8,!0);if(d)throw g(l);return g(c)}finally{i.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(j.prototype[Symbol.dispose]=j.prototype.free);V=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Lt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstcompilerbuilder_free(t,0)}constructor(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompilerbuilder_new(o);var t=a().getInt32(o+0,!0),n=a().getInt32(o+4,!0),r=a().getInt32(o+8,!0);if(r)throw g(n);return this.__wbg_ptr=t>>>0,Lt.register(this,this.__wbg_ptr,this),this}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_dummy_access_model(){try{let r=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompilerbuilder_set_dummy_access_model(r,this.__wbg_ptr);var t=a().getInt32(r+0,!0),n=a().getInt32(r+4,!0);if(n)throw g(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_access_model(t,n,r,o,s){let _=i.typstcompilerbuilder_set_access_model(this.__wbg_ptr,f(t),f(n),f(r),f(o),f(s));return g(_)}set_package_registry(t,n){let r=i.typstcompilerbuilder_set_package_registry(this.__wbg_ptr,f(t),f(n));return g(r)}add_raw_font(t){let n=i.typstcompilerbuilder_add_raw_font(this.__wbg_ptr,f(t));return g(n)}add_lazy_font(t,n){let r=i.typstcompilerbuilder_add_lazy_font(this.__wbg_ptr,f(t),f(n));return g(r)}build(){let t=this.__destroy_into_raw(),n=i.typstcompilerbuilder_build(t);return g(n)}};Symbol.dispose&&(V.prototype[Symbol.dispose]=V.prototype.free);R=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,zt.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,zt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstfontresolver_free(t,0)}};Symbol.dispose&&(R.prototype[Symbol.dispose]=R.prototype.free);$=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Dt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstfontresolverbuilder_free(t,0)}constructor(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_new(o);var t=a().getInt32(o+0,!0),n=a().getInt32(o+4,!0),r=a().getInt32(o+8,!0);if(r)throw g(n);return this.__wbg_ptr=t>>>0,Dt.register(this,this.__wbg_ptr,this),this}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_font_info(t){try{let s=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_get_font_info(s,this.__wbg_ptr,f(t));var n=a().getInt32(s+0,!0),r=a().getInt32(s+4,!0),o=a().getInt32(s+8,!0);if(o)throw g(r);return g(n)}finally{i.__wbindgen_add_to_stack_pointer(16)}}add_raw_font(t){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_add_raw_font(o,this.__wbg_ptr,f(t));var n=a().getInt32(o+0,!0),r=a().getInt32(o+4,!0);if(r)throw g(n)}finally{i.__wbindgen_add_to_stack_pointer(16)}}add_lazy_font(t,n){try{let s=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_add_lazy_font(s,this.__wbg_ptr,f(t),f(n));var r=a().getInt32(s+0,!0),o=a().getInt32(s+4,!0);if(o)throw g(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}build(){let t=this.__destroy_into_raw(),n=i.typstfontresolverbuilder_build(t);return g(n)}};Symbol.dispose&&($.prototype[Symbol.dispose]=$.prototype.free);Ce=new Set(["basic","cors","default"]);Vt=qt,$t=async function(e,t){throw new Error("Cannot import wasm module without importer: "+e+" "+t)}});var Jt={};re(Jt,{IncrServer:()=>F,ProxyContext:()=>C,TypstCompileWorld:()=>P,TypstCompiler:()=>j,TypstCompilerBuilder:()=>V,TypstFontResolver:()=>R,TypstFontResolverBuilder:()=>$,default:()=>Le,get_font_info:()=>Oe,initSync:()=>je,setImportWasmModule:()=>pt});var Le,ze,De,Ht=vt(()=>{ot();ot();ot();Le=Vt,ze=async function(e,t){let n=new Function("m","return import(m)"),{readFileSync:r}=await n("fs"),o=new URL(e,t);return await r(o).buffer},De=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;De&&pt(ze)});var It=Symbol("Comlink.proxy"),oe=Symbol("Comlink.endpoint"),ie=Symbol("Comlink.releaseProxy"),at=Symbol("Comlink.finalizer"),G=Symbol("Comlink.thrown"),kt=e=>typeof e=="object"&&e!==null||typeof e=="function",se={canHandle:e=>kt(e)&&e[It],serialize(e){let{port1:t,port2:n}=new MessageChannel;return Q(e,t),[n,[n]]},deserialize(e){return e.start(),ue(e)}},_e={canHandle:e=>kt(e)&&G in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},St=new Map([["proxy",se],["throw",_e]]);function ae(e,t){for(let n of e)if(t===n||n==="*"||n instanceof RegExp&&n.test(t))return!0;return!1}function Q(e,t=globalThis,n=["*"]){t.addEventListener("message",function r(o){if(!o||!o.data)return;if(!ae(n,o.origin)){console.warn(`Invalid origin \'${o.origin}\' for comlink proxy`);return}let{id:s,type:_,path:c}=Object.assign({path:[]},o.data),l=(o.data.argumentList||[]).map(A),d;try{let w=c.slice(0,-1).reduce((p,m)=>p[m],e),y=c.reduce((p,m)=>p[m],e);switch(_){case"GET":d=y;break;case"SET":w[c.slice(-1)[0]]=A(o.data.value),d=!0;break;case"APPLY":d=y.apply(w,l);break;case"CONSTRUCT":{let p=new y(...l);d=le(p)}break;case"ENDPOINT":{let{port1:p,port2:m}=new MessageChannel;Q(e,m),d=Z(p,[p])}break;case"RELEASE":d=void 0;break;default:return}}catch(w){d={value:w,[G]:0}}Promise.resolve(d).catch(w=>({value:w,[G]:0})).then(w=>{let[y,p]=K(w);t.postMessage(Object.assign(Object.assign({},y),{id:s}),p),_==="RELEASE"&&(t.removeEventListener("message",r),Ft(t),at in e&&typeof e[at]=="function"&&e[at]())}).catch(w=>{let[y,p]=K({value:new TypeError("Unserializable return value"),[G]:0});t.postMessage(Object.assign(Object.assign({},y),{id:s}),p)})}),t.start&&t.start()}function ce(e){return e.constructor.name==="MessagePort"}function Ft(e){ce(e)&&e.close()}function ue(e,t){let n=new Map;return e.addEventListener("message",function(o){let{data:s}=o;if(!s||!s.id)return;let _=n.get(s.id);if(_)try{_(s)}finally{n.delete(s.id)}}),ct(e,n,[],t)}function H(e){if(e)throw new Error("Proxy has been released and is not useable")}function At(e){return E(e,new Map,{type:"RELEASE"}).then(()=>{Ft(e)})}var X=new WeakMap,Y="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{let t=(X.get(e)||0)-1;X.set(e,t),t===0&&At(e)});function fe(e,t){let n=(X.get(t)||0)+1;X.set(t,n),Y&&Y.register(e,t,e)}function de(e){Y&&Y.unregister(e)}function ct(e,t,n=[],r=function(){}){let o=!1,s=new Proxy(r,{get(_,c){if(H(o),c===ie)return()=>{de(s),At(e),t.clear(),o=!0};if(c==="then"){if(n.length===0)return{then:()=>s};let l=E(e,t,{type:"GET",path:n.map(d=>d.toString())}).then(A);return l.then.bind(l)}return ct(e,t,[...n,c])},set(_,c,l){H(o);let[d,w]=K(l);return E(e,t,{type:"SET",path:[...n,c].map(y=>y.toString()),value:d},w).then(A)},apply(_,c,l){H(o);let d=n[n.length-1];if(d===oe)return E(e,t,{type:"ENDPOINT"}).then(A);if(d==="bind")return ct(e,t,n.slice(0,-1));let[w,y]=xt(l);return E(e,t,{type:"APPLY",path:n.map(p=>p.toString()),argumentList:w},y).then(A)},construct(_,c){H(o);let[l,d]=xt(c);return E(e,t,{type:"CONSTRUCT",path:n.map(w=>w.toString()),argumentList:l},d).then(A)}});return fe(s,e),s}function ge(e){return Array.prototype.concat.apply([],e)}function xt(e){let t=e.map(K);return[t.map(n=>n[0]),ge(t.map(n=>n[1]))]}var Mt=new WeakMap;function Z(e,t){return Mt.set(e,t),e}function le(e){return Object.assign(e,{[It]:!0})}function K(e){for(let[t,n]of St)if(n.canHandle(e)){let[r,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},o]}return[{type:"RAW",value:e},Mt.get(e)||[]]}function A(e){switch(e.type){case"HANDLER":return St.get(e.name).deserialize(e.value);case"RAW":return e.value}}function E(e,t,n,r){return new Promise(o=>{let s=we();t.set(s,o),e.start&&e.start(),e.postMessage(Object.assign({id:s},n),r)})}function we(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var ut=class{loadedFonts=new Set;fetcher=fetch;setFetcher(t){this.fetcher=t}async loadFonts(t,n){let r=new Function("m","return import(m)"),o=this.fetcher||=await(async function(){let{fetchBuilder:c,FileSystemCache:l}=await r("node-fetch-cache"),d=new l({cacheDirectory:".cache/typst/fonts"}),w=c.withCache(d);return function(y,p){let m=setTimeout(()=>{console.warn("font fetching is stucking:",y)},15e3);return w(y,p).finally(()=>{clearTimeout(m)})}})(),s=n.filter(c=>c instanceof Uint8Array||typeof c=="object"&&"info"in c?!0:this.loadedFonts.has(c)?!1:(this.loadedFonts.add(c),!0)),_=await Promise.all(s.map(async c=>{if(c instanceof Uint8Array){await t.add_raw_font(c);return}if(typeof c=="object"&&"info"in c){await t.add_lazy_font(c,"blob"in c?c.blob:be(c));return}return new Uint8Array(await(await o(c)).arrayBuffer())}));for(let c of _)c&&await t.add_raw_font(c)}async build(t,n,r){let o={ref:this,builder:n,hooks:r};for(let s of t?.beforeBuild??[])await s(void 0,o);return r.latelyBuild&&r.latelyBuild(o),await n.build()}};async function Rt(e,t,n,r){return await t.init(e?.getModule?.()),await new ut().build(e,new n,r)}function be(e){return()=>{let t=new XMLHttpRequest;return t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",e.url,!1),t.send(null),t.status===200&&(t.response instanceof String||typeof t.response=="string")?Uint8Array.from(t.response,n=>n.charCodeAt(0)):new Uint8Array}}var x=Symbol.for("reflexo-obj");var Et;(function(e){e[e.PIXEL_PER_PT=3]="PIXEL_PER_PT"})(Et||(Et={}));var ye=["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"],me=["InriaSerif-Bold.ttf","InriaSerif-BoldItalic.ttf","InriaSerif-Italic.ttf","InriaSerif-Regular.ttf","Roboto-Regular.ttf","NotoSerifCJKsc-Regular.otf"],he=["TwitterColorEmoji.ttf","NotoColorEmoji-Regular-COLR.subset.ttf"];function ve(e){let t=[];if(e&&e?.assets!==!1&&e?.assets?.length&&e?.assets?.length>0){let n={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/"},r=e.assetUrlPrefix??n;typeof r=="string"?r={_:r}:r={...n,...r};for(let s of Object.keys(r)){let _=r[s];_[_.length-1]!=="/"&&(r[s]=_+"/")}let o=(s,_)=>_.map(c=>(r[s]||r._)+c);for(let s of e.assets)switch(s){case"text":t.push(...o(s,ye));break;case"cjk":t.push(...o(s,me));break;case"emoji":t.push(...o(s,he));break}}return t}function tt(e,t){let n=ve(t),r=async(o,{ref:s,builder:_})=>{t?.fetcher&&s.setFetcher(t.fetcher),await s.loadFonts(_,[...e,...n])};return r._preloadRemoteFontOptions=t,r._kind="fontLoader",r}function Tt(e){return async(t,{builder:n})=>new Promise(r=>{n.set_package_registry(e,function(o){return e.resolve(o,this)}),r()})}function Ot(e){return async(t,n)=>{if(n.alreadySetAccessModel)throw new Error(`already set some assess model before: ${n.alreadySetAccessModel.constructor?.name}(${n.alreadySetAccessModel})`);return n.alreadySetAccessModel=e,new Promise(r=>{n.builder.set_access_model(e,o=>{let s=e.getMTime(o);return s?s.getTime():0},o=>e.isFile(o)||!1,o=>e.getRealPath(o)||o,o=>e.readAll(o)),r()})}}var xe=e=>{let t=!1,n;return()=>t?n:(t=!0,n=e())},et=class{wasmBin;initOnce;constructor(t){if(typeof t!="function")throw new Error("initFn is not a function");this.initOnce=xe(async()=>{await t(this.wasmBin)})}async init(t){this.wasmBin=t,await this.initOnce()}};var J;(function(e){e[e.vector=0]="vector",e[e.pdf=1]="pdf",e[e._dummy=2]="_dummy"})(J||(J={}));var bt=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)}},Gt;Gt||(Gt={});var yt=class{[x];constructor(t){this[x]=t}compile(t){return this[x].compile(0,B(t?.diagnostics))}compileHtml(t){return this[x].compile(1,B(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,B(t?.diagnostics))||{}}pdf(t){return this[x].get_artifact(1,B(t?.diagnostics))||{}}},Ue=e=>new et(async t=>await e.default(t));function mt(){return new it}var it=class e{compiler;compilerJs;static defaultAssets=["text"];constructor(){}async init(t){this.compilerJs=await(t?.getWrapper?.()||Promise.resolve().then(()=>(Ht(),Jt)));let n=this.compilerJs.TypstCompilerBuilder,r={...t||{}},o=r.beforeBuild??=[],s=o.some(d=>d._preloadRemoteFontOptions!==void 0),_=o.some(d=>d._preloadRemoteFontOptions?.assets!==void 0),c=o.some(d=>d._preloadRemoteFontOptions?.assets===!1);if((!s||!_&&!c)&&o.push(tt([],{assets:e.defaultAssets})),!o.some(d=>d._kind==="fontLoader"))throw new Error("TypstCompiler: no font loader found, please use font loaders, e.g. loadFonts or preloadSystemFonts");this.compiler=await Rt(t,Ue(this.compilerJs),n,{})}setFonts(t){this.compiler.set_fonts(t)}compile(t){return new Promise(n=>{let r=this.compiler.snapshot(t.root,t.mainFilePath,Xt(t.inputs));if("incrementalServer"in t){n(r.incr_compile(t.incrementalServer[x],B(t.diagnostics)));return}n(r.get_artifact(t.format||J.vector,B(t.diagnostics)))})}async runWithWorld(t,n){let r=this.compiler.snapshot(t.root,t.mainFilePath,Xt(t.inputs)),o=await n(new yt(r));return r.free(),o}query(t){return this.runWithWorld(t,async n=>JSON.parse(await n.query(t)))}getSemanticTokenLegend(){return new Promise(t=>{t(this.compiler.get_semantic_token_legend())})}getSemanticTokens(t){return new Promise(n=>{this.compiler.reset(),n(this.compiler.get_semantic_tokens(t.offsetEncoding||"utf-16",t.mainFilePath,t.resultId))})}async withIncrementalServer(t){let n=new bt(this.compiler.create_incr_server());try{return await t(n)}finally{n[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,n){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,n)}mapShadow(t,n){this.compiler.map_shadow(t,n)}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")}};mt._impl=it;function Xt(e){return e?Object.entries(e):void 0}function B(e){switch(e){case"none":return 1;case"unix":return 2;default:return 3}}var st=class{mTimes=new Map;mData=new Map;constructor(){}reset(){this.mTimes.clear(),this.mData.clear()}insertFile(t,n,r){this.mTimes.set(t,r),this.mData.set(t,n)}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 _t=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 n=new XMLHttpRequest;if(n.overrideMimeType("text/plain; charset=x-user-defined"),n.open("GET",this.resolvePath(t),!1),n.send(null),n.status===200&&(n.response instanceof String||typeof n.response=="string"))return Uint8Array.from(n.response,r=>r.charCodeAt(0))}resolve(t,n){if(t.namespace!=="preview")return;let r=this.resolvePath(t);if(this.cache.has(r))return this.cache.get(r)();let o=this.pullPackageData(t);if(!o)return;let s=`/@memory/fetch/packages/${t.namespace}/${t.name}/${t.version}`,_=[];n.untar(o,(l,d,w)=>{_.push([s+"/"+l,d,new Date(w)])});let c=()=>{for(let[l,d,w]of _)this.am.insertFile(l,d,w);return s};return this.cache.set(r,c),c()}};function Yt(e){return[...e].sort((t,n)=>t.path.localeCompare(n.path)||t.range.startLine-n.range.startLine||t.range.startCol-n.range.startCol||t.range.endLine-n.range.endLine||t.range.endCol-n.range.endCol||t.message.localeCompare(n.message))}var Kt="/main.typ",ht=class{#e=null;#n=new st;#r;constructor(){this.#r=new _t(this.#n)}#t(){if(!this.#e)throw new Error("Compiler not initialized");return this.#e}async init(t,n,r){this.#e=mt(),await this.#e.init({getModule:()=>t,beforeBuild:[tt(n),...r?[Ot(this.#n),Tt(this.#r)]:[]]})}async compile(t){let n=await this.#t().compile({mainFilePath:t??Kt,diagnostics:"full"}),r=Yt((n.diagnostics??[]).flatMap(s=>{let _=s.range.match(/(\\d+):(\\d+)-(\\d+):(\\d+)/);return _?[{...s,severity:s.severity,range:{startLine:+_[1],startCol:+_[2],endLine:+_[3],endCol:+_[4]}}]:(console.warn(`[typst-web-service] Skipping diagnostic with unrecognized range format: ${JSON.stringify(s.range)}`),[])})),o=n.result??void 0;return o?Z({diagnostics:r,vector:o},[o.buffer]):{diagnostics:r}}async compilePdf(t){let n=await this.#t().compile({mainFilePath:t??Kt,format:J.pdf,diagnostics:"none"});if(!n.result)throw new Error("Compilation produced no output");return Z(n.result,[n.result.buffer])}mapShadow(t,n){this.#t().mapShadow(t,n)}mapShadowMany(t){let n=this.#t();for(let[r,o]of Object.entries(t))n.mapShadow(r,o)}unmapShadow(t){this.#t().unmapShadow(t)}resetShadow(){this.#t().resetShadow()}destroy(){this.#e=null}};Q(new ht);})();\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');
18
18
  }
19
19
  function createAnalyzerWorker() {
20
- return createBlobWorker('"use strict";(()=>{var $=Symbol("Comlink.proxy"),se=Symbol("Comlink.endpoint"),_e=Symbol("Comlink.releaseProxy"),W=Symbol("Comlink.finalizer"),F=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 j(t,e),[n,[n]]},deserialize(t){return t.start(),ge(t)}},ae={canHandle:t=>G(t)&&F 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 ue(t,e){for(let n of t)if(e===n||n==="*"||n instanceof RegExp&&n.test(e))return!0;return!1}function j(t,e=globalThis,n=["*"]){e.addEventListener("message",function r(i){if(!i||!i.data)return;if(!ue(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),u;try{let f=c.slice(0,-1).reduce((g,A)=>g[A],t),d=c.reduce((g,A)=>g[A],t);switch(_){case"GET":u=d;break;case"SET":f[c.slice(-1)[0]]=p(i.data.value),u=!0;break;case"APPLY":u=d.apply(f,a);break;case"CONSTRUCT":{let g=new d(...a);u=ye(g)}break;case"ENDPOINT":{let{port1:g,port2:A}=new MessageChannel;j(t,A),u=we(g,[g])}break;case"RELEASE":u=void 0;break;default:return}}catch(f){u={value:f,[F]:0}}Promise.resolve(u).catch(f=>({value:f,[F]:0})).then(f=>{let[d,g]=I(f);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(f=>{let[d,g]=I({value:new TypeError("Unserializable return value"),[F]:0});e.postMessage(Object.assign(Object.assign({},d),{id:s}),g)})}),e.start&&e.start()}function fe(t){return t.constructor.name==="MessagePort"}function X(t){fe(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 D(t){if(t)throw new Error("Proxy has been released and is not useable")}function J(t){return m(t,new Map,{type:"RELEASE"}).then(()=>{X(t)})}var C=new WeakMap,P="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{let e=(C.get(t)||0)-1;C.set(t,e),e===0&&J(t)});function be(t,e){let n=(C.get(e)||0)+1;C.set(e,n),P&&P.register(t,e,t)}function le(t){P&&P.unregister(t)}function N(t,e,n=[],r=function(){}){let i=!1,s=new Proxy(r,{get(_,c){if(D(i),c===_e)return()=>{le(s),J(t),e.clear(),i=!0};if(c==="then"){if(n.length===0)return{then:()=>s};let a=m(t,e,{type:"GET",path:n.map(u=>u.toString())}).then(p);return a.then.bind(a)}return N(t,e,[...n,c])},set(_,c,a){D(i);let[u,f]=I(a);return m(t,e,{type:"SET",path:[...n,c].map(d=>d.toString()),value:u},f).then(p)},apply(_,c,a){D(i);let u=n[n.length-1];if(u===se)return m(t,e,{type:"ENDPOINT"}).then(p);if(u==="bind")return N(t,e,n.slice(0,-1));let[f,d]=H(a);return m(t,e,{type:"APPLY",path:n.map(g=>g.toString()),argumentList:f},d).then(p)},construct(_,c){D(i);let[a,u]=H(c);return m(t,e,{type:"CONSTRUCT",path:n.map(f=>f.toString()),argumentList:a},u).then(p)}});return be(s,t),s}function de(t){return Array.prototype.concat.apply([],t)}function H(t){let e=t.map(I);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 I(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 m(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 O(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 B(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+=B(t[0]));for(let _=1;_<i;_++)s+=", "+B(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 h=null;function l(){return(h===null||h.buffer.detached===!0||h.buffer.detached===void 0&&h.buffer!==o.memory.buffer)&&(h=new DataView(o.memory.buffer)),h}function b(t,e){return t=t>>>0,Ee(t,e)}var M=null;function E(){return(M===null||M.byteLength===0)&&(M=new Uint8Array(o.memory.buffer)),M}function v(t,e){try{return t.apply(this,e)}catch(n){let r=O(n);o.__wbindgen_exn_store(r)}}function w(t){return t==null}function me(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 ve(t,e){let n=e(t.length*1,1)>>>0;return E().set(t,n/1),y=t.length,n}function x(t,e,n){if(n===void 0){let c=R.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=R.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 z=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});z.decode();var xe=2146435072,U=0;function Ee(t,e){return U+=e,U>=xe&&(z=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),z.decode(),U=e),z.decode(E().subarray(t,t+e))}var R=new TextEncoder;"encodeInto"in R||(R.encodeInto=function(t,e){let n=R.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)),k=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&&(k.prototype[Symbol.dispose]=k.prototype.free);var L=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&&(L.prototype[Symbol.dispose]=L.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=ve(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=x(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=x(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 Oe=new Set(["basic","cors","default"]);async function Me(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&&Oe.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 Re(){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=x(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=B(n),i=x(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:x(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 v(function(e,n,r){return e.call(n,r)},arguments)},t.wbg.__wbg_call_78f94eb02ec7f9b2=function(){return v(function(e,n,r,i,s){return e.call(n,r,i,s)},arguments)},t.wbg.__wbg_call_abb4ff46ce38be40=function(){return v(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 v(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 k.__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 v(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 v(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=x(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:O(e)},t.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1=function(){let e=typeof globalThis>"u"?null:globalThis;return w(e)?0:O(e)},t.wbg.__wbg_static_accessor_SELF_08f5a74c69739274=function(){let e=typeof self>"u"?null:self;return w(e)?0:O(e)},t.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024=function(){let e=typeof window>"u"?null:window;return w(e)?0:O(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 me(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 ke(t,e){return o=t.exports,ie.__wbindgen_wasm_module=e,h=null,M=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=Re();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:n,module:r}=await Me(await t,e);return ke(n,r)}var oe=ie;var V=class{server=null;events=[];ensureServer(){if(!this.server)throw new Error("Analyzer not initialized");return this.server}notifyDidOpen(e,n){this.ensureServer().on_notification("textDocument/didOpen",{textDocument:{uri:e,languageId:"typst",version:1,text:n}})}notifyDidClose(e){this.ensureServer().on_notification("textDocument/didClose",{textDocument:{uri:e}})}notifyDidChange(e,n,r){this.ensureServer().on_notification("textDocument/didChange",{textDocument:{uri:e,version:n},contentChanges:[{text:r}]})}flushEvents(){if(this.server)for(;this.events.length>0;)for(let e of this.events.splice(0))this.server.on_event(e)}async init(e){await oe({module_or_path:e}),this.server=new S({sendEvent:r=>{this.events.push(r)},sendRequest:({id:r})=>{this.server.on_response({id:r,result:null})},sendNotification:()=>{},resolveFn:()=>{}});let n=this.server.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.flushEvents(),this.server.on_notification("initialized",{}),this.flushEvents()}async didOpen(e,n){this.notifyDidOpen(e,n),this.flushEvents()}async didClose(e){this.notifyDidClose(e),this.flushEvents()}async didChange(e,n,r){this.notifyDidChange(e,n,r),this.flushEvents()}async didChangeMany(e,n){this.ensureServer();for(let{uri:r,content:i}of e)this.notifyDidOpen(r,i);for(let{uri:r,version:i,content:s}of n)this.notifyDidChange(r,i,s);this.flushEvents()}async didCloseMany(e){this.ensureServer();for(let n of e)this.notifyDidClose(n);this.flushEvents()}async completion(e,n,r){let i=this.ensureServer().on_request("textDocument/completion",{textDocument:{uri:e},position:{line:n,character:r}}),s=i&&typeof i=="object"&&"then"in i?await i:i;return this.flushEvents(),s??null}async hover(e,n,r){let i=this.ensureServer().on_request("textDocument/hover",{textDocument:{uri:e},position:{line:n,character:r}}),s=i&&typeof i=="object"&&"then"in i?await i:i;return this.flushEvents(),s??null}destroy(){this.server?.free(),this.server=null}};j(new V);})();\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');
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
22
 
23
23
  // src/analyzer.ts
@@ -25,7 +25,11 @@ var TypstAnalyzer = class _TypstAnalyzer {
25
25
  proxy;
26
26
  worker;
27
27
  versionCounter = 0;
28
- openedUris = /* @__PURE__ */ new Set();
28
+ /**
29
+ * Last content pushed to the worker per URI. Presence is the source of
30
+ * truth for "is this URI opened on the worker?"; value drives own-RPC dedup.
31
+ */
32
+ content = /* @__PURE__ */ new Map();
29
33
  constructor(worker, proxy) {
30
34
  this.worker = worker;
31
35
  this.proxy = proxy;
@@ -39,37 +43,42 @@ var TypstAnalyzer = class _TypstAnalyzer {
39
43
  return analyzer;
40
44
  }
41
45
  async didOpen(uri, content) {
42
- this.openedUris.add(uri);
46
+ this.content.set(uri, content);
43
47
  await this.proxy.didOpen(uri, content);
44
48
  }
45
49
  async didClose(uri) {
46
- if (!this.openedUris.delete(uri)) return;
50
+ if (!this.content.delete(uri)) return;
47
51
  await this.proxy.didClose(uri);
48
52
  }
49
53
  /**
50
- * Notify the analyzer that a document has changed.
54
+ * Notify the analyzer that a document has changed. Skips the RPC when the
55
+ * content matches what the worker last saw.
51
56
  */
52
57
  async didChange(uri, content) {
53
- if (!this.openedUris.has(uri)) {
58
+ if (!this.content.has(uri)) {
54
59
  await this.didOpen(uri, content);
55
60
  return;
56
61
  }
62
+ if (this.content.get(uri) === content) return;
63
+ this.content.set(uri, content);
57
64
  const version = ++this.versionCounter;
58
65
  await this.proxy.didChange(uri, version, content);
59
66
  }
60
67
  /**
61
68
  * Batch document changes. Splits inputs into opens (first-time URIs) and
62
69
  * changes (already-open URIs) and sends them in a single worker roundtrip.
70
+ * Skips unchanged documents; returns without an RPC if nothing is pending.
63
71
  */
64
72
  async didChangeMany(docs) {
65
73
  const opens = [];
66
74
  const changes = [];
67
75
  for (const [uri, content] of Object.entries(docs)) {
68
- if (this.openedUris.has(uri)) {
69
- changes.push({ uri, version: ++this.versionCounter, content });
70
- } else {
76
+ if (!this.content.has(uri)) {
71
77
  opens.push({ uri, content });
72
- this.openedUris.add(uri);
78
+ this.content.set(uri, content);
79
+ } else if (this.content.get(uri) !== content) {
80
+ changes.push({ uri, version: ++this.versionCounter, content });
81
+ this.content.set(uri, content);
73
82
  }
74
83
  }
75
84
  if (opens.length === 0 && changes.length === 0) return;
@@ -82,16 +91,52 @@ var TypstAnalyzer = class _TypstAnalyzer {
82
91
  async didCloseMany(uris) {
83
92
  const toClose = [];
84
93
  for (const uri of uris) {
85
- if (this.openedUris.delete(uri)) toClose.push(uri);
94
+ if (this.content.delete(uri)) toClose.push(uri);
86
95
  }
87
96
  if (toClose.length === 0) return;
88
97
  await this.proxy.didCloseMany(toClose);
89
98
  }
90
- async completion(uri, line, character) {
91
- return this.proxy.completion(uri, line, character);
99
+ /**
100
+ * Request completion at `position` for `uri`, with `content` as the current
101
+ * document state. Bundles the didChange notification with the request in one
102
+ * worker roundtrip; degrades to a plain completion request when the worker
103
+ * already has this exact content.
104
+ */
105
+ async completion(uri, content, position) {
106
+ if (this.content.get(uri) === content) {
107
+ return this.proxy.completion(uri, position);
108
+ }
109
+ const isOpen = this.content.has(uri);
110
+ this.content.set(uri, content);
111
+ const version = ++this.versionCounter;
112
+ return this.proxy.completionWithDoc(
113
+ uri,
114
+ version,
115
+ content,
116
+ position,
117
+ isOpen ? "change" : "open"
118
+ );
92
119
  }
93
- async hover(uri, line, character) {
94
- return this.proxy.hover(uri, line, character);
120
+ /**
121
+ * Request hover at `position` for `uri`, with `content` as the current
122
+ * document state. Bundles the didChange notification with the request in one
123
+ * worker roundtrip; degrades to a plain hover request when the worker
124
+ * already has this exact content.
125
+ */
126
+ async hover(uri, content, position) {
127
+ if (this.content.get(uri) === content) {
128
+ return this.proxy.hover(uri, position);
129
+ }
130
+ const isOpen = this.content.has(uri);
131
+ this.content.set(uri, content);
132
+ const version = ++this.versionCounter;
133
+ return this.proxy.hoverWithDoc(
134
+ uri,
135
+ version,
136
+ content,
137
+ position,
138
+ isOpen ? "change" : "open"
139
+ );
95
140
  }
96
141
  destroy() {
97
142
  this.proxy[Comlink.releaseProxy]();
@@ -99,11 +144,7 @@ var TypstAnalyzer = class _TypstAnalyzer {
99
144
  }
100
145
  };
101
146
 
102
- // src/uri.ts
103
- function normalizeUntitledUri(uri) {
104
- if (!uri.startsWith("untitled:")) return uri;
105
- return `untitled:${uri.slice("untitled:".length).replace(/^\/+/, "")}`;
106
- }
147
+ // src/identifiers.ts
107
148
  function normalizePath(path) {
108
149
  return path.startsWith("/") ? path : `/${path}`;
109
150
  }
@@ -111,24 +152,23 @@ function normalizeRoot(rootPath) {
111
152
  const root = normalizePath(rootPath);
112
153
  return root === "/" ? "" : root.replace(/\/+$/, "");
113
154
  }
155
+ function pathToAnalyzerUri(path, root) {
156
+ const bare = root.replace(/^\//, "");
157
+ return `untitled:${bare}${normalizePath(path)}`;
158
+ }
114
159
 
115
160
  // src/compiler.ts
116
161
  import * as Comlink2 from "comlink";
117
162
  var DEFAULT_FONTS = [
118
163
  "https://cdn.jsdelivr.net/npm/roboto-font@0.1.0/fonts/Roboto/roboto-regular-webfont.ttf"
119
164
  ];
120
- var DEFAULT_WASM_URL = "https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-web-compiler@0.7.0-rc2/pkg/typst_ts_web_compiler_bg.wasm";
121
- var DEFAULT_ENTRY = "/main.typ";
122
- function toFiles(source, entry) {
123
- if (source === void 0) return void 0;
124
- return typeof source === "string" ? { [entry ?? DEFAULT_ENTRY]: source } : source;
125
- }
165
+ var DEFAULT_WASM_URL = `https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-web-compiler@${"0.7.0-rc2"}/pkg/typst_ts_web_compiler_bg.wasm`;
126
166
  var TypstCompiler = class _TypstCompiler {
127
167
  proxy;
128
168
  worker;
129
169
  encoder = new TextEncoder();
130
- /** The most recent vector artifact from a compile, if any. */
131
- lastVector;
170
+ /** Last text content pushed per path. Drives own-RPC dedup. Invalidated by binary writes. */
171
+ content = /* @__PURE__ */ new Map();
132
172
  constructor(worker, proxy) {
133
173
  this.worker = worker;
134
174
  this.proxy = proxy;
@@ -144,27 +184,28 @@ var TypstCompiler = class _TypstCompiler {
144
184
  return new _TypstCompiler(worker, proxy);
145
185
  }
146
186
  /**
147
- * Compile. Pass a source string (written to the entry path) or a map of
148
- * files to register before compiling; omit to compile whatever is currently
149
- * in the VFS (populated via setText/setBinary/setJson/setMany).
150
- * Defaults to compiling "/main.typ"; override with `entry`.
187
+ * Compile whatever is currently in the VFS (populated via
188
+ * setText/setBinary/setJson/setMany). Defaults to compiling "/main.typ";
189
+ * override with `entry`.
151
190
  */
152
- async compile(source, entry) {
153
- const result = await this.proxy.compile(toFiles(source, entry), entry);
154
- if (result.vector) this.lastVector = result.vector;
155
- return result;
191
+ compile(entry) {
192
+ return this.proxy.compile(entry);
156
193
  }
157
194
  /**
158
- * Compile to PDF. Pass a source string (written to the entry path) or a map
159
- * of files to register before compiling; omit to compile whatever is
160
- * currently in the VFS (populated via setText/setBinary/setJson/setMany).
161
- * Defaults to compiling "/main.typ"; override with `entry`.
195
+ * Compile to PDF. Operates on whatever is currently in the VFS (populated
196
+ * via setText/setBinary/setJson/setMany). Defaults to compiling "/main.typ";
197
+ * override with `entry`.
162
198
  */
163
- compilePdf(source, entry) {
164
- return this.proxy.compilePdf(toFiles(source, entry), entry);
199
+ compilePdf(entry) {
200
+ return this.proxy.compilePdf(entry);
165
201
  }
166
- /** Add or overwrite a text file in the virtual compiler filesystem. */
167
- setText(path, source) {
202
+ /**
203
+ * Add or overwrite a text file in the virtual compiler filesystem. Skips
204
+ * the worker RPC when `source` matches the last value pushed for `path`.
205
+ */
206
+ async setText(path, source) {
207
+ if (this.content.get(path) === source) return;
208
+ this.content.set(path, source);
168
209
  return this.proxy.mapShadow(path, this.encoder.encode(source));
169
210
  }
170
211
  /** Add or overwrite a JSON file in the virtual compiler filesystem. */
@@ -173,18 +214,28 @@ var TypstCompiler = class _TypstCompiler {
173
214
  }
174
215
  /**
175
216
  * Add or overwrite multiple files in the virtual compiler filesystem in a
176
- * single worker roundtrip. Strings are UTF-8 encoded; Uint8Arrays are passed
177
- * through.
217
+ * single worker roundtrip. Strings are UTF-8 encoded; Uint8Arrays are
218
+ * passed through. Text entries unchanged since their last push are skipped;
219
+ * binary entries always push and invalidate the text cache for their path.
178
220
  */
179
- setMany(files) {
221
+ async setMany(files) {
180
222
  const encoded = {};
181
223
  for (const [path, content] of Object.entries(files)) {
182
- encoded[path] = typeof content === "string" ? this.encoder.encode(content) : content;
224
+ if (typeof content === "string") {
225
+ if (this.content.get(path) === content) continue;
226
+ this.content.set(path, content);
227
+ encoded[path] = this.encoder.encode(content);
228
+ } else {
229
+ this.content.delete(path);
230
+ encoded[path] = content;
231
+ }
183
232
  }
233
+ if (Object.keys(encoded).length === 0) return;
184
234
  return this.proxy.mapShadowMany(encoded);
185
235
  }
186
236
  /** Add or overwrite a binary file in the virtual compiler filesystem. */
187
237
  setBinary(path, content) {
238
+ this.content.delete(path);
188
239
  const bytes = content instanceof ArrayBuffer ? new Uint8Array(content) : new Uint8Array(
189
240
  content.buffer,
190
241
  content.byteOffset,
@@ -194,10 +245,12 @@ var TypstCompiler = class _TypstCompiler {
194
245
  }
195
246
  /** Remove a file from the virtual compiler filesystem. */
196
247
  remove(path) {
248
+ this.content.delete(path);
197
249
  return this.proxy.unmapShadow(path);
198
250
  }
199
251
  /** Clear all virtual files from the compiler filesystem. */
200
252
  clear() {
253
+ this.content.clear();
201
254
  return this.proxy.resetShadow();
202
255
  }
203
256
  destroy() {
@@ -240,87 +293,209 @@ var TypstFormatter = class _TypstFormatter {
240
293
  }
241
294
  };
242
295
 
296
+ // src/compile-scheduler.ts
297
+ var CompileScheduler = class {
298
+ constructor(options = {}) {
299
+ this.options = options;
300
+ }
301
+ debounceTimer = null;
302
+ throttleTimer = null;
303
+ lastFireTime = 0;
304
+ schedule(callback) {
305
+ if (this.debounceTimer) {
306
+ clearTimeout(this.debounceTimer);
307
+ this.debounceTimer = null;
308
+ }
309
+ const delay = Math.max(0, this.options.debounceDelay ?? 0);
310
+ this.debounceTimer = setTimeout(() => {
311
+ this.debounceTimer = null;
312
+ this.fire(callback);
313
+ }, delay);
314
+ const throttle = this.options.throttleDelay;
315
+ if (throttle != null && throttle > 0 && !this.throttleTimer) {
316
+ const wait = Math.max(
317
+ 0,
318
+ throttle - (performance.now() - this.lastFireTime)
319
+ );
320
+ this.throttleTimer = setTimeout(() => {
321
+ this.throttleTimer = null;
322
+ if (this.debounceTimer) {
323
+ clearTimeout(this.debounceTimer);
324
+ this.debounceTimer = null;
325
+ this.fire(callback);
326
+ }
327
+ }, wait);
328
+ }
329
+ }
330
+ /** Cancel any pending scheduled fire without calling the callback. */
331
+ cancel() {
332
+ if (this.debounceTimer) {
333
+ clearTimeout(this.debounceTimer);
334
+ this.debounceTimer = null;
335
+ }
336
+ if (this.throttleTimer) {
337
+ clearTimeout(this.throttleTimer);
338
+ this.throttleTimer = null;
339
+ }
340
+ }
341
+ fire(callback) {
342
+ this.lastFireTime = performance.now();
343
+ callback();
344
+ }
345
+ };
346
+
243
347
  // src/project.ts
244
- var DEFAULT_ENTRY2 = "/main.typ";
348
+ var DEFAULT_ENTRY = "/main.typ";
245
349
  var DEFAULT_ROOT = "/project";
350
+ function errorAsCompileResult(err, paths) {
351
+ const message = err instanceof Error ? err.message : String(err);
352
+ return {
353
+ diagnostics: paths.map((path) => ({
354
+ package: "",
355
+ path,
356
+ severity: "Error",
357
+ range: { startLine: 0, startCol: 0, endLine: 0, endCol: 1 },
358
+ message
359
+ }))
360
+ };
361
+ }
246
362
  var TypstProject = class {
247
363
  compiler;
248
364
  analyzer;
249
- rootPath;
250
- trackedTextPaths = /* @__PURE__ */ new Set();
251
- /** Last content written via setText/setMany, per path. Used to skip redundant writes to compiler + analyzer. */
252
- lastSyncedContent = /* @__PURE__ */ new Map();
365
+ analyzerUriRoot;
366
+ /**
367
+ * Tracked text files: path latest content observed. Presence in this map
368
+ * is the source of truth for "is this a tracked text file?"; insertion
369
+ * order drives the `files` getter. Per-sink dedup lives in the compiler and
370
+ * analyzer.
371
+ */
372
+ contentByPath = /* @__PURE__ */ new Map();
373
+ compileListeners = /* @__PURE__ */ new Set();
374
+ scheduler;
375
+ compileVersion = 0;
376
+ _lastResult;
253
377
  _entry;
378
+ destroyed = false;
254
379
  constructor(options) {
255
380
  this.compiler = options.compiler;
256
381
  this.analyzer = options.analyzer;
257
- this.rootPath = normalizeRoot(options.rootPath ?? DEFAULT_ROOT);
258
- this._entry = normalizePath(options.entry ?? DEFAULT_ENTRY2);
382
+ this.analyzerUriRoot = normalizeRoot(
383
+ options.analyzerUriRoot ?? DEFAULT_ROOT
384
+ );
385
+ this._entry = normalizePath(options.entry ?? DEFAULT_ENTRY);
386
+ this.scheduler = new CompileScheduler({
387
+ debounceDelay: options.compileDebounceMs,
388
+ throttleDelay: options.compileThrottleMs
389
+ });
390
+ }
391
+ /**
392
+ * Schedule an auto-compile after VFS mutations. Coalesces rapid calls via
393
+ * the configured debounce/throttle. Errors surface through `onCompile`
394
+ * listeners via a synthetic diagnostic; callers awaiting a specific compile
395
+ * should call `compile()` directly.
396
+ */
397
+ scheduleCompile() {
398
+ if (this.destroyed) return;
399
+ this.scheduler.schedule(() => {
400
+ this.compile().catch((err) => console.error("[typst]", err));
401
+ });
259
402
  }
260
- /** Current entry file path. */
403
+ /** Current entry file path. Assign to change the sticky entry used by subsequent `compile()` calls. */
261
404
  get entry() {
262
405
  return this._entry;
263
406
  }
407
+ set entry(path) {
408
+ const next = normalizePath(path);
409
+ if (next === this._entry) return;
410
+ this._entry = next;
411
+ this.scheduleCompile();
412
+ }
264
413
  /** Whether an analyzer is attached. */
265
414
  get hasAnalyzer() {
266
415
  return this.analyzer !== void 0;
267
416
  }
268
- /** Change the sticky entry file used by subsequent compile() calls. */
269
- setEntry(path) {
270
- this._entry = normalizePath(path);
417
+ /**
418
+ * Most recent compile result, or `undefined` before the first compile has
419
+ * settled. Useful for lazy-mounted UI that subscribes after boot and needs
420
+ * an initial value.
421
+ */
422
+ get lastResult() {
423
+ return this._lastResult;
424
+ }
425
+ /**
426
+ * Snapshot of tracked text file paths, in insertion order. Updated by
427
+ * `setText`, `setMany`, `remove`, and `clear`. Returns a fresh array — mutate
428
+ * freely without affecting project state.
429
+ */
430
+ get files() {
431
+ return [...this.contentByPath.keys()];
432
+ }
433
+ /**
434
+ * Current text content for a tracked file, or `undefined` if the path was
435
+ * never written via `setText`/`setMany` (or was removed). Read-through to the
436
+ * project's sync cache — lets consumers avoid shadowing the VFS themselves.
437
+ */
438
+ getText(path) {
439
+ return this.contentByPath.get(normalizePath(path));
271
440
  }
272
441
  /**
273
442
  * Add or overwrite a text file. Goes to the compiler's VFS and, when an
274
- * analyzer is attached, to the analyzer as a document change. Redundant
275
- * calls with unchanged content are skipped.
443
+ * analyzer is attached, to the analyzer as a document change. No-op when
444
+ * the tracked path already has this exact content skips both worker RPCs
445
+ * and the auto-scheduled compile.
276
446
  */
277
447
  async setText(path, content) {
278
448
  const p = normalizePath(path);
279
- this.trackedTextPaths.add(p);
280
- if (this.lastSyncedContent.get(p) === content) return;
281
- this.lastSyncedContent.set(p, content);
282
- const ops = [this.compiler.setText(p, content)];
283
- if (this.analyzer) {
284
- ops.push(this.analyzer.didChange(this.toUri(p), content));
285
- }
286
- await Promise.all(ops);
449
+ if (this.contentByPath.get(p) === content) return;
450
+ this.contentByPath.set(p, content);
451
+ await Promise.all([
452
+ this.compiler.setText(p, content),
453
+ this.analyzer?.didChange(
454
+ pathToAnalyzerUri(p, this.analyzerUriRoot),
455
+ content
456
+ ) ?? Promise.resolve()
457
+ ]);
458
+ this.scheduleCompile();
287
459
  }
288
460
  /**
289
461
  * Add or overwrite a JSON file. Compiler-only — the analyzer does not track
290
462
  * data files.
291
463
  */
292
- setJson(path, value) {
293
- return this.compiler.setJson(normalizePath(path), value);
464
+ async setJson(path, value) {
465
+ await this.compiler.setJson(normalizePath(path), value);
466
+ this.scheduleCompile();
294
467
  }
295
468
  /** Add or overwrite a binary file. Compiler-only. */
296
- setBinary(path, content) {
297
- return this.compiler.setBinary(normalizePath(path), content);
469
+ async setBinary(path, content) {
470
+ await this.compiler.setBinary(normalizePath(path), content);
471
+ this.scheduleCompile();
298
472
  }
299
473
  /**
300
474
  * Batch set multiple files. Strings route to both compiler and analyzer;
301
- * Uint8Array entries go to the compiler only.
475
+ * Uint8Array entries go to the compiler only. Strings matching the last
476
+ * tracked content for their path are skipped on both sinks. Binary entries
477
+ * always go through (no content cache, so no dedup).
302
478
  */
303
479
  async setMany(files) {
304
480
  const normalized = {};
481
+ const analyzerDocs = {};
305
482
  for (const [path, content] of Object.entries(files)) {
306
- normalized[normalizePath(path)] = content;
307
- }
308
- const compilerOp = this.compiler.setMany(normalized);
309
- const analyzerOp = (async () => {
310
- if (!this.analyzer) return;
311
- const docs = {};
312
- for (const [path, content] of Object.entries(normalized)) {
313
- if (typeof content !== "string") continue;
314
- this.trackedTextPaths.add(path);
315
- if (this.lastSyncedContent.get(path) === content) continue;
316
- this.lastSyncedContent.set(path, content);
317
- docs[this.toUri(path)] = content;
483
+ const p = normalizePath(path);
484
+ if (typeof content !== "string") {
485
+ normalized[p] = content;
486
+ continue;
318
487
  }
319
- if (Object.keys(docs).length > 0) {
320
- await this.analyzer.didChangeMany(docs);
321
- }
322
- })();
323
- await Promise.all([compilerOp, analyzerOp]);
488
+ if (this.contentByPath.get(p) === content) continue;
489
+ this.contentByPath.set(p, content);
490
+ normalized[p] = content;
491
+ analyzerDocs[pathToAnalyzerUri(p, this.analyzerUriRoot)] = content;
492
+ }
493
+ if (Object.keys(normalized).length === 0) return;
494
+ await Promise.all([
495
+ this.compiler.setMany(normalized),
496
+ this.analyzer?.didChangeMany(analyzerDocs) ?? Promise.resolve()
497
+ ]);
498
+ this.scheduleCompile();
324
499
  }
325
500
  /**
326
501
  * Remove a file. Always removed from the compiler's VFS; also closed on the
@@ -328,30 +503,82 @@ var TypstProject = class {
328
503
  */
329
504
  async remove(path) {
330
505
  const p = normalizePath(path);
331
- const wasText = this.trackedTextPaths.delete(p);
332
- this.lastSyncedContent.delete(p);
333
- const ops = [this.compiler.remove(p)];
334
- if (this.analyzer && wasText) {
335
- ops.push(this.analyzer.didClose(this.toUri(p)));
336
- }
337
- await Promise.all(ops);
506
+ const wasText = this.contentByPath.delete(p);
507
+ await Promise.all([
508
+ this.compiler.remove(p),
509
+ wasText ? this.analyzer?.didClose(pathToAnalyzerUri(p, this.analyzerUriRoot)) : void 0
510
+ ]);
511
+ this.scheduleCompile();
338
512
  }
339
513
  /** Clear all files from both compiler VFS and analyzer document set. */
340
514
  async clear() {
341
- const uris = Array.from(this.trackedTextPaths, (p) => this.toUri(p));
342
- this.trackedTextPaths.clear();
343
- this.lastSyncedContent.clear();
344
- const compilerOp = this.compiler.clear();
345
- const analyzerOp = this.analyzer && uris.length > 0 ? this.analyzer.didCloseMany(uris) : Promise.resolve();
346
- await Promise.all([compilerOp, analyzerOp]);
515
+ const uris = Array.from(
516
+ this.contentByPath.keys(),
517
+ (p) => pathToAnalyzerUri(p, this.analyzerUriRoot)
518
+ );
519
+ this.contentByPath.clear();
520
+ await Promise.all([
521
+ this.compiler.clear(),
522
+ uris.length > 0 ? this.analyzer?.didCloseMany(uris) : void 0
523
+ ]);
524
+ this.scheduleCompile();
525
+ }
526
+ /**
527
+ * Subscribe to compile results. Fires after every `compile()` whose result is
528
+ * still current (stale results from out-of-order concurrent compiles are
529
+ * dropped). If a compile has already settled, the most recent result is
530
+ * delivered synchronously so late-mounted listeners aren't stuck blank until
531
+ * the next compile. Returns an unsubscribe function.
532
+ */
533
+ onCompile(listener) {
534
+ this.compileListeners.add(listener);
535
+ if (this._lastResult !== void 0) {
536
+ try {
537
+ listener(this._lastResult);
538
+ } catch (err) {
539
+ console.error("[typst] compile listener threw:", err);
540
+ }
541
+ }
542
+ return () => {
543
+ this.compileListeners.delete(listener);
544
+ };
347
545
  }
348
- /** Compile the current VFS state using the sticky entry. */
349
- compile() {
350
- return this.compiler.compile(void 0, this._entry);
546
+ /**
547
+ * Compile the current VFS state using the sticky entry. Errors from the
548
+ * underlying compiler are converted into a synthetic error diagnostic so
549
+ * callers and listeners always receive a `CompileResult`. Listeners are
550
+ * notified only for the most recent compile — results from an earlier call
551
+ * that resolves after a later one are suppressed.
552
+ *
553
+ * VFS mutations (`setText`, `remove`, etc.) auto-schedule a debounced
554
+ * compile; call this directly only when you need an awaitable handle on the
555
+ * result (e.g., to flush before rendering to PDF).
556
+ */
557
+ async compile() {
558
+ this.scheduler.cancel();
559
+ const version = ++this.compileVersion;
560
+ let result;
561
+ try {
562
+ result = await this.compiler.compile(this._entry);
563
+ } catch (err) {
564
+ const paths = this.contentByPath.size > 0 ? [...this.contentByPath.keys()] : [this._entry];
565
+ result = errorAsCompileResult(err, paths);
566
+ }
567
+ if (version === this.compileVersion) {
568
+ this._lastResult = result;
569
+ for (const listener of this.compileListeners) {
570
+ try {
571
+ listener(result);
572
+ } catch (err) {
573
+ console.error("[typst] compile listener threw:", err);
574
+ }
575
+ }
576
+ }
577
+ return result;
351
578
  }
352
579
  /** Compile the current VFS state to PDF using the sticky entry. */
353
580
  compilePdf() {
354
- return this.compiler.compilePdf(void 0, this._entry);
581
+ return this.compiler.compilePdf(this._entry);
355
582
  }
356
583
  requireAnalyzer(operation) {
357
584
  if (!this.analyzer) {
@@ -359,30 +586,61 @@ var TypstProject = class {
359
586
  }
360
587
  return this.analyzer;
361
588
  }
362
- /** Request completions at the given position. Throws when no analyzer is attached. */
363
- completion(path, line, character) {
364
- return this.requireAnalyzer("completion").completion(
365
- this.toUri(normalizePath(path)),
366
- line,
367
- character
589
+ /**
590
+ * Request completion for `path` at `position`, using `source` as the
591
+ * current document state. One analyzer roundtrip; compiler is not touched —
592
+ * the compile sync path writes to the compiler separately. Throws when no
593
+ * analyzer is attached.
594
+ */
595
+ completion(path, source, position) {
596
+ const analyzer = this.requireAnalyzer("completion");
597
+ const p = normalizePath(path);
598
+ this.contentByPath.set(p, source);
599
+ return analyzer.completion(
600
+ pathToAnalyzerUri(p, this.analyzerUriRoot),
601
+ source,
602
+ position
368
603
  );
369
604
  }
370
- /** Request hover info at the given position. Throws when no analyzer is attached. */
371
- hover(path, line, character) {
372
- return this.requireAnalyzer("hover").hover(
373
- this.toUri(normalizePath(path)),
374
- line,
375
- character
605
+ /**
606
+ * Request hover for `path` at `position`, using `source` as the current
607
+ * document state. One analyzer roundtrip; compiler is not touched. Throws
608
+ * when no analyzer is attached.
609
+ */
610
+ hover(path, source, position) {
611
+ const analyzer = this.requireAnalyzer("hover");
612
+ const p = normalizePath(path);
613
+ this.contentByPath.set(p, source);
614
+ return analyzer.hover(
615
+ pathToAnalyzerUri(p, this.analyzerUriRoot),
616
+ source,
617
+ position
376
618
  );
377
619
  }
378
- toUri(path) {
379
- const root = this.rootPath.replace(/^\//, "");
380
- return `untitled:${root}${normalizePath(path)}`;
620
+ /**
621
+ * Tear down the project and the services it owns. Destroys the attached
622
+ * compiler and analyzer, drops all listeners, and clears VFS tracking state.
623
+ * Idempotent — calling twice is a no-op. After destruction, further calls on
624
+ * the project are not supported; construct a new one.
625
+ *
626
+ * If you need to share a compiler or analyzer across projects, destroy them
627
+ * yourself and don't call this method — the project does not provide an
628
+ * ownership toggle.
629
+ */
630
+ destroy() {
631
+ if (this.destroyed) return;
632
+ this.destroyed = true;
633
+ this.scheduler.cancel();
634
+ this.compileListeners.clear();
635
+ this.contentByPath.clear();
636
+ this._lastResult = void 0;
637
+ this.compiler.destroy();
638
+ this.analyzer?.destroy();
381
639
  }
382
640
  };
383
641
 
384
642
  // src/renderer.ts
385
- var DEFAULT_RENDERER_WASM_URL = "https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-renderer@0.7.0-rc2/pkg/typst_ts_renderer_bg.wasm";
643
+ var DEFAULT_RENDERER_WASM_URL = `https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-renderer@${"0.7.0-rc2"}/pkg/typst_ts_renderer_bg.wasm`;
386
644
  var rendererModulePromise = null;
387
645
  function getRendererModule() {
388
646
  if (!rendererModulePromise) {
@@ -439,7 +697,45 @@ var TypstRenderer = class _TypstRenderer {
439
697
  session.free();
440
698
  }
441
699
  }
700
+ /**
701
+ * Render a Typst vector artifact into one self-contained SVG string per
702
+ * physical page. The merged SVG is split by `<g class="typst-page">`
703
+ * children; each group's `data-page-width` / `data-page-height` give the
704
+ * page-local viewBox. Shared `<defs>` / `<style>` are duplicated into each
705
+ * page so the output SVGs render independently. Returns an empty array if
706
+ * the document has no page groups.
707
+ */
708
+ async renderSvgPages(vector) {
709
+ return splitMergedSvgPages(await this.renderSvg(vector));
710
+ }
442
711
  };
712
+ function splitMergedSvgPages(svg) {
713
+ const doc = new DOMParser().parseFromString(svg, "text/html");
714
+ const root = doc.querySelector("svg");
715
+ if (!root) return [];
716
+ const children = Array.from(root.children);
717
+ const pageGroups = children.filter(
718
+ (el) => el.tagName.toLowerCase() === "g" && el.classList.contains("typst-page")
719
+ );
720
+ if (pageGroups.length === 0) return [];
721
+ const sharedHtml = children.filter((el) => !el.classList.contains("typst-page")).map((el) => el.outerHTML).join("");
722
+ const namespaceAttrs = Array.from(root.attributes).filter((attr) => attr.name === "xmlns" || attr.name.startsWith("xmlns:")).map((attr) => `${attr.name}="${attr.value}"`).join(" ");
723
+ return pageGroups.flatMap((group, index) => {
724
+ const width = Number(group.getAttribute("data-page-width")) || 0;
725
+ const height = Number(group.getAttribute("data-page-height")) || 0;
726
+ if (width <= 0 || height <= 0) return [];
727
+ const clone = group.cloneNode(true);
728
+ clone.removeAttribute("transform");
729
+ return [
730
+ {
731
+ index,
732
+ width,
733
+ height,
734
+ svg: `<svg ${namespaceAttrs} viewBox="0 0 ${width} ${height}" width="${width}" height="${height}">${sharedHtml}${clone.outerHTML}</svg>`
735
+ }
736
+ ];
737
+ });
738
+ }
443
739
  export {
444
740
  TypstAnalyzer,
445
741
  TypstCompiler,
@@ -448,6 +744,6 @@ export {
448
744
  TypstRenderer,
449
745
  normalizePath,
450
746
  normalizeRoot,
451
- normalizeUntitledUri
747
+ pathToAnalyzerUri
452
748
  };
453
749
  //# sourceMappingURL=index.js.map