PageSourceSearch

https://unterrichtsplanung.ai/assets/offline-queue-BhNypXC-.js

js unterrichtsplanung.ai collected 2026-10-05 15:14:22 UTC 4,853 bytes, 1 lines download raw bytes

1import{t as e}from"./client-CgQ6iHoJ.js";var t=(e,t)=>t.some(t=>e instanceof t),n,r;function i(){return n||(n=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function a(){return r||(r=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var o=new WeakMap,s=new WeakMap,c=new WeakMap;function l(e){let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`success`,i),e.removeEventListener(`error`,a)},i=()=>{t(h(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener(`success`,i),e.addEventListener(`error`,a)});return c.set(t,e),t}function u(e){if(o.has(e))return;let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`complete`,i),e.removeEventListener(`error`,a),e.removeEventListener(`abort`,a)},i=()=>{t(),r()},a=()=>{n(e.error||new DOMException(`AbortError`,`AbortError`)),r()};e.addEventListener(`complete`,i),e.addEventListener(`error`,a),e.addEventListener(`abort`,a)});o.set(e,t)}var d={get(e,t,n){if(e instanceof IDBTransaction){if(t===`done`)return o.get(e);if(t===`store`)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return h(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t===`done`||t===`store`)?!0:t in e}};function f(e){d=e(d)}function p(e){return a().includes(e)?function(...t){return e.apply(g(this),t),h(this.request)}:function(...t){return h(e.apply(g(this),t))}}function m(e){return typeof e==`function`?p(e):(e instanceof IDBTransaction&&u(e),t(e,i())?new Proxy(e,d):e)}function h(e){if(e instanceof IDBRequest)return l(e);if(s.has(e))return s.get(e);let t=m(e);return t!==e&&(s.set(e,t),c.set(t,e)),t}var g=e=>c.get(e);function _(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){let o=indexedDB.open(e,t),s=h(o);return r&&o.addEventListener(`upgradeneeded`,e=>{r(h(o.result),e.oldVersion,e.newVersion,h(o.transaction),e)}),n&&o.addEventListener(`blocked`,e=>n(e.oldVersion,e.newVersion,e)),s.then(e=>{a&&e.addEventListener(`close`,()=>a()),i&&e.addEventListener(`versionchange`,e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}var v=[`get`,`getKey`,`getAll`,`getAllKeys`,`count`],y=[`put`,`add`,`delete`,`clear`],b=new Map;function x(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t==`string`))return;if(b.get(t))return b.get(t);let n=t.replace(/FromIndex$/,``),r=t!==n,i=y.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||v.includes(n)))return;let a=async function(e,...t){let a=this.transaction(e,i?`readwrite`:`readonly`),o=a.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&a.done]))[0]};return b.set(t,a),a}f(e=>({...e,get:(t,n,r)=>x(t,n)||e.get(t,n,r),has:(t,n)=>!!x(t,n)||e.has(t,n)}));var S=[`continue`,`continuePrimaryKey`,`advance`],C={},w=new WeakMap,T=new WeakMap,E={get(e,t){if(!S.includes(t))return e[t];let n=C[t];return n||(n=C[t]=function(...e){w.set(this,T.get(this)[t](...e))}),n}};async function*D(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;let n=new Proxy(t,E);for(T.set(n,t),c.set(n,g(t));t;)yield n,t=await(w.get(n)||t.continue()),w.delete(n)}function O(e,n){return n===Symbol.asyncIterator&&t(e,[IDBIndex,IDBObjectStore,IDBCursor])||n===`iterate`&&t(e,[IDBIndex,IDBObjectStore])}f(e=>({...e,get(t,n,r){return O(t,n)?D:e.get(t,n,r)},has(t,n){return O(t,n)||e.has(t,n)}}));var k=`lernplan-offline`,A=1,j=`learning_state_queue`,M=null;function N(){return M||(M=_(k,A,{upgrade(e){e.objectStoreNames.contains(j)||e.createObjectStore(j,{keyPath:`id`,autoIncrement:!0})}})),M}async function P(e){let t=await N(),n=await t.getAll(j);for(let r of n)r.student_id===e.student_id&&r.learning_goal_id===e.learning_goal_id&&r.id&&await t.delete(j,r.id);await t.add(j,{...e,queued_at:Date.now()})}async function F(){return(await N()).count(j)}async function I(){if(!navigator.onLine)return{flushed:0,failed:0};let t=await N(),n=await t.getAll(j),r=0,i=0;for(let a of n){let n={student_id:a.student_id,learning_goal_id:a.learning_goal_id,level:a.level,notes:a.notes,updated_by:a.updated_by,source:a.source,updated_at:new Date().toISOString()};a.lesson_plan_id&&(n.lesson_plan_id=a.lesson_plan_id);let{error:o}=await e.from(`lp_student_learning_state`).upsert(n,{onConflict:`student_id,learning_goal_id`});if(o){i+=1;continue}a.id&&await t.delete(j,a.id),r+=1}return{flushed:r,failed:i}}async function L(t){if(navigator.onLine){let n={student_id:t.student_id,learning_goal_id:t.learning_goal_id,level:t.level,notes:t.notes,updated_by:t.updated_by,source:t.source};t.lesson_plan_id&&(n.lesson_plan_id=t.lesson_plan_id);let{error:r}=await e.from(`lp_student_learning_state`).upsert(n,{onConflict:`student_id,learning_goal_id`});if(!r)return`online`}return await P(t),`queued`}function R(){typeof window>`u`||window.addEventListener(`online`,()=>{I()})}
1export{L as i,F as n,R as r,I as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.