@stacksjs/stx 0.2.413 → 0.2.414

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/dist/appearance-bootstrap.js +1 -1
  2. package/dist/binding-manifest.d.ts +1 -1
  3. package/dist/bundle-analyzer.js +20 -20
  4. package/dist/chunk-020xyn9q.js +3 -0
  5. package/dist/chunk-04jhmfbz.js +2 -0
  6. package/dist/chunk-10957mcb.js +2 -0
  7. package/dist/chunk-1098mas0.js +2 -0
  8. package/dist/chunk-169n1vpx.js +12 -0
  9. package/dist/chunk-1b6t12hd.js +2 -0
  10. package/dist/chunk-1chw8xsw.js +2 -0
  11. package/dist/chunk-1xdzcy9d.js +14 -0
  12. package/dist/chunk-2ce7f416.js +2 -0
  13. package/dist/chunk-2gr351s0.js +7 -0
  14. package/dist/chunk-2mkcjw08.js +2 -0
  15. package/dist/chunk-2v8wztd5.js +2 -0
  16. package/dist/chunk-340a824p.js +2 -0
  17. package/dist/chunk-39g1134q.js +2 -0
  18. package/dist/chunk-3c74vag1.js +2 -0
  19. package/dist/chunk-3kthfs03.js +3 -0
  20. package/dist/chunk-3qn1wcdg.js +2 -0
  21. package/dist/chunk-3s2vnqcf.js +2 -0
  22. package/dist/chunk-48bwk47q.js +2 -0
  23. package/dist/chunk-4bjravgk.js +2 -0
  24. package/dist/chunk-4jjme6a5.js +2 -0
  25. package/dist/chunk-5g3y8kym.js +2 -0
  26. package/dist/chunk-5gsxpaqk.js +2 -0
  27. package/dist/{chunk-bwsxym3d.js → chunk-5qns2sdz.js} +17 -17
  28. package/dist/chunk-69mc2np8.js +2785 -0
  29. package/dist/chunk-6cfa3g0r.js +2 -0
  30. package/dist/{chunk-bjar18jd.js → chunk-6h38kkjf.js} +46 -52
  31. package/dist/chunk-6hc5vz20.js +3 -0
  32. package/dist/chunk-6q6g76vg.js +499 -0
  33. package/dist/{chunk-bwjxk1dw.js → chunk-6sgswrqw.js} +29 -29
  34. package/dist/chunk-6y8hnymb.js +2 -0
  35. package/dist/chunk-74j18qk0.js +930 -0
  36. package/dist/chunk-752hw7cd.js +4 -0
  37. package/dist/{chunk-kgd8kchy.js → chunk-765e1s44.js} +11 -76
  38. package/dist/chunk-7gkv67ky.js +4 -0
  39. package/dist/chunk-7z2ra0yf.js +2 -0
  40. package/dist/chunk-866n724v.js +2 -0
  41. package/dist/chunk-8nhshfz6.js +5 -0
  42. package/dist/chunk-92ps1xpk.js +2 -0
  43. package/dist/chunk-9g27ybyr.js +3 -0
  44. package/dist/{chunk-xq1acw1r.js → chunk-9pt8fd2n.js} +13 -13
  45. package/dist/{chunk-24zher49.js → chunk-9vrja6vp.js} +4 -4
  46. package/dist/chunk-9xrbve19.js +2 -0
  47. package/dist/chunk-a688m6js.js +3 -0
  48. package/dist/chunk-afhxw2t8.js +2 -0
  49. package/dist/chunk-ak1cgcah.js +5 -0
  50. package/dist/{chunk-4m7ajama.js → chunk-amd6ey3t.js} +14 -14
  51. package/dist/chunk-apg16xcn.js +2 -0
  52. package/dist/chunk-b52s5z0c.js +2 -0
  53. package/dist/chunk-b84h16er.js +61 -0
  54. package/dist/{chunk-hx998w7n.js → chunk-bay9s6rs.js} +13 -13
  55. package/dist/chunk-bmt7w2pk.js +2 -0
  56. package/dist/chunk-btmhj5t7.js +2 -0
  57. package/dist/chunk-ce1sejr3.js +3 -0
  58. package/dist/chunk-cg8hg6cs.js +3 -0
  59. package/dist/{chunk-4f9zyfdw.js → chunk-czxt605c.js} +4 -5
  60. package/dist/chunk-d44b9ktb.js +4 -0
  61. package/dist/chunk-daz5aqcf.js +24 -0
  62. package/dist/chunk-dgdm3hy3.js +2 -0
  63. package/dist/chunk-dvgv8nry.js +11 -0
  64. package/dist/chunk-dx7n22ed.js +2 -0
  65. package/dist/chunk-e57rhf65.js +3 -0
  66. package/dist/chunk-eed4fwps.js +3 -0
  67. package/dist/chunk-ej9j6k1q.js +3 -0
  68. package/dist/chunk-et0rr8c7.js +3 -0
  69. package/dist/chunk-f46qsp4m.js +4 -0
  70. package/dist/chunk-f6az0xj5.js +2 -0
  71. package/dist/{chunk-bjcsc6wx.js → chunk-fh1qrp68.js} +21 -21
  72. package/dist/chunk-fjs0a8h7.js +2 -0
  73. package/dist/chunk-fr2txj8q.js +829 -0
  74. package/dist/{chunk-xssw417m.js → chunk-ft4p6d28.js} +14 -14
  75. package/dist/chunk-fyzajkrx.js +2 -0
  76. package/dist/chunk-fzapbw9p.js +3 -0
  77. package/dist/chunk-g578mcb0.js +194 -0
  78. package/dist/chunk-gawrg4gb.js +216 -0
  79. package/dist/chunk-gw07qmjk.js +2 -0
  80. package/dist/chunk-h0atqq82.js +32 -0
  81. package/dist/chunk-h6zsqb9r.js +3 -0
  82. package/dist/{chunk-2snqdnk9.js → chunk-h85hrwkq.js} +13 -13
  83. package/dist/chunk-hbxz85wy.js +2 -0
  84. package/dist/chunk-hjg3ndgh.js +2 -0
  85. package/dist/chunk-hkxsewzk.js +2 -0
  86. package/dist/chunk-hrbbbtbn.js +2 -0
  87. package/dist/chunk-j03revz2.js +8 -0
  88. package/dist/chunk-j9qcrwbg.js +2 -0
  89. package/dist/chunk-jk4njz0w.js +2 -0
  90. package/dist/chunk-jmabeqfq.js +2 -0
  91. package/dist/chunk-jt0n43mk.js +2 -0
  92. package/dist/chunk-kjbv8a3m.js +2 -0
  93. package/dist/chunk-m1vdghnx.js +2 -0
  94. package/dist/chunk-m4sk62wb.js +5 -0
  95. package/dist/chunk-md8rqn48.js +30 -0
  96. package/dist/chunk-mepdnezf.js +17 -0
  97. package/dist/chunk-mhq0pjws.js +2 -0
  98. package/dist/chunk-mp6hy8g4.js +2 -0
  99. package/dist/chunk-ngc2wke4.js +3 -0
  100. package/dist/chunk-nn2vstke.js +2 -0
  101. package/dist/chunk-p2v2a68k.js +2 -0
  102. package/dist/{chunk-qn5srnj3.js → chunk-pbh4smw3.js} +16 -16
  103. package/dist/chunk-pdt69hpb.js +2 -0
  104. package/dist/chunk-pgzvyrv6.js +29 -0
  105. package/dist/chunk-pj1wg7jg.js +2 -0
  106. package/dist/chunk-pqxzp1bb.js +3 -0
  107. package/dist/chunk-px7fvbj6.js +3 -0
  108. package/dist/chunk-q4c06e8x.js +20 -0
  109. package/dist/chunk-q6vrb2pe.js +2 -0
  110. package/dist/chunk-q7qchkvk.js +2 -0
  111. package/dist/chunk-q9bdh4s5.js +8 -0
  112. package/dist/chunk-qet5gc6s.js +2033 -0
  113. package/dist/chunk-qz519eyp.js +2 -0
  114. package/dist/chunk-r3f9jcf7.js +5 -0
  115. package/dist/chunk-rs4v4fha.js +4 -0
  116. package/dist/chunk-s2x4wcrz.js +2 -0
  117. package/dist/chunk-s5xezjps.js +3 -0
  118. package/dist/chunk-scezfp0w.js +30 -0
  119. package/dist/chunk-sd321bn3.js +2 -0
  120. package/dist/{chunk-smcj3442.js → chunk-sd47dzs0.js} +79 -79
  121. package/dist/chunk-se7mwqd1.js +2 -0
  122. package/dist/chunk-shr559s7.js +3 -0
  123. package/dist/chunk-syaw6b75.js +2 -0
  124. package/dist/chunk-t4hzprsm.js +3 -0
  125. package/dist/{chunk-pv3d7sfn.js → chunk-t61vdbje.js} +89 -89
  126. package/dist/chunk-tfexmdkt.js +3 -0
  127. package/dist/chunk-thyt8ed8.js +6 -0
  128. package/dist/chunk-v091jft4.js +12 -0
  129. package/dist/chunk-v4vaqxrf.js +33 -0
  130. package/dist/chunk-vgvtnwxa.js +4 -0
  131. package/dist/chunk-x0q32ees.js +3 -0
  132. package/dist/chunk-x5bpeb4a.js +2 -0
  133. package/dist/chunk-x72tv2cg.js +3 -0
  134. package/dist/chunk-xfp7k0v8.js +64 -0
  135. package/dist/chunk-xtdw3692.js +6 -0
  136. package/dist/chunk-y1cmjvk3.js +43 -0
  137. package/dist/chunk-y5310237.js +311 -0
  138. package/dist/chunk-ya0qecph.js +27 -0
  139. package/dist/chunk-yazk54jr.js +8 -0
  140. package/dist/chunk-ydjfar14.js +2 -0
  141. package/dist/chunk-ym95v4nc.js +3 -0
  142. package/dist/chunk-ynvdvbat.js +18 -0
  143. package/dist/chunk-yvx1ap9b.js +3 -0
  144. package/dist/chunk-z0g9jvv0.js +40 -0
  145. package/dist/chunk-z6d0jmjb.js +2 -0
  146. package/dist/{chunk-8sdhs0zk.js → chunk-zhxdpzga.js} +4 -4
  147. package/dist/cli.js +110 -110
  148. package/dist/craft-entry.js +7 -7
  149. package/dist/craft.js +7 -7
  150. package/dist/database.js +2 -2
  151. package/dist/image-optimization/component.js +4 -4
  152. package/dist/media/image/component.js +5 -5
  153. package/dist/media/protected/component.js +2 -2
  154. package/dist/media/video/index.js +4 -4
  155. package/dist/native/bridge/protocol.d.ts +325 -0
  156. package/dist/native/bridge/protocol.js +219 -0
  157. package/dist/native/cli.d.ts +24 -0
  158. package/dist/native/cli.js +52 -0
  159. package/dist/native/compiler/bundle.d.ts +41 -0
  160. package/dist/native/compiler/bundle.js +90 -0
  161. package/dist/native/compiler/client-script.d.ts +8 -0
  162. package/dist/native/compiler/client-script.js +31 -0
  163. package/dist/native/compiler/codegen.d.ts +10 -0
  164. package/dist/native/compiler/codegen.js +145 -0
  165. package/dist/native/compiler/headwind-to-style.d.ts +395 -0
  166. package/dist/native/compiler/headwind-to-style.js +1163 -0
  167. package/dist/native/compiler/html-to-ir.d.ts +41 -0
  168. package/dist/native/compiler/html-to-ir.js +411 -0
  169. package/dist/native/compiler/icons.d.ts +220 -0
  170. package/dist/native/compiler/icons.js +208 -0
  171. package/dist/native/compiler/ir.d.ts +234 -0
  172. package/dist/native/compiler/ir.js +15 -0
  173. package/dist/native/compiler/parser.d.ts +88 -0
  174. package/dist/native/compiler/parser.js +753 -0
  175. package/dist/native/compiler/render-screen.d.ts +26 -0
  176. package/dist/native/compiler/render-screen.js +31 -0
  177. package/dist/native/components/primitives.d.ts +291 -0
  178. package/dist/native/components/primitives.js +22 -0
  179. package/dist/native/hot-reload/client.d.ts +62 -0
  180. package/dist/native/hot-reload/client.js +324 -0
  181. package/dist/native/index.d.ts +90 -0
  182. package/dist/native/index.js +34 -0
  183. package/dist/native/primitives/ActivityIndicator.stx +5 -0
  184. package/dist/native/primitives/Button.stx +5 -0
  185. package/dist/native/primitives/DatePicker.stx +5 -0
  186. package/dist/native/primitives/FlatList.stx +5 -0
  187. package/dist/native/primitives/Image.stx +5 -0
  188. package/dist/native/primitives/ImageBackground.stx +5 -0
  189. package/dist/native/primitives/KeyboardAvoidingView.stx +5 -0
  190. package/dist/native/primitives/Modal.stx +5 -0
  191. package/dist/native/primitives/Picker.stx +5 -0
  192. package/dist/native/primitives/Pressable.stx +5 -0
  193. package/dist/native/primitives/RefreshControl.stx +5 -0
  194. package/dist/native/primitives/SafeAreaView.stx +5 -0
  195. package/dist/native/primitives/ScrollView.stx +5 -0
  196. package/dist/native/primitives/SectionList.stx +5 -0
  197. package/dist/native/primitives/Slider.stx +5 -0
  198. package/dist/native/primitives/StatusBar.stx +5 -0
  199. package/dist/native/primitives/Switch.stx +5 -0
  200. package/dist/native/primitives/Text.stx +5 -0
  201. package/dist/native/primitives/TextInput.stx +5 -0
  202. package/dist/native/primitives/TouchableHighlight.stx +5 -0
  203. package/dist/native/primitives/TouchableOpacity.stx +5 -0
  204. package/dist/native/primitives/View.stx +5 -0
  205. package/dist/native/runtime/craft.d.ts +75 -0
  206. package/dist/native/runtime/craft.js +0 -0
  207. package/dist/native/runtime/entry.d.ts +1 -0
  208. package/dist/native/runtime/entry.js +3 -0
  209. package/dist/native/runtime/index.d.ts +45 -0
  210. package/dist/native/runtime/index.js +165 -0
  211. package/dist/native/runtime/native-host.d.ts +33 -0
  212. package/dist/native/runtime/native-host.js +184 -0
  213. package/dist/native/runtime/screen.d.ts +43 -0
  214. package/dist/native/runtime/screen.js +808 -0
  215. package/dist/pwa/service-worker.js +1 -1
  216. package/dist/pwa/workbox.js +1 -1
  217. package/dist/pwa.js +8 -8
  218. package/dist/site-url.d.ts +1 -1
  219. package/dist/ssg.js +53 -53
  220. package/dist/visual-testing.js +42 -42
  221. package/dist/web-components/reactive-generator.js +2 -2
  222. package/package.json +9 -5
  223. package/dist/chunk-0btmm4m2.js +0 -147
  224. package/dist/chunk-0c2h69k2.js +0 -4
  225. package/dist/chunk-0d0qeqvv.js +0 -2
  226. package/dist/chunk-0psndabd.js +0 -2
  227. package/dist/chunk-0qv8yf53.js +0 -2
  228. package/dist/chunk-0vkxyvsd.js +0 -2
  229. package/dist/chunk-0we9nw1d.js +0 -3
  230. package/dist/chunk-0xqdmemy.js +0 -3
  231. package/dist/chunk-0y46fbkx.js +0 -3
  232. package/dist/chunk-158wqccn.js +0 -4422
  233. package/dist/chunk-1cyxbb8y.js +0 -16
  234. package/dist/chunk-1enwnh2a.js +0 -2
  235. package/dist/chunk-213pzm0d.js +0 -3
  236. package/dist/chunk-21hzqyja.js +0 -12
  237. package/dist/chunk-266t58b8.js +0 -5
  238. package/dist/chunk-27fgag95.js +0 -4
  239. package/dist/chunk-2a9n102n.js +0 -2
  240. package/dist/chunk-2eqzrczk.js +0 -2
  241. package/dist/chunk-2ke37m54.js +0 -14
  242. package/dist/chunk-35ds08e7.js +0 -3
  243. package/dist/chunk-3mtwkjcg.js +0 -2
  244. package/dist/chunk-4xr8zwkp.js +0 -2
  245. package/dist/chunk-58v77x2c.js +0 -2
  246. package/dist/chunk-5mhq8605.js +0 -2
  247. package/dist/chunk-5se8xt9e.js +0 -64
  248. package/dist/chunk-5zh0h080.js +0 -2
  249. package/dist/chunk-62435225.js +0 -2
  250. package/dist/chunk-6kdrncsx.js +0 -30
  251. package/dist/chunk-6n2rr3x7.js +0 -2
  252. package/dist/chunk-6xk87qf2.js +0 -30
  253. package/dist/chunk-72rwcbp6.js +0 -3
  254. package/dist/chunk-76w34xne.js +0 -3
  255. package/dist/chunk-7ekd7zj9.js +0 -2
  256. package/dist/chunk-7pr3wdd5.js +0 -3
  257. package/dist/chunk-7rxvafwc.js +0 -24
  258. package/dist/chunk-7tnwfa7w.js +0 -8
  259. package/dist/chunk-8c5je0wf.js +0 -2
  260. package/dist/chunk-8dz6nyvx.js +0 -2
  261. package/dist/chunk-98zj3fv2.js +0 -7
  262. package/dist/chunk-9e8t0twa.js +0 -3
  263. package/dist/chunk-9fqp72ze.js +0 -5
  264. package/dist/chunk-anydpa34.js +0 -3
  265. package/dist/chunk-ay6zjq8v.js +0 -3
  266. package/dist/chunk-az4v4ard.js +0 -3
  267. package/dist/chunk-ba5erggg.js +0 -2
  268. package/dist/chunk-bnagrdz6.js +0 -2
  269. package/dist/chunk-by8wghtf.js +0 -2
  270. package/dist/chunk-cd7h4q51.js +0 -2
  271. package/dist/chunk-cjmv8hgp.js +0 -33
  272. package/dist/chunk-cthf912y.js +0 -2
  273. package/dist/chunk-cxbpmwq5.js +0 -4
  274. package/dist/chunk-d3sy16qn.js +0 -2
  275. package/dist/chunk-dh6s7mrj.js +0 -1199
  276. package/dist/chunk-dm2nzg7a.js +0 -2
  277. package/dist/chunk-e2sgcnxc.js +0 -2
  278. package/dist/chunk-e3b7jj74.js +0 -2
  279. package/dist/chunk-ec4wq2sv.js +0 -6
  280. package/dist/chunk-ekzg97dn.js +0 -29
  281. package/dist/chunk-epjt342x.js +0 -2
  282. package/dist/chunk-eqe26g14.js +0 -18
  283. package/dist/chunk-ev0v1yma.js +0 -2
  284. package/dist/chunk-f53psr2y.js +0 -5
  285. package/dist/chunk-f8p69dsg.js +0 -3
  286. package/dist/chunk-f95drhdb.js +0 -194
  287. package/dist/chunk-ff5a6hvb.js +0 -17
  288. package/dist/chunk-fs5fy4h8.js +0 -2
  289. package/dist/chunk-fzsygce3.js +0 -2
  290. package/dist/chunk-g465x63k.js +0 -2
  291. package/dist/chunk-g708ekh1.js +0 -2
  292. package/dist/chunk-gcr9e83g.js +0 -11
  293. package/dist/chunk-gdmyrsr8.js +0 -4
  294. package/dist/chunk-gkms2ngq.js +0 -2
  295. package/dist/chunk-gnfywmgs.js +0 -7
  296. package/dist/chunk-hpf8kq7e.js +0 -2
  297. package/dist/chunk-j4x3faf8.js +0 -2
  298. package/dist/chunk-jkavtw9f.js +0 -2
  299. package/dist/chunk-kg1rdena.js +0 -3
  300. package/dist/chunk-km91wx0v.js +0 -2
  301. package/dist/chunk-kmsyvaex.js +0 -8
  302. package/dist/chunk-mrahwn5v.js +0 -8
  303. package/dist/chunk-nk3czvnk.js +0 -2
  304. package/dist/chunk-nmw4eewb.js +0 -2
  305. package/dist/chunk-nq5zxrk0.js +0 -4
  306. package/dist/chunk-ny67c03k.js +0 -3
  307. package/dist/chunk-p4wdxp2c.js +0 -2
  308. package/dist/chunk-pcxp4r9n.js +0 -3
  309. package/dist/chunk-pdyeaxc1.js +0 -2
  310. package/dist/chunk-pf06ded4.js +0 -2
  311. package/dist/chunk-pfs0gpzm.js +0 -2
  312. package/dist/chunk-pshdwq44.js +0 -2
  313. package/dist/chunk-pwgv84pn.js +0 -32
  314. package/dist/chunk-pwsnafp3.js +0 -4367
  315. package/dist/chunk-q9n5swx7.js +0 -3
  316. package/dist/chunk-qr346wnp.js +0 -2
  317. package/dist/chunk-r02hke04.js +0 -2
  318. package/dist/chunk-ranshpyc.js +0 -3
  319. package/dist/chunk-rn194bhp.js +0 -20
  320. package/dist/chunk-rn1hgyc8.js +0 -930
  321. package/dist/chunk-s7z5dp70.js +0 -43
  322. package/dist/chunk-s8jd13nb.js +0 -3
  323. package/dist/chunk-sn7exv0n.js +0 -2
  324. package/dist/chunk-t1tdjjht.js +0 -216
  325. package/dist/chunk-t6qx04s8.js +0 -499
  326. package/dist/chunk-t6y6gyps.js +0 -2
  327. package/dist/chunk-tjfs7cc3.js +0 -2
  328. package/dist/chunk-tkyrk66a.js +0 -3
  329. package/dist/chunk-tntv9hvq.js +0 -2
  330. package/dist/chunk-v3nwkveg.js +0 -12
  331. package/dist/chunk-vd4cb5xr.js +0 -2
  332. package/dist/chunk-vkhdce50.js +0 -2
  333. package/dist/chunk-w183av08.js +0 -2
  334. package/dist/chunk-w2m02njv.js +0 -2
  335. package/dist/chunk-wpjrcrs5.js +0 -2
  336. package/dist/chunk-wqmppf6b.js +0 -3
  337. package/dist/chunk-wtb9fxdy.js +0 -2
  338. package/dist/chunk-xmzygmcz.js +0 -3
  339. package/dist/chunk-xsng1mtq.js +0 -3
  340. package/dist/chunk-xxzefj4j.js +0 -2
  341. package/dist/chunk-yq8x8bxq.js +0 -47
  342. package/dist/chunk-ytma76qe.js +0 -3
  343. package/dist/chunk-yw1m115e.js +0 -2
  344. package/dist/chunk-z64a924m.js +0 -2
  345. package/dist/chunk-zcz9rs6p.js +0 -3
@@ -0,0 +1,829 @@
1
+ // @bun
2
+ import{ae,pt,Hr}from"./chunk-thyt8ed8.js";function Mn(e,a){let t=e.pwa;if(!t?.enabled)return"";let c=t.serviceWorker||{},d=t.routes||[],i=c.cacheVersion||"1.0.0",o=t.offline,l=o?.page?"/offline.html":"/offline.html",{push:r,backgroundSync:s,cacheStorage:n}=t,u=a?ae(a,e):null,h=u?pt(u):"[]",f=["/","/manifest.json",...o?.enabled?[l]:[],...o?.precacheAssets||[]];return`/**
3
+ * Service Worker - Auto-generated by stx
4
+ * Cache Version: ${i}
5
+ *
6
+ * This service worker implements configurable caching strategies:
7
+ * - cache-first: Serve from cache, fall back to network
8
+ * - network-first: Try network, fall back to cache
9
+ * - stale-while-revalidate: Serve cached, update in background
10
+ * - network-only: Always fetch from network
11
+ * - cache-only: Only serve from cache
12
+ *
13
+ * Additional features:
14
+ * - Push notifications: ${r?.enabled?"enabled":"disabled"}
15
+ * - Background sync: ${s?.enabled?"enabled":"disabled"}
16
+ * - Cache limits: ${n?.maxSize?`${Hr(n.maxSize*1024*1024)}`:"unlimited"}
17
+ */
18
+
19
+ const CACHE_VERSION = '${i}';
20
+ const CACHE_NAME = 'stx-pwa-v' + CACHE_VERSION;
21
+ const OFFLINE_PAGE = '${l}';
22
+
23
+ // Assets to precache on install
24
+ const PRECACHE_ASSETS = ${JSON.stringify(f,null,2)};
25
+
26
+ // Auto-generated precache manifest from build output
27
+ const BUILD_PRECACHE_MANIFEST = ${h};
28
+
29
+ // Route caching strategies
30
+ const ROUTE_STRATEGIES = ${JSON.stringify(d,null,2)};
31
+
32
+ // Routes to exclude from caching
33
+ const EXCLUDED_ROUTES = ${JSON.stringify(c.excludeRoutes||[],null,2)};
34
+
35
+ // Cache storage configuration
36
+ const CACHE_CONFIG = {
37
+ maxSize: ${n?.maxSize||0} * 1024 * 1024, // Convert MB to bytes
38
+ maxAge: ${n?.maxAge||0} * 24 * 60 * 60 * 1000, // Convert days to ms
39
+ maxEntries: ${n?.maxEntries||0},
40
+ purgeStrategy: '${n?.purgeStrategy||"lru"}',
41
+ };
42
+
43
+ // Background sync configuration
44
+ const SYNC_CONFIG = {
45
+ enabled: ${s?.enabled||!1},
46
+ queueName: '${s?.queueName||"stx-sync-queue"}',
47
+ maxRetries: ${s?.maxRetries||3},
48
+ minInterval: ${s?.minInterval||1000},
49
+ };
50
+
51
+ // Push notification configuration
52
+ const PUSH_CONFIG = {
53
+ enabled: ${r?.enabled||!1},
54
+ defaultIcon: '${r?.defaultIcon||"/pwa-icons/icon-192x192.png"}',
55
+ defaultBadge: '${r?.defaultBadge||"/pwa-icons/icon-72x72.png"}',
56
+ };
57
+
58
+ /**
59
+ * Install event - precache essential assets
60
+ */
61
+ self.addEventListener('install', (event) => {
62
+ console.log('[SW] Installing service worker...');
63
+ ${c.skipWaiting?"self.skipWaiting();":""}
64
+
65
+ event.waitUntil(
66
+ caches.open(CACHE_NAME).then(async (cache) => {
67
+ // Combine manual precache assets with auto-generated manifest
68
+ const allAssets = [...PRECACHE_ASSETS];
69
+
70
+ // Add build precache manifest entries
71
+ for (const entry of BUILD_PRECACHE_MANIFEST) {
72
+ if (!allAssets.includes(entry.url)) {
73
+ allAssets.push(entry.url);
74
+ }
75
+ }
76
+
77
+ console.log('[SW] Precaching assets:', allAssets.length);
78
+
79
+ // Cache assets one by one to handle failures gracefully
80
+ const results = await Promise.allSettled(
81
+ allAssets.map(async (url) => {
82
+ try {
83
+ const response = await fetch(url);
84
+ if (response.ok) {
85
+ await cache.put(url, response);
86
+ return { url, success: true };
87
+ }
88
+ return { url, success: false, reason: response.status };
89
+ }
90
+ catch (error) {
91
+ return { url, success: false, reason: error.message };
92
+ }
93
+ })
94
+ );
95
+
96
+ const failed = results.filter(r => r.status === 'rejected' || (r.status === 'fulfilled' && !r.value.success));
97
+ if (failed.length > 0) {
98
+ console.warn('[SW] Failed to precache some assets:', failed.length);
99
+ }
100
+ })
101
+ );
102
+ });
103
+
104
+ /**
105
+ * Activate event - clean up old caches
106
+ */
107
+ self.addEventListener('activate', (event) => {
108
+ console.log('[SW] Activating service worker...');
109
+ ${c.clientsClaim?"self.clients.claim();":""}
110
+
111
+ event.waitUntil(
112
+ (async () => {
113
+ // Clean up old caches
114
+ const cacheNames = await caches.keys();
115
+ await Promise.all(
116
+ cacheNames
117
+ .filter((name) => name.startsWith('stx-pwa-') && name !== CACHE_NAME)
118
+ .map((name) => {
119
+ console.log('[SW] Deleting old cache:', name);
120
+ return caches.delete(name);
121
+ })
122
+ );
123
+
124
+ // Enforce cache storage limits
125
+ if (CACHE_CONFIG.maxSize > 0 || CACHE_CONFIG.maxEntries > 0) {
126
+ await enforceCacheLimits();
127
+ }
128
+ })()
129
+ );
130
+ });
131
+
132
+ /**
133
+ * Fetch event - apply caching strategies
134
+ */
135
+ self.addEventListener('fetch', (event) => {
136
+ const { request } = event;
137
+ const url = new URL(request.url);
138
+
139
+ // Only handle GET requests
140
+ if (request.method !== 'GET') {
141
+ return;
142
+ }
143
+
144
+ // Skip cross-origin requests
145
+ if (url.origin !== location.origin) {
146
+ return;
147
+ }
148
+
149
+ // Skip excluded routes
150
+ if (isExcludedRoute(url.pathname)) {
151
+ return;
152
+ }
153
+
154
+ // Find matching strategy and apply
155
+ const routeConfig = getRouteConfig(url.pathname);
156
+ event.respondWith(applyStrategy(request, routeConfig));
157
+ });
158
+
159
+ /**
160
+ * Message event - handle messages from main thread
161
+ */
162
+ self.addEventListener('message', (event) => {
163
+ const { type, payload } = event.data || {};
164
+
165
+ switch (type) {
166
+ case 'SKIP_WAITING':
167
+ console.log('[SW] Received SKIP_WAITING message');
168
+ self.skipWaiting();
169
+ break;
170
+
171
+ case 'CACHE_URLS':
172
+ if (Array.isArray(payload)) {
173
+ event.waitUntil(
174
+ caches.open(CACHE_NAME).then((cache) => cache.addAll(payload))
175
+ );
176
+ }
177
+ break;
178
+
179
+ case 'CLEAR_CACHE':
180
+ event.waitUntil(
181
+ caches.keys().then((names) =>
182
+ Promise.all(names.map((name) => caches.delete(name)))
183
+ )
184
+ );
185
+ break;
186
+
187
+ case 'GET_CACHE_SIZE':
188
+ event.waitUntil(
189
+ getCacheSize().then((size) => {
190
+ event.source?.postMessage({ type: 'CACHE_SIZE', payload: size });
191
+ })
192
+ );
193
+ break;
194
+ }
195
+ });
196
+
197
+ ${r?.enabled?g():"// Push notifications disabled"}
198
+
199
+ ${s?.enabled?p():"// Background sync disabled"}
200
+
201
+ /**
202
+ * Check if a route should be excluded from caching
203
+ */
204
+ function isExcludedRoute(pathname) {
205
+ return EXCLUDED_ROUTES.some((pattern) => matchPattern(pathname, pattern));
206
+ }
207
+
208
+ /**
209
+ * Match a path against a glob pattern
210
+ * Supports: *.ext, /path/*, /path/**, exact matches
211
+ */
212
+ function matchPattern(path, pattern) {
213
+ // Handle file extension patterns like *.js, *.css
214
+ if (pattern.startsWith('*.')) {
215
+ return path.endsWith(pattern.slice(1));
216
+ }
217
+
218
+ // Handle patterns ending with /**
219
+ if (pattern.endsWith('/**')) {
220
+ const prefix = pattern.slice(0, -3);
221
+ return path.startsWith(prefix);
222
+ }
223
+
224
+ // Handle patterns ending with /*
225
+ if (pattern.endsWith('/*')) {
226
+ const prefix = pattern.slice(0, -2);
227
+ if (!path.startsWith(prefix)) return false;
228
+ const rest = path.slice(prefix.length);
229
+ return rest.length > 0 && !rest.slice(1).includes('/');
230
+ }
231
+
232
+ // Handle patterns with * in the middle
233
+ if (pattern.includes('*')) {
234
+ const parts = pattern.split('*');
235
+ if (parts.length === 2) {
236
+ return path.startsWith(parts[0]) && path.endsWith(parts[1]);
237
+ }
238
+ }
239
+
240
+ // Exact match
241
+ return path === pattern;
242
+ }
243
+
244
+ /**
245
+ * Get the cache configuration for a given path
246
+ */
247
+ function getRouteConfig(pathname) {
248
+ for (const route of ROUTE_STRATEGIES) {
249
+ if (matchPattern(pathname, route.pattern)) {
250
+ return route;
251
+ }
252
+ }
253
+ // Default to network-first for unmatched routes
254
+ return { strategy: 'network-first' };
255
+ }
256
+
257
+ /**
258
+ * Apply the appropriate caching strategy
259
+ */
260
+ async function applyStrategy(request, routeConfig) {
261
+ const { strategy, cacheName, maxAgeSeconds, maxEntries } = routeConfig;
262
+ const cache = await caches.open(cacheName || CACHE_NAME);
263
+
264
+ switch (strategy) {
265
+ case 'cache-first':
266
+ return cacheFirst(request, cache, maxAgeSeconds);
267
+
268
+ case 'network-first':
269
+ return networkFirst(request, cache);
270
+
271
+ case 'stale-while-revalidate':
272
+ return staleWhileRevalidate(request, cache);
273
+
274
+ case 'network-only':
275
+ return networkOnly(request);
276
+
277
+ case 'cache-only':
278
+ return cacheOnly(request, cache);
279
+
280
+ default:
281
+ return networkFirst(request, cache);
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Cache-first strategy
287
+ * Serve from cache if available, otherwise fetch from network
288
+ */
289
+ async function cacheFirst(request, cache, maxAge) {
290
+ const cached = await cache.match(request);
291
+
292
+ if (cached) {
293
+ // Check if cache is still valid (if maxAge is set)
294
+ if (maxAge) {
295
+ const cachedDate = cached.headers.get('sw-cache-date');
296
+ if (cachedDate) {
297
+ const age = (Date.now() - new Date(cachedDate).getTime()) / 1000;
298
+ if (age > maxAge) {
299
+ // Cache expired, fetch fresh
300
+ return fetchAndCache(request, cache);
301
+ }
302
+ }
303
+ }
304
+ return cached;
305
+ }
306
+
307
+ return fetchAndCache(request, cache);
308
+ }
309
+
310
+ /**
311
+ * Network-first strategy
312
+ * Try network first, fall back to cache if offline
313
+ */
314
+ async function networkFirst(request, cache) {
315
+ try {
316
+ const response = await fetch(request);
317
+ if (response.ok) {
318
+ const cloned = response.clone();
319
+ cache.put(request, cloned);
320
+ }
321
+ return response;
322
+ }
323
+ catch (error) {
324
+ const cached = await cache.match(request);
325
+ if (cached) {
326
+ return cached;
327
+ }
328
+ return offlineResponse(request);
329
+ }
330
+ }
331
+
332
+ /**
333
+ * Stale-while-revalidate strategy
334
+ * Serve cached immediately, update cache in background
335
+ */
336
+ async function staleWhileRevalidate(request, cache) {
337
+ const cached = await cache.match(request);
338
+
339
+ // Fetch in background to update cache
340
+ const fetchPromise = fetch(request)
341
+ .then((response) => {
342
+ if (response.ok) {
343
+ cache.put(request, response.clone());
344
+ }
345
+ return response;
346
+ })
347
+ .catch(() => null);
348
+
349
+ // Return cached immediately if available, otherwise wait for fetch
350
+ if (cached) {
351
+ return cached;
352
+ }
353
+
354
+ const response = await fetchPromise;
355
+ return response || offlineResponse(request);
356
+ }
357
+
358
+ /**
359
+ * Network-only strategy
360
+ * Always fetch from network, no caching
361
+ */
362
+ async function networkOnly(request) {
363
+ try {
364
+ return await fetch(request);
365
+ }
366
+ catch (error) {
367
+ return offlineResponse(request);
368
+ }
369
+ }
370
+
371
+ /**
372
+ * Cache-only strategy
373
+ * Only serve from cache, never fetch
374
+ */
375
+ async function cacheOnly(request, cache) {
376
+ const cached = await cache.match(request);
377
+ return cached || offlineResponse(request);
378
+ }
379
+
380
+ /**
381
+ * Fetch and cache a request
382
+ */
383
+ async function fetchAndCache(request, cache) {
384
+ try {
385
+ const response = await fetch(request);
386
+ if (response.ok) {
387
+ // Add cache timestamp header
388
+ const headers = new Headers(response.headers);
389
+ headers.set('sw-cache-date', new Date().toISOString());
390
+
391
+ const cachedResponse = new Response(response.clone().body, {
392
+ status: response.status,
393
+ statusText: response.statusText,
394
+ headers,
395
+ });
396
+
397
+ cache.put(request, cachedResponse);
398
+ }
399
+ return response;
400
+ }
401
+ catch (error) {
402
+ return offlineResponse(request);
403
+ }
404
+ }
405
+
406
+ /**
407
+ * Generate offline response
408
+ */
409
+ async function offlineResponse(request) {
410
+ // For navigation requests, return offline page
411
+ if (request.mode === 'navigate') {
412
+ const cache = await caches.open(CACHE_NAME);
413
+ const offlinePage = await cache.match(OFFLINE_PAGE);
414
+ if (offlinePage) {
415
+ return offlinePage;
416
+ }
417
+ }
418
+
419
+ // Return a basic offline response
420
+ return new Response('You are offline', {
421
+ status: 503,
422
+ statusText: 'Service Unavailable',
423
+ headers: {
424
+ 'Content-Type': 'text/plain',
425
+ },
426
+ });
427
+ }
428
+
429
+ /**
430
+ * Get total cache size
431
+ */
432
+ async function getCacheSize() {
433
+ let totalSize = 0;
434
+ const cacheNames = await caches.keys();
435
+
436
+ for (const cacheName of cacheNames) {
437
+ const cache = await caches.open(cacheName);
438
+ const keys = await cache.keys();
439
+
440
+ for (const request of keys) {
441
+ const response = await cache.match(request);
442
+ if (response) {
443
+ const blob = await response.clone().blob();
444
+ totalSize += blob.size;
445
+ }
446
+ }
447
+ }
448
+
449
+ return totalSize;
450
+ }
451
+
452
+ /**
453
+ * Enforce cache storage limits
454
+ */
455
+ async function enforceCacheLimits() {
456
+ const cache = await caches.open(CACHE_NAME);
457
+ const keys = await cache.keys();
458
+
459
+ // Get cache entries with metadata
460
+ const entries = [];
461
+ for (const request of keys) {
462
+ const response = await cache.match(request);
463
+ if (response) {
464
+ const blob = await response.clone().blob();
465
+ const cachedDate = response.headers.get('sw-cache-date');
466
+ entries.push({
467
+ request,
468
+ size: blob.size,
469
+ date: cachedDate ? new Date(cachedDate) : new Date(),
470
+ });
471
+ }
472
+ }
473
+
474
+ // Check total size limit
475
+ if (CACHE_CONFIG.maxSize > 0) {
476
+ const totalSize = entries.reduce((sum, e) => sum + e.size, 0);
477
+
478
+ if (totalSize > CACHE_CONFIG.maxSize) {
479
+ console.log('[SW] Cache size exceeded, purging...');
480
+ await purgeCache(entries, cache, CACHE_CONFIG.maxSize);
481
+ }
482
+ }
483
+
484
+ // Check max entries limit
485
+ if (CACHE_CONFIG.maxEntries > 0 && entries.length > CACHE_CONFIG.maxEntries) {
486
+ console.log('[SW] Cache entries exceeded, purging...');
487
+ await purgeByEntryCount(entries, cache, CACHE_CONFIG.maxEntries);
488
+ }
489
+
490
+ // Check max age limit
491
+ if (CACHE_CONFIG.maxAge > 0) {
492
+ const now = Date.now();
493
+ const expiredEntries = entries.filter(e => (now - e.date.getTime()) > CACHE_CONFIG.maxAge);
494
+
495
+ for (const entry of expiredEntries) {
496
+ console.log('[SW] Removing expired cache entry:', entry.request.url);
497
+ await cache.delete(entry.request);
498
+ }
499
+ }
500
+ }
501
+
502
+ /**
503
+ * Purge cache to meet size limit
504
+ */
505
+ async function purgeCache(entries, cache, maxSize) {
506
+ // Sort by purge strategy
507
+ const sorted = [...entries];
508
+
509
+ switch (CACHE_CONFIG.purgeStrategy) {
510
+ case 'lru':
511
+ // Least Recently Used - remove oldest first
512
+ sorted.sort((a, b) => a.date.getTime() - b.date.getTime());
513
+ break;
514
+ case 'fifo':
515
+ // First In First Out - same as lru for our purposes
516
+ sorted.sort((a, b) => a.date.getTime() - b.date.getTime());
517
+ break;
518
+ case 'lfu':
519
+ // Least Frequently Used - we don't track frequency, use size as proxy
520
+ sorted.sort((a, b) => b.size - a.size);
521
+ break;
522
+ default:
523
+ sorted.sort((a, b) => a.date.getTime() - b.date.getTime());
524
+ }
525
+
526
+ let currentSize = entries.reduce((sum, e) => sum + e.size, 0);
527
+
528
+ for (const entry of sorted) {
529
+ if (currentSize <= maxSize * 0.8) { // Keep 80% buffer
530
+ break;
531
+ }
532
+
533
+ // Don't delete essential assets
534
+ const url = entry.request.url;
535
+ if (PRECACHE_ASSETS.some(asset => url.endsWith(asset))) {
536
+ continue;
537
+ }
538
+
539
+ console.log('[SW] Purging cache entry:', url);
540
+ await cache.delete(entry.request);
541
+ currentSize -= entry.size;
542
+ }
543
+ }
544
+
545
+ /**
546
+ * Purge cache by entry count
547
+ */
548
+ async function purgeByEntryCount(entries, cache, maxEntries) {
549
+ const sorted = [...entries].sort((a, b) => a.date.getTime() - b.date.getTime());
550
+ const toRemove = sorted.slice(0, entries.length - maxEntries);
551
+
552
+ for (const entry of toRemove) {
553
+ // Don't delete essential assets
554
+ const url = entry.request.url;
555
+ if (PRECACHE_ASSETS.some(asset => url.endsWith(asset))) {
556
+ continue;
557
+ }
558
+
559
+ await cache.delete(entry.request);
560
+ }
561
+ }
562
+
563
+ console.log('[SW] Service Worker loaded - Version:', CACHE_VERSION);
564
+ `}function g(){return`
565
+ /**
566
+ * Push event - handle incoming push notifications
567
+ */
568
+ self.addEventListener('push', (event) => {
569
+ console.log('[SW] Push notification received');
570
+
571
+ let data = {
572
+ title: 'Notification',
573
+ body: 'You have a new notification',
574
+ icon: PUSH_CONFIG.defaultIcon,
575
+ badge: PUSH_CONFIG.defaultBadge,
576
+ };
577
+
578
+ if (event.data) {
579
+ try {
580
+ const payload = event.data.json();
581
+ data = { ...data, ...payload };
582
+ }
583
+ catch {
584
+ data.body = event.data.text();
585
+ }
586
+ }
587
+
588
+ const options = {
589
+ body: data.body,
590
+ icon: data.icon || PUSH_CONFIG.defaultIcon,
591
+ badge: data.badge || PUSH_CONFIG.defaultBadge,
592
+ vibrate: data.vibrate || [100, 50, 100],
593
+ data: {
594
+ url: data.url || '/',
595
+ ...data.data,
596
+ },
597
+ actions: data.actions || [],
598
+ tag: data.tag,
599
+ renotify: data.renotify || false,
600
+ requireInteraction: data.requireInteraction || false,
601
+ silent: data.silent || false,
602
+ };
603
+
604
+ event.waitUntil(
605
+ self.registration.showNotification(data.title, options)
606
+ );
607
+ });
608
+
609
+ /**
610
+ * Notification click event - handle notification interactions
611
+ */
612
+ self.addEventListener('notificationclick', (event) => {
613
+ console.log('[SW] Notification clicked:', event.action);
614
+ event.notification.close();
615
+
616
+ const url = event.notification.data?.url || '/';
617
+
618
+ event.waitUntil(
619
+ clients.matchAll({ type: 'window', includeUncontrolled: true }).then((windowClients) => {
620
+ // Check if there's already a window open with this URL
621
+ for (const client of windowClients) {
622
+ if (client.url === url && 'focus' in client) {
623
+ return client.focus();
624
+ }
625
+ }
626
+ // Open a new window
627
+ if (clients.openWindow) {
628
+ return clients.openWindow(url);
629
+ }
630
+ })
631
+ );
632
+ });
633
+
634
+ /**
635
+ * Notification close event
636
+ */
637
+ self.addEventListener('notificationclose', (event) => {
638
+ console.log('[SW] Notification closed');
639
+
640
+ // Track notification dismissal if needed
641
+ const data = event.notification.data;
642
+ if (data?.trackDismiss) {
643
+ // Could send analytics here
644
+ }
645
+ });
646
+ `}function p(){return`
647
+ /**
648
+ * Background sync queue storage (IndexedDB)
649
+ */
650
+ const SYNC_STORE = 'stx-sync-store';
651
+ let syncDb = null;
652
+
653
+ async function getSyncDb() {
654
+ if (syncDb) return syncDb;
655
+
656
+ return new Promise((resolve, reject) => {
657
+ const request = indexedDB.open(SYNC_STORE, 1);
658
+
659
+ request.onerror = () => reject(request.error);
660
+ request.onsuccess = () => {
661
+ syncDb = request.result;
662
+ resolve(syncDb);
663
+ };
664
+
665
+ request.onupgradeneeded = (event) => {
666
+ const db = event.target.result;
667
+ if (!db.objectStoreNames.contains('queue')) {
668
+ db.createObjectStore('queue', { keyPath: 'id', autoIncrement: true });
669
+ }
670
+ };
671
+ });
672
+ }
673
+
674
+ /**
675
+ * Add request to sync queue
676
+ */
677
+ async function addToSyncQueue(request) {
678
+ const db = await getSyncDb();
679
+ const tx = db.transaction('queue', 'readwrite');
680
+ const store = tx.objectStore('queue');
681
+
682
+ const data = {
683
+ url: request.url,
684
+ method: request.method,
685
+ headers: Object.fromEntries(request.headers.entries()),
686
+ body: await request.clone().text(),
687
+ timestamp: Date.now(),
688
+ retries: 0,
689
+ };
690
+
691
+ return new Promise((resolve, reject) => {
692
+ const req = store.add(data);
693
+ req.onsuccess = () => resolve(req.result);
694
+ req.onerror = () => reject(req.error);
695
+ });
696
+ }
697
+
698
+ /**
699
+ * Get all pending sync requests
700
+ */
701
+ async function getPendingSyncRequests() {
702
+ const db = await getSyncDb();
703
+ const tx = db.transaction('queue', 'readonly');
704
+ const store = tx.objectStore('queue');
705
+
706
+ return new Promise((resolve, reject) => {
707
+ const req = store.getAll();
708
+ req.onsuccess = () => resolve(req.result);
709
+ req.onerror = () => reject(req.error);
710
+ });
711
+ }
712
+
713
+ /**
714
+ * Remove request from sync queue
715
+ */
716
+ async function removeSyncRequest(id) {
717
+ const db = await getSyncDb();
718
+ const tx = db.transaction('queue', 'readwrite');
719
+ const store = tx.objectStore('queue');
720
+
721
+ return new Promise((resolve, reject) => {
722
+ const req = store.delete(id);
723
+ req.onsuccess = () => resolve();
724
+ req.onerror = () => reject(req.error);
725
+ });
726
+ }
727
+
728
+ /**
729
+ * Update sync request retry count
730
+ */
731
+ async function updateSyncRetries(id, retries) {
732
+ const db = await getSyncDb();
733
+ const tx = db.transaction('queue', 'readwrite');
734
+ const store = tx.objectStore('queue');
735
+
736
+ const req = store.get(id);
737
+ req.onsuccess = () => {
738
+ const data = req.result;
739
+ if (data) {
740
+ data.retries = retries;
741
+ store.put(data);
742
+ }
743
+ };
744
+ }
745
+
746
+ /**
747
+ * Sync event - process queued requests when online
748
+ */
749
+ self.addEventListener('sync', (event) => {
750
+ console.log('[SW] Sync event:', event.tag);
751
+
752
+ if (event.tag === SYNC_CONFIG.queueName || event.tag === 'stx-form-sync') {
753
+ event.waitUntil(processBackgroundSync());
754
+ }
755
+ });
756
+
757
+ /**
758
+ * Process all queued sync requests
759
+ */
760
+ async function processBackgroundSync() {
761
+ console.log('[SW] Processing background sync queue');
762
+
763
+ const requests = await getPendingSyncRequests();
764
+ console.log('[SW] Pending sync requests:', requests.length);
765
+
766
+ for (const request of requests) {
767
+ if (request.retries >= SYNC_CONFIG.maxRetries) {
768
+ console.log('[SW] Max retries reached, removing:', request.url);
769
+ await removeSyncRequest(request.id);
770
+ continue;
771
+ }
772
+
773
+ try {
774
+ const response = await fetch(request.url, {
775
+ method: request.method,
776
+ headers: request.headers,
777
+ body: request.method !== 'GET' ? request.body : undefined,
778
+ });
779
+
780
+ if (response.ok) {
781
+ console.log('[SW] Sync succeeded:', request.url);
782
+ await removeSyncRequest(request.id);
783
+
784
+ // Notify clients of successful sync
785
+ const clients = await self.clients.matchAll();
786
+ clients.forEach(client => {
787
+ client.postMessage({
788
+ type: 'SYNC_COMPLETE',
789
+ url: request.url,
790
+ success: true,
791
+ });
792
+ });
793
+ }
794
+ else {
795
+ throw new Error('Response not ok: ' + response.status);
796
+ }
797
+ }
798
+ catch (error) {
799
+ console.log('[SW] Sync failed, will retry:', request.url, error.message);
800
+ await updateSyncRetries(request.id, request.retries + 1);
801
+ }
802
+ }
803
+ }
804
+
805
+ /**
806
+ * Register a form for background sync
807
+ * Called from main thread via message
808
+ */
809
+ async function registerFormSync(formData) {
810
+ // Store form data in IndexedDB
811
+ await addToSyncQueue({
812
+ url: formData.action,
813
+ method: formData.method || 'POST',
814
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
815
+ clone: () => ({ text: async () => new URLSearchParams(formData.data).toString() }),
816
+ });
817
+
818
+ // Register for background sync
819
+ await self.registration.sync.register(SYNC_CONFIG.queueName);
820
+ }
821
+
822
+ // Listen for form sync requests
823
+ self.addEventListener('message', (event) => {
824
+ if (event.data?.type === 'REGISTER_FORM_SYNC') {
825
+ event.waitUntil(registerFormSync(event.data.payload));
826
+ }
827
+ });
828
+ `}function Oe(e){return e.pwa?.serviceWorker?.fileName||"sw.js"}function Ii(e){return e.pwa?.enabled===!0&&e.pwa?.serviceWorker?.useWorkbox===!0}function Ba(e,a){if(!e.pwa?.enabled)return"";if(Ii(e)){let{generateWorkboxServiceWorker:t}=import.meta.require("./chunk-y5310237.js");return t(e,a)}return Mn(e,a)}
829
+ export{Mn,Oe,Ii,Ba};