(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))c(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const h of l.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&c(h)}).observe(document,{childList:!0,subtree:!0});function i(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function c(o){if(o.ep)return;o.ep=!0;const l=i(o);fetch(o.href,l)}})();const _e=new Worker(new URL("/assets/db-worker-AHwpujSZ.js",import.meta.url),{type:"module"});let ir=0,Be=null;const De=new Map;function kn(){return Be||(Be=new Promise((r,n)=>{_e.onmessage=c=>{const o=c.data;if(o.type==="ready")return;const l=De.get(o.id);l&&(De.delete(o.id),o.type=="success"?l.resolve(o.data):l.reject(new Error(o.error??o.message??"Неизвестная ошибка Worker")))},_e.onerror=c=>{console.error("[SQLite Worker] Ошибка:",c),n(new Error("Ошибка Worker"))};const i=++ir;De.set(i,{resolve:r,reject:n}),_e.postMessage({type:"start",id:i})}),Be)}function $n(r,n){return new Promise((i,c)=>{if(!_e){c(new Error("Worker не создан"));return}const o=++ir;De.set(o,{resolve:i,reject:c}),_e.postMessage({type:r,id:o,...n})})}async function Ae(r,n){return await $n("query",{sql:r,params:n??[]})}function xn(r){if(r==null)return[];const n=String(r).trim();return n?n.split(/[,\s;]+/).map(i=>i.trim()).filter(i=>i.length>0):[]}function Qn(r){const n=new Map;if(r==null)return n;const i=String(r);if(!i)return n;const c=i.split("");for(let o=0;o+10?`WHERE ${n.join(" AND ")}`:"",params:i}}async function Nn(r={}){const{clause:n,params:i}=or(r),o=(await Ae(`SELECT COUNT(*) as cnt FROM words ${n}`,i))[0]?.cnt;return typeof o=="number"?o:Number(o??0)}async function Wt(r={}){const{clause:n,params:i}=or(r),c=Math.max(1,Math.min(r.limit??50,500)),o=Math.max(0,r.offset??0);return(await Ae(`SELECT id, key, value, tags, more, group_id FROM words ${n} ORDER BY id LIMIT ? OFFSET ?`,[...i,c,o])).map(Fn)}async function Tn(){return(await Ae("SELECT id, name FROM word_groups ORDER BY id")).map(n=>({id:Number(n.id),name:String(n.name??"")}))}async function Pn(){return(await Ae("SELECT id, name, identifier FROM custom_fields ORDER BY id")).map(n=>({id:Number(n.id),name:String(n.name??""),identifier:String(n.identifier??"")}))}const Ut="japanese_app.db";async function Ct(){return navigator.storage.getDirectory()}async function _n(r){r[18]=1,r[19]=1;const i=await(await Ct()).getFileHandle(Ut,{create:!0}),c=i.createSyncAccessHandle;if(typeof c=="function")try{const l=await c.call(i);try{l.truncate(0),l.write(r,{at:0}),l.flush()}finally{l.close()}return}catch{}const o=await i.createWritable();try{await o.truncate(0);const l=new Uint8Array(r.length);l.set(r),await o.write(l)}finally{await o.close()}}async function Hn(){const r=await Ct();let n;try{n=await r.getFileHandle(Ut)}catch{throw new Error("Локальная база не найдена — сначала скачай сохранение")}const i=await n.getFile();if(i.size===0)throw new Error("Локальная база пуста");return new Uint8Array(await i.arrayBuffer())}async function Ge(){try{return(await(await(await Ct()).getFileHandle(Ut)).getFile()).size>0}catch{return!1}}var qn=ArrayBuffer,z=Uint8Array,je=Uint16Array,Ln=Int16Array,et=Int32Array,ft=function(r,n,i){if(z.prototype.slice)return z.prototype.slice.call(r,n,i);(n==null||n<0)&&(n=0),(i==null||i>r.length)&&(i=r.length);var c=new z(i-n);return c.set(r.subarray(n,i)),c},He=function(r,n,i,c){if(z.prototype.fill)return z.prototype.fill.call(r,n,i,c);for((i==null||i<0)&&(i=0),(c==null||c>r.length)&&(c=r.length);ir.length)&&(c=r.length);i2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],Y=function(r,n,i){var c=new Error(n||In[r]);if(c.code=r,Error.captureStackTrace&&Error.captureStackTrace(c,Y),!i)throw c;return c},At=function(r,n,i){for(var c=0,o=0;c>>0},Sn=function(r,n){var i=r[0]|r[1]<<8|r[2]<<16;if(i==3126568&&r[3]==253){var c=r[4],o=c>>5&1,l=c>>2&1,h=c&3,g=c>>6;c&8&&Y(0);var v=6-o,k=h==3?4:h,C=At(r,v,k);v+=k;var M=g?1<>3);y=N+(N>>3)*(r[5]&7)}y>2145386496&&Y(1);var w=new z((n==1?F||y:n?0:y)+12);return w[0]=1,w[4]=4,w[8]=8,{b:v+M,y:0,l:0,d:C,w:n&&n!=1?n:w.subarray(12),e:y,o:new et(w.buffer,0,3),u:F,c:l,m:Math.min(131072,y)}}else if((i>>4|r[3]<<20)==25481893)return Jn(r,4)+8;Y(0)},be=function(r){for(var n=0;1<i&&Y(3);for(var l=1<0;){var J=be(h+1),H=c>>3,te=(1<>(c&7)&te,b=(1<b&&(K-=B)),F[++g]=--K,K==-1?(h+=K,$[--C]=g):h-=K,!K)do{var G=c>>3;v=(r[G]|r[G+1]<<8)>>(c&7)&3,c+=2,g+=v}while(v==3)}(g>255||h)&&Y(0);for(var j=0,T=(l>>1)+(l>>3)+3,_=l-1,P=0;P<=g;++P){var U=F[P];if(U<1){y[P]=-U;continue}for(k=0;k=C)}}for(j&&Y(0),k=0;k>3,{b:o,s:$,n:D,t:N}]},Kn=function(r,n){var i=0,c=-1,o=new z(292),l=r[n],h=o.subarray(0,256),g=o.subarray(256,268),v=new je(o.buffer,268);if(l<128){var k=qe(r,n+1,6),C=k[0],M=k[1];n+=l;var F=C<<3,y=r[n];y||Y(0);for(var N=0,w=0,$=M.b,D=$,J=(++n<<3)-8+be(y);J-=$,!(J>3;if(N+=(r[H]|r[H+1]<<8)>>(J&7)&(1<<$)-1,h[++c]=M.s[N],J-=D,J>3,w+=(r[H]|r[H+1]<<8)>>(J&7)&(1<255&&Y(0)}else{for(c=l-127;i>4,h[i+1]=te&15}++n}var K=0;for(i=0;i11&&Y(0),K+=b&&1<0;--i){var P=v[i];He(_,i,P,v[i-1]=P+g[i]*(1<g&&M>3,y=(r[F]|r[F+1]<<8|r[F+2]<<16)>>(C&7);v=(v<>2,h=l<<1,g=l+h;Pe(r.subarray(c,c+=r[0]|r[1]<<8),n.subarray(0,l),i),Pe(r.subarray(c,c+=r[2]|r[3]<<8),n.subarray(l,h),i),Pe(r.subarray(c,c+=r[4]|r[5]<<8),n.subarray(h,g),i),Pe(r.subarray(c),n.subarray(g),i)},Bn=function(r,n,i){var c,o=n.b,l=r[o],h=l>>1&3;n.l=l&1;var g=l>>3|r[o+1]<<5|r[o+2]<<13,v=(o+=3)+g;if(h==1)return o>=r.length?void 0:(n.b=o+1,i?(He(i,r[o],n.y,n.y+=g),i):He(new z(g),r[o]));if(!(v>r.length)){if(h==0)return n.b=v,i?(i.set(r.subarray(o,v),n.y),n.y+=g,i):ft(r,o,v);if(h==2){var k=r[o],C=k&3,M=k>>2&3,F=k>>4,y=0,N=0;C<2?M&1?F|=r[++o]<<4|(M&2&&r[++o]<<12):F=k>>3:(N=M,M<2?(F|=(r[++o]&63)<<4,y=r[o]>>6|r[++o]<<2):M==2?(F|=r[++o]<<4|(r[++o]&3)<<12,y=r[o]>>2|r[++o]<<6):(F|=r[++o]<<4|(r[++o]&63)<<12,y=r[o]>>6|r[++o]<<2|r[++o]<<10)),++o;var w=i?i.subarray(n.y,n.y+n.m):new z(n.m),$=w.length-F;if(C==0)w.set(r.subarray(o,o+=F),$);else if(C==1)He(w,r[o++],$);else{var D=n.h;if(C==2){var J=Kn(r,o);y+=o-(o=J[0]),n.h=D=J[1]}else D||Y(0);(N?Yn:Pe)(r.subarray(o,o+=y),w.subarray($),D)}var H=r[o++];if(H){H==255?H=(r[o++]|r[o++]<<8)+32512:H>127&&(H=H-128<<8|r[o++]);var te=r[o++];te&3&&Y(0);for(var K=[Xn,zn,On],b=2;b>-1;--b){var B=te>>(b<<1)+2&3;if(B==1){var S=new z([0,0,r[o++]]);K[b]={s:S.subarray(2,3),n:S.subarray(0,1),t:new je(S.buffer,0,1),b:0}}else B==2?(c=qe(r,o,9-(b&1)),o=c[0],K[b]=c[1]):B==3&&(n.t||Y(0),K[b]=n.t[b])}var G=n.t=K,j=G[0],T=G[1],_=G[2],P=r[v-1];P||Y(0);var U=(v<<3)-8+be(P)-_.b,E=U>>3,V=0,O=(r[E]|r[E+1]<<8)>>(U&7)&(1<<_.b)-1;E=(U-=T.b)>>3;var de=(r[E]|r[E+1]<<8)>>(U&7)&(1<>3;var X=(r[E]|r[E+1]<<8)>>(U&7)&(1<>3;var he=1<>>(U&7)&he-1);E=(U-=vt[Ee])>>3;var ie=Zn[Ee]+((r[E]|r[E+1]<<8|r[E+2]<<16)>>(U&7)&(1<>3;var pe=Vn[Ce]+((r[E]|r[E+1]<<8|r[E+2]<<16)>>(U&7)&(1<>3,O=_.t[O]+((r[E]|r[E+1]<<8)>>(U&7)&(1<>3,X=j.t[X]+((r[E]|r[E+1]<<8)>>(U&7)&(1<>3,de=T.t[de]+((r[E]|r[E+1]<<8)>>(U&7)&(1<3)n.o[2]=n.o[1],n.o[1]=n.o[0],n.o[0]=re-=3;else{var Ue=re-(pe!=0);Ue?(re=Ue==3?n.o[0]-1:n.o[Ue],Ue>1&&(n.o[2]=n.o[1]),n.o[1]=n.o[0],n.o[0]=re):re=n.o[0]}for(var b=0;bie&&(ne=ie);for(var b=0;b{throw e},c,o=console.log.bind(console),l=console.error.bind(console),h,g=!1,v,k=t=>t.startsWith("file://"),C=!1;function M(){return Ze.buffer}function F(){if(!S?.buffer?.resizable){var t=M();S=new Int8Array(t),Se=new Int16Array(t),n.HEAPU8=O=new Uint8Array(t),$e=new Uint16Array(t),Ke=new Int32Array(t),X=new Uint32Array(t),Lt=new Float32Array(t),Rt=new Float64Array(t),kt=new BigInt64Array(t),$t=new BigUint64Array(t)}}function y(){C=!0,Fe.A()}function N(t){t=`Aborted(${t})`,l(t),g=!0,t+=". Build with -sASSERTIONS for more info.",C&&Xt();var e=new WebAssembly.RuntimeError(t);throw e}var w;let $=()=>"";function D(t){if(t==w&&h)return new Uint8Array(h);throw"both async and sync fetching of the wasm failed"}async function J(t){if(!h)try{var e=await c(t);return new Uint8Array(e)}catch{}return D(t)}async function H(t,e){try{var a=await J(t),s=await WebAssembly.instantiate(a,e);return s}catch(u){l(`failed to asynchronously prepare wasm: ${u}`),N(u)}}async function te(t,e,a){if(!t&&!k(e))try{var s=fetch(e,{credentials:"same-origin"}),u=await WebAssembly.instantiateStreaming(s,a);return u}catch(d){l(`wasm streaming compile failed: ${d}`),l("falling back to ArrayBuffer instantiation")}return H(e,a)}function K(){var t={a:En};return t}async function b(){function t(d){return Fe=d.exports,Cn(Fe),F(),Fe}function e(d){return t(d.instance)}var a=K();w??=$();var s=await te(h,w,a),u=e(s);return u}class B{name="ExitStatus";constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var S,G=()=>Dt,j=t=>{var e=t.getArg(G(),0);return Yt(e)},T=()=>Zt(),_=t=>zt(t),P=t=>Vt(t),U=globalThis.TextDecoder&&new TextDecoder,E=(t,e,a,s)=>{var u=e+a;if(s)return u;for(;t[e]&&!(e>=u);)++e;return e},V=(t,e=0,a,s)=>{var u=E(t,e,a,s);if(u-e>16&&t.buffer&&U)return U.decode(t.subarray(e,u));for(var d="";e>10,56320|x&1023)}}return d},O,de=(t,e,a)=>t?V(O,t,e,a):"",X,Ce=t=>{var e=T(),a=P(4),s=P(4);Bt(t,a,s);var u=X[a>>2],d=X[s>>2],p=de(u);ue(u);var f;return d&&(f=de(d),ue(d)),_(e),[p,f]},Ie=t=>{var e=j(t);return Ce(e)},Ee=t=>{var e=new WebAssembly.Exception(G(),[t],{traceStack:!0});throw e.message=Ie(e),e},Je=()=>N(""),we={},Me=t=>{for(;t.length;){var e=t.pop(),a=t.pop();a(e)}};function he(t){return this.fromWireType(X[t>>2])}var re={},ie={},pe={};class Ue extends Error{constructor(e){super(e),this.name="InternalError"}}var ce=t=>{throw new Ue(t)},ne=(t,e,a)=>{t.forEach(f=>pe[f]=e);function s(f){var m=a(f);m.length!==t.length&&ce("Mismatched type converter count");for(var x=0;x{u[f]=ie[m],++p,p===d.length&&s(u)}));d.length===0&&s(u)},tt=t=>{var e=we[t];delete we[t];var a=e.rawConstructor,s=e.rawDestructor,u=e.fields,d=u.map(p=>p.getterReturnType).concat(u.map(p=>p.setterArgumentType));ne([t],d,p=>{var f={};for(var[m,x]of u.entries()){let Q=p[m],R=x.getter,L=x.getterContext,I=p[m+u.length],W=x.setter,ae=x.setterContext;f[x.fieldName]={read:A=>Q.fromWireType(R(L,A)),write:(A,Z)=>{var ge=[];W(ae,A,I.toWireType(ge,Z)),Me(ge)},optional:Q.optional}}return[{name:e.name,fromWireType:Q=>{var R={};for(var L in f)R[L]=f[L].read(Q);return s(Q),R},toWireType:(Q,R)=>{for(var L in f)if(!(L in R)&&!f[L].optional)throw new TypeError(`Missing field: "${L}"`);var I=a();for(L in f)f[L].write(I,R[L]);return Q!==null&&Q.push(s,I),I},readValueFromPointer:he,destructorFunction:s}]})},ee=t=>{for(var e="";;){var a=O[t++];if(!a)return e;e+=String.fromCharCode(a)}};class ke extends Error{constructor(e){super(e),this.name="BindingError"}}var q=t=>{throw new ke(t)};function fr(t,e,a={}){var s=e.name;if(t||q(`type "${s}" must have a positive integer typeid pointer`),ie.hasOwnProperty(t)){if(a.ignoreDuplicateRegistrations)return;q(`Cannot register type '${s}' twice`)}if(ie[t]=e,delete pe[t],re.hasOwnProperty(t)){var u=re[t];delete re[t],u.forEach(d=>d())}}function le(t,e,a={}){return fr(t,e,a)}var Se,$e,Ke,kt,$t,xt=(t,e,a)=>{switch(e){case 1:return a?s=>S[s]:s=>O[s];case 2:return a?s=>Se[s>>1]:s=>$e[s>>1];case 4:return a?s=>Ke[s>>2]:s=>X[s>>2];case 8:return a?s=>kt[s>>3]:s=>$t[s>>3];default:throw new TypeError(`invalid integer width (${e}): ${t}`)}},hr=(t,e,a,s,u)=>{e=ee(e);let d=s===0n,p=f=>f;if(d){let f=a*8;p=m=>BigInt.asUintN(f,m),u=p(u)}le(t,{name:e,fromWireType:p,toWireType:(f,m)=>(typeof m=="number"&&(m=BigInt(m)),m),readValueFromPointer:xt(e,a,!d),destructorFunction:null})},gr=(t,e,a,s)=>{e=ee(e),le(t,{name:e,fromWireType:function(u){return!!u},toWireType:function(u,d){return d?a:s},readValueFromPointer:function(u){return this.fromWireType(O[u])},destructorFunction:null})},wr=t=>({count:t.count,deleteScheduled:t.deleteScheduled,preservePointerOnDelete:t.preservePointerOnDelete,ptr:t.ptr,ptrType:t.ptrType,smartPtr:t.smartPtr,smartPtrType:t.smartPtrType}),rt=t=>{function e(a){return a.$$.ptrType.registeredClass.name}q(e(t)+" instance already deleted")},nt=!1,Qt=t=>{},mr=t=>{t.smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr)},Ft=t=>{t.count.value-=1;var e=t.count.value===0;e&&mr(t)},xe=t=>globalThis.FinalizationRegistry?(nt=new FinalizationRegistry(e=>{Ft(e.$$)}),xe=e=>{var a=e.$$,s=!!a.smartPtr;if(s){var u={$$:a};nt.register(e,u,e)}return e},Qt=e=>nt.unregister(e),xe(t)):(xe=e=>e,t),vr=()=>{let t=Oe.prototype;Object.assign(t,{isAliasOf(a){if(!(this instanceof Oe)||!(a instanceof Oe))return!1;var s=this.$$.ptrType.registeredClass,u=this.$$.ptr;a.$$=a.$$;for(var d=a.$$.ptrType.registeredClass,p=a.$$.ptr;s.baseClass;)u=s.upcast(u),s=s.baseClass;for(;d.baseClass;)p=d.upcast(p),d=d.baseClass;return s===d&&u===p},clone(){if(this.$$.ptr||rt(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var a=xe(Object.create(Object.getPrototypeOf(this),{$$:{value:wr(this.$$)}}));return a.$$.count.value+=1,a.$$.deleteScheduled=!1,a},delete(){this.$$.ptr||rt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&q("Object already scheduled for deletion"),Qt(this),Ft(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||rt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&q("Object already scheduled for deletion"),this.$$.deleteScheduled=!0,this}});let e=Symbol.dispose;e&&(t[e]=t.delete)};function Oe(){}var Nt=(t,e)=>Object.defineProperty(e,"name",{value:t}),Tt={},at=(t,e,a)=>{if(t[e].overloadTable===void 0){var s=t[e];t[e]=function(...u){return t[e].overloadTable.hasOwnProperty(u.length)||q(`Function '${a}' called with an invalid number of arguments (${u.length}) - expects one of (${t[e].overloadTable})!`),t[e].overloadTable[u.length].apply(this,u)},t[e].overloadTable=[],t[e].overloadTable[s.argCount]=s}},yr=(t,e,a)=>{n.hasOwnProperty(t)?(q(`Cannot register public name '${t}' twice`),at(n,t,t),n[t].overloadTable.hasOwnProperty(a)&&q(`Cannot register multiple overloads of a function with the same number of arguments (${a})!`),n[t].overloadTable[a]=e):(n[t]=e,n[t].argCount=a)},br=48,Ur=57,Cr=t=>{t=t.replace(/[^a-zA-Z0-9_]/g,"$");var e=t.charCodeAt(0);return e>=br&&e<=Ur?`_${t}`:t};function Er(t,e,a,s,u,d,p,f){this.name=t,this.constructor=e,this.instancePrototype=a,this.rawDestructor=s,this.baseClass=u,this.getActualType=d,this.upcast=p,this.downcast=f,this.pureVirtualFunctions=[]}var it=(t,e,a)=>{for(;e!==a;)e.upcast||q(`Expected null or instance of ${a.name}, got an instance of ${e.name}`),t=e.upcast(t),e=e.baseClass;return t},ot=t=>{if(t===null)return"null";var e=typeof t;return e==="object"||e==="array"||e==="function"?t.toString():""+t};function Mr(t,e){if(e===null)return this.isReference&&q(`null is not a valid ${this.name}`),0;e.$$||q(`Cannot pass "${ot(e)}" as a ${this.name}`),e.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`);var a=e.$$.ptrType.registeredClass,s=it(e.$$.ptr,a,this.registeredClass);return s}function kr(t,e){var a;if(e===null)return this.isReference&&q(`null is not a valid ${this.name}`),this.isSmartPointer?(a=this.rawConstructor(),t!==null&&t.push(this.rawDestructor,a),a):0;(!e||!e.$$)&&q(`Cannot pass "${ot(e)}" as a ${this.name}`),e.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&e.$$.ptrType.isConst&&q(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);var s=e.$$.ptrType.registeredClass;if(a=it(e.$$.ptr,s,this.registeredClass),this.isSmartPointer)switch(e.$$.smartPtr===void 0&&q("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:e.$$.smartPtrType===this?a=e.$$.smartPtr:q(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:a=e.$$.smartPtr;break;case 2:if(e.$$.smartPtrType===this)a=e.$$.smartPtr;else{var u=e.clone();a=this.rawShare(a,lt.toHandle(()=>u.delete())),t!==null&&t.push(this.rawDestructor,a)}break;default:q("Unsupported sharing policy")}return a}function $r(t,e){if(e===null)return this.isReference&&q(`null is not a valid ${this.name}`),0;e.$$||q(`Cannot pass "${ot(e)}" as a ${this.name}`),e.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`),e.$$.ptrType.isConst&&q(`Cannot convert argument of type ${e.$$.ptrType.name} to parameter type ${this.name}`);var a=e.$$.ptrType.registeredClass,s=it(e.$$.ptr,a,this.registeredClass);return s}var Pt=(t,e,a)=>{if(e===a)return t;if(a.baseClass===void 0)return null;var s=Pt(t,e,a.baseClass);return s===null?null:a.downcast(s)},xr={},Qr=(t,e)=>{for(e===void 0&&q("ptr should not be undefined");t.baseClass;)e=t.upcast(e),t=t.baseClass;return e},Fr=(t,e)=>(e=Qr(t,e),xr[e]),Xe=(t,e)=>{(!e.ptrType||!e.ptr)&&ce("makeClassHandle requires ptr and ptrType");var a=!!e.smartPtrType,s=!!e.smartPtr;return a!==s&&ce("Both smartPtrType and smartPtr must be specified"),e.count={value:1},xe(Object.create(t,{$$:{value:e,writable:!0}}))};function Nr(t){var e=this.getPointee(t);if(!e)return this.destructor(t),null;var a=Fr(this.registeredClass,e);if(a!==void 0){if(a.$$.count.value===0)return a.$$.ptr=e,a.$$.smartPtr=t,a.clone();var s=a.clone();return this.destructor(t),s}function u(){return this.isSmartPointer?Xe(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:e,smartPtrType:this,smartPtr:t}):Xe(this.registeredClass.instancePrototype,{ptrType:this,ptr:t})}var d=this.registeredClass.getActualType(e),p=Tt[d];if(!p)return u.call(this);var f;this.isConst?f=p.constPointerType:f=p.pointerType;var m=Pt(e,this.registeredClass,f.registeredClass);return m===null?u.call(this):this.isSmartPointer?Xe(f.registeredClass.instancePrototype,{ptrType:f,ptr:m,smartPtrType:this,smartPtr:t}):Xe(f.registeredClass.instancePrototype,{ptrType:f,ptr:m})}var Tr=()=>{Object.assign(ze.prototype,{getPointee(t){return this.rawGetPointee&&(t=this.rawGetPointee(t)),t},destructor(t){this.rawDestructor?.(t)},readValueFromPointer:he,fromWireType:Nr})};function ze(t,e,a,s,u,d,p,f,m,x,Q){this.name=t,this.registeredClass=e,this.isReference=a,this.isConst=s,this.isSmartPointer=u,this.pointeeType=d,this.sharingPolicy=p,this.rawGetPointee=f,this.rawConstructor=m,this.rawShare=x,this.rawDestructor=Q,!u&&e.baseClass===void 0?s?(this.toWireType=Mr,this.destructorFunction=null):(this.toWireType=$r,this.destructorFunction=null):this.toWireType=kr}var Pr=(t,e,a)=>{n.hasOwnProperty(t)||ce("Replacing nonexistent public symbol"),n[t].overloadTable!==void 0&&a!==void 0?n[t].overloadTable[a]=e:(n[t]=e,n[t].argCount=a)},_r=t=>Gt.get(t),se=(t,e,a=!1)=>{t=ee(t);function s(){var d=_r(e);return d}var u=s();return typeof u!="function"&&q(`unknown function pointer with signature ${t}: ${e}`),u};class Hr extends Error{}var qr=t=>{var e=Kt(t),a=ee(e);return ue(e),a},Ve=(t,e)=>{var a=[],s={};function u(d){if(!s[d]&&!ie[d]){if(pe[d]){pe[d].forEach(u);return}a.push(d),s[d]=!0}}throw e.forEach(u),new Hr(`${t}: `+a.map(qr).join([", "]))},Lr=(t,e,a,s,u,d,p,f,m,x,Q,R,L)=>{Q=ee(Q),d=se(u,d),f&&=se(p,f),x&&=se(m,x),L=se(R,L);var I=Cr(Q);yr(I,function(){Ve(`Cannot construct ${Q} due to unbound types`,[s])}),ne([t,e,a],s?[s]:[],W=>{W=W[0];var ae,A;s?(ae=W.registeredClass,A=ae.instancePrototype):A=Oe.prototype;var Z=Nt(Q,function(...pt){if(Object.getPrototypeOf(this)!==ge)throw new ke(`Use 'new' to construct ${Q}`);if(oe.constructor_body===void 0)throw new ke(`${Q} has no accessible constructor`);var jt=oe.constructor_body[pt.length];if(jt===void 0)throw new ke(`Tried to invoke ctor of ${Q} with invalid number of parameters (${pt.length}) - expected (${Object.keys(oe.constructor_body).toString()}) parameters instead!`);return jt.apply(this,pt)}),ge=Object.create(A,{constructor:{value:Z}});Z.prototype=ge;var oe=new Er(Q,Z,ge,L,ae,d,f,x);oe.baseClass&&(oe.baseClass.__derivedClasses??=[],oe.baseClass.__derivedClasses.push(oe));var dt=new ze(Q,oe,!0,!1,!1),fe=new ze(Q+"*",oe,!1,!1,!1),Ye=new ze(Q+" const*",oe,!1,!0,!1);return Tt[t]={pointerType:fe,constPointerType:Ye},Pr(I,Z),[dt,fe,Ye]})};function Rr(t){for(var e=1;e{for(var a=[],s=0;s>2]);return a},_t=t=>{t=t.trim();let e=t.indexOf("(");return e===-1?t:t.slice(0,e)},Ir=(t,e,a,s,u,d,p,f,m)=>{var x=ct(a,s);e=ee(e),e=_t(e),d=se(u,d,f),ne([],[t],Q=>{Q=Q[0];var R=`${Q.name}.${e}`;function L(){Ve(`Cannot call ${R} due to unbound types`,x)}e.startsWith("@@")&&(e=Symbol[e.substring(2)]);var I=Q.registeredClass.constructor;return I[e]===void 0?(L.argCount=a-1,I[e]=L):(at(I,e,R),I[e].overloadTable[a-1]=L),ne([],x,W=>{var ae=[W[0],null].concat(W.slice(1)),A=st(R,ae,null,d,p);if(I[e].overloadTable===void 0?(A.argCount=a-1,I[e]=A):I[e].overloadTable[a-1]=A,Q.registeredClass.__derivedClasses)for(let Z of Q.registeredClass.__derivedClasses)Z.constructor.hasOwnProperty(e)||(Z.constructor[e]=A);return[]}),[]})},Jr=(t,e,a,s,u,d)=>{var p=ct(e,a);u=se(s,u),ne([],[t],f=>{f=f[0];var m=`constructor ${f.name}`;if(f.registeredClass.constructor_body===void 0&&(f.registeredClass.constructor_body=[]),f.registeredClass.constructor_body[e-1]!==void 0)throw new ke(`Cannot register multiple constructors with identical number of parameters (${e-1}) for class '${f.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return f.registeredClass.constructor_body[e-1]=()=>{Ve(`Cannot construct ${f.name} due to unbound types`,p)},ne([],p,x=>(x.splice(1,0,null),f.registeredClass.constructor_body[e-1]=st(m,x,null,u,d),[])),[]})},Sr=(t,e,a,s,u,d,p,f,m,x)=>{var Q=ct(a,s);e=ee(e),e=_t(e),d=se(u,d,m),ne([],[t],R=>{R=R[0];var L=`${R.name}.${e}`;e.startsWith("@@")&&(e=Symbol[e.substring(2)]),f&&R.registeredClass.pureVirtualFunctions.push(e);function I(){Ve(`Cannot call ${L} due to unbound types`,Q)}var W=R.registeredClass.instancePrototype,ae=W[e];return ae===void 0||ae.overloadTable===void 0&&ae.className!==R.name&&ae.argCount===a-2?(I.argCount=a-2,I.className=R.name,W[e]=I):(at(W,e,L),W[e].overloadTable[a-2]=I),ne([],Q,A=>{var Z=st(L,A,R,d,p);return W[e].overloadTable===void 0?(Z.argCount=a-2,W[e]=Z):W[e].overloadTable[a-2]=Z,[]}),[]})},Ht=[],me=[0,1,,1,null,1,!0,1,!1,1],qt=[],Kr=t=>{if(t>9&&--me[t+1]===0){var e=me[t];me[t]=void 0;var a=qt[t];a&&(qt[t]=void 0,a(e)),Ht.push(t)}},lt={toValue:t=>(t||q(`Cannot use deleted val. handle = ${t}`),me[t]),toHandle:t=>{switch(t){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let e=Ht.pop()||me.length;return me[e]=t,me[e+1]=1,e}}}},Or={name:"emscripten::val",fromWireType:t=>{var e=lt.toValue(t);return Kr(t),e},toWireType:(t,e)=>lt.toHandle(e),readValueFromPointer:he,destructorFunction:null},Xr=t=>le(t,Or),Lt,Rt,zr=(t,e)=>{switch(e){case 4:return function(a){return this.fromWireType(Lt[a>>2])};case 8:return function(a){return this.fromWireType(Rt[a>>3])};default:throw new TypeError(`invalid float width (${e}): ${t}`)}},Vr=(t,e,a)=>{e=ee(e),le(t,{name:e,fromWireType:s=>s,toWireType:(s,u)=>u,readValueFromPointer:zr(e,a),destructorFunction:null})},Zr=(t,e,a,s,u)=>{e=ee(e);let d=s===0,p=m=>m;if(d){var f=32-8*a;p=m=>m<>>f,u=p(u)}le(t,{name:e,fromWireType:p,toWireType:(m,x)=>x,readValueFromPointer:xt(e,a,s!==0),destructorFunction:null})},Yr=(t,e,a)=>{var s=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],u=s[e];function d(p){var f=X[p>>2],m=X[p+4>>2];return new u(S.buffer,m,f)}a=ee(a),le(t,{name:a,fromWireType:d,readValueFromPointer:d},{ignoreDuplicateRegistrations:!0})},Br=(t,e,a,s)=>{if(!(s>0))return 0;for(var u=a,d=a+s-1,p=0;p=d)break;e[a++]=f}else if(f<=2047){if(a+1>=d)break;e[a++]=192|f>>6,e[a++]=128|f&63}else if(f<=65535){if(a+2>=d)break;e[a++]=224|f>>12,e[a++]=128|f>>6&63,e[a++]=128|f&63}else{if(a+3>=d)break;e[a++]=240|f>>18,e[a++]=128|f>>12&63,e[a++]=128|f>>6&63,e[a++]=128|f&63,p++}}return e[a]=0,a-u},It=(t,e,a)=>Br(t,O,e,a),Jt=t=>{for(var e=0,a=0;a=55296&&s<=57343?(e+=4,++a):e+=3}return e},Dr=(t,e)=>{e=ee(e),le(t,{name:e,fromWireType(a){var s=X[a>>2],u=a+4,d;return d=de(u,s,!0),ue(a),d},toWireType(a,s){s instanceof ArrayBuffer&&(s=new Uint8Array(s));var u,d=typeof s=="string";d||ArrayBuffer.isView(s)&&s.BYTES_PER_ELEMENT==1||q("Cannot pass non-string to std::string"),d?u=Jt(s):u=s.length;var p=ut(4+u+1),f=p+4;return X[p>>2]=u,d?It(s,f,u+1):O.set(s,f),a!==null&&a.push(ue,p),p},readValueFromPointer:he,destructorFunction(a){ue(a)}})},St=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,Gr=(t,e,a)=>{var s=t>>1,u=E($e,s,e/2,a);if(u-s>16&&St)return St.decode($e.subarray(s,u));for(var d="",p=s;p{if(a<2)return 0;a-=2;for(var s=e,u=a>1]=p,e+=2}return Se[e>>1]=0,e-s},Wr=t=>t.length*2,Ar=(t,e,a)=>{for(var s="",u=t>>2,d=0;!(d>=e/4);d++){var p=X[u+d];if(!p&&!a)break;s+=String.fromCodePoint(p)}return s},en=(t,e,a=2147483647)=>{if(a<4)return 0;for(var s=e,u=s+a-4,d=0;d65535&&d++,Ke[e>>2]=p,e+=4,e+4>u)break}return Ke[e>>2]=0,e-s},tn=t=>{for(var e=0,a=0;a65535&&a++,e+=4}return e},rn=(t,e,a)=>{a=ee(a);var s,u,d;e===2?(s=Gr,u=jr,d=Wr):(s=Ar,u=en,d=tn),le(t,{name:a,fromWireType:p=>{var f=X[p>>2],m=s(p+4,f*e,!0);return ue(p),m},toWireType:(p,f)=>{typeof f!="string"&&q(`Cannot pass non-string to C++ string type ${a}`);var m=d(f),x=ut(4+m+e);return X[x>>2]=m/e,u(f,x+4,m+e),p!==null&&p.push(ue,x),x},readValueFromPointer:he,destructorFunction(p){ue(p)}})},nn=(t,e,a,s,u,d)=>{we[t]={name:ee(e),rawConstructor:se(a,s),rawDestructor:se(u,d),fields:[]}},an=(t,e,a,s,u,d,p,f,m,x)=>{we[t].fields.push({fieldName:ee(e),getterReturnType:a,getter:se(s,u),getterContext:d,setterArgumentType:p,setter:se(f,m),setterContext:x})},on=(t,e)=>{e=ee(e),le(t,{isVoid:!0,name:e,fromWireType:()=>{},toWireType:(a,s)=>{}})},sn=()=>{},Qe={},cn=t=>{if(t instanceof B||t=="unwind")return v;i(1,t)},ln=t=>{v=t,i(t,new B(t))},un=t=>{if(!g)try{return t()}catch(e){cn(e)}},dn=()=>performance.now(),pn=(t,e)=>{if(Qe[t]&&(clearTimeout(Qe[t].id),delete Qe[t]),!e)return 0;var a=setTimeout(()=>{delete Qe[t],un(()=>Ot(t,dn()))},e);return Qe[t]={id:a,timeout_ms:e},0},fn=()=>2147483648,hn=(t,e)=>Math.ceil(t/e)*e,gn=t=>{var e=Ze.buffer.byteLength,a=(t-e+65535)/65536|0;try{return Ze.grow(a),F(),1}catch{}},wn=t=>{var e=O.length;t>>>=0;var a=fn();if(t>a)return!1;for(var s=1;s<=4;s*=2){var u=e*(1+.2/s);u=Math.min(u,t+100663296);var d=Math.min(a,hn(Math.max(t,u),65536)),p=gn(d);if(p)return!0}return!1},mn=t=>52;function vn(t,e,a,s){return 70}var yn=[null,[],[]],bn=(t,e)=>{var a=yn[t];!e||e===10?((t===1?o:l)(V(a)),a.length=0):a.push(e)},Un=(t,e,a,s)=>{for(var u=0,d=0;d>2],f=X[e+4>>2];e+=8;for(var m=0;m>2]=u,0};vr(),Tr(),n.wasmBinary&&(h=n.wasmBinary),n.UTF8ToString=de,n.stringToUTF8=It,n.lengthBytesUTF8=Jt;var Kt,ut,ue,Ot,Xt,zt,Vt,Zt,Yt,Bt,Dt,Ze,Gt;function Cn(t){Kt=t.B,ut=n._malloc=t.C,ue=n._free=t.D,Ot=t.F,Xt=t.G,zt=t.H,Vt=t.I,Zt=t.J,Yt=t.K,Bt=t.L,Ze=t.z,Gt=t.E,Dt=t.M}var En={t:Ee,x:Je,f:tt,i:hr,l:gr,o:Lr,b:Ir,n:Jr,d:Sr,y:Xr,h:Vr,c:Zr,a:Yr,k:Dr,g:rn,j:nn,e:an,m:on,w:sn,p:pn,u:wn,s:mn,q:vn,r:Un,v:ln};async function Mn(){!g&&y()}var Fe;return Fe=await b(),await Mn(),n}var Wn=jn,An=new Int8Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,90,63,64,65,66,-1,67,68,69,70,71,-1,72,73,52,53,54,55,56,57,58,59,60,61,74,75,76,77,78,79,80,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,81,-1,82,83,84,85,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,86,87,88,89,-1]);function ea(r){let n=new Uint8Array(170930),i=0,c=0,o=0,l=-1;for(let h=0,g=r.length;h127)continue;let k=An[v];if(!(k<0))if(l<0)l=k;else{l+=k*91,c|=l<88?13:14;do n[i++]=c,c>>>=8,o-=8;while(o>7);l=-1}}return l>=0&&(n[i++]=(c|l<""})}function na(){yt=void 0}var aa=class{_module;constructor(r){this._module=r}malloc(r){let n=this._module._malloc(r);return{ptr:n,size:r,dispose:()=>this.free({ptr:n,size:r,dispose:()=>{}})}}free(r){this._module._free(r.ptr)}dataToHeap(r){let n=this.malloc(r.byteLength);return this._module.HEAPU8.set(r,n.ptr),n}heapView(r){return this._module.HEAPU8.subarray(r.ptr,r.ptr+r.size)}heapToUint8Array(r){return new Uint8Array([...this.heapView(r)])}lengthBytes(r){return this._module.lengthBytesUTF8(r)}stringToHeap(r){let n=this.lengthBytes(r)+1,i=this._module._malloc(n);return this._module.stringToUTF8(r,i,n),{ptr:i,size:n,dispose:()=>this.free({ptr:i,size:n,dispose:()=>{}})}}heapToString(r){return this._module.UTF8ToString(r.ptr,r.size)}hasFilesystem(){let r=this._module;return r.FS_createPath!==void 0&&r.FS_createDataFile!==void 0&&r.FS_preloadFile!==void 0&&r.FS_unlink!==void 0}createPath(r,n=!0,i=!0){return this._module.FS_createPath("/",r,n,i)}createDataFile(r,n,i=!0,c=!0,o=!0){return this._module.FS_createDataFile("/",r,n,i,c,o)}preloadFile(r,n,i=!0,c=!0,o=!1,l=!0,h=!1){return this._module.FS_preloadFile("/",r,n,i,c,o,l,h)}unlink(r){return this._module.FS_unlink(r)}},Ne,ia=4294967295;function Te(r,n){if(!Number.isInteger(r)||r<0||r>ia)throw new Error(`${n} length ${r} is outside the WASM32-safe range`)}function ht(r){if(r.length===0)return new Uint8Array(0);if(r.length===1)return r[0];let n=0;for(let o of r)n+=o.length;let i=new Uint8Array(n),c=0;for(let o of r)i.set(o,c),c+=o.length;return i}var oa=class cr{_mainModule;_zstdClass;_zstd;_compressionLevel;_decompressFrameCompleted=!1;_decompressRemaining=0;_decompressSawInput=!1;constructor(n){this._mainModule=new aa(n),this._zstdClass=n.zstd,this._zstd=new this._zstdClass,this._compressionLevel=this._zstdClass.defaultCLevel()}static load(){return Ne||(Ne=ra().then(n=>new cr(n))),Ne}static unload(){na(),Ne?.then(n=>{n?._zstd?.delete()}),Ne=void 0}copyHeap(n){return this._mainModule.heapView(n).slice()}mallocChecked(n,i){Te(n,i);let c=this._mainModule.malloc(n);if(!c.ptr)throw this._mainModule.free(c),new Error(`Failed to allocate ${n} bytes for ${i}`);return c}throwStreamError(n,i){throw new Error(`${n} failed: ${i.errorName||"unknown error"}`)}ensureStreamOk(n,i){i.error&&this.throwStreamError(n,i)}version(){return this._zstdClass.version()}reset(){let n=this._zstd.reset();this.ensureStreamOk("reset",n),this._decompressFrameCompleted=!1,this._decompressRemaining=0,this._decompressSawInput=!1}resetCompression(n){n!==void 0&&(this._compressionLevel=n);let i=this._zstd.resetCompression(this._compressionLevel);this.ensureStreamOk("resetCompression",i)}resetDecompression(){let n=this._zstd.resetDecompression();this.ensureStreamOk("resetDecompression",n),this._decompressFrameCompleted=!1,this._decompressRemaining=0,this._decompressSawInput=!1}setCompressionLevel(n){let i=this._zstd.setCompressionLevel(n);this.ensureStreamOk("setCompressionLevel",i),this._compressionLevel=n}compress(n,i=this.defaultCLevel()){Te(n.length,"compress input");let c=this._mainModule.dataToHeap(n);try{if(!c.ptr&&n.length>0)throw new Error("Failed to allocate compress input buffer");let o=this._zstdClass.compressBound(n.length),l=this.mallocChecked(o,"compress output");try{if(l.size=this._zstdClass.compress(l.ptr,o,c.ptr,c.size,i),this._zstdClass.isError(l.size))throw new Error(`compress failed: ${this._zstdClass.getErrorName(l.size)}`);return this.copyHeap(l)}finally{this._mainModule.free(l)}}finally{this._mainModule.free(c)}}compressChunk(n){if(Te(n.length,"compressChunk input"),n.length===0)return new Uint8Array(0);let i=this._mainModule.dataToHeap(n);try{if(!i.ptr)throw new Error("Failed to allocate compressChunk input buffer");let c=this._zstdClass.CStreamOutSize(),o=[],l=0;for(;l0&&(h.size=g.produced,o.push(this.copyHeap(h)))}finally{this._mainModule.free(h)}}return ht(o)}finally{this._mainModule.free(i)}}compressEnd(){let n=this._zstdClass.CStreamOutSize(),i=[],c=1;for(;c!==0;){let o=this.mallocChecked(n,"compressEnd output");try{let l=this._zstd.compressEnd(o.ptr,n);if(this.ensureStreamOk("compressEnd",l),l.produced===0&&l.remaining!==0)throw new Error("compressEnd failed: no progress while finishing stream");c=l.remaining,l.produced>0&&(o.size=l.produced,i.push(this.copyHeap(o)))}finally{this._mainModule.free(o)}}return ht(i)}frameContentSize(n){return this._zstdClass.getFrameContentSize(n.ptr,n.size)}decompress(n){Te(n.length,"decompress input");let i=this._mainModule.dataToHeap(n);try{if(!i.ptr&&n.length>0)throw new Error("Failed to allocate decompress input buffer");let c=this.frameContentSize(i);if(c.error)throw new Error(`Failed to get frame content size: ${c.errorName}`);let o=c.known;if(o){let l=this._zstdClass.findFrameCompressedSize(i.ptr,i.size);if(this._zstdClass.isError(l))throw new Error(`Failed to find frame compressed size: ${this._zstdClass.getErrorName(l)}`);l0?i.ptr+l:0,C=this._zstd.decompressChunk(g.ptr,c,k,v);if(this.ensureStreamOk("decompressChunk",C),C.consumed===0&&C.produced===0){if(v===0){C.remaining>0&&(this._decompressRemaining=C.remaining);break}throw new Error("decompressChunk failed: no progress while consuming input")}l+=C.consumed,h=C.produced===c&&C.remaining!==0,C.produced>0&&(g.size=C.produced,o.push(this.copyHeap(g))),C.remaining===0?(this._decompressFrameCompleted=!0,this._decompressRemaining=0):this._decompressRemaining=C.remaining}finally{this._mainModule.free(g)}}return ht(o)}finally{this._mainModule.free(i)}}decompressEnd(){if(!this._decompressSawInput)throw new Error("decompressEnd failed: empty compressed input is not a completed frame");if(!this._decompressFrameCompleted||this._decompressRemaining!==0)throw new Error("decompressEnd failed: truncated Zstandard input")}defaultCLevel(){return this._zstdClass.defaultCLevel()}minCLevel(){return this._zstdClass.minCLevel()}maxCLevel(){return this._zstdClass.maxCLevel()}};let gt=null;function sa(){return gt||(gt=oa.load()),gt}function ca(r){return r.length>=4&&r[0]===40&&r[1]===181&&r[2]===47&&r[3]===253}function bt(r){const n="SQLite format 3\0";if(r.length/g,">").replace(/"/g,""").replace(/'/g,"'")}function tr(r,n,i){const c=r.tagsList.map(h=>`${ye(h)}`).join(""),o=[...r.more.entries()].map(([h,g])=>{const v=i.get(h);return`
${v?`${ye(v.name)} #${h}`:`Поле #${h}`}
${ye(g)}
`}).join(""),l=o?`
Дополнительно (${r.more.size})
${o}
`:"";return`
${ye(r.key)}
`+(n?`${ye(n)}`:"")+`
${ye(r.value)}
`+(c?`
${c}
`:"")+l+"
"}function ua(r,n){r.innerHTML=`

🏠 Главная

Локальное сохранение и повторения — всё работает офлайн.

Проверка локальной базы…

📚 Слова

База ещё не проверена.
`;const i=r.querySelector("#home-db-status"),c=r.querySelector("#btn-go-sync"),o=r.querySelector("#home-actions"),l=r.querySelector("#btn-start"),h=r.querySelector("#words-search"),g=r.querySelector("#words-group"),v=r.querySelector("#words-count"),k=r.querySelector("#words-status"),C=r.querySelector("#words-list"),M=r.querySelector("#words-more");c.addEventListener("click",()=>n.goSync()),l.addEventListener("click",()=>{i.textContent="Экран повторений — следующий шаг."});let F=!1,y=new Map,N=new Map,w=0,$=[],D=0,J=!1,H=0,te=0;function K(){const T=g.value;if(T==="")return{search:h.value.trim(),groupId:null};const _=Number(T);return{search:h.value.trim(),groupId:Number.isFinite(_)?_:null}}function b(){M.hidden=!(F&&$.lengthtr(T,y.get(T.group_id),N)).join(""),v.textContent=w>0?`Показано ${$.length} из ${w}`:"",b()}function S(T){k.textContent=T,k.hidden=T===""}async function G(){if(!F||J)return;J=!0;const T=++H,_=K();M.disabled=!0,$.length===0&&S("Загрузка слов…");try{const[P,U]=await Promise.all([Nn({search:_.search,groupId:_.groupId??void 0}),Wt({search:_.search,groupId:_.groupId??void 0,limit:er,offset:0})]);if(T!==H)return;w=P,$=U,D=U.length,B(),S(U.length===0?"По этому запросу слов нет.":""),U.length===0&&w===0&&(v.textContent="Слов в базе пока нет.")}catch(P){if(T!==H)return;S(`Не удалось загрузить слова: ${P instanceof Error?P.message:String(P)}`)}finally{T===H&&(J=!1,M.disabled=!1,b())}}async function j(){if(!F||J||$.length>=w)return;J=!0;const T=++H,_=K();M.disabled=!0,M.textContent="Загрузка…";try{const P=await Wt({search:_.search,groupId:_.groupId??void 0,limit:er,offset:D});if(T!==H)return;$=$.concat(P),D+=P.length,C.insertAdjacentHTML("beforeend",P.map(U=>tr(U,y.get(U.group_id),N)).join("")),v.textContent=`Показано ${$.length} из ${w}`,b()}catch(P){if(T!==H)return;S(`Не удалось догрузить: ${P instanceof Error?P.message:String(P)}`)}finally{T===H&&(J=!1,M.disabled=!1,b())}}h.addEventListener("input",()=>{window.clearTimeout(te),te=window.setTimeout(()=>{G()},300)}),h.addEventListener("keydown",T=>{T.key==="Enter"&&(window.clearTimeout(te),G())}),g.addEventListener("change",()=>{G()}),M.addEventListener("click",()=>{j()}),(async()=>{if(!await Ge()){i.textContent="Локальной базы нет. Скачай сохранение на странице «Синхронизация».",o.hidden=!0,S("Нет локальной базы — скачай сохранение на странице «Синхронизация»."),v.textContent="";return}try{const _=await Hn(),P=bt(_);if(i.textContent=P?`Локальная база на месте: ${(_.length/1024).toFixed(1)} КБ, сигнатура SQLite OK.`:"Файл в OPFS есть, но это не похоже на SQLite — перекачай сохранение.",o.hidden=!P,!P){S("Файл в OPFS не похож на SQLite — перекачай сохранение.");return}try{const[U,E]=await Promise.all([Tn(),Pn()]),V=U;y=new Map(V.map(O=>[O.id,O.name])),N=new Map(E.map(O=>[O.id,O])),g.innerHTML=''+V.map(O=>``).join(""),F=!0,await G(),g.options[0].textContent=`Все группы (${w})`}catch(U){S(`БД есть, но слова не прочитались: ${U instanceof Error?U.message:String(U)}`)}}catch(_){i.textContent=`Не удалось прочитать базу: ${_ instanceof Error?_.message:String(_)}`,o.hidden=!0}})()}const rr=24,da=/^[A-Za-z0-9]{24}$/,lr="japlearn_sync_token";function nr(r){return r.trim().replace(/\s+/g,"")}function ve(r){return da.test(r)}function pa(){try{return localStorage.getItem(lr)??""}catch{return""}}function wt(r){try{localStorage.setItem(lr,r)}catch{}}const ur="https://learning.micialware.ru";function fa(r,n=ur){return`${n.replace(/\/+$/,"")}/download/${encodeURIComponent(r)}`}async function ha(r,n,i=ur){const c=fa(r,i);let o;try{o=await fetch(c,{method:"GET",...n})}catch(h){throw new Error(`Нет связи с сервером: ${h instanceof Error?h.message:String(h)}`)}if(!o.ok)throw o.status===404?new Error("Сохранение не найдено (404). Проверь токен."):new Error(`Сервер ответил ${o.status} ${o.statusText}`);const l=await o.arrayBuffer();if(l.byteLength===0)throw new Error("Сервер вернул пустой файл");return new Uint8Array(l)}function ga(r){r.innerHTML=`

📡 Синхронизация

Токен сохранения — 24 символа: латинские буквы и цифры.

0 / 24

Введите токен из 24 символов

`;const n=r.querySelector("#token-input"),i=r.querySelector("#token-error"),c=r.querySelector("#token-counter"),o=r.querySelector("#btn-download"),l=r.querySelector("#btn-upload"),h=r.querySelector("#status");function g(y){h.textContent=y,console.log(`[JapLearn] ${y}`)}function v(){return nr(n.value)}function k(y){o.disabled=y||!ve(v()),l.disabled=!0,n.disabled=y,y||Ge().then(N=>{!n.disabled&&ve(v())&&(l.disabled=!N)})}function C(){const y=v(),N=y.length;c.textContent=`${N} / ${rr}`;const w=ve(y),$=N===0;n.classList.toggle("invalid",!$&&!w),n.setAttribute("aria-invalid",String(!$&&!w)),$?i.textContent="":N!==rr?i.textContent=`Нужно 24 символа, сейчас ${N}`:i.textContent=w?"":"Только латинские буквы и цифры",o.disabled=!w,w?Ge().then(D=>{n.disabled||(l.disabled=!D)}):l.disabled=!0}async function M(){const y=v();if(ve(y)){wt(y),k(!0),g("Скачивание сохранения...");try{const N=await ha(y);g(`Скачано ${(N.length/1024).toFixed(1)} КБ, распаковка...`);const w=await la(N);g(`Распаковано ${(w.length/1024).toFixed(1)} КБ, сохранение в OPFS...`),await _n(w),g(`Готово: база ${(w.length/1024).toFixed(1)} КБ сохранена локально (OPFS).`)}catch(N){g(`Ошибка скачивания: ${N instanceof Error?N.message:String(N)}`)}finally{k(!1),C()}}}n.addEventListener("input",()=>{C()}),n.addEventListener("change",()=>{const y=v();n.value=y,ve(y)&&(wt(y),g("Токен сохранён локально. Можно скачивать или выгружать.")),C()}),o.addEventListener("click",()=>{M()}),l.addEventListener("click",()=>{const y=v();ve(y)&&(wt(y),g("Выгрузка — следующий шаг (POST /upload/stream/{id})."))});const F=pa();F&&(n.value=F),C(),ve(nr(F))&&Ge().then(y=>{g(y?"Токен восстановлен, локальная база на месте.":"Токен восстановлен. Нажми «Скачать», чтобы получить базу."),C()})}const wa={home:"Главная",sync:"Синхронизация"};function Le(r){const n=document.getElementById(r);if(!n)throw new Error(`[JapLearn] Не найден элемент #${r}`);return n}const dr=Le("burger-btn"),We=Le("drawer"),pr=Le("drawer-overlay"),ma=Le("page-title"),ar=Le("page");let Et=!1;function Re(r){Et=r,We.classList.toggle("open",r),pr.hidden=!r,dr.setAttribute("aria-expanded",String(r)),We.setAttribute("aria-hidden",String(!r)),document.body.classList.toggle("drawer-open",r)}function va(r){We.querySelectorAll(".drawer-btn").forEach(n=>{n.classList.toggle("active",n.dataset.page===r)})}function Mt(r){ma.textContent=wa[r],va(r),r==="home"?ua(ar,{goSync:()=>Mt("sync")}):ga(ar)}dr.addEventListener("click",()=>{Re(!Et)});pr.addEventListener("click",()=>{Re(!1)});document.addEventListener("keydown",r=>{r.key==="Escape"&&Et&&Re(!1)});We.querySelectorAll(".drawer-btn").forEach(r=>{r.addEventListener("click",()=>{const n=r.dataset.page;(n==="home"||n==="sync")&&Mt(n),Re(!1)})});await kn();Re(!1);Mt("home");console.log("[JapLearn] crossOriginIsolated =",window.crossOriginIsolated);