diff --git a/frontend/src/test/components/ApproveCard.test.ts b/frontend/src/test/components/ApproveCard.test.ts index 0b1cbbf..df50b35 100644 --- a/frontend/src/test/components/ApproveCard.test.ts +++ b/frontend/src/test/components/ApproveCard.test.ts @@ -43,6 +43,7 @@ const makeDevice = (overrides: Partial = {}): Device => ({ uniquenessWindow: 30, linkedAt: '2026-01-01T00:00:00Z', lastSeenAt: null, + nextPollExpectedAt: null, lockedImageId: null, currentImageId: null, ...overrides, diff --git a/frontend/src/test/components/DevicePicker.test.ts b/frontend/src/test/components/DevicePicker.test.ts index 1335768..149cfa4 100644 --- a/frontend/src/test/components/DevicePicker.test.ts +++ b/frontend/src/test/components/DevicePicker.test.ts @@ -32,6 +32,7 @@ const makeDevice = (overrides: Partial = {}): Device => ({ uniquenessWindow: 30, linkedAt: '2026-01-01T00:00:00Z', lastSeenAt: null, + nextPollExpectedAt: null, lockedImageId: null, currentImageId: null, ...overrides, diff --git a/frontend/src/test/stores/devices.test.ts b/frontend/src/test/stores/devices.test.ts index 2bead8c..1d1d380 100644 --- a/frontend/src/test/stores/devices.test.ts +++ b/frontend/src/test/stores/devices.test.ts @@ -14,6 +14,7 @@ const makeDevice = (overrides: Partial = {}): Device => ({ uniquenessWindow: 30, linkedAt: '2026-01-01T00:00:00Z', lastSeenAt: null, + nextPollExpectedAt: null, lockedImageId: null, currentImageId: null, ...overrides, diff --git a/frontend/src/test/views/HomeView.test.ts b/frontend/src/test/views/HomeView.test.ts index 5aec3f4..2f533fc 100644 --- a/frontend/src/test/views/HomeView.test.ts +++ b/frontend/src/test/views/HomeView.test.ts @@ -71,6 +71,7 @@ const makeDevice = (overrides: Partial = {}): Device => ({ uniquenessWindow: 30, linkedAt: '2026-01-01T00:00:00Z', lastSeenAt: null, + nextPollExpectedAt: null, lockedImageId: null, currentImageId: null, ...overrides, @@ -586,6 +587,33 @@ describe('HomeView', () => { })) }) + // The card's "next sync" must use the server-stamped nextPollExpectedAt + // when present, ignoring the locally-saved (but not yet device-applied) + // schedule. This is the bug Matt hit: changing 5 min → 3 min in the sheet + // made the card jump to "in 3m" even though the device is still asleep + // on the 5-min schedule and will wake at lastSeenAt + 5 min. + it('nextSync uses server nextPollExpectedAt when present, not local schedule', async () => { + const devicesStore = useDevicesStore() + devicesStore.devices = [makeDevice({ + id: 1, + // Locally we just saved every-3-min, but the device is still on + // every-5-min until it next polls. The server's expected-next-poll + // (set under the old schedule at the last poll) is 4 minutes out. + rotationIntervalMinutes: 3, + wakeTimes: [], + lastSeenAt: new Date(Date.now() - 60_000).toISOString(), + nextPollExpectedAt: new Date(Date.now() + 4 * 60_000).toISOString(), + })] + vi.spyOn(devicesStore, 'fetchDevices').mockResolvedValue() + + const wrapper = mountView() + await flushPromises() + const props = wrapper.findComponent({ name: 'FrameCard' }).props() + // 4 minutes — what the server actually plans, NOT 2 min from + // (lastSeenAt + 3 min - now), which would be the bug. + expect(props.nextSync).toMatch(/in 4m/) + }) + // The "next update" preview must reflect when the device will *actually* // next sync — that's when it picks up the new settings, not the first hit // of the new schedule. The device is asleep on its CURRENT schedule. diff --git a/frontend/src/test/views/LibraryView.test.ts b/frontend/src/test/views/LibraryView.test.ts index 9f4f3a1..2774b16 100644 --- a/frontend/src/test/views/LibraryView.test.ts +++ b/frontend/src/test/views/LibraryView.test.ts @@ -85,6 +85,7 @@ const makeDevice = (overrides: Partial = {}): Device => ({ uniquenessWindow: 30, linkedAt: '2026-01-01T00:00:00Z', lastSeenAt: null, + nextPollExpectedAt: null, lockedImageId: null, currentImageId: null, ...overrides, diff --git a/frontend/src/test/views/UploadView.test.ts b/frontend/src/test/views/UploadView.test.ts index 1e36a16..35445ad 100644 --- a/frontend/src/test/views/UploadView.test.ts +++ b/frontend/src/test/views/UploadView.test.ts @@ -61,6 +61,7 @@ const makeDevice = (overrides: Partial = {}): Device => ({ uniquenessWindow: 30, linkedAt: '2026-01-01T00:00:00Z', lastSeenAt: null, + nextPollExpectedAt: null, lockedImageId: null, currentImageId: null, ...overrides, diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index 22b2f00..dc18d61 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -18,6 +18,8 @@ export interface Device { uniquenessWindow: number linkedAt: string lastSeenAt: string | null + /** Server-stamped expected next poll time. Drives the "next sync" label. */ + nextPollExpectedAt: string | null lockedImageId: number | null currentImageId: number | null } diff --git a/frontend/src/views/HomeView.vue b/frontend/src/views/HomeView.vue index c10be92..97752e7 100644 --- a/frontend/src/views/HomeView.vue +++ b/frontend/src/views/HomeView.vue @@ -277,19 +277,38 @@ function nextWakeMatch(times: number[], tz: string): { minutes: number; today: b return best } +// Prefer the server-stamped nextPollExpectedAt — that's the schedule the +// device is *actually* on, set every poll. Falls back to a local computation +// for devices that haven't polled since the column was added. function nextSyncLabel(device: Device): string | null { - if (device.wakeTimes.length > 0) { + let nextMs: number | null = null + if (device.nextPollExpectedAt) { + nextMs = new Date(device.nextPollExpectedAt).getTime() + } else if (device.wakeTimes.length > 0) { const next = nextWakeMatch(device.wakeTimes, device.timezone || 'UTC') if (!next) return null return `next sync ~${formatTime(next.minutes)} ${next.today ? 'today' : 'tomorrow'}` + } else if (device.lastSeenAt) { + nextMs = new Date(device.lastSeenAt).getTime() + device.rotationIntervalMinutes * 60_000 + } else { + return null } - if (!device.lastSeenAt) return null - const next = new Date(device.lastSeenAt).getTime() + device.rotationIntervalMinutes * 60_000 - const fromNow = next - Date.now() + + const fromNow = nextMs - Date.now() if (fromNow <= 0) return null if (fromNow < 60_000) return 'next sync in <1m' if (fromNow < 3_600_000) return `next sync in ${Math.round(fromNow / 60_000)}m` - return `next sync in ${Math.round(fromNow / 3_600_000)}h` + if (fromNow < 86_400_000) { + // Long horizons read better as a clock time than "in 14h". + const tz = device.timezone || 'UTC' + const minOfDay = getMinuteOfDayInTz(new Date(nextMs), tz) + const dayDelta = daysFromTodayInTz(new Date(nextMs), tz) + const dayLabel = dayDelta === 0 ? 'today' + : dayDelta === 1 ? 'tomorrow' + : `in ${dayDelta}d` + return `next sync ~${formatTime(minOfDay)} ${dayLabel}` + } + return `next sync in ${Math.round(fromNow / 86_400_000)}d` } // Home shows what's actually on the frame right now — the last image the @@ -507,17 +526,23 @@ const nextUpdatePreview = computed(() => { // The preview is about when the device will *next sync* — it does NOT // depend on the proposed new settings, only on the device's current saved // schedule. The "no update times yet" hint already lives in the time list. - if (!device.lastSeenAt) { - return 'Next update: when the frame next connects' - } + const tz = device.timezone || 'UTC' - const tz = device.timezone || 'UTC' - const lastSeen = new Date(device.lastSeenAt).getTime() + // Prefer the server-stamped expected-next-poll: that timestamp was set + // under the schedule active at the device's last poll, and isn't disturbed + // by the user's PATCHes — exactly what we want for "when will the new + // settings reach the frame?" let nextPollMs: number - if (device.wakeTimes.length > 0) { - nextPollMs = nextWakeAfter(lastSeen, device.wakeTimes, tz) + if (device.nextPollExpectedAt) { + nextPollMs = new Date(device.nextPollExpectedAt).getTime() + } else if (!device.lastSeenAt) { + return 'Next update: when the frame next connects' } else { - nextPollMs = lastSeen + device.rotationIntervalMinutes * 60_000 + // Legacy fallback for devices that haven't polled since the column was added. + const lastSeen = new Date(device.lastSeenAt).getTime() + nextPollMs = device.wakeTimes.length > 0 + ? nextWakeAfter(lastSeen, device.wakeTimes, tz) + : lastSeen + device.rotationIntervalMinutes * 60_000 } // Already-overdue device: it'll poll any moment now. if (nextPollMs < Date.now()) nextPollMs = Date.now() diff --git a/migrations/Version20260507230002.php b/migrations/Version20260507230002.php new file mode 100644 index 0000000..2a59d8b --- /dev/null +++ b/migrations/Version20260507230002.php @@ -0,0 +1,27 @@ +addSql('ALTER TABLE device ADD next_poll_expected_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql("COMMENT ON COLUMN device.next_poll_expected_at IS '(DC2Type:datetime_immutable)'"); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE device DROP COLUMN next_poll_expected_at'); + } +} diff --git a/public/build/assets/BaseBottomSheet-DohSPmvo.js b/public/build/assets/BaseBottomSheet-Y2PW4H1i.js similarity index 98% rename from public/build/assets/BaseBottomSheet-DohSPmvo.js rename to public/build/assets/BaseBottomSheet-Y2PW4H1i.js index fba12b1..13302bf 100644 --- a/public/build/assets/BaseBottomSheet-DohSPmvo.js +++ b/public/build/assets/BaseBottomSheet-Y2PW4H1i.js @@ -1 +1 @@ -import{C as e,L as t,N as n,O as r,R as i,S as a,V as o,_ as s,d as c,dt as l,f as u,g as d,j as f,p,r as m,s as h,t as g,u as _,ut as v}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{c as y,d as b,f as x}from"./index-B5Obd-7x.js";var S=m(`devices`,()=>{let e=o([]),t=o(!1),n=o(null);async function r(r={}){r.silent||(t.value=!0),n.value=null;try{let t=await fetch(`/api/devices`);if(!t.ok)throw Error(`Failed to load devices`);e.value=await t.json()}catch(e){n.value=e instanceof Error?e.message:`Unknown error`}finally{t.value=!1}}async function i(t,n){let r=await fetch(`/api/devices/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to update device`);let i=await r.json(),a=e.value.findIndex(e=>e.id===t);return a!==-1&&(e.value[a]=i),i}async function a(t,n){let r=await fetch(`/api/devices/${t}/lock`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({imageId:n})});if(!r.ok)throw Error(`Failed to lock image`);let i=await r.json(),a=e.value.findIndex(e=>e.id===t);return a!==-1&&(e.value[a]=i),i}async function s(t){let n=await fetch(`/api/devices/${t}/lock`,{method:`DELETE`});if(!n.ok)throw Error(`Failed to unlock`);let r=await n.json(),i=e.value.findIndex(e=>e.id===t);return i!==-1&&(e.value[i]=r),r}return{devices:e,loading:t,error:n,fetchDevices:r,updateDevice:i,lockImage:a,unlockImage:s}}),C=m(`upload`,()=>{let e=o(null),t=o(null),n=o(null),r=o(null),i=o(null),a=o(null),s=o([]),c=o(null),l=o([]),u=o(null);function d(n,r){_(),e.value=n,t.value=URL.createObjectURL(n),c.value=r??null,l.value=r?[r]:[]}async function f(n,r){_();let o=await(await fetch(n.originalUrl)).blob();e.value=new File([o],n.originalFilename,{type:o.type}),t.value=URL.createObjectURL(o),u.value=n.id,i.value=n.cropParams??null,a.value=n.cropOrientation??null,s.value=n.stickerState?[...n.stickerState]:[],l.value=n.approvedDeviceIds,c.value=r??null}function p(e,t,o){r.value&&URL.revokeObjectURL(r.value),n.value=e,r.value=URL.createObjectURL(e),i.value=t,a.value=o}function m(e){s.value=[...s.value,e]}function h(e,t){s.value=s.value.map(n=>n.id===e?{...n,...t}:n)}function g(e){s.value=s.value.filter(t=>t.id!==e)}function _(){t.value&&URL.revokeObjectURL(t.value),r.value&&URL.revokeObjectURL(r.value),e.value=null,t.value=null,n.value=null,r.value=null,i.value=null,a.value=null,s.value=[],c.value=null,l.value=[],u.value=null}return{originalFile:e,originalUrl:t,croppedBlob:n,croppedUrl:r,cropParams:i,cropOrientation:a,stickers:s,contextDeviceId:c,selectedDeviceIds:l,editingImageId:u,init:d,initEdit:f,setCrop:p,addSticker:m,updateSticker:h,removeSticker:g,cleanup:_}}),w={key:0,class:`btn__spinner`,"aria-hidden":`true`},T=g(s({__name:`BaseButton`,props:{variant:{default:`primary`},tag:{default:`button`},type:{default:`button`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},setup(e){return(t,o)=>(r(),c(n(e.tag),a({type:e.tag===`button`?e.type:void 0,disabled:e.disabled||e.loading,class:[`btn`,`btn--${e.variant}`,{"btn--loading":e.loading}]},t.$attrs),{default:i(()=>[e.loading?(r(),p(`span`,w)):u(``,!0),f(t.$slots,`default`,{},void 0,!0)]),_:3},16,[`type`,`disabled`,`class`]))}}),[[`__scopeId`,`data-v-7d3f1e61`]]),E=[`aria-label`],D=80,O=g(s({__name:`BaseBottomSheet`,props:{modelValue:{type:Boolean},label:{}},emits:[`update:modelValue`],setup(n,{emit:a}){let s=n,m=a,g=o(null),S=o(0),C=o(!1),w=0,T=null,O=null;function k(){m(`update:modelValue`,!1)}function A(e){w=e.touches[0].clientY,C.value=!0,S.value=0}function j(e){if(!C.value)return;let t=e.touches[0].clientY-w;S.value=t>0?t:0}function M(){C.value&&(C.value=!1,S.value>D&&k(),S.value=0)}function N(e){e.pointerType!==`touch`&&(w=e.clientY,C.value=!0,S.value=0,T=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),window.addEventListener(`pointermove`,P),window.addEventListener(`pointerup`,F),window.addEventListener(`pointercancel`,F))}function P(e){if(!C.value||e.pointerId!==T)return;let t=e.clientY-w;S.value=t>0?t:0}function F(e){e.pointerId===T&&(T=null,window.removeEventListener(`pointermove`,P),window.removeEventListener(`pointerup`,F),window.removeEventListener(`pointercancel`,F),M())}return t(()=>s.modelValue,async t=>{t?(O=document.activeElement,await e(),g.value?.focus()):(O?.focus(),O=null,S.value=0,C.value=!1)}),(e,t)=>(r(),c(h,{to:`body`},[d(y,{name:`sheet`},{default:i(()=>[n.modelValue?(r(),p(`div`,{key:0,class:`sheet-overlay`,role:`dialog`,"aria-label":n.label,"aria-modal":`true`,onClick:x(k,[`self`]),onKeydown:b(k,[`esc`])},[_(`div`,{ref_key:`sheetRef`,ref:g,class:v([`sheet`,{"sheet--dragging":C.value}]),style:l(S.value>0?{transform:`translateY(${S.value}px)`}:void 0),tabindex:`-1`},[_(`div`,{class:`sheet__handle-target`,onTouchstartPassive:A,onTouchmovePassive:j,onTouchend:M,onTouchcancel:M,onPointerdown:N,"aria-hidden":`true`},[...t[0]||=[_(`div`,{class:`sheet__handle`},null,-1)]],32),f(e.$slots,`default`,{},void 0,!0)],6)],40,E)):u(``,!0)]),_:3})]))}}),[[`__scopeId`,`data-v-967683c3`]]);export{S as i,T as n,C as r,O as t}; \ No newline at end of file +import{C as e,L as t,N as n,O as r,R as i,S as a,V as o,_ as s,d as c,dt as l,f as u,g as d,j as f,p,r as m,s as h,t as g,u as _,ut as v}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{c as y,d as b,f as x}from"./index-DabTPrXi.js";var S=m(`devices`,()=>{let e=o([]),t=o(!1),n=o(null);async function r(r={}){r.silent||(t.value=!0),n.value=null;try{let t=await fetch(`/api/devices`);if(!t.ok)throw Error(`Failed to load devices`);e.value=await t.json()}catch(e){n.value=e instanceof Error?e.message:`Unknown error`}finally{t.value=!1}}async function i(t,n){let r=await fetch(`/api/devices/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to update device`);let i=await r.json(),a=e.value.findIndex(e=>e.id===t);return a!==-1&&(e.value[a]=i),i}async function a(t,n){let r=await fetch(`/api/devices/${t}/lock`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({imageId:n})});if(!r.ok)throw Error(`Failed to lock image`);let i=await r.json(),a=e.value.findIndex(e=>e.id===t);return a!==-1&&(e.value[a]=i),i}async function s(t){let n=await fetch(`/api/devices/${t}/lock`,{method:`DELETE`});if(!n.ok)throw Error(`Failed to unlock`);let r=await n.json(),i=e.value.findIndex(e=>e.id===t);return i!==-1&&(e.value[i]=r),r}return{devices:e,loading:t,error:n,fetchDevices:r,updateDevice:i,lockImage:a,unlockImage:s}}),C=m(`upload`,()=>{let e=o(null),t=o(null),n=o(null),r=o(null),i=o(null),a=o(null),s=o([]),c=o(null),l=o([]),u=o(null);function d(n,r){_(),e.value=n,t.value=URL.createObjectURL(n),c.value=r??null,l.value=r?[r]:[]}async function f(n,r){_();let o=await(await fetch(n.originalUrl)).blob();e.value=new File([o],n.originalFilename,{type:o.type}),t.value=URL.createObjectURL(o),u.value=n.id,i.value=n.cropParams??null,a.value=n.cropOrientation??null,s.value=n.stickerState?[...n.stickerState]:[],l.value=n.approvedDeviceIds,c.value=r??null}function p(e,t,o){r.value&&URL.revokeObjectURL(r.value),n.value=e,r.value=URL.createObjectURL(e),i.value=t,a.value=o}function m(e){s.value=[...s.value,e]}function h(e,t){s.value=s.value.map(n=>n.id===e?{...n,...t}:n)}function g(e){s.value=s.value.filter(t=>t.id!==e)}function _(){t.value&&URL.revokeObjectURL(t.value),r.value&&URL.revokeObjectURL(r.value),e.value=null,t.value=null,n.value=null,r.value=null,i.value=null,a.value=null,s.value=[],c.value=null,l.value=[],u.value=null}return{originalFile:e,originalUrl:t,croppedBlob:n,croppedUrl:r,cropParams:i,cropOrientation:a,stickers:s,contextDeviceId:c,selectedDeviceIds:l,editingImageId:u,init:d,initEdit:f,setCrop:p,addSticker:m,updateSticker:h,removeSticker:g,cleanup:_}}),w={key:0,class:`btn__spinner`,"aria-hidden":`true`},T=g(s({__name:`BaseButton`,props:{variant:{default:`primary`},tag:{default:`button`},type:{default:`button`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},setup(e){return(t,o)=>(r(),c(n(e.tag),a({type:e.tag===`button`?e.type:void 0,disabled:e.disabled||e.loading,class:[`btn`,`btn--${e.variant}`,{"btn--loading":e.loading}]},t.$attrs),{default:i(()=>[e.loading?(r(),p(`span`,w)):u(``,!0),f(t.$slots,`default`,{},void 0,!0)]),_:3},16,[`type`,`disabled`,`class`]))}}),[[`__scopeId`,`data-v-7d3f1e61`]]),E=[`aria-label`],D=80,O=g(s({__name:`BaseBottomSheet`,props:{modelValue:{type:Boolean},label:{}},emits:[`update:modelValue`],setup(n,{emit:a}){let s=n,m=a,g=o(null),S=o(0),C=o(!1),w=0,T=null,O=null;function k(){m(`update:modelValue`,!1)}function A(e){w=e.touches[0].clientY,C.value=!0,S.value=0}function j(e){if(!C.value)return;let t=e.touches[0].clientY-w;S.value=t>0?t:0}function M(){C.value&&(C.value=!1,S.value>D&&k(),S.value=0)}function N(e){e.pointerType!==`touch`&&(w=e.clientY,C.value=!0,S.value=0,T=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),window.addEventListener(`pointermove`,P),window.addEventListener(`pointerup`,F),window.addEventListener(`pointercancel`,F))}function P(e){if(!C.value||e.pointerId!==T)return;let t=e.clientY-w;S.value=t>0?t:0}function F(e){e.pointerId===T&&(T=null,window.removeEventListener(`pointermove`,P),window.removeEventListener(`pointerup`,F),window.removeEventListener(`pointercancel`,F),M())}return t(()=>s.modelValue,async t=>{t?(O=document.activeElement,await e(),g.value?.focus()):(O?.focus(),O=null,S.value=0,C.value=!1)}),(e,t)=>(r(),c(h,{to:`body`},[d(y,{name:`sheet`},{default:i(()=>[n.modelValue?(r(),p(`div`,{key:0,class:`sheet-overlay`,role:`dialog`,"aria-label":n.label,"aria-modal":`true`,onClick:x(k,[`self`]),onKeydown:b(k,[`esc`])},[_(`div`,{ref_key:`sheetRef`,ref:g,class:v([`sheet`,{"sheet--dragging":C.value}]),style:l(S.value>0?{transform:`translateY(${S.value}px)`}:void 0),tabindex:`-1`},[_(`div`,{class:`sheet__handle-target`,onTouchstartPassive:A,onTouchmovePassive:j,onTouchend:M,onTouchcancel:M,onPointerdown:N,"aria-hidden":`true`},[...t[0]||=[_(`div`,{class:`sheet__handle`},null,-1)]],32),f(e.$slots,`default`,{},void 0,!0)],6)],40,E)):u(``,!0)]),_:3})]))}}),[[`__scopeId`,`data-v-967683c3`]]);export{S as i,T as n,C as r,O as t}; \ No newline at end of file diff --git a/public/build/assets/DevicePicker-BF3g7ETO.js b/public/build/assets/DevicePicker-DcPlHAXI.js similarity index 92% rename from public/build/assets/DevicePicker-BF3g7ETO.js rename to public/build/assets/DevicePicker-DcPlHAXI.js index 5681353..fb4b76d 100644 --- a/public/build/assets/DevicePicker-BF3g7ETO.js +++ b/public/build/assets/DevicePicker-DcPlHAXI.js @@ -1 +1 @@ -import{A as e,O as t,R as n,_ as r,d as i,ft as a,g as o,h as s,l as c,o as l,p as u,t as d,u as f}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{n as p,t as m}from"./BaseBottomSheet-DohSPmvo.js";var h={class:`device-picker__list`},g=[`checked`,`onChange`],_={class:`device-picker__name`},v={class:`device-picker__orientation`},y=d(r({__name:`DevicePicker`,props:{modelValue:{type:Boolean},devices:{},selected:{},uploading:{type:Boolean}},emits:[`update:modelValue`,`update:selected`,`confirm`],setup(r,{emit:d}){let y=r,b=d;function x(e){y.selected.includes(e)?b(`update:selected`,y.selected.filter(t=>t!==e)):b(`update:selected`,[...y.selected,e])}let S=c(()=>{let e=y.selected.length;return e===0?`Add to frame`:`Add to ${e} frame${e>1?`s`:``}`});return(c,d)=>(t(),i(m,{"model-value":r.modelValue,label:`Choose frames`,"onUpdate:modelValue":d[1]||=e=>c.$emit(`update:modelValue`,e)},{default:n(()=>[d[2]||=f(`h2`,{class:`device-picker__title`},`Add to frames`,-1),d[3]||=f(`p`,{class:`device-picker__sub`},`Choose which frames will show this photo.`,-1),f(`div`,h,[(t(!0),u(l,null,e(r.devices,e=>(t(),u(`label`,{key:e.id,class:`device-picker__row`},[f(`input`,{type:`checkbox`,class:`device-picker__check`,checked:r.selected.includes(e.id),onChange:t=>x(e.id)},null,40,g),f(`span`,_,a(e.name),1),f(`span`,v,a(e.orientation),1)]))),128))]),o(p,{variant:`primary`,class:`device-picker__confirm`,disabled:r.selected.length===0||r.uploading,onClick:d[0]||=e=>c.$emit(`confirm`)},{default:n(()=>[s(a(r.uploading?`Uploading…`:S.value),1)]),_:1},8,[`disabled`])]),_:1},8,[`model-value`]))}}),[[`__scopeId`,`data-v-a6466fa5`]]);export{y as t}; \ No newline at end of file +import{A as e,O as t,R as n,_ as r,d as i,ft as a,g as o,h as s,l as c,o as l,p as u,t as d,u as f}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{n as p,t as m}from"./BaseBottomSheet-Y2PW4H1i.js";var h={class:`device-picker__list`},g=[`checked`,`onChange`],_={class:`device-picker__name`},v={class:`device-picker__orientation`},y=d(r({__name:`DevicePicker`,props:{modelValue:{type:Boolean},devices:{},selected:{},uploading:{type:Boolean}},emits:[`update:modelValue`,`update:selected`,`confirm`],setup(r,{emit:d}){let y=r,b=d;function x(e){y.selected.includes(e)?b(`update:selected`,y.selected.filter(t=>t!==e)):b(`update:selected`,[...y.selected,e])}let S=c(()=>{let e=y.selected.length;return e===0?`Add to frame`:`Add to ${e} frame${e>1?`s`:``}`});return(c,d)=>(t(),i(m,{"model-value":r.modelValue,label:`Choose frames`,"onUpdate:modelValue":d[1]||=e=>c.$emit(`update:modelValue`,e)},{default:n(()=>[d[2]||=f(`h2`,{class:`device-picker__title`},`Add to frames`,-1),d[3]||=f(`p`,{class:`device-picker__sub`},`Choose which frames will show this photo.`,-1),f(`div`,h,[(t(!0),u(l,null,e(r.devices,e=>(t(),u(`label`,{key:e.id,class:`device-picker__row`},[f(`input`,{type:`checkbox`,class:`device-picker__check`,checked:r.selected.includes(e.id),onChange:t=>x(e.id)},null,40,g),f(`span`,_,a(e.name),1),f(`span`,v,a(e.orientation),1)]))),128))]),o(p,{variant:`primary`,class:`device-picker__confirm`,disabled:r.selected.length===0||r.uploading,onClick:d[0]||=e=>c.$emit(`confirm`)},{default:n(()=>[s(a(r.uploading?`Uploading…`:S.value),1)]),_:1},8,[`disabled`])]),_:1},8,[`model-value`]))}}),[[`__scopeId`,`data-v-a6466fa5`]]);export{y as t}; \ No newline at end of file diff --git a/public/build/assets/HomeView-9tP5PwaG.css b/public/build/assets/HomeView-Bc2Cp9Ti.css similarity index 78% rename from public/build/assets/HomeView-9tP5PwaG.css rename to public/build/assets/HomeView-Bc2Cp9Ti.css index 03d2806..6be9c0d 100644 --- a/public/build/assets/HomeView-9tP5PwaG.css +++ b/public/build/assets/HomeView-Bc2Cp9Ti.css @@ -1 +1 @@ -.frame-card[data-v-608d39a4]{background:var(--color-surface);border:2px solid var(--color-border);border-radius:var(--radius-md);transition:border-color var(--duration-fast);position:relative;overflow:hidden}.frame-card--ok[data-v-608d39a4]{border-color:var(--color-border)}.frame-card--sync-fail[data-v-608d39a4]{border-color:#c49a20}.frame-card--offline[data-v-608d39a4]{border-color:#c0392b}.frame-card__settings-btn[data-v-608d39a4]{top:var(--space-2);right:var(--space-2);-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);width:36px;height:36px;color:var(--color-text);cursor:pointer;z-index:1;background:#ffffffd9;border:none;border-radius:50%;justify-content:center;align-items:center;display:flex;position:absolute;box-shadow:0 1px 4px #00000026}.frame-card__status-line[data-v-608d39a4]{font-size:var(--text-sm);align-items:center;gap:6px;font-weight:600;display:flex}.frame-card--ok .frame-card__status-line[data-v-608d39a4]{color:#1a7f4b}.frame-card--sync-fail .frame-card__status-line[data-v-608d39a4]{color:#8a6a00}.frame-card--offline .frame-card__status-line[data-v-608d39a4]{color:#c0392b}.frame-card__status-dot[data-v-608d39a4]{border-radius:50%;flex-shrink:0;width:8px;height:8px}.frame-card--ok .frame-card__status-dot[data-v-608d39a4]{background:#1a7f4b}.frame-card--sync-fail .frame-card__status-dot[data-v-608d39a4]{background:#c49a20}.frame-card--offline .frame-card__status-dot[data-v-608d39a4]{background:#c0392b}.frame-card__sync-line[data-v-608d39a4]{font-size:var(--text-xs);color:var(--color-text-muted);flex-wrap:wrap;gap:0 6px;margin-top:2px;display:flex}.frame-card__sync-sep[data-v-608d39a4]{opacity:.6}.frame-card--large[data-v-608d39a4]{flex-direction:column;height:100%;display:flex}.frame-card--large .frame-card__preview[data-v-608d39a4]{background:var(--color-surface-2);flex:none;justify-content:center;align-items:center;max-height:40dvh;display:flex;overflow:hidden}.frame-card--large .frame-card__img[data-v-608d39a4]{width:auto;max-width:100%;height:auto;max-height:100%;display:block}.frame-card--large .frame-card__empty-preview[data-v-608d39a4]{color:var(--color-text-muted);opacity:.5;justify-content:center;align-items:center;width:100%;display:flex}.frame-card--large .frame-card__body[data-v-608d39a4]{min-height:0;padding:var(--space-4);gap:var(--space-3);flex-direction:column;flex:1;display:flex}.frame-card--large .frame-card__info[data-v-608d39a4]{flex-direction:column;gap:2px;min-width:0;display:flex}.frame-card--large .frame-card__name[data-v-608d39a4]{font-size:var(--text-md);font-weight:700}.frame-card--large .frame-card__add-btn[data-v-608d39a4]{width:100%;margin-top:auto}.frame-card--compact[data-v-608d39a4]{align-items:center;gap:var(--space-3);padding:var(--space-3) var(--space-4);display:flex}.frame-card--compact .frame-card__preview[data-v-608d39a4]{border-radius:var(--radius-sm);background:var(--color-surface-2);flex-shrink:0;justify-content:center;align-items:center;width:52px;height:52px;display:flex;overflow:hidden}.frame-card--compact .frame-card__img[data-v-608d39a4]{object-fit:cover;width:100%;height:100%}.frame-card--compact .frame-card__empty-preview[data-v-608d39a4]{color:var(--color-text-muted);opacity:.4}.frame-card--compact .frame-card__body[data-v-608d39a4]{justify-content:space-between;align-items:center;gap:var(--space-2);flex:1;min-width:0;display:flex}.frame-card--compact .frame-card__info[data-v-608d39a4]{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.frame-card--compact .frame-card__name[data-v-608d39a4]{font-size:var(--text-base);font-weight:700}.frame-card--compact .frame-card__count[data-v-608d39a4]{font-size:var(--text-xs);color:var(--color-text-muted)}.frame-card__add-btn[data-v-608d39a4]{flex-shrink:0}@media (orientation:landscape) and (height<=600px){.frame-card--large .frame-card__preview[data-v-608d39a4]{flex:1;justify-content:center;align-items:center;min-height:0;display:flex;overflow:hidden}.frame-card--large .frame-card__img[data-v-608d39a4]{object-fit:contain;width:100%;height:100%}.frame-card--large .frame-card__body[data-v-608d39a4]{align-items:center;gap:var(--space-3);padding:var(--space-2) var(--space-3);flex-direction:row;flex:none}.frame-card--large .frame-card__info[data-v-608d39a4]{flex:1;min-width:0}.frame-card--large .frame-card__sync-line[data-v-608d39a4]{display:none}.frame-card--large .frame-card__add-btn[data-v-608d39a4]{flex-shrink:0;width:auto;margin-top:0}.frame-card--large .frame-card__settings-btn[data-v-608d39a4]{width:32px;height:32px;top:var(--space-1);right:var(--space-1)}}.input-wrap[data-v-c8235ab2]{width:100%;position:relative}.input-wrap__field[data-v-c8235ab2]{width:100%;min-height:56px;padding:22px var(--space-4) 8px;border:1px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface);color:var(--color-text);font-family:var(--font-family);font-size:var(--text-base);transition:border-color var(--duration-fast)}.input-wrap__field[data-v-c8235ab2]::placeholder{color:#0000}.input-wrap__field[data-v-c8235ab2]:focus{border-color:var(--color-primary);outline:none}.input-wrap__field:not(:placeholder-shown)~.input-wrap__label[data-v-c8235ab2],.input-wrap__field:focus~.input-wrap__label[data-v-c8235ab2]{font-size:var(--text-xs);color:var(--color-primary);top:8px;transform:none}.input-wrap__label[data-v-c8235ab2]{left:var(--space-4);color:var(--color-text-muted);font-size:var(--text-base);pointer-events:none;transition:top var(--duration-fast), font-size var(--duration-fast), color var(--duration-fast), transform var(--duration-fast);position:absolute;top:50%;transform:translateY(-50%)}.input-wrap--error .input-wrap__field[data-v-c8235ab2]{border-color:var(--color-destructive)}.input-wrap__error[data-v-c8235ab2]{margin-top:var(--space-1);padding-left:var(--space-4);font-size:var(--text-sm);color:var(--color-destructive)}.orientation-picker[data-v-679dae08]{gap:var(--space-3);grid-template-columns:repeat(2,1fr);display:grid}.orientation-opt[data-v-679dae08]{align-items:center;gap:var(--space-1);padding:var(--space-3) var(--space-2);background:var(--color-surface);border:2px solid var(--color-border);border-radius:var(--radius-md);cursor:pointer;transition:border-color var(--duration-fast);min-height:var(--touch-min);flex-direction:column;display:flex}.orientation-opt--active[data-v-679dae08]{border-color:var(--color-primary)}.orientation-opt__diagram[data-v-679dae08]{width:48px;height:48px;color:var(--color-text-muted)}.orientation-opt__label[data-v-679dae08]{font-size:var(--text-xs);color:var(--color-text);font-weight:700}.orientation-opt__sub[data-v-679dae08]{font-size:var(--text-xs);color:var(--color-text-muted);text-align:center;line-height:1.2}.home-view[data-v-e927a6a4]{padding:var(--space-4) var(--space-4) calc(var(--bottom-nav-height) + var(--space-4));gap:var(--space-3);flex-direction:column;flex:1;display:flex}.home-view__loading[data-v-e927a6a4]{color:var(--color-text-muted);font-size:var(--text-sm);padding:var(--space-4) 0;text-align:center}.home-view__empty[data-v-e927a6a4]{padding-top:var(--space-6);justify-content:center;display:flex}.home-view__empty-card[data-v-e927a6a4]{background:var(--color-surface);border:2px dashed var(--color-border);border-radius:var(--radius-md);padding:var(--space-6) var(--space-5);text-align:center;align-items:center;gap:var(--space-3);flex-direction:column;width:100%;max-width:320px;display:flex}.home-view__empty-icon[data-v-e927a6a4]{color:var(--color-text-muted);opacity:.5}.home-view__empty-title[data-v-e927a6a4]{font-size:var(--text-md);font-weight:700}.home-view__empty-sub[data-v-e927a6a4]{font-size:var(--text-sm);color:var(--color-text-muted);line-height:1.5}.home-view__single[data-v-e927a6a4]{flex-direction:column;flex:1;display:flex}.home-view__stack[data-v-e927a6a4]{gap:var(--space-3);scroll-snap-type:y mandatory;scroll-behavior:smooth;scrollbar-width:none;-webkit-overflow-scrolling:touch;flex-direction:column;flex:1;min-height:0;display:flex;overflow-y:auto}.home-view__stack[data-v-e927a6a4]::-webkit-scrollbar{display:none}.home-view__slide[data-v-e927a6a4]{box-sizing:border-box;scroll-snap-align:start;scroll-snap-stop:always;flex-direction:column;flex:none;min-height:100%;display:flex}@media (orientation:landscape) and (height<=600px){.home-view__stack[data-v-e927a6a4]{scroll-snap-type:x mandatory;gap:var(--space-3);margin:0 calc(-1 * var(--space-4));padding:0 var(--space-4);flex-direction:row;overflow:auto hidden}.home-view__slide[data-v-e927a6a4]{scroll-snap-align:center;flex:0 0 min(320px,70vw);height:100%;min-height:0}}.home-view__sheet-title[data-v-e927a6a4]{font-size:var(--text-md);margin-bottom:var(--space-4);font-weight:700}.home-view__sheet-field[data-v-e927a6a4]{margin-bottom:var(--space-4)}.home-view__sheet-label[data-v-e927a6a4]{font-size:var(--text-sm);color:var(--color-text-muted);margin-bottom:var(--space-2);font-weight:600;display:block}.home-view__mode-select[data-v-e927a6a4],.home-view__tz-select[data-v-e927a6a4]{width:100%;min-height:var(--touch-min);padding:0 var(--space-3);border:1.5px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface);color:var(--color-text);font-size:var(--text-sm);cursor:pointer;appearance:auto;font-family:inherit}.home-view__mode-select[data-v-e927a6a4]:focus,.home-view__tz-select[data-v-e927a6a4]:focus{outline:2px solid var(--color-primary);outline-offset:2px}.home-view__tz-select[data-v-e927a6a4],.home-view__times-mode[data-v-e927a6a4],.home-view__interval-mode[data-v-e927a6a4]{margin-top:var(--space-3)}.home-view__times-list[data-v-e927a6a4]{gap:var(--space-2);flex-direction:column;display:flex}.home-view__times-empty[data-v-e927a6a4]{font-size:var(--text-sm);color:var(--color-text-muted);padding:var(--space-2) 0;font-style:italic}.home-view__time-row[data-v-e927a6a4]{align-items:center;gap:var(--space-1);display:flex}.home-view__time-part[data-v-e927a6a4]{min-height:var(--touch-min);padding:0 var(--space-2);border:1.5px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface);color:var(--color-text);font-size:var(--text-sm);cursor:pointer;appearance:auto;flex:1 1 0;min-width:0;font-family:inherit}.home-view__time-part--ampm[data-v-e927a6a4]{flex:none;min-width:64px}.home-view__time-part[data-v-e927a6a4]:focus{outline:2px solid var(--color-primary);outline-offset:2px}.home-view__time-sep[data-v-e927a6a4]{color:var(--color-text-muted);padding:0 2px;font-weight:700}.home-view__time-remove[data-v-e927a6a4]{width:var(--touch-min);height:var(--touch-min);border:1.5px solid var(--color-border);border-radius:var(--radius-md);color:var(--color-text-muted);cursor:pointer;transition:all var(--duration-fast);background:0 0;flex:none;justify-content:center;align-items:center;display:inline-flex}.home-view__time-remove[data-v-e927a6a4]:hover,.home-view__time-remove[data-v-e927a6a4]:focus-visible{border-color:var(--color-danger,#c0392b);color:var(--color-danger,#c0392b);outline:none}.home-view__time-add[data-v-e927a6a4]{margin-top:var(--space-3);width:100%;min-height:var(--touch-min);border:1.5px dashed var(--color-border);border-radius:var(--radius-md);color:var(--color-text-muted);font-size:var(--text-sm);cursor:pointer;transition:all var(--duration-fast);background:0 0;font-weight:600}.home-view__time-add[data-v-e927a6a4]:hover,.home-view__time-add[data-v-e927a6a4]:focus-visible{border-color:var(--color-primary);color:var(--color-primary);outline:none}.home-view__interval-input-row[data-v-e927a6a4]{align-items:center;gap:var(--space-2);font-size:var(--text-sm);display:flex}.home-view__interval-input[data-v-e927a6a4]{min-height:var(--touch-min);padding:0 var(--space-3);border:1.5px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface);color:var(--color-text);text-align:center;flex:0 0 96px;font-family:inherit;font-size:16px}.home-view__interval-input[data-v-e927a6a4]:focus{outline:2px solid var(--color-primary);outline-offset:2px}.home-view__next-update[data-v-e927a6a4]{margin-top:var(--space-3);font-size:var(--text-sm);color:var(--color-text);font-weight:600}.home-view__propagation-note[data-v-e927a6a4]{margin-top:var(--space-1);font-size:var(--text-xs);color:var(--color-text-muted);font-style:italic;line-height:1.4}.home-view__sheet-save[data-v-e927a6a4]{width:100%;margin-top:var(--space-2)} +.frame-card[data-v-608d39a4]{background:var(--color-surface);border:2px solid var(--color-border);border-radius:var(--radius-md);transition:border-color var(--duration-fast);position:relative;overflow:hidden}.frame-card--ok[data-v-608d39a4]{border-color:var(--color-border)}.frame-card--sync-fail[data-v-608d39a4]{border-color:#c49a20}.frame-card--offline[data-v-608d39a4]{border-color:#c0392b}.frame-card__settings-btn[data-v-608d39a4]{top:var(--space-2);right:var(--space-2);-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);width:36px;height:36px;color:var(--color-text);cursor:pointer;z-index:1;background:#ffffffd9;border:none;border-radius:50%;justify-content:center;align-items:center;display:flex;position:absolute;box-shadow:0 1px 4px #00000026}.frame-card__status-line[data-v-608d39a4]{font-size:var(--text-sm);align-items:center;gap:6px;font-weight:600;display:flex}.frame-card--ok .frame-card__status-line[data-v-608d39a4]{color:#1a7f4b}.frame-card--sync-fail .frame-card__status-line[data-v-608d39a4]{color:#8a6a00}.frame-card--offline .frame-card__status-line[data-v-608d39a4]{color:#c0392b}.frame-card__status-dot[data-v-608d39a4]{border-radius:50%;flex-shrink:0;width:8px;height:8px}.frame-card--ok .frame-card__status-dot[data-v-608d39a4]{background:#1a7f4b}.frame-card--sync-fail .frame-card__status-dot[data-v-608d39a4]{background:#c49a20}.frame-card--offline .frame-card__status-dot[data-v-608d39a4]{background:#c0392b}.frame-card__sync-line[data-v-608d39a4]{font-size:var(--text-xs);color:var(--color-text-muted);flex-wrap:wrap;gap:0 6px;margin-top:2px;display:flex}.frame-card__sync-sep[data-v-608d39a4]{opacity:.6}.frame-card--large[data-v-608d39a4]{flex-direction:column;height:100%;display:flex}.frame-card--large .frame-card__preview[data-v-608d39a4]{background:var(--color-surface-2);flex:none;justify-content:center;align-items:center;max-height:40dvh;display:flex;overflow:hidden}.frame-card--large .frame-card__img[data-v-608d39a4]{width:auto;max-width:100%;height:auto;max-height:100%;display:block}.frame-card--large .frame-card__empty-preview[data-v-608d39a4]{color:var(--color-text-muted);opacity:.5;justify-content:center;align-items:center;width:100%;display:flex}.frame-card--large .frame-card__body[data-v-608d39a4]{min-height:0;padding:var(--space-4);gap:var(--space-3);flex-direction:column;flex:1;display:flex}.frame-card--large .frame-card__info[data-v-608d39a4]{flex-direction:column;gap:2px;min-width:0;display:flex}.frame-card--large .frame-card__name[data-v-608d39a4]{font-size:var(--text-md);font-weight:700}.frame-card--large .frame-card__add-btn[data-v-608d39a4]{width:100%;margin-top:auto}.frame-card--compact[data-v-608d39a4]{align-items:center;gap:var(--space-3);padding:var(--space-3) var(--space-4);display:flex}.frame-card--compact .frame-card__preview[data-v-608d39a4]{border-radius:var(--radius-sm);background:var(--color-surface-2);flex-shrink:0;justify-content:center;align-items:center;width:52px;height:52px;display:flex;overflow:hidden}.frame-card--compact .frame-card__img[data-v-608d39a4]{object-fit:cover;width:100%;height:100%}.frame-card--compact .frame-card__empty-preview[data-v-608d39a4]{color:var(--color-text-muted);opacity:.4}.frame-card--compact .frame-card__body[data-v-608d39a4]{justify-content:space-between;align-items:center;gap:var(--space-2);flex:1;min-width:0;display:flex}.frame-card--compact .frame-card__info[data-v-608d39a4]{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.frame-card--compact .frame-card__name[data-v-608d39a4]{font-size:var(--text-base);font-weight:700}.frame-card--compact .frame-card__count[data-v-608d39a4]{font-size:var(--text-xs);color:var(--color-text-muted)}.frame-card__add-btn[data-v-608d39a4]{flex-shrink:0}@media (orientation:landscape) and (height<=600px){.frame-card--large .frame-card__preview[data-v-608d39a4]{flex:1;justify-content:center;align-items:center;min-height:0;display:flex;overflow:hidden}.frame-card--large .frame-card__img[data-v-608d39a4]{object-fit:contain;width:100%;height:100%}.frame-card--large .frame-card__body[data-v-608d39a4]{align-items:center;gap:var(--space-3);padding:var(--space-2) var(--space-3);flex-direction:row;flex:none}.frame-card--large .frame-card__info[data-v-608d39a4]{flex:1;min-width:0}.frame-card--large .frame-card__sync-line[data-v-608d39a4]{display:none}.frame-card--large .frame-card__add-btn[data-v-608d39a4]{flex-shrink:0;width:auto;margin-top:0}.frame-card--large .frame-card__settings-btn[data-v-608d39a4]{width:32px;height:32px;top:var(--space-1);right:var(--space-1)}}.input-wrap[data-v-c8235ab2]{width:100%;position:relative}.input-wrap__field[data-v-c8235ab2]{width:100%;min-height:56px;padding:22px var(--space-4) 8px;border:1px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface);color:var(--color-text);font-family:var(--font-family);font-size:var(--text-base);transition:border-color var(--duration-fast)}.input-wrap__field[data-v-c8235ab2]::placeholder{color:#0000}.input-wrap__field[data-v-c8235ab2]:focus{border-color:var(--color-primary);outline:none}.input-wrap__field:not(:placeholder-shown)~.input-wrap__label[data-v-c8235ab2],.input-wrap__field:focus~.input-wrap__label[data-v-c8235ab2]{font-size:var(--text-xs);color:var(--color-primary);top:8px;transform:none}.input-wrap__label[data-v-c8235ab2]{left:var(--space-4);color:var(--color-text-muted);font-size:var(--text-base);pointer-events:none;transition:top var(--duration-fast), font-size var(--duration-fast), color var(--duration-fast), transform var(--duration-fast);position:absolute;top:50%;transform:translateY(-50%)}.input-wrap--error .input-wrap__field[data-v-c8235ab2]{border-color:var(--color-destructive)}.input-wrap__error[data-v-c8235ab2]{margin-top:var(--space-1);padding-left:var(--space-4);font-size:var(--text-sm);color:var(--color-destructive)}.orientation-picker[data-v-679dae08]{gap:var(--space-3);grid-template-columns:repeat(2,1fr);display:grid}.orientation-opt[data-v-679dae08]{align-items:center;gap:var(--space-1);padding:var(--space-3) var(--space-2);background:var(--color-surface);border:2px solid var(--color-border);border-radius:var(--radius-md);cursor:pointer;transition:border-color var(--duration-fast);min-height:var(--touch-min);flex-direction:column;display:flex}.orientation-opt--active[data-v-679dae08]{border-color:var(--color-primary)}.orientation-opt__diagram[data-v-679dae08]{width:48px;height:48px;color:var(--color-text-muted)}.orientation-opt__label[data-v-679dae08]{font-size:var(--text-xs);color:var(--color-text);font-weight:700}.orientation-opt__sub[data-v-679dae08]{font-size:var(--text-xs);color:var(--color-text-muted);text-align:center;line-height:1.2}.home-view[data-v-f583ffd6]{padding:var(--space-4) var(--space-4) calc(var(--bottom-nav-height) + var(--space-4));gap:var(--space-3);flex-direction:column;flex:1;display:flex}.home-view__loading[data-v-f583ffd6]{color:var(--color-text-muted);font-size:var(--text-sm);padding:var(--space-4) 0;text-align:center}.home-view__empty[data-v-f583ffd6]{padding-top:var(--space-6);justify-content:center;display:flex}.home-view__empty-card[data-v-f583ffd6]{background:var(--color-surface);border:2px dashed var(--color-border);border-radius:var(--radius-md);padding:var(--space-6) var(--space-5);text-align:center;align-items:center;gap:var(--space-3);flex-direction:column;width:100%;max-width:320px;display:flex}.home-view__empty-icon[data-v-f583ffd6]{color:var(--color-text-muted);opacity:.5}.home-view__empty-title[data-v-f583ffd6]{font-size:var(--text-md);font-weight:700}.home-view__empty-sub[data-v-f583ffd6]{font-size:var(--text-sm);color:var(--color-text-muted);line-height:1.5}.home-view__single[data-v-f583ffd6]{flex-direction:column;flex:1;display:flex}.home-view__stack[data-v-f583ffd6]{gap:var(--space-3);scroll-snap-type:y mandatory;scroll-behavior:smooth;scrollbar-width:none;-webkit-overflow-scrolling:touch;flex-direction:column;flex:1;min-height:0;display:flex;overflow-y:auto}.home-view__stack[data-v-f583ffd6]::-webkit-scrollbar{display:none}.home-view__slide[data-v-f583ffd6]{box-sizing:border-box;scroll-snap-align:start;scroll-snap-stop:always;flex-direction:column;flex:none;min-height:100%;display:flex}@media (orientation:landscape) and (height<=600px){.home-view__stack[data-v-f583ffd6]{scroll-snap-type:x mandatory;gap:var(--space-3);margin:0 calc(-1 * var(--space-4));padding:0 var(--space-4);flex-direction:row;overflow:auto hidden}.home-view__slide[data-v-f583ffd6]{scroll-snap-align:center;flex:0 0 min(320px,70vw);height:100%;min-height:0}}.home-view__sheet-title[data-v-f583ffd6]{font-size:var(--text-md);margin-bottom:var(--space-4);font-weight:700}.home-view__sheet-field[data-v-f583ffd6]{margin-bottom:var(--space-4)}.home-view__sheet-label[data-v-f583ffd6]{font-size:var(--text-sm);color:var(--color-text-muted);margin-bottom:var(--space-2);font-weight:600;display:block}.home-view__mode-select[data-v-f583ffd6],.home-view__tz-select[data-v-f583ffd6]{width:100%;min-height:var(--touch-min);padding:0 var(--space-3);border:1.5px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface);color:var(--color-text);font-size:var(--text-sm);cursor:pointer;appearance:auto;font-family:inherit}.home-view__mode-select[data-v-f583ffd6]:focus,.home-view__tz-select[data-v-f583ffd6]:focus{outline:2px solid var(--color-primary);outline-offset:2px}.home-view__tz-select[data-v-f583ffd6],.home-view__times-mode[data-v-f583ffd6],.home-view__interval-mode[data-v-f583ffd6]{margin-top:var(--space-3)}.home-view__times-list[data-v-f583ffd6]{gap:var(--space-2);flex-direction:column;display:flex}.home-view__times-empty[data-v-f583ffd6]{font-size:var(--text-sm);color:var(--color-text-muted);padding:var(--space-2) 0;font-style:italic}.home-view__time-row[data-v-f583ffd6]{align-items:center;gap:var(--space-1);display:flex}.home-view__time-part[data-v-f583ffd6]{min-height:var(--touch-min);padding:0 var(--space-2);border:1.5px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface);color:var(--color-text);font-size:var(--text-sm);cursor:pointer;appearance:auto;flex:1 1 0;min-width:0;font-family:inherit}.home-view__time-part--ampm[data-v-f583ffd6]{flex:none;min-width:64px}.home-view__time-part[data-v-f583ffd6]:focus{outline:2px solid var(--color-primary);outline-offset:2px}.home-view__time-sep[data-v-f583ffd6]{color:var(--color-text-muted);padding:0 2px;font-weight:700}.home-view__time-remove[data-v-f583ffd6]{width:var(--touch-min);height:var(--touch-min);border:1.5px solid var(--color-border);border-radius:var(--radius-md);color:var(--color-text-muted);cursor:pointer;transition:all var(--duration-fast);background:0 0;flex:none;justify-content:center;align-items:center;display:inline-flex}.home-view__time-remove[data-v-f583ffd6]:hover,.home-view__time-remove[data-v-f583ffd6]:focus-visible{border-color:var(--color-danger,#c0392b);color:var(--color-danger,#c0392b);outline:none}.home-view__time-add[data-v-f583ffd6]{margin-top:var(--space-3);width:100%;min-height:var(--touch-min);border:1.5px dashed var(--color-border);border-radius:var(--radius-md);color:var(--color-text-muted);font-size:var(--text-sm);cursor:pointer;transition:all var(--duration-fast);background:0 0;font-weight:600}.home-view__time-add[data-v-f583ffd6]:hover,.home-view__time-add[data-v-f583ffd6]:focus-visible{border-color:var(--color-primary);color:var(--color-primary);outline:none}.home-view__interval-input-row[data-v-f583ffd6]{align-items:center;gap:var(--space-2);font-size:var(--text-sm);display:flex}.home-view__interval-input[data-v-f583ffd6]{min-height:var(--touch-min);padding:0 var(--space-3);border:1.5px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface);color:var(--color-text);text-align:center;flex:0 0 96px;font-family:inherit;font-size:16px}.home-view__interval-input[data-v-f583ffd6]:focus{outline:2px solid var(--color-primary);outline-offset:2px}.home-view__next-update[data-v-f583ffd6]{margin-top:var(--space-3);font-size:var(--text-sm);color:var(--color-text);font-weight:600}.home-view__propagation-note[data-v-f583ffd6]{margin-top:var(--space-1);font-size:var(--text-xs);color:var(--color-text-muted);font-style:italic;line-height:1.4}.home-view__sheet-save[data-v-f583ffd6]{width:100%;margin-top:var(--space-2)} diff --git a/public/build/assets/HomeView-NFtwfB9R.js b/public/build/assets/HomeView-NFtwfB9R.js deleted file mode 100644 index 19e6fdc..0000000 --- a/public/build/assets/HomeView-NFtwfB9R.js +++ /dev/null @@ -1 +0,0 @@ -import{A as e,E as t,G as n,O as r,R as i,S as a,T as o,V as s,_ as c,dt as l,f as u,ft as d,g as f,h as ee,l as p,o as m,p as h,t as g,u as _,ut as v,z as y}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{l as b,s as te,u as ne}from"./index-B5Obd-7x.js";import{i as re,n as x,r as ie,t as ae}from"./BaseBottomSheet-DohSPmvo.js";import{t as oe}from"./PullToRefresh-DZt-0188.js";var S=[`src`,`alt`],C={class:`frame-card__body`},w={class:`frame-card__info`},T={class:`frame-card__name`},E={class:`frame-card__status-line`,"aria-live":`polite`},D={class:`frame-card__status-text`},O={key:0,class:`frame-card__sync-line`},k={key:0},A={key:1,class:`frame-card__sync-sep`,"aria-hidden":`true`},j={key:2},M={key:1,class:`frame-card__count`},N={key:0},P={key:1,"aria-hidden":`true`},F=g(c({__name:`FrameCard`,props:{deviceId:{},name:{},size:{},status:{},orientation:{},thumbnailUrl:{},photoCount:{},lastSync:{},nextSync:{}},emits:[`add-photo`,`edit`],setup(e){let t=e,n=p(()=>({})),a=p(()=>t.size===`large`?{aspectRatio:t.orientation===`portrait`?`3 / 5`:`5 / 3`}:{}),o=p(()=>{switch(t.status){case`ok`:return`Online`;case`sync-fail`:return`Sync issue`;case`offline`:return`Offline`}});return(t,s)=>(r(),h(`div`,{class:v([`frame-card`,`frame-card--${e.size}`,`frame-card--${e.status}`])},[e.size===`large`?(r(),h(`button`,{key:0,class:`frame-card__settings-btn`,type:`button`,"aria-label":`Frame settings`,onClick:s[0]||=n=>t.$emit(`edit`,e.deviceId)},[...s[2]||=[_(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"aria-hidden":`true`},[_(`circle`,{cx:`12`,cy:`12`,r:`3`}),_(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z`})],-1)]])):u(``,!0),_(`div`,{class:`frame-card__preview`,style:l(n.value)},[e.thumbnailUrl?(r(),h(`img`,{key:0,src:e.thumbnailUrl,alt:`Current photo on ${e.name}`,class:`frame-card__img`},null,8,S)):(r(),h(`div`,{key:1,class:`frame-card__empty-preview`,style:l(a.value),"aria-hidden":`true`},[...s[3]||=[_(`svg`,{width:`32`,height:`32`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`},[_(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),_(`circle`,{cx:`8.5`,cy:`8.5`,r:`1.5`}),_(`polyline`,{points:`21,15 16,10 5,21`})],-1)]],4))],4),_(`div`,C,[_(`div`,w,[_(`p`,T,d(e.name),1),_(`p`,E,[s[4]||=_(`span`,{class:`frame-card__status-dot`,"aria-hidden":`true`},null,-1),_(`span`,D,d(o.value),1)]),e.size===`large`&&(e.lastSync||e.nextSync)?(r(),h(`p`,O,[e.lastSync?(r(),h(`span`,k,`synced `+d(e.lastSync),1)):u(``,!0),e.lastSync&&e.nextSync?(r(),h(`span`,A,`·`)):u(``,!0),e.nextSync?(r(),h(`span`,j,d(e.nextSync),1)):u(``,!0)])):e.size===`compact`&&e.photoCount!==void 0?(r(),h(`p`,M,d(e.photoCount)+` `+d(e.photoCount===1?`photo`:`photos`),1)):u(``,!0)]),f(x,{variant:e.size===`large`?`primary`:`icon-pill`,"aria-label":`Add photo to ${e.name}`,class:`frame-card__add-btn`,onClick:s[1]||=n=>t.$emit(`add-photo`,e.deviceId)},{default:i(()=>[e.size===`large`?(r(),h(`span`,N,`+ Add Photo`)):(r(),h(`span`,P,`+`))]),_:1},8,[`variant`,`aria-label`])])],2))}}),[[`__scopeId`,`data-v-608d39a4`]]),I=[`id`,`value`,`type`],L=[`for`],R=[`id`],z=g(c({__name:`BaseInput`,props:{modelValue:{default:``},label:{},type:{default:`text`},error:{},id:{}},emits:[`update:modelValue`,`blur`],setup(e,{emit:t}){let n=e,i=t,o=p(()=>n.id??`input-${Math.random().toString(36).slice(2)}`);return(t,n)=>(r(),h(`div`,{class:v([`input-wrap`,{"input-wrap--error":!!e.error,"input-wrap--filled":!!e.modelValue}])},[_(`input`,a({id:o.value},t.$attrs,{value:e.modelValue,type:e.type,class:`input-wrap__field`,placeholder:` `,onInput:n[0]||=e=>i(`update:modelValue`,e.target.value),onBlur:n[1]||=e=>i(`blur`,e)}),null,16,I),_(`label`,{for:o.value,class:`input-wrap__label`},d(e.label),9,L),e.error?(r(),h(`p`,{key:0,id:`${o.value}-error`,class:`input-wrap__error`,role:`alert`},d(e.error),9,R)):u(``,!0)],2))}}),[[`__scopeId`,`data-v-c8235ab2`]]),B={class:`orientation-picker`,role:`radiogroup`,"aria-label":`Display orientation`},V=[`aria-checked`,`aria-label`,`onClick`],H=[`viewBox`],U=[`stroke`,`fill`],W=[`fill`],G={class:`orientation-opt__label`},K={class:`orientation-opt__sub`},q=g(c({__name:`OrientationPicker`,props:{modelValue:{}},emits:[`update:modelValue`],setup(t){let n=[{value:`landscape`,label:`Landscape`,sub:`Ribbon at bottom`,viewBox:`0 0 48 48`,rect:{x:4,y:12,width:40,height:24},ribbon:{x:20,y:36,width:8,height:5}},{value:`portrait`,label:`Portrait`,sub:`Ribbon on left`,viewBox:`0 0 48 48`,rect:{x:12,y:4,width:24,height:40},ribbon:{x:7,y:20,width:5,height:8}}];return(i,o)=>(r(),h(`div`,B,[(r(),h(m,null,e(n,e=>_(`button`,{key:e.value,type:`button`,role:`radio`,"aria-checked":t.modelValue===e.value,"aria-label":e.label,class:v([`orientation-opt`,{"orientation-opt--active":t.modelValue===e.value}]),onClick:t=>i.$emit(`update:modelValue`,e.value)},[(r(),h(`svg`,{class:`orientation-opt__diagram`,viewBox:e.viewBox,fill:`none`,"aria-hidden":`true`},[_(`rect`,a({ref_for:!0},e.rect,{rx:`2`,stroke:t.modelValue===e.value?`var(--color-primary)`:`currentColor`,"stroke-width":`1.5`,fill:t.modelValue===e.value?`color-mix(in srgb, var(--color-primary) 12%, transparent)`:`var(--color-surface-2)`}),null,16,U),_(`rect`,a({ref_for:!0},e.ribbon,{fill:t.modelValue===e.value?`var(--color-primary)`:`var(--color-text-muted)`,rx:`1`}),null,16,W)],8,H)),_(`span`,G,d(e.label),1),_(`span`,K,d(e.sub),1)],10,V)),64))]))}}),[[`__scopeId`,`data-v-679dae08`]]),se={class:`home-view`},ce={key:0,class:`home-view__loading`,"aria-live":`polite`},le={key:1,class:`home-view__empty`},ue={key:2,class:`home-view__single`},de=[`aria-label`],fe={class:`home-view__sheet-field`},pe={class:`home-view__sheet-field`},me={class:`home-view__sheet-field`},he={key:0,class:`home-view__times-mode`},ge={class:`home-view__times-list`},_e=[`value`,`onChange`],ve=[`value`],ye=[`value`,`onChange`],be=[`value`],xe=[`value`,`onChange`],Se=[`aria-label`,`onClick`],Ce={key:0,class:`home-view__times-empty`},we=[`label`],Te=[`value`],Ee={key:1,class:`home-view__interval-mode`},De={class:`home-view__interval-input-row`},Oe={class:`home-view__next-update`,"aria-live":`polite`},J=g(c({__name:`HomeView`,setup(a){function c(e){return e.wakeTimes.length>0?1440*60*1e3:e.rotationIntervalMinutes*6e4}function l(e){if(!e.lastSeenAt)return`offline`;let t=Date.now()-new Date(e.lastSeenAt).getTime(),n=c(e);return t<=n?`ok`:t<=2*n?`sync-fail`:`offline`}function g(e){if(!e.lastSeenAt)return null;let t=Date.now()-new Date(e.lastSeenAt).getTime();if(t<6e4)return`just now`;if(t<36e5)return`${Math.round(t/6e4)}m ago`;if(t<864e5)return`${Math.round(t/36e5)}h ago`;let n=Math.round(t/864e5);return n===1?`yesterday`:`${n} days ago`}function v(e){let t=Math.floor(e/60),n=e%60,r=t>=12?`PM`:`AM`,i=t%12;i===0&&(i=12);let a=n===0?``:`:${String(n).padStart(2,`0`)}`;return`${i}${a} ${r}`}function S(e,t){let n=new Intl.DateTimeFormat(`en-GB`,{timeZone:t,hour:`2-digit`,minute:`2-digit`,hour12:!1}).formatToParts(e),r=parseInt(n.find(e=>e.type===`hour`)?.value??`0`,10),i=parseInt(n.find(e=>e.type===`minute`)?.value??`0`,10);return r*60+i}function C(e,t){if(e.length===0)return null;let n=S(new Date,t),r=null,i=1/0;for(let t of e){let e=t>n?t-n:1440+(t-n);en})}return r}function w(e){if(e.wakeTimes.length>0){let t=C(e.wakeTimes,e.timezone||`UTC`);return t?`next sync ~${v(t.minutes)} ${t.today?`today`:`tomorrow`}`:null}if(!e.lastSeenAt)return null;let t=new Date(e.lastSeenAt).getTime()+e.rotationIntervalMinutes*6e4-Date.now();return t<=0?null:t<6e4?`next sync in <1m`:t<36e5?`next sync in ${Math.round(t/6e4)}m`:`next sync in ${Math.round(t/36e5)}h`}function T(e){return e.currentImageId?`/api/devices/${e.id}/preview?v=${e.currentImageId}`:void 0}let E=te(),D=re(),O=ie();o(()=>{D.fetchDevices(),document.addEventListener(`visibilitychange`,k)}),t(()=>{document.removeEventListener(`visibilitychange`,k)});function k(){document.visibilityState===`visible`&&D.fetchDevices({silent:!0})}let A=s(null);function j(){return window.scrollY>0?!1:(A.value?.scrollTop??0)===0}async function M(){await D.fetchDevices({silent:!0})}function N(e){let t=document.createElement(`input`);t.type=`file`,t.accept=`image/jpeg,image/png,image/webp,image/gif`,t.onchange=()=>{let n=t.files?.[0];n&&(O.init(n,e),E.push(`/upload`))},t.click()}let P=[12,1,2,3,4,5,6,7,8,9,10,11],I=[0,5,10,15,20,25,30,35,40,45,50,55];function L(e){let t=Math.floor(e/60),n=e%60,r=t>=12?`PM`:`AM`,i=t%12;return i===0&&(i=12),{h:i,mm:n,p:r}}function R(e,t,n){let r=e%12;return n===`PM`&&(r+=12),r*60+t}let B=[{label:`Americas`,zones:[{value:`America/New_York`,label:`Eastern — New York, Toronto`},{value:`America/Chicago`,label:`Central — Chicago, Mexico City`},{value:`America/Denver`,label:`Mountain — Denver, Calgary`},{value:`America/Phoenix`,label:`Mountain (no DST) — Phoenix`},{value:`America/Los_Angeles`,label:`Pacific — Los Angeles, Vancouver`},{value:`America/Anchorage`,label:`Alaska — Anchorage`},{value:`Pacific/Honolulu`,label:`Hawaii — Honolulu`},{value:`America/Sao_Paulo`,label:`Brasília — São Paulo`},{value:`America/Argentina/Buenos_Aires`,label:`Argentina — Buenos Aires`},{value:`America/Bogota`,label:`Colombia — Bogotá`}]},{label:`Europe`,zones:[{value:`Europe/London`,label:`GMT/BST — London, Dublin`},{value:`Europe/Lisbon`,label:`WET/WEST — Lisbon`},{value:`Europe/Paris`,label:`CET/CEST — Paris, Brussels, Amsterdam`},{value:`Europe/Berlin`,label:`CET/CEST — Berlin, Vienna, Zurich`},{value:`Europe/Stockholm`,label:`CET/CEST — Stockholm, Oslo, Copenhagen`},{value:`Europe/Helsinki`,label:`EET/EEST — Helsinki, Tallinn, Riga`},{value:`Europe/Warsaw`,label:`CET/CEST — Warsaw, Prague, Budapest`},{value:`Europe/Rome`,label:`CET/CEST — Rome, Madrid`},{value:`Europe/Athens`,label:`EET/EEST — Athens, Bucharest`},{value:`Europe/Istanbul`,label:`TRT — Istanbul`},{value:`Europe/Moscow`,label:`MSK — Moscow`}]},{label:`Asia & Pacific`,zones:[{value:`Asia/Dubai`,label:`GST — Dubai, Abu Dhabi`},{value:`Asia/Karachi`,label:`PKT — Karachi, Islamabad`},{value:`Asia/Kolkata`,label:`IST — India`},{value:`Asia/Dhaka`,label:`BST — Dhaka, Bangladesh`},{value:`Asia/Bangkok`,label:`ICT — Bangkok, Jakarta, Hanoi`},{value:`Asia/Singapore`,label:`SGT — Singapore, Kuala Lumpur`},{value:`Asia/Shanghai`,label:`CST — Beijing, Shanghai, Taipei`},{value:`Asia/Seoul`,label:`KST — Seoul`},{value:`Asia/Tokyo`,label:`JST — Tokyo`},{value:`Australia/Sydney`,label:`AEDT/AEST — Sydney, Melbourne`},{value:`Australia/Brisbane`,label:`AEST (no DST) — Brisbane`},{value:`Australia/Perth`,label:`AWST — Perth`},{value:`Pacific/Auckland`,label:`NZDT/NZST — Auckland`}]},{label:`Africa & Middle East`,zones:[{value:`Africa/Cairo`,label:`EET — Cairo`},{value:`Africa/Nairobi`,label:`EAT — Nairobi, East Africa`},{value:`Africa/Johannesburg`,label:`SAST — Johannesburg`},{value:`Africa/Lagos`,label:`WAT — Lagos, West Africa`}]},{label:`UTC`,zones:[{value:`UTC`,label:`UTC — Coordinated Universal Time`}]}],V=s(!1),H=s(!1),U=s(null),W=s(``),G=s(`landscape`),K=s(`interval`),J=s([]),Y=s(60),X=s(`UTC`),ke=[540,1080,720,1260,360,900,450,1170,0];function Ae(){for(let e of ke)if(!J.value.includes(e)){J.value=[...J.value,e].sort((e,t)=>e-t);return}for(let e=0;e<1440;e+=5)if(!J.value.includes(e)){J.value=[...J.value,e].sort((e,t)=>e-t);return}}function je(e){J.value=J.value.filter((t,n)=>n!==e)}function Z(e,t,n){let r=L(J.value[e]),i=t===`h`?parseInt(n,10):r.h,a=t===`mm`?parseInt(n,10):r.mm,o=t===`p`?n:r.p,s=[...J.value];s[e]=R(i,a,o),J.value=s.sort((e,t)=>e-t)}let Q=p(()=>{let e=U.value;if(!e)return``;if(!e.lastSeenAt)return`Next update: when the frame next connects`;let t=e.timezone||`UTC`,n=new Date(e.lastSeenAt).getTime(),r;return r=e.wakeTimes.length>0?Me(n,e.wakeTimes,t):n+e.rotationIntervalMinutes*6e4,rt.id===e);t&&(U.value=t,W.value=t.name,G.value=t.orientation,X.value=t.timezone??`UTC`,Y.value=t.rotationIntervalMinutes,J.value=[...t.wakeTimes],K.value=t.wakeTimes.length>0?`times`:`interval`,V.value=!0)}async function Fe(){if(U.value){H.value=!0;try{let e={name:W.value.trim()||U.value.name,orientation:G.value,timezone:X.value};K.value===`times`?e.wakeTimes=[...J.value]:(e.wakeTimes=[],e.rotationIntervalMinutes=Math.max(1,Math.min(1440,Y.value||1))),await D.updateDevice(U.value.id,e),V.value=!1}finally{H.value=!1}}}return(t,a)=>(r(),h(m,null,[_(`main`,se,[f(oe,{"is-at-top":j,"on-refresh":M},{default:i(()=>[n(D).loading?(r(),h(`div`,ce,` Loading… `)):n(D).devices.length===0?(r(),h(`div`,le,[...a[6]||=[_(`div`,{class:`home-view__empty-card`},[_(`svg`,{class:`home-view__empty-icon`,width:`48`,height:`48`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"aria-hidden":`true`},[_(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),_(`circle`,{cx:`8.5`,cy:`8.5`,r:`1.5`}),_(`polyline`,{points:`21,15 16,10 5,21`})]),_(`p`,{class:`home-view__empty-title`},`Set up your first frame`),_(`p`,{class:`home-view__empty-sub`},` Power on your pictureFrame device and scan the QR code it displays to get started. `)],-1)]])):n(D).devices.length===1?(r(),h(`div`,ue,[f(F,{deviceId:n(D).devices[0].id,name:n(D).devices[0].name,size:`large`,status:l(n(D).devices[0]),orientation:n(D).devices[0].orientation,thumbnailUrl:T(n(D).devices[0]),lastSync:g(n(D).devices[0]),nextSync:w(n(D).devices[0]),onAddPhoto:N,onEdit:$},null,8,[`deviceId`,`name`,`status`,`orientation`,`thumbnailUrl`,`lastSync`,`nextSync`])])):(r(),h(`div`,{key:3,ref_key:`stackEl`,ref:A,class:`home-view__stack`,role:`list`,"aria-label":`Frames`},[(r(!0),h(m,null,e(n(D).devices,e=>(r(),h(`div`,{key:e.id,class:`home-view__slide`,role:`listitem`,"aria-label":e.name},[f(F,{deviceId:e.id,name:e.name,size:`large`,status:l(e),orientation:e.orientation,thumbnailUrl:T(e),lastSync:g(e),nextSync:w(e),onAddPhoto:N,onEdit:$},null,8,[`deviceId`,`name`,`status`,`orientation`,`thumbnailUrl`,`lastSync`,`nextSync`])],8,de))),128))],512))]),_:1})]),f(ae,{modelValue:V.value,"onUpdate:modelValue":a[5]||=e=>V.value=e,label:`Frame settings`},{default:i(()=>[a[16]||=_(`h2`,{class:`home-view__sheet-title`},`Frame settings`,-1),_(`div`,fe,[f(z,{modelValue:W.value,"onUpdate:modelValue":a[0]||=e=>W.value=e,label:`Frame name`,maxlength:`100`},null,8,[`modelValue`])]),_(`div`,pe,[a[7]||=_(`p`,{class:`home-view__sheet-label`},`Orientation`,-1),f(q,{modelValue:G.value,"onUpdate:modelValue":a[1]||=e=>G.value=e},null,8,[`modelValue`])]),_(`div`,me,[a[14]||=_(`p`,{class:`home-view__sheet-label`},`Update frequency`,-1),y(_(`select`,{class:`home-view__mode-select`,"onUpdate:modelValue":a[2]||=e=>K.value=e,"aria-label":`Update frequency mode`},[...a[8]||=[_(`option`,{value:`times`},`At specific time(s)`,-1),_(`option`,{value:`interval`},`Every X minutes`,-1)]],512),[[b,K.value]]),K.value===`times`?(r(),h(`div`,he,[_(`div`,ge,[(r(!0),h(m,null,e(J.value,(t,n)=>(r(),h(`div`,{key:n,class:`home-view__time-row`},[_(`select`,{class:`home-view__time-part`,value:L(t).h,"aria-label":`Hour`,onChange:e=>Z(n,`h`,e.target.value)},[(r(),h(m,null,e(P,e=>_(`option`,{key:e,value:e},d(e),9,ve)),64))],40,_e),a[11]||=_(`span`,{class:`home-view__time-sep`},`:`,-1),_(`select`,{class:`home-view__time-part`,value:L(t).mm,"aria-label":`Minutes`,onChange:e=>Z(n,`mm`,e.target.value)},[(r(),h(m,null,e(I,e=>_(`option`,{key:e,value:e},d(String(e).padStart(2,`0`)),9,be)),64))],40,ye),_(`select`,{class:`home-view__time-part home-view__time-part--ampm`,value:L(t).p,"aria-label":`AM or PM`,onChange:e=>Z(n,`p`,e.target.value)},[...a[9]||=[_(`option`,{value:`AM`},`AM`,-1),_(`option`,{value:`PM`},`PM`,-1)]],40,xe),_(`button`,{type:`button`,class:`home-view__time-remove`,"aria-label":`Remove ${v(t)}`,onClick:e=>je(n)},[...a[10]||=[_(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`},[_(`polyline`,{points:`3 6 5 6 21 6`}),_(`path`,{d:`M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6`}),_(`path`,{d:`M10 11v6`}),_(`path`,{d:`M14 11v6`})],-1)]],8,Se)]))),128)),J.value.length===0?(r(),h(`p`,Ce,`No update times yet — add one below.`)):u(``,!0)]),_(`button`,{type:`button`,class:`home-view__time-add`,onClick:Ae},`+ Add time`),y(_(`select`,{class:`home-view__tz-select`,"onUpdate:modelValue":a[3]||=e=>X.value=e},[(r(),h(m,null,e(B,t=>_(`optgroup`,{key:t.label,label:t.label},[(r(!0),h(m,null,e(t.zones,e=>(r(),h(`option`,{key:e.value,value:e.value},d(e.label),9,Te))),128))],8,we)),64))],512),[[b,X.value]])])):(r(),h(`div`,Ee,[_(`div`,De,[a[12]||=_(`span`,null,`Every`,-1),y(_(`input`,{type:`number`,inputmode:`numeric`,pattern:`[0-9]*`,min:`1`,max:`1440`,class:`home-view__interval-input`,"onUpdate:modelValue":a[4]||=e=>Y.value=e,"aria-label":`Update interval in minutes`},null,512),[[ne,Y.value,void 0,{number:!0}]]),a[13]||=_(`span`,null,`minutes`,-1)])])),_(`p`,Oe,d(Q.value),1),a[15]||=_(`p`,{class:`home-view__propagation-note`},` Changes will only take effect at the next device update. `,-1)]),f(x,{variant:`primary`,class:`home-view__sheet-save`,disabled:H.value,onClick:Fe},{default:i(()=>[ee(d(H.value?`Saving…`:`Save`),1)]),_:1},8,[`disabled`])]),_:1},8,[`modelValue`])],64))}}),[[`__scopeId`,`data-v-e927a6a4`]]);export{J as default}; \ No newline at end of file diff --git a/public/build/assets/HomeView-_Dkprh5_.js b/public/build/assets/HomeView-_Dkprh5_.js new file mode 100644 index 0000000..0fd5b15 --- /dev/null +++ b/public/build/assets/HomeView-_Dkprh5_.js @@ -0,0 +1 @@ +import{A as e,E as t,G as n,O as r,R as i,S as a,T as o,V as s,_ as c,dt as l,f as u,ft as d,g as f,h as ee,l as p,o as m,p as h,t as g,u as _,ut as v,z as y}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{l as b,s as te,u as ne}from"./index-DabTPrXi.js";import{i as re,n as x,r as ie,t as ae}from"./BaseBottomSheet-Y2PW4H1i.js";import{t as oe}from"./PullToRefresh-DZt-0188.js";var S=[`src`,`alt`],C={class:`frame-card__body`},w={class:`frame-card__info`},T={class:`frame-card__name`},E={class:`frame-card__status-line`,"aria-live":`polite`},D={class:`frame-card__status-text`},O={key:0,class:`frame-card__sync-line`},k={key:0},A={key:1,class:`frame-card__sync-sep`,"aria-hidden":`true`},j={key:2},M={key:1,class:`frame-card__count`},N={key:0},P={key:1,"aria-hidden":`true`},F=g(c({__name:`FrameCard`,props:{deviceId:{},name:{},size:{},status:{},orientation:{},thumbnailUrl:{},photoCount:{},lastSync:{},nextSync:{}},emits:[`add-photo`,`edit`],setup(e){let t=e,n=p(()=>({})),a=p(()=>t.size===`large`?{aspectRatio:t.orientation===`portrait`?`3 / 5`:`5 / 3`}:{}),o=p(()=>{switch(t.status){case`ok`:return`Online`;case`sync-fail`:return`Sync issue`;case`offline`:return`Offline`}});return(t,s)=>(r(),h(`div`,{class:v([`frame-card`,`frame-card--${e.size}`,`frame-card--${e.status}`])},[e.size===`large`?(r(),h(`button`,{key:0,class:`frame-card__settings-btn`,type:`button`,"aria-label":`Frame settings`,onClick:s[0]||=n=>t.$emit(`edit`,e.deviceId)},[...s[2]||=[_(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"aria-hidden":`true`},[_(`circle`,{cx:`12`,cy:`12`,r:`3`}),_(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z`})],-1)]])):u(``,!0),_(`div`,{class:`frame-card__preview`,style:l(n.value)},[e.thumbnailUrl?(r(),h(`img`,{key:0,src:e.thumbnailUrl,alt:`Current photo on ${e.name}`,class:`frame-card__img`},null,8,S)):(r(),h(`div`,{key:1,class:`frame-card__empty-preview`,style:l(a.value),"aria-hidden":`true`},[...s[3]||=[_(`svg`,{width:`32`,height:`32`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`},[_(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),_(`circle`,{cx:`8.5`,cy:`8.5`,r:`1.5`}),_(`polyline`,{points:`21,15 16,10 5,21`})],-1)]],4))],4),_(`div`,C,[_(`div`,w,[_(`p`,T,d(e.name),1),_(`p`,E,[s[4]||=_(`span`,{class:`frame-card__status-dot`,"aria-hidden":`true`},null,-1),_(`span`,D,d(o.value),1)]),e.size===`large`&&(e.lastSync||e.nextSync)?(r(),h(`p`,O,[e.lastSync?(r(),h(`span`,k,`synced `+d(e.lastSync),1)):u(``,!0),e.lastSync&&e.nextSync?(r(),h(`span`,A,`·`)):u(``,!0),e.nextSync?(r(),h(`span`,j,d(e.nextSync),1)):u(``,!0)])):e.size===`compact`&&e.photoCount!==void 0?(r(),h(`p`,M,d(e.photoCount)+` `+d(e.photoCount===1?`photo`:`photos`),1)):u(``,!0)]),f(x,{variant:e.size===`large`?`primary`:`icon-pill`,"aria-label":`Add photo to ${e.name}`,class:`frame-card__add-btn`,onClick:s[1]||=n=>t.$emit(`add-photo`,e.deviceId)},{default:i(()=>[e.size===`large`?(r(),h(`span`,N,`+ Add Photo`)):(r(),h(`span`,P,`+`))]),_:1},8,[`variant`,`aria-label`])])],2))}}),[[`__scopeId`,`data-v-608d39a4`]]),I=[`id`,`value`,`type`],L=[`for`],R=[`id`],se=g(c({__name:`BaseInput`,props:{modelValue:{default:``},label:{},type:{default:`text`},error:{},id:{}},emits:[`update:modelValue`,`blur`],setup(e,{emit:t}){let n=e,i=t,o=p(()=>n.id??`input-${Math.random().toString(36).slice(2)}`);return(t,n)=>(r(),h(`div`,{class:v([`input-wrap`,{"input-wrap--error":!!e.error,"input-wrap--filled":!!e.modelValue}])},[_(`input`,a({id:o.value},t.$attrs,{value:e.modelValue,type:e.type,class:`input-wrap__field`,placeholder:` `,onInput:n[0]||=e=>i(`update:modelValue`,e.target.value),onBlur:n[1]||=e=>i(`blur`,e)}),null,16,I),_(`label`,{for:o.value,class:`input-wrap__label`},d(e.label),9,L),e.error?(r(),h(`p`,{key:0,id:`${o.value}-error`,class:`input-wrap__error`,role:`alert`},d(e.error),9,R)):u(``,!0)],2))}}),[[`__scopeId`,`data-v-c8235ab2`]]),z={class:`orientation-picker`,role:`radiogroup`,"aria-label":`Display orientation`},B=[`aria-checked`,`aria-label`,`onClick`],V=[`viewBox`],H=[`stroke`,`fill`],U=[`fill`],W={class:`orientation-opt__label`},G={class:`orientation-opt__sub`},K=g(c({__name:`OrientationPicker`,props:{modelValue:{}},emits:[`update:modelValue`],setup(t){let n=[{value:`landscape`,label:`Landscape`,sub:`Ribbon at bottom`,viewBox:`0 0 48 48`,rect:{x:4,y:12,width:40,height:24},ribbon:{x:20,y:36,width:8,height:5}},{value:`portrait`,label:`Portrait`,sub:`Ribbon on left`,viewBox:`0 0 48 48`,rect:{x:12,y:4,width:24,height:40},ribbon:{x:7,y:20,width:5,height:8}}];return(i,o)=>(r(),h(`div`,z,[(r(),h(m,null,e(n,e=>_(`button`,{key:e.value,type:`button`,role:`radio`,"aria-checked":t.modelValue===e.value,"aria-label":e.label,class:v([`orientation-opt`,{"orientation-opt--active":t.modelValue===e.value}]),onClick:t=>i.$emit(`update:modelValue`,e.value)},[(r(),h(`svg`,{class:`orientation-opt__diagram`,viewBox:e.viewBox,fill:`none`,"aria-hidden":`true`},[_(`rect`,a({ref_for:!0},e.rect,{rx:`2`,stroke:t.modelValue===e.value?`var(--color-primary)`:`currentColor`,"stroke-width":`1.5`,fill:t.modelValue===e.value?`color-mix(in srgb, var(--color-primary) 12%, transparent)`:`var(--color-surface-2)`}),null,16,H),_(`rect`,a({ref_for:!0},e.ribbon,{fill:t.modelValue===e.value?`var(--color-primary)`:`var(--color-text-muted)`,rx:`1`}),null,16,U)],8,V)),_(`span`,W,d(e.label),1),_(`span`,G,d(e.sub),1)],10,B)),64))]))}}),[[`__scopeId`,`data-v-679dae08`]]),ce={class:`home-view`},le={key:0,class:`home-view__loading`,"aria-live":`polite`},ue={key:1,class:`home-view__empty`},de={key:2,class:`home-view__single`},fe=[`aria-label`],pe={class:`home-view__sheet-field`},me={class:`home-view__sheet-field`},he={class:`home-view__sheet-field`},ge={key:0,class:`home-view__times-mode`},_e={class:`home-view__times-list`},ve=[`value`,`onChange`],ye=[`value`],be=[`value`,`onChange`],xe=[`value`],Se=[`value`,`onChange`],Ce=[`aria-label`,`onClick`],we={key:0,class:`home-view__times-empty`},Te=[`label`],Ee=[`value`],De={key:1,class:`home-view__interval-mode`},Oe={class:`home-view__interval-input-row`},ke={class:`home-view__next-update`,"aria-live":`polite`},q=g(c({__name:`HomeView`,setup(a){function c(e){return e.wakeTimes.length>0?1440*60*1e3:e.rotationIntervalMinutes*6e4}function l(e){if(!e.lastSeenAt)return`offline`;let t=Date.now()-new Date(e.lastSeenAt).getTime(),n=c(e);return t<=n?`ok`:t<=2*n?`sync-fail`:`offline`}function g(e){if(!e.lastSeenAt)return null;let t=Date.now()-new Date(e.lastSeenAt).getTime();if(t<6e4)return`just now`;if(t<36e5)return`${Math.round(t/6e4)}m ago`;if(t<864e5)return`${Math.round(t/36e5)}h ago`;let n=Math.round(t/864e5);return n===1?`yesterday`:`${n} days ago`}function v(e){let t=Math.floor(e/60),n=e%60,r=t>=12?`PM`:`AM`,i=t%12;i===0&&(i=12);let a=n===0?``:`:${String(n).padStart(2,`0`)}`;return`${i}${a} ${r}`}function S(e,t){let n=new Intl.DateTimeFormat(`en-GB`,{timeZone:t,hour:`2-digit`,minute:`2-digit`,hour12:!1}).formatToParts(e),r=parseInt(n.find(e=>e.type===`hour`)?.value??`0`,10),i=parseInt(n.find(e=>e.type===`minute`)?.value??`0`,10);return r*60+i}function C(e,t){if(e.length===0)return null;let n=S(new Date,t),r=null,i=1/0;for(let t of e){let e=t>n?t-n:1440+(t-n);en})}return r}function w(e){let t=null;if(e.nextPollExpectedAt)t=new Date(e.nextPollExpectedAt).getTime();else if(e.wakeTimes.length>0){let t=C(e.wakeTimes,e.timezone||`UTC`);return t?`next sync ~${v(t.minutes)} ${t.today?`today`:`tomorrow`}`:null}else if(e.lastSeenAt)t=new Date(e.lastSeenAt).getTime()+e.rotationIntervalMinutes*6e4;else return null;let n=t-Date.now();if(n<=0)return null;if(n<6e4)return`next sync in <1m`;if(n<36e5)return`next sync in ${Math.round(n/6e4)}m`;if(n<864e5){let n=e.timezone||`UTC`,r=S(new Date(t),n),i=Q(new Date(t),n),a=i===0?`today`:i===1?`tomorrow`:`in ${i}d`;return`next sync ~${v(r)} ${a}`}return`next sync in ${Math.round(n/864e5)}d`}function T(e){return e.currentImageId?`/api/devices/${e.id}/preview?v=${e.currentImageId}`:void 0}let E=te(),D=re(),O=ie();o(()=>{D.fetchDevices(),document.addEventListener(`visibilitychange`,k)}),t(()=>{document.removeEventListener(`visibilitychange`,k)});function k(){document.visibilityState===`visible`&&D.fetchDevices({silent:!0})}let A=s(null);function j(){return window.scrollY>0?!1:(A.value?.scrollTop??0)===0}async function M(){await D.fetchDevices({silent:!0})}function N(e){let t=document.createElement(`input`);t.type=`file`,t.accept=`image/jpeg,image/png,image/webp,image/gif`,t.onchange=()=>{let n=t.files?.[0];n&&(O.init(n,e),E.push(`/upload`))},t.click()}let P=[12,1,2,3,4,5,6,7,8,9,10,11],I=[0,5,10,15,20,25,30,35,40,45,50,55];function L(e){let t=Math.floor(e/60),n=e%60,r=t>=12?`PM`:`AM`,i=t%12;return i===0&&(i=12),{h:i,mm:n,p:r}}function R(e,t,n){let r=e%12;return n===`PM`&&(r+=12),r*60+t}let z=[{label:`Americas`,zones:[{value:`America/New_York`,label:`Eastern — New York, Toronto`},{value:`America/Chicago`,label:`Central — Chicago, Mexico City`},{value:`America/Denver`,label:`Mountain — Denver, Calgary`},{value:`America/Phoenix`,label:`Mountain (no DST) — Phoenix`},{value:`America/Los_Angeles`,label:`Pacific — Los Angeles, Vancouver`},{value:`America/Anchorage`,label:`Alaska — Anchorage`},{value:`Pacific/Honolulu`,label:`Hawaii — Honolulu`},{value:`America/Sao_Paulo`,label:`Brasília — São Paulo`},{value:`America/Argentina/Buenos_Aires`,label:`Argentina — Buenos Aires`},{value:`America/Bogota`,label:`Colombia — Bogotá`}]},{label:`Europe`,zones:[{value:`Europe/London`,label:`GMT/BST — London, Dublin`},{value:`Europe/Lisbon`,label:`WET/WEST — Lisbon`},{value:`Europe/Paris`,label:`CET/CEST — Paris, Brussels, Amsterdam`},{value:`Europe/Berlin`,label:`CET/CEST — Berlin, Vienna, Zurich`},{value:`Europe/Stockholm`,label:`CET/CEST — Stockholm, Oslo, Copenhagen`},{value:`Europe/Helsinki`,label:`EET/EEST — Helsinki, Tallinn, Riga`},{value:`Europe/Warsaw`,label:`CET/CEST — Warsaw, Prague, Budapest`},{value:`Europe/Rome`,label:`CET/CEST — Rome, Madrid`},{value:`Europe/Athens`,label:`EET/EEST — Athens, Bucharest`},{value:`Europe/Istanbul`,label:`TRT — Istanbul`},{value:`Europe/Moscow`,label:`MSK — Moscow`}]},{label:`Asia & Pacific`,zones:[{value:`Asia/Dubai`,label:`GST — Dubai, Abu Dhabi`},{value:`Asia/Karachi`,label:`PKT — Karachi, Islamabad`},{value:`Asia/Kolkata`,label:`IST — India`},{value:`Asia/Dhaka`,label:`BST — Dhaka, Bangladesh`},{value:`Asia/Bangkok`,label:`ICT — Bangkok, Jakarta, Hanoi`},{value:`Asia/Singapore`,label:`SGT — Singapore, Kuala Lumpur`},{value:`Asia/Shanghai`,label:`CST — Beijing, Shanghai, Taipei`},{value:`Asia/Seoul`,label:`KST — Seoul`},{value:`Asia/Tokyo`,label:`JST — Tokyo`},{value:`Australia/Sydney`,label:`AEDT/AEST — Sydney, Melbourne`},{value:`Australia/Brisbane`,label:`AEST (no DST) — Brisbane`},{value:`Australia/Perth`,label:`AWST — Perth`},{value:`Pacific/Auckland`,label:`NZDT/NZST — Auckland`}]},{label:`Africa & Middle East`,zones:[{value:`Africa/Cairo`,label:`EET — Cairo`},{value:`Africa/Nairobi`,label:`EAT — Nairobi, East Africa`},{value:`Africa/Johannesburg`,label:`SAST — Johannesburg`},{value:`Africa/Lagos`,label:`WAT — Lagos, West Africa`}]},{label:`UTC`,zones:[{value:`UTC`,label:`UTC — Coordinated Universal Time`}]}],B=s(!1),V=s(!1),H=s(null),U=s(``),W=s(`landscape`),G=s(`interval`),q=s([]),J=s(60),Y=s(`UTC`),Ae=[540,1080,720,1260,360,900,450,1170,0];function je(){for(let e of Ae)if(!q.value.includes(e)){q.value=[...q.value,e].sort((e,t)=>e-t);return}for(let e=0;e<1440;e+=5)if(!q.value.includes(e)){q.value=[...q.value,e].sort((e,t)=>e-t);return}}function Me(e){q.value=q.value.filter((t,n)=>n!==e)}function X(e,t,n){let r=L(q.value[e]),i=t===`h`?parseInt(n,10):r.h,a=t===`mm`?parseInt(n,10):r.mm,o=t===`p`?n:r.p,s=[...q.value];s[e]=R(i,a,o),q.value=s.sort((e,t)=>e-t)}let Z=p(()=>{let e=H.value;if(!e)return``;let t=e.timezone||`UTC`,n;if(e.nextPollExpectedAt)n=new Date(e.nextPollExpectedAt).getTime();else if(e.lastSeenAt){let r=new Date(e.lastSeenAt).getTime();n=e.wakeTimes.length>0?Ne(r,e.wakeTimes,t):r+e.rotationIntervalMinutes*6e4}else return`Next update: when the frame next connects`;return nt.id===e);t&&(H.value=t,U.value=t.name,W.value=t.orientation,Y.value=t.timezone??`UTC`,J.value=t.rotationIntervalMinutes,q.value=[...t.wakeTimes],G.value=t.wakeTimes.length>0?`times`:`interval`,B.value=!0)}async function Fe(){if(H.value){V.value=!0;try{let e={name:U.value.trim()||H.value.name,orientation:W.value,timezone:Y.value};G.value===`times`?e.wakeTimes=[...q.value]:(e.wakeTimes=[],e.rotationIntervalMinutes=Math.max(1,Math.min(1440,J.value||1))),await D.updateDevice(H.value.id,e),B.value=!1}finally{V.value=!1}}}return(t,a)=>(r(),h(m,null,[_(`main`,ce,[f(oe,{"is-at-top":j,"on-refresh":M},{default:i(()=>[n(D).loading?(r(),h(`div`,le,` Loading… `)):n(D).devices.length===0?(r(),h(`div`,ue,[...a[6]||=[_(`div`,{class:`home-view__empty-card`},[_(`svg`,{class:`home-view__empty-icon`,width:`48`,height:`48`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"aria-hidden":`true`},[_(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),_(`circle`,{cx:`8.5`,cy:`8.5`,r:`1.5`}),_(`polyline`,{points:`21,15 16,10 5,21`})]),_(`p`,{class:`home-view__empty-title`},`Set up your first frame`),_(`p`,{class:`home-view__empty-sub`},` Power on your pictureFrame device and scan the QR code it displays to get started. `)],-1)]])):n(D).devices.length===1?(r(),h(`div`,de,[f(F,{deviceId:n(D).devices[0].id,name:n(D).devices[0].name,size:`large`,status:l(n(D).devices[0]),orientation:n(D).devices[0].orientation,thumbnailUrl:T(n(D).devices[0]),lastSync:g(n(D).devices[0]),nextSync:w(n(D).devices[0]),onAddPhoto:N,onEdit:$},null,8,[`deviceId`,`name`,`status`,`orientation`,`thumbnailUrl`,`lastSync`,`nextSync`])])):(r(),h(`div`,{key:3,ref_key:`stackEl`,ref:A,class:`home-view__stack`,role:`list`,"aria-label":`Frames`},[(r(!0),h(m,null,e(n(D).devices,e=>(r(),h(`div`,{key:e.id,class:`home-view__slide`,role:`listitem`,"aria-label":e.name},[f(F,{deviceId:e.id,name:e.name,size:`large`,status:l(e),orientation:e.orientation,thumbnailUrl:T(e),lastSync:g(e),nextSync:w(e),onAddPhoto:N,onEdit:$},null,8,[`deviceId`,`name`,`status`,`orientation`,`thumbnailUrl`,`lastSync`,`nextSync`])],8,fe))),128))],512))]),_:1})]),f(ae,{modelValue:B.value,"onUpdate:modelValue":a[5]||=e=>B.value=e,label:`Frame settings`},{default:i(()=>[a[16]||=_(`h2`,{class:`home-view__sheet-title`},`Frame settings`,-1),_(`div`,pe,[f(se,{modelValue:U.value,"onUpdate:modelValue":a[0]||=e=>U.value=e,label:`Frame name`,maxlength:`100`},null,8,[`modelValue`])]),_(`div`,me,[a[7]||=_(`p`,{class:`home-view__sheet-label`},`Orientation`,-1),f(K,{modelValue:W.value,"onUpdate:modelValue":a[1]||=e=>W.value=e},null,8,[`modelValue`])]),_(`div`,he,[a[14]||=_(`p`,{class:`home-view__sheet-label`},`Update frequency`,-1),y(_(`select`,{class:`home-view__mode-select`,"onUpdate:modelValue":a[2]||=e=>G.value=e,"aria-label":`Update frequency mode`},[...a[8]||=[_(`option`,{value:`times`},`At specific time(s)`,-1),_(`option`,{value:`interval`},`Every X minutes`,-1)]],512),[[b,G.value]]),G.value===`times`?(r(),h(`div`,ge,[_(`div`,_e,[(r(!0),h(m,null,e(q.value,(t,n)=>(r(),h(`div`,{key:n,class:`home-view__time-row`},[_(`select`,{class:`home-view__time-part`,value:L(t).h,"aria-label":`Hour`,onChange:e=>X(n,`h`,e.target.value)},[(r(),h(m,null,e(P,e=>_(`option`,{key:e,value:e},d(e),9,ye)),64))],40,ve),a[11]||=_(`span`,{class:`home-view__time-sep`},`:`,-1),_(`select`,{class:`home-view__time-part`,value:L(t).mm,"aria-label":`Minutes`,onChange:e=>X(n,`mm`,e.target.value)},[(r(),h(m,null,e(I,e=>_(`option`,{key:e,value:e},d(String(e).padStart(2,`0`)),9,xe)),64))],40,be),_(`select`,{class:`home-view__time-part home-view__time-part--ampm`,value:L(t).p,"aria-label":`AM or PM`,onChange:e=>X(n,`p`,e.target.value)},[...a[9]||=[_(`option`,{value:`AM`},`AM`,-1),_(`option`,{value:`PM`},`PM`,-1)]],40,Se),_(`button`,{type:`button`,class:`home-view__time-remove`,"aria-label":`Remove ${v(t)}`,onClick:e=>Me(n)},[...a[10]||=[_(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`},[_(`polyline`,{points:`3 6 5 6 21 6`}),_(`path`,{d:`M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6`}),_(`path`,{d:`M10 11v6`}),_(`path`,{d:`M14 11v6`})],-1)]],8,Ce)]))),128)),q.value.length===0?(r(),h(`p`,we,`No update times yet — add one below.`)):u(``,!0)]),_(`button`,{type:`button`,class:`home-view__time-add`,onClick:je},`+ Add time`),y(_(`select`,{class:`home-view__tz-select`,"onUpdate:modelValue":a[3]||=e=>Y.value=e},[(r(),h(m,null,e(z,t=>_(`optgroup`,{key:t.label,label:t.label},[(r(!0),h(m,null,e(t.zones,e=>(r(),h(`option`,{key:e.value,value:e.value},d(e.label),9,Ee))),128))],8,Te)),64))],512),[[b,Y.value]])])):(r(),h(`div`,De,[_(`div`,Oe,[a[12]||=_(`span`,null,`Every`,-1),y(_(`input`,{type:`number`,inputmode:`numeric`,pattern:`[0-9]*`,min:`1`,max:`1440`,class:`home-view__interval-input`,"onUpdate:modelValue":a[4]||=e=>J.value=e,"aria-label":`Update interval in minutes`},null,512),[[ne,J.value,void 0,{number:!0}]]),a[13]||=_(`span`,null,`minutes`,-1)])])),_(`p`,ke,d(Z.value),1),a[15]||=_(`p`,{class:`home-view__propagation-note`},` Changes will only take effect at the next device update. `,-1)]),f(x,{variant:`primary`,class:`home-view__sheet-save`,disabled:V.value,onClick:Fe},{default:i(()=>[ee(d(V.value?`Saving…`:`Save`),1)]),_:1},8,[`disabled`])]),_:1},8,[`modelValue`])],64))}}),[[`__scopeId`,`data-v-f583ffd6`]]);export{q as default}; \ No newline at end of file diff --git a/public/build/assets/LibraryView-D6fwq_vN.js b/public/build/assets/LibraryView-CiCcJhRw.js similarity index 98% rename from public/build/assets/LibraryView-D6fwq_vN.js rename to public/build/assets/LibraryView-CiCcJhRw.js index fcb1726..93ad55d 100644 --- a/public/build/assets/LibraryView-D6fwq_vN.js +++ b/public/build/assets/LibraryView-CiCcJhRw.js @@ -1 +1 @@ -import{A as e,G as t,L as n,O as r,R as i,T as a,V as o,_ as s,d as c,f as l,ft as u,g as d,h as f,l as p,o as m,p as h,t as g,u as _,ut as v,z as y}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{a as b,d as x,f as S,i as C,o as w,s as T,u as E}from"./index-B5Obd-7x.js";import{i as D,n as O,r as ee,t as k}from"./BaseBottomSheet-DohSPmvo.js";import{t as te}from"./PullToRefresh-DZt-0188.js";import{t as A}from"./DevicePicker-BF3g7ETO.js";var j={class:`approve-card`},M=[`src`,`alt`],N={class:`approve-card__body`},P={class:`approve-card__from`},F={class:`approve-card__date`},I={key:0,class:`approve-card__status`},L={class:`approve-card__actions`},ne=g(s({__name:`ApproveCard`,props:{item:{}},emits:[`updated`],setup(e,{emit:n}){let a=e,s=n,g=b(),y=D(),x=o(!1),S=o(!1),C=o([]),w=p(()=>new Date(a.item.sharedAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`}));async function T(){x.value=!1,S.value=!0;try{s(`updated`,await g.approveShared(a.item.id,C.value))}finally{S.value=!1,C.value=[]}}async function E(){S.value=!0;try{s(`updated`,await g.declineShared(a.item.id))}finally{S.value=!1}}return(n,a)=>(r(),h(m,null,[_(`div`,j,[_(`img`,{src:e.item.thumbnailUrl,alt:`Photo from ${e.item.sharedBy}`,class:`approve-card__thumb`,loading:`lazy`},null,8,M),_(`div`,N,[_(`p`,P,[a[3]||=f(`From `,-1),_(`strong`,null,u(e.item.sharedBy),1)]),_(`p`,F,u(w.value),1),e.item.status===`pending`?l(``,!0):(r(),h(`div`,I,[_(`span`,{class:v([`approve-card__badge`,`approve-card__badge--${e.item.status}`])},u(e.item.status),3)])),_(`div`,L,[e.item.status===`pending`||e.item.status===`declined`?(r(),c(O,{key:0,variant:`primary`,size:`sm`,disabled:S.value,onClick:a[0]||=e=>x.value=!0},{default:i(()=>[f(u(e.item.status===`declined`?`Add anyway`:`Add to frame`),1)]),_:1},8,[`disabled`])):l(``,!0),e.item.status===`pending`||e.item.status===`approved`?(r(),c(O,{key:1,variant:`ghost`,size:`sm`,disabled:S.value,onClick:E},{default:i(()=>[f(u(e.item.status===`approved`?`Remove`:`Decline`),1)]),_:1},8,[`disabled`])):l(``,!0)])])]),d(A,{modelValue:x.value,"onUpdate:modelValue":a[1]||=e=>x.value=e,devices:t(y).devices,selected:C.value,uploading:S.value,"confirm-label":`Add to frames`,"onUpdate:selected":a[2]||=e=>C.value=e,onConfirm:T},null,8,[`modelValue`,`devices`,`selected`,`uploading`])],64))}}),[[`__scopeId`,`data-v-6d3dd8b4`]]),R={class:`share-sheet__field`},z=[`onKeydown`],B={key:0,class:`share-sheet__error`},V={key:1,class:`share-sheet__success`},re=g(s({__name:`ShareSheet`,props:{modelValue:{type:Boolean},imageId:{}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,a=b(),s=o(``),p=o(!1),m=o(``),g=o(``);async function v(){if(m.value=``,g.value=``,s.value.trim()){p.value=!0;try{await a.shareImage(n.imageId,s.value.trim()),g.value=`Invite sent to ${s.value.trim()}`,s.value=``}catch(e){m.value=e instanceof Error?e.message:`Failed to send`}finally{p.value=!1}}}return(t,n)=>(r(),c(k,{"model-value":e.modelValue,label:`Share photo`,"onUpdate:modelValue":n[1]||=e=>t.$emit(`update:modelValue`,e)},{default:i(()=>[n[2]||=_(`h2`,{class:`share-sheet__title`},`Share with someone`,-1),n[3]||=_(`p`,{class:`share-sheet__sub`},`They'll get an email and can add it to their frame.`,-1),_(`div`,R,[y(_(`input`,{"onUpdate:modelValue":n[0]||=e=>s.value=e,type:`email`,class:`share-sheet__input`,placeholder:`their@email.com`,autocomplete:`email`,onKeydown:x(S(v,[`prevent`]),[`enter`])},null,40,z),[[E,s.value]])]),m.value?(r(),h(`p`,B,u(m.value),1)):l(``,!0),g.value?(r(),h(`p`,V,u(g.value),1)):l(``,!0),d(O,{variant:`primary`,class:`share-sheet__btn`,disabled:p.value||!s.value.trim(),onClick:v},{default:i(()=>[f(u(p.value?`Sending…`:`Send invite`),1)]),_:1},8,[`disabled`])]),_:1},8,[`model-value`]))}}),[[`__scopeId`,`data-v-24296e7b`]]),ie={class:`library`},ae={class:`library__header`},oe={class:`library__tabs`,role:`tablist`},se=[`aria-selected`,`onClick`],ce={key:0,class:`library__loading`},le={key:0,class:`library__empty`},ue={key:1,class:`library__grid`},de={class:`library__thumb`},fe=[`src`,`alt`],pe={class:`library__thumb-actions`},me=[`aria-label`,`title`,`onClick`],he=[`aria-label`,`disabled`,`onClick`],ge={key:0,width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},_e={key:1,width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`},ve=[`aria-label`,`onClick`],ye=[`onClick`],be={key:0,class:`library__approvals`},xe=[`aria-label`,`onClick`],Se={key:1,class:`library__locks`},Ce=[`aria-label`,`onClick`],we={width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},Te={key:0,d:`M7 11V7a5 5 0 0 1 10 0v4`},Ee={key:1,d:`M7 11V7a5 5 0 0 1 9.9-1`},De={class:`library__subtabs`,role:`tablist`},Oe=[`aria-selected`,`onClick`],ke={key:0,class:`library__loading`},Ae={key:1,class:`library__shared-empty`},H={class:`library__empty-title`},je={class:`library__empty-sub`},Me={key:2,class:`library__shared-list`},Ne={key:3,class:`library__pagination`},Pe=[`disabled`],Fe={class:`library__page-info`},Ie=[`disabled`],Le={class:`library__sheet-actions`},U=g(s({__name:`LibraryView`,setup(s){let g=T(),y=b(),x=D(),S=ee(),E=C(),A=w(),j=[{id:`all`,label:`All`},{id:`mine`,label:`Mine`},{id:`shared`,label:`Shared`}];function M(e){return j.some(t=>t.id===e)?e:`all`}let N=o(M(A.query.tab));n(()=>A.query.tab,e=>{let t=M(e);t!==N.value&&(N.value=t,t===`shared`&&B(F.value))});let P=[{id:`pending`,label:`Pending`},{id:`approved`,label:`Approved`},{id:`declined`,label:`Declined`}],F=o(`pending`),I=o([]),L=o(!1),R=o(1),z=o(1);async function B(e,t=1){L.value=!0;try{let n=await y.fetchSharedImages(e,t);I.value=n.items,R.value=n.page,z.value=n.totalPages}finally{L.value=!1}}function V(e){F.value=e,B(e,1)}function U(e){B(F.value,e)}function Re(e){let t=I.value.findIndex(t=>t.id===e.id);t!==-1&&(I.value[t]=e)}a(()=>{y.fetchImages(),x.fetchDevices(),y.fetchPendingCount(),N.value===`shared`&&B(F.value)});function ze(){let e=document.createElement(`input`);e.type=`file`,e.accept=`image/jpeg,image/png,image/webp,image/gif`,e.onchange=()=>{let t=e.files?.[0];t&&(S.init(t),g.push(`/upload`))},e.click()}function Be(){return window.scrollY===0}async function Ve(){await Promise.all([y.fetchImages({silent:!0}),y.fetchPendingCount(),x.fetchDevices({silent:!0}),N.value===`shared`?B(F.value,R.value):Promise.resolve()])}let W=p(()=>y.images),G=o(!1),K=o(null);function He(e){K.value=e,G.value=!0}let q=o(null);async function J(e,t){if(!q.value){q.value=e.id;try{await S.initEdit(e,t),g.push(`/upload`)}catch{E.show(`Could not load photo for editing`,`error`)}finally{q.value=null}}}function Y(e){if(e.cropOrientation)return e.cropOrientation;let t=e.cropParams;return!t?.natW||!t?.natH?null:t.natW>=t.natH?`landscape`:`portrait`}function X(e){let t=Y(e);if(!t)return null;for(let n of e.approvedDeviceIds){let e=x.devices.find(e=>e.id===n);if(e&&e.orientation!==t)return e}return null}async function Ue(e,t){try{t.lockedImageId===e?await x.unlockImage(t.id):await x.lockImage(t.id,e)}catch{E.show(`Failed to update lock`,`error`)}}async function We(e,t,n){try{await y.setApproval(e,t,n)}catch{E.show(`Failed to update frame approval`,`error`)}}let Z=o(!1),Q=o(null),$=o(!1);function Ge(e){Q.value=e,Z.value=!0}async function Ke(){if(Q.value){$.value=!0;try{await y.deleteImage(Q.value),Z.value=!1,E.show(`Photo deleted`,`success`)}catch{E.show(`Delete failed`,`error`)}finally{$.value=!1}}}return(n,a)=>(r(),h(`main`,ie,[d(te,{"is-at-top":Be,"on-refresh":Ve},{default:i(()=>[_(`div`,ae,[d(O,{variant:`primary`,class:`library__add-btn`,onClick:ze},{default:i(()=>[...a[5]||=[f(` + Add Photo `,-1)]]),_:1})]),_(`div`,oe,[(r(),h(m,null,e(j,e=>_(`button`,{key:e.id,type:`button`,role:`tab`,"aria-selected":N.value===e.id,class:v([`library__tab`,{"library__tab--active":N.value===e.id}]),onClick:t=>N.value=e.id},u(e.label),11,se)),64))]),t(y).loading?(r(),h(`div`,ce,`Loading…`)):N.value===`shared`?(r(),h(m,{key:2},[_(`div`,De,[(r(),h(m,null,e(P,e=>_(`button`,{key:e.id,type:`button`,role:`tab`,"aria-selected":F.value===e.id,class:v([`library__subtab`,{"library__subtab--active":F.value===e.id}]),onClick:t=>V(e.id)},u(e.label),11,Oe)),64))]),L.value?(r(),h(`div`,ke,`Loading…`)):I.value.length===0?(r(),h(`div`,Ae,[a[13]||=_(`svg`,{width:`48`,height:`48`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"aria-hidden":`true`},[_(`circle`,{cx:`18`,cy:`5`,r:`3`}),_(`circle`,{cx:`6`,cy:`12`,r:`3`}),_(`circle`,{cx:`18`,cy:`19`,r:`3`}),_(`line`,{x1:`8.59`,y1:`13.51`,x2:`15.42`,y2:`17.49`}),_(`line`,{x1:`15.41`,y1:`6.51`,x2:`8.59`,y2:`10.49`})],-1),_(`p`,H,u(F.value===`pending`?`No pending photos`:F.value===`approved`?`No approved photos`:`No declined photos`),1),_(`p`,je,u(F.value===`pending`?`Photos shared with you will appear here.`:`Photos you've added to a frame will appear here.`),1)])):(r(),h(`div`,Me,[(r(!0),h(m,null,e(I.value,e=>(r(),c(ne,{key:e.id,item:e,onUpdated:Re},null,8,[`item`]))),128))])),z.value>1?(r(),h(`div`,Ne,[_(`button`,{class:`library__page-btn`,disabled:R.value<=1,onClick:a[0]||=e=>U(R.value-1)},`← Prev`,8,Pe),_(`span`,Fe,u(R.value)+` / `+u(z.value),1),_(`button`,{class:`library__page-btn`,disabled:R.value>=z.value,onClick:a[1]||=e=>U(R.value+1)},`Next →`,8,Ie)])):l(``,!0)],64)):(r(),h(m,{key:1},[W.value.length===0?(r(),h(`div`,le,[...a[6]||=[_(`svg`,{width:`48`,height:`48`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"aria-hidden":`true`},[_(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),_(`circle`,{cx:`8.5`,cy:`8.5`,r:`1.5`}),_(`polyline`,{points:`21,15 16,10 5,21`})],-1),_(`p`,{class:`library__empty-title`},`No photos yet`,-1),_(`p`,{class:`library__empty-sub`},`Tap "+ Add Photo" above to upload your first one.`,-1)]])):(r(),h(`div`,ue,[(r(!0),h(m,null,e(W.value,n=>(r(),h(`div`,{key:n.id,class:`library__item`},[_(`div`,de,[_(`img`,{src:n.thumbnailUrl,alt:n.originalFilename,class:`library__img`,loading:`lazy`},null,8,fe),_(`div`,pe,[X(n)?(r(),h(`button`,{key:0,class:`library__action-btn library__action-btn--warn`,type:`button`,"aria-label":`Crop orientation does not match ${X(n).name}; tap to re-crop`,title:`Cropped ${Y(n)}, but ${X(n).name} is set to ${X(n).orientation}.`,onClick:e=>J(n,X(n).id)},[...a[7]||=[_(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},[_(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`}),_(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),_(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})],-1)]],8,me)):l(``,!0),_(`button`,{class:`library__action-btn`,type:`button`,"aria-label":`Edit ${n.originalFilename}`,disabled:q.value===n.id,onClick:e=>J(n)},[q.value===n.id?(r(),h(`svg`,_e,[...a[9]||=[_(`circle`,{cx:`12`,cy:`12`,r:`10`},null,-1),_(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`},null,-1),_(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`},null,-1)]])):(r(),h(`svg`,ge,[...a[8]||=[_(`path`,{d:`M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`},null,-1),_(`path`,{d:`M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z`},null,-1)]]))],8,he),_(`button`,{class:`library__action-btn`,type:`button`,"aria-label":`Share ${n.originalFilename}`,onClick:e=>He(n.id)},[...a[10]||=[_(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},[_(`circle`,{cx:`18`,cy:`5`,r:`3`}),_(`circle`,{cx:`6`,cy:`12`,r:`3`}),_(`circle`,{cx:`18`,cy:`19`,r:`3`}),_(`line`,{x1:`8.59`,y1:`13.51`,x2:`15.42`,y2:`17.49`}),_(`line`,{x1:`15.41`,y1:`6.51`,x2:`8.59`,y2:`10.49`})],-1)]],8,ve),_(`button`,{class:`library__action-btn library__action-btn--danger`,type:`button`,"aria-label":`Delete photo`,onClick:e=>Ge(n.id)},[...a[11]||=[_(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},[_(`polyline`,{points:`3 6 5 6 21 6`}),_(`path`,{d:`M19 6l-1 14H6L5 6`}),_(`path`,{d:`M10 11v6M14 11v6`}),_(`path`,{d:`M9 6V4h6v2`})],-1)]],8,ye)])]),t(x).devices.length>0?(r(),h(`div`,be,[(r(!0),h(m,null,e(t(x).devices,e=>(r(),h(`button`,{key:e.id,class:v([`library__approval-chip`,{"library__approval-chip--on":n.approvedDeviceIds.includes(e.id)}]),type:`button`,"aria-label":`${n.approvedDeviceIds.includes(e.id)?`Remove from`:`Add to`} ${e.name}`,onClick:t=>We(n.id,e.id,!n.approvedDeviceIds.includes(e.id))},u(e.name),11,xe))),128))])):l(``,!0),t(x).devices.length>0?(r(),h(`div`,Se,[(r(!0),h(m,null,e(t(x).devices.filter(e=>n.approvedDeviceIds.includes(e.id)),e=>(r(),h(`button`,{key:e.id,class:v([`library__lock-chip`,{"library__lock-chip--on":e.lockedImageId===n.id}]),type:`button`,"aria-label":`${e.lockedImageId===n.id?`Unlock from`:`Lock to`} ${e.name}`,onClick:t=>Ue(n.id,e)},[(r(),h(`svg`,we,[a[12]||=_(`rect`,{x:`3`,y:`11`,width:`18`,height:`11`,rx:`2`,ry:`2`},null,-1),e.lockedImageId===n.id?(r(),h(`path`,Te)):(r(),h(`path`,Ee))])),f(` `+u(e.name),1)],10,Ce))),128))])):l(``,!0)]))),128))]))],64))]),_:1}),K.value===null?l(``,!0):(r(),c(re,{key:0,modelValue:G.value,"onUpdate:modelValue":a[2]||=e=>G.value=e,"image-id":K.value},null,8,[`modelValue`,`image-id`])),d(k,{modelValue:Z.value,"onUpdate:modelValue":a[4]||=e=>Z.value=e,label:`Delete photo`},{default:i(()=>[a[15]||=_(`h2`,{class:`library__sheet-title`},`Delete this photo?`,-1),a[16]||=_(`p`,{class:`library__sheet-sub`},`It will be removed from all frames.`,-1),_(`div`,Le,[d(O,{variant:`secondary`,onClick:a[3]||=e=>Z.value=!1},{default:i(()=>[...a[14]||=[f(`Cancel`,-1)]]),_:1}),d(O,{variant:`destructive`,disabled:$.value,onClick:Ke},{default:i(()=>[f(u($.value?`Deleting…`:`Delete`),1)]),_:1},8,[`disabled`])])]),_:1},8,[`modelValue`])]))}}),[[`__scopeId`,`data-v-d22a9085`]]);export{U as default}; \ No newline at end of file +import{A as e,G as t,L as n,O as r,R as i,T as a,V as o,_ as s,d as c,f as l,ft as u,g as d,h as f,l as p,o as m,p as h,t as g,u as _,ut as v,z as y}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{a as b,d as x,f as S,i as C,o as w,s as T,u as E}from"./index-DabTPrXi.js";import{i as D,n as O,r as ee,t as k}from"./BaseBottomSheet-Y2PW4H1i.js";import{t as te}from"./PullToRefresh-DZt-0188.js";import{t as A}from"./DevicePicker-DcPlHAXI.js";var j={class:`approve-card`},M=[`src`,`alt`],N={class:`approve-card__body`},P={class:`approve-card__from`},F={class:`approve-card__date`},I={key:0,class:`approve-card__status`},L={class:`approve-card__actions`},ne=g(s({__name:`ApproveCard`,props:{item:{}},emits:[`updated`],setup(e,{emit:n}){let a=e,s=n,g=b(),y=D(),x=o(!1),S=o(!1),C=o([]),w=p(()=>new Date(a.item.sharedAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`}));async function T(){x.value=!1,S.value=!0;try{s(`updated`,await g.approveShared(a.item.id,C.value))}finally{S.value=!1,C.value=[]}}async function E(){S.value=!0;try{s(`updated`,await g.declineShared(a.item.id))}finally{S.value=!1}}return(n,a)=>(r(),h(m,null,[_(`div`,j,[_(`img`,{src:e.item.thumbnailUrl,alt:`Photo from ${e.item.sharedBy}`,class:`approve-card__thumb`,loading:`lazy`},null,8,M),_(`div`,N,[_(`p`,P,[a[3]||=f(`From `,-1),_(`strong`,null,u(e.item.sharedBy),1)]),_(`p`,F,u(w.value),1),e.item.status===`pending`?l(``,!0):(r(),h(`div`,I,[_(`span`,{class:v([`approve-card__badge`,`approve-card__badge--${e.item.status}`])},u(e.item.status),3)])),_(`div`,L,[e.item.status===`pending`||e.item.status===`declined`?(r(),c(O,{key:0,variant:`primary`,size:`sm`,disabled:S.value,onClick:a[0]||=e=>x.value=!0},{default:i(()=>[f(u(e.item.status===`declined`?`Add anyway`:`Add to frame`),1)]),_:1},8,[`disabled`])):l(``,!0),e.item.status===`pending`||e.item.status===`approved`?(r(),c(O,{key:1,variant:`ghost`,size:`sm`,disabled:S.value,onClick:E},{default:i(()=>[f(u(e.item.status===`approved`?`Remove`:`Decline`),1)]),_:1},8,[`disabled`])):l(``,!0)])])]),d(A,{modelValue:x.value,"onUpdate:modelValue":a[1]||=e=>x.value=e,devices:t(y).devices,selected:C.value,uploading:S.value,"confirm-label":`Add to frames`,"onUpdate:selected":a[2]||=e=>C.value=e,onConfirm:T},null,8,[`modelValue`,`devices`,`selected`,`uploading`])],64))}}),[[`__scopeId`,`data-v-6d3dd8b4`]]),R={class:`share-sheet__field`},z=[`onKeydown`],B={key:0,class:`share-sheet__error`},V={key:1,class:`share-sheet__success`},re=g(s({__name:`ShareSheet`,props:{modelValue:{type:Boolean},imageId:{}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,a=b(),s=o(``),p=o(!1),m=o(``),g=o(``);async function v(){if(m.value=``,g.value=``,s.value.trim()){p.value=!0;try{await a.shareImage(n.imageId,s.value.trim()),g.value=`Invite sent to ${s.value.trim()}`,s.value=``}catch(e){m.value=e instanceof Error?e.message:`Failed to send`}finally{p.value=!1}}}return(t,n)=>(r(),c(k,{"model-value":e.modelValue,label:`Share photo`,"onUpdate:modelValue":n[1]||=e=>t.$emit(`update:modelValue`,e)},{default:i(()=>[n[2]||=_(`h2`,{class:`share-sheet__title`},`Share with someone`,-1),n[3]||=_(`p`,{class:`share-sheet__sub`},`They'll get an email and can add it to their frame.`,-1),_(`div`,R,[y(_(`input`,{"onUpdate:modelValue":n[0]||=e=>s.value=e,type:`email`,class:`share-sheet__input`,placeholder:`their@email.com`,autocomplete:`email`,onKeydown:x(S(v,[`prevent`]),[`enter`])},null,40,z),[[E,s.value]])]),m.value?(r(),h(`p`,B,u(m.value),1)):l(``,!0),g.value?(r(),h(`p`,V,u(g.value),1)):l(``,!0),d(O,{variant:`primary`,class:`share-sheet__btn`,disabled:p.value||!s.value.trim(),onClick:v},{default:i(()=>[f(u(p.value?`Sending…`:`Send invite`),1)]),_:1},8,[`disabled`])]),_:1},8,[`model-value`]))}}),[[`__scopeId`,`data-v-24296e7b`]]),ie={class:`library`},ae={class:`library__header`},oe={class:`library__tabs`,role:`tablist`},se=[`aria-selected`,`onClick`],ce={key:0,class:`library__loading`},le={key:0,class:`library__empty`},ue={key:1,class:`library__grid`},de={class:`library__thumb`},fe=[`src`,`alt`],pe={class:`library__thumb-actions`},me=[`aria-label`,`title`,`onClick`],he=[`aria-label`,`disabled`,`onClick`],ge={key:0,width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},_e={key:1,width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`},ve=[`aria-label`,`onClick`],ye=[`onClick`],be={key:0,class:`library__approvals`},xe=[`aria-label`,`onClick`],Se={key:1,class:`library__locks`},Ce=[`aria-label`,`onClick`],we={width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},Te={key:0,d:`M7 11V7a5 5 0 0 1 10 0v4`},Ee={key:1,d:`M7 11V7a5 5 0 0 1 9.9-1`},De={class:`library__subtabs`,role:`tablist`},Oe=[`aria-selected`,`onClick`],ke={key:0,class:`library__loading`},Ae={key:1,class:`library__shared-empty`},H={class:`library__empty-title`},je={class:`library__empty-sub`},Me={key:2,class:`library__shared-list`},Ne={key:3,class:`library__pagination`},Pe=[`disabled`],Fe={class:`library__page-info`},Ie=[`disabled`],Le={class:`library__sheet-actions`},U=g(s({__name:`LibraryView`,setup(s){let g=T(),y=b(),x=D(),S=ee(),E=C(),A=w(),j=[{id:`all`,label:`All`},{id:`mine`,label:`Mine`},{id:`shared`,label:`Shared`}];function M(e){return j.some(t=>t.id===e)?e:`all`}let N=o(M(A.query.tab));n(()=>A.query.tab,e=>{let t=M(e);t!==N.value&&(N.value=t,t===`shared`&&B(F.value))});let P=[{id:`pending`,label:`Pending`},{id:`approved`,label:`Approved`},{id:`declined`,label:`Declined`}],F=o(`pending`),I=o([]),L=o(!1),R=o(1),z=o(1);async function B(e,t=1){L.value=!0;try{let n=await y.fetchSharedImages(e,t);I.value=n.items,R.value=n.page,z.value=n.totalPages}finally{L.value=!1}}function V(e){F.value=e,B(e,1)}function U(e){B(F.value,e)}function Re(e){let t=I.value.findIndex(t=>t.id===e.id);t!==-1&&(I.value[t]=e)}a(()=>{y.fetchImages(),x.fetchDevices(),y.fetchPendingCount(),N.value===`shared`&&B(F.value)});function ze(){let e=document.createElement(`input`);e.type=`file`,e.accept=`image/jpeg,image/png,image/webp,image/gif`,e.onchange=()=>{let t=e.files?.[0];t&&(S.init(t),g.push(`/upload`))},e.click()}function Be(){return window.scrollY===0}async function Ve(){await Promise.all([y.fetchImages({silent:!0}),y.fetchPendingCount(),x.fetchDevices({silent:!0}),N.value===`shared`?B(F.value,R.value):Promise.resolve()])}let W=p(()=>y.images),G=o(!1),K=o(null);function He(e){K.value=e,G.value=!0}let q=o(null);async function J(e,t){if(!q.value){q.value=e.id;try{await S.initEdit(e,t),g.push(`/upload`)}catch{E.show(`Could not load photo for editing`,`error`)}finally{q.value=null}}}function Y(e){if(e.cropOrientation)return e.cropOrientation;let t=e.cropParams;return!t?.natW||!t?.natH?null:t.natW>=t.natH?`landscape`:`portrait`}function X(e){let t=Y(e);if(!t)return null;for(let n of e.approvedDeviceIds){let e=x.devices.find(e=>e.id===n);if(e&&e.orientation!==t)return e}return null}async function Ue(e,t){try{t.lockedImageId===e?await x.unlockImage(t.id):await x.lockImage(t.id,e)}catch{E.show(`Failed to update lock`,`error`)}}async function We(e,t,n){try{await y.setApproval(e,t,n)}catch{E.show(`Failed to update frame approval`,`error`)}}let Z=o(!1),Q=o(null),$=o(!1);function Ge(e){Q.value=e,Z.value=!0}async function Ke(){if(Q.value){$.value=!0;try{await y.deleteImage(Q.value),Z.value=!1,E.show(`Photo deleted`,`success`)}catch{E.show(`Delete failed`,`error`)}finally{$.value=!1}}}return(n,a)=>(r(),h(`main`,ie,[d(te,{"is-at-top":Be,"on-refresh":Ve},{default:i(()=>[_(`div`,ae,[d(O,{variant:`primary`,class:`library__add-btn`,onClick:ze},{default:i(()=>[...a[5]||=[f(` + Add Photo `,-1)]]),_:1})]),_(`div`,oe,[(r(),h(m,null,e(j,e=>_(`button`,{key:e.id,type:`button`,role:`tab`,"aria-selected":N.value===e.id,class:v([`library__tab`,{"library__tab--active":N.value===e.id}]),onClick:t=>N.value=e.id},u(e.label),11,se)),64))]),t(y).loading?(r(),h(`div`,ce,`Loading…`)):N.value===`shared`?(r(),h(m,{key:2},[_(`div`,De,[(r(),h(m,null,e(P,e=>_(`button`,{key:e.id,type:`button`,role:`tab`,"aria-selected":F.value===e.id,class:v([`library__subtab`,{"library__subtab--active":F.value===e.id}]),onClick:t=>V(e.id)},u(e.label),11,Oe)),64))]),L.value?(r(),h(`div`,ke,`Loading…`)):I.value.length===0?(r(),h(`div`,Ae,[a[13]||=_(`svg`,{width:`48`,height:`48`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"aria-hidden":`true`},[_(`circle`,{cx:`18`,cy:`5`,r:`3`}),_(`circle`,{cx:`6`,cy:`12`,r:`3`}),_(`circle`,{cx:`18`,cy:`19`,r:`3`}),_(`line`,{x1:`8.59`,y1:`13.51`,x2:`15.42`,y2:`17.49`}),_(`line`,{x1:`15.41`,y1:`6.51`,x2:`8.59`,y2:`10.49`})],-1),_(`p`,H,u(F.value===`pending`?`No pending photos`:F.value===`approved`?`No approved photos`:`No declined photos`),1),_(`p`,je,u(F.value===`pending`?`Photos shared with you will appear here.`:`Photos you've added to a frame will appear here.`),1)])):(r(),h(`div`,Me,[(r(!0),h(m,null,e(I.value,e=>(r(),c(ne,{key:e.id,item:e,onUpdated:Re},null,8,[`item`]))),128))])),z.value>1?(r(),h(`div`,Ne,[_(`button`,{class:`library__page-btn`,disabled:R.value<=1,onClick:a[0]||=e=>U(R.value-1)},`← Prev`,8,Pe),_(`span`,Fe,u(R.value)+` / `+u(z.value),1),_(`button`,{class:`library__page-btn`,disabled:R.value>=z.value,onClick:a[1]||=e=>U(R.value+1)},`Next →`,8,Ie)])):l(``,!0)],64)):(r(),h(m,{key:1},[W.value.length===0?(r(),h(`div`,le,[...a[6]||=[_(`svg`,{width:`48`,height:`48`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"aria-hidden":`true`},[_(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),_(`circle`,{cx:`8.5`,cy:`8.5`,r:`1.5`}),_(`polyline`,{points:`21,15 16,10 5,21`})],-1),_(`p`,{class:`library__empty-title`},`No photos yet`,-1),_(`p`,{class:`library__empty-sub`},`Tap "+ Add Photo" above to upload your first one.`,-1)]])):(r(),h(`div`,ue,[(r(!0),h(m,null,e(W.value,n=>(r(),h(`div`,{key:n.id,class:`library__item`},[_(`div`,de,[_(`img`,{src:n.thumbnailUrl,alt:n.originalFilename,class:`library__img`,loading:`lazy`},null,8,fe),_(`div`,pe,[X(n)?(r(),h(`button`,{key:0,class:`library__action-btn library__action-btn--warn`,type:`button`,"aria-label":`Crop orientation does not match ${X(n).name}; tap to re-crop`,title:`Cropped ${Y(n)}, but ${X(n).name} is set to ${X(n).orientation}.`,onClick:e=>J(n,X(n).id)},[...a[7]||=[_(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},[_(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`}),_(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),_(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})],-1)]],8,me)):l(``,!0),_(`button`,{class:`library__action-btn`,type:`button`,"aria-label":`Edit ${n.originalFilename}`,disabled:q.value===n.id,onClick:e=>J(n)},[q.value===n.id?(r(),h(`svg`,_e,[...a[9]||=[_(`circle`,{cx:`12`,cy:`12`,r:`10`},null,-1),_(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`},null,-1),_(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`},null,-1)]])):(r(),h(`svg`,ge,[...a[8]||=[_(`path`,{d:`M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`},null,-1),_(`path`,{d:`M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z`},null,-1)]]))],8,he),_(`button`,{class:`library__action-btn`,type:`button`,"aria-label":`Share ${n.originalFilename}`,onClick:e=>He(n.id)},[...a[10]||=[_(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},[_(`circle`,{cx:`18`,cy:`5`,r:`3`}),_(`circle`,{cx:`6`,cy:`12`,r:`3`}),_(`circle`,{cx:`18`,cy:`19`,r:`3`}),_(`line`,{x1:`8.59`,y1:`13.51`,x2:`15.42`,y2:`17.49`}),_(`line`,{x1:`15.41`,y1:`6.51`,x2:`8.59`,y2:`10.49`})],-1)]],8,ve),_(`button`,{class:`library__action-btn library__action-btn--danger`,type:`button`,"aria-label":`Delete photo`,onClick:e=>Ge(n.id)},[...a[11]||=[_(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},[_(`polyline`,{points:`3 6 5 6 21 6`}),_(`path`,{d:`M19 6l-1 14H6L5 6`}),_(`path`,{d:`M10 11v6M14 11v6`}),_(`path`,{d:`M9 6V4h6v2`})],-1)]],8,ye)])]),t(x).devices.length>0?(r(),h(`div`,be,[(r(!0),h(m,null,e(t(x).devices,e=>(r(),h(`button`,{key:e.id,class:v([`library__approval-chip`,{"library__approval-chip--on":n.approvedDeviceIds.includes(e.id)}]),type:`button`,"aria-label":`${n.approvedDeviceIds.includes(e.id)?`Remove from`:`Add to`} ${e.name}`,onClick:t=>We(n.id,e.id,!n.approvedDeviceIds.includes(e.id))},u(e.name),11,xe))),128))])):l(``,!0),t(x).devices.length>0?(r(),h(`div`,Se,[(r(!0),h(m,null,e(t(x).devices.filter(e=>n.approvedDeviceIds.includes(e.id)),e=>(r(),h(`button`,{key:e.id,class:v([`library__lock-chip`,{"library__lock-chip--on":e.lockedImageId===n.id}]),type:`button`,"aria-label":`${e.lockedImageId===n.id?`Unlock from`:`Lock to`} ${e.name}`,onClick:t=>Ue(n.id,e)},[(r(),h(`svg`,we,[a[12]||=_(`rect`,{x:`3`,y:`11`,width:`18`,height:`11`,rx:`2`,ry:`2`},null,-1),e.lockedImageId===n.id?(r(),h(`path`,Te)):(r(),h(`path`,Ee))])),f(` `+u(e.name),1)],10,Ce))),128))])):l(``,!0)]))),128))]))],64))]),_:1}),K.value===null?l(``,!0):(r(),c(re,{key:0,modelValue:G.value,"onUpdate:modelValue":a[2]||=e=>G.value=e,"image-id":K.value},null,8,[`modelValue`,`image-id`])),d(k,{modelValue:Z.value,"onUpdate:modelValue":a[4]||=e=>Z.value=e,label:`Delete photo`},{default:i(()=>[a[15]||=_(`h2`,{class:`library__sheet-title`},`Delete this photo?`,-1),a[16]||=_(`p`,{class:`library__sheet-sub`},`It will be removed from all frames.`,-1),_(`div`,Le,[d(O,{variant:`secondary`,onClick:a[3]||=e=>Z.value=!1},{default:i(()=>[...a[14]||=[f(`Cancel`,-1)]]),_:1}),d(O,{variant:`destructive`,disabled:$.value,onClick:Ke},{default:i(()=>[f(u($.value?`Deleting…`:`Delete`),1)]),_:1},8,[`disabled`])])]),_:1},8,[`modelValue`])]))}}),[[`__scopeId`,`data-v-d22a9085`]]);export{U as default}; \ No newline at end of file diff --git a/public/build/assets/SettingsView-9KXbjwsG.js b/public/build/assets/SettingsView-w7VPfpOy.js similarity index 92% rename from public/build/assets/SettingsView-9KXbjwsG.js rename to public/build/assets/SettingsView-w7VPfpOy.js index 9285781..6221394 100644 --- a/public/build/assets/SettingsView-9KXbjwsG.js +++ b/public/build/assets/SettingsView-w7VPfpOy.js @@ -1 +1 @@ -import{A as e,G as t,O as n,_ as r,dt as i,f as a,ft as o,l as s,o as c,p as l,t as u,u as d,ut as f}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{n as p,r as m,t as h}from"./index-B5Obd-7x.js";var g={class:`settings`},_={class:`settings__section`},v={class:`theme-grid`,role:`radiogroup`,"aria-label":`Choose theme`},y=[`aria-checked`,`aria-label`,`onClick`],b={class:`theme-swatch__label`},x={key:0,class:`theme-swatch__check`,"aria-hidden":`true`},S={class:`settings__section`},C={class:`settings__row`},w={class:`settings__row-value`},T=u(r({__name:`SettingsView`,setup(r){let u=m(),{saveTheme:T}=p(),E=s(()=>u.user?.theme??`warm-craft`);function D(e){T(e)}return(r,s)=>(n(),l(`main`,g,[s[5]||=d(`h1`,{class:`settings__title`},`Settings`,-1),d(`section`,_,[s[1]||=d(`h2`,{class:`settings__section-title`},`Theme`,-1),d(`div`,v,[(n(!0),l(c,null,e(t(h),e=>(n(),l(`button`,{key:e.id,type:`button`,role:`radio`,"aria-checked":E.value===e.id,"aria-label":e.label,class:f([`theme-swatch`,{"theme-swatch--active":E.value===e.id}]),style:i({"--swatch-bg":e.bg,"--swatch-primary":e.primary,"--swatch-text":e.text}),onClick:t=>D(e.id)},[s[0]||=d(`span`,{class:`theme-swatch__preview`,"aria-hidden":`true`},[d(`span`,{class:`theme-swatch__bar`}),d(`span`,{class:`theme-swatch__dot`})],-1),d(`span`,b,o(e.label),1),E.value===e.id?(n(),l(`span`,x,`✓`)):a(``,!0)],14,y))),128))])]),d(`section`,S,[s[3]||=d(`h2`,{class:`settings__section-title`},`Account`,-1),d(`div`,C,[s[2]||=d(`span`,{class:`settings__row-label`},`Signed in as`,-1),d(`span`,w,o(t(u).user?.email),1)]),s[4]||=d(`a`,{href:`/logout`,class:`settings__logout`},`Sign out`,-1)])]))}}),[[`__scopeId`,`data-v-76ec3881`]]);export{T as default}; \ No newline at end of file +import{A as e,G as t,O as n,_ as r,dt as i,f as a,ft as o,l as s,o as c,p as l,t as u,u as d,ut as f}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{n as p,r as m,t as h}from"./index-DabTPrXi.js";var g={class:`settings`},_={class:`settings__section`},v={class:`theme-grid`,role:`radiogroup`,"aria-label":`Choose theme`},y=[`aria-checked`,`aria-label`,`onClick`],b={class:`theme-swatch__label`},x={key:0,class:`theme-swatch__check`,"aria-hidden":`true`},S={class:`settings__section`},C={class:`settings__row`},w={class:`settings__row-value`},T=u(r({__name:`SettingsView`,setup(r){let u=m(),{saveTheme:T}=p(),E=s(()=>u.user?.theme??`warm-craft`);function D(e){T(e)}return(r,s)=>(n(),l(`main`,g,[s[5]||=d(`h1`,{class:`settings__title`},`Settings`,-1),d(`section`,_,[s[1]||=d(`h2`,{class:`settings__section-title`},`Theme`,-1),d(`div`,v,[(n(!0),l(c,null,e(t(h),e=>(n(),l(`button`,{key:e.id,type:`button`,role:`radio`,"aria-checked":E.value===e.id,"aria-label":e.label,class:f([`theme-swatch`,{"theme-swatch--active":E.value===e.id}]),style:i({"--swatch-bg":e.bg,"--swatch-primary":e.primary,"--swatch-text":e.text}),onClick:t=>D(e.id)},[s[0]||=d(`span`,{class:`theme-swatch__preview`,"aria-hidden":`true`},[d(`span`,{class:`theme-swatch__bar`}),d(`span`,{class:`theme-swatch__dot`})],-1),d(`span`,b,o(e.label),1),E.value===e.id?(n(),l(`span`,x,`✓`)):a(``,!0)],14,y))),128))])]),d(`section`,S,[s[3]||=d(`h2`,{class:`settings__section-title`},`Account`,-1),d(`div`,C,[s[2]||=d(`span`,{class:`settings__row-label`},`Signed in as`,-1),d(`span`,w,o(t(u).user?.email),1)]),s[4]||=d(`a`,{href:`/logout`,class:`settings__logout`},`Sign out`,-1)])]))}}),[[`__scopeId`,`data-v-76ec3881`]]);export{T as default}; \ No newline at end of file diff --git a/public/build/assets/UploadView-CjF1nTLf.js b/public/build/assets/UploadView-BGpSWlmP.js similarity index 98% rename from public/build/assets/UploadView-CjF1nTLf.js rename to public/build/assets/UploadView-BGpSWlmP.js index f586d17..e78d69c 100644 --- a/public/build/assets/UploadView-CjF1nTLf.js +++ b/public/build/assets/UploadView-BGpSWlmP.js @@ -1 +1 @@ -import{A as e,C as t,G as n,L as r,M as i,O as a,R as o,T as s,V as c,_ as l,d as u,f as d,ft as f,g as p,h as m,l as h,o as g,p as _,t as v,u as y,ut as b,w as x}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{a as S,i as C,s as w}from"./index-B5Obd-7x.js";import{i as T,n as E,r as D,t as O}from"./BaseBottomSheet-DohSPmvo.js";import{t as k}from"./DevicePicker-BF3g7ETO.js";var A={class:`crop-editor__top`},j={key:0,class:`crop-editor__label`},M={class:`crop-editor__orient`,role:`radiogroup`,"aria-label":`Crop orientation`},N=[`aria-checked`,`aria-label`,`onClick`],P={width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`},ee={key:0,x:`2`,y:`6`,width:`20`,height:`12`,rx:`1.5`},F={key:1,x:`6`,y:`2`,width:`12`,height:`20`,rx:`1.5`},te={key:1,class:`crop-editor__mismatch`,role:`status`},ne={class:`crop-editor__actions`},I=v(l({__name:`CropEditor`,props:{src:{},orientation:{},deviceName:{},initialParams:{},initialOrientation:{}},emits:[`crop`],setup(t,{emit:n}){let i=t,l=n,u=[{value:`landscape`,label:`Landscape crop`},{value:`portrait`,label:`Portrait crop`}],v=c(i.initialOrientation??i.orientation),S=h(()=>v.value===`landscape`?{w:1600,h:960}:{w:960,h:1600}),C=h(()=>S.value.w/S.value.h),w=h(()=>v.value!==i.orientation),T=c(),D=c(),O=null,k=null,I=0,L=c(0),R=c(0),z=c(1),B={x:0,y:0,w:0,h:0},V=1;function re(e){v.value!==e&&(v.value=e,L.value=0,R.value=0,z.value=1,H())}function H(){let e=D.value,t=T.value;if(!e||!t)return;let n=t.getBoundingClientRect(),r=n.height-80,i=n.width;e.width=i,e.height=r,O=e.getContext(`2d`);let a=i-48,o=r-48,s,c;a/o>C.value?(c=o,s=c*C.value):(s=a,c=s/C.value),B={x:(i-s)/2,y:(r-c)/2,w:s,h:c},k&&U()}function U(){k&&(V=Math.max(B.w/k.naturalWidth,B.h/k.naturalHeight),i.initialParams?W(i.initialParams):(z.value=1,L.value=0,R.value=0,K()))}function W(e){if(!k)return;let t=B.w/e.natW;z.value=t/V,L.value=t*(k.naturalWidth/2-e.natX-e.natW/2),R.value=t*(k.naturalHeight/2-e.natY-e.natH/2);let[n,r]=G(L.value,R.value);L.value=n,R.value=r,K()}function G(e,t){if(!k)return[e,t];let n=V*z.value,r=k.naturalWidth*n,i=k.naturalHeight*n,a=(r-B.w)/2,o=(i-B.h)/2;return[Math.max(-a,Math.min(a,e)),Math.max(-o,Math.min(o,t))]}function K(){if(!O||!k||!D.value)return;let{width:e,height:t}=D.value,n=V*z.value,r=k.naturalWidth*n,i=k.naturalHeight*n,a=B.x+B.w/2+L.value,o=B.y+B.h/2+R.value,s=a-r/2,c=o-i/2;O.clearRect(0,0,e,t),O.drawImage(k,s,c,r,i),O.save(),O.fillStyle=`rgba(0,0,0,0.55)`,O.fillRect(0,0,e,t),O.globalCompositeOperation=`destination-out`,O.fillRect(B.x,B.y,B.w,B.h),O.restore(),O.strokeStyle=`#fff`,O.lineWidth=2,O.strokeRect(B.x,B.y,B.w,B.h),O.lineWidth=3,[[B.x,B.y,20,0,0,20],[B.x+B.w,B.y,-20,0,0,20],[B.x,B.y+B.h,20,0,0,-20],[B.x+B.w,B.y+B.h,-20,0,0,-20]].forEach(([e,t,n,r,i,a])=>{O.beginPath(),O.moveTo(e+n,t+r),O.lineTo(e,t),O.lineTo(e+i,t+a),O.stroke()})}let q=new Map,J=0;function Y(e){if(D.value?.setPointerCapture(e.pointerId),q.set(e.pointerId,{x:e.clientX,y:e.clientY}),q.size===2){let e=[...q.values()];J=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y)}}function X(e){if(!q.has(e.pointerId))return;let t=q.get(e.pointerId);if(q.set(e.pointerId,{x:e.clientX,y:e.clientY}),q.size===1){let n=e.clientX-t.x,r=e.clientY-t.y,[i,a]=G(L.value+n,R.value+r);L.value=i,R.value=a,Q();return}if(q.size===2){let e=[...q.values()],t=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y);if(J>0){let e=t/J;z.value=Math.max(1,z.value*e);let[n,r]=G(L.value,R.value);L.value=n,R.value=r,Q()}J=t}}function Z(e){q.delete(e.pointerId),J=0}function Q(){cancelAnimationFrame(I),I=requestAnimationFrame(K)}async function ie(){if(!k)return;let e=V*z.value,t=B.x+B.w/2+L.value,n=B.y+B.h/2+R.value,r=t-k.naturalWidth*e/2,i=n-k.naturalHeight*e/2,a=(B.x-r)/e,o=(B.y-i)/e,s=B.w/e,c=B.h/e,{w:u,h:d}=S.value,f=new OffscreenCanvas(u,d);f.getContext(`2d`).drawImage(k,a,o,s,c,0,0,u,d),l(`crop`,{blob:await f.convertToBlob({type:`image/jpeg`,quality:.92}),params:{natX:a,natY:o,natW:s,natH:c},orientation:v.value})}let $=new ResizeObserver(H);return s(()=>{T.value&&$.observe(T.value),H(),k=new Image,k.onload=()=>{H(),U()},k.src=i.src}),r(()=>i.src,e=>{k&&(k.onload=()=>U(),k.src=e)}),x(()=>{$.disconnect(),cancelAnimationFrame(I)}),(n,r)=>(a(),_(`div`,{class:`crop-editor`,ref_key:`containerRef`,ref:T},[y(`canvas`,{ref_key:`canvasRef`,ref:D,class:`crop-editor__canvas`,onPointerdown:Y,onPointermove:X,onPointerup:Z,onPointercancel:Z},null,544),y(`div`,A,[t.deviceName?(a(),_(`div`,j,f(t.deviceName),1)):d(``,!0),y(`div`,M,[(a(),_(g,null,e(u,e=>y(`button`,{key:e.value,type:`button`,role:`radio`,"aria-checked":v.value===e.value,"aria-label":e.label,class:b([`crop-editor__orient-btn`,{"crop-editor__orient-btn--active":v.value===e.value}]),onClick:t=>re(e.value)},[(a(),_(`svg`,P,[e.value===`landscape`?(a(),_(`rect`,ee)):(a(),_(`rect`,F))]))],10,N)),64))]),w.value?(a(),_(`div`,te,[r[0]||=y(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},[y(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`}),y(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),y(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})],-1),y(`span`,null,`Frame is set to `+f(t.orientation)+`. Switch the frame in Settings to display this crop.`,1)])):d(``,!0)]),y(`div`,ne,[p(E,{variant:`primary`,class:`crop-editor__use-btn`,onClick:ie},{default:o(()=>[...r[1]||=[m(` Use this crop `,-1)]]),_:1})])],512))}}),[[`__scopeId`,`data-v-85d7731b`]]),L=[{id:`seasonal`,label:`Seasonal`},{id:`holidays`,label:`Holidays`},{id:`fun`,label:`Fun`},{id:`family`,label:`Family`},{id:`nature`,label:`Nature`}],R=[{id:`sea-snow`,category:`seasonal`,label:`Snowflake`,emoji:`❄️`},{id:`sea-sun`,category:`seasonal`,label:`Sun`,emoji:`☀️`},{id:`sea-leaves`,category:`seasonal`,label:`Autumn`,emoji:`🍂`},{id:`sea-blossom`,category:`seasonal`,label:`Blossom`,emoji:`🌸`},{id:`sea-snowman`,category:`seasonal`,label:`Snowman`,emoji:`⛄`},{id:`hol-tree`,category:`holidays`,label:`Tree`,emoji:`🎄`},{id:`hol-gift`,category:`holidays`,label:`Gift`,emoji:`🎁`},{id:`hol-heart`,category:`holidays`,label:`Heart`,emoji:`❤️`},{id:`hol-party`,category:`holidays`,label:`Party`,emoji:`🎉`},{id:`hol-cake`,category:`holidays`,label:`Cake`,emoji:`🎂`},{id:`fun-star`,category:`fun`,label:`Star`,emoji:`⭐`},{id:`fun-rainbow`,category:`fun`,label:`Rainbow`,emoji:`🌈`},{id:`fun-balloon`,category:`fun`,label:`Balloon`,emoji:`🎈`},{id:`fun-sparkle`,category:`fun`,label:`Sparkles`,emoji:`✨`},{id:`fun-fire`,category:`fun`,label:`Fire`,emoji:`🔥`},{id:`fam-house`,category:`family`,label:`Home`,emoji:`🏠`},{id:`fam-paw`,category:`family`,label:`Paw`,emoji:`🐾`},{id:`fam-camera`,category:`family`,label:`Camera`,emoji:`📷`},{id:`fam-plane`,category:`family`,label:`Airplane`,emoji:`✈️`},{id:`fam-music`,category:`family`,label:`Music`,emoji:`🎵`},{id:`nat-tree`,category:`nature`,label:`Tree`,emoji:`🌲`},{id:`nat-flower`,category:`nature`,label:`Flower`,emoji:`🌺`},{id:`nat-bee`,category:`nature`,label:`Bee`,emoji:`🐝`},{id:`nat-fly`,category:`nature`,label:`Butterfly`,emoji:`🦋`},{id:`nat-moon`,category:`nature`,label:`Moon`,emoji:`🌙`}],z={class:`sticker-tray`},B={class:`sticker-tray__cats`,role:`tablist`},V=[`onClick`],re={class:`sticker-tray__grid`,role:`tabpanel`},H=[`aria-label`,`onClick`],U={class:`sticker-tray__emoji`,"aria-hidden":`true`},W={class:`sticker-tray__label`},G=v(l({__name:`StickerTray`,props:{modelValue:{type:Boolean}},emits:[`update:modelValue`,`pick`],setup(t){let r=c(`seasonal`),i=h(()=>R.filter(e=>e.category===r.value));return(s,c)=>(a(),u(O,{"model-value":t.modelValue,label:`Add sticker`,"onUpdate:modelValue":c[0]||=e=>s.$emit(`update:modelValue`,e)},{default:o(()=>[y(`div`,z,[y(`div`,B,[(a(!0),_(g,null,e(n(L),e=>(a(),_(`button`,{key:e.id,type:`button`,role:`tab`,class:b([`sticker-tray__cat`,{"sticker-tray__cat--active":r.value===e.id}]),onClick:t=>r.value=e.id},f(e.label),11,V))),128))]),y(`div`,re,[(a(!0),_(g,null,e(i.value,e=>(a(),_(`button`,{key:e.id,type:`button`,class:`sticker-tray__item`,"aria-label":e.label,onClick:t=>s.$emit(`pick`,e.id)},[y(`span`,U,f(e.emoji),1),y(`span`,W,f(e.label),1)],8,H))),128))])])]),_:1},8,[`model-value`]))}}),[[`__scopeId`,`data-v-7eada75b`]]),K={class:`sticker-canvas__bar`},q=52,J=v(l({__name:`StickerCanvas`,props:{croppedUrl:{},orientation:{},stickers:{}},emits:[`add-sticker`,`update-sticker`,`remove-sticker`,`done`],setup(n,{emit:l}){let f=n,v=l,b=c(),S=c(),C=c(),w=c(),T=c(!1),D=c(null),O=c(375),k=c(225),A=f.orientation===`landscape`?1600/960:960/1600;function j(){if(!b.value)return;let{width:e,height:t}=b.value.getBoundingClientRect(),n=t-72;e/n>A?(k.value=n,O.value=n*A):(O.value=e,k.value=e/A),P()}let M=new ResizeObserver(j);s(()=>{b.value&&M.observe(b.value),j(),Q()}),x(()=>{M.disconnect(),ie()});let N=c(null);function P(){let e=new Image;e.onload=()=>{N.value=e},e.src=f.croppedUrl}r(()=>f.croppedUrl,()=>P(),{immediate:!0});let ee=h(()=>({width:O.value,height:k.value})),F=h(()=>({image:N.value,x:0,y:0,width:O.value,height:k.value})),te={enabledAnchors:[`top-left`,`top-right`,`bottom-left`,`bottom-right`],rotateEnabled:!0,borderStroke:`rgba(255,255,255,0.8)`,anchorFill:`#fff`,anchorSize:18,keepRatio:!0,boundBoxFunc:(e,t)=>t};function ne(e){return{id:e.id,text:I(e.type),fontSize:q,fontFamily:`"Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif`,x:e.x,y:e.y,scaleX:e.scale,scaleY:e.scale,rotation:e.rotation,draggable:!0,offsetX:q/2,offsetY:q/2}}function I(e){return R.find(t=>t.id===e)?.emoji??`⭐`}function L(e,n){n.cancelBubble=!0,D.value=e,t(()=>{let t=(w.value?.getNode())?.findOne(`#${e}`),n=C.value?.getNode();t&&n&&n.nodes([t])})}function z(e){e.target===e.target.getStage()&&(D.value=null,C.value?.getNode()?.nodes([]))}function B(){D.value&&(v(`remove-sticker`,D.value),D.value=null,C.value?.getNode()?.nodes([]))}function V(e,t){v(`update-sticker`,e,{x:t.target.x(),y:t.target.y()})}function re(e,t){v(`update-sticker`,e,{x:t.target.x(),y:t.target.y(),scale:t.target.scaleX(),rotation:t.target.rotation()})}function H(e){let n={id:`${e}-${Date.now()}`,type:e,x:O.value/2,y:k.value/2,scale:1,rotation:0};v(`add-sticker`,n),T.value=!1,t(()=>L(n.id,{cancelBubble:!1}))}let U=0,W=1;function J(e){let t=e[0].clientX-e[1].clientX,n=e[0].clientY-e[1].clientY;return Math.hypot(t,n)}function Y(e){e.touches.length!==2||!D.value||(U=J(e.touches),W=f.stickers.find(e=>e.id===D.value)?.scale??1)}function X(e){if(e.touches.length!==2||!D.value||U===0)return;e.preventDefault();let t=Math.max(.2,Math.min(6,W*(J(e.touches)/U)));v(`update-sticker`,D.value,{scale:t})}function Z(){U=0,W=1}function Q(){let e=b.value;e&&(e.addEventListener(`touchstart`,Y,{passive:!0}),e.addEventListener(`touchmove`,X,{passive:!1}),e.addEventListener(`touchend`,Z,{passive:!0}))}function ie(){let e=b.value;e&&(e.removeEventListener(`touchstart`,Y),e.removeEventListener(`touchmove`,X),e.removeEventListener(`touchend`,Z))}async function $(){D.value=null,C.value?.getNode()?.nodes([]),await t();let e=S.value?.getNode();if(!e)return;let n=(f.orientation===`landscape`?1600:960)/O.value,r=await e.toBlob({pixelRatio:n,mimeType:`image/jpeg`,quality:.92});r&&v(`done`,r)}return(t,r)=>{let s=i(`v-image`),c=i(`v-layer`),l=i(`v-text`),f=i(`v-transformer`),h=i(`v-stage`);return a(),_(`div`,{class:`sticker-canvas`,ref_key:`containerRef`,ref:b},[p(h,{ref_key:`stageRef`,ref:S,config:ee.value,onClick:z,onTap:z},{default:o(()=>[p(c,null,{default:o(()=>[p(s,{config:F.value},null,8,[`config`])]),_:1}),p(c,{ref_key:`stickerLayerRef`,ref:w},{default:o(()=>[(a(!0),_(g,null,e(n.stickers,e=>(a(),u(l,{key:e.id,config:ne(e),onClick:t=>L(e.id,t),onTap:t=>L(e.id,t),onDragend:t=>V(e.id,t),onTransformend:t=>re(e.id,t)},null,8,[`config`,`onClick`,`onTap`,`onDragend`,`onTransformend`]))),128)),p(f,{ref_key:`transformerRef`,ref:C,config:te},null,512)]),_:1},512)]),_:1},8,[`config`]),D.value?(a(),_(`button`,{key:0,class:`sticker-canvas__delete`,type:`button`,"aria-label":`Remove sticker`,onClick:B},[...r[2]||=[y(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},[y(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),y(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})],-1)]])):d(``,!0),y(`div`,K,[y(`button`,{class:`sticker-canvas__add-btn`,type:`button`,onClick:r[0]||=e=>T.value=!0},[...r[3]||=[y(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`},[y(`circle`,{cx:`12`,cy:`12`,r:`10`}),y(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`16`}),y(`line`,{x1:`8`,y1:`12`,x2:`16`,y2:`12`})],-1),m(` Add sticker `,-1)]]),p(E,{variant:`primary`,class:`sticker-canvas__next-btn`,onClick:$},{default:o(()=>[...r[4]||=[m(`Next`,-1)]]),_:1})]),p(G,{modelValue:T.value,"onUpdate:modelValue":r[1]||=e=>T.value=e,onPick:H},null,8,[`modelValue`])],512)}}}),[[`__scopeId`,`data-v-fb52db70`]]),Y={class:`upload-view`},X={class:`upload-view__header`},Z=[`aria-label`],Q={key:0,width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},ie={key:1,width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},$={class:`upload-view__step-label`},ae={key:2,class:`upload-view__done`},oe={class:`upload-view__done-title`},se=v(l({__name:`UploadView`,setup(e){let t=w(),r=D(),i=T(),l=S(),g=C(),v=c(`crop`),b=c(!1),x=c(!1),O=null,A=h(()=>r.editingImageId!==null);s(async()=>{if(await i.fetchDevices(),!r.originalFile){t.replace(`/`);return}v.value=`crop`});let j=h(()=>r.contextDeviceId?i.devices.find(e=>e.id===r.contextDeviceId):i.devices[0]),M=h(()=>j.value?.orientation??`landscape`),N=h(()=>r.cropOrientation??M.value),P=h(()=>j.value?.name),ee=h(()=>v.value===`crop`?A.value?`Edit crop`:`Crop photo`:v.value===`stickers`?`Add stickers`:A.value?`Updated`:`Added`);function F({blob:e,params:t,orientation:n}){r.setCrop(e,t,n),v.value=`stickers`}function te(){r.croppedBlob&&(O=r.croppedBlob,A.value?R():x.value=!0)}function ne(e){O=e,A.value?R():x.value=!0}function L(){if(v.value===`crop`){r.cleanup(),t.replace(`/library`);return}v.value===`stickers`&&(v.value=`crop`)}async function R(){if(O){b.value=!0;try{let e=new File([O],`photo.jpg`,{type:`image/jpeg`});if(A.value){await l.reprocessImage(r.editingImageId,e,{cropParams:r.cropParams??void 0,stickerState:r.stickers,cropOrientation:r.cropOrientation??void 0}),x.value=!1,v.value=`done`;return}let t=await l.uploadImage(e,{original:r.originalFile??void 0,cropParams:r.cropParams??void 0,stickerState:r.stickers,cropOrientation:r.cropOrientation??void 0});await Promise.all(r.selectedDeviceIds.map(e=>l.setApproval(t.id,e,!0))),x.value=!1,v.value=`done`}catch(e){g.show(e instanceof Error?e.message:`Upload failed`,`error`)}finally{b.value=!1}}}function z(){r.cleanup(),t.replace(`/library`)}return(e,t)=>(a(),_(`div`,Y,[y(`header`,X,[v.value===`done`?d(``,!0):(a(),_(`button`,{key:0,class:`upload-view__back`,type:`button`,"aria-label":v.value===`crop`?`Cancel`:`Back`,onClick:L},[v.value===`crop`?(a(),_(`svg`,Q,[...t[2]||=[y(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`},null,-1),y(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`},null,-1)]])):(a(),_(`svg`,ie,[...t[3]||=[y(`polyline`,{points:`15 18 9 12 15 6`},null,-1)]]))],8,Z)),y(`span`,$,f(ee.value),1),v.value===`stickers`?(a(),_(`button`,{key:1,class:`upload-view__skip`,type:`button`,onClick:te},`Skip`)):d(``,!0)]),v.value===`crop`&&n(r).originalUrl?(a(),u(I,{key:0,src:n(r).originalUrl,orientation:M.value,"device-name":P.value,"initial-params":n(r).cropParams,"initial-orientation":n(r).cropOrientation,class:`upload-view__stage`,onCrop:F},null,8,[`src`,`orientation`,`device-name`,`initial-params`,`initial-orientation`])):v.value===`stickers`&&n(r).croppedUrl?(a(),u(J,{key:1,"cropped-url":n(r).croppedUrl,orientation:N.value,stickers:n(r).stickers,class:`upload-view__stage`,onAddSticker:n(r).addSticker,onUpdateSticker:n(r).updateSticker,onRemoveSticker:n(r).removeSticker,onDone:ne},null,8,[`cropped-url`,`orientation`,`stickers`,`onAddSticker`,`onUpdateSticker`,`onRemoveSticker`])):v.value===`done`?(a(),_(`div`,ae,[t[5]||=y(`div`,{class:`upload-view__done-icon`,"aria-hidden":`true`},`🎉`,-1),y(`p`,oe,f(A.value?`Photo updated!`:`Photo added!`),1),t[6]||=y(`p`,{class:`upload-view__done-sub`},`It'll appear on your frame at the next update.`,-1),p(E,{variant:`primary`,class:`upload-view__done-btn`,onClick:z},{default:o(()=>[...t[4]||=[m(`Done`,-1)]]),_:1})])):d(``,!0),A.value?d(``,!0):(a(),u(k,{key:3,modelValue:x.value,"onUpdate:modelValue":t[0]||=e=>x.value=e,devices:n(i).devices,selected:n(r).selectedDeviceIds,uploading:b.value,"onUpdate:selected":t[1]||=e=>n(r).selectedDeviceIds=e,onConfirm:R},null,8,[`modelValue`,`devices`,`selected`,`uploading`]))]))}}),[[`__scopeId`,`data-v-af5b9c38`]]);export{se as default}; \ No newline at end of file +import{A as e,C as t,G as n,L as r,M as i,O as a,R as o,T as s,V as c,_ as l,d as u,f as d,ft as f,g as p,h as m,l as h,o as g,p as _,t as v,u as y,ut as b,w as x}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{a as S,i as C,s as w}from"./index-DabTPrXi.js";import{i as T,n as E,r as D,t as O}from"./BaseBottomSheet-Y2PW4H1i.js";import{t as k}from"./DevicePicker-DcPlHAXI.js";var A={class:`crop-editor__top`},j={key:0,class:`crop-editor__label`},M={class:`crop-editor__orient`,role:`radiogroup`,"aria-label":`Crop orientation`},N=[`aria-checked`,`aria-label`,`onClick`],P={width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`},ee={key:0,x:`2`,y:`6`,width:`20`,height:`12`,rx:`1.5`},F={key:1,x:`6`,y:`2`,width:`12`,height:`20`,rx:`1.5`},te={key:1,class:`crop-editor__mismatch`,role:`status`},ne={class:`crop-editor__actions`},I=v(l({__name:`CropEditor`,props:{src:{},orientation:{},deviceName:{},initialParams:{},initialOrientation:{}},emits:[`crop`],setup(t,{emit:n}){let i=t,l=n,u=[{value:`landscape`,label:`Landscape crop`},{value:`portrait`,label:`Portrait crop`}],v=c(i.initialOrientation??i.orientation),S=h(()=>v.value===`landscape`?{w:1600,h:960}:{w:960,h:1600}),C=h(()=>S.value.w/S.value.h),w=h(()=>v.value!==i.orientation),T=c(),D=c(),O=null,k=null,I=0,L=c(0),R=c(0),z=c(1),B={x:0,y:0,w:0,h:0},V=1;function re(e){v.value!==e&&(v.value=e,L.value=0,R.value=0,z.value=1,H())}function H(){let e=D.value,t=T.value;if(!e||!t)return;let n=t.getBoundingClientRect(),r=n.height-80,i=n.width;e.width=i,e.height=r,O=e.getContext(`2d`);let a=i-48,o=r-48,s,c;a/o>C.value?(c=o,s=c*C.value):(s=a,c=s/C.value),B={x:(i-s)/2,y:(r-c)/2,w:s,h:c},k&&U()}function U(){k&&(V=Math.max(B.w/k.naturalWidth,B.h/k.naturalHeight),i.initialParams?W(i.initialParams):(z.value=1,L.value=0,R.value=0,K()))}function W(e){if(!k)return;let t=B.w/e.natW;z.value=t/V,L.value=t*(k.naturalWidth/2-e.natX-e.natW/2),R.value=t*(k.naturalHeight/2-e.natY-e.natH/2);let[n,r]=G(L.value,R.value);L.value=n,R.value=r,K()}function G(e,t){if(!k)return[e,t];let n=V*z.value,r=k.naturalWidth*n,i=k.naturalHeight*n,a=(r-B.w)/2,o=(i-B.h)/2;return[Math.max(-a,Math.min(a,e)),Math.max(-o,Math.min(o,t))]}function K(){if(!O||!k||!D.value)return;let{width:e,height:t}=D.value,n=V*z.value,r=k.naturalWidth*n,i=k.naturalHeight*n,a=B.x+B.w/2+L.value,o=B.y+B.h/2+R.value,s=a-r/2,c=o-i/2;O.clearRect(0,0,e,t),O.drawImage(k,s,c,r,i),O.save(),O.fillStyle=`rgba(0,0,0,0.55)`,O.fillRect(0,0,e,t),O.globalCompositeOperation=`destination-out`,O.fillRect(B.x,B.y,B.w,B.h),O.restore(),O.strokeStyle=`#fff`,O.lineWidth=2,O.strokeRect(B.x,B.y,B.w,B.h),O.lineWidth=3,[[B.x,B.y,20,0,0,20],[B.x+B.w,B.y,-20,0,0,20],[B.x,B.y+B.h,20,0,0,-20],[B.x+B.w,B.y+B.h,-20,0,0,-20]].forEach(([e,t,n,r,i,a])=>{O.beginPath(),O.moveTo(e+n,t+r),O.lineTo(e,t),O.lineTo(e+i,t+a),O.stroke()})}let q=new Map,J=0;function Y(e){if(D.value?.setPointerCapture(e.pointerId),q.set(e.pointerId,{x:e.clientX,y:e.clientY}),q.size===2){let e=[...q.values()];J=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y)}}function X(e){if(!q.has(e.pointerId))return;let t=q.get(e.pointerId);if(q.set(e.pointerId,{x:e.clientX,y:e.clientY}),q.size===1){let n=e.clientX-t.x,r=e.clientY-t.y,[i,a]=G(L.value+n,R.value+r);L.value=i,R.value=a,Q();return}if(q.size===2){let e=[...q.values()],t=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y);if(J>0){let e=t/J;z.value=Math.max(1,z.value*e);let[n,r]=G(L.value,R.value);L.value=n,R.value=r,Q()}J=t}}function Z(e){q.delete(e.pointerId),J=0}function Q(){cancelAnimationFrame(I),I=requestAnimationFrame(K)}async function ie(){if(!k)return;let e=V*z.value,t=B.x+B.w/2+L.value,n=B.y+B.h/2+R.value,r=t-k.naturalWidth*e/2,i=n-k.naturalHeight*e/2,a=(B.x-r)/e,o=(B.y-i)/e,s=B.w/e,c=B.h/e,{w:u,h:d}=S.value,f=new OffscreenCanvas(u,d);f.getContext(`2d`).drawImage(k,a,o,s,c,0,0,u,d),l(`crop`,{blob:await f.convertToBlob({type:`image/jpeg`,quality:.92}),params:{natX:a,natY:o,natW:s,natH:c},orientation:v.value})}let $=new ResizeObserver(H);return s(()=>{T.value&&$.observe(T.value),H(),k=new Image,k.onload=()=>{H(),U()},k.src=i.src}),r(()=>i.src,e=>{k&&(k.onload=()=>U(),k.src=e)}),x(()=>{$.disconnect(),cancelAnimationFrame(I)}),(n,r)=>(a(),_(`div`,{class:`crop-editor`,ref_key:`containerRef`,ref:T},[y(`canvas`,{ref_key:`canvasRef`,ref:D,class:`crop-editor__canvas`,onPointerdown:Y,onPointermove:X,onPointerup:Z,onPointercancel:Z},null,544),y(`div`,A,[t.deviceName?(a(),_(`div`,j,f(t.deviceName),1)):d(``,!0),y(`div`,M,[(a(),_(g,null,e(u,e=>y(`button`,{key:e.value,type:`button`,role:`radio`,"aria-checked":v.value===e.value,"aria-label":e.label,class:b([`crop-editor__orient-btn`,{"crop-editor__orient-btn--active":v.value===e.value}]),onClick:t=>re(e.value)},[(a(),_(`svg`,P,[e.value===`landscape`?(a(),_(`rect`,ee)):(a(),_(`rect`,F))]))],10,N)),64))]),w.value?(a(),_(`div`,te,[r[0]||=y(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},[y(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`}),y(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),y(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})],-1),y(`span`,null,`Frame is set to `+f(t.orientation)+`. Switch the frame in Settings to display this crop.`,1)])):d(``,!0)]),y(`div`,ne,[p(E,{variant:`primary`,class:`crop-editor__use-btn`,onClick:ie},{default:o(()=>[...r[1]||=[m(` Use this crop `,-1)]]),_:1})])],512))}}),[[`__scopeId`,`data-v-85d7731b`]]),L=[{id:`seasonal`,label:`Seasonal`},{id:`holidays`,label:`Holidays`},{id:`fun`,label:`Fun`},{id:`family`,label:`Family`},{id:`nature`,label:`Nature`}],R=[{id:`sea-snow`,category:`seasonal`,label:`Snowflake`,emoji:`❄️`},{id:`sea-sun`,category:`seasonal`,label:`Sun`,emoji:`☀️`},{id:`sea-leaves`,category:`seasonal`,label:`Autumn`,emoji:`🍂`},{id:`sea-blossom`,category:`seasonal`,label:`Blossom`,emoji:`🌸`},{id:`sea-snowman`,category:`seasonal`,label:`Snowman`,emoji:`⛄`},{id:`hol-tree`,category:`holidays`,label:`Tree`,emoji:`🎄`},{id:`hol-gift`,category:`holidays`,label:`Gift`,emoji:`🎁`},{id:`hol-heart`,category:`holidays`,label:`Heart`,emoji:`❤️`},{id:`hol-party`,category:`holidays`,label:`Party`,emoji:`🎉`},{id:`hol-cake`,category:`holidays`,label:`Cake`,emoji:`🎂`},{id:`fun-star`,category:`fun`,label:`Star`,emoji:`⭐`},{id:`fun-rainbow`,category:`fun`,label:`Rainbow`,emoji:`🌈`},{id:`fun-balloon`,category:`fun`,label:`Balloon`,emoji:`🎈`},{id:`fun-sparkle`,category:`fun`,label:`Sparkles`,emoji:`✨`},{id:`fun-fire`,category:`fun`,label:`Fire`,emoji:`🔥`},{id:`fam-house`,category:`family`,label:`Home`,emoji:`🏠`},{id:`fam-paw`,category:`family`,label:`Paw`,emoji:`🐾`},{id:`fam-camera`,category:`family`,label:`Camera`,emoji:`📷`},{id:`fam-plane`,category:`family`,label:`Airplane`,emoji:`✈️`},{id:`fam-music`,category:`family`,label:`Music`,emoji:`🎵`},{id:`nat-tree`,category:`nature`,label:`Tree`,emoji:`🌲`},{id:`nat-flower`,category:`nature`,label:`Flower`,emoji:`🌺`},{id:`nat-bee`,category:`nature`,label:`Bee`,emoji:`🐝`},{id:`nat-fly`,category:`nature`,label:`Butterfly`,emoji:`🦋`},{id:`nat-moon`,category:`nature`,label:`Moon`,emoji:`🌙`}],z={class:`sticker-tray`},B={class:`sticker-tray__cats`,role:`tablist`},V=[`onClick`],re={class:`sticker-tray__grid`,role:`tabpanel`},H=[`aria-label`,`onClick`],U={class:`sticker-tray__emoji`,"aria-hidden":`true`},W={class:`sticker-tray__label`},G=v(l({__name:`StickerTray`,props:{modelValue:{type:Boolean}},emits:[`update:modelValue`,`pick`],setup(t){let r=c(`seasonal`),i=h(()=>R.filter(e=>e.category===r.value));return(s,c)=>(a(),u(O,{"model-value":t.modelValue,label:`Add sticker`,"onUpdate:modelValue":c[0]||=e=>s.$emit(`update:modelValue`,e)},{default:o(()=>[y(`div`,z,[y(`div`,B,[(a(!0),_(g,null,e(n(L),e=>(a(),_(`button`,{key:e.id,type:`button`,role:`tab`,class:b([`sticker-tray__cat`,{"sticker-tray__cat--active":r.value===e.id}]),onClick:t=>r.value=e.id},f(e.label),11,V))),128))]),y(`div`,re,[(a(!0),_(g,null,e(i.value,e=>(a(),_(`button`,{key:e.id,type:`button`,class:`sticker-tray__item`,"aria-label":e.label,onClick:t=>s.$emit(`pick`,e.id)},[y(`span`,U,f(e.emoji),1),y(`span`,W,f(e.label),1)],8,H))),128))])])]),_:1},8,[`model-value`]))}}),[[`__scopeId`,`data-v-7eada75b`]]),K={class:`sticker-canvas__bar`},q=52,J=v(l({__name:`StickerCanvas`,props:{croppedUrl:{},orientation:{},stickers:{}},emits:[`add-sticker`,`update-sticker`,`remove-sticker`,`done`],setup(n,{emit:l}){let f=n,v=l,b=c(),S=c(),C=c(),w=c(),T=c(!1),D=c(null),O=c(375),k=c(225),A=f.orientation===`landscape`?1600/960:960/1600;function j(){if(!b.value)return;let{width:e,height:t}=b.value.getBoundingClientRect(),n=t-72;e/n>A?(k.value=n,O.value=n*A):(O.value=e,k.value=e/A),P()}let M=new ResizeObserver(j);s(()=>{b.value&&M.observe(b.value),j(),Q()}),x(()=>{M.disconnect(),ie()});let N=c(null);function P(){let e=new Image;e.onload=()=>{N.value=e},e.src=f.croppedUrl}r(()=>f.croppedUrl,()=>P(),{immediate:!0});let ee=h(()=>({width:O.value,height:k.value})),F=h(()=>({image:N.value,x:0,y:0,width:O.value,height:k.value})),te={enabledAnchors:[`top-left`,`top-right`,`bottom-left`,`bottom-right`],rotateEnabled:!0,borderStroke:`rgba(255,255,255,0.8)`,anchorFill:`#fff`,anchorSize:18,keepRatio:!0,boundBoxFunc:(e,t)=>t};function ne(e){return{id:e.id,text:I(e.type),fontSize:q,fontFamily:`"Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif`,x:e.x,y:e.y,scaleX:e.scale,scaleY:e.scale,rotation:e.rotation,draggable:!0,offsetX:q/2,offsetY:q/2}}function I(e){return R.find(t=>t.id===e)?.emoji??`⭐`}function L(e,n){n.cancelBubble=!0,D.value=e,t(()=>{let t=(w.value?.getNode())?.findOne(`#${e}`),n=C.value?.getNode();t&&n&&n.nodes([t])})}function z(e){e.target===e.target.getStage()&&(D.value=null,C.value?.getNode()?.nodes([]))}function B(){D.value&&(v(`remove-sticker`,D.value),D.value=null,C.value?.getNode()?.nodes([]))}function V(e,t){v(`update-sticker`,e,{x:t.target.x(),y:t.target.y()})}function re(e,t){v(`update-sticker`,e,{x:t.target.x(),y:t.target.y(),scale:t.target.scaleX(),rotation:t.target.rotation()})}function H(e){let n={id:`${e}-${Date.now()}`,type:e,x:O.value/2,y:k.value/2,scale:1,rotation:0};v(`add-sticker`,n),T.value=!1,t(()=>L(n.id,{cancelBubble:!1}))}let U=0,W=1;function J(e){let t=e[0].clientX-e[1].clientX,n=e[0].clientY-e[1].clientY;return Math.hypot(t,n)}function Y(e){e.touches.length!==2||!D.value||(U=J(e.touches),W=f.stickers.find(e=>e.id===D.value)?.scale??1)}function X(e){if(e.touches.length!==2||!D.value||U===0)return;e.preventDefault();let t=Math.max(.2,Math.min(6,W*(J(e.touches)/U)));v(`update-sticker`,D.value,{scale:t})}function Z(){U=0,W=1}function Q(){let e=b.value;e&&(e.addEventListener(`touchstart`,Y,{passive:!0}),e.addEventListener(`touchmove`,X,{passive:!1}),e.addEventListener(`touchend`,Z,{passive:!0}))}function ie(){let e=b.value;e&&(e.removeEventListener(`touchstart`,Y),e.removeEventListener(`touchmove`,X),e.removeEventListener(`touchend`,Z))}async function $(){D.value=null,C.value?.getNode()?.nodes([]),await t();let e=S.value?.getNode();if(!e)return;let n=(f.orientation===`landscape`?1600:960)/O.value,r=await e.toBlob({pixelRatio:n,mimeType:`image/jpeg`,quality:.92});r&&v(`done`,r)}return(t,r)=>{let s=i(`v-image`),c=i(`v-layer`),l=i(`v-text`),f=i(`v-transformer`),h=i(`v-stage`);return a(),_(`div`,{class:`sticker-canvas`,ref_key:`containerRef`,ref:b},[p(h,{ref_key:`stageRef`,ref:S,config:ee.value,onClick:z,onTap:z},{default:o(()=>[p(c,null,{default:o(()=>[p(s,{config:F.value},null,8,[`config`])]),_:1}),p(c,{ref_key:`stickerLayerRef`,ref:w},{default:o(()=>[(a(!0),_(g,null,e(n.stickers,e=>(a(),u(l,{key:e.id,config:ne(e),onClick:t=>L(e.id,t),onTap:t=>L(e.id,t),onDragend:t=>V(e.id,t),onTransformend:t=>re(e.id,t)},null,8,[`config`,`onClick`,`onTap`,`onDragend`,`onTransformend`]))),128)),p(f,{ref_key:`transformerRef`,ref:C,config:te},null,512)]),_:1},512)]),_:1},8,[`config`]),D.value?(a(),_(`button`,{key:0,class:`sticker-canvas__delete`,type:`button`,"aria-label":`Remove sticker`,onClick:B},[...r[2]||=[y(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},[y(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),y(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})],-1)]])):d(``,!0),y(`div`,K,[y(`button`,{class:`sticker-canvas__add-btn`,type:`button`,onClick:r[0]||=e=>T.value=!0},[...r[3]||=[y(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`},[y(`circle`,{cx:`12`,cy:`12`,r:`10`}),y(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`16`}),y(`line`,{x1:`8`,y1:`12`,x2:`16`,y2:`12`})],-1),m(` Add sticker `,-1)]]),p(E,{variant:`primary`,class:`sticker-canvas__next-btn`,onClick:$},{default:o(()=>[...r[4]||=[m(`Next`,-1)]]),_:1})]),p(G,{modelValue:T.value,"onUpdate:modelValue":r[1]||=e=>T.value=e,onPick:H},null,8,[`modelValue`])],512)}}}),[[`__scopeId`,`data-v-fb52db70`]]),Y={class:`upload-view`},X={class:`upload-view__header`},Z=[`aria-label`],Q={key:0,width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},ie={key:1,width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`,"aria-hidden":`true`},$={class:`upload-view__step-label`},ae={key:2,class:`upload-view__done`},oe={class:`upload-view__done-title`},se=v(l({__name:`UploadView`,setup(e){let t=w(),r=D(),i=T(),l=S(),g=C(),v=c(`crop`),b=c(!1),x=c(!1),O=null,A=h(()=>r.editingImageId!==null);s(async()=>{if(await i.fetchDevices(),!r.originalFile){t.replace(`/`);return}v.value=`crop`});let j=h(()=>r.contextDeviceId?i.devices.find(e=>e.id===r.contextDeviceId):i.devices[0]),M=h(()=>j.value?.orientation??`landscape`),N=h(()=>r.cropOrientation??M.value),P=h(()=>j.value?.name),ee=h(()=>v.value===`crop`?A.value?`Edit crop`:`Crop photo`:v.value===`stickers`?`Add stickers`:A.value?`Updated`:`Added`);function F({blob:e,params:t,orientation:n}){r.setCrop(e,t,n),v.value=`stickers`}function te(){r.croppedBlob&&(O=r.croppedBlob,A.value?R():x.value=!0)}function ne(e){O=e,A.value?R():x.value=!0}function L(){if(v.value===`crop`){r.cleanup(),t.replace(`/library`);return}v.value===`stickers`&&(v.value=`crop`)}async function R(){if(O){b.value=!0;try{let e=new File([O],`photo.jpg`,{type:`image/jpeg`});if(A.value){await l.reprocessImage(r.editingImageId,e,{cropParams:r.cropParams??void 0,stickerState:r.stickers,cropOrientation:r.cropOrientation??void 0}),x.value=!1,v.value=`done`;return}let t=await l.uploadImage(e,{original:r.originalFile??void 0,cropParams:r.cropParams??void 0,stickerState:r.stickers,cropOrientation:r.cropOrientation??void 0});await Promise.all(r.selectedDeviceIds.map(e=>l.setApproval(t.id,e,!0))),x.value=!1,v.value=`done`}catch(e){g.show(e instanceof Error?e.message:`Upload failed`,`error`)}finally{b.value=!1}}}function z(){r.cleanup(),t.replace(`/library`)}return(e,t)=>(a(),_(`div`,Y,[y(`header`,X,[v.value===`done`?d(``,!0):(a(),_(`button`,{key:0,class:`upload-view__back`,type:`button`,"aria-label":v.value===`crop`?`Cancel`:`Back`,onClick:L},[v.value===`crop`?(a(),_(`svg`,Q,[...t[2]||=[y(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`},null,-1),y(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`},null,-1)]])):(a(),_(`svg`,ie,[...t[3]||=[y(`polyline`,{points:`15 18 9 12 15 6`},null,-1)]]))],8,Z)),y(`span`,$,f(ee.value),1),v.value===`stickers`?(a(),_(`button`,{key:1,class:`upload-view__skip`,type:`button`,onClick:te},`Skip`)):d(``,!0)]),v.value===`crop`&&n(r).originalUrl?(a(),u(I,{key:0,src:n(r).originalUrl,orientation:M.value,"device-name":P.value,"initial-params":n(r).cropParams,"initial-orientation":n(r).cropOrientation,class:`upload-view__stage`,onCrop:F},null,8,[`src`,`orientation`,`device-name`,`initial-params`,`initial-orientation`])):v.value===`stickers`&&n(r).croppedUrl?(a(),u(J,{key:1,"cropped-url":n(r).croppedUrl,orientation:N.value,stickers:n(r).stickers,class:`upload-view__stage`,onAddSticker:n(r).addSticker,onUpdateSticker:n(r).updateSticker,onRemoveSticker:n(r).removeSticker,onDone:ne},null,8,[`cropped-url`,`orientation`,`stickers`,`onAddSticker`,`onUpdateSticker`,`onRemoveSticker`])):v.value===`done`?(a(),_(`div`,ae,[t[5]||=y(`div`,{class:`upload-view__done-icon`,"aria-hidden":`true`},`🎉`,-1),y(`p`,oe,f(A.value?`Photo updated!`:`Photo added!`),1),t[6]||=y(`p`,{class:`upload-view__done-sub`},`It'll appear on your frame at the next update.`,-1),p(E,{variant:`primary`,class:`upload-view__done-btn`,onClick:z},{default:o(()=>[...t[4]||=[m(`Done`,-1)]]),_:1})])):d(``,!0),A.value?d(``,!0):(a(),u(k,{key:3,modelValue:x.value,"onUpdate:modelValue":t[0]||=e=>x.value=e,devices:n(i).devices,selected:n(r).selectedDeviceIds,uploading:b.value,"onUpdate:selected":t[1]||=e=>n(r).selectedDeviceIds=e,onConfirm:R},null,8,[`modelValue`,`devices`,`selected`,`uploading`]))]))}}),[[`__scopeId`,`data-v-af5b9c38`]]);export{se as default}; \ No newline at end of file diff --git a/public/build/assets/index-B5Obd-7x.js b/public/build/assets/index-DabTPrXi.js similarity index 99% rename from public/build/assets/index-B5Obd-7x.js rename to public/build/assets/index-DabTPrXi.js index 109e1db..0e2fb11 100644 --- a/public/build/assets/index-B5Obd-7x.js +++ b/public/build/assets/index-DabTPrXi.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomeView-NFtwfB9R.js","assets/_plugin-vue_export-helper-CeYnMxKK.js","assets/BaseBottomSheet-DohSPmvo.js","assets/BaseBottomSheet-9_gNUOjo.css","assets/PullToRefresh-DZt-0188.js","assets/PullToRefresh-Dh6ArHZZ.css","assets/HomeView-9tP5PwaG.css","assets/LibraryView-D6fwq_vN.js","assets/DevicePicker-BF3g7ETO.js","assets/DevicePicker-B4xrdE2f.css","assets/LibraryView-jkY9po1z.css","assets/UploadView-CjF1nTLf.js","assets/UploadView-CH8tyGyv.css","assets/SettingsView-9KXbjwsG.js","assets/SettingsView-BGXX7ONa.css"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomeView-_Dkprh5_.js","assets/_plugin-vue_export-helper-CeYnMxKK.js","assets/BaseBottomSheet-Y2PW4H1i.js","assets/BaseBottomSheet-9_gNUOjo.css","assets/PullToRefresh-DZt-0188.js","assets/PullToRefresh-Dh6ArHZZ.css","assets/HomeView-Bc2Cp9Ti.css","assets/LibraryView-CiCcJhRw.js","assets/DevicePicker-DcPlHAXI.js","assets/DevicePicker-B4xrdE2f.css","assets/LibraryView-jkY9po1z.css","assets/UploadView-BGpSWlmP.js","assets/UploadView-CH8tyGyv.css","assets/SettingsView-w7VPfpOy.js","assets/SettingsView-BGXX7ONa.css"])))=>i.map(i=>d[i]); import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,O as m,P as h,Q as g,R as _,T as v,U as y,V as b,W as x,X as S,Y as C,Z as w,_ as ee,a as te,at as T,b as E,c as D,ct as ne,d as O,et as re,f as ie,ft as k,g as A,h as j,i as ae,it as oe,k as se,l as M,lt as ce,m as le,n as ue,nt as de,o as fe,ot as pe,p as me,pt as he,q as ge,r as _e,rt as ve,st as ye,t as be,tt as xe,u as Se,ut as Ce,v as we,w as Te,x as Ee,y as De}from"./_plugin-vue_export-helper-CeYnMxKK.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Oe=void 0,ke=typeof window<`u`&&window.trustedTypes;if(ke)try{Oe=ke.createPolicy(`vue`,{createHTML:e=>e})}catch{}var Ae=Oe?e=>Oe.createHTML(e):e=>e,je=`http://www.w3.org/2000/svg`,Me=`http://www.w3.org/1998/Math/MathML`,Ne=typeof document<`u`?document:null,Pe=Ne&&Ne.createElement(`template`),Fe={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{let t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{let i=t===`svg`?Ne.createElementNS(je,e):t===`mathml`?Ne.createElementNS(Me,e):n?Ne.createElement(e,{is:n}):Ne.createElement(e);return e===`select`&&r&&r.multiple!=null&&i.setAttribute(`multiple`,r.multiple),i},createText:e=>Ne.createTextNode(e),createComment:e=>Ne.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Ne.querySelector(e),setScopeId(e,t){e.setAttribute(t,``)},insertStaticContent(e,t,n,r,i,a){let o=n?n.previousSibling:t.lastChild;if(i&&(i===a||i.nextSibling))for(;t.insertBefore(i.cloneNode(!0),n),!(i===a||!(i=i.nextSibling)););else{Pe.innerHTML=Ae(r===`svg`?`${e}`:r===`mathml`?`${e}`:e);let i=Pe.content;if(r===`svg`||r===`mathml`){let e=i.firstChild;for(;e.firstChild;)i.appendChild(e.firstChild);i.removeChild(e)}t.insertBefore(i,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Ie=`transition`,Le=`animation`,Re=Symbol(`_vtc`),ze={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},Be=u({},te,ze),Ve=(e=>(e.displayName=`Transition`,e.props=Be,e))((e,{slots:t})=>E(ae,We(e),t)),He=(e,t=[])=>{g(e)?e.forEach(e=>e(...t)):e&&e(...t)},Ue=e=>e?g(e)?e.some(e=>e.length>1):e.length>1:!1;function We(e){let t={};for(let n in e)n in ze||(t[n]=e[n]);if(e.css===!1)return t;let{name:n=`v`,type:r,duration:i,enterFromClass:a=`${n}-enter-from`,enterActiveClass:o=`${n}-enter-active`,enterToClass:s=`${n}-enter-to`,appearFromClass:c=a,appearActiveClass:l=o,appearToClass:d=s,leaveFromClass:f=`${n}-leave-from`,leaveActiveClass:p=`${n}-leave-active`,leaveToClass:m=`${n}-leave-to`}=e,h=Ge(i),g=h&&h[0],_=h&&h[1],{onBeforeEnter:v,onEnter:y,onEnterCancelled:b,onLeave:x,onLeaveCancelled:S,onBeforeAppear:C=v,onAppear:w=y,onAppearCancelled:ee=b}=t,te=(e,t,n,r)=>{e._enterCancelled=r,Je(e,t?d:s),Je(e,t?l:o),n&&n()},T=(e,t)=>{e._isLeaving=!1,Je(e,f),Je(e,m),Je(e,p),t&&t()},E=e=>(t,n)=>{let i=e?w:y,o=()=>te(t,e,n);He(i,[t,o]),Ye(()=>{Je(t,e?c:a),qe(t,e?d:s),Ue(i)||Ze(t,r,g,o)})};return u(t,{onBeforeEnter(e){He(v,[e]),qe(e,a),qe(e,o)},onBeforeAppear(e){He(C,[e]),qe(e,c),qe(e,l)},onEnter:E(!1),onAppear:E(!0),onLeave(e,t){e._isLeaving=!0;let n=()=>T(e,t);qe(e,f),e._enterCancelled?(qe(e,p),tt(e)):(tt(e),qe(e,p)),Ye(()=>{e._isLeaving&&(Je(e,f),qe(e,m),Ue(x)||Ze(e,r,_,n))}),He(x,[e,n])},onEnterCancelled(e){te(e,!1,void 0,!0),He(b,[e])},onAppearCancelled(e){te(e,!0,void 0,!0),He(ee,[e])},onLeaveCancelled(e){T(e),He(S,[e])}})}function Ge(e){if(e==null)return null;if(xe(e))return[Ke(e.enter),Ke(e.leave)];{let t=Ke(e);return[t,t]}}function Ke(e){return he(e)}function qe(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.add(t)),(e[Re]||(e[Re]=new Set)).add(t)}function Je(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.remove(t));let n=e[Re];n&&(n.delete(t),n.size||(e[Re]=void 0))}function Ye(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}var Xe=0;function Ze(e,t,n,r){let i=e._endId=++Xe,a=()=>{i===e._endId&&r()};if(n!=null)return setTimeout(a,n);let{type:o,timeout:s,propCount:c}=Qe(e,t);if(!o)return r();let l=o+`end`,u=0,d=()=>{e.removeEventListener(l,f),a()},f=t=>{t.target===e&&++u>=c&&d()};setTimeout(()=>{u(n[e]||``).split(`, `),i=r(`${Ie}Delay`),a=r(`${Ie}Duration`),o=$e(i,a),s=r(`${Le}Delay`),c=r(`${Le}Duration`),l=$e(s,c),u=null,d=0,f=0;t===Ie?o>0&&(u=Ie,d=o,f=a.length):t===Le?l>0&&(u=Le,d=l,f=c.length):(d=Math.max(o,l),u=d>0?o>l?Ie:Le:null,f=u?u===Ie?a.length:c.length:0);let p=u===Ie&&/\b(?:transform|all)(?:,|$)/.test(r(`${Ie}Property`).toString());return{type:u,timeout:d,propCount:f,hasTransform:p}}function $e(e,t){for(;e.lengthet(t)+et(e[n])))}function et(e){return e===`auto`?0:Number(e.slice(0,-1).replace(`,`,`.`))*1e3}function tt(e){return(e?e.ownerDocument:document).body.offsetHeight}function nt(e,t,n){let r=e[Re];r&&(t=(t?[t,...r]:[...r]).join(` `)),t==null?e.removeAttribute(`class`):n?e.setAttribute(`class`,t):e.className=t}var rt=Symbol(`_vod`),it=Symbol(`_vsh`),at=Symbol(``),ot=/(?:^|;)\s*display\s*:/;function st(e,t,n){let r=e.style,i=T(n),a=!1;if(n&&!i){if(t)if(T(t))for(let e of t.split(`;`)){let t=e.slice(0,e.indexOf(`:`)).trim();n[t]??lt(r,t,``)}else for(let e in t)n[e]??lt(r,e,``);for(let i in n){i===`display`&&(a=!0);let o=n[i];o==null?lt(r,i,``):pt(e,i,!T(t)&&t?t[i]:void 0,o)||lt(r,i,o)}}else if(i){if(t!==n){let e=r[at];e&&(n+=`;`+e),r.cssText=n,a=ot.test(n)}}else t&&e.removeAttribute(`style`);rt in e&&(e[rt]=a?r.display:``,e[it]&&(r.display=`none`))}var ct=/\s*!important$/;function lt(e,t,n){if(g(n))n.forEach(n=>lt(e,t,n));else if(n??=``,t.startsWith(`--`))e.setProperty(t,n);else{let r=ft(e,t);ct.test(n)?e.setProperty(C(r),n.replace(ct,``),`important`):e[r]=n}}var ut=[`Webkit`,`Moz`,`ms`],dt={};function ft(e,t){let n=dt[t];if(n)return n;let r=d(t);if(r!==`filter`&&r in e)return dt[t]=r;r=ge(r);for(let n=0;nCt||=(wt.then(()=>Ct=0),Date.now());function Et(e,t){let n=e=>{if(!e._vts)e._vts=Date.now();else if(e._vts<=n.attached)return;D(Dt(e,n.value),t,5,[e])};return n.value=e,n.attached=Tt(),n}function Dt(e,t){if(g(t)){let n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(e=>t=>!t._stopped&&e&&e(t))}else return t}var Ot=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,kt=(e,t,n,r,i,a)=>{let o=i===`svg`;t===`class`?nt(e,r,o):t===`style`?st(e,n,r):de(t)?re(t)||bt(e,t,n,r,a):(t[0]===`.`?(t=t.slice(1),!0):t[0]===`^`?(t=t.slice(1),!1):At(e,t,r,o))?(gt(e,t,r),!e.tagName.includes(`-`)&&(t===`value`||t===`checked`||t===`selected`)&&ht(e,t,r,o,a,t!==`value`)):e._isVueCE&&(jt(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!T(r)))?gt(e,d(t),r,a,t):(t===`true-value`?e._trueValue=r:t===`false-value`&&(e._falseValue=r),ht(e,t,r,o))};function At(t,n,r,i){if(i)return!!(n===`innerHTML`||n===`textContent`||n in t&&Ot(n)&&e(r));if(n===`spellcheck`||n===`draggable`||n===`translate`||n===`autocorrect`||n===`sandbox`&&t.tagName===`IFRAME`||n===`form`||n===`list`&&t.tagName===`INPUT`||n===`type`&&t.tagName===`TEXTAREA`)return!1;if(n===`width`||n===`height`){let e=t.tagName;if(e===`IMG`||e===`VIDEO`||e===`CANVAS`||e===`SOURCE`)return!1}return Ot(n)&&T(r)?!1:n in t}function jt(e,t){let n=e._def.props;if(!n)return!1;let r=d(t);return Array.isArray(n)?n.some(e=>d(e)===r):Object.keys(n).some(e=>d(e)===r)}var Mt=new WeakMap,Nt=new WeakMap,Pt=Symbol(`_moveCb`),Ft=Symbol(`_enterCb`),It=(e=>(delete e.props.mode,e))({name:`TransitionGroup`,props:u({},Be,{tag:String,moveClass:String}),setup(e,{slots:t}){let n=we(),r=l(),a,s;return i(()=>{if(!a.length)return;let t=e.moveClass||`${e.name||`v`}-move`;if(!Vt(a[0].el,n.vnode.el,t)){a=[];return}a.forEach(Lt),a.forEach(Rt);let r=a.filter(zt);tt(n.vnode.el),r.forEach(e=>{let n=e.el,r=n.style;qe(n,t),r.transform=r.webkitTransform=r.transitionDuration=``;let i=n[Pt]=e=>{e&&e.target!==n||(!e||e.propertyName.endsWith(`transform`))&&(n.removeEventListener(`transitionend`,i),n[Pt]=null,Je(n,t))};n.addEventListener(`transitionend`,i)}),a=[]}),()=>{let i=x(e),c=We(i),l=i.tag||fe;if(a=[],s)for(let e=0;e{e.split(/\s+/).forEach(e=>e&&r.classList.remove(e))}),n.split(/\s+/).forEach(e=>e&&r.classList.add(e)),r.style.display=`none`;let a=t.nodeType===1?t:t.parentNode;a.appendChild(r);let{hasTransform:o}=Qe(r);return a.removeChild(r),o}var Ht=e=>{let t=e.props[`onUpdate:modelValue`]||!1;return g(t)?e=>w(t,e):t};function Ut(e){e.target.composing=!0}function Wt(e){let t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event(`input`)))}var Gt=Symbol(`_assign`);function Kt(e,t,n){return t&&(e=e.trim()),n&&(e=ce(e)),e}var qt={created(e,{modifiers:{lazy:t,trim:n,number:r}},i){e[Gt]=Ht(i);let a=r||i.props&&i.props.type===`number`;_t(e,t?`change`:`input`,t=>{t.target.composing||e[Gt](Kt(e.value,n,a))}),(n||a)&&_t(e,`change`,()=>{e.value=Kt(e.value,n,a)}),t||(_t(e,`compositionstart`,Ut),_t(e,`compositionend`,Wt),_t(e,`change`,Wt))},mounted(e,{value:t}){e.value=t??``},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Gt]=Ht(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?ce(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Jt={deep:!0,created(e,{value:t,modifiers:{number:n}},i){let a=ve(t);_t(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?ce(Xt(e)):Xt(e));e[Gt](e.multiple?a?new Set(t):t:t[0]),e._assigning=!0,r(()=>{e._assigning=!1})}),e[Gt]=Ht(i)},mounted(e,{value:t}){Yt(e,t)},beforeUpdate(e,t,n){e[Gt]=Ht(n)},updated(e,{value:t}){e._assigning||Yt(e,t)}};function Yt(e,t){let n=e.multiple,r=g(t);if(!(n&&!r&&!ve(t))){for(let i=0,a=e.options.length;iString(e)===String(o)):a.selected=ne(t,o)>-1}else a.selected=t.has(o);else if(ye(Xt(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function Xt(e){return`_value`in e?e._value:e.value}var Zt=[`ctrl`,`shift`,`alt`,`meta`],Qt={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>Zt.some(n=>e[`${n}Key`]&&!t.includes(n))},$t=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=C(n.key);if(t.some(e=>e===r||en[e]===r))return e(n)}))},nn=u({patchProp:kt},Fe),rn;function an(){return rn||=le(nn)}var on=((...t)=>{let n=an().createApp(...t),{mount:r}=n;return n.mount=t=>{let i=cn(t);if(!i)return;let a=n._component;!e(a)&&!a.render&&!a.template&&(a.template=i.innerHTML),i.nodeType===1&&(i.textContent=``);let o=r(i,!1,sn(i));return i instanceof Element&&(i.removeAttribute(`v-cloak`),i.setAttribute(`data-v-app`,``)),o},n});function sn(e){if(e instanceof SVGElement)return`svg`;if(typeof MathMLElement==`function`&&e instanceof MathMLElement)return`mathml`}function cn(e){return T(e)?document.querySelector(e):e}var ln=Math.PI/180;function un(){return typeof window<`u`&&({}.toString.call(window)===`[object Window]`||{}.toString.call(window)===`[object global]`)}var dn=typeof global<`u`?global:typeof window<`u`?window:typeof WorkerGlobalScope<`u`?self:{},N={_global:dn,version:`10.3.0`,isBrowser:un(),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle(e){return N.angleDeg?e*ln:e},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_renderBackend:`web`,legacyTextRendering:!1,pixelRatio:typeof window<`u`&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return N.DD.isDragging},isTransforming(){return N.Transformer?.isTransforming()??!1},isDragReady(){return!!N.DD.node},releaseCanvasOnDestroy:!0,document:dn.document,_injectGlobal(e){dn.Konva!==void 0&&console.error(`Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.`),dn.Konva=e}},P=e=>{N[e.prototype.getClassName()]=e};N._injectGlobal(N);var fn=`Konva.js unsupported environment. Looks like you are trying to use Konva.js in Node.js environment. because "document" object is undefined. @@ -13,4 +13,4 @@ or bash: npm install skia-canvas js: import "konva/skia-backend"; `,pn=()=>{if(typeof document>`u`)throw Error(fn)},mn=class e{constructor(e=[1,0,0,1,0,0]){this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new e(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){let t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.m[0]*t+this.m[2]*n,i=this.m[1]*t+this.m[3]*n,a=this.m[0]*-n+this.m[2]*t,o=this.m[1]*-n+this.m[3]*t;return this.m[0]=r,this.m[1]=i,this.m[2]=a,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){let n=this.m[0]+this.m[2]*t,r=this.m[1]+this.m[3]*t,i=this.m[2]+this.m[0]*e,a=this.m[3]+this.m[1]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=a,this}multiply(e){let t=this.m[0]*e.m[0]+this.m[2]*e.m[1],n=this.m[1]*e.m[0]+this.m[3]*e.m[1],r=this.m[0]*e.m[2]+this.m[2]*e.m[3],i=this.m[1]*e.m[2]+this.m[3]*e.m[3],a=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],o=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}invert(){let e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,n=-this.m[1]*e,r=-this.m[2]*e,i=this.m[0]*e,a=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}getMatrix(){return this.m}decompose(){let e=this.m[0],t=this.m[1],n=this.m[2],r=this.m[3],i=this.m[4],a=this.m[5],o=e*r-t*n,s={x:i,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){let i=Math.sqrt(e*e+t*t);s.rotation=t>0?Math.acos(e/i):-Math.acos(e/i),s.scaleX=i,s.scaleY=o/i,s.skewX=(e*n+t*r)/o,s.skewY=0}else if(n!=0||r!=0){let i=Math.sqrt(n*n+r*r);s.rotation=Math.PI/2-(r>0?Math.acos(-n/i):-Math.acos(n/i)),s.scaleX=o/i,s.scaleY=i,s.skewX=0,s.skewY=(e*n+t*r)/o}return s.rotation=F._getRotation(s.rotation),s}},hn=`[object Array]`,gn=`[object Number]`,_n=`[object String]`,vn=`[object Boolean]`,yn=Math.PI/180,bn=180/Math.PI,xn=`#`,Sn=``,Cn=`0`,wn=`Konva warning: `,Tn=`Konva error: `,En=`rgb(`,Dn={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},On=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,kn=[],An=null,jn=typeof requestAnimationFrame<`u`&&requestAnimationFrame||function(e){setTimeout(e,16)},F={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===hn},_isNumber(e){return Object.prototype.toString.call(e)===gn&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===_n},_isBoolean(e){return Object.prototype.toString.call(e)===vn},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!=`string`)return!1;let t=e[0];return t===`#`||t===`.`||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e){kn.push(e),kn.length===1&&jn(function(){let e=kn;kn=[],e.forEach(function(e){e()})})},createCanvasElement(){pn();let e=document.createElement(`canvas`);try{e.style=e.style||{}}catch{}return e},createImageElement(){return pn(),document.createElement(`img`)},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){let n=F.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(xn,Sn);let t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215<<0).toString(16);for(;e.length<6;)e=Cn+e;return xn+e},isCanvasFarblingActive(){if(An!==null)return An;if(typeof document>`u`)return An=!1,!1;let e=this.createCanvasElement();e.width=10,e.height=10;let t=e.getContext(`2d`,{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle=`#282828`,t.fillRect(0,0,10,10);let n=t.getImageData(0,0,10,10).data,r=!1;for(let e=0;e<100;e++)if(n[e*4]!==40||n[e*4+1]!==40||n[e*4+2]!==40||n[e*4+3]!==255){r=!0;break}return An=r,this.releaseCanvas(e),An},getHitColor(){let e=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(e):e},getHitColorKey(e,t,n){return this.isCanvasFarblingActive()&&(e=Math.round(e/5)*5,t=Math.round(t/5)*5,n=Math.round(n/5)*5),xn+this._rgbToHex(e,t,n)},getSnappedHexColor(e){let t=this._hexToRgb(e);return xn+this._rgbToHex(Math.round(t.r/5)*5,Math.round(t.g/5)*5,Math.round(t.b/5)*5)},getRGB(e){let t;return e in Dn?(t=Dn[e],{r:t[0],g:t[1],b:t[2]}):e[0]===xn?this._hexToRgb(e.substring(1)):e.substr(0,4)===En?(t=On.exec(e.replace(/ /g,``)),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}):{r:0,g:0,b:0}},colorToRGBA(e){return e||=`black`,F._namedColorToRBA(e)||F._hex3ColorToRGBA(e)||F._hex4ColorToRGBA(e)||F._hex6ColorToRGBA(e)||F._hex8ColorToRGBA(e)||F._rgbColorToRGBA(e)||F._rgbaColorToRGBA(e)||F._hslColorToRGBA(e)},_namedColorToRBA(e){let t=Dn[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:1}:null},_rgbColorToRGBA(e){if(e.indexOf(`rgb(`)===0){e=e.match(/rgb\(([^)]+)\)/)[1];let t=e.split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(e.indexOf(`rgba(`)===0){e=e.match(/rgba\(([^)]+)\)/)[1];let t=e.split(/ *, */).map((e,t)=>e.slice(-1)===`%`?t===3?parseInt(e)/100:parseInt(e)/100*255:Number(e));return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if(e[0]===`#`&&e.length===9)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e[0]===`#`&&e.length===7)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e[0]===`#`&&e.length===5)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e[0]===`#`&&e.length===4)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){let[t,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),r=Number(n[0])/360,i=Number(n[1])/100,a=Number(n[2])/100,o,s,c;if(i===0)return c=a*255,{r:Math.round(c),g:Math.round(c),b:Math.round(c),a:1};o=a<.5?a*(1+i):a+i-a*i;let l=2*a-o,u=[0,0,0];for(let e=0;e<3;e++)s=r+1/3*-(e-1),s<0&&s++,s>1&&s--,c=6*s<1?l+(o-l)*6*s:2*s<1?o:3*s<2?l+(o-l)*(2/3-s)*6:l,u[e]=c*255;return{r:Math.round(u[0]),g:Math.round(u[1]),b:Math.round(u[2]),a:1}}},haveIntersection(e,t){return!(t.x>e.x+e.width||t.x+t.widthe.y+e.height||t.y+t.height1?(o=n,s=r,c=(n-i)*(n-i)+(r-a)*(r-a)):(o=e+u*(n-e),s=t+u*(r-t),c=(o-i)*(o-i)+(s-a)*(s-a))}return[o,s,c]},_getProjectionToLine(e,t,n){let r=F.cloneObject(e),i=Number.MAX_VALUE;return t.forEach(function(a,o){if(!n&&o===t.length-1)return;let s=t[(o+1)%t.length],c=F._getProjectionToSegment(a.x,a.y,s.x,s.y,e.x,e.y),l=c[0],u=c[1],d=c[2];dt.length){let n=t;t=e,e=n}for(let t=0;t{e.width=0,e.height=0})},drawRoundedRectPath(e,t,n,r){let i=t<0?t:0,a=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let o=0,s=0,c=0,l=0;typeof r==`number`?o=s=c=l=Math.min(r,t/2,n/2):(o=Math.min(r[0]||0,t/2,n/2),s=Math.min(r[1]||0,t/2,n/2),l=Math.min(r[2]||0,t/2,n/2),c=Math.min(r[3]||0,t/2,n/2)),e.moveTo(i+o,a),e.lineTo(i+t-s,a),e.arc(i+t-s,a+s,s,Math.PI*3/2,0,!1),e.lineTo(i+t,a+n-l),e.arc(i+t-l,a+n-l,l,0,Math.PI/2,!1),e.lineTo(i+c,a+n),e.arc(i+c,a+n-c,c,Math.PI/2,Math.PI,!1),e.lineTo(i,a+o),e.arc(i+o,a+o,o,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,i){r=Math.abs(r);for(let a=0;atypeof e==`number`?Math.floor(e):e)),i+=Pn+c.join(Nn)+Fn)):(i+=o.property,e||(i+=Bn+o.val)),i+=Rn;return i}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=Un&&t.shift()}reset(){let e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){let t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){let t=e.attrs.lineCap;t&&this.setAttr(`lineCap`,t)}_applyOpacity(e){let t=e.getAbsoluteOpacity();t!==1&&this.setAttr(`globalAlpha`,t)}_applyLineJoin(e){let t=e.attrs.lineJoin;t&&this.setAttr(`lineJoin`,t)}_applyMiterLimit(e){let t=e.attrs.miterLimit;t!=null&&this.setAttr(`miterLimit`,t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,i,a){this._context.arc(e,t,n,r,i,a)}arcTo(e,t,n,r,i){this._context.arcTo(e,t,n,r,i)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,i,a){this._context.bezierCurveTo(e,t,n,r,i,a)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){let n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,i,a){return this._context.createRadialGradient(e,t,n,r,i,a)}drawImage(e,t,n,r,i,a,o,s,c){let l=arguments,u=this._context;l.length===3?u.drawImage(e,t,n):l.length===5?u.drawImage(e,t,n,r,i):l.length===9&&u.drawImage(e,t,n,r,i,a,o,s,c)}ellipse(e,t,n,r,i,a,o,s){this._context.ellipse(e,t,n,r,i,a,o,s)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,i){this._context.roundRect(e,t,n,r,i)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):`mozDash`in this._context?this._context.mozDash=e:`webkitLineDash`in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,i,a){this._context.setTransform(e,t,n,r,i,a)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,i,a){this._context.transform(e,t,n,r,i,a)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=Vn.length,n=this.setAttr,r,i,a=function(t){let n=e[t],r;e[t]=function(){return i=Mn(Array.prototype.slice.call(arguments,0)),r=n.apply(e,arguments),e._trace({method:t,args:i}),r}};for(r=0;r{t.dragStatus===`dragging`&&(e=!0)}),e},justDragged:!1,get node(){let e;return I._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){let t=[];I._dragElements.forEach((n,r)=>{let{node:i}=n,a=i.getStage();a.setPointersPositions(e),n.pointerId===void 0&&(n.pointerId=F._getFirstPointerId(e));let o=a._changedPointerPositions.find(e=>e.id===n.pointerId);if(o){if(n.dragStatus!==`dragging`){let t=i.dragDistance();if(Math.max(Math.abs(o.x-n.startPointerPos.x),Math.abs(o.y-n.startPointerPos.y)){t.getStage()&&t.fire(`dragmove`,{type:`dragmove`,target:t,evt:e},!0)})},_endDragBefore(e){let t=[];I._dragElements.forEach(n=>{let{node:r}=n,i=r.getStage();if(e&&i.setPointersPositions(e),!i._changedPointerPositions.find(e=>e.id===n.pointerId))return;(n.dragStatus===`dragging`||n.dragStatus===`stopped`)&&(I.justDragged=!0,N._mouseListenClick=!1,N._touchListenClick=!1,N._pointerListenClick=!1,n.dragStatus=`stopped`);let a=n.node.getLayer()||n.node instanceof N.Stage&&n.node;a&&t.indexOf(a)===-1&&t.push(a)}),t.forEach(e=>{e.draw()})},_endDragAfter(e){I._dragElements.forEach((t,n)=>{t.dragStatus===`stopped`&&t.node.fire(`dragend`,{type:`dragend`,target:t.node,evt:e},!0),t.dragStatus!==`dragging`&&I._dragElements.delete(n)})}};N.isBrowser&&(window.addEventListener(`mouseup`,I._endDragBefore,!0),window.addEventListener(`touchend`,I._endDragBefore,!0),window.addEventListener(`touchcancel`,I._endDragBefore,!0),window.addEventListener(`mousemove`,I._drag),window.addEventListener(`touchmove`,I._drag),window.addEventListener(`mouseup`,I._endDragAfter,!1),window.addEventListener(`touchend`,I._endDragAfter,!1),window.addEventListener(`touchcancel`,I._endDragAfter,!1));function er(e){return F._isString(e)?`"`+e+`"`:Object.prototype.toString.call(e)===`[object Number]`||F._isBoolean(e)?e:Object.prototype.toString.call(e)}function tr(e){return e>255?255:e<0?0:Math.round(e)}function L(){if(N.isUnminified)return function(e,t){return F._isNumber(e)||F.warn(er(e)+` is a not valid value for "`+t+`" attribute. The value should be a number.`),e}}function nr(e){if(N.isUnminified)return function(t,n){let r=F._isNumber(t),i=F._isArray(t)&&t.length==e;return!r&&!i&&F.warn(er(t)+` is a not valid value for "`+n+`" attribute. The value should be a number or Array(`+e+`)`),t}}function rr(){if(N.isUnminified)return function(e,t){return F._isNumber(e)||e===`auto`||F.warn(er(e)+` is a not valid value for "`+t+`" attribute. The value should be a number or "auto".`),e}}function ir(){if(N.isUnminified)return function(e,t){return F._isString(e)||F.warn(er(e)+` is a not valid value for "`+t+`" attribute. The value should be a string.`),e}}function ar(){if(N.isUnminified)return function(e,t){let n=F._isString(e),r=Object.prototype.toString.call(e)===`[object CanvasGradient]`||e&&e.addColorStop;return n||r||F.warn(er(e)+` is a not valid value for "`+t+`" attribute. The value should be a string or a native gradient.`),e}}function or(){if(N.isUnminified)return function(e,t){let n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(F._isArray(e)?e.forEach(function(e){F._isNumber(e)||F.warn(`"`+t+`" attribute has non numeric element `+e+`. Make sure that all elements are numbers.`)}):F.warn(er(e)+` is a not valid value for "`+t+`" attribute. The value should be a array of numbers.`)),e}}function R(){if(N.isUnminified)return function(e,t){return e===!0||e===!1||F.warn(er(e)+` is a not valid value for "`+t+`" attribute. The value should be a boolean.`),e}}function sr(e){if(N.isUnminified)return function(t,n){return t==null||F.isObject(t)||F.warn(er(t)+` is a not valid value for "`+n+`" attribute. The value should be an object with properties `+e),t}}var cr=`get`,lr=`set`,z={addGetterSetter(e,t,n,r,i){z.addGetter(e,t,n),z.addSetter(e,t,r,i),z.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){let r=cr+F._capitalize(t);e.prototype[r]=e.prototype[r]||function(){let e=this.attrs[t];return e===void 0?n:e}},addSetter(e,t,n,r){let i=lr+F._capitalize(t);e.prototype[i]||z.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){let i=lr+F._capitalize(t);e.prototype[i]=function(e){return n&&e!=null&&(e=n.call(this,e,t)),this._setAttr(t,e),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,i){let a=n.length,o=F._capitalize,s=cr+o(t),c=lr+o(t);e.prototype[s]=function(){let e={};for(let r=0;r{this._setAttr(t+o(e),void 0)}),this._fireChangeEvent(t,a,e),i&&i.call(this),this},z.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){let n=F._capitalize(t),r=lr+n,i=cr+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[i]()}},addDeprecatedGetterSetter(e,t,n,r){F.error(`Adding deprecated `+t);let i=cr+F._capitalize(t),a=t+` property is deprecated and will be removed soon. Look at Konva change log for more information.`;e.prototype[i]=function(){F.error(a);let e=this.attrs[t];return e===void 0?n:e},z.addSetter(e,t,r,function(){F.error(a)}),z.addOverloadedGetterSetter(e,t)},backCompat(e,t){F.each(t,function(t,n){let r=e.prototype[n],i=cr+F._capitalize(t),a=lr+F._capitalize(t);function o(){r.apply(this,arguments),F.error(`"`+t+`" method is deprecated and will be removed soon. Use ""`+n+`" instead.`)}e.prototype[t]=o,e.prototype[i]=o,e.prototype[a]=o})},afterSetFilter(){this._filterUpToDate=!1}};function ur(e){let t=/(\w+)\(([^)]+)\)/g,n;for(;(n=t.exec(e))!==null;){let[,e,t]=n;switch(e){case`blur`:{let e=parseFloat(t.replace(`px`,``));return function(t){this.blurRadius(e*.5);let n=N.Filters;n&&n.Blur&&n.Blur.call(this,t)}}case`brightness`:{let e=t.includes(`%`)?parseFloat(t)/100:parseFloat(t);return function(t){this.brightness(e);let n=N.Filters;n&&n.Brightness&&n.Brightness.call(this,t)}}case`contrast`:{let e=parseFloat(t);return function(t){let n=100*(Math.sqrt(e)-1);this.contrast(n);let r=N.Filters;r&&r.Contrast&&r.Contrast.call(this,t)}}case`grayscale`:return function(e){let t=N.Filters;t&&t.Grayscale&&t.Grayscale.call(this,e)};case`sepia`:return function(e){let t=N.Filters;t&&t.Sepia&&t.Sepia.call(this,e)};case`invert`:return function(e){let t=N.Filters;t&&t.Invert&&t.Invert.call(this,e)};default:F.warn(`CSS filter "${e}" is not supported in fallback mode. Consider using function filters for better compatibility.`);break}}return()=>{}}var dr=`absoluteOpacity`,fr=`allEventListeners`,pr=`absoluteTransform`,mr=`absoluteScale`,hr=`canvas`,gr=`Change`,_r=`children`,vr=`konva`,yr=`listening`,br=`mouseenter`,xr=`mouseleave`,Sr=`pointerenter`,Cr=`pointerleave`,wr=`touchenter`,Tr=`touchleave`,Er=`set`,Dr=`Shape`,Or=` `,kr=`stage`,Ar=`transform`,jr=`Stage`,Mr=`visible`,Nr=[`xChange.konva`,`yChange.konva`,`scaleXChange.konva`,`scaleYChange.konva`,`skewXChange.konva`,`skewYChange.konva`,`rotationChange.konva`,`offsetXChange.konva`,`offsetYChange.konva`,`transformsEnabledChange.konva`].join(Or),Pr=1,B=class e{constructor(e){this._id=Pr++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){(e===Ar||e===pr)&&this._cache.get(e)?this._cache.get(e).dirty=!0:e?this._cache.delete(e):this._cache.clear()}_getCache(e,t){let n=this._cache.get(e);return(n===void 0||(e===Ar||e===pr)&&n.dirty===!0)&&(n=t.call(this),this._cache.set(e,n)),n}_calculate(e,t,n){if(!this._attachedDepsListeners.get(e)){let n=t.map(e=>e+`Change.konva`).join(Or);this.on(n,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,n)}_getCanvasCache(){return this._cache.get(hr)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===pr&&this.fire(`absoluteTransformChange`)}clearCache(){if(this._cache.has(hr)){let{scene:e,filter:t,hit:n}=this._cache.get(hr);F.releaseCanvas(e._canvas,t._canvas,n._canvas),this._cache.delete(hr)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){let t=e||{},n={};(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)&&(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let r=Math.ceil(t.width||n.width),i=Math.ceil(t.height||n.height),a=t.pixelRatio,o=t.x===void 0?Math.floor(n.x):t.x,s=t.y===void 0?Math.floor(n.y):t.y,c=t.offset||0,l=t.drawBorder||!1,u=t.hitCanvasPixelRatio||1;if(!r||!i){F.error(`Can not cache the node. Width or height of the node equals 0. Caching is skipped.`);return}let d=+(Math.abs(Math.round(n.x)-o)>.5),f=+(Math.abs(Math.round(n.y)-s)>.5);r+=c*2+d,i+=c*2+f,o-=c,s-=c;let p=new Qn({pixelRatio:a,width:r,height:i}),m=new Qn({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),h=new $n({pixelRatio:u,width:r,height:i}),g=p.getContext(),_=h.getContext(),v=new Qn({width:p.width/p.pixelRatio+Math.abs(o),height:p.height/p.pixelRatio+Math.abs(s),pixelRatio:p.pixelRatio}),y=v.getContext();return h.isCache=!0,p.isCache=!0,this._cache.delete(hr),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(p.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),g.save(),_.save(),y.save(),g.translate(-o,-s),_.translate(-o,-s),y.translate(-o,-s),v.x=o,v.y=s,this._isUnderCache=!0,this._clearSelfAndDescendantCache(dr),this._clearSelfAndDescendantCache(mr),this.drawScene(p,this,v),this.drawHit(h,this),this._isUnderCache=!1,g.restore(),_.restore(),l&&(g.save(),g.beginPath(),g.rect(0,0,r,i),g.closePath(),g.setAttr(`strokeStyle`,`red`),g.setAttr(`lineWidth`,5),g.stroke(),g.restore()),F.releaseCanvas(v._canvas),this._cache.set(hr,{scene:p,filter:m,hit:h,x:o,y:s}),this._requestDraw(),this}isCached(){return this._cache.has(hr)}getClientRect(e){throw Error(`abstract "getClientRect" method call`)}_transformedRect(e,t){let n=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],r=1/0,i=1/0,a=-1/0,o=-1/0,s=this.getAbsoluteTransform(t);return n.forEach(function(e){let t=s.point(e);r===void 0&&(r=a=t.x,i=o=t.y),r=Math.min(r,t.x),i=Math.min(i,t.y),a=Math.max(a,t.x),o=Math.max(o,t.y)}),{x:r,y:i,width:a-r,height:o-i}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);let t=this._getCanvasCache();e.translate(t.x,t.y);let n=this._getCachedSceneCanvas(),r=n.pixelRatio;e.drawImage(n._canvas,0,0,n.width/r,n.height/r),e.restore()}_drawCachedHitCanvas(e){let t=this._getCanvasCache(),n=t.hit;e.save(),e.translate(t.x,t.y),e.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),e.restore()}_getCachedSceneCanvas(){let e=this.filters(),t=this._getCanvasCache(),n=t.scene,r=t.filter,i=r.getContext(),a,o,s,c;if(!e||e.length===0)return n;if(this._filterUpToDate)return r;let l=!0;for(let t=0;t{this.isAncestorOf(e.node)&&I._dragElements.delete(t)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(pr),this._clearSelfAndDescendantCache(dr),this._clearSelfAndDescendantCache(mr),this._clearSelfAndDescendantCache(kr),this._clearSelfAndDescendantCache(Mr),this._clearSelfAndDescendantCache(yr)}_remove(){this._clearCaches();let e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){let t=`get`+F._capitalize(e);return F._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){let e=this.getParent(),t=[];for(;e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{let t,n;if(!e)return this;for(t in e)t!==_r&&(n=Er+F._capitalize(t),F._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(yr,this._isListening)}_isListening(e){if(!this.listening())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isListening(e):!0}isVisible(){return this._getCache(Mr,this._isVisible)}_isVisible(e){if(!this.visible())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isVisible(e):!0}shouldDrawHit(e,t=!1){if(e)return this._isVisible(e)&&this._isListening(e);let n=this.getLayer(),r=!1;I._dragElements.forEach(e=>{e.dragStatus===`dragging`&&(e.node.nodeType===`Stage`||e.node.getLayer()===n)&&(r=!0)});let i=!t&&!N.hitOnDragEnabled&&(r||N.isTransforming());return this.isListening()&&this.isVisible()&&!i}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let e=this.getDepth(),t=this,n=0,r,i,a,o;function s(c){for(r=[],i=c.length,a=0;a0&&r[0].getDepth()<=e&&s(r)}let c=this.getStage();return t.nodeType!==jr&&c&&s(c.getChildren()),n}getDepth(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Ar),this._clearSelfAndDescendantCache(pr)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){let e=this.getStage();if(!e)return null;let t=e.getPointerPosition();if(!t)return null;let n=this.getAbsoluteTransform().copy();return n.invert(),n.point(t)}getAbsolutePosition(e){let t=!1,n=this.parent;for(;n;){if(n.isCached()){t=!0;break}n=n.parent}t&&!e&&(e=!0);let r=this.getAbsoluteTransform(e).getMatrix(),i=new mn,a=this.offset();return i.m=r.slice(),i.translate(a.x,a.y),i.getTranslation()}setAbsolutePosition(e){let{x:t,y:n,...r}=this._clearTransform();this.attrs.x=t,this.attrs.y=n,this._clearCache(Ar);let i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(e.x,e.y),e={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(r),this.setPosition({x:e.x,y:e.y}),this._clearCache(Ar),this._clearSelfAndDescendantCache(pr),this}_setTransform(e){let t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){let e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){let t=e.x,n=e.y,r=this.x(),i=this.y();return t!==void 0&&(r+=t),n!==void 0&&(i+=n),this.setPosition({x:r,y:i}),this}_eachAncestorReverse(e,t){let n=[],r=this.getParent(),i,a;if(!(t&&t._id===this._id)){for(n.unshift(this);r&&(!t||r._id!==t._id);)n.unshift(r),r=r.parent;for(i=n.length,a=0;a0?(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return F.warn(`Node has no parent. moveToBottom function is ignored.`),!1;let e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(e){if(!this.parent)return F.warn(`Node has no parent. zIndex parameter is ignored.`),this;(e<0||e>=this.parent.children.length)&&F.warn(`Unexpected value `+e+` for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to `+(this.parent.children.length-1)+`.`);let t=this.index;return this.parent.children.splice(t,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(dr,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let e=this.opacity(),t=this.getParent();return t&&!t._isUnderCache&&(e*=t.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){let e=this.getAttrs(),t,n,r,i,a,o={attrs:{},className:this.getClassName()};for(t in e)n=e[t],a=F.isObject(n)&&!F._isPlainObject(n)&&!F._isArray(n),!a&&(r=typeof this[t]==`function`&&this[t],delete e[t],i=r?r.call(this):null,e[t]=n,i!==n&&(o.attrs[t]=n));return F._prepareToStringify(o)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,n){let r=[];t&&this._isMatch(e)&&r.push(this);let i=this.parent;for(;i;){if(i===n)return r;i._isMatch(e)&&r.push(i),i=i.parent}return r}isAncestorOf(e){return!1}findAncestor(e,t,n){return this.findAncestors(e,t,n)[0]}_isMatch(e){if(!e)return!1;if(typeof e==`function`)return e(this);let t=e.replace(/ /g,``).split(`,`),n=t.length,r,i;for(r=0;r{try{let n=e?.callback;n&&delete e.callback,F._urlToImage(this.toDataURL(e),function(e){t(e),n?.(e)})}catch(e){n(e)}})}toBlob(e){return new Promise((t,n)=>{try{let n=e?.callback;n&&delete e.callback,this.toCanvas(e).toBlob(e=>{t(e),n?.(e)},e?.mimeType,e?.quality)}catch(e){n(e)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance===void 0?this.parent?this.parent.getDragDistance():N.dragDistance:this.attrs.dragDistance}_off(e,t,n){let r=this.eventListeners[e],i,a,o;for(i=0;i=0)||this.isDragging())return;let t=!1;I._dragElements.forEach(e=>{this.isAncestorOf(e.node)&&(t=!0)}),t||this._createDragElement(e)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;let e=I._dragElements.get(this._id),t=e&&e.dragStatus===`dragging`,n=e&&e.dragStatus===`ready`;t?this.stopDrag():n&&I._dragElements.delete(this._id)}}_dragCleanup(){this.off(`mousedown.konva`),this.off(`touchstart.konva`)}isClientRectOnScreen(e={x:0,y:0}){let t=this.getStage();if(!t)return!1;let n={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return F.haveIntersection(n,this.getClientRect())}static create(e,t){return F._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(t,n){let r=e.prototype.getClassName.call(t),i=t.children,a,o,s;n&&(t.attrs.container=n),N[r]||(F.warn(`Can not find a node with class name "`+r+`". Fallback to "Shape".`),r=`Shape`);let c=N[r];if(a=new c(t.attrs),i)for(o=i.length,s=0;s0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(let t=0;t0?t[0]:void 0}_generalFind(e,t){let n=[];return this._descendants(r=>{let i=r._isMatch(e);return i&&n.push(r),!!(i&&t)}),n}_descendants(e){let t=!1,n=this.getChildren();for(let r of n)if(t=e(r),t||r.hasChildren()&&(t=r._descendants(e),t))return!0;return!1}toObject(){let e=B.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){let t=B.prototype.clone.call(this,e);return this.getChildren().forEach(function(e){t.add(e.clone())}),t}getAllIntersections(e){let t=[];return this.find(`Shape`).forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),!this.isCached()&&((t=this.children)==null||t.forEach(function(t){t._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)==null||e.forEach(function(e,t){e.index=t}),this._requestDraw()}drawScene(e,t,n){let r=this.getLayer(),i=e||r&&r.getCanvas(),a=i&&i.getContext(),o=this._getCanvasCache(),s=o&&o.scene,c=i&&i.isCache;if(!this.isVisible()&&!c)return this;if(s){a.save();let e=this.getAbsoluteTransform(t).getMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(a),a.restore()}else this._drawChildren(`drawScene`,i,t,n);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n&&n.hitCanvas,i=r&&r.getContext(),a=this._getCanvasCache();if(a&&a.hit){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i),i.restore()}else this._drawChildren(`drawHit`,r,t);return this}_drawChildren(e,t,n,r){var i;let a=t&&t.getContext(),o=this.clipWidth(),s=this.clipHeight(),c=this.clipFunc(),l=typeof o==`number`&&typeof s==`number`||c,u=n===this;if(l){a.save();let e=this.getAbsoluteTransform(n),t=e.getMatrix();a.transform(t[0],t[1],t[2],t[3],t[4],t[5]),a.beginPath();let r;if(c)r=c.call(this,a,this);else{let e=this.clipX(),t=this.clipY();a.rect(e||0,t||0,o,s)}a.clip.apply(a,r),t=e.copy().invert().getMatrix(),a.transform(t[0],t[1],t[2],t[3],t[4],t[5])}let d=!u&&this.globalCompositeOperation()!==`source-over`&&e===`drawScene`;d&&(a.save(),a._applyGlobalCompositeOperation(this)),(i=this.children)==null||i.forEach(function(i){i[e](t,n,r)}),d&&a.restore(),l&&a.restore()}getClientRect(e={}){var t;let n=e.skipTransform,r=e.relativeTo,i,a,o,s,c={x:1/0,y:1/0,width:0,height:0},l=this;(t=this.children)==null||t.forEach(function(t){if(!t.visible())return;let n=t.getClientRect({relativeTo:l,skipShadow:e.skipShadow,skipStroke:e.skipStroke});n.width===0&&n.height===0||(i===void 0?(i=n.x,a=n.y,o=n.x+n.width,s=n.y+n.height):(i=Math.min(i,n.x),a=Math.min(a,n.y),o=Math.max(o,n.x+n.width),s=Math.max(s,n.y+n.height)))});let u=this.find(`Shape`),d=!1;for(let e=0;ee.indexOf(`pointer`)>=0?`pointer`:e.indexOf(`touch`)>=0?`touch`:`mouse`,_i=e=>{let t=gi(e);if(t===`pointer`)return N.pointerEventsEnabled&&hi.pointer;if(t===`touch`)return hi.touch;if(t===`mouse`)return hi.mouse};function vi(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&F.warn(`Stage does not support clipping. Please use clip for Layers or Groups.`),e}var yi=`Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);`,bi=[],xi=class extends H{constructor(e){super(vi(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),bi.push(this),this.on(`widthChange.konva heightChange.konva`,this._resizeDOM),this.on(`visibleChange.konva`,this._checkVisibility),this.on(`clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva`,()=>{vi(this.attrs)}),this._checkVisibility()}_validateAdd(e){let t=e.getType()===`Layer`,n=e.getType()===`FastLayer`;t||n||F.throw(`You may only add layers to the stage.`)}_checkVisibility(){if(!this.content)return;let e=this.visible()?``:`none`;this.content.style.display=e}setContainer(e){if(typeof e===Ur){let t;if(e.charAt(0)===`.`){let t=e.slice(1);e=document.getElementsByClassName(t)[0]}else t=e.charAt(0)===`#`?e.slice(1):e,e=document.getElementById(t);if(!e)throw`Can not find container in document with id `+t}return this._setAttr(`container`,e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){let e=this.children,t=e.length;for(let n=0;n-1&&bi.splice(t,1),F.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){let e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(F.warn(yi),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();let t=new Qn({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(t){if(!t.isVisible())return;let r=t._toKonvaCanvas(e);n.drawImage(r._canvas,e.x,e.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())}),t}getIntersection(e){if(!e)return null;let t=this.children,n=t.length-1;for(let r=n;r>=0;r--){let n=t[r].getIntersection(e);if(n)return n}return null}_resizeDOM(){let e=this.width(),t=this.height();this.content&&(this.content.style.width=e+Wr,this.content.style.height=t+Wr),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(n=>{n.setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let e=0;epi&&F.warn(`The stage has `+n+` layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.`),e.setSize({width:this.width(),height:this.height()}),e.draw(),N.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return zr(e,this)}setPointerCapture(e){Br(e,this)}releaseCapture(e){Vr(e,this)}getLayers(){return this.children}_bindContentEvents(){N.isBrowser&&mi.forEach(([e,t])=>{this.content.addEventListener(e,e=>{this[t](e)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);let t=_i(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);let t=_i(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+`targetShape`];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){let t=_i(e.type),n=gi(e.type);if(!t)return;this.setPointersPositions(e);let r=this._getTargetShape(n),i=!(N.isDragging()||N.isTransforming())||N.hitOnDragEnabled;r&&i?(r._fireAndBubble(t.pointerout,{evt:e}),r._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+`targetShape`]=null):i&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(e){let t=_i(e.type),n=gi(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(i=>{let a=this.getIntersection(i);if(I.justDragged=!1,N[`_`+n+`ListenClick`]=!0,!a||!a.isListening()){this[n+`ClickStartShape`]=void 0;return}N.capturePointerEventsEnabled&&a.setPointerCapture(i.id),this[n+`ClickStartShape`]=a,a._fireAndBubble(t.pointerdown,{evt:e,pointerId:i.id}),r=!0;let o=e.type.indexOf(`touch`)>=0;a.preventDefault()&&e.cancelable&&o&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(e){let t=_i(e.type),n=gi(e.type);if(!t)return;let r=e.type.indexOf(`touch`)>=0||e.pointerType===`touch`;if(N.isDragging()&&I.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(N.isDragging()||N.isTransforming())||N.hitOnDragEnabled))return;let i={},a=!1,o=this._getTargetShape(n);this._changedPointerPositions.forEach(r=>{let s=Lr(r.id)||this.getIntersection(r),c=r.id,l={evt:e,pointerId:c},u=o!==s;if(u&&o&&(o._fireAndBubble(t.pointerout,{...l},s),o._fireAndBubble(t.pointerleave,{...l},s)),s){if(i[s._id])return;i[s._id]=!0}s&&s.isListening()?(a=!0,u&&(s._fireAndBubble(t.pointerover,{...l},o),s._fireAndBubble(t.pointerenter,{...l},o),this[n+`targetShape`]=s),s._fireAndBubble(t.pointermove,{...l})):o&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:c}),this[n+`targetShape`]=null)}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){let t=_i(e.type),n=gi(e.type);if(!t)return;this.setPointersPositions(e);let r=this[n+`ClickStartShape`],i=this[n+`ClickEndShape`],a={},o=!1;this._changedPointerPositions.forEach(s=>{let c=Lr(s.id)||this.getIntersection(s);if(c){if(c.releaseCapture(s.id),a[c._id])return;a[c._id]=!0}let l=s.id,u={evt:e,pointerId:l},d=!1;N[`_`+n+`InDblClickWindow`]?(d=!0,clearTimeout(this[n+`DblTimeout`])):I.justDragged||(N[`_`+n+`InDblClickWindow`]=!0,clearTimeout(this[n+`DblTimeout`])),this[n+`DblTimeout`]=setTimeout(function(){N[`_`+n+`InDblClickWindow`]=!1},N.dblClickWindow),c&&c.isListening()?(o=!0,this[n+`ClickEndShape`]=c,c._fireAndBubble(t.pointerup,{...u}),N[`_`+n+`ListenClick`]&&r&&r===c&&(c._fireAndBubble(t.pointerclick,{...u}),d&&i&&i===c&&c._fireAndBubble(t.pointerdblclick,{...u}))):(this[n+`ClickEndShape`]=null,o||=(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),!0),N[`_`+n+`ListenClick`]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:l}),d&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:l}))}),o||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),N[`_`+n+`ListenClick`]=!1,e.cancelable&&n!==`touch`&&n!==`pointer`&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(si,{evt:e}):this._fire(si,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(fi,{evt:e}):this._fire(fi,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);let t=Lr(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(ei,Rr(e)),Vr(e.pointerId)}_lostpointercapture(e){Vr(e.pointerId)}setPointersPositions(e){let t=this._getContentPosition(),n=null,r=null;e||=window.event,e.touches===void 0?(n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:F._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:F._getFirstPointerId(e)}]):(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,e=>{this._pointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,e=>{this._changedPointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}))}_setPointerPosition(e){F.warn(`Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.`),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};let e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new Qn({width:this.width(),height:this.height()}),this.bufferHitCanvas=new $n({pixelRatio:1,width:this.width(),height:this.height()}),!N.isBrowser)return;let e=this.container();if(!e)throw`Stage has no container. A container is required.`;e.innerHTML=``,this.content=document.createElement(`div`),this.content.style.position=`relative`,this.content.style.userSelect=`none`,this.content.className=`konvajs-content`,this.content.setAttribute(`role`,`presentation`),e.appendChild(this.content),this._resizeDOM()}cache(){return F.warn(`Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.`),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}};xi.prototype.nodeType=Hr,P(xi),z.addGetterSetter(xi,`container`),N.isBrowser&&document.addEventListener(`visibilitychange`,()=>{bi.forEach(e=>{e.batchDraw()})});var Si=`hasShadow`,Ci=`shadowRGBA`,wi=`patternImage`,Ti=`linearGradient`,Ei=`radialGradient`,Di;function Oi(){return Di||(Di=F.createCanvasElement().getContext(`2d`),Di)}var ki={};function Ai(e){let t=this.attrs.fillRule;t?e.fill(t):e.fill()}function ji(e){e.stroke()}function Mi(e){let t=this.attrs.fillRule;t?e.fill(t):e.fill()}function Ni(e){e.stroke()}function Pi(){this._clearCache(Si)}function Fi(){this._clearCache(Ci)}function Ii(){this._clearCache(wi)}function Li(){this._clearCache(Ti)}function Ri(){this._clearCache(Ei)}var U=class extends B{constructor(e){super(e);let t,n=0;for(;t=F.getHitColor(),!(t&&!(t in ki));)if(n++,n>=1e4){F.warn(`Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it.`),t=F.getRandomColor();break}this.colorKey=t,ki[t]=this}getContext(){return F.warn(`shape.getContext() method is deprecated. Please do not use it.`),this.getLayer().getContext()}getCanvas(){return F.warn(`shape.getCanvas() method is deprecated. Please do not use it.`),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(Si,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(wi,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){let e=Oi().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||`repeat`);if(e&&e.setTransform){let t=new mn;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(N.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());let n=t.getMatrix(),r=typeof DOMMatrix>`u`?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(Ti,this.__getLinearGradient)}__getLinearGradient(){let e=this.fillLinearGradientColorStops();if(e){let t=Oi(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),i=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let t=0;tthis.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate(`hasStroke`,[`strokeEnabled`,`strokeWidth`,`stroke`,`strokeLinearGradientColorStops`],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){let e=this.hitStrokeWidth();return e===`auto`?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){let t=this.getStage();if(!t)return!1;let n=t.bufferHitCanvas;return n.getContext().clear(),this.drawHit(n,void 0,!0),n.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return B.prototype.destroy.call(this),delete ki[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){if(!(this.attrs.perfectDrawEnabled??!0))return!1;let t=e||this.hasFill(),n=this.hasStroke(),r=this.getAbsoluteOpacity()!==1;if(t&&n&&r)return!0;let i=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(t&&n&&i&&a)}setStrokeHitEnabled(e){F.warn(`strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.`),e?this.hitStrokeWidth(`auto`):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){let e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){let t=!1,n=this.getParent();for(;n;){if(n.isCached()){t=!0;break}n=n.getParent()}let r=e.skipTransform,i=e.relativeTo||t&&this.getStage()||void 0,a=this.getSelfRect(),o=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,s=a.width+o,c=a.height+o,l=!e.skipShadow&&this.hasShadow(),u=l?this.shadowOffsetX():0,d=l?this.shadowOffsetY():0,f=s+Math.abs(u),p=c+Math.abs(d),m=l&&this.shadowBlur()||0,h={width:f+m*2,height:p+m*2,x:-(o/2+m)+Math.min(u,0)+a.x,y:-(o/2+m)+Math.min(d,0)+a.y};return r?h:this._transformedRect(h,i)}drawScene(e,t,n){let r=this.getLayer(),i=(e||r.getCanvas()).getContext(),a=this._getCanvasCache(),o=this.getSceneFunc(),s=this.hasShadow(),c,l=t===this;if(!this.isVisible()&&!l)return this;if(a){i.save();let e=this.getAbsoluteTransform(t).getMatrix();return i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(i),i.restore(),this}if(!o)return this;if(i.save(),this._useBufferCanvas()){c=this.getStage();let e=n||c.bufferCanvas,r=e.getContext();n?(r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e.width,e.height),r.restore()):r.clear(),r.save(),r._applyLineJoin(this),r._applyMiterLimit(this);let a=this.getAbsoluteTransform(t).getMatrix();r.transform(a[0],a[1],a[2],a[3],a[4],a[5]),o.call(this,r,this),r.restore();let u=e.pixelRatio;s&&i._applyShadow(this),l||(i._applyOpacity(this),i._applyGlobalCompositeOperation(this)),i.drawImage(e._canvas,e.x||0,e.y||0,e.width/u,e.height/u)}else{if(i._applyLineJoin(this),i._applyMiterLimit(this),!l){let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),i._applyOpacity(this),i._applyGlobalCompositeOperation(this)}s&&i._applyShadow(this),o.call(this,i,this)}return i.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;let r=this.getLayer(),i=e||r.hitCanvas,a=i&&i.getContext(),o=this.hitFunc()||this.sceneFunc(),s=this._getCanvasCache(),c=s&&s.hit;if(this.colorKey||F.warn(`Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()`),c){a.save();let e=this.getAbsoluteTransform(t).getMatrix();return a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!o)return this;if(a.save(),a._applyLineJoin(this),a._applyMiterLimit(this),this!==t){let e=this.getAbsoluteTransform(t).getMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5])}return o.call(this,a,this),a.restore(),this}drawHitFromCache(e=0){let t=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=t.hit,i=r.getContext(),a=r.getWidth(),o=r.getHeight();i.clear(),i.drawImage(n._canvas,0,0,a,o);try{let t=i.getImageData(0,0,a,o),n=t.data,r=n.length,s=F._hexToRgb(this.colorKey);for(let t=0;te?(n[t]=s.r,n[t+1]=s.g,n[t+2]=s.b,n[t+3]=255):n[t+3]=0;i.putImageData(t,0,0)}catch(e){F.error(`Unable to draw hit graph from cached scene canvas. `+e.message)}return this}hasPointerCapture(e){return zr(e,this)}setPointerCapture(e){Br(e,this)}releaseCapture(e){Vr(e,this)}};U.prototype._fillFunc=Ai,U.prototype._strokeFunc=ji,U.prototype._fillFuncHit=Mi,U.prototype._strokeFuncHit=Ni,U.prototype._centroid=!1,U.prototype.nodeType=`Shape`,P(U),U.prototype.eventListeners={},U.prototype.on(`shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,Pi),U.prototype.on(`shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,Fi),U.prototype.on(`fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva`,Ii),U.prototype.on(`fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva`,Li),U.prototype.on(`fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva`,Ri),z.addGetterSetter(U,`stroke`,void 0,ar()),z.addGetterSetter(U,`strokeWidth`,2,L()),z.addGetterSetter(U,`fillAfterStrokeEnabled`,!1),z.addGetterSetter(U,`hitStrokeWidth`,`auto`,rr()),z.addGetterSetter(U,`strokeHitEnabled`,!0,R()),z.addGetterSetter(U,`perfectDrawEnabled`,!0,R()),z.addGetterSetter(U,`shadowForStrokeEnabled`,!0,R()),z.addGetterSetter(U,`lineJoin`),z.addGetterSetter(U,`lineCap`),z.addGetterSetter(U,`miterLimit`),z.addGetterSetter(U,`sceneFunc`),z.addGetterSetter(U,`hitFunc`),z.addGetterSetter(U,`dash`),z.addGetterSetter(U,`dashOffset`,0,L()),z.addGetterSetter(U,`shadowColor`,void 0,ir()),z.addGetterSetter(U,`shadowBlur`,0,L()),z.addGetterSetter(U,`shadowOpacity`,1,L()),z.addComponentsGetterSetter(U,`shadowOffset`,[`x`,`y`]),z.addGetterSetter(U,`shadowOffsetX`,0,L()),z.addGetterSetter(U,`shadowOffsetY`,0,L()),z.addGetterSetter(U,`fillPatternImage`),z.addGetterSetter(U,`fill`,void 0,ar()),z.addGetterSetter(U,`fillPatternX`,0,L()),z.addGetterSetter(U,`fillPatternY`,0,L()),z.addGetterSetter(U,`fillLinearGradientColorStops`),z.addGetterSetter(U,`strokeLinearGradientColorStops`),z.addGetterSetter(U,`fillRadialGradientStartRadius`,0),z.addGetterSetter(U,`fillRadialGradientEndRadius`,0),z.addGetterSetter(U,`fillRadialGradientColorStops`),z.addGetterSetter(U,`fillPatternRepeat`,`repeat`),z.addGetterSetter(U,`fillEnabled`,!0),z.addGetterSetter(U,`strokeEnabled`,!0),z.addGetterSetter(U,`shadowEnabled`,!0),z.addGetterSetter(U,`dashEnabled`,!0),z.addGetterSetter(U,`strokeScaleEnabled`,!0),z.addGetterSetter(U,`fillPriority`,`color`),z.addComponentsGetterSetter(U,`fillPatternOffset`,[`x`,`y`]),z.addGetterSetter(U,`fillPatternOffsetX`,0,L()),z.addGetterSetter(U,`fillPatternOffsetY`,0,L()),z.addComponentsGetterSetter(U,`fillPatternScale`,[`x`,`y`]),z.addGetterSetter(U,`fillPatternScaleX`,1,L()),z.addGetterSetter(U,`fillPatternScaleY`,1,L()),z.addComponentsGetterSetter(U,`fillLinearGradientStartPoint`,[`x`,`y`]),z.addComponentsGetterSetter(U,`strokeLinearGradientStartPoint`,[`x`,`y`]),z.addGetterSetter(U,`fillLinearGradientStartPointX`,0),z.addGetterSetter(U,`strokeLinearGradientStartPointX`,0),z.addGetterSetter(U,`fillLinearGradientStartPointY`,0),z.addGetterSetter(U,`strokeLinearGradientStartPointY`,0),z.addComponentsGetterSetter(U,`fillLinearGradientEndPoint`,[`x`,`y`]),z.addComponentsGetterSetter(U,`strokeLinearGradientEndPoint`,[`x`,`y`]),z.addGetterSetter(U,`fillLinearGradientEndPointX`,0),z.addGetterSetter(U,`strokeLinearGradientEndPointX`,0),z.addGetterSetter(U,`fillLinearGradientEndPointY`,0),z.addGetterSetter(U,`strokeLinearGradientEndPointY`,0),z.addComponentsGetterSetter(U,`fillRadialGradientStartPoint`,[`x`,`y`]),z.addGetterSetter(U,`fillRadialGradientStartPointX`,0),z.addGetterSetter(U,`fillRadialGradientStartPointY`,0),z.addComponentsGetterSetter(U,`fillRadialGradientEndPoint`,[`x`,`y`]),z.addGetterSetter(U,`fillRadialGradientEndPointX`,0),z.addGetterSetter(U,`fillRadialGradientEndPointY`,0),z.addGetterSetter(U,`fillPatternRotation`,0),z.addGetterSetter(U,`fillRule`,void 0,ir()),z.backCompat(U,{dashArray:`dash`,getDashArray:`getDash`,setDashArray:`getDash`,drawFunc:`sceneFunc`,getDrawFunc:`getSceneFunc`,setDrawFunc:`setSceneFunc`,drawHitFunc:`hitFunc`,getDrawHitFunc:`getHitFunc`,setDrawHitFunc:`setHitFunc`});var zi=`beforeDraw`,Bi=`draw`,Vi=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],Hi=Vi.length,Ui=class extends H{constructor(e){super(e),this.canvas=new Qn,this.hitCanvas=new $n({pixelRatio:1}),this._waitingForDraw=!1,this.on(`visibleChange.konva`,this._checkVisibility),this._checkVisibility(),this.on(`imageSmoothingEnabledChange.konva`,this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);let t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=1,n=!1;for(;;){for(let r=0;r0)return{antialiased:!0};return{}}drawScene(e,t,n){let r=this.getLayer(),i=e||r&&r.getCanvas();return this._fire(zi,{node:this}),this.clearBeforeDraw()&&i.getContext().clear(),H.prototype.drawScene.call(this,i,t,n),this._fire(Bi,{node:this}),this}drawHit(e,t){let n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),H.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){F.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening(e)}getHitGraphEnabled(e){return F.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;let e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return F.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};Ui.prototype.nodeType=`Layer`,P(Ui),z.addGetterSetter(Ui,`imageSmoothingEnabled`,!0),z.addGetterSetter(Ui,`clearBeforeDraw`,!0),z.addGetterSetter(Ui,`hitGraphEnabled`,!0,R());var Wi=class extends Ui{constructor(e){super(e),this.listening(!1),F.warn(`Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.`)}};Wi.prototype.nodeType=`FastLayer`,P(Wi);var Gi=class extends H{_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&F.throw(`You may only add groups and shapes to groups.`)}};Gi.prototype.nodeType=`Group`,P(Gi);var Ki=(function(){return dn.performance&&dn.performance.now?function(){return dn.performance.now()}:function(){return new Date().getTime()}})(),qi=class e{constructor(t,n){this.id=e.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Ki(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(e){let t=[];return e&&(t=Array.isArray(e)?e:[e]),this.layers=t,this}getLayers(){return this.layers}addLayer(e){let t=this.layers,n=t.length;for(let r=0;rthis.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=Xi,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire(`onPlay`)}reverse(){this.state=Zi,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire(`onReverse`)}seek(e){this.pause(),this._time=e,this.update(),this.fire(`onSeek`)}reset(){this.pause(),this._time=0,this.update(),this.fire(`onReset`)}finish(){this.pause(),this._time=this.duration,this.update(),this.fire(`onFinish`)}update(){this.setPosition(this.getPosition(this._time)),this.fire(`onUpdate`)}onEnterFrame(){let e=this.getTimer()-this._startTime;this.state===Xi?this.setTime(e):this.state===Zi&&this.setTime(this.duration-e)}pause(){this.state=Yi,this.fire(`onPause`)}getTimer(){return new Date().getTime()}},ta=class e{constructor(t){let n=this,r=t.node,i=r._id,a=t.easing||na.Linear,o=!!t.yoyo,s,c;s=t.duration===void 0?.3:t.duration===0?.001:t.duration,this.node=r,this._id=$i++;let l=r.getLayer()||(r instanceof N.Stage?r.getLayers():null);for(c in l||F.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new qi(function(){n.tween.onEnterFrame()},l),this.tween=new ea(c,function(e){n._tweenFunc(e)},a,0,1,s*1e3,o),this._addListeners(),e.attrs[i]||(e.attrs[i]={}),e.attrs[i][this._id]||(e.attrs[i][this._id]={}),e.tweens[i]||(e.tweens[i]={}),t)Ji[c]===void 0&&this._addAttr(c,t[c]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){let r=this.node,i=r._id,a,o,s,c,l,u=e.tweens[i][t];u&&delete e.attrs[i][u][t];let d=r.getAttr(t);if(F._isArray(n))if(a=[],o=Math.max(n.length,d.length),t===`points`&&n.length!==d.length&&(n.length>d.length?(c=d,d=F._prepareArrayForTween(d,n,r.closed())):(s=n,n=F._prepareArrayForTween(n,d,r.closed()))),t.indexOf(`fill`)===0)for(let e=0;e{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{let t=this.node,n=e.attrs[t._id][this._id];n.points&&n.points.trueEnd&&t.setAttr(`points`,n.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{let t=this.node,n=e.attrs[t._id][this._id];n.points&&n.points.trueStart&&t.points(n.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(e*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){let t=this.node._id,n=this._id,r=e.tweens[t];this.pause(),this.anim&&this.anim.stop();for(let n in r)delete e.tweens[t][n];delete e.attrs[t][n],e.tweens[t]&&(Object.keys(e.tweens[t]).length===0&&delete e.tweens[t],Object.keys(e.attrs[t]).length===0&&delete e.attrs[t])}};ta.attrs={},ta.tweens={},B.prototype.to=function(e){let t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new ta(e).play()};var na={BackEaseIn(e,t,n,r){let i=1.70158;return n*(e/=r)*e*((i+1)*e-i)+t},BackEaseOut(e,t,n,r){let i=1.70158;return n*((e=e/r-1)*e*((i+1)*e+i)+1)+t},BackEaseInOut(e,t,n,r){let i=1.70158;return(e/=r/2)<1?n/2*(e*e*(((i*=1.525)+1)*e-i))+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t},ElasticEaseIn(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,!i||i0?e:t),c=1*t,l=a*(a>0?e:t),u=o*(o>0?t:e);return{x:s,y:n?-1*u:l,width:c-s,height:u-l}}};ia.prototype._centroid=!0,ia.prototype.className=`Arc`,ia.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`,`angle`,`clockwise`],P(ia),z.addGetterSetter(ia,`innerRadius`,0,L()),z.addGetterSetter(ia,`outerRadius`,0,L()),z.addGetterSetter(ia,`angle`,0,L()),z.addGetterSetter(ia,`clockwise`,!1,R());function aa(e,t,n,r,i,a,o){let s=Math.sqrt((n-e)**2+(r-t)**2),c=Math.sqrt((i-n)**2+(a-r)**2),l=o*s/(s+c),u=o*c/(s+c);return[n-l*(i-e),r-l*(a-t),n+u*(i-e),r+u*(a-t)]}function oa(e,t){let n=e.length,r=[];for(let i=2;i=0){let e=Math.sqrt(a);n.push((-r+e)/(2*t)),n.push((-r-e)/(2*t))}}}return n.filter(e=>e>0&&e<1).flatMap(e=>t.map(t=>{let n=1-e;return n*n*n*t[0]+3*n*n*e*t[1]+3*n*e*e*t[2]+e*e*e*t[3]}))}var ca=class extends U{constructor(e){super(e),this.on(`pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva`,function(){this._clearCache(`tensionPoints`)})}_sceneFunc(e){let t=this.points(),n=t.length,r=this.tension(),i=this.closed(),a=this.bezier();if(!n)return;let o=0;if(e.beginPath(),e.moveTo(t[0],t[1]),r!==0&&n>4){let r=this.getTensionPoints(),a=r.length;for(o=i?0:4,i||e.quadraticCurveTo(r[0],r[1],r[2],r[3]);o{let r,i,a=n/2;r=0;for(let n=0;n<20;n++)i=a*la[20][n]+a,r+=ua[20][n]*ma(e,t,i);return a*r},pa=(e,t,n)=>{n===void 0&&(n=1);let r=e[0]-2*e[1]+e[2],i=t[0]-2*t[1]+t[2],a=2*e[1]-2*e[0],o=2*t[1]-2*t[0],s=4*(r*r+i*i),c=4*(r*a+i*o),l=a*a+o*o;if(s===0)return n*Math.sqrt((e[2]-e[0])**2+(t[2]-t[0])**2);let u=c/(2*s),d=l/s,f=n+u,p=d-u*u,m=f*f+p>0?Math.sqrt(f*f+p):0,h=u*u+p>0?Math.sqrt(u*u+p):0,g=u+Math.sqrt(u*u+p)===0?0:p*Math.log(Math.abs((f+m)/(u+h)));return Math.sqrt(s)/2*(f*m-u*h+g)};function ma(e,t,n){let r=ha(1,n,e),i=ha(1,n,t),a=r*r+i*i;return Math.sqrt(a)}var ha=(e,t,n)=>{let r=n.length-1,i,a;if(r===0)return 0;if(e===0){a=0;for(let e=0;e<=r;e++)a+=da[r][e]*(1-t)**(r-e)*t**+e*n[e];return a}else{i=Array(r);for(let e=0;e{let r=1,i=e/t,a=(e-n(i))/t,o=0;for(;r>.001;){let s=n(i+a),c=Math.abs(e-s)/t;if(c500)break}return i},W=class e extends U{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on(`dataChange.konva`,function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=e.parsePathData(this.data()),this.pathLength=e.getPathLength(this.dataArray)}_sceneFunc(e){let t=this.dataArray;e.beginPath();let n=!1;for(let r=0;ro?i:o,f=i>o?1:i/o,p=i>o?o/i:1;e.translate(t,r),e.rotate(l),e.scale(f,p),e.arc(0,0,d,s,s+c,1-u),e.scale(1/f,1/p),e.rotate(-l),e.translate(-t,-r);break;case`z`:n=!0,e.closePath();break}}!n&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(n){if(n.command===`A`){let r=n.points[4],i=n.points[5],a=n.points[4]+i,o=Math.PI/180;if(Math.abs(r-a)a;i-=o){let r=e.getPointOnEllipticalArc(n.points[0],n.points[1],n.points[2],n.points[3],i,0);t.push(r.x,r.y)}else for(let i=r+o;in[i].pathLength;)t-=n[i].pathLength,++i;if(i===a)return r=n[i-1].points.slice(-2),{x:r[0],y:r[1]};if(t<.01)return n[i].command===`M`?(r=n[i].points.slice(0,2),{x:r[0],y:r[1]}):{x:n[i].start.x,y:n[i].start.y};let o=n[i],s=o.points;switch(o.command){case`L`:return e.getPointOnLine(t,o.start.x,o.start.y,s[0],s[1]);case`C`:return e.getPointOnCubicBezier(ga(t,e.getPathLength(n),e=>fa([o.start.x,s[0],s[2],s[4]],[o.start.y,s[1],s[3],s[5]],e)),o.start.x,o.start.y,s[0],s[1],s[2],s[3],s[4],s[5]);case`Q`:return e.getPointOnQuadraticBezier(ga(t,e.getPathLength(n),e=>pa([o.start.x,s[0],s[2]],[o.start.y,s[1],s[3]],e)),o.start.x,o.start.y,s[0],s[1],s[2],s[3]);case`A`:let r=s[0],i=s[1],a=s[2],c=s[3],l=s[5],u=s[6],d=s[4];return d+=l*t/o.pathLength,e.getPointOnEllipticalArc(r,i,a,c,d,u)}return null}static getPointOnLine(e,t,n,r,i,a,o){a??=t,o??=n;let s=this.getLineLength(t,n,r,i);if(s<1e-10)return{x:t,y:n};if(r===t)return{x:a,y:o+(i>n?e:-e)};let c=(i-n)/(r-t),l=Math.sqrt(e*e/(1+c*c))*(r=0&&(d+=2,d>=7&&(d-=7));continue}if(d>=0){if(d===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(t)){u.push(parseInt(t[0],10)),u.push(parseInt(t[1],10)),u.push(parseFloat(t.slice(2))),d+=3,d>=7&&(d-=7);continue}if(t===`11`||t===`10`||t===`01`){u.push(parseInt(t[0],10)),u.push(parseInt(t[1],10)),d+=2,d>=7&&(d-=7);continue}if(t===`0`||t===`1`){u.push(parseInt(t,10)),d+=1,d>=7&&(d-=7);continue}}else if(d===4){if(/^[01]\d+(?:\.\d+)?$/.test(t)){u.push(parseInt(t[0],10)),u.push(parseFloat(t.slice(1))),d+=2,d>=7&&(d-=7);continue}if(t===`0`||t===`1`){u.push(parseInt(t,10)),d+=1,d>=7&&(d-=7);continue}}let e=parseFloat(t);isNaN(e)?u.push(0):u.push(e),d+=1,d>=7&&(d-=7)}else{let e=parseFloat(t);isNaN(e)?u.push(0):u.push(e)}}for(;u.length>0&&!isNaN(u[0]);){let e=``,t=[],r=o,a=s,c,l,d,f,p,m,h,g,_,v;switch(n){case`l`:o+=u.shift(),s+=u.shift(),e=`L`,t.push(o,s);break;case`L`:o=u.shift(),s=u.shift(),t.push(o,s);break;case`m`:let r=u.shift(),a=u.shift();if(o+=r,s+=a,e=`M`,i.length>2&&i[i.length-1].command===`z`){for(let e=i.length-2;e>=0;e--)if(i[e].command===`M`){o=i[e].points[0]+r,s=i[e].points[1]+a;break}}t.push(o,s),n=`l`;break;case`M`:o=u.shift(),s=u.shift(),e=`M`,t.push(o,s),n=`L`;break;case`h`:o+=u.shift(),e=`L`,t.push(o,s);break;case`H`:o=u.shift(),e=`L`,t.push(o,s);break;case`v`:s+=u.shift(),e=`L`,t.push(o,s);break;case`V`:s=u.shift(),e=`L`,t.push(o,s);break;case`C`:t.push(u.shift(),u.shift(),u.shift(),u.shift()),o=u.shift(),s=u.shift(),t.push(o,s);break;case`c`:t.push(o+u.shift(),s+u.shift(),o+u.shift(),s+u.shift()),o+=u.shift(),s+=u.shift(),e=`C`,t.push(o,s);break;case`S`:l=o,d=s,c=i[i.length-1],c.command===`C`&&(l=o+(o-c.points[2]),d=s+(s-c.points[3])),t.push(l,d,u.shift(),u.shift()),o=u.shift(),s=u.shift(),e=`C`,t.push(o,s);break;case`s`:l=o,d=s,c=i[i.length-1],c.command===`C`&&(l=o+(o-c.points[2]),d=s+(s-c.points[3])),t.push(l,d,o+u.shift(),s+u.shift()),o+=u.shift(),s+=u.shift(),e=`C`,t.push(o,s);break;case`Q`:t.push(u.shift(),u.shift()),o=u.shift(),s=u.shift(),t.push(o,s);break;case`q`:t.push(o+u.shift(),s+u.shift()),o+=u.shift(),s+=u.shift(),e=`Q`,t.push(o,s);break;case`T`:l=o,d=s,c=i[i.length-1],c.command===`Q`&&(l=o+(o-c.points[0]),d=s+(s-c.points[1])),o=u.shift(),s=u.shift(),e=`Q`,t.push(l,d,o,s);break;case`t`:l=o,d=s,c=i[i.length-1],c.command===`Q`&&(l=o+(o-c.points[0]),d=s+(s-c.points[1])),o+=u.shift(),s+=u.shift(),e=`Q`,t.push(l,d,o,s);break;case`A`:f=u.shift(),p=u.shift(),m=u.shift(),h=u.shift(),g=u.shift(),_=o,v=s,o=u.shift(),s=u.shift(),e=`A`,t=this.convertEndpointToCenterParameterization(_,v,o,s,h,g,f,p,m);break;case`a`:f=u.shift(),p=u.shift(),m=u.shift(),h=u.shift(),g=u.shift(),_=o,v=s,o+=u.shift(),s+=u.shift(),e=`A`,t=this.convertEndpointToCenterParameterization(_,v,o,s,h,g,f,p,m);break}i.push({command:e||n,points:t,start:{x:r,y:a},pathLength:this.calcLength(r,a,e||n,t)})}(n===`z`||n===`Z`)&&i.push({command:`z`,points:[],start:void 0,pathLength:0})}return i}static calcLength(t,n,r,i){let a,o,s,c,l=e;switch(r){case`L`:return l.getLineLength(t,n,i[0],i[1]);case`C`:return fa([t,i[0],i[2],i[4]],[n,i[1],i[3],i[5]],1);case`Q`:return pa([t,i[0],i[2]],[n,i[1],i[3]],1);case`A`:a=0;let e=i[4],r=i[5],u=i[4]+r,d=Math.PI/180;if(Math.abs(e-u)u;c-=d)s=l.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],c,0),a+=l.getLineLength(o.x,o.y,s.x,s.y),o=s;else for(c=e+d;c1&&(o*=Math.sqrt(f),s*=Math.sqrt(f));let p=Math.sqrt((o*o*(s*s)-o*o*(d*d)-s*s*(u*u))/(o*o*(d*d)+s*s*(u*u)));i===a&&(p*=-1),isNaN(p)&&(p=0);let m=p*o*d/s,h=p*-s*u/o,g=(e+n)/2+Math.cos(l)*m-Math.sin(l)*h,_=(t+r)/2+Math.sin(l)*m+Math.cos(l)*h,v=function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])},y=function(e,t){return(e[0]*t[0]+e[1]*t[1])/(v(e)*v(t))},b=function(e,t){return(e[0]*t[1]=1&&(w=0),a===0&&w>0&&(w-=2*Math.PI),a===1&&w<0&&(w+=2*Math.PI),[g,_,o,s,x,w,l,a]}};W.prototype.className=`Path`,W.prototype._attrsAffectingSize=[`data`],P(W),z.addGetterSetter(W,`data`);var _a=class extends ca{_sceneFunc(e){super._sceneFunc(e);let t=Math.PI*2,n=this.points(),r=n,i=this.tension()!==0&&n.length>4;i&&(r=this.getTensionPoints());let a=this.pointerLength(),o=n.length,s,c;if(i){let e=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[o-2],n[o-1]],t=W.calcLength(r[r.length-4],r[r.length-3],`C`,e),i=W.getPointOnQuadraticBezier(Math.min(1,1-a/t),e[0],e[1],e[2],e[3],e[4],e[5]);s=n[o-2]-i.x,c=n[o-1]-i.y}else s=n[o-2]-n[o-4],c=n[o-1]-n[o-3];let l=(Math.atan2(c,s)+t)%t,u=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[o-2],n[o-1]),e.rotate(l),e.moveTo(0,0),e.lineTo(-a,u/2),e.lineTo(-a,-u/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),i?(s=(r[0]+r[2])/2-n[0],c=(r[1]+r[3])/2-n[1]):(s=n[2]-n[0],c=n[3]-n[1]),e.rotate((Math.atan2(-c,-s)+t)%t),e.moveTo(0,0),e.lineTo(-a,u/2),e.lineTo(-a,-u/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){let t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){let e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x,y:e.y-t,width:e.width,height:e.height+t*2}}};_a.prototype.className=`Arrow`,P(_a),z.addGetterSetter(_a,`pointerLength`,10,L()),z.addGetterSetter(_a,`pointerWidth`,10,L()),z.addGetterSetter(_a,`pointerAtBeginning`,!1),z.addGetterSetter(_a,`pointerAtEnding`,!0);var va=class extends U{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}};va.prototype._centroid=!0,va.prototype.className=`Circle`,va.prototype._attrsAffectingSize=[`radius`],P(va),z.addGetterSetter(va,`radius`,0,L());var ya=class extends U{_sceneFunc(e){let t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}};ya.prototype.className=`Ellipse`,ya.prototype._centroid=!0,ya.prototype._attrsAffectingSize=[`radiusX`,`radiusY`],P(ya),z.addComponentsGetterSetter(ya,`radius`,[`x`,`y`]),z.addGetterSetter(ya,`radiusX`,0,L()),z.addGetterSetter(ya,`radiusY`,0,L());var ba=class e extends U{constructor(e){super(e),this._loadListener=()=>{this._requestDraw()},this.on(`imageChange.konva`,e=>{this._removeImageLoad(e.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){let e=this.image();e&&e.complete||e&&e.readyState===4||e&&e.addEventListener&&e.addEventListener(`load`,this._loadListener)}_removeImageLoad(e){e&&e.removeEventListener&&e.removeEventListener(`load`,this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){let e=!!this.cornerRadius(),t=this.hasShadow();return e&&t?!0:super._useBufferCanvas(!0)}_sceneFunc(e){let t=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),i=this.attrs.image,a;if(i){let e=this.attrs.cropWidth,r=this.attrs.cropHeight;a=e&&r?[i,this.cropX(),this.cropY(),e,r,0,0,t,n]:[i,0,0,t,n]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?F.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),i&&(r&&e.clip(),e.drawImage.apply(e,a))}_hitFunc(e){let t=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?F.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.attrs.width??this.image()?.width??0}getHeight(){return this.attrs.height??this.image()?.height??0}static fromURL(t,n,r=null){let i=F.createImageElement();i.onload=function(){n(new e({image:i}))},i.onerror=r,i.crossOrigin=`Anonymous`,i.src=t}};ba.prototype.className=`Image`,ba.prototype._attrsAffectingSize=[`image`],P(ba),z.addGetterSetter(ba,`cornerRadius`,0,nr(4)),z.addGetterSetter(ba,`image`),z.addComponentsGetterSetter(ba,`crop`,[`x`,`y`,`width`,`height`]),z.addGetterSetter(ba,`cropX`,0,L()),z.addGetterSetter(ba,`cropY`,0,L()),z.addGetterSetter(ba,`cropWidth`,0,L()),z.addGetterSetter(ba,`cropHeight`,0,L());var xa=[`fontFamily`,`fontSize`,`fontStyle`,`padding`,`lineHeight`,`text`,`width`,`height`,`pointerDirection`,`pointerWidth`,`pointerHeight`],Sa=`Change.konva`,Ca=`none`,wa=`up`,Ta=`right`,Ea=`down`,Da=`left`,Oa=xa.length,ka=class extends Gi{constructor(e){super(e),this.on(`add.konva`,function(e){this._addListeners(e.child),this._sync()})}getText(){return this.find(`Text`)[0]}getTag(){return this.find(`Tag`)[0]}_addListeners(e){let t=this,n,r=function(){t._sync()};for(n=0;n{t=Math.min(t,e.x),n=Math.max(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.y)}),{x:t,y:r,width:n-t,height:i-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Ma.prototype.className=`RegularPolygon`,Ma.prototype._centroid=!0,Ma.prototype._attrsAffectingSize=[`radius`],P(Ma),z.addGetterSetter(Ma,`radius`,0,L()),z.addGetterSetter(Ma,`sides`,0,L()),z.addGetterSetter(Ma,`cornerRadius`,0,nr(4));var Na=Math.PI*2,Pa=class extends U{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,Na,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),Na,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Pa.prototype.className=`Ring`,Pa.prototype._centroid=!0,Pa.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],P(Pa),z.addGetterSetter(Pa,`innerRadius`,0,L()),z.addGetterSetter(Pa,`outerRadius`,0,L());var Fa=class extends U{constructor(e){super(e),this._updated=!0,this.anim=new qi(()=>{let e=this._updated;return this._updated=!1,e}),this.on(`animationChange.konva`,function(){this.frameIndex(0)}),this.on(`frameIndexChange.konva`,function(){this._updated=!0}),this.on(`frameRateChange.konva`,function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){let t=this.animation(),n=this.frameIndex(),r=n*4,i=this.animations()[t],a=this.frameOffsets(),o=i[r+0],s=i[r+1],c=i[r+2],l=i[r+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,c,l),e.closePath(),e.fillStrokeShape(this)),u)if(a){let r=a[t],i=n*2;e.drawImage(u,o,s,c,l,r[i+0],r[i+1],c,l)}else e.drawImage(u,o,s,c,l,0,0,c,l)}_hitFunc(e){let t=this.animation(),n=this.frameIndex(),r=n*4,i=this.animations()[t],a=this.frameOffsets(),o=i[r+2],s=i[r+3];if(e.beginPath(),a){let r=a[t],i=n*2;e.rect(r[i+0],r[i+1],o,s)}else e.rect(0,0,o,s);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){let e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;let e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){let e=this.frameIndex(),t=this.animation();e{if(/\p{Emoji}/u.test(t)){let i=r[n+1];i&&/\p{Emoji_Modifier}|\u200D/u.test(i)?(e.push(t+i),r[n+1]=``):e.push(t)}else /\p{Regional_Indicator}{2}/u.test(t+(r[n+1]||``))?e.push(t+r[n+1]):n>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(t)?e[e.length-1]+=t:t&&e.push(t);return e},[])}var Ra=`auto`,za=`center`,Ba=`inherit`,Va=`justify`,Ha=`Change.konva`,Ua=`2d`,Wa=`-`,Ga=`left`,Ka=`text`,qa=`Text`,Ja=`top`,Ya=`bottom`,Xa=`middle`,Za=`normal`,Qa=`px `,$a=` `,eo=`right`,to=`rtl`,no=`word`,ro=`char`,io=`none`,ao=`…`,oo=[`direction`,`fontFamily`,`fontSize`,`fontStyle`,`fontVariant`,`padding`,`align`,`verticalAlign`,`lineHeight`,`text`,`width`,`height`,`wrap`,`ellipsis`,`letterSpacing`],so=oo.length,co=null;function lo(){if(co!==null)return co;co=!1;try{let e=document.createElement(`canvas`);e.width=10,e.height=10;let t=e.getContext(Ua);if(t){t.globalAlpha=0,t.shadowColor=`black`,t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle=`black`,t.font=`10px Arial`,t.fillText(`X`,0,10);let e=t.getImageData(0,0,10,10).data;for(let t=3;t0){co=!0;break}}}catch{}return co}function uo(e){return e.split(`,`).map(e=>{e=e.trim();let t=e.indexOf(` `)>=0,n=e.indexOf(`"`)>=0||e.indexOf(`'`)>=0;return t&&!n&&(e=`"${e}"`),e}).join(`, `)}var fo;function po(){return fo||(fo=F.createCanvasElement().getContext(Ua),fo)}function mo(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function ho(e){e.setAttr(`miterLimit`,2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function go(e){return e||={},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||`black`),e}var G=class extends U{constructor(e){super(go(e)),this._partialTextX=0,this._partialTextY=0;for(let e=0;ee+La(t.text).length,0);f({char:s,index:a+n,x:o,y:y+0,lineIndex:v,column:a,isLastInLine:x,width:this.measureSize(s).width,context:e})}e.fillStrokeShape(this),f&&e.restore(),o+=this.measureSize(s).width+d}}else d!==0&&e.setAttr(`letterSpacing`,`${d}px`),this._partialTextX=o,this._partialTextY=y+0,this._partialText=m,e.fillStrokeShape(this);if(_){e.save(),e.beginPath();let t=N.legacyTextRendering?0:-Math.round(i/4),n=S;e.moveTo(n,y+0+t);let a=l===Va&&!x?u-r*2:b;e.lineTo(n+Math.round(a),y+0+t),e.lineWidth=i/15,e.strokeStyle=this._getLinearGradient()||p,e.stroke(),e.restore()}e.restore(),n>1&&(y+=a)}}_hitFunc(e){let t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){let t=F._isString(e)?e:e==null?``:e+``;return this._setAttr(Ka,t),this}getWidth(){return this.attrs.width===Ra||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===Ra||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return F.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}measureSize(e){let t=po(),n=this.fontSize(),r;t.save(),t.font=this._getContextFont(),r=t.measureText(e),t.restore();let i=n/100;return{actualBoundingBoxAscent:r.actualBoundingBoxAscent??71.58203125*i,actualBoundingBoxDescent:r.actualBoundingBoxDescent??0,actualBoundingBoxLeft:r.actualBoundingBoxLeft??-7.421875*i,actualBoundingBoxRight:r.actualBoundingBoxRight??75.732421875*i,alphabeticBaseline:r.alphabeticBaseline??0,emHeightAscent:r.emHeightAscent??100*i,emHeightDescent:r.emHeightDescent??-20*i,fontBoundingBoxAscent:r.fontBoundingBoxAscent??91*i,fontBoundingBoxDescent:r.fontBoundingBoxDescent??21*i,hangingBaseline:r.hangingBaseline??72.80000305175781*i,ideographicBaseline:r.ideographicBaseline??-21*i,width:r.width,height:n}}_getContextFont(){return this.fontStyle()+$a+this.fontVariant()+$a+(this.fontSize()+Qa)+uo(this.fontFamily())}_addTextLine(e){this.align()===Va&&(e=e.trim());let t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){let t=this.letterSpacing(),n=e.length;return po().measureText(e).width+t*n}_setTextData(){let e=this.text().split(` -`),t=+this.fontSize(),n=0,r=this.lineHeight()*t,i=this.attrs.width,a=this.attrs.height,o=i!==Ra&&i!==void 0,s=a!==Ra&&a!==void 0,c=this.padding(),l=i-c*2,u=a-c*2,d=0,f=this.wrap(),p=f!==ro&&f!==io,m=this.ellipsis();this.textArr=[],po().font=this._getContextFont();let h=m?this._getTextWidth(ao):0;for(let t=0,i=e.length;tl)for(;a.length>0;){let e=0,t=La(a).length,i=``,o=0;for(;e>>1,c=La(a).slice(0,n+1).join(``),f=this._getTextWidth(c);(m&&s&&d+r>u?f+h:f)<=l?(e=n+1,i=c,o=f):t=n}if(i){if(p){let t=La(a),n=La(i),r=t[n.length],s=r===$a||r===Wa,c;if(s&&o<=l)c=n.length;else{let e=n.lastIndexOf($a),t=n.lastIndexOf(Wa);c=Math.max(e,t)+1}c>0&&(e=c,i=t.slice(0,e).join(``),o=this._getTextWidth(i))}if(i=i.trimRight(),this._addTextLine(i),n=Math.max(n,o),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(a=La(a).slice(e).join(``).trimLeft(),a.length>0&&(c=this._getTextWidth(a),c<=l)){this._addTextLine(a),d+=r,n=Math.max(n,c);break}}else break}else this._addTextLine(a),d+=r,n=Math.max(n,c),this._shouldHandleEllipsis(d)&&tu)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){let t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==Ra&&r!==void 0,a=r-this.padding()*2;return this.wrap()===io||i&&e+n>a}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==Ra&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];!i||!r||(t&&(this._getTextWidth(i.text+ao)this.pathLength?null:W.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=W.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,this.textBaseline()),e.setAttr(`textAlign`,`left`),e.save();let t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,a=t.indexOf(`underline`)!==-1,o=t.indexOf(`line-through`)!==-1;a&&e.beginPath();for(let t=0;t=1){let n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;nthis.pathLength&&f-this.pathLength<=c?this.pathLength:f);if(!p)return;let m=W.getLineLength(r.x,r.y,p.x,p.y),h=0;if(s)try{h=s(t[n-1].char,i)*this.fontSize()}catch{h=0}r.x+=h,p.x+=h,this.textWidth+=h;let g=W.getPointOnLine(h+m/2,r.x,r.y,p.x,p.y),_=Math.atan2(p.y-r.y,p.x-r.x);this.glyphInfo.push({transposeX:g.x,transposeY:g.y,text:e[n],rotation:_,p0:r,p1:p,width:m}),d+=u}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};let e=[];this.glyphInfo.forEach(function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,i=e[1]||0,a,o;for(let s=0;se+`.${xo}`).join(` `),Co=`nodesRect`,wo=[`widthChange`,`heightChange`,`scaleXChange`,`scaleYChange`,`skewXChange`,`skewYChange`,`rotationChange`,`offsetXChange`,`offsetYChange`,`transformsEnabledChange`,`strokeWidthChange`,`draggableChange`],To={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},Eo=`ontouchstart`in N._global;function Do(e,t,n){if(e===`rotater`)return n;t+=F.degToRad(To[e]||0);let r=(F.radToDeg(t)%360+360)%360;return F._inRange(r,337.5,360)||F._inRange(r,0,22.5)?`ns-resize`:F._inRange(r,22.5,67.5)?`nesw-resize`:F._inRange(r,67.5,112.5)?`ew-resize`:F._inRange(r,112.5,157.5)?`nwse-resize`:F._inRange(r,157.5,202.5)?`ns-resize`:F._inRange(r,202.5,247.5)?`nesw-resize`:F._inRange(r,247.5,292.5)?`ew-resize`:F._inRange(r,292.5,337.5)?`nwse-resize`:(F.error(`Transformer has unknown angle for cursor detection: `+r),`pointer`)}var Oo=[`top-left`,`top-center`,`top-right`,`middle-right`,`middle-left`,`bottom-left`,`bottom-center`,`bottom-right`],ko=1e8;function Ao(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function jo(e,t,n){let r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function Mo(e,t){return jo(e,t,Ao(e))}function No(e,t,n){let r=t;for(let i=0;ie.isAncestorOf(this)?(F.error(`Konva.Transformer cannot be an a child of the node you are trying to attach`),!1):!0);return this._nodes=e=t,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(e=>{let t=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(e._attrsAffectingSize.length){let n=e._attrsAffectingSize.map(e=>e+`Change.`+this._getEventNamespace()).join(` `);e.on(n,t)}e.on(wo.map(e=>e+`.${this._getEventNamespace()}`).join(` `),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),this._proxyDrag(e)}),this._resetTransformCache(),this.findOne(`.top-left`)&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(`.back`)&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;let r=e.getAbsolutePosition(),i=r.x-t.x,a=r.y-t.y;this.nodes().forEach(t=>{if(t===e||t.isDragging())return;let r=t.getAbsolutePosition();t.setAbsolutePosition({x:r.x+i,y:r.y+a}),t.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off(`.`+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(Co),this._clearCache(`transform`),this._clearSelfAndDescendantCache(`absoluteTransform`)}_getNodeRect(){return this._getCache(Co,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){let r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),i=e.getAbsoluteScale(n),a=e.getAbsolutePosition(n),o=r.x*i.x-e.offsetX()*i.x,s=r.y*i.y-e.offsetY()*i.y,c=(N.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return jo({x:a.x+o*Math.cos(c)+s*Math.sin(-c),y:a.y+s*Math.cos(c)+o*Math.sin(c),width:r.width*i.x,height:r.height*i.y,rotation:c},-N.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-ko,y:-ko,width:0,height:0,rotation:0};let e=[];this.nodes().map(t=>{let n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],i=t.getAbsoluteTransform();r.forEach(function(t){let n=i.point(t);e.push(n)})});let t=new mn;t.rotate(-N.getAngle(this.rotation()));let n=1/0,r=1/0,i=-1/0,a=-1/0;e.forEach(function(e){let o=t.point(e);n===void 0&&(n=i=o.x,r=a=o.y),n=Math.min(n,o.x),r=Math.min(r,o.y),i=Math.max(i,o.x),a=Math.max(a,o.y)}),t.invert();let o=t.point({x:n,y:r});return{x:o.x,y:o.y,width:i-n,height:a-r,rotation:N.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Oo.forEach(e=>{this._createAnchor(e)}),this._createAnchor(`rotater`),this._elementsCreated=!0}_createAnchor(e){let t=new ja({stroke:`rgb(0, 161, 255)`,fill:`white`,strokeWidth:1,name:e+` _anchor`,dragDistance:0,draggable:!0,hitStrokeWidth:Eo?10:`auto`}),n=this;t.on(`mousedown touchstart`,function(e){n._handleMouseDown(e)}),t.on(`dragstart`,e=>{t.stopDrag(),e.cancelBubble=!0}),t.on(`dragend`,e=>{e.cancelBubble=!0}),t.on(`mouseenter`,()=>{let n=Do(e,N.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=n),this._cursorChange=!0}),t.on(`mouseout`,()=>{t.getStage().content&&(t.getStage().content.style.cursor=``),this._cursorChange=!1}),this.add(t)}_createBack(){let e=new U({name:`back`,width:0,height:0,sceneFunc(e,t){let n=t.getParent(),r=n.padding(),i=t.width(),a=t.height();if(e.beginPath(),e.rect(-r,-r,i+r*2,a+r*2),n.rotateEnabled()&&n.rotateLineVisible()){let t=n.rotateAnchorAngle(),r=n.rotateAnchorOffset(),o=F.degToRad(t),s=Math.sin(o),c=-Math.cos(o),l=i/2,u=a/2,d=1/0;c<0?d=Math.min(d,-u/c):c>0&&(d=Math.min(d,(a-u)/c)),s<0?d=Math.min(d,-l/s):s>0&&(d=Math.min(d,(i-l)/s));let f=l+s*d,p=u+c*d,m=F._sign(a),h=f+s*r*m,g=p+c*r*m;e.moveTo(f,p),e.lineTo(h,g)}e.fillStrokeShape(t)},hitFunc:(e,t)=>{if(!this.shouldOverdrawWholeArea())return;let n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+n*2,t.height()+n*2),e.fillStrokeShape(t)}});this.add(e),this._proxyDrag(e),e.on(`dragstart`,e=>{e.cancelBubble=!0}),e.on(`dragmove`,e=>{e.cancelBubble=!0}),e.on(`dragend`,e=>{e.cancelBubble=!0}),this.on(`dragmove`,e=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(` `)[0];let t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(n**2+r**2);this.sin=Math.abs(r/i),this.cos=Math.abs(n/i),typeof window<`u`&&(window.addEventListener(`mousemove`,this._handleMouseMove),window.addEventListener(`touchmove`,this._handleMouseMove),window.addEventListener(`mouseup`,this._handleMouseUp,!0),window.addEventListener(`touchend`,this._handleMouseUp,!0)),this._transforming=!0;let a=e.target.getAbsolutePosition(),o=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:o.x-a.x,y:o.y-a.y},Po++,this._fire(`transformstart`,{evt:e.evt,target:this.getNode()}),this._nodes.forEach(t=>{t._fire(`transformstart`,{evt:e.evt,target:t})})}_handleMouseMove(e){let t,n,r,i=this.findOne(`.`+this._movingAnchorName),a=i.getStage();a.setPointersPositions(e);let o=a.getPointerPosition(),s={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y},c=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(c,s,e)),i.setAbsolutePosition(s);let l=i.getAbsolutePosition();if(c.x===l.x&&c.y===l.y)return;if(this._movingAnchorName===`rotater`){let r=this._getNodeRect();t=i.x()-r.width/2,n=-i.y()+r.height/2;let a=N.getAngle(this.rotateAnchorAngle()),o=Math.atan2(-n,t)+Math.PI/2-a;r.height<0&&(o-=Math.PI);let s=N.getAngle(this.rotation())+o,c=N.getAngle(this.rotationSnapTolerance()),l=Mo(r,No(this.rotationSnaps(),s,c)-r.rotation);this._fitNodesInto(l,e);return}let u=this.shiftBehavior(),d;d=u===`inverted`?this.keepRatio()&&!e.shiftKey:u===`none`?this.keepRatio():this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey;if(this._movingAnchorName===`top-left`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.bottom-right`).x(),y:this.findOne(`.bottom-right`).y()};r=Math.sqrt((e.x-i.x())**2+(e.y-i.y())**2);let a=this.findOne(`.top-left`).x()>e.x?-1:1,o=this.findOne(`.top-left`).y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this.findOne(`.top-left`).x(e.x-t),this.findOne(`.top-left`).y(e.y-n)}}else if(this._movingAnchorName===`top-center`)this.findOne(`.top-left`).y(i.y());else if(this._movingAnchorName===`top-right`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.bottom-left`).x(),y:this.findOne(`.bottom-left`).y()};r=Math.sqrt((i.x()-e.x)**2+(e.y-i.y())**2);let a=this.findOne(`.top-right`).x()e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this.findOne(`.top-right`).x(e.x+t),this.findOne(`.top-right`).y(e.y-n)}var p=i.position();this.findOne(`.top-left`).y(p.y),this.findOne(`.bottom-right`).x(p.x)}else if(this._movingAnchorName===`middle-left`)this.findOne(`.top-left`).x(i.x());else if(this._movingAnchorName===`middle-right`)this.findOne(`.bottom-right`).x(i.x());else if(this._movingAnchorName===`bottom-left`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.top-right`).x(),y:this.findOne(`.top-right`).y()};r=Math.sqrt((e.x-i.x())**2+(i.y()-e.y)**2);let a=e.x{var n;t._fire(`transformend`,{evt:e,target:t}),(n=t.getLayer())==null||n.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){let n=this._getNodeRect();if(F._inRange(e.width,-this.padding()*2-1,1)){this.update();return}if(F._inRange(e.height,-this.padding()*2-1,1)){this.update();return}let r=new mn;if(r.rotate(N.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`left`)>=0){let t=r.point({x:-this.padding()*2,y:0});e.x+=t.x,e.y+=t.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace(`left`,`right`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`right`)>=0){let t=r.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace(`right`,`left`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`top`)>=0){let t=r.point({x:0,y:-this.padding()*2});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace(`top`,`bottom`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`bottom`)>=0){let t=r.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace(`bottom`,`top`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){let t=this.boundBoxFunc()(n,e);t?e=t:F.warn(`boundBoxFunc returned falsy. You should return new bound rect from it!`)}let i=1e7,a=new mn;a.translate(n.x,n.y),a.rotate(n.rotation),a.scale(n.width/i,n.height/i);let o=new mn,s=e.width/i,c=e.height/i;this.flipEnabled()===!1?(o.translate(e.x,e.y),o.rotate(e.rotation),o.translate(e.width<0?e.width:0,e.height<0?e.height:0),o.scale(Math.abs(s),Math.abs(c))):(o.translate(e.x,e.y),o.rotate(e.rotation),o.scale(s,c));let l=o.multiply(a.invert());this._nodes.forEach(e=>{var t;if(!e.getStage())return;let n=e.getParent().getAbsoluteTransform(),r=e.getTransform().copy();r.translate(e.offsetX(),e.offsetY());let i=new mn;i.multiply(n.copy().invert()).multiply(l).multiply(n).multiply(r);let a=i.decompose();e.setAttrs(a),(t=e.getLayer())==null||t.batchDraw()}),this.rotation(F._getRotation(e.rotation)),this._nodes.forEach(e=>{this._fire(`transform`,{evt:t,target:e}),e._fire(`transform`,{evt:t,target:e})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;let t=this._getNodeRect();this.rotation(F._getRotation(t.rotation));let n=t.width,r=t.height,i=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),s=this.anchorSize(),c=this.find(`._anchor`);c.forEach(e=>{e.setAttrs({width:s,height:s,offsetX:s/2,offsetY:s/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(`.top-left`,{x:0,y:0,offsetX:s/2+o,offsetY:s/2+o,visible:a&&i.indexOf(`top-left`)>=0}),this._batchChangeChild(`.top-center`,{x:n/2,y:0,offsetY:s/2+o,visible:a&&i.indexOf(`top-center`)>=0}),this._batchChangeChild(`.top-right`,{x:n,y:0,offsetX:s/2-o,offsetY:s/2+o,visible:a&&i.indexOf(`top-right`)>=0}),this._batchChangeChild(`.middle-left`,{x:0,y:r/2,offsetX:s/2+o,visible:a&&i.indexOf(`middle-left`)>=0}),this._batchChangeChild(`.middle-right`,{x:n,y:r/2,offsetX:s/2-o,visible:a&&i.indexOf(`middle-right`)>=0}),this._batchChangeChild(`.bottom-left`,{x:0,y:r,offsetX:s/2+o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-left`)>=0}),this._batchChangeChild(`.bottom-center`,{x:n/2,y:r,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-center`)>=0}),this._batchChangeChild(`.bottom-right`,{x:n,y:r,offsetX:s/2-o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-right`)>=0});let l=this.rotateAnchorAngle(),u=this.rotateAnchorOffset(),d=F.degToRad(l),f=Math.sin(d),p=-Math.cos(d),m=n/2,h=r/2,g=1/0;p<0?g=Math.min(g,-h/p):p>0&&(g=Math.min(g,(r-h)/p)),f<0?g=Math.min(g,-m/f):f>0&&(g=Math.min(g,(n-m)/f));let _=m+f*g,v=h+p*g,y=F._sign(r);this._batchChangeChild(`.rotater`,{x:_+f*u*y,y:v+p*u*y-o*p,visible:this.rotateEnabled()}),this._batchChangeChild(`.back`,{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(e=>e.draggable()),x:0,y:0});let b=this.anchorStyleFunc();b&&c.forEach(e=>{b(e)}),(e=this.getLayer())==null||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();let e=this.findOne(`.`+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=``),Gi.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(F.error(`You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.`),this):super.add(...e)}toObject(){return B.prototype.toObject.call(this)}clone(e){return B.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};q.isTransforming=()=>Po>0;function Fo(e){return e instanceof Array||F.warn(`enabledAnchors value should be an array`),e instanceof Array&&e.forEach(function(e){Oo.indexOf(e)===-1&&F.warn(`Unknown anchor name: `+e+`. Available names are: `+Oo.join(`, `))}),e||[]}q.prototype.className=`Transformer`,P(q),z.addGetterSetter(q,`enabledAnchors`,Oo,Fo),z.addGetterSetter(q,`flipEnabled`,!0,R()),z.addGetterSetter(q,`resizeEnabled`,!0),z.addGetterSetter(q,`anchorSize`,10,L()),z.addGetterSetter(q,`rotateEnabled`,!0),z.addGetterSetter(q,`rotateLineVisible`,!0),z.addGetterSetter(q,`rotationSnaps`,[]),z.addGetterSetter(q,`rotateAnchorOffset`,50,L()),z.addGetterSetter(q,`rotateAnchorAngle`,0,L()),z.addGetterSetter(q,`rotateAnchorCursor`,`crosshair`),z.addGetterSetter(q,`rotationSnapTolerance`,5,L()),z.addGetterSetter(q,`borderEnabled`,!0),z.addGetterSetter(q,`anchorStroke`,`rgb(0, 161, 255)`),z.addGetterSetter(q,`anchorStrokeWidth`,1,L()),z.addGetterSetter(q,`anchorFill`,`white`),z.addGetterSetter(q,`anchorCornerRadius`,0,L()),z.addGetterSetter(q,`borderStroke`,`rgb(0, 161, 255)`),z.addGetterSetter(q,`borderStrokeWidth`,1,L()),z.addGetterSetter(q,`borderDash`),z.addGetterSetter(q,`keepRatio`,!0),z.addGetterSetter(q,`shiftBehavior`,`default`),z.addGetterSetter(q,`centeredScaling`,!1),z.addGetterSetter(q,`ignoreStroke`,!1),z.addGetterSetter(q,`padding`,0,L()),z.addGetterSetter(q,`nodes`),z.addGetterSetter(q,`node`),z.addGetterSetter(q,`boundBoxFunc`),z.addGetterSetter(q,`anchorDragBoundFunc`),z.addGetterSetter(q,`anchorStyleFunc`),z.addGetterSetter(q,`shouldOverdrawWholeArea`,!1),z.addGetterSetter(q,`useSingleNodeRotation`,!0),z.backCompat(q,{lineEnabled:`borderEnabled`,rotateHandlerOffset:`rotateAnchorOffset`,enabledHandlers:`enabledAnchors`});var Io=class extends U{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,N.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Io.prototype.className=`Wedge`,Io.prototype._centroid=!0,Io.prototype._attrsAffectingSize=[`radius`],P(Io),z.addGetterSetter(Io,`radius`,0,L()),z.addGetterSetter(Io,`angle`,0,L()),z.addGetterSetter(Io,`clockwise`,!1),z.backCompat(Io,{angleDeg:`angle`,getAngleDeg:`getAngle`,setAngleDeg:`setAngle`});function Lo(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var Ro=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],zo=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function Bo(e,t){let n=e.data,r=e.width,i=e.height,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,ee=t+t+1,te=r-1,T=i-1,E=t+1,D=E*(E+1)/2,ne=new Lo,O=Ro[t],re=zo[t],ie=null,k=ne,A=null,j=null;for(let e=1;e>re,C===0?n[o]=n[o+1]=n[o+2]=0:(C=255/C,n[o]=(c*O>>re)*C,n[o+1]=(l*O>>re)*C,n[o+2]=(u*O>>re)*C),c-=f,l-=p,u-=m,d-=h,f-=A.r,p-=A.g,m-=A.b,h-=A.a,a=s+((a=e+t+1)>re,C>0?(C=255/C,n[a]=(c*O>>re)*C,n[a+1]=(l*O>>re)*C,n[a+2]=(u*O>>re)*C):n[a]=n[a+1]=n[a+2]=0,c-=f,l-=p,u-=m,d-=h,f-=A.r,p-=A.g,m-=A.b,h-=A.a,a=e+((a=t+E)0&&Bo(e,t)};z.addGetterSetter(B,`blurRadius`,0,L(),z.afterSetFilter);var Ho=function(e){let t=this.brightness()*255,n=e.data,r=n.length;for(let e=0;e255?255:i,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,n[e]=i,n[e+1]=a,n[e+2]=o};z.addGetterSetter(B,`contrast`,0,L(),z.afterSetFilter);var Go=function(e){let t=e.data,n=e.width,r=e.height,i=Math.min(1,Math.max(0,this.embossStrength?.call(this)??.5)),a=Math.min(1,Math.max(0,this.embossWhiteLevel?.call(this)??.5)),o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[this.embossDirection?.call(this)??`top-left`]??315,s=!!(this.embossBlend?.call(this)??!1),c=i*10,l=a*255,u=o*Math.PI/180,d=Math.cos(u),f=Math.sin(u),p=128/1020*c,m=new Uint8ClampedArray(t),h=new Float32Array(n*r);for(let e=0,n=0;ne<0?0:e>255?255:e;for(let e=1;ei&&(i=a),c=t[e+1],cs&&(s=c),d=t[e+2],du&&(u=d);i===r&&(i=255,r=0),s===o&&(s=255,o=0),u===l&&(u=255,l=0);let p,m,h,g,_,v;if(f>0)p=i+f*(255-i),m=r-f*(r-0),h=s+f*(255-s),g=o-f*(o-0),_=u+f*(255-u),v=l-f*(l-0);else{let e=(i+r)*.5;p=i+f*(i-e),m=r+f*(r-e);let t=(s+o)*.5;h=s+f*(s-t),g=o+f*(o-t);let n=(u+l)*.5;_=u+f*(u-n),v=l+f*(l-n)}for(let e=0;el?f:l;let p=o,m=a,h=360/m*Math.PI/180;for(let e=0;el?f:l;let p=o,m=a,h=n.polarRotation||0,g,_;for(u=0;ut&&(b=y,x=0,S=-1),i=0;i=0&&d=0&&f=0&&d=0&&f=1020?255:0}return o}function cs(e,t,n){let r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s=0&&d=0&&f=n))for(let t=f;t=r)continue;let i=(n*t+e)*4;a+=o[i+0],s+=o[i+1],c+=o[i+2],l+=o[i+3],m+=1}a/=m,s/=m,c/=m,l/=m;for(let e=u;e=n))for(let t=f;t=r)continue;let i=(n*t+e)*4;o[i+0]=a,o[i+1]=s,o[i+2]=c,o[i+3]=l}}};z.addGetterSetter(B,`pixelSize`,8,L(),z.afterSetFilter);var fs=function(e){let t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,i=255/t;for(let e=0;e255?255:e<0?0:Math.round(e)}),z.addGetterSetter(B,`green`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),z.addGetterSetter(B,`blue`,0,tr,z.afterSetFilter);var ms=function(e){let t=e.data,n=t.length,r=this.red(),i=this.green(),a=this.blue(),o=this.alpha();for(let e=0;e255?255:e<0?0:Math.round(e)}),z.addGetterSetter(B,`green`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),z.addGetterSetter(B,`blue`,0,tr,z.afterSetFilter),z.addGetterSetter(B,`alpha`,1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});var hs=function(e){let t=e.data,n=t.length;for(let e=0;e=128&&(t[e]=255-n,t[e+1]=255-r,t[e+2]=255-i)}return e},_s=function(e){let t=this.threshold()*255,n=e.data,r=n.length;for(let e=0;e{i(e.getAttr(r))})}}var Es=`V`;function Ds(e){function t(e){return e?.__konvaNode?e:e?.parent?t(e.parent):(console.error(`vue-konva error: Can not find parent node`),null)}return t(e.parent)}function Os(e){return e.component?e.component.__konvaNode||Os(e.component.subTree):null}function ks(e){let{el:t,component:n}=e,r=Os(e);if(t?.tagName&&n&&!r){let e=t.tagName.toLowerCase();return console.error(`vue-konva error: You are trying to render "${e}" inside your component tree. Looks like it is not a Konva node. You can render only Konva components inside the Stage.`),null}return r}function As(e){let t=e=>!!e&&typeof e==`object`&&`component`in e,n=e=>Array.isArray(e),r=e=>t(e)?[e,...r(e.children)]:n(e)?e.flatMap(r):[];return r(e.children)}function js(e,t){let n=As(e),r=[];n.forEach(e=>{let t=ks(e);t&&r.push(t)});let i=!1;r.forEach((e,t)=>{e.getZIndex()!==t&&(e.setZIndex(t),i=!0)}),i&&ys(t)}var Ms=vs.default?.Stage||vs.Stage,Ns=ee({name:`Stage`,props:{config:{type:Object,default:function(){return{}}},__useStrictMode:{type:Boolean}},inheritAttrs:!1,setup(e,{attrs:t,slots:r,expose:a}){let o=we();if(!o)return;let s=n({}),c=b(null),l=new Ms({width:e.config.width,height:e.config.height,container:document.createElement(`div`)});o.__konvaNode=l,p();function u(){return o?.__konvaNode}function d(){return o?.__konvaNode}function p(){if(!o)return;let n=s||{},r={...t,...e.config};Ss(o,r,n,e.__useStrictMode),Object.assign(s,r)}return v(()=>{c.value&&l.container(c.value),p(),Ts(l,o)}),i(()=>{p(),js(o.subTree,l),Ts(l,o)}),Te(()=>{l.destroy()}),f(()=>e.config,p,{deep:!0}),a({getStage:d,getNode:u}),()=>E(`div`,{ref:c,id:t?.id,accesskey:t?.accesskey,class:t?.class,role:t?.role,style:t?.style,tabindex:t?.tabindex,title:t?.title},r.default?.())}}),Ps=`.vue-konva-event`,Fs={Group:!0,Layer:!0,FastLayer:!0,Label:!0};function J(e,t){return ee({name:e,props:{config:{type:Object,default:function(){return{}}},__useStrictMode:{type:Boolean}},setup(r,{attrs:o,slots:s,expose:c}){let l=we();if(!l)return;let u=n({}),d=new t;l.__konvaNode=d,l.vnode.__konvaNode=d,h();function p(){return l?.__konvaNode}function m(){return l?.__konvaNode}function h(){if(!l)return;let e={};for(let t in l?.vnode.props)t.slice(0,2)===`on`&&(e[t]=l.vnode.props[t]);let t=u||{},n={...o,...r.config,...e};Ss(l,n,t,r.__useStrictMode),Object.assign(u,n)}v(()=>{let e=Ds(l)?.__konvaNode;e&&`add`in e&&e.add(d),ys(d),Ts(d,l)}),a(()=>{ys(d),d.destroy(),d.off(Ps),d.off(Cs)}),i(()=>{h(),js(l.subTree,d),Ts(d,l)}),f(()=>r.config,h,{deep:!0}),c({getStage:m,getNode:p});let g=Fs.hasOwnProperty(e);return()=>g?s.default?.():null}})}var Y=vs.default||vs,Is=J(`Arc`,Y.Arc),Ls=J(`Arrow`,Y.Arrow),Rs=J(`Circle`,Y.Circle),zs=J(`Ellipse`,Y.Ellipse),Bs=J(`FastLayer`,Y.FastLayer),Vs=J(`Group`,Y.Group),Hs=J(`Image`,Y.Image),Us=J(`Label`,Y.Label),Ws=J(`Layer`,Y.Layer),Gs=J(`Line`,Y.Line),Ks=J(`Path`,Y.Path),qs=J(`Rect`,Y.Rect),Js=J(`RegularPolygon`,Y.RegularPolygon),Ys=J(`Ring`,Y.Ring),Xs=J(`Shape`,Y.Shape),Zs=J(`Sprite`,Y.Sprite),Qs=J(`Star`,Y.Star),$s=J(`Tag`,Y.Tag),ec=J(`Text`,Y.Text),tc=J(`TextPath`,Y.TextPath),nc=J(`Transformer`,Y.Transformer),rc=J(`Wedge`,Y.Wedge),ic=Object.freeze(Object.defineProperty({__proto__:null,Arc:Is,Arrow:Ls,Circle:Rs,Ellipse:zs,FastLayer:Bs,Group:Vs,Image:Hs,Label:Us,Layer:Ws,Line:Gs,Path:Ks,Rect:qs,RegularPolygon:Js,Ring:Ys,Shape:Xs,Sprite:Zs,Star:Qs,Tag:$s,Text:ec,TextPath:tc,Transformer:nc,Wedge:rc},Symbol.toStringTag,{value:`Module`})),ac={install:(e,t)=>{let n=t?.prefix||Es,r=t?.customNodes?Object.entries(t.customNodes).map(([e,t])=>J(e,t)):[];[Ns,...Object.values(ic),...r].forEach(t=>{e.component(`${n}${t.name}`,t)})}},oc=typeof document<`u`;function sc(e){return typeof e==`object`||`displayName`in e||`props`in e||`__vccOpts`in e}function cc(e){return e.__esModule||e[Symbol.toStringTag]===`Module`||e.default&&sc(e.default)}var X=Object.assign;function lc(e,t){let n={};for(let r in t){let i=t[r];n[r]=dc(i)?i.map(e):e(i)}return n}var uc=()=>{},dc=Array.isArray;function fc(e,t){let n={};for(let r in e)n[r]=r in t?t[r]:e[r];return n}var pc=/#/g,mc=/&/g,hc=/\//g,gc=/=/g,_c=/\?/g,vc=/\+/g,yc=/%5B/g,bc=/%5D/g,xc=/%5E/g,Sc=/%60/g,Cc=/%7B/g,wc=/%7C/g,Tc=/%7D/g,Ec=/%20/g;function Dc(e){return e==null?``:encodeURI(``+e).replace(wc,`|`).replace(yc,`[`).replace(bc,`]`)}function Oc(e){return Dc(e).replace(Cc,`{`).replace(Tc,`}`).replace(xc,`^`)}function kc(e){return Dc(e).replace(vc,`%2B`).replace(Ec,`+`).replace(pc,`%23`).replace(mc,`%26`).replace(Sc,"`").replace(Cc,`{`).replace(Tc,`}`).replace(xc,`^`)}function Ac(e){return kc(e).replace(gc,`%3D`)}function jc(e){return Dc(e).replace(pc,`%23`).replace(_c,`%3F`)}function Mc(e){return jc(e).replace(hc,`%2F`)}function Nc(e){if(e==null)return null;try{return decodeURIComponent(``+e)}catch{}return``+e}var Pc=/\/$/,Fc=e=>e.replace(Pc,``);function Ic(e,t,n=`/`){let r,i={},a=``,o=``,s=t.indexOf(`#`),c=t.indexOf(`?`);return c=s>=0&&c>s?-1:c,c>=0&&(r=t.slice(0,c),a=t.slice(c,s>0?s:t.length),i=e(a.slice(1))),s>=0&&(r||=t.slice(0,s),o=t.slice(s,t.length)),r=Wc(r??t,n),{fullPath:r+a+o,path:r,query:i,hash:Nc(o)}}function Lc(e,t){let n=t.query?e(t.query):``;return t.path+(n&&`?`)+n+(t.hash||``)}function Rc(e,t){return!t||!e.toLowerCase().startsWith(t.toLowerCase())?e:e.slice(t.length)||`/`}function zc(e,t,n){let r=t.matched.length-1,i=n.matched.length-1;return r>-1&&r===i&&Bc(t.matched[r],n.matched[i])&&Vc(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function Bc(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function Vc(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n in e)if(!Hc(e[n],t[n]))return!1;return!0}function Hc(e,t){return dc(e)?Uc(e,t):dc(t)?Uc(t,e):e?.valueOf()===t?.valueOf()}function Uc(e,t){return dc(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):e.length===1&&e[0]===t}function Wc(e,t){if(e.startsWith(`/`))return e;if(!e)return t;let n=t.split(`/`),r=e.split(`/`),i=r[r.length-1];(i===`..`||i===`.`)&&r.push(``);let a=n.length-1,o,s;for(o=0;o1&&a--;else break;return n.slice(0,a).join(`/`)+`/`+r.slice(o).join(`/`)}var Gc={path:`/`,name:void 0,params:{},query:{},hash:``,fullPath:`/`,matched:[],meta:{},redirectedFrom:void 0},Kc=function(e){return e.pop=`pop`,e.push=`push`,e}({}),qc=function(e){return e.back=`back`,e.forward=`forward`,e.unknown=``,e}({});function Jc(e){if(!e)if(oc){let t=document.querySelector(`base`);e=t&&t.getAttribute(`href`)||`/`,e=e.replace(/^\w+:\/\/[^\/]+/,``)}else e=`/`;return e[0]!==`/`&&e[0]!==`#`&&(e=`/`+e),Fc(e)}var Yc=/^[^#]+#/;function Xc(e,t){return e.replace(Yc,`#`)+t}function Zc(e,t){let n=document.documentElement.getBoundingClientRect(),r=e.getBoundingClientRect();return{behavior:t.behavior,left:r.left-n.left-(t.left||0),top:r.top-n.top-(t.top||0)}}var Qc=()=>({left:window.scrollX,top:window.scrollY});function $c(e){let t;if(`el`in e){let n=e.el,r=typeof n==`string`&&n.startsWith(`#`),i=typeof n==`string`?r?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!i)return;t=Zc(i,e)}else t=e;`scrollBehavior`in document.documentElement.style?window.scrollTo(t):window.scrollTo(t.left==null?window.scrollX:t.left,t.top==null?window.scrollY:t.top)}function el(e,t){return(history.state?history.state.position-t:-1)+e}var tl=new Map;function nl(e,t){tl.set(e,t)}function rl(e){let t=tl.get(e);return tl.delete(e),t}function il(e){return typeof e==`string`||e&&typeof e==`object`}function al(e){return typeof e==`string`||typeof e==`symbol`}var Z=function(e){return e[e.MATCHER_NOT_FOUND=1]=`MATCHER_NOT_FOUND`,e[e.NAVIGATION_GUARD_REDIRECT=2]=`NAVIGATION_GUARD_REDIRECT`,e[e.NAVIGATION_ABORTED=4]=`NAVIGATION_ABORTED`,e[e.NAVIGATION_CANCELLED=8]=`NAVIGATION_CANCELLED`,e[e.NAVIGATION_DUPLICATED=16]=`NAVIGATION_DUPLICATED`,e}({}),ol=Symbol(``);Z.MATCHER_NOT_FOUND,Z.NAVIGATION_GUARD_REDIRECT,Z.NAVIGATION_ABORTED,Z.NAVIGATION_CANCELLED,Z.NAVIGATION_DUPLICATED;function sl(e,t){return X(Error(),{type:e,[ol]:!0},t)}function cl(e,t){return e instanceof Error&&ol in e&&(t==null||!!(e.type&t))}function ll(e){let t={};if(e===``||e===`?`)return t;let n=(e[0]===`?`?e.slice(1):e).split(`&`);for(let e=0;ee&&kc(e)):[r&&kc(r)]).forEach(e=>{e!==void 0&&(t+=(t.length?`&`:``)+n,e!=null&&(t+=`=`+e))})}return t}function dl(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=dc(r)?r.map(e=>e==null?null:``+e):r==null?r:``+r)}return t}var fl=Symbol(``),pl=Symbol(``),ml=Symbol(``),hl=Symbol(``),gl=Symbol(``);function _l(){let e=[];function t(t){return e.push(t),()=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)}}function n(){e=[]}return{add:t,list:()=>e.slice(),reset:n}}function vl(e,t,n,r,i,a=e=>e()){let o=r&&(r.enterCallbacks[i]=r.enterCallbacks[i]||[]);return()=>new Promise((s,c)=>{let l=e=>{e===!1?c(sl(Z.NAVIGATION_ABORTED,{from:n,to:t})):e instanceof Error?c(e):il(e)?c(sl(Z.NAVIGATION_GUARD_REDIRECT,{from:t,to:e})):(o&&r.enterCallbacks[i]===o&&typeof e==`function`&&o.push(e),s())},u=a(()=>e.call(r&&r.instances[i],t,n,l)),d=Promise.resolve(u);e.length<3&&(d=d.then(l)),d.catch(e=>c(e))})}function yl(e,t,n,r,i=e=>e()){let a=[];for(let o of e)for(let e in o.components){let s=o.components[e];if(!(t!==`beforeRouteEnter`&&!o.instances[e]))if(sc(s)){let c=(s.__vccOpts||s)[t];c&&a.push(vl(c,n,r,o,e,i))}else{let c=s();a.push(()=>c.then(a=>{if(!a)throw Error(`Couldn't resolve component "${e}" at "${o.path}"`);let s=cc(a)?a.default:a;o.mods[e]=a,o.components[e]=s;let c=(s.__vccOpts||s)[t];return c&&vl(c,n,r,o,e,i)()}))}}return a}function bl(e,t){let n=[],r=[],i=[],a=Math.max(t.matched.length,e.matched.length);for(let o=0;oBc(e,a))?r.push(a):n.push(a));let s=e.matched[o];s&&(t.matched.find(e=>Bc(e,s))||i.push(s))}return[n,r,i]}var xl=()=>location.protocol+`//`+location.host;function Sl(e,t){let{pathname:n,search:r,hash:i}=t,a=e.indexOf(`#`);if(a>-1){let t=i.includes(e.slice(a))?e.slice(a).length:1,n=i.slice(t);return n[0]!==`/`&&(n=`/`+n),Rc(n,``)}return Rc(n,e)+r+i}function Cl(e,t,n,r){let i=[],a=[],o=null,s=({state:a})=>{let s=Sl(e,location),c=n.value,l=t.value,u=0;if(a){if(n.value=s,t.value=a,o&&o===c){o=null;return}u=l?a.position-l.position:0}else r(s);i.forEach(e=>{e(n.value,c,{delta:u,type:Kc.pop,direction:u?u>0?qc.forward:qc.back:qc.unknown})})};function c(){o=n.value}function l(e){i.push(e);let t=()=>{let t=i.indexOf(e);t>-1&&i.splice(t,1)};return a.push(t),t}function u(){if(document.visibilityState===`hidden`){let{history:e}=window;if(!e.state)return;e.replaceState(X({},e.state,{scroll:Qc()}),``)}}function d(){for(let e of a)e();a=[],window.removeEventListener(`popstate`,s),window.removeEventListener(`pagehide`,u),document.removeEventListener(`visibilitychange`,u)}return window.addEventListener(`popstate`,s),window.addEventListener(`pagehide`,u),document.addEventListener(`visibilitychange`,u),{pauseListeners:c,listen:l,destroy:d}}function wl(e,t,n,r=!1,i=!1){return{back:e,current:t,forward:n,replaced:r,position:window.history.length,scroll:i?Qc():null}}function Tl(e){let{history:t,location:n}=window,r={value:Sl(e,n)},i={value:t.state};i.value||a(r.value,{back:null,current:r.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function a(r,a,o){let s=e.indexOf(`#`),c=s>-1?(n.host&&document.querySelector(`base`)?e:e.slice(s))+r:xl()+e+r;try{t[o?`replaceState`:`pushState`](a,``,c),i.value=a}catch(e){console.error(e),n[o?`replace`:`assign`](c)}}function o(e,n){a(e,X({},t.state,wl(i.value.back,e,i.value.forward,!0),n,{position:i.value.position}),!0),r.value=e}function s(e,n){let o=X({},i.value,t.state,{forward:e,scroll:Qc()});a(o.current,o,!0),a(e,X({},wl(r.value,e,null),{position:o.position+1},n),!1),r.value=e}return{location:r,state:i,push:s,replace:o}}function El(e){e=Jc(e);let t=Tl(e),n=Cl(e,t.state,t.location,t.replace);function r(e,t=!0){t||n.pauseListeners(),history.go(e)}let i=X({location:``,base:e,go:r,createHref:Xc.bind(null,e)},t,n);return Object.defineProperty(i,`location`,{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(i,`state`,{enumerable:!0,get:()=>t.state.value}),i}var Dl=function(e){return e[e.Static=0]=`Static`,e[e.Param=1]=`Param`,e[e.Group=2]=`Group`,e}({}),Q=function(e){return e[e.Static=0]=`Static`,e[e.Param=1]=`Param`,e[e.ParamRegExp=2]=`ParamRegExp`,e[e.ParamRegExpEnd=3]=`ParamRegExpEnd`,e[e.EscapeNext=4]=`EscapeNext`,e}(Q||{}),Ol={type:Dl.Static,value:``},kl=/[a-zA-Z0-9_]/;function Al(e){if(!e)return[[]];if(e===`/`)return[[Ol]];if(!e.startsWith(`/`))throw Error(`Invalid path "${e}"`);function t(e){throw Error(`ERR (${n})/"${l}": ${e}`)}let n=Q.Static,r=n,i=[],a;function o(){a&&i.push(a),a=[]}let s=0,c,l=``,u=``;function d(){l&&=(n===Q.Static?a.push({type:Dl.Static,value:l}):n===Q.Param||n===Q.ParamRegExp||n===Q.ParamRegExpEnd?(a.length>1&&(c===`*`||c===`+`)&&t(`A repeatable param (${l}) must be alone in its segment. eg: '/:ids+.`),a.push({type:Dl.Param,value:l,regexp:u,repeatable:c===`*`||c===`+`,optional:c===`*`||c===`?`})):t(`Invalid state to consume buffer`),``)}function f(){l+=c}for(;st.length?t.length===1&&t[0]===$.Static+$.Segment?1:-1:0}function Il(e,t){let n=0,r=e.score,i=t.score;for(;n0&&t[t.length-1]<0}var Rl={strict:!1,end:!0,sensitive:!1};function zl(e,t,n){let r=X(Pl(Al(e.path),n),{record:e,parent:t,children:[],alias:[]});return t&&!r.record.aliasOf==!t.record.aliasOf&&t.children.push(r),r}function Bl(e,t){let n=[],r=new Map;t=fc(Rl,t);function i(e){return r.get(e)}function a(e,n,r){let i=!r,s=Hl(e);s.aliasOf=r&&r.record;let l=fc(t,e),u=[s];if(`alias`in e){let t=typeof e.alias==`string`?[e.alias]:e.alias;for(let e of t)u.push(Hl(X({},s,{components:r?r.record.components:s.components,path:e,aliasOf:r?r.record:s})))}let d,f;for(let t of u){let{path:u}=t;if(n&&u[0]!==`/`){let e=n.record.path,r=e[e.length-1]===`/`?``:`/`;t.path=n.record.path+(u&&r+u)}if(d=zl(t,n,l),r?r.alias.push(d):(f||=d,f!==d&&f.alias.push(d),i&&e.name&&!Wl(d)&&o(e.name)),Jl(d)&&c(d),s.children){let e=s.children;for(let t=0;t{o(f)}:uc}function o(e){if(al(e)){let t=r.get(e);t&&(r.delete(e),n.splice(n.indexOf(t),1),t.children.forEach(o),t.alias.forEach(o))}else{let t=n.indexOf(e);t>-1&&(n.splice(t,1),e.record.name&&r.delete(e.record.name),e.children.forEach(o),e.alias.forEach(o))}}function s(){return n}function c(e){let t=Kl(e,n);n.splice(t,0,e),e.record.name&&!Wl(e)&&r.set(e.record.name,e)}function l(e,t){let i,a={},o,s;if(`name`in e&&e.name){if(i=r.get(e.name),!i)throw sl(Z.MATCHER_NOT_FOUND,{location:e});s=i.record.name,a=X(Vl(t.params,i.keys.filter(e=>!e.optional).concat(i.parent?i.parent.keys.filter(e=>e.optional):[]).map(e=>e.name)),e.params&&Vl(e.params,i.keys.map(e=>e.name))),o=i.stringify(a)}else if(e.path!=null)o=e.path,i=n.find(e=>e.re.test(o)),i&&(a=i.parse(o),s=i.record.name);else{if(i=t.name?r.get(t.name):n.find(e=>e.re.test(t.path)),!i)throw sl(Z.MATCHER_NOT_FOUND,{location:e,currentLocation:t});s=i.record.name,a=X({},t.params,e.params),o=i.stringify(a)}let c=[],l=i;for(;l;)c.unshift(l.record),l=l.parent;return{name:s,path:o,params:a,matched:c,meta:Gl(c)}}e.forEach(e=>a(e));function u(){n.length=0,r.clear()}return{addRoute:a,resolve:l,removeRoute:o,clearRoutes:u,getRoutes:s,getRecordMatcher:i}}function Vl(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Hl(e){let t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:Ul(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:`components`in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,`mods`,{value:{}}),t}function Ul(e){let t={},n=e.props||!1;if(`component`in e)t.default=n;else for(let r in e.components)t[r]=typeof n==`object`?n[r]:n;return t}function Wl(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function Gl(e){return e.reduce((e,t)=>X(e,t.meta),{})}function Kl(e,t){let n=0,r=t.length;for(;n!==r;){let i=n+r>>1;Il(e,t[i])<0?r=i:n=i+1}let i=ql(e);return i&&(r=t.lastIndexOf(i,r-1)),r}function ql(e){let t=e;for(;t=t.parent;)if(Jl(t)&&Il(e,t)===0)return t}function Jl({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function Yl(e){let t=Ee(ml),n=Ee(hl),r=M(()=>{let n=s(e.to);return t.resolve(n)}),i=M(()=>{let{matched:e}=r.value,{length:t}=e,i=e[t-1],a=n.matched;if(!i||!a.length)return-1;let o=a.findIndex(Bc.bind(null,i));if(o>-1)return o;let s=eu(e[t-2]);return t>1&&eu(i)===s&&a[a.length-1].path!==s?a.findIndex(Bc.bind(null,e[t-2])):o}),a=M(()=>i.value>-1&&$l(n.params,r.value.params)),o=M(()=>i.value>-1&&i.value===n.matched.length-1&&Vc(n.params,r.value.params));function c(n={}){if(Ql(n)){let n=t[s(e.replace)?`replace`:`push`](s(e.to)).catch(uc);return e.viewTransition&&typeof document<`u`&&`startViewTransition`in document&&document.startViewTransition(()=>n),n}return Promise.resolve()}return{route:r,href:M(()=>r.value.href),isActive:a,isExactActive:o,navigate:c}}function Xl(e){return e.length===1?e[0]:e}var Zl=ee({name:`RouterLink`,compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:`page`},viewTransition:Boolean},useLink:Yl,setup(e,{slots:t}){let r=n(Yl(e)),{options:i}=Ee(ml),a=M(()=>({[tu(e.activeClass,i.linkActiveClass,`router-link-active`)]:r.isActive,[tu(e.exactActiveClass,i.linkExactActiveClass,`router-link-exact-active`)]:r.isExactActive}));return()=>{let n=t.default&&Xl(t.default(r));return e.custom?n:E(`a`,{"aria-current":r.isExactActive?e.ariaCurrentValue:null,href:r.href,onClick:r.navigate,class:a.value},n)}}});function Ql(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){let t=e.currentTarget.getAttribute(`target`);if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function $l(e,t){for(let n in t){let r=t[n],i=e[n];if(typeof r==`string`){if(r!==i)return!1}else if(!dc(i)||i.length!==r.length||r.some((e,t)=>e.valueOf()!==i[t].valueOf()))return!1}return!0}function eu(e){return e?e.aliasOf?e.aliasOf.path:e.path:``}var tu=(e,t,n)=>e??t??n,nu=ee({name:`RouterView`,inheritAttrs:!1,props:{name:{type:String,default:`default`},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:n}){let r=Ee(gl),i=M(()=>e.route||r.value),a=Ee(pl,0),o=M(()=>{let e=s(a),{matched:t}=i.value,n;for(;(n=t[e])&&!n.components;)e++;return e}),c=M(()=>i.value.matched[o.value]);se(pl,M(()=>o.value+1)),se(fl,c),se(gl,i);let l=b();return f(()=>[l.value,c.value,e.name],([e,t,n],[r,i,a])=>{t&&(t.instances[n]=e,i&&i!==t&&e&&e===r&&(t.leaveGuards.size||(t.leaveGuards=i.leaveGuards),t.updateGuards.size||(t.updateGuards=i.updateGuards))),e&&t&&(!i||!Bc(t,i)||!r)&&(t.enterCallbacks[n]||[]).forEach(t=>t(e))},{flush:`post`}),()=>{let r=i.value,a=e.name,o=c.value,s=o&&o.components[a];if(!s)return ru(n.default,{Component:s,route:r});let u=o.props[a],d=E(s,X({},u?u===!0?r.params:typeof u==`function`?u(r):u:null,t,{onVnodeUnmounted:e=>{e.component.isUnmounted&&(o.instances[a]=null)},ref:l}));return ru(n.default,{Component:d,route:r})||d}}});function ru(e,t){if(!e)return null;let n=e(t);return n.length===1?n[0]:n}var iu=nu;function au(e){let t=Bl(e.routes,e),n=e.parseQuery||ll,i=e.stringifyQuery||ul,a=e.history,o=_l(),l=_l(),u=_l(),d=y(Gc),f=Gc;oc&&e.scrollBehavior&&`scrollRestoration`in history&&(history.scrollRestoration=`manual`);let p=lc.bind(null,e=>``+e),m=lc.bind(null,Mc),h=lc.bind(null,Nc);function g(e,n){let r,i;return al(e)?(r=t.getRecordMatcher(e),i=n):i=e,t.addRoute(i,r)}function _(e){let n=t.getRecordMatcher(e);n&&t.removeRoute(n)}function v(){return t.getRoutes().map(e=>e.record)}function b(e){return!!t.getRecordMatcher(e)}function x(e,r){if(r=X({},r||d.value),typeof e==`string`){let i=Ic(n,e,r.path),o=t.resolve({path:i.path},r),s=a.createHref(i.fullPath);return X(i,o,{params:h(o.params),hash:Nc(i.hash),redirectedFrom:void 0,href:s})}let o;if(e.path!=null)o=X({},e,{path:Ic(n,e.path,r.path).path});else{let t=X({},e.params);for(let e in t)t[e]??delete t[e];o=X({},e,{params:m(t)}),r.params=m(r.params)}let s=t.resolve(o,r),c=e.hash||``;s.params=p(h(s.params));let l=Lc(i,X({},e,{hash:Oc(c),path:s.path})),u=a.createHref(l);return X({fullPath:l,hash:c,query:i===ul?dl(e.query):e.query||{}},s,{redirectedFrom:void 0,href:u})}function S(e){return typeof e==`string`?Ic(n,e,d.value.path):X({},e)}function C(e,t){if(f!==e)return sl(Z.NAVIGATION_CANCELLED,{from:t,to:e})}function w(e){return T(e)}function ee(e){return w(X(S(e),{replace:!0}))}function te(e,t){let n=e.matched[e.matched.length-1];if(n&&n.redirect){let{redirect:r}=n,i=typeof r==`function`?r(e,t):r;return typeof i==`string`&&(i=i.includes(`?`)||i.includes(`#`)?i=S(i):{path:i},i.params={}),X({query:e.query,hash:e.hash,params:i.path==null?e.params:{}},i)}}function T(e,t){let n=f=x(e),r=d.value,a=e.state,o=e.force,s=e.replace===!0,c=te(n,r);if(c)return T(X(S(c),{state:typeof c==`object`?X({},a,c.state):a,force:o,replace:s}),t||n);let l=n;l.redirectedFrom=t;let u;return!o&&zc(i,r,n)&&(u=sl(Z.NAVIGATION_DUPLICATED,{to:l,from:r}),ce(r,r,!0,!1)),(u?Promise.resolve(u):ne(l,r)).catch(e=>cl(e)?cl(e,Z.NAVIGATION_GUARD_REDIRECT)?e:M(e):oe(e,l,r)).then(e=>{if(e){if(cl(e,Z.NAVIGATION_GUARD_REDIRECT))return T(X({replace:s},S(e.to),{state:typeof e.to==`object`?X({},a,e.to.state):a,force:o}),t||l)}else e=re(l,r,!0,s,a);return O(l,r,e),e})}function E(e,t){let n=C(e,t);return n?Promise.reject(n):Promise.resolve()}function D(e){let t=de.values().next().value;return t&&typeof t.runWithContext==`function`?t.runWithContext(e):e()}function ne(e,t){let n,[r,i,a]=bl(e,t);n=yl(r.reverse(),`beforeRouteLeave`,e,t);for(let i of r)i.leaveGuards.forEach(r=>{n.push(vl(r,e,t))});let s=E.bind(null,e,t);return n.push(s),pe(n).then(()=>{n=[];for(let r of o.list())n.push(vl(r,e,t));return n.push(s),pe(n)}).then(()=>{n=yl(i,`beforeRouteUpdate`,e,t);for(let r of i)r.updateGuards.forEach(r=>{n.push(vl(r,e,t))});return n.push(s),pe(n)}).then(()=>{n=[];for(let r of a)if(r.beforeEnter)if(dc(r.beforeEnter))for(let i of r.beforeEnter)n.push(vl(i,e,t));else n.push(vl(r.beforeEnter,e,t));return n.push(s),pe(n)}).then(()=>(e.matched.forEach(e=>e.enterCallbacks={}),n=yl(a,`beforeRouteEnter`,e,t,D),n.push(s),pe(n))).then(()=>{n=[];for(let r of l.list())n.push(vl(r,e,t));return n.push(s),pe(n)}).catch(e=>cl(e,Z.NAVIGATION_CANCELLED)?e:Promise.reject(e))}function O(e,t,n){u.list().forEach(r=>D(()=>r(e,t,n)))}function re(e,t,n,r,i){let o=C(e,t);if(o)return o;let s=t===Gc,c=oc?history.state:{};n&&(r||s?a.replace(e.fullPath,X({scroll:s&&c&&c.scroll},i)):a.push(e.fullPath,i)),d.value=e,ce(e,t,n,s),M()}let ie;function k(){ie||=a.listen((e,t,n)=>{if(!fe.listening)return;let r=x(e),i=te(r,fe.currentRoute.value);if(i){T(X(i,{replace:!0,force:!0}),r).catch(uc);return}f=r;let o=d.value;oc&&nl(el(o.fullPath,n.delta),Qc()),ne(r,o).catch(e=>cl(e,Z.NAVIGATION_ABORTED|Z.NAVIGATION_CANCELLED)?e:cl(e,Z.NAVIGATION_GUARD_REDIRECT)?(T(X(S(e.to),{force:!0}),r).then(e=>{cl(e,Z.NAVIGATION_ABORTED|Z.NAVIGATION_DUPLICATED)&&!n.delta&&n.type===Kc.pop&&a.go(-1,!1)}).catch(uc),Promise.reject()):(n.delta&&a.go(-n.delta,!1),oe(e,r,o))).then(e=>{e||=re(r,o,!1),e&&(n.delta&&!cl(e,Z.NAVIGATION_CANCELLED)?a.go(-n.delta,!1):n.type===Kc.pop&&cl(e,Z.NAVIGATION_ABORTED|Z.NAVIGATION_DUPLICATED)&&a.go(-1,!1)),O(r,o,e)}).catch(uc)})}let A=_l(),j=_l(),ae;function oe(e,t,n){M(e);let r=j.list();return r.length?r.forEach(r=>r(e,t,n)):console.error(e),Promise.reject(e)}function se(){return ae&&d.value!==Gc?Promise.resolve():new Promise((e,t)=>{A.add([e,t])})}function M(e){return ae||(ae=!e,k(),A.list().forEach(([t,n])=>e?n(e):t()),A.reset()),e}function ce(t,n,i,a){let{scrollBehavior:o}=e;if(!oc||!o)return Promise.resolve();let s=!i&&rl(el(t.fullPath,0))||(a||!i)&&history.state&&history.state.scroll||null;return r().then(()=>o(t,n,s)).then(e=>e&&$c(e)).catch(e=>oe(e,t,n))}let le=e=>a.go(e),ue,de=new Set,fe={currentRoute:d,listening:!0,addRoute:g,removeRoute:_,clearRoutes:t.clearRoutes,hasRoute:b,getRoutes:v,resolve:x,options:e,push:w,replace:ee,go:le,back:()=>le(-1),forward:()=>le(1),beforeEach:o.add,beforeResolve:l.add,afterEach:u.add,onError:j.add,isReady:se,install(e){e.component(`RouterLink`,Zl),e.component(`RouterView`,iu),e.config.globalProperties.$router=fe,Object.defineProperty(e.config.globalProperties,`$route`,{enumerable:!0,get:()=>s(d)}),oc&&!ue&&d.value===Gc&&(ue=!0,w(a.location).catch(e=>{}));let t={};for(let e in Gc)Object.defineProperty(t,e,{get:()=>d.value[e],enumerable:!0});e.provide(ml,fe),e.provide(hl,c(t)),e.provide(gl,d);let n=e.unmount;de.add(e),e.unmount=function(){de.delete(e),de.size<1&&(f=Gc,ie&&ie(),ie=null,d.value=Gc,ue=!1,ae=!1),n()}}};function pe(e){return e.reduce((e,t)=>e.then(()=>D(t)),Promise.resolve())}return fe}function ou(){return Ee(ml)}function su(e){return Ee(hl)}var cu=_e(`images`,()=>{let e=b([]),t=b(!1),n=b(null),r=b(0);async function i(r={}){r.silent||(t.value=!0),n.value=null;try{let t=await fetch(`/api/images`);if(!t.ok)throw Error(`Failed to load images`);e.value=await t.json()}catch(e){n.value=e instanceof Error?e.message:`Unknown error`}finally{t.value=!1}}async function a(t,n){let r=new FormData;r.append(`file`,t),n?.original&&r.append(`original`,n.original),n?.cropParams&&r.append(`cropParams`,JSON.stringify(n.cropParams)),n?.stickerState&&r.append(`stickerState`,JSON.stringify(n.stickerState)),n?.cropOrientation&&r.append(`cropOrientation`,n.cropOrientation);let i=await fetch(`/api/images`,{method:`POST`,body:r});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`Upload failed`)}let a=await i.json();return e.value.unshift(a),a}async function o(t,n,r){let i=new FormData;i.append(`file`,n),r?.cropParams&&i.append(`cropParams`,JSON.stringify(r.cropParams)),r?.stickerState&&i.append(`stickerState`,JSON.stringify(r.stickerState)),r?.cropOrientation&&i.append(`cropOrientation`,r.cropOrientation);let a=await fetch(`/api/images/${t}/reprocess`,{method:`POST`,body:i});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error??`Reprocess failed`)}let o=await a.json(),s=e.value.findIndex(e=>e.id===t);return s!==-1&&(e.value[s]=o),o}async function s(t){if(!(await fetch(`/api/images/${t}`,{method:`DELETE`})).ok)throw Error(`Delete failed`);e.value=e.value.filter(e=>e.id!==t)}async function c(t,n,r){let i=r?`POST`:`DELETE`,a=await fetch(`/api/images/${t}/approve/${n}`,{method:i});if(!a.ok)throw Error(`Failed to update approval`);let o=await a.json(),s=e.value.findIndex(e=>e.id===t);s!==-1&&(e.value[s]=o)}async function l(e,t=1,n=20){let r=new URLSearchParams({page:String(t),limit:String(n)});e&&r.set(`status`,e);let i=await fetch(`/api/shared-images?${r}`);if(!i.ok)throw Error(`Failed to load shared images`);return i.json()}async function u(){let e=await fetch(`/api/shared-images/pending-count`);e.ok&&(r.value=(await e.json()).count)}async function d(e,t){let n=await fetch(`/api/shared-images/${e}/approve`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({deviceIds:t})});if(!n.ok)throw Error(`Failed to approve`);return r.value>0&&r.value--,n.json()}async function f(e){let t=await fetch(`/api/shared-images/${e}/decline`,{method:`POST`});if(!t.ok)throw Error(`Failed to decline`);return r.value>0&&r.value--,t.json()}async function p(e,t){let n=await fetch(`/api/images/${e}/share`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recipientEmail:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`Failed to share`)}}return{images:e,loading:t,error:n,pendingCount:r,fetchImages:i,uploadImage:a,reprocessImage:o,deleteImage:s,setApproval:c,fetchSharedImages:l,fetchPendingCount:u,approveShared:d,declineShared:f,shareImage:p}}),lu={class:`bottom-nav`,"aria-label":`Main navigation`},uu={class:`bottom-nav__icon-wrap`,"aria-hidden":`true`},du=[`innerHTML`],fu={key:0,class:`bottom-nav__badge`},pu={class:`bottom-nav__label`},mu=be(ee({__name:`BottomNav`,setup(e){let n=su(),r=cu(),i=[{name:`home`,label:`Home`,to:`/`,icon:``,isActive:e=>e.path===`/`},{name:`library`,label:`Library`,to:`/library`,icon:``,isActive:e=>e.path.startsWith(`/library`)},{name:`settings`,label:`Settings`,to:`/settings`,icon:``,isActive:e=>e.path.startsWith(`/settings`)}];return(e,a)=>{let o=p(`RouterLink`);return m(),me(`nav`,lu,[(m(),me(fe,null,t(i,e=>A(o,{key:e.name,to:e.to,class:Ce([`bottom-nav__tab`,{"bottom-nav__tab--active":e.isActive(s(n))}]),"aria-label":e.label,"aria-current":e.isActive(s(n))?`page`:void 0},{default:_(()=>[Se(`span`,uu,[Se(`span`,{class:`bottom-nav__icon`,innerHTML:e.icon},null,8,du),e.name===`library`&&s(r).pendingCount>0?(m(),me(`span`,fu,k(s(r).pendingCount>9?`9+`:s(r).pendingCount),1)):ie(``,!0)]),Se(`span`,pu,k(e.label),1)]),_:2},1032,[`to`,`class`,`aria-label`,`aria-current`])),64))])}}}),[[`__scopeId`,`data-v-e670448a`]]),hu=0,gu=_e(`toast`,()=>{let e=b([]);function t(t,r=`info`){let i=++hu;e.value.push({id:i,message:t,type:r}),setTimeout(()=>n(i),2500)}function n(t){let n=e.value.findIndex(e=>e.id===t);n!==-1&&e.value.splice(n,1)}return{toasts:e,show:t,dismiss:n}}),_u={class:`toast-region`,"aria-live":`polite`,"aria-atomic":`false`},vu=[`onClick`],yu=be(ee({__name:`BaseToast`,setup(e){let n=gu();return(e,r)=>(m(),me(`div`,_u,[A(It,{name:`toast`,tag:`ul`,class:`toast-list`},{default:_(()=>[(m(!0),me(fe,null,t(s(n).toasts,e=>(m(),me(`li`,{key:e.id,class:Ce([`toast`,`toast--${e.type}`]),role:`status`},[j(k(e.message)+` `,1),Se(`button`,{class:`toast__close`,"aria-label":`Dismiss`,onClick:t=>s(n).dismiss(e.id)},` × `,8,vu)],2))),128))]),_:1})]))}}),[[`__scopeId`,`data-v-546af507`]]),bu=_e(`auth`,()=>{let e=b(window.__PF_USER__??null),t=M(()=>e.value!==null);function n(t){e.value=t}return{user:e,isAuthenticated:t,setUser:n}}),xu=[{id:`warm-craft`,label:`Warm Craft`,primary:`#c97c3a`,bg:`#fdf6ee`,text:`#3a2e22`},{id:`playful-pop`,label:`Playful Pop`,primary:`#d63aab`,bg:`#fff0fb`,text:`#2d0a28`},{id:`sage-cream`,label:`Sage & Cream`,primary:`#4e7c3a`,bg:`#f6f8f3`,text:`#1e2b1a`},{id:`dusty-mauve`,label:`Dusty Mauve`,primary:`#8e4a84`,bg:`#f6f0f4`,text:`#2a1828`},{id:`ocean-dusk`,label:`Ocean Dusk`,primary:`#1a6ea8`,bg:`#eef3f8`,text:`#0e2030`},{id:`honey-slate`,label:`Honey & Slate`,primary:`#c49a20`,bg:`#f2f2ee`,text:`#1c1c18`}];function Su(){let e=bu(),t=gu();function n(t){document.documentElement.dataset.theme=t,e.user&&(e.user.theme=t);let n=xu.find(e=>e.id===t);if(n){let e=document.querySelector(`meta[name="theme-color"]`);e&&e.setAttribute(`content`,n.bg)}}async function r(e){n(e);try{if(!(await fetch(`/api/user/theme`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({theme:e})})).ok)throw Error(`Failed to save theme`)}catch{t.show(`Could not save theme — try again`,`error`)}}return{THEMES:xu,applyTheme:n,saveTheme:r}}var Cu=ee({__name:`App`,setup(e){let t=su(),n=bu(),{applyTheme:r}=Su();return v(()=>{let e=document.documentElement.dataset.theme||n.user?.theme;e&&r(e)}),(e,n)=>{let r=p(`RouterView`);return m(),me(fe,null,[A(r),s(t).meta.hideNav?ie(``,!0):(m(),O(mu,{key:0})),A(yu)],64)}}}),wu=`modulepreload`,Tu=function(e){return`/build/`+e},Eu={},Du=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Tu(t,n),t in Eu)return;Eu[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:wu,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ou=au({history:El(),routes:[{path:`/`,name:`home`,component:()=>Du(()=>import(`./HomeView-NFtwfB9R.js`),__vite__mapDeps([0,1,2,3,4,5,6])),meta:{requiresAuth:!0}},{path:`/library`,name:`library`,component:()=>Du(()=>import(`./LibraryView-D6fwq_vN.js`),__vite__mapDeps([7,1,2,3,8,9,4,5,10])),meta:{requiresAuth:!0}},{path:`/upload`,name:`upload`,component:()=>Du(()=>import(`./UploadView-CjF1nTLf.js`),__vite__mapDeps([11,1,2,3,8,9,12])),meta:{requiresAuth:!0,hideNav:!0}},{path:`/settings`,name:`settings`,component:()=>Du(()=>import(`./SettingsView-9KXbjwsG.js`),__vite__mapDeps([13,1,14])),meta:{requiresAuth:!0}},{path:`/shared`,redirect:`/library?tab=shared`},{path:`/:pathMatch(.*)*`,redirect:`/`}]});Ou.beforeEach(e=>{let t=bu();if(e.meta.requiresAuth&&!t.isAuthenticated)return window.location.href=`/login`,!1});var ku=on(Cu);ku.use(ue()),ku.use(Ou),ku.use(ac),ku.mount(`#app`);export{cu as a,Ve as c,tn as d,$t as f,gu as i,Jt as l,Su as n,su as o,bu as r,ou as s,xu as t,qt as u}; \ No newline at end of file +`),t=+this.fontSize(),n=0,r=this.lineHeight()*t,i=this.attrs.width,a=this.attrs.height,o=i!==Ra&&i!==void 0,s=a!==Ra&&a!==void 0,c=this.padding(),l=i-c*2,u=a-c*2,d=0,f=this.wrap(),p=f!==ro&&f!==io,m=this.ellipsis();this.textArr=[],po().font=this._getContextFont();let h=m?this._getTextWidth(ao):0;for(let t=0,i=e.length;tl)for(;a.length>0;){let e=0,t=La(a).length,i=``,o=0;for(;e>>1,c=La(a).slice(0,n+1).join(``),f=this._getTextWidth(c);(m&&s&&d+r>u?f+h:f)<=l?(e=n+1,i=c,o=f):t=n}if(i){if(p){let t=La(a),n=La(i),r=t[n.length],s=r===$a||r===Wa,c;if(s&&o<=l)c=n.length;else{let e=n.lastIndexOf($a),t=n.lastIndexOf(Wa);c=Math.max(e,t)+1}c>0&&(e=c,i=t.slice(0,e).join(``),o=this._getTextWidth(i))}if(i=i.trimRight(),this._addTextLine(i),n=Math.max(n,o),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(a=La(a).slice(e).join(``).trimLeft(),a.length>0&&(c=this._getTextWidth(a),c<=l)){this._addTextLine(a),d+=r,n=Math.max(n,c);break}}else break}else this._addTextLine(a),d+=r,n=Math.max(n,c),this._shouldHandleEllipsis(d)&&tu)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){let t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==Ra&&r!==void 0,a=r-this.padding()*2;return this.wrap()===io||i&&e+n>a}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==Ra&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];!i||!r||(t&&(this._getTextWidth(i.text+ao)this.pathLength?null:W.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=W.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,this.textBaseline()),e.setAttr(`textAlign`,`left`),e.save();let t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,a=t.indexOf(`underline`)!==-1,o=t.indexOf(`line-through`)!==-1;a&&e.beginPath();for(let t=0;t=1){let n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;nthis.pathLength&&f-this.pathLength<=c?this.pathLength:f);if(!p)return;let m=W.getLineLength(r.x,r.y,p.x,p.y),h=0;if(s)try{h=s(t[n-1].char,i)*this.fontSize()}catch{h=0}r.x+=h,p.x+=h,this.textWidth+=h;let g=W.getPointOnLine(h+m/2,r.x,r.y,p.x,p.y),_=Math.atan2(p.y-r.y,p.x-r.x);this.glyphInfo.push({transposeX:g.x,transposeY:g.y,text:e[n],rotation:_,p0:r,p1:p,width:m}),d+=u}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};let e=[];this.glyphInfo.forEach(function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,i=e[1]||0,a,o;for(let s=0;se+`.${xo}`).join(` `),Co=`nodesRect`,wo=[`widthChange`,`heightChange`,`scaleXChange`,`scaleYChange`,`skewXChange`,`skewYChange`,`rotationChange`,`offsetXChange`,`offsetYChange`,`transformsEnabledChange`,`strokeWidthChange`,`draggableChange`],To={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},Eo=`ontouchstart`in N._global;function Do(e,t,n){if(e===`rotater`)return n;t+=F.degToRad(To[e]||0);let r=(F.radToDeg(t)%360+360)%360;return F._inRange(r,337.5,360)||F._inRange(r,0,22.5)?`ns-resize`:F._inRange(r,22.5,67.5)?`nesw-resize`:F._inRange(r,67.5,112.5)?`ew-resize`:F._inRange(r,112.5,157.5)?`nwse-resize`:F._inRange(r,157.5,202.5)?`ns-resize`:F._inRange(r,202.5,247.5)?`nesw-resize`:F._inRange(r,247.5,292.5)?`ew-resize`:F._inRange(r,292.5,337.5)?`nwse-resize`:(F.error(`Transformer has unknown angle for cursor detection: `+r),`pointer`)}var Oo=[`top-left`,`top-center`,`top-right`,`middle-right`,`middle-left`,`bottom-left`,`bottom-center`,`bottom-right`],ko=1e8;function Ao(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function jo(e,t,n){let r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function Mo(e,t){return jo(e,t,Ao(e))}function No(e,t,n){let r=t;for(let i=0;ie.isAncestorOf(this)?(F.error(`Konva.Transformer cannot be an a child of the node you are trying to attach`),!1):!0);return this._nodes=e=t,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(e=>{let t=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(e._attrsAffectingSize.length){let n=e._attrsAffectingSize.map(e=>e+`Change.`+this._getEventNamespace()).join(` `);e.on(n,t)}e.on(wo.map(e=>e+`.${this._getEventNamespace()}`).join(` `),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),this._proxyDrag(e)}),this._resetTransformCache(),this.findOne(`.top-left`)&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(`.back`)&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;let r=e.getAbsolutePosition(),i=r.x-t.x,a=r.y-t.y;this.nodes().forEach(t=>{if(t===e||t.isDragging())return;let r=t.getAbsolutePosition();t.setAbsolutePosition({x:r.x+i,y:r.y+a}),t.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off(`.`+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(Co),this._clearCache(`transform`),this._clearSelfAndDescendantCache(`absoluteTransform`)}_getNodeRect(){return this._getCache(Co,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){let r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),i=e.getAbsoluteScale(n),a=e.getAbsolutePosition(n),o=r.x*i.x-e.offsetX()*i.x,s=r.y*i.y-e.offsetY()*i.y,c=(N.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return jo({x:a.x+o*Math.cos(c)+s*Math.sin(-c),y:a.y+s*Math.cos(c)+o*Math.sin(c),width:r.width*i.x,height:r.height*i.y,rotation:c},-N.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-ko,y:-ko,width:0,height:0,rotation:0};let e=[];this.nodes().map(t=>{let n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],i=t.getAbsoluteTransform();r.forEach(function(t){let n=i.point(t);e.push(n)})});let t=new mn;t.rotate(-N.getAngle(this.rotation()));let n=1/0,r=1/0,i=-1/0,a=-1/0;e.forEach(function(e){let o=t.point(e);n===void 0&&(n=i=o.x,r=a=o.y),n=Math.min(n,o.x),r=Math.min(r,o.y),i=Math.max(i,o.x),a=Math.max(a,o.y)}),t.invert();let o=t.point({x:n,y:r});return{x:o.x,y:o.y,width:i-n,height:a-r,rotation:N.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Oo.forEach(e=>{this._createAnchor(e)}),this._createAnchor(`rotater`),this._elementsCreated=!0}_createAnchor(e){let t=new ja({stroke:`rgb(0, 161, 255)`,fill:`white`,strokeWidth:1,name:e+` _anchor`,dragDistance:0,draggable:!0,hitStrokeWidth:Eo?10:`auto`}),n=this;t.on(`mousedown touchstart`,function(e){n._handleMouseDown(e)}),t.on(`dragstart`,e=>{t.stopDrag(),e.cancelBubble=!0}),t.on(`dragend`,e=>{e.cancelBubble=!0}),t.on(`mouseenter`,()=>{let n=Do(e,N.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=n),this._cursorChange=!0}),t.on(`mouseout`,()=>{t.getStage().content&&(t.getStage().content.style.cursor=``),this._cursorChange=!1}),this.add(t)}_createBack(){let e=new U({name:`back`,width:0,height:0,sceneFunc(e,t){let n=t.getParent(),r=n.padding(),i=t.width(),a=t.height();if(e.beginPath(),e.rect(-r,-r,i+r*2,a+r*2),n.rotateEnabled()&&n.rotateLineVisible()){let t=n.rotateAnchorAngle(),r=n.rotateAnchorOffset(),o=F.degToRad(t),s=Math.sin(o),c=-Math.cos(o),l=i/2,u=a/2,d=1/0;c<0?d=Math.min(d,-u/c):c>0&&(d=Math.min(d,(a-u)/c)),s<0?d=Math.min(d,-l/s):s>0&&(d=Math.min(d,(i-l)/s));let f=l+s*d,p=u+c*d,m=F._sign(a),h=f+s*r*m,g=p+c*r*m;e.moveTo(f,p),e.lineTo(h,g)}e.fillStrokeShape(t)},hitFunc:(e,t)=>{if(!this.shouldOverdrawWholeArea())return;let n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+n*2,t.height()+n*2),e.fillStrokeShape(t)}});this.add(e),this._proxyDrag(e),e.on(`dragstart`,e=>{e.cancelBubble=!0}),e.on(`dragmove`,e=>{e.cancelBubble=!0}),e.on(`dragend`,e=>{e.cancelBubble=!0}),this.on(`dragmove`,e=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(` `)[0];let t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(n**2+r**2);this.sin=Math.abs(r/i),this.cos=Math.abs(n/i),typeof window<`u`&&(window.addEventListener(`mousemove`,this._handleMouseMove),window.addEventListener(`touchmove`,this._handleMouseMove),window.addEventListener(`mouseup`,this._handleMouseUp,!0),window.addEventListener(`touchend`,this._handleMouseUp,!0)),this._transforming=!0;let a=e.target.getAbsolutePosition(),o=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:o.x-a.x,y:o.y-a.y},Po++,this._fire(`transformstart`,{evt:e.evt,target:this.getNode()}),this._nodes.forEach(t=>{t._fire(`transformstart`,{evt:e.evt,target:t})})}_handleMouseMove(e){let t,n,r,i=this.findOne(`.`+this._movingAnchorName),a=i.getStage();a.setPointersPositions(e);let o=a.getPointerPosition(),s={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y},c=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(c,s,e)),i.setAbsolutePosition(s);let l=i.getAbsolutePosition();if(c.x===l.x&&c.y===l.y)return;if(this._movingAnchorName===`rotater`){let r=this._getNodeRect();t=i.x()-r.width/2,n=-i.y()+r.height/2;let a=N.getAngle(this.rotateAnchorAngle()),o=Math.atan2(-n,t)+Math.PI/2-a;r.height<0&&(o-=Math.PI);let s=N.getAngle(this.rotation())+o,c=N.getAngle(this.rotationSnapTolerance()),l=Mo(r,No(this.rotationSnaps(),s,c)-r.rotation);this._fitNodesInto(l,e);return}let u=this.shiftBehavior(),d;d=u===`inverted`?this.keepRatio()&&!e.shiftKey:u===`none`?this.keepRatio():this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey;if(this._movingAnchorName===`top-left`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.bottom-right`).x(),y:this.findOne(`.bottom-right`).y()};r=Math.sqrt((e.x-i.x())**2+(e.y-i.y())**2);let a=this.findOne(`.top-left`).x()>e.x?-1:1,o=this.findOne(`.top-left`).y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this.findOne(`.top-left`).x(e.x-t),this.findOne(`.top-left`).y(e.y-n)}}else if(this._movingAnchorName===`top-center`)this.findOne(`.top-left`).y(i.y());else if(this._movingAnchorName===`top-right`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.bottom-left`).x(),y:this.findOne(`.bottom-left`).y()};r=Math.sqrt((i.x()-e.x)**2+(e.y-i.y())**2);let a=this.findOne(`.top-right`).x()e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this.findOne(`.top-right`).x(e.x+t),this.findOne(`.top-right`).y(e.y-n)}var p=i.position();this.findOne(`.top-left`).y(p.y),this.findOne(`.bottom-right`).x(p.x)}else if(this._movingAnchorName===`middle-left`)this.findOne(`.top-left`).x(i.x());else if(this._movingAnchorName===`middle-right`)this.findOne(`.bottom-right`).x(i.x());else if(this._movingAnchorName===`bottom-left`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.top-right`).x(),y:this.findOne(`.top-right`).y()};r=Math.sqrt((e.x-i.x())**2+(i.y()-e.y)**2);let a=e.x{var n;t._fire(`transformend`,{evt:e,target:t}),(n=t.getLayer())==null||n.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){let n=this._getNodeRect();if(F._inRange(e.width,-this.padding()*2-1,1)){this.update();return}if(F._inRange(e.height,-this.padding()*2-1,1)){this.update();return}let r=new mn;if(r.rotate(N.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`left`)>=0){let t=r.point({x:-this.padding()*2,y:0});e.x+=t.x,e.y+=t.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace(`left`,`right`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`right`)>=0){let t=r.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace(`right`,`left`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`top`)>=0){let t=r.point({x:0,y:-this.padding()*2});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace(`top`,`bottom`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`bottom`)>=0){let t=r.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace(`bottom`,`top`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){let t=this.boundBoxFunc()(n,e);t?e=t:F.warn(`boundBoxFunc returned falsy. You should return new bound rect from it!`)}let i=1e7,a=new mn;a.translate(n.x,n.y),a.rotate(n.rotation),a.scale(n.width/i,n.height/i);let o=new mn,s=e.width/i,c=e.height/i;this.flipEnabled()===!1?(o.translate(e.x,e.y),o.rotate(e.rotation),o.translate(e.width<0?e.width:0,e.height<0?e.height:0),o.scale(Math.abs(s),Math.abs(c))):(o.translate(e.x,e.y),o.rotate(e.rotation),o.scale(s,c));let l=o.multiply(a.invert());this._nodes.forEach(e=>{var t;if(!e.getStage())return;let n=e.getParent().getAbsoluteTransform(),r=e.getTransform().copy();r.translate(e.offsetX(),e.offsetY());let i=new mn;i.multiply(n.copy().invert()).multiply(l).multiply(n).multiply(r);let a=i.decompose();e.setAttrs(a),(t=e.getLayer())==null||t.batchDraw()}),this.rotation(F._getRotation(e.rotation)),this._nodes.forEach(e=>{this._fire(`transform`,{evt:t,target:e}),e._fire(`transform`,{evt:t,target:e})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;let t=this._getNodeRect();this.rotation(F._getRotation(t.rotation));let n=t.width,r=t.height,i=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),s=this.anchorSize(),c=this.find(`._anchor`);c.forEach(e=>{e.setAttrs({width:s,height:s,offsetX:s/2,offsetY:s/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(`.top-left`,{x:0,y:0,offsetX:s/2+o,offsetY:s/2+o,visible:a&&i.indexOf(`top-left`)>=0}),this._batchChangeChild(`.top-center`,{x:n/2,y:0,offsetY:s/2+o,visible:a&&i.indexOf(`top-center`)>=0}),this._batchChangeChild(`.top-right`,{x:n,y:0,offsetX:s/2-o,offsetY:s/2+o,visible:a&&i.indexOf(`top-right`)>=0}),this._batchChangeChild(`.middle-left`,{x:0,y:r/2,offsetX:s/2+o,visible:a&&i.indexOf(`middle-left`)>=0}),this._batchChangeChild(`.middle-right`,{x:n,y:r/2,offsetX:s/2-o,visible:a&&i.indexOf(`middle-right`)>=0}),this._batchChangeChild(`.bottom-left`,{x:0,y:r,offsetX:s/2+o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-left`)>=0}),this._batchChangeChild(`.bottom-center`,{x:n/2,y:r,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-center`)>=0}),this._batchChangeChild(`.bottom-right`,{x:n,y:r,offsetX:s/2-o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-right`)>=0});let l=this.rotateAnchorAngle(),u=this.rotateAnchorOffset(),d=F.degToRad(l),f=Math.sin(d),p=-Math.cos(d),m=n/2,h=r/2,g=1/0;p<0?g=Math.min(g,-h/p):p>0&&(g=Math.min(g,(r-h)/p)),f<0?g=Math.min(g,-m/f):f>0&&(g=Math.min(g,(n-m)/f));let _=m+f*g,v=h+p*g,y=F._sign(r);this._batchChangeChild(`.rotater`,{x:_+f*u*y,y:v+p*u*y-o*p,visible:this.rotateEnabled()}),this._batchChangeChild(`.back`,{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(e=>e.draggable()),x:0,y:0});let b=this.anchorStyleFunc();b&&c.forEach(e=>{b(e)}),(e=this.getLayer())==null||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();let e=this.findOne(`.`+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=``),Gi.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(F.error(`You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.`),this):super.add(...e)}toObject(){return B.prototype.toObject.call(this)}clone(e){return B.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};q.isTransforming=()=>Po>0;function Fo(e){return e instanceof Array||F.warn(`enabledAnchors value should be an array`),e instanceof Array&&e.forEach(function(e){Oo.indexOf(e)===-1&&F.warn(`Unknown anchor name: `+e+`. Available names are: `+Oo.join(`, `))}),e||[]}q.prototype.className=`Transformer`,P(q),z.addGetterSetter(q,`enabledAnchors`,Oo,Fo),z.addGetterSetter(q,`flipEnabled`,!0,R()),z.addGetterSetter(q,`resizeEnabled`,!0),z.addGetterSetter(q,`anchorSize`,10,L()),z.addGetterSetter(q,`rotateEnabled`,!0),z.addGetterSetter(q,`rotateLineVisible`,!0),z.addGetterSetter(q,`rotationSnaps`,[]),z.addGetterSetter(q,`rotateAnchorOffset`,50,L()),z.addGetterSetter(q,`rotateAnchorAngle`,0,L()),z.addGetterSetter(q,`rotateAnchorCursor`,`crosshair`),z.addGetterSetter(q,`rotationSnapTolerance`,5,L()),z.addGetterSetter(q,`borderEnabled`,!0),z.addGetterSetter(q,`anchorStroke`,`rgb(0, 161, 255)`),z.addGetterSetter(q,`anchorStrokeWidth`,1,L()),z.addGetterSetter(q,`anchorFill`,`white`),z.addGetterSetter(q,`anchorCornerRadius`,0,L()),z.addGetterSetter(q,`borderStroke`,`rgb(0, 161, 255)`),z.addGetterSetter(q,`borderStrokeWidth`,1,L()),z.addGetterSetter(q,`borderDash`),z.addGetterSetter(q,`keepRatio`,!0),z.addGetterSetter(q,`shiftBehavior`,`default`),z.addGetterSetter(q,`centeredScaling`,!1),z.addGetterSetter(q,`ignoreStroke`,!1),z.addGetterSetter(q,`padding`,0,L()),z.addGetterSetter(q,`nodes`),z.addGetterSetter(q,`node`),z.addGetterSetter(q,`boundBoxFunc`),z.addGetterSetter(q,`anchorDragBoundFunc`),z.addGetterSetter(q,`anchorStyleFunc`),z.addGetterSetter(q,`shouldOverdrawWholeArea`,!1),z.addGetterSetter(q,`useSingleNodeRotation`,!0),z.backCompat(q,{lineEnabled:`borderEnabled`,rotateHandlerOffset:`rotateAnchorOffset`,enabledHandlers:`enabledAnchors`});var Io=class extends U{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,N.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Io.prototype.className=`Wedge`,Io.prototype._centroid=!0,Io.prototype._attrsAffectingSize=[`radius`],P(Io),z.addGetterSetter(Io,`radius`,0,L()),z.addGetterSetter(Io,`angle`,0,L()),z.addGetterSetter(Io,`clockwise`,!1),z.backCompat(Io,{angleDeg:`angle`,getAngleDeg:`getAngle`,setAngleDeg:`setAngle`});function Lo(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var Ro=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],zo=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function Bo(e,t){let n=e.data,r=e.width,i=e.height,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,ee=t+t+1,te=r-1,T=i-1,E=t+1,D=E*(E+1)/2,ne=new Lo,O=Ro[t],re=zo[t],ie=null,k=ne,A=null,j=null;for(let e=1;e>re,C===0?n[o]=n[o+1]=n[o+2]=0:(C=255/C,n[o]=(c*O>>re)*C,n[o+1]=(l*O>>re)*C,n[o+2]=(u*O>>re)*C),c-=f,l-=p,u-=m,d-=h,f-=A.r,p-=A.g,m-=A.b,h-=A.a,a=s+((a=e+t+1)>re,C>0?(C=255/C,n[a]=(c*O>>re)*C,n[a+1]=(l*O>>re)*C,n[a+2]=(u*O>>re)*C):n[a]=n[a+1]=n[a+2]=0,c-=f,l-=p,u-=m,d-=h,f-=A.r,p-=A.g,m-=A.b,h-=A.a,a=e+((a=t+E)0&&Bo(e,t)};z.addGetterSetter(B,`blurRadius`,0,L(),z.afterSetFilter);var Ho=function(e){let t=this.brightness()*255,n=e.data,r=n.length;for(let e=0;e255?255:i,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,n[e]=i,n[e+1]=a,n[e+2]=o};z.addGetterSetter(B,`contrast`,0,L(),z.afterSetFilter);var Go=function(e){let t=e.data,n=e.width,r=e.height,i=Math.min(1,Math.max(0,this.embossStrength?.call(this)??.5)),a=Math.min(1,Math.max(0,this.embossWhiteLevel?.call(this)??.5)),o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[this.embossDirection?.call(this)??`top-left`]??315,s=!!(this.embossBlend?.call(this)??!1),c=i*10,l=a*255,u=o*Math.PI/180,d=Math.cos(u),f=Math.sin(u),p=128/1020*c,m=new Uint8ClampedArray(t),h=new Float32Array(n*r);for(let e=0,n=0;ne<0?0:e>255?255:e;for(let e=1;ei&&(i=a),c=t[e+1],cs&&(s=c),d=t[e+2],du&&(u=d);i===r&&(i=255,r=0),s===o&&(s=255,o=0),u===l&&(u=255,l=0);let p,m,h,g,_,v;if(f>0)p=i+f*(255-i),m=r-f*(r-0),h=s+f*(255-s),g=o-f*(o-0),_=u+f*(255-u),v=l-f*(l-0);else{let e=(i+r)*.5;p=i+f*(i-e),m=r+f*(r-e);let t=(s+o)*.5;h=s+f*(s-t),g=o+f*(o-t);let n=(u+l)*.5;_=u+f*(u-n),v=l+f*(l-n)}for(let e=0;el?f:l;let p=o,m=a,h=360/m*Math.PI/180;for(let e=0;el?f:l;let p=o,m=a,h=n.polarRotation||0,g,_;for(u=0;ut&&(b=y,x=0,S=-1),i=0;i=0&&d=0&&f=0&&d=0&&f=1020?255:0}return o}function cs(e,t,n){let r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s=0&&d=0&&f=n))for(let t=f;t=r)continue;let i=(n*t+e)*4;a+=o[i+0],s+=o[i+1],c+=o[i+2],l+=o[i+3],m+=1}a/=m,s/=m,c/=m,l/=m;for(let e=u;e=n))for(let t=f;t=r)continue;let i=(n*t+e)*4;o[i+0]=a,o[i+1]=s,o[i+2]=c,o[i+3]=l}}};z.addGetterSetter(B,`pixelSize`,8,L(),z.afterSetFilter);var fs=function(e){let t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,i=255/t;for(let e=0;e255?255:e<0?0:Math.round(e)}),z.addGetterSetter(B,`green`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),z.addGetterSetter(B,`blue`,0,tr,z.afterSetFilter);var ms=function(e){let t=e.data,n=t.length,r=this.red(),i=this.green(),a=this.blue(),o=this.alpha();for(let e=0;e255?255:e<0?0:Math.round(e)}),z.addGetterSetter(B,`green`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),z.addGetterSetter(B,`blue`,0,tr,z.afterSetFilter),z.addGetterSetter(B,`alpha`,1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});var hs=function(e){let t=e.data,n=t.length;for(let e=0;e=128&&(t[e]=255-n,t[e+1]=255-r,t[e+2]=255-i)}return e},_s=function(e){let t=this.threshold()*255,n=e.data,r=n.length;for(let e=0;e{i(e.getAttr(r))})}}var Es=`V`;function Ds(e){function t(e){return e?.__konvaNode?e:e?.parent?t(e.parent):(console.error(`vue-konva error: Can not find parent node`),null)}return t(e.parent)}function Os(e){return e.component?e.component.__konvaNode||Os(e.component.subTree):null}function ks(e){let{el:t,component:n}=e,r=Os(e);if(t?.tagName&&n&&!r){let e=t.tagName.toLowerCase();return console.error(`vue-konva error: You are trying to render "${e}" inside your component tree. Looks like it is not a Konva node. You can render only Konva components inside the Stage.`),null}return r}function As(e){let t=e=>!!e&&typeof e==`object`&&`component`in e,n=e=>Array.isArray(e),r=e=>t(e)?[e,...r(e.children)]:n(e)?e.flatMap(r):[];return r(e.children)}function js(e,t){let n=As(e),r=[];n.forEach(e=>{let t=ks(e);t&&r.push(t)});let i=!1;r.forEach((e,t)=>{e.getZIndex()!==t&&(e.setZIndex(t),i=!0)}),i&&ys(t)}var Ms=vs.default?.Stage||vs.Stage,Ns=ee({name:`Stage`,props:{config:{type:Object,default:function(){return{}}},__useStrictMode:{type:Boolean}},inheritAttrs:!1,setup(e,{attrs:t,slots:r,expose:a}){let o=we();if(!o)return;let s=n({}),c=b(null),l=new Ms({width:e.config.width,height:e.config.height,container:document.createElement(`div`)});o.__konvaNode=l,p();function u(){return o?.__konvaNode}function d(){return o?.__konvaNode}function p(){if(!o)return;let n=s||{},r={...t,...e.config};Ss(o,r,n,e.__useStrictMode),Object.assign(s,r)}return v(()=>{c.value&&l.container(c.value),p(),Ts(l,o)}),i(()=>{p(),js(o.subTree,l),Ts(l,o)}),Te(()=>{l.destroy()}),f(()=>e.config,p,{deep:!0}),a({getStage:d,getNode:u}),()=>E(`div`,{ref:c,id:t?.id,accesskey:t?.accesskey,class:t?.class,role:t?.role,style:t?.style,tabindex:t?.tabindex,title:t?.title},r.default?.())}}),Ps=`.vue-konva-event`,Fs={Group:!0,Layer:!0,FastLayer:!0,Label:!0};function J(e,t){return ee({name:e,props:{config:{type:Object,default:function(){return{}}},__useStrictMode:{type:Boolean}},setup(r,{attrs:o,slots:s,expose:c}){let l=we();if(!l)return;let u=n({}),d=new t;l.__konvaNode=d,l.vnode.__konvaNode=d,h();function p(){return l?.__konvaNode}function m(){return l?.__konvaNode}function h(){if(!l)return;let e={};for(let t in l?.vnode.props)t.slice(0,2)===`on`&&(e[t]=l.vnode.props[t]);let t=u||{},n={...o,...r.config,...e};Ss(l,n,t,r.__useStrictMode),Object.assign(u,n)}v(()=>{let e=Ds(l)?.__konvaNode;e&&`add`in e&&e.add(d),ys(d),Ts(d,l)}),a(()=>{ys(d),d.destroy(),d.off(Ps),d.off(Cs)}),i(()=>{h(),js(l.subTree,d),Ts(d,l)}),f(()=>r.config,h,{deep:!0}),c({getStage:m,getNode:p});let g=Fs.hasOwnProperty(e);return()=>g?s.default?.():null}})}var Y=vs.default||vs,Is=J(`Arc`,Y.Arc),Ls=J(`Arrow`,Y.Arrow),Rs=J(`Circle`,Y.Circle),zs=J(`Ellipse`,Y.Ellipse),Bs=J(`FastLayer`,Y.FastLayer),Vs=J(`Group`,Y.Group),Hs=J(`Image`,Y.Image),Us=J(`Label`,Y.Label),Ws=J(`Layer`,Y.Layer),Gs=J(`Line`,Y.Line),Ks=J(`Path`,Y.Path),qs=J(`Rect`,Y.Rect),Js=J(`RegularPolygon`,Y.RegularPolygon),Ys=J(`Ring`,Y.Ring),Xs=J(`Shape`,Y.Shape),Zs=J(`Sprite`,Y.Sprite),Qs=J(`Star`,Y.Star),$s=J(`Tag`,Y.Tag),ec=J(`Text`,Y.Text),tc=J(`TextPath`,Y.TextPath),nc=J(`Transformer`,Y.Transformer),rc=J(`Wedge`,Y.Wedge),ic=Object.freeze(Object.defineProperty({__proto__:null,Arc:Is,Arrow:Ls,Circle:Rs,Ellipse:zs,FastLayer:Bs,Group:Vs,Image:Hs,Label:Us,Layer:Ws,Line:Gs,Path:Ks,Rect:qs,RegularPolygon:Js,Ring:Ys,Shape:Xs,Sprite:Zs,Star:Qs,Tag:$s,Text:ec,TextPath:tc,Transformer:nc,Wedge:rc},Symbol.toStringTag,{value:`Module`})),ac={install:(e,t)=>{let n=t?.prefix||Es,r=t?.customNodes?Object.entries(t.customNodes).map(([e,t])=>J(e,t)):[];[Ns,...Object.values(ic),...r].forEach(t=>{e.component(`${n}${t.name}`,t)})}},oc=typeof document<`u`;function sc(e){return typeof e==`object`||`displayName`in e||`props`in e||`__vccOpts`in e}function cc(e){return e.__esModule||e[Symbol.toStringTag]===`Module`||e.default&&sc(e.default)}var X=Object.assign;function lc(e,t){let n={};for(let r in t){let i=t[r];n[r]=dc(i)?i.map(e):e(i)}return n}var uc=()=>{},dc=Array.isArray;function fc(e,t){let n={};for(let r in e)n[r]=r in t?t[r]:e[r];return n}var pc=/#/g,mc=/&/g,hc=/\//g,gc=/=/g,_c=/\?/g,vc=/\+/g,yc=/%5B/g,bc=/%5D/g,xc=/%5E/g,Sc=/%60/g,Cc=/%7B/g,wc=/%7C/g,Tc=/%7D/g,Ec=/%20/g;function Dc(e){return e==null?``:encodeURI(``+e).replace(wc,`|`).replace(yc,`[`).replace(bc,`]`)}function Oc(e){return Dc(e).replace(Cc,`{`).replace(Tc,`}`).replace(xc,`^`)}function kc(e){return Dc(e).replace(vc,`%2B`).replace(Ec,`+`).replace(pc,`%23`).replace(mc,`%26`).replace(Sc,"`").replace(Cc,`{`).replace(Tc,`}`).replace(xc,`^`)}function Ac(e){return kc(e).replace(gc,`%3D`)}function jc(e){return Dc(e).replace(pc,`%23`).replace(_c,`%3F`)}function Mc(e){return jc(e).replace(hc,`%2F`)}function Nc(e){if(e==null)return null;try{return decodeURIComponent(``+e)}catch{}return``+e}var Pc=/\/$/,Fc=e=>e.replace(Pc,``);function Ic(e,t,n=`/`){let r,i={},a=``,o=``,s=t.indexOf(`#`),c=t.indexOf(`?`);return c=s>=0&&c>s?-1:c,c>=0&&(r=t.slice(0,c),a=t.slice(c,s>0?s:t.length),i=e(a.slice(1))),s>=0&&(r||=t.slice(0,s),o=t.slice(s,t.length)),r=Wc(r??t,n),{fullPath:r+a+o,path:r,query:i,hash:Nc(o)}}function Lc(e,t){let n=t.query?e(t.query):``;return t.path+(n&&`?`)+n+(t.hash||``)}function Rc(e,t){return!t||!e.toLowerCase().startsWith(t.toLowerCase())?e:e.slice(t.length)||`/`}function zc(e,t,n){let r=t.matched.length-1,i=n.matched.length-1;return r>-1&&r===i&&Bc(t.matched[r],n.matched[i])&&Vc(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function Bc(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function Vc(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n in e)if(!Hc(e[n],t[n]))return!1;return!0}function Hc(e,t){return dc(e)?Uc(e,t):dc(t)?Uc(t,e):e?.valueOf()===t?.valueOf()}function Uc(e,t){return dc(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):e.length===1&&e[0]===t}function Wc(e,t){if(e.startsWith(`/`))return e;if(!e)return t;let n=t.split(`/`),r=e.split(`/`),i=r[r.length-1];(i===`..`||i===`.`)&&r.push(``);let a=n.length-1,o,s;for(o=0;o1&&a--;else break;return n.slice(0,a).join(`/`)+`/`+r.slice(o).join(`/`)}var Gc={path:`/`,name:void 0,params:{},query:{},hash:``,fullPath:`/`,matched:[],meta:{},redirectedFrom:void 0},Kc=function(e){return e.pop=`pop`,e.push=`push`,e}({}),qc=function(e){return e.back=`back`,e.forward=`forward`,e.unknown=``,e}({});function Jc(e){if(!e)if(oc){let t=document.querySelector(`base`);e=t&&t.getAttribute(`href`)||`/`,e=e.replace(/^\w+:\/\/[^\/]+/,``)}else e=`/`;return e[0]!==`/`&&e[0]!==`#`&&(e=`/`+e),Fc(e)}var Yc=/^[^#]+#/;function Xc(e,t){return e.replace(Yc,`#`)+t}function Zc(e,t){let n=document.documentElement.getBoundingClientRect(),r=e.getBoundingClientRect();return{behavior:t.behavior,left:r.left-n.left-(t.left||0),top:r.top-n.top-(t.top||0)}}var Qc=()=>({left:window.scrollX,top:window.scrollY});function $c(e){let t;if(`el`in e){let n=e.el,r=typeof n==`string`&&n.startsWith(`#`),i=typeof n==`string`?r?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!i)return;t=Zc(i,e)}else t=e;`scrollBehavior`in document.documentElement.style?window.scrollTo(t):window.scrollTo(t.left==null?window.scrollX:t.left,t.top==null?window.scrollY:t.top)}function el(e,t){return(history.state?history.state.position-t:-1)+e}var tl=new Map;function nl(e,t){tl.set(e,t)}function rl(e){let t=tl.get(e);return tl.delete(e),t}function il(e){return typeof e==`string`||e&&typeof e==`object`}function al(e){return typeof e==`string`||typeof e==`symbol`}var Z=function(e){return e[e.MATCHER_NOT_FOUND=1]=`MATCHER_NOT_FOUND`,e[e.NAVIGATION_GUARD_REDIRECT=2]=`NAVIGATION_GUARD_REDIRECT`,e[e.NAVIGATION_ABORTED=4]=`NAVIGATION_ABORTED`,e[e.NAVIGATION_CANCELLED=8]=`NAVIGATION_CANCELLED`,e[e.NAVIGATION_DUPLICATED=16]=`NAVIGATION_DUPLICATED`,e}({}),ol=Symbol(``);Z.MATCHER_NOT_FOUND,Z.NAVIGATION_GUARD_REDIRECT,Z.NAVIGATION_ABORTED,Z.NAVIGATION_CANCELLED,Z.NAVIGATION_DUPLICATED;function sl(e,t){return X(Error(),{type:e,[ol]:!0},t)}function cl(e,t){return e instanceof Error&&ol in e&&(t==null||!!(e.type&t))}function ll(e){let t={};if(e===``||e===`?`)return t;let n=(e[0]===`?`?e.slice(1):e).split(`&`);for(let e=0;ee&&kc(e)):[r&&kc(r)]).forEach(e=>{e!==void 0&&(t+=(t.length?`&`:``)+n,e!=null&&(t+=`=`+e))})}return t}function dl(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=dc(r)?r.map(e=>e==null?null:``+e):r==null?r:``+r)}return t}var fl=Symbol(``),pl=Symbol(``),ml=Symbol(``),hl=Symbol(``),gl=Symbol(``);function _l(){let e=[];function t(t){return e.push(t),()=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)}}function n(){e=[]}return{add:t,list:()=>e.slice(),reset:n}}function vl(e,t,n,r,i,a=e=>e()){let o=r&&(r.enterCallbacks[i]=r.enterCallbacks[i]||[]);return()=>new Promise((s,c)=>{let l=e=>{e===!1?c(sl(Z.NAVIGATION_ABORTED,{from:n,to:t})):e instanceof Error?c(e):il(e)?c(sl(Z.NAVIGATION_GUARD_REDIRECT,{from:t,to:e})):(o&&r.enterCallbacks[i]===o&&typeof e==`function`&&o.push(e),s())},u=a(()=>e.call(r&&r.instances[i],t,n,l)),d=Promise.resolve(u);e.length<3&&(d=d.then(l)),d.catch(e=>c(e))})}function yl(e,t,n,r,i=e=>e()){let a=[];for(let o of e)for(let e in o.components){let s=o.components[e];if(!(t!==`beforeRouteEnter`&&!o.instances[e]))if(sc(s)){let c=(s.__vccOpts||s)[t];c&&a.push(vl(c,n,r,o,e,i))}else{let c=s();a.push(()=>c.then(a=>{if(!a)throw Error(`Couldn't resolve component "${e}" at "${o.path}"`);let s=cc(a)?a.default:a;o.mods[e]=a,o.components[e]=s;let c=(s.__vccOpts||s)[t];return c&&vl(c,n,r,o,e,i)()}))}}return a}function bl(e,t){let n=[],r=[],i=[],a=Math.max(t.matched.length,e.matched.length);for(let o=0;oBc(e,a))?r.push(a):n.push(a));let s=e.matched[o];s&&(t.matched.find(e=>Bc(e,s))||i.push(s))}return[n,r,i]}var xl=()=>location.protocol+`//`+location.host;function Sl(e,t){let{pathname:n,search:r,hash:i}=t,a=e.indexOf(`#`);if(a>-1){let t=i.includes(e.slice(a))?e.slice(a).length:1,n=i.slice(t);return n[0]!==`/`&&(n=`/`+n),Rc(n,``)}return Rc(n,e)+r+i}function Cl(e,t,n,r){let i=[],a=[],o=null,s=({state:a})=>{let s=Sl(e,location),c=n.value,l=t.value,u=0;if(a){if(n.value=s,t.value=a,o&&o===c){o=null;return}u=l?a.position-l.position:0}else r(s);i.forEach(e=>{e(n.value,c,{delta:u,type:Kc.pop,direction:u?u>0?qc.forward:qc.back:qc.unknown})})};function c(){o=n.value}function l(e){i.push(e);let t=()=>{let t=i.indexOf(e);t>-1&&i.splice(t,1)};return a.push(t),t}function u(){if(document.visibilityState===`hidden`){let{history:e}=window;if(!e.state)return;e.replaceState(X({},e.state,{scroll:Qc()}),``)}}function d(){for(let e of a)e();a=[],window.removeEventListener(`popstate`,s),window.removeEventListener(`pagehide`,u),document.removeEventListener(`visibilitychange`,u)}return window.addEventListener(`popstate`,s),window.addEventListener(`pagehide`,u),document.addEventListener(`visibilitychange`,u),{pauseListeners:c,listen:l,destroy:d}}function wl(e,t,n,r=!1,i=!1){return{back:e,current:t,forward:n,replaced:r,position:window.history.length,scroll:i?Qc():null}}function Tl(e){let{history:t,location:n}=window,r={value:Sl(e,n)},i={value:t.state};i.value||a(r.value,{back:null,current:r.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function a(r,a,o){let s=e.indexOf(`#`),c=s>-1?(n.host&&document.querySelector(`base`)?e:e.slice(s))+r:xl()+e+r;try{t[o?`replaceState`:`pushState`](a,``,c),i.value=a}catch(e){console.error(e),n[o?`replace`:`assign`](c)}}function o(e,n){a(e,X({},t.state,wl(i.value.back,e,i.value.forward,!0),n,{position:i.value.position}),!0),r.value=e}function s(e,n){let o=X({},i.value,t.state,{forward:e,scroll:Qc()});a(o.current,o,!0),a(e,X({},wl(r.value,e,null),{position:o.position+1},n),!1),r.value=e}return{location:r,state:i,push:s,replace:o}}function El(e){e=Jc(e);let t=Tl(e),n=Cl(e,t.state,t.location,t.replace);function r(e,t=!0){t||n.pauseListeners(),history.go(e)}let i=X({location:``,base:e,go:r,createHref:Xc.bind(null,e)},t,n);return Object.defineProperty(i,`location`,{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(i,`state`,{enumerable:!0,get:()=>t.state.value}),i}var Dl=function(e){return e[e.Static=0]=`Static`,e[e.Param=1]=`Param`,e[e.Group=2]=`Group`,e}({}),Q=function(e){return e[e.Static=0]=`Static`,e[e.Param=1]=`Param`,e[e.ParamRegExp=2]=`ParamRegExp`,e[e.ParamRegExpEnd=3]=`ParamRegExpEnd`,e[e.EscapeNext=4]=`EscapeNext`,e}(Q||{}),Ol={type:Dl.Static,value:``},kl=/[a-zA-Z0-9_]/;function Al(e){if(!e)return[[]];if(e===`/`)return[[Ol]];if(!e.startsWith(`/`))throw Error(`Invalid path "${e}"`);function t(e){throw Error(`ERR (${n})/"${l}": ${e}`)}let n=Q.Static,r=n,i=[],a;function o(){a&&i.push(a),a=[]}let s=0,c,l=``,u=``;function d(){l&&=(n===Q.Static?a.push({type:Dl.Static,value:l}):n===Q.Param||n===Q.ParamRegExp||n===Q.ParamRegExpEnd?(a.length>1&&(c===`*`||c===`+`)&&t(`A repeatable param (${l}) must be alone in its segment. eg: '/:ids+.`),a.push({type:Dl.Param,value:l,regexp:u,repeatable:c===`*`||c===`+`,optional:c===`*`||c===`?`})):t(`Invalid state to consume buffer`),``)}function f(){l+=c}for(;st.length?t.length===1&&t[0]===$.Static+$.Segment?1:-1:0}function Il(e,t){let n=0,r=e.score,i=t.score;for(;n0&&t[t.length-1]<0}var Rl={strict:!1,end:!0,sensitive:!1};function zl(e,t,n){let r=X(Pl(Al(e.path),n),{record:e,parent:t,children:[],alias:[]});return t&&!r.record.aliasOf==!t.record.aliasOf&&t.children.push(r),r}function Bl(e,t){let n=[],r=new Map;t=fc(Rl,t);function i(e){return r.get(e)}function a(e,n,r){let i=!r,s=Hl(e);s.aliasOf=r&&r.record;let l=fc(t,e),u=[s];if(`alias`in e){let t=typeof e.alias==`string`?[e.alias]:e.alias;for(let e of t)u.push(Hl(X({},s,{components:r?r.record.components:s.components,path:e,aliasOf:r?r.record:s})))}let d,f;for(let t of u){let{path:u}=t;if(n&&u[0]!==`/`){let e=n.record.path,r=e[e.length-1]===`/`?``:`/`;t.path=n.record.path+(u&&r+u)}if(d=zl(t,n,l),r?r.alias.push(d):(f||=d,f!==d&&f.alias.push(d),i&&e.name&&!Wl(d)&&o(e.name)),Jl(d)&&c(d),s.children){let e=s.children;for(let t=0;t{o(f)}:uc}function o(e){if(al(e)){let t=r.get(e);t&&(r.delete(e),n.splice(n.indexOf(t),1),t.children.forEach(o),t.alias.forEach(o))}else{let t=n.indexOf(e);t>-1&&(n.splice(t,1),e.record.name&&r.delete(e.record.name),e.children.forEach(o),e.alias.forEach(o))}}function s(){return n}function c(e){let t=Kl(e,n);n.splice(t,0,e),e.record.name&&!Wl(e)&&r.set(e.record.name,e)}function l(e,t){let i,a={},o,s;if(`name`in e&&e.name){if(i=r.get(e.name),!i)throw sl(Z.MATCHER_NOT_FOUND,{location:e});s=i.record.name,a=X(Vl(t.params,i.keys.filter(e=>!e.optional).concat(i.parent?i.parent.keys.filter(e=>e.optional):[]).map(e=>e.name)),e.params&&Vl(e.params,i.keys.map(e=>e.name))),o=i.stringify(a)}else if(e.path!=null)o=e.path,i=n.find(e=>e.re.test(o)),i&&(a=i.parse(o),s=i.record.name);else{if(i=t.name?r.get(t.name):n.find(e=>e.re.test(t.path)),!i)throw sl(Z.MATCHER_NOT_FOUND,{location:e,currentLocation:t});s=i.record.name,a=X({},t.params,e.params),o=i.stringify(a)}let c=[],l=i;for(;l;)c.unshift(l.record),l=l.parent;return{name:s,path:o,params:a,matched:c,meta:Gl(c)}}e.forEach(e=>a(e));function u(){n.length=0,r.clear()}return{addRoute:a,resolve:l,removeRoute:o,clearRoutes:u,getRoutes:s,getRecordMatcher:i}}function Vl(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Hl(e){let t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:Ul(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:`components`in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,`mods`,{value:{}}),t}function Ul(e){let t={},n=e.props||!1;if(`component`in e)t.default=n;else for(let r in e.components)t[r]=typeof n==`object`?n[r]:n;return t}function Wl(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function Gl(e){return e.reduce((e,t)=>X(e,t.meta),{})}function Kl(e,t){let n=0,r=t.length;for(;n!==r;){let i=n+r>>1;Il(e,t[i])<0?r=i:n=i+1}let i=ql(e);return i&&(r=t.lastIndexOf(i,r-1)),r}function ql(e){let t=e;for(;t=t.parent;)if(Jl(t)&&Il(e,t)===0)return t}function Jl({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function Yl(e){let t=Ee(ml),n=Ee(hl),r=M(()=>{let n=s(e.to);return t.resolve(n)}),i=M(()=>{let{matched:e}=r.value,{length:t}=e,i=e[t-1],a=n.matched;if(!i||!a.length)return-1;let o=a.findIndex(Bc.bind(null,i));if(o>-1)return o;let s=eu(e[t-2]);return t>1&&eu(i)===s&&a[a.length-1].path!==s?a.findIndex(Bc.bind(null,e[t-2])):o}),a=M(()=>i.value>-1&&$l(n.params,r.value.params)),o=M(()=>i.value>-1&&i.value===n.matched.length-1&&Vc(n.params,r.value.params));function c(n={}){if(Ql(n)){let n=t[s(e.replace)?`replace`:`push`](s(e.to)).catch(uc);return e.viewTransition&&typeof document<`u`&&`startViewTransition`in document&&document.startViewTransition(()=>n),n}return Promise.resolve()}return{route:r,href:M(()=>r.value.href),isActive:a,isExactActive:o,navigate:c}}function Xl(e){return e.length===1?e[0]:e}var Zl=ee({name:`RouterLink`,compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:`page`},viewTransition:Boolean},useLink:Yl,setup(e,{slots:t}){let r=n(Yl(e)),{options:i}=Ee(ml),a=M(()=>({[tu(e.activeClass,i.linkActiveClass,`router-link-active`)]:r.isActive,[tu(e.exactActiveClass,i.linkExactActiveClass,`router-link-exact-active`)]:r.isExactActive}));return()=>{let n=t.default&&Xl(t.default(r));return e.custom?n:E(`a`,{"aria-current":r.isExactActive?e.ariaCurrentValue:null,href:r.href,onClick:r.navigate,class:a.value},n)}}});function Ql(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){let t=e.currentTarget.getAttribute(`target`);if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function $l(e,t){for(let n in t){let r=t[n],i=e[n];if(typeof r==`string`){if(r!==i)return!1}else if(!dc(i)||i.length!==r.length||r.some((e,t)=>e.valueOf()!==i[t].valueOf()))return!1}return!0}function eu(e){return e?e.aliasOf?e.aliasOf.path:e.path:``}var tu=(e,t,n)=>e??t??n,nu=ee({name:`RouterView`,inheritAttrs:!1,props:{name:{type:String,default:`default`},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:n}){let r=Ee(gl),i=M(()=>e.route||r.value),a=Ee(pl,0),o=M(()=>{let e=s(a),{matched:t}=i.value,n;for(;(n=t[e])&&!n.components;)e++;return e}),c=M(()=>i.value.matched[o.value]);se(pl,M(()=>o.value+1)),se(fl,c),se(gl,i);let l=b();return f(()=>[l.value,c.value,e.name],([e,t,n],[r,i,a])=>{t&&(t.instances[n]=e,i&&i!==t&&e&&e===r&&(t.leaveGuards.size||(t.leaveGuards=i.leaveGuards),t.updateGuards.size||(t.updateGuards=i.updateGuards))),e&&t&&(!i||!Bc(t,i)||!r)&&(t.enterCallbacks[n]||[]).forEach(t=>t(e))},{flush:`post`}),()=>{let r=i.value,a=e.name,o=c.value,s=o&&o.components[a];if(!s)return ru(n.default,{Component:s,route:r});let u=o.props[a],d=E(s,X({},u?u===!0?r.params:typeof u==`function`?u(r):u:null,t,{onVnodeUnmounted:e=>{e.component.isUnmounted&&(o.instances[a]=null)},ref:l}));return ru(n.default,{Component:d,route:r})||d}}});function ru(e,t){if(!e)return null;let n=e(t);return n.length===1?n[0]:n}var iu=nu;function au(e){let t=Bl(e.routes,e),n=e.parseQuery||ll,i=e.stringifyQuery||ul,a=e.history,o=_l(),l=_l(),u=_l(),d=y(Gc),f=Gc;oc&&e.scrollBehavior&&`scrollRestoration`in history&&(history.scrollRestoration=`manual`);let p=lc.bind(null,e=>``+e),m=lc.bind(null,Mc),h=lc.bind(null,Nc);function g(e,n){let r,i;return al(e)?(r=t.getRecordMatcher(e),i=n):i=e,t.addRoute(i,r)}function _(e){let n=t.getRecordMatcher(e);n&&t.removeRoute(n)}function v(){return t.getRoutes().map(e=>e.record)}function b(e){return!!t.getRecordMatcher(e)}function x(e,r){if(r=X({},r||d.value),typeof e==`string`){let i=Ic(n,e,r.path),o=t.resolve({path:i.path},r),s=a.createHref(i.fullPath);return X(i,o,{params:h(o.params),hash:Nc(i.hash),redirectedFrom:void 0,href:s})}let o;if(e.path!=null)o=X({},e,{path:Ic(n,e.path,r.path).path});else{let t=X({},e.params);for(let e in t)t[e]??delete t[e];o=X({},e,{params:m(t)}),r.params=m(r.params)}let s=t.resolve(o,r),c=e.hash||``;s.params=p(h(s.params));let l=Lc(i,X({},e,{hash:Oc(c),path:s.path})),u=a.createHref(l);return X({fullPath:l,hash:c,query:i===ul?dl(e.query):e.query||{}},s,{redirectedFrom:void 0,href:u})}function S(e){return typeof e==`string`?Ic(n,e,d.value.path):X({},e)}function C(e,t){if(f!==e)return sl(Z.NAVIGATION_CANCELLED,{from:t,to:e})}function w(e){return T(e)}function ee(e){return w(X(S(e),{replace:!0}))}function te(e,t){let n=e.matched[e.matched.length-1];if(n&&n.redirect){let{redirect:r}=n,i=typeof r==`function`?r(e,t):r;return typeof i==`string`&&(i=i.includes(`?`)||i.includes(`#`)?i=S(i):{path:i},i.params={}),X({query:e.query,hash:e.hash,params:i.path==null?e.params:{}},i)}}function T(e,t){let n=f=x(e),r=d.value,a=e.state,o=e.force,s=e.replace===!0,c=te(n,r);if(c)return T(X(S(c),{state:typeof c==`object`?X({},a,c.state):a,force:o,replace:s}),t||n);let l=n;l.redirectedFrom=t;let u;return!o&&zc(i,r,n)&&(u=sl(Z.NAVIGATION_DUPLICATED,{to:l,from:r}),ce(r,r,!0,!1)),(u?Promise.resolve(u):ne(l,r)).catch(e=>cl(e)?cl(e,Z.NAVIGATION_GUARD_REDIRECT)?e:M(e):oe(e,l,r)).then(e=>{if(e){if(cl(e,Z.NAVIGATION_GUARD_REDIRECT))return T(X({replace:s},S(e.to),{state:typeof e.to==`object`?X({},a,e.to.state):a,force:o}),t||l)}else e=re(l,r,!0,s,a);return O(l,r,e),e})}function E(e,t){let n=C(e,t);return n?Promise.reject(n):Promise.resolve()}function D(e){let t=de.values().next().value;return t&&typeof t.runWithContext==`function`?t.runWithContext(e):e()}function ne(e,t){let n,[r,i,a]=bl(e,t);n=yl(r.reverse(),`beforeRouteLeave`,e,t);for(let i of r)i.leaveGuards.forEach(r=>{n.push(vl(r,e,t))});let s=E.bind(null,e,t);return n.push(s),pe(n).then(()=>{n=[];for(let r of o.list())n.push(vl(r,e,t));return n.push(s),pe(n)}).then(()=>{n=yl(i,`beforeRouteUpdate`,e,t);for(let r of i)r.updateGuards.forEach(r=>{n.push(vl(r,e,t))});return n.push(s),pe(n)}).then(()=>{n=[];for(let r of a)if(r.beforeEnter)if(dc(r.beforeEnter))for(let i of r.beforeEnter)n.push(vl(i,e,t));else n.push(vl(r.beforeEnter,e,t));return n.push(s),pe(n)}).then(()=>(e.matched.forEach(e=>e.enterCallbacks={}),n=yl(a,`beforeRouteEnter`,e,t,D),n.push(s),pe(n))).then(()=>{n=[];for(let r of l.list())n.push(vl(r,e,t));return n.push(s),pe(n)}).catch(e=>cl(e,Z.NAVIGATION_CANCELLED)?e:Promise.reject(e))}function O(e,t,n){u.list().forEach(r=>D(()=>r(e,t,n)))}function re(e,t,n,r,i){let o=C(e,t);if(o)return o;let s=t===Gc,c=oc?history.state:{};n&&(r||s?a.replace(e.fullPath,X({scroll:s&&c&&c.scroll},i)):a.push(e.fullPath,i)),d.value=e,ce(e,t,n,s),M()}let ie;function k(){ie||=a.listen((e,t,n)=>{if(!fe.listening)return;let r=x(e),i=te(r,fe.currentRoute.value);if(i){T(X(i,{replace:!0,force:!0}),r).catch(uc);return}f=r;let o=d.value;oc&&nl(el(o.fullPath,n.delta),Qc()),ne(r,o).catch(e=>cl(e,Z.NAVIGATION_ABORTED|Z.NAVIGATION_CANCELLED)?e:cl(e,Z.NAVIGATION_GUARD_REDIRECT)?(T(X(S(e.to),{force:!0}),r).then(e=>{cl(e,Z.NAVIGATION_ABORTED|Z.NAVIGATION_DUPLICATED)&&!n.delta&&n.type===Kc.pop&&a.go(-1,!1)}).catch(uc),Promise.reject()):(n.delta&&a.go(-n.delta,!1),oe(e,r,o))).then(e=>{e||=re(r,o,!1),e&&(n.delta&&!cl(e,Z.NAVIGATION_CANCELLED)?a.go(-n.delta,!1):n.type===Kc.pop&&cl(e,Z.NAVIGATION_ABORTED|Z.NAVIGATION_DUPLICATED)&&a.go(-1,!1)),O(r,o,e)}).catch(uc)})}let A=_l(),j=_l(),ae;function oe(e,t,n){M(e);let r=j.list();return r.length?r.forEach(r=>r(e,t,n)):console.error(e),Promise.reject(e)}function se(){return ae&&d.value!==Gc?Promise.resolve():new Promise((e,t)=>{A.add([e,t])})}function M(e){return ae||(ae=!e,k(),A.list().forEach(([t,n])=>e?n(e):t()),A.reset()),e}function ce(t,n,i,a){let{scrollBehavior:o}=e;if(!oc||!o)return Promise.resolve();let s=!i&&rl(el(t.fullPath,0))||(a||!i)&&history.state&&history.state.scroll||null;return r().then(()=>o(t,n,s)).then(e=>e&&$c(e)).catch(e=>oe(e,t,n))}let le=e=>a.go(e),ue,de=new Set,fe={currentRoute:d,listening:!0,addRoute:g,removeRoute:_,clearRoutes:t.clearRoutes,hasRoute:b,getRoutes:v,resolve:x,options:e,push:w,replace:ee,go:le,back:()=>le(-1),forward:()=>le(1),beforeEach:o.add,beforeResolve:l.add,afterEach:u.add,onError:j.add,isReady:se,install(e){e.component(`RouterLink`,Zl),e.component(`RouterView`,iu),e.config.globalProperties.$router=fe,Object.defineProperty(e.config.globalProperties,`$route`,{enumerable:!0,get:()=>s(d)}),oc&&!ue&&d.value===Gc&&(ue=!0,w(a.location).catch(e=>{}));let t={};for(let e in Gc)Object.defineProperty(t,e,{get:()=>d.value[e],enumerable:!0});e.provide(ml,fe),e.provide(hl,c(t)),e.provide(gl,d);let n=e.unmount;de.add(e),e.unmount=function(){de.delete(e),de.size<1&&(f=Gc,ie&&ie(),ie=null,d.value=Gc,ue=!1,ae=!1),n()}}};function pe(e){return e.reduce((e,t)=>e.then(()=>D(t)),Promise.resolve())}return fe}function ou(){return Ee(ml)}function su(e){return Ee(hl)}var cu=_e(`images`,()=>{let e=b([]),t=b(!1),n=b(null),r=b(0);async function i(r={}){r.silent||(t.value=!0),n.value=null;try{let t=await fetch(`/api/images`);if(!t.ok)throw Error(`Failed to load images`);e.value=await t.json()}catch(e){n.value=e instanceof Error?e.message:`Unknown error`}finally{t.value=!1}}async function a(t,n){let r=new FormData;r.append(`file`,t),n?.original&&r.append(`original`,n.original),n?.cropParams&&r.append(`cropParams`,JSON.stringify(n.cropParams)),n?.stickerState&&r.append(`stickerState`,JSON.stringify(n.stickerState)),n?.cropOrientation&&r.append(`cropOrientation`,n.cropOrientation);let i=await fetch(`/api/images`,{method:`POST`,body:r});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`Upload failed`)}let a=await i.json();return e.value.unshift(a),a}async function o(t,n,r){let i=new FormData;i.append(`file`,n),r?.cropParams&&i.append(`cropParams`,JSON.stringify(r.cropParams)),r?.stickerState&&i.append(`stickerState`,JSON.stringify(r.stickerState)),r?.cropOrientation&&i.append(`cropOrientation`,r.cropOrientation);let a=await fetch(`/api/images/${t}/reprocess`,{method:`POST`,body:i});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error??`Reprocess failed`)}let o=await a.json(),s=e.value.findIndex(e=>e.id===t);return s!==-1&&(e.value[s]=o),o}async function s(t){if(!(await fetch(`/api/images/${t}`,{method:`DELETE`})).ok)throw Error(`Delete failed`);e.value=e.value.filter(e=>e.id!==t)}async function c(t,n,r){let i=r?`POST`:`DELETE`,a=await fetch(`/api/images/${t}/approve/${n}`,{method:i});if(!a.ok)throw Error(`Failed to update approval`);let o=await a.json(),s=e.value.findIndex(e=>e.id===t);s!==-1&&(e.value[s]=o)}async function l(e,t=1,n=20){let r=new URLSearchParams({page:String(t),limit:String(n)});e&&r.set(`status`,e);let i=await fetch(`/api/shared-images?${r}`);if(!i.ok)throw Error(`Failed to load shared images`);return i.json()}async function u(){let e=await fetch(`/api/shared-images/pending-count`);e.ok&&(r.value=(await e.json()).count)}async function d(e,t){let n=await fetch(`/api/shared-images/${e}/approve`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({deviceIds:t})});if(!n.ok)throw Error(`Failed to approve`);return r.value>0&&r.value--,n.json()}async function f(e){let t=await fetch(`/api/shared-images/${e}/decline`,{method:`POST`});if(!t.ok)throw Error(`Failed to decline`);return r.value>0&&r.value--,t.json()}async function p(e,t){let n=await fetch(`/api/images/${e}/share`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recipientEmail:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`Failed to share`)}}return{images:e,loading:t,error:n,pendingCount:r,fetchImages:i,uploadImage:a,reprocessImage:o,deleteImage:s,setApproval:c,fetchSharedImages:l,fetchPendingCount:u,approveShared:d,declineShared:f,shareImage:p}}),lu={class:`bottom-nav`,"aria-label":`Main navigation`},uu={class:`bottom-nav__icon-wrap`,"aria-hidden":`true`},du=[`innerHTML`],fu={key:0,class:`bottom-nav__badge`},pu={class:`bottom-nav__label`},mu=be(ee({__name:`BottomNav`,setup(e){let n=su(),r=cu(),i=[{name:`home`,label:`Home`,to:`/`,icon:``,isActive:e=>e.path===`/`},{name:`library`,label:`Library`,to:`/library`,icon:``,isActive:e=>e.path.startsWith(`/library`)},{name:`settings`,label:`Settings`,to:`/settings`,icon:``,isActive:e=>e.path.startsWith(`/settings`)}];return(e,a)=>{let o=p(`RouterLink`);return m(),me(`nav`,lu,[(m(),me(fe,null,t(i,e=>A(o,{key:e.name,to:e.to,class:Ce([`bottom-nav__tab`,{"bottom-nav__tab--active":e.isActive(s(n))}]),"aria-label":e.label,"aria-current":e.isActive(s(n))?`page`:void 0},{default:_(()=>[Se(`span`,uu,[Se(`span`,{class:`bottom-nav__icon`,innerHTML:e.icon},null,8,du),e.name===`library`&&s(r).pendingCount>0?(m(),me(`span`,fu,k(s(r).pendingCount>9?`9+`:s(r).pendingCount),1)):ie(``,!0)]),Se(`span`,pu,k(e.label),1)]),_:2},1032,[`to`,`class`,`aria-label`,`aria-current`])),64))])}}}),[[`__scopeId`,`data-v-e670448a`]]),hu=0,gu=_e(`toast`,()=>{let e=b([]);function t(t,r=`info`){let i=++hu;e.value.push({id:i,message:t,type:r}),setTimeout(()=>n(i),2500)}function n(t){let n=e.value.findIndex(e=>e.id===t);n!==-1&&e.value.splice(n,1)}return{toasts:e,show:t,dismiss:n}}),_u={class:`toast-region`,"aria-live":`polite`,"aria-atomic":`false`},vu=[`onClick`],yu=be(ee({__name:`BaseToast`,setup(e){let n=gu();return(e,r)=>(m(),me(`div`,_u,[A(It,{name:`toast`,tag:`ul`,class:`toast-list`},{default:_(()=>[(m(!0),me(fe,null,t(s(n).toasts,e=>(m(),me(`li`,{key:e.id,class:Ce([`toast`,`toast--${e.type}`]),role:`status`},[j(k(e.message)+` `,1),Se(`button`,{class:`toast__close`,"aria-label":`Dismiss`,onClick:t=>s(n).dismiss(e.id)},` × `,8,vu)],2))),128))]),_:1})]))}}),[[`__scopeId`,`data-v-546af507`]]),bu=_e(`auth`,()=>{let e=b(window.__PF_USER__??null),t=M(()=>e.value!==null);function n(t){e.value=t}return{user:e,isAuthenticated:t,setUser:n}}),xu=[{id:`warm-craft`,label:`Warm Craft`,primary:`#c97c3a`,bg:`#fdf6ee`,text:`#3a2e22`},{id:`playful-pop`,label:`Playful Pop`,primary:`#d63aab`,bg:`#fff0fb`,text:`#2d0a28`},{id:`sage-cream`,label:`Sage & Cream`,primary:`#4e7c3a`,bg:`#f6f8f3`,text:`#1e2b1a`},{id:`dusty-mauve`,label:`Dusty Mauve`,primary:`#8e4a84`,bg:`#f6f0f4`,text:`#2a1828`},{id:`ocean-dusk`,label:`Ocean Dusk`,primary:`#1a6ea8`,bg:`#eef3f8`,text:`#0e2030`},{id:`honey-slate`,label:`Honey & Slate`,primary:`#c49a20`,bg:`#f2f2ee`,text:`#1c1c18`}];function Su(){let e=bu(),t=gu();function n(t){document.documentElement.dataset.theme=t,e.user&&(e.user.theme=t);let n=xu.find(e=>e.id===t);if(n){let e=document.querySelector(`meta[name="theme-color"]`);e&&e.setAttribute(`content`,n.bg)}}async function r(e){n(e);try{if(!(await fetch(`/api/user/theme`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({theme:e})})).ok)throw Error(`Failed to save theme`)}catch{t.show(`Could not save theme — try again`,`error`)}}return{THEMES:xu,applyTheme:n,saveTheme:r}}var Cu=ee({__name:`App`,setup(e){let t=su(),n=bu(),{applyTheme:r}=Su();return v(()=>{let e=document.documentElement.dataset.theme||n.user?.theme;e&&r(e)}),(e,n)=>{let r=p(`RouterView`);return m(),me(fe,null,[A(r),s(t).meta.hideNav?ie(``,!0):(m(),O(mu,{key:0})),A(yu)],64)}}}),wu=`modulepreload`,Tu=function(e){return`/build/`+e},Eu={},Du=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Tu(t,n),t in Eu)return;Eu[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:wu,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ou=au({history:El(),routes:[{path:`/`,name:`home`,component:()=>Du(()=>import(`./HomeView-_Dkprh5_.js`),__vite__mapDeps([0,1,2,3,4,5,6])),meta:{requiresAuth:!0}},{path:`/library`,name:`library`,component:()=>Du(()=>import(`./LibraryView-CiCcJhRw.js`),__vite__mapDeps([7,1,2,3,8,9,4,5,10])),meta:{requiresAuth:!0}},{path:`/upload`,name:`upload`,component:()=>Du(()=>import(`./UploadView-BGpSWlmP.js`),__vite__mapDeps([11,1,2,3,8,9,12])),meta:{requiresAuth:!0,hideNav:!0}},{path:`/settings`,name:`settings`,component:()=>Du(()=>import(`./SettingsView-w7VPfpOy.js`),__vite__mapDeps([13,1,14])),meta:{requiresAuth:!0}},{path:`/shared`,redirect:`/library?tab=shared`},{path:`/:pathMatch(.*)*`,redirect:`/`}]});Ou.beforeEach(e=>{let t=bu();if(e.meta.requiresAuth&&!t.isAuthenticated)return window.location.href=`/login`,!1});var ku=on(Cu);ku.use(ue()),ku.use(Ou),ku.use(ac),ku.mount(`#app`);export{cu as a,Ve as c,tn as d,$t as f,gu as i,Jt as l,Su as n,su as o,bu as r,ou as s,xu as t,qt as u}; \ No newline at end of file diff --git a/public/build/index.html b/public/build/index.html index 0d4dfe6..05cf671 100644 --- a/public/build/index.html +++ b/public/build/index.html @@ -14,7 +14,7 @@ - + diff --git a/src/Controller/DeviceApiController.php b/src/Controller/DeviceApiController.php index 899c7fd..ed9b319 100644 --- a/src/Controller/DeviceApiController.php +++ b/src/Controller/DeviceApiController.php @@ -183,6 +183,7 @@ class DeviceApiController extends AbstractController 'uniquenessWindow' => $d->getUniquenessWindow(), 'linkedAt' => $d->getLinkedAt()->format(\DateTimeInterface::ATOM), 'lastSeenAt' => $d->getLastSeenAt()?->format(\DateTimeInterface::ATOM), + 'nextPollExpectedAt' => $d->getNextPollExpectedAt()?->format(\DateTimeInterface::ATOM), 'lockedImageId' => $d->getLockedImage()?->getId(), 'currentImageId' => $d->getCurrentImage()?->getId(), ]; diff --git a/src/Controller/DeviceImageController.php b/src/Controller/DeviceImageController.php index f7e5ebe..a275f2b 100644 --- a/src/Controller/DeviceImageController.php +++ b/src/Controller/DeviceImageController.php @@ -61,6 +61,17 @@ class DeviceImageController extends AbstractController $currentImageId = (int) $request->headers->get('X-Current-Image-Id', '-1'); $device->markSeen(); + // Stamp when we expect the device to call back — the PWA reads this + // directly so its "next sync" label reflects the schedule the device + // is actually on, not the freshly-saved one that won't reach it + // until that next poll. + $device->setNextPollExpectedAt( + (new \DateTimeImmutable())->modify('+' . (int) ceil($intervalMs / 1000) . ' seconds') + ); + // Flush up-front so the 204/no_image/no_asset paths persist these too + // (they previously didn't flush at all — latent bug for lastSeenAt). + $em->flush(); + // Locked image bypasses rotation entirely. $image = $device->getLockedImage() ?? $this->rotation->advance($device); @@ -111,9 +122,6 @@ class DeviceImageController extends AbstractController // would otherwise have set this. Without the assignment, currentImage // stays stale — Home would keep showing the previous photo even // though the device has been confirming the new one for cycles. - // Also flush so markSeen() above is persisted on every 304 (lastSeenAt - // would otherwise freeze whenever the device polls and gets no - // change, causing the status badge to drift to "offline"). $device->setCurrentImage($image); $em->flush(); diff --git a/src/Entity/Device.php b/src/Entity/Device.php index 1d03d16..3ab3d04 100644 --- a/src/Entity/Device.php +++ b/src/Entity/Device.php @@ -71,6 +71,17 @@ class Device #[ORM\Column(nullable: true)] private ?\DateTimeImmutable $lastSeenAt = null; + /** + * Server-stamped wall-clock time at which the device is expected to poll + * next, computed as `now + computeIntervalMs($device)` at every successful + * response. The PWA reads this directly so the displayed "next sync" + * always reflects the schedule the device is *actually on* — not whatever + * the user just saved through the settings sheet (which the device won't + * pick up until that next poll). + */ + #[ORM\Column(nullable: true)] + private ?\DateTimeImmutable $nextPollExpectedAt = null; + /** * Orientation in effect when currentImage was last served as a 200 response. * Used alongside currentImage's id to decide whether a poll can be answered @@ -151,6 +162,9 @@ class Device public function getLastSeenAt(): ?\DateTimeImmutable { return $this->lastSeenAt; } public function markSeen(): static { $this->lastSeenAt = new \DateTimeImmutable(); return $this; } + public function getNextPollExpectedAt(): ?\DateTimeImmutable { return $this->nextPollExpectedAt; } + public function setNextPollExpectedAt(?\DateTimeImmutable $t): static { $this->nextPollExpectedAt = $t; return $this; } + public function getCurrentImageOrientation(): ?Orientation { return $this->currentImageOrientation; } public function setCurrentImageOrientation(?Orientation $o): static { $this->currentImageOrientation = $o; return $this; }