This is page 9 of 10. Use http://codebase.md/jakedismo/master-mcp-server?lines=true&page={x} to view the full context.
# Directory Structure
```
├── .env.example
├── .eslintignore
├── .eslintrc.cjs
├── .eslintrc.js
├── .gitignore
├── .prettierignore
├── .prettierrc
├── .prettierrc.json
├── CHANGELOG.md
├── config
│ ├── default.json
│ ├── development.json
│ ├── production.json
│ └── schema.json
├── config.json
├── CONTRIBUTING.md
├── debug-stdio.cjs
├── debug-stdio.js
├── deploy
│ ├── cloudflare
│ │ ├── .gitkeep
│ │ ├── README.md
│ │ └── wrangler.toml
│ ├── docker
│ │ ├── .gitkeep
│ │ ├── docker-compose.yml
│ │ ├── Dockerfile
│ │ └── entrypoint.sh
│ ├── koyeb
│ │ ├── .gitkeep
│ │ └── koyeb.yaml
│ └── README.md
├── docker-compose.yml
├── Dockerfile
├── docs
│ ├── .DS_Store
│ ├── .vitepress
│ │ ├── cache
│ │ │ └── deps
│ │ │ ├── _metadata.json
│ │ │ ├── chunk-HVR2FF6M.js
│ │ │ ├── chunk-HVR2FF6M.js.map
│ │ │ ├── chunk-P2XGSYO7.js
│ │ │ ├── chunk-P2XGSYO7.js.map
│ │ │ ├── package.json
│ │ │ ├── vitepress___@vue_devtools-api.js
│ │ │ ├── vitepress___@vue_devtools-api.js.map
│ │ │ ├── vitepress___@vueuse_core.js
│ │ │ ├── vitepress___@vueuse_core.js.map
│ │ │ ├── vitepress___@vueuse_integrations_useFocusTrap.js
│ │ │ ├── vitepress___@vueuse_integrations_useFocusTrap.js.map
│ │ │ ├── vitepress___mark__js_src_vanilla__js.js
│ │ │ ├── vitepress___mark__js_src_vanilla__js.js.map
│ │ │ ├── vitepress___minisearch.js
│ │ │ ├── vitepress___minisearch.js.map
│ │ │ ├── vue.js
│ │ │ └── vue.js.map
│ │ ├── config.ts
│ │ ├── dist
│ │ │ ├── 404.html
│ │ │ ├── advanced
│ │ │ │ ├── extensibility.html
│ │ │ │ ├── index.html
│ │ │ │ ├── monitoring.html
│ │ │ │ ├── performance.html
│ │ │ │ └── security.html
│ │ │ ├── api
│ │ │ │ ├── index.html
│ │ │ │ └── README.html
│ │ │ ├── assets
│ │ │ │ ├── advanced_extensibility.md.TrXUn5w5.js
│ │ │ │ ├── advanced_extensibility.md.TrXUn5w5.lean.js
│ │ │ │ ├── advanced_index.md.CPcpUlw_.js
│ │ │ │ ├── advanced_index.md.CPcpUlw_.lean.js
│ │ │ │ ├── advanced_monitoring.md.DTybdNg-.js
│ │ │ │ ├── advanced_monitoring.md.DTybdNg-.lean.js
│ │ │ │ ├── advanced_performance.md.DKmzK0ia.js
│ │ │ │ ├── advanced_performance.md.DKmzK0ia.lean.js
│ │ │ │ ├── advanced_security.md.B-oBD7IB.js
│ │ │ │ ├── advanced_security.md.B-oBD7IB.lean.js
│ │ │ │ ├── api_index.md.Dl1JB08_.js
│ │ │ │ ├── api_index.md.Dl1JB08_.lean.js
│ │ │ │ ├── chunks
│ │ │ │ │ └── framework.CHl2ywxc.js
│ │ │ │ ├── configuration_environment-variables.md.Ddy3P_Wz.js
│ │ │ │ ├── configuration_environment-variables.md.Ddy3P_Wz.lean.js
│ │ │ │ ├── configuration_environment.md.DxcTQ623.js
│ │ │ │ ├── configuration_environment.md.DxcTQ623.lean.js
│ │ │ │ ├── configuration_overview.md.DIkVDv7V.js
│ │ │ │ ├── configuration_overview.md.DIkVDv7V.lean.js
│ │ │ │ ├── configuration_performance.md.DbJdmLrW.js
│ │ │ │ ├── configuration_performance.md.DbJdmLrW.lean.js
│ │ │ │ ├── configuration_reference.md.27IKWqtk.js
│ │ │ │ ├── configuration_reference.md.27IKWqtk.lean.js
│ │ │ │ ├── configuration_security.md.-OOlkzN4.js
│ │ │ │ ├── configuration_security.md.-OOlkzN4.lean.js
│ │ │ │ ├── contributing_dev-setup.md.Ceqh4w-R.js
│ │ │ │ ├── contributing_dev-setup.md.Ceqh4w-R.lean.js
│ │ │ │ ├── contributing_guidelines.md.ZEAX2yVh.js
│ │ │ │ ├── contributing_guidelines.md.ZEAX2yVh.lean.js
│ │ │ │ ├── contributing_index.md.DYq9R6wr.js
│ │ │ │ ├── contributing_index.md.DYq9R6wr.lean.js
│ │ │ │ ├── contributing_maintenance.md.k2bR0IaR.js
│ │ │ │ ├── contributing_maintenance.md.k2bR0IaR.lean.js
│ │ │ │ ├── deployment_cicd.md.Ci2T0UYC.js
│ │ │ │ ├── deployment_cicd.md.Ci2T0UYC.lean.js
│ │ │ │ ├── deployment_cloudflare-workers.md.D2WHsfep.js
│ │ │ │ ├── deployment_cloudflare-workers.md.D2WHsfep.lean.js
│ │ │ │ ├── deployment_docker.md.B8bQDQTo.js
│ │ │ │ ├── deployment_docker.md.B8bQDQTo.lean.js
│ │ │ │ ├── deployment_index.md.ClYeOkpy.js
│ │ │ │ ├── deployment_index.md.ClYeOkpy.lean.js
│ │ │ │ ├── deployment_koyeb.md.B_wJhvF7.js
│ │ │ │ ├── deployment_koyeb.md.B_wJhvF7.lean.js
│ │ │ │ ├── examples_advanced-routing.md.B3CqhLZ7.js
│ │ │ │ ├── examples_advanced-routing.md.B3CqhLZ7.lean.js
│ │ │ │ ├── examples_basic-node.md.CaDZzGlO.js
│ │ │ │ ├── examples_basic-node.md.CaDZzGlO.lean.js
│ │ │ │ ├── examples_cloudflare-worker.md.DwVSz-c7.js
│ │ │ │ ├── examples_cloudflare-worker.md.DwVSz-c7.lean.js
│ │ │ │ ├── examples_index.md.CBF_BLkl.js
│ │ │ │ ├── examples_index.md.CBF_BLkl.lean.js
│ │ │ │ ├── examples_oauth-delegation.md.1hZxoqDl.js
│ │ │ │ ├── examples_oauth-delegation.md.1hZxoqDl.lean.js
│ │ │ │ ├── examples_overview.md.CZN0JbZ7.js
│ │ │ │ ├── examples_overview.md.CZN0JbZ7.lean.js
│ │ │ │ ├── examples_testing.md.Dek4GpNs.js
│ │ │ │ ├── examples_testing.md.Dek4GpNs.lean.js
│ │ │ │ ├── getting-started_concepts.md.D7ON9iGB.js
│ │ │ │ ├── getting-started_concepts.md.D7ON9iGB.lean.js
│ │ │ │ ├── getting-started_installation.md.BKnVqAGg.js
│ │ │ │ ├── getting-started_installation.md.BKnVqAGg.lean.js
│ │ │ │ ├── getting-started_overview.md.DvJDFL2N.js
│ │ │ │ ├── getting-started_overview.md.DvJDFL2N.lean.js
│ │ │ │ ├── getting-started_quickstart-node.md.GOO4aGas.js
│ │ │ │ ├── getting-started_quickstart-node.md.GOO4aGas.lean.js
│ │ │ │ ├── getting-started_quickstart-workers.md.Cpofh8Mj.js
│ │ │ │ ├── getting-started_quickstart-workers.md.Cpofh8Mj.lean.js
│ │ │ │ ├── getting-started.md.DG9ndneo.js
│ │ │ │ ├── getting-started.md.DG9ndneo.lean.js
│ │ │ │ ├── guides_configuration-management.md.B-jwYMbA.js
│ │ │ │ ├── guides_configuration-management.md.B-jwYMbA.lean.js
│ │ │ │ ├── guides_configuration.md.Ci3zYDFA.js
│ │ │ │ ├── guides_configuration.md.Ci3zYDFA.lean.js
│ │ │ │ ├── guides_index.md.CIlq2fmx.js
│ │ │ │ ├── guides_index.md.CIlq2fmx.lean.js
│ │ │ │ ├── guides_module-loading.md.BkJvuRnQ.js
│ │ │ │ ├── guides_module-loading.md.BkJvuRnQ.lean.js
│ │ │ │ ├── guides_oauth-delegation.md.DEOZ-_G0.js
│ │ │ │ ├── guides_oauth-delegation.md.DEOZ-_G0.lean.js
│ │ │ │ ├── guides_request-routing.md.Bdzf0VLg.js
│ │ │ │ ├── guides_request-routing.md.Bdzf0VLg.lean.js
│ │ │ │ ├── guides_testing.md.kYfHqJLu.js
│ │ │ │ ├── guides_testing.md.kYfHqJLu.lean.js
│ │ │ │ ├── inter-italic-cyrillic-ext.r48I6akx.woff2
│ │ │ │ ├── inter-italic-cyrillic.By2_1cv3.woff2
│ │ │ │ ├── inter-italic-greek-ext.1u6EdAuj.woff2
│ │ │ │ ├── inter-italic-greek.DJ8dCoTZ.woff2
│ │ │ │ ├── inter-italic-latin-ext.CN1xVJS-.woff2
│ │ │ │ ├── inter-italic-latin.C2AdPX0b.woff2
│ │ │ │ ├── inter-italic-vietnamese.BSbpV94h.woff2
│ │ │ │ ├── inter-roman-cyrillic-ext.BBPuwvHQ.woff2
│ │ │ │ ├── inter-roman-cyrillic.C5lxZ8CY.woff2
│ │ │ │ ├── inter-roman-greek-ext.CqjqNYQ-.woff2
│ │ │ │ ├── inter-roman-greek.BBVDIX6e.woff2
│ │ │ │ ├── inter-roman-latin-ext.4ZJIpNVo.woff2
│ │ │ │ ├── inter-roman-latin.Di8DUHzh.woff2
│ │ │ │ ├── inter-roman-vietnamese.BjW4sHH5.woff2
│ │ │ │ ├── README.md.BO5r5M9u.js
│ │ │ │ ├── README.md.BO5r5M9u.lean.js
│ │ │ │ ├── style.BQrfSMzK.css
│ │ │ │ ├── troubleshooting_common-issues.md.CScvzWM1.js
│ │ │ │ ├── troubleshooting_common-issues.md.CScvzWM1.lean.js
│ │ │ │ ├── troubleshooting_deployment.md.DUhpqnLE.js
│ │ │ │ ├── troubleshooting_deployment.md.DUhpqnLE.lean.js
│ │ │ │ ├── troubleshooting_errors.md.BSCsEmGc.js
│ │ │ │ ├── troubleshooting_errors.md.BSCsEmGc.lean.js
│ │ │ │ ├── troubleshooting_oauth.md.Cw60Eka3.js
│ │ │ │ ├── troubleshooting_oauth.md.Cw60Eka3.lean.js
│ │ │ │ ├── troubleshooting_performance.md.DxY6LJcT.js
│ │ │ │ ├── troubleshooting_performance.md.DxY6LJcT.lean.js
│ │ │ │ ├── troubleshooting_routing.md.BHN-MDhs.js
│ │ │ │ ├── troubleshooting_routing.md.BHN-MDhs.lean.js
│ │ │ │ ├── troubleshooting_security-best-practices.md.Yiu8E-zt.js
│ │ │ │ ├── troubleshooting_security-best-practices.md.Yiu8E-zt.lean.js
│ │ │ │ ├── tutorials_beginner-getting-started.md.BXObgobW.js
│ │ │ │ ├── tutorials_beginner-getting-started.md.BXObgobW.lean.js
│ │ │ │ ├── tutorials_cloudflare-workers-tutorial.md.MPHsc0aT.js
│ │ │ │ ├── tutorials_cloudflare-workers-tutorial.md.MPHsc0aT.lean.js
│ │ │ │ ├── tutorials_load-balancing-and-resilience.md.Dv9r9jyW.js
│ │ │ │ ├── tutorials_load-balancing-and-resilience.md.Dv9r9jyW.lean.js
│ │ │ │ ├── tutorials_oauth-delegation-github.md.Nq4glqCe.js
│ │ │ │ └── tutorials_oauth-delegation-github.md.Nq4glqCe.lean.js
│ │ │ ├── configuration
│ │ │ │ ├── environment-variables.html
│ │ │ │ ├── environment.html
│ │ │ │ ├── examples.html
│ │ │ │ ├── overview.html
│ │ │ │ ├── performance.html
│ │ │ │ ├── reference.html
│ │ │ │ └── security.html
│ │ │ ├── contributing
│ │ │ │ ├── dev-setup.html
│ │ │ │ ├── guidelines.html
│ │ │ │ ├── index.html
│ │ │ │ └── maintenance.html
│ │ │ ├── deployment
│ │ │ │ ├── cicd.html
│ │ │ │ ├── cloudflare-workers.html
│ │ │ │ ├── docker.html
│ │ │ │ ├── index.html
│ │ │ │ └── koyeb.html
│ │ │ ├── diagrams
│ │ │ │ └── architecture.svg
│ │ │ ├── examples
│ │ │ │ ├── advanced-routing.html
│ │ │ │ ├── basic-node.html
│ │ │ │ ├── cloudflare-worker.html
│ │ │ │ ├── index.html
│ │ │ │ ├── oauth-delegation.html
│ │ │ │ ├── overview.html
│ │ │ │ └── testing.html
│ │ │ ├── getting-started
│ │ │ │ ├── concepts.html
│ │ │ │ ├── installation.html
│ │ │ │ ├── overview.html
│ │ │ │ ├── quick-start.html
│ │ │ │ ├── quickstart-node.html
│ │ │ │ └── quickstart-workers.html
│ │ │ ├── getting-started.html
│ │ │ ├── guides
│ │ │ │ ├── authentication.html
│ │ │ │ ├── client-integration.html
│ │ │ │ ├── configuration-management.html
│ │ │ │ ├── configuration.html
│ │ │ │ ├── index.html
│ │ │ │ ├── module-loading.html
│ │ │ │ ├── oauth-delegation.html
│ │ │ │ ├── request-routing.html
│ │ │ │ ├── server-management.html
│ │ │ │ ├── server-sharing.html
│ │ │ │ └── testing.html
│ │ │ ├── hashmap.json
│ │ │ ├── index.html
│ │ │ ├── logo.svg
│ │ │ ├── README.html
│ │ │ ├── reports
│ │ │ │ └── mcp-compliance-audit.html
│ │ │ ├── troubleshooting
│ │ │ │ ├── common-issues.html
│ │ │ │ ├── deployment.html
│ │ │ │ ├── errors.html
│ │ │ │ ├── index.html
│ │ │ │ ├── oauth.html
│ │ │ │ ├── performance.html
│ │ │ │ ├── routing.html
│ │ │ │ └── security-best-practices.html
│ │ │ ├── tutorials
│ │ │ │ ├── beginner-getting-started.html
│ │ │ │ ├── cloudflare-workers-tutorial.html
│ │ │ │ ├── load-balancing-and-resilience.html
│ │ │ │ └── oauth-delegation-github.html
│ │ │ └── vp-icons.css
│ │ └── theme
│ │ ├── components
│ │ │ ├── ApiPlayground.vue
│ │ │ ├── AuthFlowDemo.vue
│ │ │ ├── CodeTabs.vue
│ │ │ └── ConfigGenerator.vue
│ │ ├── index.ts
│ │ └── style.css
│ ├── advanced
│ │ ├── extensibility.md
│ │ ├── index.md
│ │ ├── monitoring.md
│ │ ├── performance.md
│ │ └── security.md
│ ├── api
│ │ ├── functions
│ │ │ └── createServer.md
│ │ ├── index.md
│ │ ├── interfaces
│ │ │ └── RunningServer.md
│ │ └── README.md
│ ├── architecture
│ │ └── images
│ │ └── mcp_master_architecture.svg
│ ├── configuration
│ │ ├── environment-variables.md
│ │ ├── environment.md
│ │ ├── examples.md
│ │ ├── overview.md
│ │ ├── performance.md
│ │ ├── reference.md
│ │ └── security.md
│ ├── contributing
│ │ ├── dev-setup.md
│ │ ├── guidelines.md
│ │ ├── index.md
│ │ └── maintenance.md
│ ├── deployment
│ │ ├── cicd.md
│ │ ├── cloudflare-workers.md
│ │ ├── docker.md
│ │ ├── docs-site.md
│ │ ├── index.md
│ │ └── koyeb.md
│ ├── examples
│ │ ├── advanced-routing.md
│ │ ├── basic-node.md
│ │ ├── cloudflare-worker.md
│ │ ├── index.md
│ │ ├── oauth-delegation.md
│ │ ├── overview.md
│ │ └── testing.md
│ ├── getting-started
│ │ ├── concepts.md
│ │ ├── installation.md
│ │ ├── overview.md
│ │ ├── quick-start.md
│ │ ├── quickstart-node.md
│ │ └── quickstart-workers.md
│ ├── getting-started.md
│ ├── guides
│ │ ├── authentication.md
│ │ ├── client-integration.md
│ │ ├── configuration-management.md
│ │ ├── configuration.md
│ │ ├── index.md
│ │ ├── module-loading.md
│ │ ├── oauth-delegation.md
│ │ ├── request-routing.md
│ │ ├── server-management.md
│ │ ├── server-sharing.md
│ │ └── testing.md
│ ├── index.html
│ ├── public
│ │ ├── diagrams
│ │ │ └── architecture.svg
│ │ ├── github-social.png
│ │ │ └── image.png
│ │ ├── logo.png
│ │ └── logo.svg
│ ├── README.md
│ ├── stdio-servers.md
│ ├── testing
│ │ └── phase-9-testing-architecture.md
│ ├── troubleshooting
│ │ ├── common-issues.md
│ │ ├── deployment.md
│ │ ├── errors.md
│ │ ├── index.md
│ │ ├── oauth.md
│ │ ├── performance.md
│ │ ├── routing.md
│ │ └── security-best-practices.md
│ └── tutorials
│ ├── beginner-getting-started.md
│ ├── cloudflare-workers-tutorial.md
│ ├── load-balancing-and-resilience.md
│ └── oauth-delegation-github.md
├── examples
│ ├── advanced-routing
│ │ ├── config.yaml
│ │ └── README.md
│ ├── basic-node
│ │ ├── config.yaml
│ │ ├── README.md
│ │ └── server.ts
│ ├── cloudflare-worker
│ │ ├── README.md
│ │ └── worker.ts
│ ├── custom-auth
│ │ ├── config.yaml
│ │ ├── index.ts
│ │ └── README.md
│ ├── multi-server
│ │ ├── config.yaml
│ │ └── README.md
│ ├── oauth-delegation
│ │ └── README.md
│ ├── oauth-node
│ │ ├── config.yaml
│ │ └── README.md
│ ├── performance
│ │ ├── config.yaml
│ │ └── README.md
│ ├── sample-configs
│ │ ├── basic.yaml
│ │ └── simple-setup.yaml
│ ├── security-hardening
│ │ └── README.md
│ ├── stdio-mcp-server.cjs
│ ├── test-mcp-server.js
│ └── test-stdio-server.js
├── LICENSE
├── master-mcp-definition.md
├── package-lock.json
├── package.json
├── README.md
├── reports
│ └── claude_report_20250815_222153.html
├── scripts
│ └── generate-config-docs.ts
├── src
│ ├── auth
│ │ ├── multi-auth-manager.ts
│ │ ├── oauth-providers.ts
│ │ └── token-manager.ts
│ ├── config
│ │ ├── config-loader.ts
│ │ ├── environment-manager.ts
│ │ ├── schema-validator.ts
│ │ └── secret-manager.ts
│ ├── index.ts
│ ├── mcp-server.ts
│ ├── modules
│ │ ├── capability-aggregator.ts
│ │ ├── module-loader.ts
│ │ ├── request-router.ts
│ │ ├── stdio-capability-discovery.ts
│ │ └── stdio-manager.ts
│ ├── oauth
│ │ ├── callback-handler.ts
│ │ ├── flow-controller.ts
│ │ ├── flow-validator.ts
│ │ ├── pkce-manager.ts
│ │ ├── state-manager.ts
│ │ └── web-interface.ts
│ ├── routing
│ │ ├── circuit-breaker.ts
│ │ ├── load-balancer.ts
│ │ ├── retry-handler.ts
│ │ └── route-registry.ts
│ ├── runtime
│ │ ├── node.ts
│ │ └── worker.ts
│ ├── server
│ │ ├── config-manager.ts
│ │ ├── dependency-container.ts
│ │ ├── master-server.ts
│ │ └── protocol-handler.ts
│ ├── types
│ │ ├── auth.ts
│ │ ├── config.ts
│ │ ├── jose-shim.d.ts
│ │ ├── mcp.ts
│ │ └── server.ts
│ └── utils
│ ├── cache.ts
│ ├── crypto.ts
│ ├── dev.ts
│ ├── errors.ts
│ ├── http.ts
│ ├── logger.ts
│ ├── monitoring.ts
│ ├── string.ts
│ ├── time.ts
│ ├── validation.ts
│ └── validators.ts
├── static
│ └── oauth
│ ├── consent.html
│ ├── error.html
│ ├── script.js
│ ├── style.css
│ └── success.html
├── tests
│ ├── _setup
│ │ ├── miniflare.setup.ts
│ │ └── vitest.setup.ts
│ ├── _utils
│ │ ├── log-capture.ts
│ │ ├── mock-fetch.ts
│ │ └── test-server.ts
│ ├── .gitkeep
│ ├── e2e
│ │ ├── flow-controller.express.test.ts
│ │ └── flow-controller.worker.test.ts
│ ├── factories
│ │ ├── configFactory.ts
│ │ ├── mcpFactory.ts
│ │ └── oauthFactory.ts
│ ├── fixtures
│ │ ├── capabilities.json
│ │ └── stdio-server.js
│ ├── integration
│ │ ├── modules.capability-aggregator.test.ts
│ │ ├── modules.module-loader-health.test.ts
│ │ ├── oauth.callback-handler.test.ts
│ │ └── request-router.test.ts
│ ├── mocks
│ │ ├── mcp
│ │ │ └── fake-backend.ts
│ │ └── oauth
│ │ └── mock-oidc-provider.ts
│ ├── perf
│ │ ├── artillery
│ │ │ └── auth-routing.yaml
│ │ └── perf.auth-and-routing.test.ts
│ ├── security
│ │ └── security.oauth-and-input.test.ts
│ ├── servers
│ │ ├── test-auth-simple.js
│ │ ├── test-debug.js
│ │ ├── test-master-mcp.js
│ │ ├── test-mcp-client.js
│ │ ├── test-streaming-both-complete.js
│ │ ├── test-streaming-both-full.js
│ │ ├── test-streaming-both-simple.js
│ │ ├── test-streaming-both.js
│ │ └── test-streaming.js
│ ├── setup
│ │ └── test-setup.ts
│ ├── unit
│ │ ├── auth.multi-auth-manager.test.ts
│ │ ├── auth.token-manager.test.ts
│ │ ├── config.environment-manager.test.ts
│ │ ├── config.schema-validator.test.ts
│ │ ├── config.secret-manager.test.ts
│ │ ├── modules
│ │ │ ├── stdio-capability-discovery.test.ts
│ │ │ └── stdio-manager.test.ts
│ │ ├── modules.route-registry.test.ts
│ │ ├── oauth.pkce-state.test.ts
│ │ ├── routing
│ │ │ └── circuit-breaker.test.ts
│ │ ├── routing.core.test.ts
│ │ ├── stdio-capability-discovery.test.ts
│ │ ├── utils.crypto.test.ts
│ │ ├── utils.logger.test.ts
│ │ └── utils.monitoring.test.ts
│ └── utils
│ ├── fake-express.ts
│ ├── mock-http.ts
│ ├── oauth-mocks.ts
│ └── token-storages.ts
├── tsconfig.base.json
├── tsconfig.json
├── tsconfig.node.json
├── tsconfig.worker.json
├── typedoc.json
├── vitest.config.ts
└── vitest.worker.config.ts
```
# Files
--------------------------------------------------------------------------------
/docs/.vitepress/cache/deps/chunk-P2XGSYO7.js:
--------------------------------------------------------------------------------
```javascript
1 | import {
2 | Fragment,
3 | TransitionGroup,
4 | computed,
5 | customRef,
6 | defineComponent,
7 | effectScope,
8 | getCurrentInstance,
9 | getCurrentScope,
10 | h,
11 | hasInjectionContext,
12 | inject,
13 | isReactive,
14 | isReadonly,
15 | isRef,
16 | markRaw,
17 | nextTick,
18 | onBeforeMount,
19 | onBeforeUnmount,
20 | onBeforeUpdate,
21 | onMounted,
22 | onScopeDispose,
23 | onUnmounted,
24 | onUpdated,
25 | provide,
26 | reactive,
27 | readonly,
28 | ref,
29 | shallowReactive,
30 | shallowRef,
31 | toRaw,
32 | toRef,
33 | toRefs,
34 | toValue,
35 | unref,
36 | watch,
37 | watchEffect
38 | } from "./chunk-HVR2FF6M.js";
39 |
40 | // node_modules/@vueuse/shared/index.mjs
41 | function computedEager(fn, options) {
42 | var _a;
43 | const result = shallowRef();
44 | watchEffect(() => {
45 | result.value = fn();
46 | }, {
47 | ...options,
48 | flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync"
49 | });
50 | return readonly(result);
51 | }
52 | function computedWithControl(source, fn) {
53 | let v = void 0;
54 | let track;
55 | let trigger;
56 | const dirty = shallowRef(true);
57 | const update = () => {
58 | dirty.value = true;
59 | trigger();
60 | };
61 | watch(source, update, { flush: "sync" });
62 | const get2 = typeof fn === "function" ? fn : fn.get;
63 | const set2 = typeof fn === "function" ? void 0 : fn.set;
64 | const result = customRef((_track, _trigger) => {
65 | track = _track;
66 | trigger = _trigger;
67 | return {
68 | get() {
69 | if (dirty.value) {
70 | v = get2(v);
71 | dirty.value = false;
72 | }
73 | track();
74 | return v;
75 | },
76 | set(v2) {
77 | set2 == null ? void 0 : set2(v2);
78 | }
79 | };
80 | });
81 | if (Object.isExtensible(result))
82 | result.trigger = update;
83 | return result;
84 | }
85 | function tryOnScopeDispose(fn) {
86 | if (getCurrentScope()) {
87 | onScopeDispose(fn);
88 | return true;
89 | }
90 | return false;
91 | }
92 | function createEventHook() {
93 | const fns = /* @__PURE__ */ new Set();
94 | const off = (fn) => {
95 | fns.delete(fn);
96 | };
97 | const clear = () => {
98 | fns.clear();
99 | };
100 | const on = (fn) => {
101 | fns.add(fn);
102 | const offFn = () => off(fn);
103 | tryOnScopeDispose(offFn);
104 | return {
105 | off: offFn
106 | };
107 | };
108 | const trigger = (...args) => {
109 | return Promise.all(Array.from(fns).map((fn) => fn(...args)));
110 | };
111 | return {
112 | on,
113 | off,
114 | trigger,
115 | clear
116 | };
117 | }
118 | function createGlobalState(stateFactory) {
119 | let initialized = false;
120 | let state;
121 | const scope = effectScope(true);
122 | return (...args) => {
123 | if (!initialized) {
124 | state = scope.run(() => stateFactory(...args));
125 | initialized = true;
126 | }
127 | return state;
128 | };
129 | }
130 | var localProvidedStateMap = /* @__PURE__ */ new WeakMap();
131 | var injectLocal = (...args) => {
132 | var _a;
133 | const key = args[0];
134 | const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
135 | if (instance == null && !hasInjectionContext())
136 | throw new Error("injectLocal must be called in setup");
137 | if (instance && localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance))
138 | return localProvidedStateMap.get(instance)[key];
139 | return inject(...args);
140 | };
141 | var provideLocal = (key, value) => {
142 | var _a;
143 | const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
144 | if (instance == null)
145 | throw new Error("provideLocal must be called in setup");
146 | if (!localProvidedStateMap.has(instance))
147 | localProvidedStateMap.set(instance, /* @__PURE__ */ Object.create(null));
148 | const localProvidedState = localProvidedStateMap.get(instance);
149 | localProvidedState[key] = value;
150 | provide(key, value);
151 | };
152 | function createInjectionState(composable, options) {
153 | const key = (options == null ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
154 | const defaultValue = options == null ? void 0 : options.defaultValue;
155 | const useProvidingState = (...args) => {
156 | const state = composable(...args);
157 | provideLocal(key, state);
158 | return state;
159 | };
160 | const useInjectedState = () => injectLocal(key, defaultValue);
161 | return [useProvidingState, useInjectedState];
162 | }
163 | function createRef(value, deep) {
164 | if (deep === true) {
165 | return ref(value);
166 | } else {
167 | return shallowRef(value);
168 | }
169 | }
170 | function createSharedComposable(composable) {
171 | let subscribers = 0;
172 | let state;
173 | let scope;
174 | const dispose = () => {
175 | subscribers -= 1;
176 | if (scope && subscribers <= 0) {
177 | scope.stop();
178 | state = void 0;
179 | scope = void 0;
180 | }
181 | };
182 | return (...args) => {
183 | subscribers += 1;
184 | if (!scope) {
185 | scope = effectScope(true);
186 | state = scope.run(() => composable(...args));
187 | }
188 | tryOnScopeDispose(dispose);
189 | return state;
190 | };
191 | }
192 | function extendRef(ref2, extend, { enumerable = false, unwrap = true } = {}) {
193 | for (const [key, value] of Object.entries(extend)) {
194 | if (key === "value")
195 | continue;
196 | if (isRef(value) && unwrap) {
197 | Object.defineProperty(ref2, key, {
198 | get() {
199 | return value.value;
200 | },
201 | set(v) {
202 | value.value = v;
203 | },
204 | enumerable
205 | });
206 | } else {
207 | Object.defineProperty(ref2, key, { value, enumerable });
208 | }
209 | }
210 | return ref2;
211 | }
212 | function get(obj, key) {
213 | if (key == null)
214 | return unref(obj);
215 | return unref(obj)[key];
216 | }
217 | function isDefined(v) {
218 | return unref(v) != null;
219 | }
220 | function makeDestructurable(obj, arr) {
221 | if (typeof Symbol !== "undefined") {
222 | const clone = { ...obj };
223 | Object.defineProperty(clone, Symbol.iterator, {
224 | enumerable: false,
225 | value() {
226 | let index = 0;
227 | return {
228 | next: () => ({
229 | value: arr[index++],
230 | done: index > arr.length
231 | })
232 | };
233 | }
234 | });
235 | return clone;
236 | } else {
237 | return Object.assign([...arr], obj);
238 | }
239 | }
240 | function reactify(fn, options) {
241 | const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? unref : toValue;
242 | return function(...args) {
243 | return computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
244 | };
245 | }
246 | function reactifyObject(obj, optionsOrKeys = {}) {
247 | let keys2 = [];
248 | let options;
249 | if (Array.isArray(optionsOrKeys)) {
250 | keys2 = optionsOrKeys;
251 | } else {
252 | options = optionsOrKeys;
253 | const { includeOwnProperties = true } = optionsOrKeys;
254 | keys2.push(...Object.keys(obj));
255 | if (includeOwnProperties)
256 | keys2.push(...Object.getOwnPropertyNames(obj));
257 | }
258 | return Object.fromEntries(
259 | keys2.map((key) => {
260 | const value = obj[key];
261 | return [
262 | key,
263 | typeof value === "function" ? reactify(value.bind(obj), options) : value
264 | ];
265 | })
266 | );
267 | }
268 | function toReactive(objectRef) {
269 | if (!isRef(objectRef))
270 | return reactive(objectRef);
271 | const proxy = new Proxy({}, {
272 | get(_, p, receiver) {
273 | return unref(Reflect.get(objectRef.value, p, receiver));
274 | },
275 | set(_, p, value) {
276 | if (isRef(objectRef.value[p]) && !isRef(value))
277 | objectRef.value[p].value = value;
278 | else
279 | objectRef.value[p] = value;
280 | return true;
281 | },
282 | deleteProperty(_, p) {
283 | return Reflect.deleteProperty(objectRef.value, p);
284 | },
285 | has(_, p) {
286 | return Reflect.has(objectRef.value, p);
287 | },
288 | ownKeys() {
289 | return Object.keys(objectRef.value);
290 | },
291 | getOwnPropertyDescriptor() {
292 | return {
293 | enumerable: true,
294 | configurable: true
295 | };
296 | }
297 | });
298 | return reactive(proxy);
299 | }
300 | function reactiveComputed(fn) {
301 | return toReactive(computed(fn));
302 | }
303 | function reactiveOmit(obj, ...keys2) {
304 | const flatKeys = keys2.flat();
305 | const predicate = flatKeys[0];
306 | return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
307 | }
308 | var isClient = typeof window !== "undefined" && typeof document !== "undefined";
309 | var isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
310 | var isDef = (val) => typeof val !== "undefined";
311 | var notNullish = (val) => val != null;
312 | var assert = (condition, ...infos) => {
313 | if (!condition)
314 | console.warn(...infos);
315 | };
316 | var toString = Object.prototype.toString;
317 | var isObject = (val) => toString.call(val) === "[object Object]";
318 | var now = () => Date.now();
319 | var timestamp = () => +Date.now();
320 | var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
321 | var noop = () => {
322 | };
323 | var rand = (min, max) => {
324 | min = Math.ceil(min);
325 | max = Math.floor(max);
326 | return Math.floor(Math.random() * (max - min + 1)) + min;
327 | };
328 | var hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
329 | var isIOS = getIsIOS();
330 | function getIsIOS() {
331 | var _a, _b;
332 | return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_b = window == null ? void 0 : window.navigator) == null ? void 0 : _b.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window == null ? void 0 : window.navigator.userAgent));
333 | }
334 | function createFilterWrapper(filter, fn) {
335 | function wrapper(...args) {
336 | return new Promise((resolve, reject) => {
337 | Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
338 | });
339 | }
340 | return wrapper;
341 | }
342 | var bypassFilter = (invoke2) => {
343 | return invoke2();
344 | };
345 | function debounceFilter(ms, options = {}) {
346 | let timer;
347 | let maxTimer;
348 | let lastRejector = noop;
349 | const _clearTimeout = (timer2) => {
350 | clearTimeout(timer2);
351 | lastRejector();
352 | lastRejector = noop;
353 | };
354 | let lastInvoker;
355 | const filter = (invoke2) => {
356 | const duration = toValue(ms);
357 | const maxDuration = toValue(options.maxWait);
358 | if (timer)
359 | _clearTimeout(timer);
360 | if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
361 | if (maxTimer) {
362 | _clearTimeout(maxTimer);
363 | maxTimer = null;
364 | }
365 | return Promise.resolve(invoke2());
366 | }
367 | return new Promise((resolve, reject) => {
368 | lastRejector = options.rejectOnCancel ? reject : resolve;
369 | lastInvoker = invoke2;
370 | if (maxDuration && !maxTimer) {
371 | maxTimer = setTimeout(() => {
372 | if (timer)
373 | _clearTimeout(timer);
374 | maxTimer = null;
375 | resolve(lastInvoker());
376 | }, maxDuration);
377 | }
378 | timer = setTimeout(() => {
379 | if (maxTimer)
380 | _clearTimeout(maxTimer);
381 | maxTimer = null;
382 | resolve(invoke2());
383 | }, duration);
384 | });
385 | };
386 | return filter;
387 | }
388 | function throttleFilter(...args) {
389 | let lastExec = 0;
390 | let timer;
391 | let isLeading = true;
392 | let lastRejector = noop;
393 | let lastValue;
394 | let ms;
395 | let trailing;
396 | let leading;
397 | let rejectOnCancel;
398 | if (!isRef(args[0]) && typeof args[0] === "object")
399 | ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
400 | else
401 | [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
402 | const clear = () => {
403 | if (timer) {
404 | clearTimeout(timer);
405 | timer = void 0;
406 | lastRejector();
407 | lastRejector = noop;
408 | }
409 | };
410 | const filter = (_invoke) => {
411 | const duration = toValue(ms);
412 | const elapsed = Date.now() - lastExec;
413 | const invoke2 = () => {
414 | return lastValue = _invoke();
415 | };
416 | clear();
417 | if (duration <= 0) {
418 | lastExec = Date.now();
419 | return invoke2();
420 | }
421 | if (elapsed > duration && (leading || !isLeading)) {
422 | lastExec = Date.now();
423 | invoke2();
424 | } else if (trailing) {
425 | lastValue = new Promise((resolve, reject) => {
426 | lastRejector = rejectOnCancel ? reject : resolve;
427 | timer = setTimeout(() => {
428 | lastExec = Date.now();
429 | isLeading = true;
430 | resolve(invoke2());
431 | clear();
432 | }, Math.max(0, duration - elapsed));
433 | });
434 | }
435 | if (!leading && !timer)
436 | timer = setTimeout(() => isLeading = true, duration);
437 | isLeading = false;
438 | return lastValue;
439 | };
440 | return filter;
441 | }
442 | function pausableFilter(extendFilter = bypassFilter, options = {}) {
443 | const {
444 | initialState = "active"
445 | } = options;
446 | const isActive = toRef2(initialState === "active");
447 | function pause() {
448 | isActive.value = false;
449 | }
450 | function resume() {
451 | isActive.value = true;
452 | }
453 | const eventFilter = (...args) => {
454 | if (isActive.value)
455 | extendFilter(...args);
456 | };
457 | return { isActive: readonly(isActive), pause, resume, eventFilter };
458 | }
459 | function cacheStringFunction(fn) {
460 | const cache = /* @__PURE__ */ Object.create(null);
461 | return (str) => {
462 | const hit = cache[str];
463 | return hit || (cache[str] = fn(str));
464 | };
465 | }
466 | var hyphenateRE = /\B([A-Z])/g;
467 | var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
468 | var camelizeRE = /-(\w)/g;
469 | var camelize = cacheStringFunction((str) => {
470 | return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
471 | });
472 | function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
473 | return new Promise((resolve, reject) => {
474 | if (throwOnTimeout)
475 | setTimeout(() => reject(reason), ms);
476 | else
477 | setTimeout(resolve, ms);
478 | });
479 | }
480 | function identity(arg) {
481 | return arg;
482 | }
483 | function createSingletonPromise(fn) {
484 | let _promise;
485 | function wrapper() {
486 | if (!_promise)
487 | _promise = fn();
488 | return _promise;
489 | }
490 | wrapper.reset = async () => {
491 | const _prev = _promise;
492 | _promise = void 0;
493 | if (_prev)
494 | await _prev;
495 | };
496 | return wrapper;
497 | }
498 | function invoke(fn) {
499 | return fn();
500 | }
501 | function containsProp(obj, ...props) {
502 | return props.some((k) => k in obj);
503 | }
504 | function increaseWithUnit(target, delta) {
505 | var _a;
506 | if (typeof target === "number")
507 | return target + delta;
508 | const value = ((_a = target.match(/^-?\d+\.?\d*/)) == null ? void 0 : _a[0]) || "";
509 | const unit = target.slice(value.length);
510 | const result = Number.parseFloat(value) + delta;
511 | if (Number.isNaN(result))
512 | return target;
513 | return result + unit;
514 | }
515 | function pxValue(px) {
516 | return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px);
517 | }
518 | function objectPick(obj, keys2, omitUndefined = false) {
519 | return keys2.reduce((n, k) => {
520 | if (k in obj) {
521 | if (!omitUndefined || obj[k] !== void 0)
522 | n[k] = obj[k];
523 | }
524 | return n;
525 | }, {});
526 | }
527 | function objectOmit(obj, keys2, omitUndefined = false) {
528 | return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
529 | return (!omitUndefined || value !== void 0) && !keys2.includes(key);
530 | }));
531 | }
532 | function objectEntries(obj) {
533 | return Object.entries(obj);
534 | }
535 | function getLifeCycleTarget(target) {
536 | return target || getCurrentInstance();
537 | }
538 | function toArray(value) {
539 | return Array.isArray(value) ? value : [value];
540 | }
541 | function toRef2(...args) {
542 | if (args.length !== 1)
543 | return toRef(...args);
544 | const r = args[0];
545 | return typeof r === "function" ? readonly(customRef(() => ({ get: r, set: noop }))) : ref(r);
546 | }
547 | var resolveRef = toRef2;
548 | function reactivePick(obj, ...keys2) {
549 | const flatKeys = keys2.flat();
550 | const predicate = flatKeys[0];
551 | return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef2(obj, k)])));
552 | }
553 | function refAutoReset(defaultValue, afterMs = 1e4) {
554 | return customRef((track, trigger) => {
555 | let value = toValue(defaultValue);
556 | let timer;
557 | const resetAfter = () => setTimeout(() => {
558 | value = toValue(defaultValue);
559 | trigger();
560 | }, toValue(afterMs));
561 | tryOnScopeDispose(() => {
562 | clearTimeout(timer);
563 | });
564 | return {
565 | get() {
566 | track();
567 | return value;
568 | },
569 | set(newValue) {
570 | value = newValue;
571 | trigger();
572 | clearTimeout(timer);
573 | timer = resetAfter();
574 | }
575 | };
576 | });
577 | }
578 | function useDebounceFn(fn, ms = 200, options = {}) {
579 | return createFilterWrapper(
580 | debounceFilter(ms, options),
581 | fn
582 | );
583 | }
584 | function refDebounced(value, ms = 200, options = {}) {
585 | const debounced = ref(value.value);
586 | const updater = useDebounceFn(() => {
587 | debounced.value = value.value;
588 | }, ms, options);
589 | watch(value, () => updater());
590 | return debounced;
591 | }
592 | function refDefault(source, defaultValue) {
593 | return computed({
594 | get() {
595 | var _a;
596 | return (_a = source.value) != null ? _a : defaultValue;
597 | },
598 | set(value) {
599 | source.value = value;
600 | }
601 | });
602 | }
603 | function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
604 | return createFilterWrapper(
605 | throttleFilter(ms, trailing, leading, rejectOnCancel),
606 | fn
607 | );
608 | }
609 | function refThrottled(value, delay = 200, trailing = true, leading = true) {
610 | if (delay <= 0)
611 | return value;
612 | const throttled = ref(value.value);
613 | const updater = useThrottleFn(() => {
614 | throttled.value = value.value;
615 | }, delay, trailing, leading);
616 | watch(value, () => updater());
617 | return throttled;
618 | }
619 | function refWithControl(initial, options = {}) {
620 | let source = initial;
621 | let track;
622 | let trigger;
623 | const ref2 = customRef((_track, _trigger) => {
624 | track = _track;
625 | trigger = _trigger;
626 | return {
627 | get() {
628 | return get2();
629 | },
630 | set(v) {
631 | set2(v);
632 | }
633 | };
634 | });
635 | function get2(tracking = true) {
636 | if (tracking)
637 | track();
638 | return source;
639 | }
640 | function set2(value, triggering = true) {
641 | var _a, _b;
642 | if (value === source)
643 | return;
644 | const old = source;
645 | if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
646 | return;
647 | source = value;
648 | (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
649 | if (triggering)
650 | trigger();
651 | }
652 | const untrackedGet = () => get2(false);
653 | const silentSet = (v) => set2(v, false);
654 | const peek = () => get2(false);
655 | const lay = (v) => set2(v, false);
656 | return extendRef(
657 | ref2,
658 | {
659 | get: get2,
660 | set: set2,
661 | untrackedGet,
662 | silentSet,
663 | peek,
664 | lay
665 | },
666 | { enumerable: true }
667 | );
668 | }
669 | var controlledRef = refWithControl;
670 | function set(...args) {
671 | if (args.length === 2) {
672 | const [ref2, value] = args;
673 | ref2.value = value;
674 | }
675 | if (args.length === 3) {
676 | const [target, key, value] = args;
677 | target[key] = value;
678 | }
679 | }
680 | function watchWithFilter(source, cb, options = {}) {
681 | const {
682 | eventFilter = bypassFilter,
683 | ...watchOptions
684 | } = options;
685 | return watch(
686 | source,
687 | createFilterWrapper(
688 | eventFilter,
689 | cb
690 | ),
691 | watchOptions
692 | );
693 | }
694 | function watchPausable(source, cb, options = {}) {
695 | const {
696 | eventFilter: filter,
697 | initialState = "active",
698 | ...watchOptions
699 | } = options;
700 | const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState });
701 | const stop = watchWithFilter(
702 | source,
703 | cb,
704 | {
705 | ...watchOptions,
706 | eventFilter
707 | }
708 | );
709 | return { stop, pause, resume, isActive };
710 | }
711 | function syncRef(left, right, ...[options]) {
712 | const {
713 | flush = "sync",
714 | deep = false,
715 | immediate = true,
716 | direction = "both",
717 | transform = {}
718 | } = options || {};
719 | const watchers = [];
720 | const transformLTR = "ltr" in transform && transform.ltr || ((v) => v);
721 | const transformRTL = "rtl" in transform && transform.rtl || ((v) => v);
722 | if (direction === "both" || direction === "ltr") {
723 | watchers.push(watchPausable(
724 | left,
725 | (newValue) => {
726 | watchers.forEach((w) => w.pause());
727 | right.value = transformLTR(newValue);
728 | watchers.forEach((w) => w.resume());
729 | },
730 | { flush, deep, immediate }
731 | ));
732 | }
733 | if (direction === "both" || direction === "rtl") {
734 | watchers.push(watchPausable(
735 | right,
736 | (newValue) => {
737 | watchers.forEach((w) => w.pause());
738 | left.value = transformRTL(newValue);
739 | watchers.forEach((w) => w.resume());
740 | },
741 | { flush, deep, immediate }
742 | ));
743 | }
744 | const stop = () => {
745 | watchers.forEach((w) => w.stop());
746 | };
747 | return stop;
748 | }
749 | function syncRefs(source, targets, options = {}) {
750 | const {
751 | flush = "sync",
752 | deep = false,
753 | immediate = true
754 | } = options;
755 | const targetsArray = toArray(targets);
756 | return watch(
757 | source,
758 | (newValue) => targetsArray.forEach((target) => target.value = newValue),
759 | { flush, deep, immediate }
760 | );
761 | }
762 | function toRefs2(objectRef, options = {}) {
763 | if (!isRef(objectRef))
764 | return toRefs(objectRef);
765 | const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
766 | for (const key in objectRef.value) {
767 | result[key] = customRef(() => ({
768 | get() {
769 | return objectRef.value[key];
770 | },
771 | set(v) {
772 | var _a;
773 | const replaceRef = (_a = toValue(options.replaceRef)) != null ? _a : true;
774 | if (replaceRef) {
775 | if (Array.isArray(objectRef.value)) {
776 | const copy = [...objectRef.value];
777 | copy[key] = v;
778 | objectRef.value = copy;
779 | } else {
780 | const newObject = { ...objectRef.value, [key]: v };
781 | Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
782 | objectRef.value = newObject;
783 | }
784 | } else {
785 | objectRef.value[key] = v;
786 | }
787 | }
788 | }));
789 | }
790 | return result;
791 | }
792 | var toValue2 = toValue;
793 | var resolveUnref = toValue;
794 | function tryOnBeforeMount(fn, sync = true, target) {
795 | const instance = getLifeCycleTarget(target);
796 | if (instance)
797 | onBeforeMount(fn, target);
798 | else if (sync)
799 | fn();
800 | else
801 | nextTick(fn);
802 | }
803 | function tryOnBeforeUnmount(fn, target) {
804 | const instance = getLifeCycleTarget(target);
805 | if (instance)
806 | onBeforeUnmount(fn, target);
807 | }
808 | function tryOnMounted(fn, sync = true, target) {
809 | const instance = getLifeCycleTarget();
810 | if (instance)
811 | onMounted(fn, target);
812 | else if (sync)
813 | fn();
814 | else
815 | nextTick(fn);
816 | }
817 | function tryOnUnmounted(fn, target) {
818 | const instance = getLifeCycleTarget(target);
819 | if (instance)
820 | onUnmounted(fn, target);
821 | }
822 | function createUntil(r, isNot = false) {
823 | function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
824 | let stop = null;
825 | const watcher = new Promise((resolve) => {
826 | stop = watch(
827 | r,
828 | (v) => {
829 | if (condition(v) !== isNot) {
830 | if (stop)
831 | stop();
832 | else
833 | nextTick(() => stop == null ? void 0 : stop());
834 | resolve(v);
835 | }
836 | },
837 | {
838 | flush,
839 | deep,
840 | immediate: true
841 | }
842 | );
843 | });
844 | const promises = [watcher];
845 | if (timeout != null) {
846 | promises.push(
847 | promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ? void 0 : stop())
848 | );
849 | }
850 | return Promise.race(promises);
851 | }
852 | function toBe(value, options) {
853 | if (!isRef(value))
854 | return toMatch((v) => v === value, options);
855 | const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
856 | let stop = null;
857 | const watcher = new Promise((resolve) => {
858 | stop = watch(
859 | [r, value],
860 | ([v1, v2]) => {
861 | if (isNot !== (v1 === v2)) {
862 | if (stop)
863 | stop();
864 | else
865 | nextTick(() => stop == null ? void 0 : stop());
866 | resolve(v1);
867 | }
868 | },
869 | {
870 | flush,
871 | deep,
872 | immediate: true
873 | }
874 | );
875 | });
876 | const promises = [watcher];
877 | if (timeout != null) {
878 | promises.push(
879 | promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
880 | stop == null ? void 0 : stop();
881 | return toValue(r);
882 | })
883 | );
884 | }
885 | return Promise.race(promises);
886 | }
887 | function toBeTruthy(options) {
888 | return toMatch((v) => Boolean(v), options);
889 | }
890 | function toBeNull(options) {
891 | return toBe(null, options);
892 | }
893 | function toBeUndefined(options) {
894 | return toBe(void 0, options);
895 | }
896 | function toBeNaN(options) {
897 | return toMatch(Number.isNaN, options);
898 | }
899 | function toContains(value, options) {
900 | return toMatch((v) => {
901 | const array = Array.from(v);
902 | return array.includes(value) || array.includes(toValue(value));
903 | }, options);
904 | }
905 | function changed(options) {
906 | return changedTimes(1, options);
907 | }
908 | function changedTimes(n = 1, options) {
909 | let count = -1;
910 | return toMatch(() => {
911 | count += 1;
912 | return count >= n;
913 | }, options);
914 | }
915 | if (Array.isArray(toValue(r))) {
916 | const instance = {
917 | toMatch,
918 | toContains,
919 | changed,
920 | changedTimes,
921 | get not() {
922 | return createUntil(r, !isNot);
923 | }
924 | };
925 | return instance;
926 | } else {
927 | const instance = {
928 | toMatch,
929 | toBe,
930 | toBeTruthy,
931 | toBeNull,
932 | toBeNaN,
933 | toBeUndefined,
934 | changed,
935 | changedTimes,
936 | get not() {
937 | return createUntil(r, !isNot);
938 | }
939 | };
940 | return instance;
941 | }
942 | }
943 | function until(r) {
944 | return createUntil(r);
945 | }
946 | function defaultComparator(value, othVal) {
947 | return value === othVal;
948 | }
949 | function useArrayDifference(...args) {
950 | var _a, _b;
951 | const list = args[0];
952 | const values = args[1];
953 | let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
954 | const {
955 | symmetric = false
956 | } = (_b = args[3]) != null ? _b : {};
957 | if (typeof compareFn === "string") {
958 | const key = compareFn;
959 | compareFn = (value, othVal) => value[key] === othVal[key];
960 | }
961 | const diff1 = computed(() => toValue(list).filter((x) => toValue(values).findIndex((y) => compareFn(x, y)) === -1));
962 | if (symmetric) {
963 | const diff2 = computed(() => toValue(values).filter((x) => toValue(list).findIndex((y) => compareFn(x, y)) === -1));
964 | return computed(() => symmetric ? [...toValue(diff1), ...toValue(diff2)] : toValue(diff1));
965 | } else {
966 | return diff1;
967 | }
968 | }
969 | function useArrayEvery(list, fn) {
970 | return computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
971 | }
972 | function useArrayFilter(list, fn) {
973 | return computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
974 | }
975 | function useArrayFind(list, fn) {
976 | return computed(() => toValue(
977 | toValue(list).find((element, index, array) => fn(toValue(element), index, array))
978 | ));
979 | }
980 | function useArrayFindIndex(list, fn) {
981 | return computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
982 | }
983 | function findLast(arr, cb) {
984 | let index = arr.length;
985 | while (index-- > 0) {
986 | if (cb(arr[index], index, arr))
987 | return arr[index];
988 | }
989 | return void 0;
990 | }
991 | function useArrayFindLast(list, fn) {
992 | return computed(() => toValue(
993 | !Array.prototype.findLast ? findLast(toValue(list), (element, index, array) => fn(toValue(element), index, array)) : toValue(list).findLast((element, index, array) => fn(toValue(element), index, array))
994 | ));
995 | }
996 | function isArrayIncludesOptions(obj) {
997 | return isObject(obj) && containsProp(obj, "formIndex", "comparator");
998 | }
999 | function useArrayIncludes(...args) {
1000 | var _a;
1001 | const list = args[0];
1002 | const value = args[1];
1003 | let comparator = args[2];
1004 | let formIndex = 0;
1005 | if (isArrayIncludesOptions(comparator)) {
1006 | formIndex = (_a = comparator.fromIndex) != null ? _a : 0;
1007 | comparator = comparator.comparator;
1008 | }
1009 | if (typeof comparator === "string") {
1010 | const key = comparator;
1011 | comparator = (element, value2) => element[key] === toValue(value2);
1012 | }
1013 | comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
1014 | return computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(
1015 | toValue(element),
1016 | toValue(value),
1017 | index,
1018 | toValue(array)
1019 | )));
1020 | }
1021 | function useArrayJoin(list, separator) {
1022 | return computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
1023 | }
1024 | function useArrayMap(list, fn) {
1025 | return computed(() => toValue(list).map((i) => toValue(i)).map(fn));
1026 | }
1027 | function useArrayReduce(list, reducer, ...args) {
1028 | const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index);
1029 | return computed(() => {
1030 | const resolved = toValue(list);
1031 | return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? toValue(args[0]()) : toValue(args[0])) : resolved.reduce(reduceCallback);
1032 | });
1033 | }
1034 | function useArraySome(list, fn) {
1035 | return computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
1036 | }
1037 | function uniq(array) {
1038 | return Array.from(new Set(array));
1039 | }
1040 | function uniqueElementsBy(array, fn) {
1041 | return array.reduce((acc, v) => {
1042 | if (!acc.some((x) => fn(v, x, array)))
1043 | acc.push(v);
1044 | return acc;
1045 | }, []);
1046 | }
1047 | function useArrayUnique(list, compareFn) {
1048 | return computed(() => {
1049 | const resolvedList = toValue(list).map((element) => toValue(element));
1050 | return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
1051 | });
1052 | }
1053 | function useCounter(initialValue = 0, options = {}) {
1054 | let _initialValue = unref(initialValue);
1055 | const count = shallowRef(initialValue);
1056 | const {
1057 | max = Number.POSITIVE_INFINITY,
1058 | min = Number.NEGATIVE_INFINITY
1059 | } = options;
1060 | const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min);
1061 | const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max);
1062 | const get2 = () => count.value;
1063 | const set2 = (val) => count.value = Math.max(min, Math.min(max, val));
1064 | const reset = (val = _initialValue) => {
1065 | _initialValue = val;
1066 | return set2(val);
1067 | };
1068 | return { count, inc, dec, get: get2, set: set2, reset };
1069 | }
1070 | var REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
1071 | var REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g;
1072 | function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
1073 | let m = hours < 12 ? "AM" : "PM";
1074 | if (hasPeriod)
1075 | m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
1076 | return isLowercase ? m.toLowerCase() : m;
1077 | }
1078 | function formatOrdinal(num) {
1079 | const suffixes = ["th", "st", "nd", "rd"];
1080 | const v = num % 100;
1081 | return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);
1082 | }
1083 | function formatDate(date, formatStr, options = {}) {
1084 | var _a;
1085 | const years = date.getFullYear();
1086 | const month = date.getMonth();
1087 | const days = date.getDate();
1088 | const hours = date.getHours();
1089 | const minutes = date.getMinutes();
1090 | const seconds = date.getSeconds();
1091 | const milliseconds = date.getMilliseconds();
1092 | const day = date.getDay();
1093 | const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
1094 | const stripTimeZone = (dateString) => {
1095 | var _a2;
1096 | return (_a2 = dateString.split(" ")[1]) != null ? _a2 : "";
1097 | };
1098 | const matches = {
1099 | Yo: () => formatOrdinal(years),
1100 | YY: () => String(years).slice(-2),
1101 | YYYY: () => years,
1102 | M: () => month + 1,
1103 | Mo: () => formatOrdinal(month + 1),
1104 | MM: () => `${month + 1}`.padStart(2, "0"),
1105 | MMM: () => date.toLocaleDateString(toValue(options.locales), { month: "short" }),
1106 | MMMM: () => date.toLocaleDateString(toValue(options.locales), { month: "long" }),
1107 | D: () => String(days),
1108 | Do: () => formatOrdinal(days),
1109 | DD: () => `${days}`.padStart(2, "0"),
1110 | H: () => String(hours),
1111 | Ho: () => formatOrdinal(hours),
1112 | HH: () => `${hours}`.padStart(2, "0"),
1113 | h: () => `${hours % 12 || 12}`.padStart(1, "0"),
1114 | ho: () => formatOrdinal(hours % 12 || 12),
1115 | hh: () => `${hours % 12 || 12}`.padStart(2, "0"),
1116 | m: () => String(minutes),
1117 | mo: () => formatOrdinal(minutes),
1118 | mm: () => `${minutes}`.padStart(2, "0"),
1119 | s: () => String(seconds),
1120 | so: () => formatOrdinal(seconds),
1121 | ss: () => `${seconds}`.padStart(2, "0"),
1122 | SSS: () => `${milliseconds}`.padStart(3, "0"),
1123 | d: () => day,
1124 | dd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "narrow" }),
1125 | ddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "short" }),
1126 | dddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "long" }),
1127 | A: () => meridiem(hours, minutes),
1128 | AA: () => meridiem(hours, minutes, false, true),
1129 | a: () => meridiem(hours, minutes, true),
1130 | aa: () => meridiem(hours, minutes, true, true),
1131 | z: () => stripTimeZone(date.toLocaleDateString(toValue(options.locales), { timeZoneName: "shortOffset" })),
1132 | zz: () => stripTimeZone(date.toLocaleDateString(toValue(options.locales), { timeZoneName: "shortOffset" })),
1133 | zzz: () => stripTimeZone(date.toLocaleDateString(toValue(options.locales), { timeZoneName: "shortOffset" })),
1134 | zzzz: () => stripTimeZone(date.toLocaleDateString(toValue(options.locales), { timeZoneName: "longOffset" }))
1135 | };
1136 | return formatStr.replace(REGEX_FORMAT, (match, $1) => {
1137 | var _a2, _b;
1138 | return (_b = $1 != null ? $1 : (_a2 = matches[match]) == null ? void 0 : _a2.call(matches)) != null ? _b : match;
1139 | });
1140 | }
1141 | function normalizeDate(date) {
1142 | if (date === null)
1143 | return new Date(Number.NaN);
1144 | if (date === void 0)
1145 | return /* @__PURE__ */ new Date();
1146 | if (date instanceof Date)
1147 | return new Date(date);
1148 | if (typeof date === "string" && !/Z$/i.test(date)) {
1149 | const d = date.match(REGEX_PARSE);
1150 | if (d) {
1151 | const m = d[2] - 1 || 0;
1152 | const ms = (d[7] || "0").substring(0, 3);
1153 | return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
1154 | }
1155 | }
1156 | return new Date(date);
1157 | }
1158 | function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
1159 | return computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
1160 | }
1161 | function useIntervalFn(cb, interval = 1e3, options = {}) {
1162 | const {
1163 | immediate = true,
1164 | immediateCallback = false
1165 | } = options;
1166 | let timer = null;
1167 | const isActive = shallowRef(false);
1168 | function clean() {
1169 | if (timer) {
1170 | clearInterval(timer);
1171 | timer = null;
1172 | }
1173 | }
1174 | function pause() {
1175 | isActive.value = false;
1176 | clean();
1177 | }
1178 | function resume() {
1179 | const intervalValue = toValue(interval);
1180 | if (intervalValue <= 0)
1181 | return;
1182 | isActive.value = true;
1183 | if (immediateCallback)
1184 | cb();
1185 | clean();
1186 | if (isActive.value)
1187 | timer = setInterval(cb, intervalValue);
1188 | }
1189 | if (immediate && isClient)
1190 | resume();
1191 | if (isRef(interval) || typeof interval === "function") {
1192 | const stopWatch = watch(interval, () => {
1193 | if (isActive.value && isClient)
1194 | resume();
1195 | });
1196 | tryOnScopeDispose(stopWatch);
1197 | }
1198 | tryOnScopeDispose(pause);
1199 | return {
1200 | isActive,
1201 | pause,
1202 | resume
1203 | };
1204 | }
1205 | function useInterval(interval = 1e3, options = {}) {
1206 | const {
1207 | controls: exposeControls = false,
1208 | immediate = true,
1209 | callback
1210 | } = options;
1211 | const counter = shallowRef(0);
1212 | const update = () => counter.value += 1;
1213 | const reset = () => {
1214 | counter.value = 0;
1215 | };
1216 | const controls = useIntervalFn(
1217 | callback ? () => {
1218 | update();
1219 | callback(counter.value);
1220 | } : update,
1221 | interval,
1222 | { immediate }
1223 | );
1224 | if (exposeControls) {
1225 | return {
1226 | counter,
1227 | reset,
1228 | ...controls
1229 | };
1230 | } else {
1231 | return counter;
1232 | }
1233 | }
1234 | function useLastChanged(source, options = {}) {
1235 | var _a;
1236 | const ms = shallowRef((_a = options.initialValue) != null ? _a : null);
1237 | watch(
1238 | source,
1239 | () => ms.value = timestamp(),
1240 | options
1241 | );
1242 | return ms;
1243 | }
1244 | function useTimeoutFn(cb, interval, options = {}) {
1245 | const {
1246 | immediate = true,
1247 | immediateCallback = false
1248 | } = options;
1249 | const isPending = shallowRef(false);
1250 | let timer = null;
1251 | function clear() {
1252 | if (timer) {
1253 | clearTimeout(timer);
1254 | timer = null;
1255 | }
1256 | }
1257 | function stop() {
1258 | isPending.value = false;
1259 | clear();
1260 | }
1261 | function start(...args) {
1262 | if (immediateCallback)
1263 | cb();
1264 | clear();
1265 | isPending.value = true;
1266 | timer = setTimeout(() => {
1267 | isPending.value = false;
1268 | timer = null;
1269 | cb(...args);
1270 | }, toValue(interval));
1271 | }
1272 | if (immediate) {
1273 | isPending.value = true;
1274 | if (isClient)
1275 | start();
1276 | }
1277 | tryOnScopeDispose(stop);
1278 | return {
1279 | isPending: readonly(isPending),
1280 | start,
1281 | stop
1282 | };
1283 | }
1284 | function useTimeout(interval = 1e3, options = {}) {
1285 | const {
1286 | controls: exposeControls = false,
1287 | callback
1288 | } = options;
1289 | const controls = useTimeoutFn(
1290 | callback != null ? callback : noop,
1291 | interval,
1292 | options
1293 | );
1294 | const ready = computed(() => !controls.isPending.value);
1295 | if (exposeControls) {
1296 | return {
1297 | ready,
1298 | ...controls
1299 | };
1300 | } else {
1301 | return ready;
1302 | }
1303 | }
1304 | function useToNumber(value, options = {}) {
1305 | const {
1306 | method = "parseFloat",
1307 | radix,
1308 | nanToZero
1309 | } = options;
1310 | return computed(() => {
1311 | let resolved = toValue(value);
1312 | if (typeof method === "function")
1313 | resolved = method(resolved);
1314 | else if (typeof resolved === "string")
1315 | resolved = Number[method](resolved, radix);
1316 | if (nanToZero && Number.isNaN(resolved))
1317 | resolved = 0;
1318 | return resolved;
1319 | });
1320 | }
1321 | function useToString(value) {
1322 | return computed(() => `${toValue(value)}`);
1323 | }
1324 | function useToggle(initialValue = false, options = {}) {
1325 | const {
1326 | truthyValue = true,
1327 | falsyValue = false
1328 | } = options;
1329 | const valueIsRef = isRef(initialValue);
1330 | const _value = shallowRef(initialValue);
1331 | function toggle(value) {
1332 | if (arguments.length) {
1333 | _value.value = value;
1334 | return _value.value;
1335 | } else {
1336 | const truthy = toValue(truthyValue);
1337 | _value.value = _value.value === truthy ? toValue(falsyValue) : truthy;
1338 | return _value.value;
1339 | }
1340 | }
1341 | if (valueIsRef)
1342 | return toggle;
1343 | else
1344 | return [_value, toggle];
1345 | }
1346 | function watchArray(source, cb, options) {
1347 | let oldList = (options == null ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : toValue(source)];
1348 | return watch(source, (newList, _, onCleanup) => {
1349 | const oldListRemains = Array.from({ length: oldList.length });
1350 | const added = [];
1351 | for (const obj of newList) {
1352 | let found = false;
1353 | for (let i = 0; i < oldList.length; i++) {
1354 | if (!oldListRemains[i] && obj === oldList[i]) {
1355 | oldListRemains[i] = true;
1356 | found = true;
1357 | break;
1358 | }
1359 | }
1360 | if (!found)
1361 | added.push(obj);
1362 | }
1363 | const removed = oldList.filter((_2, i) => !oldListRemains[i]);
1364 | cb(newList, oldList, added, removed, onCleanup);
1365 | oldList = [...newList];
1366 | }, options);
1367 | }
1368 | function watchAtMost(source, cb, options) {
1369 | const {
1370 | count,
1371 | ...watchOptions
1372 | } = options;
1373 | const current = shallowRef(0);
1374 | const stop = watchWithFilter(
1375 | source,
1376 | (...args) => {
1377 | current.value += 1;
1378 | if (current.value >= toValue(count))
1379 | nextTick(() => stop());
1380 | cb(...args);
1381 | },
1382 | watchOptions
1383 | );
1384 | return { count: current, stop };
1385 | }
1386 | function watchDebounced(source, cb, options = {}) {
1387 | const {
1388 | debounce = 0,
1389 | maxWait = void 0,
1390 | ...watchOptions
1391 | } = options;
1392 | return watchWithFilter(
1393 | source,
1394 | cb,
1395 | {
1396 | ...watchOptions,
1397 | eventFilter: debounceFilter(debounce, { maxWait })
1398 | }
1399 | );
1400 | }
1401 | function watchDeep(source, cb, options) {
1402 | return watch(
1403 | source,
1404 | cb,
1405 | {
1406 | ...options,
1407 | deep: true
1408 | }
1409 | );
1410 | }
1411 | function watchIgnorable(source, cb, options = {}) {
1412 | const {
1413 | eventFilter = bypassFilter,
1414 | ...watchOptions
1415 | } = options;
1416 | const filteredCb = createFilterWrapper(
1417 | eventFilter,
1418 | cb
1419 | );
1420 | let ignoreUpdates;
1421 | let ignorePrevAsyncUpdates;
1422 | let stop;
1423 | if (watchOptions.flush === "sync") {
1424 | const ignore = shallowRef(false);
1425 | ignorePrevAsyncUpdates = () => {
1426 | };
1427 | ignoreUpdates = (updater) => {
1428 | ignore.value = true;
1429 | updater();
1430 | ignore.value = false;
1431 | };
1432 | stop = watch(
1433 | source,
1434 | (...args) => {
1435 | if (!ignore.value)
1436 | filteredCb(...args);
1437 | },
1438 | watchOptions
1439 | );
1440 | } else {
1441 | const disposables = [];
1442 | const ignoreCounter = shallowRef(0);
1443 | const syncCounter = shallowRef(0);
1444 | ignorePrevAsyncUpdates = () => {
1445 | ignoreCounter.value = syncCounter.value;
1446 | };
1447 | disposables.push(
1448 | watch(
1449 | source,
1450 | () => {
1451 | syncCounter.value++;
1452 | },
1453 | { ...watchOptions, flush: "sync" }
1454 | )
1455 | );
1456 | ignoreUpdates = (updater) => {
1457 | const syncCounterPrev = syncCounter.value;
1458 | updater();
1459 | ignoreCounter.value += syncCounter.value - syncCounterPrev;
1460 | };
1461 | disposables.push(
1462 | watch(
1463 | source,
1464 | (...args) => {
1465 | const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
1466 | ignoreCounter.value = 0;
1467 | syncCounter.value = 0;
1468 | if (ignore)
1469 | return;
1470 | filteredCb(...args);
1471 | },
1472 | watchOptions
1473 | )
1474 | );
1475 | stop = () => {
1476 | disposables.forEach((fn) => fn());
1477 | };
1478 | }
1479 | return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
1480 | }
1481 | function watchImmediate(source, cb, options) {
1482 | return watch(
1483 | source,
1484 | cb,
1485 | {
1486 | ...options,
1487 | immediate: true
1488 | }
1489 | );
1490 | }
1491 | function watchOnce(source, cb, options) {
1492 | const stop = watch(source, (...args) => {
1493 | nextTick(() => stop());
1494 | return cb(...args);
1495 | }, options);
1496 | return stop;
1497 | }
1498 | function watchThrottled(source, cb, options = {}) {
1499 | const {
1500 | throttle = 0,
1501 | trailing = true,
1502 | leading = true,
1503 | ...watchOptions
1504 | } = options;
1505 | return watchWithFilter(
1506 | source,
1507 | cb,
1508 | {
1509 | ...watchOptions,
1510 | eventFilter: throttleFilter(throttle, trailing, leading)
1511 | }
1512 | );
1513 | }
1514 | function watchTriggerable(source, cb, options = {}) {
1515 | let cleanupFn;
1516 | function onEffect() {
1517 | if (!cleanupFn)
1518 | return;
1519 | const fn = cleanupFn;
1520 | cleanupFn = void 0;
1521 | fn();
1522 | }
1523 | function onCleanup(callback) {
1524 | cleanupFn = callback;
1525 | }
1526 | const _cb = (value, oldValue) => {
1527 | onEffect();
1528 | return cb(value, oldValue, onCleanup);
1529 | };
1530 | const res = watchIgnorable(source, _cb, options);
1531 | const { ignoreUpdates } = res;
1532 | const trigger = () => {
1533 | let res2;
1534 | ignoreUpdates(() => {
1535 | res2 = _cb(getWatchSources(source), getOldValue(source));
1536 | });
1537 | return res2;
1538 | };
1539 | return {
1540 | ...res,
1541 | trigger
1542 | };
1543 | }
1544 | function getWatchSources(sources) {
1545 | if (isReactive(sources))
1546 | return sources;
1547 | if (Array.isArray(sources))
1548 | return sources.map((item) => toValue(item));
1549 | return toValue(sources);
1550 | }
1551 | function getOldValue(source) {
1552 | return Array.isArray(source) ? source.map(() => void 0) : void 0;
1553 | }
1554 | function whenever(source, cb, options) {
1555 | const stop = watch(
1556 | source,
1557 | (v, ov, onInvalidate) => {
1558 | if (v) {
1559 | if (options == null ? void 0 : options.once)
1560 | nextTick(() => stop());
1561 | cb(v, ov, onInvalidate);
1562 | }
1563 | },
1564 | {
1565 | ...options,
1566 | once: false
1567 | }
1568 | );
1569 | return stop;
1570 | }
1571 |
1572 | // node_modules/@vueuse/core/index.mjs
1573 | function computedAsync(evaluationCallback, initialState, optionsOrRef) {
1574 | let options;
1575 | if (isRef(optionsOrRef)) {
1576 | options = {
1577 | evaluating: optionsOrRef
1578 | };
1579 | } else {
1580 | options = optionsOrRef || {};
1581 | }
1582 | const {
1583 | lazy = false,
1584 | evaluating = void 0,
1585 | shallow = true,
1586 | onError = noop
1587 | } = options;
1588 | const started = shallowRef(!lazy);
1589 | const current = shallow ? shallowRef(initialState) : ref(initialState);
1590 | let counter = 0;
1591 | watchEffect(async (onInvalidate) => {
1592 | if (!started.value)
1593 | return;
1594 | counter++;
1595 | const counterAtBeginning = counter;
1596 | let hasFinished = false;
1597 | if (evaluating) {
1598 | Promise.resolve().then(() => {
1599 | evaluating.value = true;
1600 | });
1601 | }
1602 | try {
1603 | const result = await evaluationCallback((cancelCallback) => {
1604 | onInvalidate(() => {
1605 | if (evaluating)
1606 | evaluating.value = false;
1607 | if (!hasFinished)
1608 | cancelCallback();
1609 | });
1610 | });
1611 | if (counterAtBeginning === counter)
1612 | current.value = result;
1613 | } catch (e) {
1614 | onError(e);
1615 | } finally {
1616 | if (evaluating && counterAtBeginning === counter)
1617 | evaluating.value = false;
1618 | hasFinished = true;
1619 | }
1620 | });
1621 | if (lazy) {
1622 | return computed(() => {
1623 | started.value = true;
1624 | return current.value;
1625 | });
1626 | } else {
1627 | return current;
1628 | }
1629 | }
1630 | function computedInject(key, options, defaultSource, treatDefaultAsFactory) {
1631 | let source = inject(key);
1632 | if (defaultSource)
1633 | source = inject(key, defaultSource);
1634 | if (treatDefaultAsFactory)
1635 | source = inject(key, defaultSource, treatDefaultAsFactory);
1636 | if (typeof options === "function") {
1637 | return computed((ctx) => options(source, ctx));
1638 | } else {
1639 | return computed({
1640 | get: (ctx) => options.get(source, ctx),
1641 | set: options.set
1642 | });
1643 | }
1644 | }
1645 | function createReusableTemplate(options = {}) {
1646 | const {
1647 | inheritAttrs = true
1648 | } = options;
1649 | const render = shallowRef();
1650 | const define = defineComponent({
1651 | setup(_, { slots }) {
1652 | return () => {
1653 | render.value = slots.default;
1654 | };
1655 | }
1656 | });
1657 | const reuse = defineComponent({
1658 | inheritAttrs,
1659 | props: options.props,
1660 | setup(props, { attrs, slots }) {
1661 | return () => {
1662 | var _a;
1663 | if (!render.value && true)
1664 | throw new Error("[VueUse] Failed to find the definition of reusable template");
1665 | const vnode = (_a = render.value) == null ? void 0 : _a.call(render, {
1666 | ...options.props == null ? keysToCamelKebabCase(attrs) : props,
1667 | $slots: slots
1668 | });
1669 | return inheritAttrs && (vnode == null ? void 0 : vnode.length) === 1 ? vnode[0] : vnode;
1670 | };
1671 | }
1672 | });
1673 | return makeDestructurable(
1674 | { define, reuse },
1675 | [define, reuse]
1676 | );
1677 | }
1678 | function keysToCamelKebabCase(obj) {
1679 | const newObj = {};
1680 | for (const key in obj)
1681 | newObj[camelize(key)] = obj[key];
1682 | return newObj;
1683 | }
1684 | function createTemplatePromise(options = {}) {
1685 | let index = 0;
1686 | const instances = ref([]);
1687 | function create(...args) {
1688 | const props = shallowReactive({
1689 | key: index++,
1690 | args,
1691 | promise: void 0,
1692 | resolve: () => {
1693 | },
1694 | reject: () => {
1695 | },
1696 | isResolving: false,
1697 | options
1698 | });
1699 | instances.value.push(props);
1700 | props.promise = new Promise((_resolve, _reject) => {
1701 | props.resolve = (v) => {
1702 | props.isResolving = true;
1703 | return _resolve(v);
1704 | };
1705 | props.reject = _reject;
1706 | }).finally(() => {
1707 | props.promise = void 0;
1708 | const index2 = instances.value.indexOf(props);
1709 | if (index2 !== -1)
1710 | instances.value.splice(index2, 1);
1711 | });
1712 | return props.promise;
1713 | }
1714 | function start(...args) {
1715 | if (options.singleton && instances.value.length > 0)
1716 | return instances.value[0].promise;
1717 | return create(...args);
1718 | }
1719 | const component = defineComponent((_, { slots }) => {
1720 | const renderList = () => instances.value.map((props) => {
1721 | var _a;
1722 | return h(Fragment, { key: props.key }, (_a = slots.default) == null ? void 0 : _a.call(slots, props));
1723 | });
1724 | if (options.transition)
1725 | return () => h(TransitionGroup, options.transition, renderList);
1726 | return renderList;
1727 | });
1728 | component.start = start;
1729 | return component;
1730 | }
1731 | function createUnrefFn(fn) {
1732 | return function(...args) {
1733 | return fn.apply(this, args.map((i) => toValue(i)));
1734 | };
1735 | }
1736 | var defaultWindow = isClient ? window : void 0;
1737 | var defaultDocument = isClient ? window.document : void 0;
1738 | var defaultNavigator = isClient ? window.navigator : void 0;
1739 | var defaultLocation = isClient ? window.location : void 0;
1740 | function unrefElement(elRef) {
1741 | var _a;
1742 | const plain = toValue(elRef);
1743 | return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
1744 | }
1745 | function useEventListener(...args) {
1746 | const cleanups = [];
1747 | const cleanup = () => {
1748 | cleanups.forEach((fn) => fn());
1749 | cleanups.length = 0;
1750 | };
1751 | const register = (el, event, listener, options) => {
1752 | el.addEventListener(event, listener, options);
1753 | return () => el.removeEventListener(event, listener, options);
1754 | };
1755 | const firstParamTargets = computed(() => {
1756 | const test = toArray(toValue(args[0])).filter((e) => e != null);
1757 | return test.every((e) => typeof e !== "string") ? test : void 0;
1758 | });
1759 | const stopWatch = watchImmediate(
1760 | () => {
1761 | var _a, _b;
1762 | return [
1763 | (_b = (_a = firstParamTargets.value) == null ? void 0 : _a.map((e) => unrefElement(e))) != null ? _b : [defaultWindow].filter((e) => e != null),
1764 | toArray(toValue(firstParamTargets.value ? args[1] : args[0])),
1765 | toArray(unref(firstParamTargets.value ? args[2] : args[1])),
1766 | // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
1767 | toValue(firstParamTargets.value ? args[3] : args[2])
1768 | ];
1769 | },
1770 | ([raw_targets, raw_events, raw_listeners, raw_options]) => {
1771 | cleanup();
1772 | if (!(raw_targets == null ? void 0 : raw_targets.length) || !(raw_events == null ? void 0 : raw_events.length) || !(raw_listeners == null ? void 0 : raw_listeners.length))
1773 | return;
1774 | const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
1775 | cleanups.push(
1776 | ...raw_targets.flatMap(
1777 | (el) => raw_events.flatMap(
1778 | (event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))
1779 | )
1780 | )
1781 | );
1782 | },
1783 | { flush: "post" }
1784 | );
1785 | const stop = () => {
1786 | stopWatch();
1787 | cleanup();
1788 | };
1789 | tryOnScopeDispose(cleanup);
1790 | return stop;
1791 | }
1792 | var _iOSWorkaround = false;
1793 | function onClickOutside(target, handler, options = {}) {
1794 | const { window: window2 = defaultWindow, ignore = [], capture = true, detectIframe = false, controls = false } = options;
1795 | if (!window2) {
1796 | return controls ? { stop: noop, cancel: noop, trigger: noop } : noop;
1797 | }
1798 | if (isIOS && !_iOSWorkaround) {
1799 | _iOSWorkaround = true;
1800 | const listenerOptions = { passive: true };
1801 | Array.from(window2.document.body.children).forEach((el) => useEventListener(el, "click", noop, listenerOptions));
1802 | useEventListener(window2.document.documentElement, "click", noop, listenerOptions);
1803 | }
1804 | let shouldListen = true;
1805 | const shouldIgnore = (event) => {
1806 | return toValue(ignore).some((target2) => {
1807 | if (typeof target2 === "string") {
1808 | return Array.from(window2.document.querySelectorAll(target2)).some((el) => el === event.target || event.composedPath().includes(el));
1809 | } else {
1810 | const el = unrefElement(target2);
1811 | return el && (event.target === el || event.composedPath().includes(el));
1812 | }
1813 | });
1814 | };
1815 | function hasMultipleRoots(target2) {
1816 | const vm = toValue(target2);
1817 | return vm && vm.$.subTree.shapeFlag === 16;
1818 | }
1819 | function checkMultipleRoots(target2, event) {
1820 | const vm = toValue(target2);
1821 | const children = vm.$.subTree && vm.$.subTree.children;
1822 | if (children == null || !Array.isArray(children))
1823 | return false;
1824 | return children.some((child) => child.el === event.target || event.composedPath().includes(child.el));
1825 | }
1826 | const listener = (event) => {
1827 | const el = unrefElement(target);
1828 | if (event.target == null)
1829 | return;
1830 | if (!(el instanceof Element) && hasMultipleRoots(target) && checkMultipleRoots(target, event))
1831 | return;
1832 | if (!el || el === event.target || event.composedPath().includes(el))
1833 | return;
1834 | if ("detail" in event && event.detail === 0)
1835 | shouldListen = !shouldIgnore(event);
1836 | if (!shouldListen) {
1837 | shouldListen = true;
1838 | return;
1839 | }
1840 | handler(event);
1841 | };
1842 | let isProcessingClick = false;
1843 | const cleanup = [
1844 | useEventListener(window2, "click", (event) => {
1845 | if (!isProcessingClick) {
1846 | isProcessingClick = true;
1847 | setTimeout(() => {
1848 | isProcessingClick = false;
1849 | }, 0);
1850 | listener(event);
1851 | }
1852 | }, { passive: true, capture }),
1853 | useEventListener(window2, "pointerdown", (e) => {
1854 | const el = unrefElement(target);
1855 | shouldListen = !shouldIgnore(e) && !!(el && !e.composedPath().includes(el));
1856 | }, { passive: true }),
1857 | detectIframe && useEventListener(window2, "blur", (event) => {
1858 | setTimeout(() => {
1859 | var _a;
1860 | const el = unrefElement(target);
1861 | if (((_a = window2.document.activeElement) == null ? void 0 : _a.tagName) === "IFRAME" && !(el == null ? void 0 : el.contains(window2.document.activeElement))) {
1862 | handler(event);
1863 | }
1864 | }, 0);
1865 | }, { passive: true })
1866 | ].filter(Boolean);
1867 | const stop = () => cleanup.forEach((fn) => fn());
1868 | if (controls) {
1869 | return {
1870 | stop,
1871 | cancel: () => {
1872 | shouldListen = false;
1873 | },
1874 | trigger: (event) => {
1875 | shouldListen = true;
1876 | listener(event);
1877 | shouldListen = false;
1878 | }
1879 | };
1880 | }
1881 | return stop;
1882 | }
1883 | function useMounted() {
1884 | const isMounted = shallowRef(false);
1885 | const instance = getCurrentInstance();
1886 | if (instance) {
1887 | onMounted(() => {
1888 | isMounted.value = true;
1889 | }, instance);
1890 | }
1891 | return isMounted;
1892 | }
1893 | function useSupported(callback) {
1894 | const isMounted = useMounted();
1895 | return computed(() => {
1896 | isMounted.value;
1897 | return Boolean(callback());
1898 | });
1899 | }
1900 | function useMutationObserver(target, callback, options = {}) {
1901 | const { window: window2 = defaultWindow, ...mutationOptions } = options;
1902 | let observer;
1903 | const isSupported = useSupported(() => window2 && "MutationObserver" in window2);
1904 | const cleanup = () => {
1905 | if (observer) {
1906 | observer.disconnect();
1907 | observer = void 0;
1908 | }
1909 | };
1910 | const targets = computed(() => {
1911 | const value = toValue(target);
1912 | const items = toArray(value).map(unrefElement).filter(notNullish);
1913 | return new Set(items);
1914 | });
1915 | const stopWatch = watch(
1916 | () => targets.value,
1917 | (targets2) => {
1918 | cleanup();
1919 | if (isSupported.value && targets2.size) {
1920 | observer = new MutationObserver(callback);
1921 | targets2.forEach((el) => observer.observe(el, mutationOptions));
1922 | }
1923 | },
1924 | { immediate: true, flush: "post" }
1925 | );
1926 | const takeRecords = () => {
1927 | return observer == null ? void 0 : observer.takeRecords();
1928 | };
1929 | const stop = () => {
1930 | stopWatch();
1931 | cleanup();
1932 | };
1933 | tryOnScopeDispose(stop);
1934 | return {
1935 | isSupported,
1936 | stop,
1937 | takeRecords
1938 | };
1939 | }
1940 | function onElementRemoval(target, callback, options = {}) {
1941 | const {
1942 | window: window2 = defaultWindow,
1943 | document: document2 = window2 == null ? void 0 : window2.document,
1944 | flush = "sync"
1945 | } = options;
1946 | if (!window2 || !document2)
1947 | return noop;
1948 | let stopFn;
1949 | const cleanupAndUpdate = (fn) => {
1950 | stopFn == null ? void 0 : stopFn();
1951 | stopFn = fn;
1952 | };
1953 | const stopWatch = watchEffect(() => {
1954 | const el = unrefElement(target);
1955 | if (el) {
1956 | const { stop } = useMutationObserver(
1957 | document2,
1958 | (mutationsList) => {
1959 | const targetRemoved = mutationsList.map((mutation) => [...mutation.removedNodes]).flat().some((node) => node === el || node.contains(el));
1960 | if (targetRemoved) {
1961 | callback(mutationsList);
1962 | }
1963 | },
1964 | {
1965 | window: window2,
1966 | childList: true,
1967 | subtree: true
1968 | }
1969 | );
1970 | cleanupAndUpdate(stop);
1971 | }
1972 | }, { flush });
1973 | const stopHandle = () => {
1974 | stopWatch();
1975 | cleanupAndUpdate();
1976 | };
1977 | tryOnScopeDispose(stopHandle);
1978 | return stopHandle;
1979 | }
1980 | function createKeyPredicate(keyFilter) {
1981 | if (typeof keyFilter === "function")
1982 | return keyFilter;
1983 | else if (typeof keyFilter === "string")
1984 | return (event) => event.key === keyFilter;
1985 | else if (Array.isArray(keyFilter))
1986 | return (event) => keyFilter.includes(event.key);
1987 | return () => true;
1988 | }
1989 | function onKeyStroke(...args) {
1990 | let key;
1991 | let handler;
1992 | let options = {};
1993 | if (args.length === 3) {
1994 | key = args[0];
1995 | handler = args[1];
1996 | options = args[2];
1997 | } else if (args.length === 2) {
1998 | if (typeof args[1] === "object") {
1999 | key = true;
2000 | handler = args[0];
2001 | options = args[1];
2002 | } else {
2003 | key = args[0];
2004 | handler = args[1];
2005 | }
2006 | } else {
2007 | key = true;
2008 | handler = args[0];
2009 | }
2010 | const {
2011 | target = defaultWindow,
2012 | eventName = "keydown",
2013 | passive = false,
2014 | dedupe = false
2015 | } = options;
2016 | const predicate = createKeyPredicate(key);
2017 | const listener = (e) => {
2018 | if (e.repeat && toValue(dedupe))
2019 | return;
2020 | if (predicate(e))
2021 | handler(e);
2022 | };
2023 | return useEventListener(target, eventName, listener, passive);
2024 | }
2025 | function onKeyDown(key, handler, options = {}) {
2026 | return onKeyStroke(key, handler, { ...options, eventName: "keydown" });
2027 | }
2028 | function onKeyPressed(key, handler, options = {}) {
2029 | return onKeyStroke(key, handler, { ...options, eventName: "keypress" });
2030 | }
2031 | function onKeyUp(key, handler, options = {}) {
2032 | return onKeyStroke(key, handler, { ...options, eventName: "keyup" });
2033 | }
2034 | var DEFAULT_DELAY = 500;
2035 | var DEFAULT_THRESHOLD = 10;
2036 | function onLongPress(target, handler, options) {
2037 | var _a, _b;
2038 | const elementRef = computed(() => unrefElement(target));
2039 | let timeout;
2040 | let posStart;
2041 | let startTimestamp;
2042 | let hasLongPressed = false;
2043 | function clear() {
2044 | if (timeout) {
2045 | clearTimeout(timeout);
2046 | timeout = void 0;
2047 | }
2048 | posStart = void 0;
2049 | startTimestamp = void 0;
2050 | hasLongPressed = false;
2051 | }
2052 | function onRelease(ev) {
2053 | var _a2, _b2, _c;
2054 | const [_startTimestamp, _posStart, _hasLongPressed] = [startTimestamp, posStart, hasLongPressed];
2055 | clear();
2056 | if (!(options == null ? void 0 : options.onMouseUp) || !_posStart || !_startTimestamp)
2057 | return;
2058 | if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
2059 | return;
2060 | if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
2061 | ev.preventDefault();
2062 | if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
2063 | ev.stopPropagation();
2064 | const dx = ev.x - _posStart.x;
2065 | const dy = ev.y - _posStart.y;
2066 | const distance = Math.sqrt(dx * dx + dy * dy);
2067 | options.onMouseUp(ev.timeStamp - _startTimestamp, distance, _hasLongPressed);
2068 | }
2069 | function onDown(ev) {
2070 | var _a2, _b2, _c, _d;
2071 | if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
2072 | return;
2073 | clear();
2074 | if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
2075 | ev.preventDefault();
2076 | if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
2077 | ev.stopPropagation();
2078 | posStart = {
2079 | x: ev.x,
2080 | y: ev.y
2081 | };
2082 | startTimestamp = ev.timeStamp;
2083 | timeout = setTimeout(
2084 | () => {
2085 | hasLongPressed = true;
2086 | handler(ev);
2087 | },
2088 | (_d = options == null ? void 0 : options.delay) != null ? _d : DEFAULT_DELAY
2089 | );
2090 | }
2091 | function onMove(ev) {
2092 | var _a2, _b2, _c, _d;
2093 | if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
2094 | return;
2095 | if (!posStart || (options == null ? void 0 : options.distanceThreshold) === false)
2096 | return;
2097 | if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
2098 | ev.preventDefault();
2099 | if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
2100 | ev.stopPropagation();
2101 | const dx = ev.x - posStart.x;
2102 | const dy = ev.y - posStart.y;
2103 | const distance = Math.sqrt(dx * dx + dy * dy);
2104 | if (distance >= ((_d = options == null ? void 0 : options.distanceThreshold) != null ? _d : DEFAULT_THRESHOLD))
2105 | clear();
2106 | }
2107 | const listenerOptions = {
2108 | capture: (_a = options == null ? void 0 : options.modifiers) == null ? void 0 : _a.capture,
2109 | once: (_b = options == null ? void 0 : options.modifiers) == null ? void 0 : _b.once
2110 | };
2111 | const cleanup = [
2112 | useEventListener(elementRef, "pointerdown", onDown, listenerOptions),
2113 | useEventListener(elementRef, "pointermove", onMove, listenerOptions),
2114 | useEventListener(elementRef, ["pointerup", "pointerleave"], onRelease, listenerOptions)
2115 | ];
2116 | const stop = () => cleanup.forEach((fn) => fn());
2117 | return stop;
2118 | }
2119 | function isFocusedElementEditable() {
2120 | const { activeElement, body } = document;
2121 | if (!activeElement)
2122 | return false;
2123 | if (activeElement === body)
2124 | return false;
2125 | switch (activeElement.tagName) {
2126 | case "INPUT":
2127 | case "TEXTAREA":
2128 | return true;
2129 | }
2130 | return activeElement.hasAttribute("contenteditable");
2131 | }
2132 | function isTypedCharValid({
2133 | keyCode,
2134 | metaKey,
2135 | ctrlKey,
2136 | altKey
2137 | }) {
2138 | if (metaKey || ctrlKey || altKey)
2139 | return false;
2140 | if (keyCode >= 48 && keyCode <= 57 || keyCode >= 96 && keyCode <= 105)
2141 | return true;
2142 | if (keyCode >= 65 && keyCode <= 90)
2143 | return true;
2144 | return false;
2145 | }
2146 | function onStartTyping(callback, options = {}) {
2147 | const { document: document2 = defaultDocument } = options;
2148 | const keydown = (event) => {
2149 | if (!isFocusedElementEditable() && isTypedCharValid(event)) {
2150 | callback(event);
2151 | }
2152 | };
2153 | if (document2)
2154 | useEventListener(document2, "keydown", keydown, { passive: true });
2155 | }
2156 | function templateRef(key, initialValue = null) {
2157 | const instance = getCurrentInstance();
2158 | let _trigger = () => {
2159 | };
2160 | const element = customRef((track, trigger) => {
2161 | _trigger = trigger;
2162 | return {
2163 | get() {
2164 | var _a, _b;
2165 | track();
2166 | return (_b = (_a = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a.$refs[key]) != null ? _b : initialValue;
2167 | },
2168 | set() {
2169 | }
2170 | };
2171 | });
2172 | tryOnMounted(_trigger);
2173 | onUpdated(_trigger);
2174 | return element;
2175 | }
2176 | function useActiveElement(options = {}) {
2177 | var _a;
2178 | const {
2179 | window: window2 = defaultWindow,
2180 | deep = true,
2181 | triggerOnRemoval = false
2182 | } = options;
2183 | const document2 = (_a = options.document) != null ? _a : window2 == null ? void 0 : window2.document;
2184 | const getDeepActiveElement = () => {
2185 | var _a2;
2186 | let element = document2 == null ? void 0 : document2.activeElement;
2187 | if (deep) {
2188 | while (element == null ? void 0 : element.shadowRoot)
2189 | element = (_a2 = element == null ? void 0 : element.shadowRoot) == null ? void 0 : _a2.activeElement;
2190 | }
2191 | return element;
2192 | };
2193 | const activeElement = shallowRef();
2194 | const trigger = () => {
2195 | activeElement.value = getDeepActiveElement();
2196 | };
2197 | if (window2) {
2198 | const listenerOptions = {
2199 | capture: true,
2200 | passive: true
2201 | };
2202 | useEventListener(
2203 | window2,
2204 | "blur",
2205 | (event) => {
2206 | if (event.relatedTarget !== null)
2207 | return;
2208 | trigger();
2209 | },
2210 | listenerOptions
2211 | );
2212 | useEventListener(
2213 | window2,
2214 | "focus",
2215 | trigger,
2216 | listenerOptions
2217 | );
2218 | }
2219 | if (triggerOnRemoval) {
2220 | onElementRemoval(activeElement, trigger, { document: document2 });
2221 | }
2222 | trigger();
2223 | return activeElement;
2224 | }
2225 | function useRafFn(fn, options = {}) {
2226 | const {
2227 | immediate = true,
2228 | fpsLimit = void 0,
2229 | window: window2 = defaultWindow,
2230 | once = false
2231 | } = options;
2232 | const isActive = shallowRef(false);
2233 | const intervalLimit = computed(() => {
2234 | return fpsLimit ? 1e3 / toValue(fpsLimit) : null;
2235 | });
2236 | let previousFrameTimestamp = 0;
2237 | let rafId = null;
2238 | function loop(timestamp2) {
2239 | if (!isActive.value || !window2)
2240 | return;
2241 | if (!previousFrameTimestamp)
2242 | previousFrameTimestamp = timestamp2;
2243 | const delta = timestamp2 - previousFrameTimestamp;
2244 | if (intervalLimit.value && delta < intervalLimit.value) {
2245 | rafId = window2.requestAnimationFrame(loop);
2246 | return;
2247 | }
2248 | previousFrameTimestamp = timestamp2;
2249 | fn({ delta, timestamp: timestamp2 });
2250 | if (once) {
2251 | isActive.value = false;
2252 | rafId = null;
2253 | return;
2254 | }
2255 | rafId = window2.requestAnimationFrame(loop);
2256 | }
2257 | function resume() {
2258 | if (!isActive.value && window2) {
2259 | isActive.value = true;
2260 | previousFrameTimestamp = 0;
2261 | rafId = window2.requestAnimationFrame(loop);
2262 | }
2263 | }
2264 | function pause() {
2265 | isActive.value = false;
2266 | if (rafId != null && window2) {
2267 | window2.cancelAnimationFrame(rafId);
2268 | rafId = null;
2269 | }
2270 | }
2271 | if (immediate)
2272 | resume();
2273 | tryOnScopeDispose(pause);
2274 | return {
2275 | isActive: readonly(isActive),
2276 | pause,
2277 | resume
2278 | };
2279 | }
2280 | function useAnimate(target, keyframes, options) {
2281 | let config;
2282 | let animateOptions;
2283 | if (isObject(options)) {
2284 | config = options;
2285 | animateOptions = objectOmit(options, ["window", "immediate", "commitStyles", "persist", "onReady", "onError"]);
2286 | } else {
2287 | config = { duration: options };
2288 | animateOptions = options;
2289 | }
2290 | const {
2291 | window: window2 = defaultWindow,
2292 | immediate = true,
2293 | commitStyles,
2294 | persist,
2295 | playbackRate: _playbackRate = 1,
2296 | onReady,
2297 | onError = (e) => {
2298 | console.error(e);
2299 | }
2300 | } = config;
2301 | const isSupported = useSupported(() => window2 && HTMLElement && "animate" in HTMLElement.prototype);
2302 | const animate = shallowRef(void 0);
2303 | const store = shallowReactive({
2304 | startTime: null,
2305 | currentTime: null,
2306 | timeline: null,
2307 | playbackRate: _playbackRate,
2308 | pending: false,
2309 | playState: immediate ? "idle" : "paused",
2310 | replaceState: "active"
2311 | });
2312 | const pending = computed(() => store.pending);
2313 | const playState = computed(() => store.playState);
2314 | const replaceState = computed(() => store.replaceState);
2315 | const startTime = computed({
2316 | get() {
2317 | return store.startTime;
2318 | },
2319 | set(value) {
2320 | store.startTime = value;
2321 | if (animate.value)
2322 | animate.value.startTime = value;
2323 | }
2324 | });
2325 | const currentTime = computed({
2326 | get() {
2327 | return store.currentTime;
2328 | },
2329 | set(value) {
2330 | store.currentTime = value;
2331 | if (animate.value) {
2332 | animate.value.currentTime = value;
2333 | syncResume();
2334 | }
2335 | }
2336 | });
2337 | const timeline = computed({
2338 | get() {
2339 | return store.timeline;
2340 | },
2341 | set(value) {
2342 | store.timeline = value;
2343 | if (animate.value)
2344 | animate.value.timeline = value;
2345 | }
2346 | });
2347 | const playbackRate = computed({
2348 | get() {
2349 | return store.playbackRate;
2350 | },
2351 | set(value) {
2352 | store.playbackRate = value;
2353 | if (animate.value)
2354 | animate.value.playbackRate = value;
2355 | }
2356 | });
2357 | const play = () => {
2358 | if (animate.value) {
2359 | try {
2360 | animate.value.play();
2361 | syncResume();
2362 | } catch (e) {
2363 | syncPause();
2364 | onError(e);
2365 | }
2366 | } else {
2367 | update();
2368 | }
2369 | };
2370 | const pause = () => {
2371 | var _a;
2372 | try {
2373 | (_a = animate.value) == null ? void 0 : _a.pause();
2374 | syncPause();
2375 | } catch (e) {
2376 | onError(e);
2377 | }
2378 | };
2379 | const reverse = () => {
2380 | var _a;
2381 | if (!animate.value)
2382 | update();
2383 | try {
2384 | (_a = animate.value) == null ? void 0 : _a.reverse();
2385 | syncResume();
2386 | } catch (e) {
2387 | syncPause();
2388 | onError(e);
2389 | }
2390 | };
2391 | const finish = () => {
2392 | var _a;
2393 | try {
2394 | (_a = animate.value) == null ? void 0 : _a.finish();
2395 | syncPause();
2396 | } catch (e) {
2397 | onError(e);
2398 | }
2399 | };
2400 | const cancel = () => {
2401 | var _a;
2402 | try {
2403 | (_a = animate.value) == null ? void 0 : _a.cancel();
2404 | syncPause();
2405 | } catch (e) {
2406 | onError(e);
2407 | }
2408 | };
2409 | watch(() => unrefElement(target), (el) => {
2410 | if (el) {
2411 | update();
2412 | } else {
2413 | animate.value = void 0;
2414 | }
2415 | });
2416 | watch(() => keyframes, (value) => {
2417 | if (animate.value) {
2418 | update();
2419 | const targetEl = unrefElement(target);
2420 | if (targetEl) {
2421 | animate.value.effect = new KeyframeEffect(
2422 | targetEl,
2423 | toValue(value),
2424 | animateOptions
2425 | );
2426 | }
2427 | }
2428 | }, { deep: true });
2429 | tryOnMounted(() => update(true), false);
2430 | tryOnScopeDispose(cancel);
2431 | function update(init) {
2432 | const el = unrefElement(target);
2433 | if (!isSupported.value || !el)
2434 | return;
2435 | if (!animate.value)
2436 | animate.value = el.animate(toValue(keyframes), animateOptions);
2437 | if (persist)
2438 | animate.value.persist();
2439 | if (_playbackRate !== 1)
2440 | animate.value.playbackRate = _playbackRate;
2441 | if (init && !immediate)
2442 | animate.value.pause();
2443 | else
2444 | syncResume();
2445 | onReady == null ? void 0 : onReady(animate.value);
2446 | }
2447 | const listenerOptions = { passive: true };
2448 | useEventListener(animate, ["cancel", "finish", "remove"], syncPause, listenerOptions);
2449 | useEventListener(animate, "finish", () => {
2450 | var _a;
2451 | if (commitStyles)
2452 | (_a = animate.value) == null ? void 0 : _a.commitStyles();
2453 | }, listenerOptions);
2454 | const { resume: resumeRef, pause: pauseRef } = useRafFn(() => {
2455 | if (!animate.value)
2456 | return;
2457 | store.pending = animate.value.pending;
2458 | store.playState = animate.value.playState;
2459 | store.replaceState = animate.value.replaceState;
2460 | store.startTime = animate.value.startTime;
2461 | store.currentTime = animate.value.currentTime;
2462 | store.timeline = animate.value.timeline;
2463 | store.playbackRate = animate.value.playbackRate;
2464 | }, { immediate: false });
2465 | function syncResume() {
2466 | if (isSupported.value)
2467 | resumeRef();
2468 | }
2469 | function syncPause() {
2470 | if (isSupported.value && window2)
2471 | window2.requestAnimationFrame(pauseRef);
2472 | }
2473 | return {
2474 | isSupported,
2475 | animate,
2476 | // actions
2477 | play,
2478 | pause,
2479 | reverse,
2480 | finish,
2481 | cancel,
2482 | // state
2483 | pending,
2484 | playState,
2485 | replaceState,
2486 | startTime,
2487 | currentTime,
2488 | timeline,
2489 | playbackRate
2490 | };
2491 | }
2492 | function useAsyncQueue(tasks, options) {
2493 | const {
2494 | interrupt = true,
2495 | onError = noop,
2496 | onFinished = noop,
2497 | signal
2498 | } = options || {};
2499 | const promiseState = {
2500 | aborted: "aborted",
2501 | fulfilled: "fulfilled",
2502 | pending: "pending",
2503 | rejected: "rejected"
2504 | };
2505 | const initialResult = Array.from(Array.from({ length: tasks.length }), () => ({ state: promiseState.pending, data: null }));
2506 | const result = reactive(initialResult);
2507 | const activeIndex = shallowRef(-1);
2508 | if (!tasks || tasks.length === 0) {
2509 | onFinished();
2510 | return {
2511 | activeIndex,
2512 | result
2513 | };
2514 | }
2515 | function updateResult(state, res) {
2516 | activeIndex.value++;
2517 | result[activeIndex.value].data = res;
2518 | result[activeIndex.value].state = state;
2519 | }
2520 | tasks.reduce((prev, curr) => {
2521 | return prev.then((prevRes) => {
2522 | var _a;
2523 | if (signal == null ? void 0 : signal.aborted) {
2524 | updateResult(promiseState.aborted, new Error("aborted"));
2525 | return;
2526 | }
2527 | if (((_a = result[activeIndex.value]) == null ? void 0 : _a.state) === promiseState.rejected && interrupt) {
2528 | onFinished();
2529 | return;
2530 | }
2531 | const done = curr(prevRes).then((currentRes) => {
2532 | updateResult(promiseState.fulfilled, currentRes);
2533 | if (activeIndex.value === tasks.length - 1)
2534 | onFinished();
2535 | return currentRes;
2536 | });
2537 | if (!signal)
2538 | return done;
2539 | return Promise.race([done, whenAborted(signal)]);
2540 | }).catch((e) => {
2541 | if (signal == null ? void 0 : signal.aborted) {
2542 | updateResult(promiseState.aborted, e);
2543 | return e;
2544 | }
2545 | updateResult(promiseState.rejected, e);
2546 | onError();
2547 | return e;
2548 | });
2549 | }, Promise.resolve());
2550 | return {
2551 | activeIndex,
2552 | result
2553 | };
2554 | }
2555 | function whenAborted(signal) {
2556 | return new Promise((resolve, reject) => {
2557 | const error = new Error("aborted");
2558 | if (signal.aborted)
2559 | reject(error);
2560 | else
2561 | signal.addEventListener("abort", () => reject(error), { once: true });
2562 | });
2563 | }
2564 | function useAsyncState(promise, initialState, options) {
2565 | const {
2566 | immediate = true,
2567 | delay = 0,
2568 | onError = noop,
2569 | onSuccess = noop,
2570 | resetOnExecute = true,
2571 | shallow = true,
2572 | throwError
2573 | } = options != null ? options : {};
2574 | const state = shallow ? shallowRef(initialState) : ref(initialState);
2575 | const isReady = shallowRef(false);
2576 | const isLoading = shallowRef(false);
2577 | const error = shallowRef(void 0);
2578 | async function execute(delay2 = 0, ...args) {
2579 | if (resetOnExecute)
2580 | state.value = initialState;
2581 | error.value = void 0;
2582 | isReady.value = false;
2583 | isLoading.value = true;
2584 | if (delay2 > 0)
2585 | await promiseTimeout(delay2);
2586 | const _promise = typeof promise === "function" ? promise(...args) : promise;
2587 | try {
2588 | const data = await _promise;
2589 | state.value = data;
2590 | isReady.value = true;
2591 | onSuccess(data);
2592 | } catch (e) {
2593 | error.value = e;
2594 | onError(e);
2595 | if (throwError)
2596 | throw e;
2597 | } finally {
2598 | isLoading.value = false;
2599 | }
2600 | return state.value;
2601 | }
2602 | if (immediate) {
2603 | execute(delay);
2604 | }
2605 | const shell = {
2606 | state,
2607 | isReady,
2608 | isLoading,
2609 | error,
2610 | execute
2611 | };
2612 | function waitUntilIsLoaded() {
2613 | return new Promise((resolve, reject) => {
2614 | until(isLoading).toBe(false).then(() => resolve(shell)).catch(reject);
2615 | });
2616 | }
2617 | return {
2618 | ...shell,
2619 | then(onFulfilled, onRejected) {
2620 | return waitUntilIsLoaded().then(onFulfilled, onRejected);
2621 | }
2622 | };
2623 | }
2624 | var defaults = {
2625 | array: (v) => JSON.stringify(v),
2626 | object: (v) => JSON.stringify(v),
2627 | set: (v) => JSON.stringify(Array.from(v)),
2628 | map: (v) => JSON.stringify(Object.fromEntries(v)),
2629 | null: () => ""
2630 | };
2631 | function getDefaultSerialization(target) {
2632 | if (!target)
2633 | return defaults.null;
2634 | if (target instanceof Map)
2635 | return defaults.map;
2636 | else if (target instanceof Set)
2637 | return defaults.set;
2638 | else if (Array.isArray(target))
2639 | return defaults.array;
2640 | else
2641 | return defaults.object;
2642 | }
2643 | function useBase64(target, options) {
2644 | const base64 = shallowRef("");
2645 | const promise = shallowRef();
2646 | function execute() {
2647 | if (!isClient)
2648 | return;
2649 | promise.value = new Promise((resolve, reject) => {
2650 | try {
2651 | const _target = toValue(target);
2652 | if (_target == null) {
2653 | resolve("");
2654 | } else if (typeof _target === "string") {
2655 | resolve(blobToBase64(new Blob([_target], { type: "text/plain" })));
2656 | } else if (_target instanceof Blob) {
2657 | resolve(blobToBase64(_target));
2658 | } else if (_target instanceof ArrayBuffer) {
2659 | resolve(window.btoa(String.fromCharCode(...new Uint8Array(_target))));
2660 | } else if (_target instanceof HTMLCanvasElement) {
2661 | resolve(_target.toDataURL(options == null ? void 0 : options.type, options == null ? void 0 : options.quality));
2662 | } else if (_target instanceof HTMLImageElement) {
2663 | const img = _target.cloneNode(false);
2664 | img.crossOrigin = "Anonymous";
2665 | imgLoaded(img).then(() => {
2666 | const canvas = document.createElement("canvas");
2667 | const ctx = canvas.getContext("2d");
2668 | canvas.width = img.width;
2669 | canvas.height = img.height;
2670 | ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
2671 | resolve(canvas.toDataURL(options == null ? void 0 : options.type, options == null ? void 0 : options.quality));
2672 | }).catch(reject);
2673 | } else if (typeof _target === "object") {
2674 | const _serializeFn = (options == null ? void 0 : options.serializer) || getDefaultSerialization(_target);
2675 | const serialized = _serializeFn(_target);
2676 | return resolve(blobToBase64(new Blob([serialized], { type: "application/json" })));
2677 | } else {
2678 | reject(new Error("target is unsupported types"));
2679 | }
2680 | } catch (error) {
2681 | reject(error);
2682 | }
2683 | });
2684 | promise.value.then((res) => {
2685 | base64.value = (options == null ? void 0 : options.dataUrl) === false ? res.replace(/^data:.*?;base64,/, "") : res;
2686 | });
2687 | return promise.value;
2688 | }
2689 | if (isRef(target) || typeof target === "function")
2690 | watch(target, execute, { immediate: true });
2691 | else
2692 | execute();
2693 | return {
2694 | base64,
2695 | promise,
2696 | execute
2697 | };
2698 | }
2699 | function imgLoaded(img) {
2700 | return new Promise((resolve, reject) => {
2701 | if (!img.complete) {
2702 | img.onload = () => {
2703 | resolve();
2704 | };
2705 | img.onerror = reject;
2706 | } else {
2707 | resolve();
2708 | }
2709 | });
2710 | }
2711 | function blobToBase64(blob) {
2712 | return new Promise((resolve, reject) => {
2713 | const fr = new FileReader();
2714 | fr.onload = (e) => {
2715 | resolve(e.target.result);
2716 | };
2717 | fr.onerror = reject;
2718 | fr.readAsDataURL(blob);
2719 | });
2720 | }
2721 | function useBattery(options = {}) {
2722 | const { navigator: navigator2 = defaultNavigator } = options;
2723 | const events2 = ["chargingchange", "chargingtimechange", "dischargingtimechange", "levelchange"];
2724 | const isSupported = useSupported(() => navigator2 && "getBattery" in navigator2 && typeof navigator2.getBattery === "function");
2725 | const charging = shallowRef(false);
2726 | const chargingTime = shallowRef(0);
2727 | const dischargingTime = shallowRef(0);
2728 | const level = shallowRef(1);
2729 | let battery;
2730 | function updateBatteryInfo() {
2731 | charging.value = this.charging;
2732 | chargingTime.value = this.chargingTime || 0;
2733 | dischargingTime.value = this.dischargingTime || 0;
2734 | level.value = this.level;
2735 | }
2736 | if (isSupported.value) {
2737 | navigator2.getBattery().then((_battery) => {
2738 | battery = _battery;
2739 | updateBatteryInfo.call(battery);
2740 | useEventListener(battery, events2, updateBatteryInfo, { passive: true });
2741 | });
2742 | }
2743 | return {
2744 | isSupported,
2745 | charging,
2746 | chargingTime,
2747 | dischargingTime,
2748 | level
2749 | };
2750 | }
2751 | function useBluetooth(options) {
2752 | let {
2753 | acceptAllDevices = false
2754 | } = options || {};
2755 | const {
2756 | filters = void 0,
2757 | optionalServices = void 0,
2758 | navigator: navigator2 = defaultNavigator
2759 | } = options || {};
2760 | const isSupported = useSupported(() => navigator2 && "bluetooth" in navigator2);
2761 | const device = shallowRef();
2762 | const error = shallowRef(null);
2763 | watch(device, () => {
2764 | connectToBluetoothGATTServer();
2765 | });
2766 | async function requestDevice() {
2767 | if (!isSupported.value)
2768 | return;
2769 | error.value = null;
2770 | if (filters && filters.length > 0)
2771 | acceptAllDevices = false;
2772 | try {
2773 | device.value = await (navigator2 == null ? void 0 : navigator2.bluetooth.requestDevice({
2774 | acceptAllDevices,
2775 | filters,
2776 | optionalServices
2777 | }));
2778 | } catch (err) {
2779 | error.value = err;
2780 | }
2781 | }
2782 | const server = shallowRef();
2783 | const isConnected = shallowRef(false);
2784 | function reset() {
2785 | isConnected.value = false;
2786 | device.value = void 0;
2787 | server.value = void 0;
2788 | }
2789 | async function connectToBluetoothGATTServer() {
2790 | error.value = null;
2791 | if (device.value && device.value.gatt) {
2792 | useEventListener(device, "gattserverdisconnected", reset, { passive: true });
2793 | try {
2794 | server.value = await device.value.gatt.connect();
2795 | isConnected.value = server.value.connected;
2796 | } catch (err) {
2797 | error.value = err;
2798 | }
2799 | }
2800 | }
2801 | tryOnMounted(() => {
2802 | var _a;
2803 | if (device.value)
2804 | (_a = device.value.gatt) == null ? void 0 : _a.connect();
2805 | });
2806 | tryOnScopeDispose(() => {
2807 | var _a;
2808 | if (device.value)
2809 | (_a = device.value.gatt) == null ? void 0 : _a.disconnect();
2810 | });
2811 | return {
2812 | isSupported,
2813 | isConnected: readonly(isConnected),
2814 | // Device:
2815 | device,
2816 | requestDevice,
2817 | // Server:
2818 | server,
2819 | // Errors:
2820 | error
2821 | };
2822 | }
2823 | var ssrWidthSymbol = Symbol("vueuse-ssr-width");
2824 | function useSSRWidth() {
2825 | const ssrWidth = hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null;
2826 | return typeof ssrWidth === "number" ? ssrWidth : void 0;
2827 | }
2828 | function provideSSRWidth(width, app) {
2829 | if (app !== void 0) {
2830 | app.provide(ssrWidthSymbol, width);
2831 | } else {
2832 | provideLocal(ssrWidthSymbol, width);
2833 | }
2834 | }
2835 | function useMediaQuery(query, options = {}) {
2836 | const { window: window2 = defaultWindow, ssrWidth = useSSRWidth() } = options;
2837 | const isSupported = useSupported(() => window2 && "matchMedia" in window2 && typeof window2.matchMedia === "function");
2838 | const ssrSupport = shallowRef(typeof ssrWidth === "number");
2839 | const mediaQuery = shallowRef();
2840 | const matches = shallowRef(false);
2841 | const handler = (event) => {
2842 | matches.value = event.matches;
2843 | };
2844 | watchEffect(() => {
2845 | if (ssrSupport.value) {
2846 | ssrSupport.value = !isSupported.value;
2847 | const queryStrings = toValue(query).split(",");
2848 | matches.value = queryStrings.some((queryString) => {
2849 | const not = queryString.includes("not all");
2850 | const minWidth = queryString.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
2851 | const maxWidth = queryString.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
2852 | let res = Boolean(minWidth || maxWidth);
2853 | if (minWidth && res) {
2854 | res = ssrWidth >= pxValue(minWidth[1]);
2855 | }
2856 | if (maxWidth && res) {
2857 | res = ssrWidth <= pxValue(maxWidth[1]);
2858 | }
2859 | return not ? !res : res;
2860 | });
2861 | return;
2862 | }
2863 | if (!isSupported.value)
2864 | return;
2865 | mediaQuery.value = window2.matchMedia(toValue(query));
2866 | matches.value = mediaQuery.value.matches;
2867 | });
2868 | useEventListener(mediaQuery, "change", handler, { passive: true });
2869 | return computed(() => matches.value);
2870 | }
2871 | var breakpointsTailwind = {
2872 | "sm": 640,
2873 | "md": 768,
2874 | "lg": 1024,
2875 | "xl": 1280,
2876 | "2xl": 1536
2877 | };
2878 | var breakpointsBootstrapV5 = {
2879 | xs: 0,
2880 | sm: 576,
2881 | md: 768,
2882 | lg: 992,
2883 | xl: 1200,
2884 | xxl: 1400
2885 | };
2886 | var breakpointsVuetifyV2 = {
2887 | xs: 0,
2888 | sm: 600,
2889 | md: 960,
2890 | lg: 1264,
2891 | xl: 1904
2892 | };
2893 | var breakpointsVuetifyV3 = {
2894 | xs: 0,
2895 | sm: 600,
2896 | md: 960,
2897 | lg: 1280,
2898 | xl: 1920,
2899 | xxl: 2560
2900 | };
2901 | var breakpointsVuetify = breakpointsVuetifyV2;
2902 | var breakpointsAntDesign = {
2903 | xs: 480,
2904 | sm: 576,
2905 | md: 768,
2906 | lg: 992,
2907 | xl: 1200,
2908 | xxl: 1600
2909 | };
2910 | var breakpointsQuasar = {
2911 | xs: 0,
2912 | sm: 600,
2913 | md: 1024,
2914 | lg: 1440,
2915 | xl: 1920
2916 | };
2917 | var breakpointsSematic = {
2918 | mobileS: 320,
2919 | mobileM: 375,
2920 | mobileL: 425,
2921 | tablet: 768,
2922 | laptop: 1024,
2923 | laptopL: 1440,
2924 | desktop4K: 2560
2925 | };
2926 | var breakpointsMasterCss = {
2927 | "3xs": 360,
2928 | "2xs": 480,
2929 | "xs": 600,
2930 | "sm": 768,
2931 | "md": 1024,
2932 | "lg": 1280,
2933 | "xl": 1440,
2934 | "2xl": 1600,
2935 | "3xl": 1920,
2936 | "4xl": 2560
2937 | };
2938 | var breakpointsPrimeFlex = {
2939 | sm: 576,
2940 | md: 768,
2941 | lg: 992,
2942 | xl: 1200
2943 | };
2944 | var breakpointsElement = {
2945 | xs: 0,
2946 | sm: 768,
2947 | md: 992,
2948 | lg: 1200,
2949 | xl: 1920
2950 | };
2951 | function useBreakpoints(breakpoints, options = {}) {
2952 | function getValue2(k, delta) {
2953 | let v = toValue(breakpoints[toValue(k)]);
2954 | if (delta != null)
2955 | v = increaseWithUnit(v, delta);
2956 | if (typeof v === "number")
2957 | v = `${v}px`;
2958 | return v;
2959 | }
2960 | const { window: window2 = defaultWindow, strategy = "min-width", ssrWidth = useSSRWidth() } = options;
2961 | const ssrSupport = typeof ssrWidth === "number";
2962 | const mounted = ssrSupport ? shallowRef(false) : { value: true };
2963 | if (ssrSupport) {
2964 | tryOnMounted(() => mounted.value = !!window2);
2965 | }
2966 | function match(query, size) {
2967 | if (!mounted.value && ssrSupport) {
2968 | return query === "min" ? ssrWidth >= pxValue(size) : ssrWidth <= pxValue(size);
2969 | }
2970 | if (!window2)
2971 | return false;
2972 | return window2.matchMedia(`(${query}-width: ${size})`).matches;
2973 | }
2974 | const greaterOrEqual = (k) => {
2975 | return useMediaQuery(() => `(min-width: ${getValue2(k)})`, options);
2976 | };
2977 | const smallerOrEqual = (k) => {
2978 | return useMediaQuery(() => `(max-width: ${getValue2(k)})`, options);
2979 | };
2980 | const shortcutMethods = Object.keys(breakpoints).reduce((shortcuts, k) => {
2981 | Object.defineProperty(shortcuts, k, {
2982 | get: () => strategy === "min-width" ? greaterOrEqual(k) : smallerOrEqual(k),
2983 | enumerable: true,
2984 | configurable: true
2985 | });
2986 | return shortcuts;
2987 | }, {});
2988 | function current() {
2989 | const points = Object.keys(breakpoints).map((k) => [k, shortcutMethods[k], pxValue(getValue2(k))]).sort((a, b) => a[2] - b[2]);
2990 | return computed(() => points.filter(([, v]) => v.value).map(([k]) => k));
2991 | }
2992 | return Object.assign(shortcutMethods, {
2993 | greaterOrEqual,
2994 | smallerOrEqual,
2995 | greater(k) {
2996 | return useMediaQuery(() => `(min-width: ${getValue2(k, 0.1)})`, options);
2997 | },
2998 | smaller(k) {
2999 | return useMediaQuery(() => `(max-width: ${getValue2(k, -0.1)})`, options);
3000 | },
3001 | between(a, b) {
3002 | return useMediaQuery(() => `(min-width: ${getValue2(a)}) and (max-width: ${getValue2(b, -0.1)})`, options);
3003 | },
3004 | isGreater(k) {
3005 | return match("min", getValue2(k, 0.1));
3006 | },
3007 | isGreaterOrEqual(k) {
3008 | return match("min", getValue2(k));
3009 | },
3010 | isSmaller(k) {
3011 | return match("max", getValue2(k, -0.1));
3012 | },
3013 | isSmallerOrEqual(k) {
3014 | return match("max", getValue2(k));
3015 | },
3016 | isInBetween(a, b) {
3017 | return match("min", getValue2(a)) && match("max", getValue2(b, -0.1));
3018 | },
3019 | current,
3020 | active() {
3021 | const bps = current();
3022 | return computed(() => bps.value.length === 0 ? "" : bps.value.at(strategy === "min-width" ? -1 : 0));
3023 | }
3024 | });
3025 | }
3026 | function useBroadcastChannel(options) {
3027 | const {
3028 | name,
3029 | window: window2 = defaultWindow
3030 | } = options;
3031 | const isSupported = useSupported(() => window2 && "BroadcastChannel" in window2);
3032 | const isClosed = shallowRef(false);
3033 | const channel = ref();
3034 | const data = ref();
3035 | const error = shallowRef(null);
3036 | const post = (data2) => {
3037 | if (channel.value)
3038 | channel.value.postMessage(data2);
3039 | };
3040 | const close = () => {
3041 | if (channel.value)
3042 | channel.value.close();
3043 | isClosed.value = true;
3044 | };
3045 | if (isSupported.value) {
3046 | tryOnMounted(() => {
3047 | error.value = null;
3048 | channel.value = new BroadcastChannel(name);
3049 | const listenerOptions = {
3050 | passive: true
3051 | };
3052 | useEventListener(channel, "message", (e) => {
3053 | data.value = e.data;
3054 | }, listenerOptions);
3055 | useEventListener(channel, "messageerror", (e) => {
3056 | error.value = e;
3057 | }, listenerOptions);
3058 | useEventListener(channel, "close", () => {
3059 | isClosed.value = true;
3060 | }, listenerOptions);
3061 | });
3062 | }
3063 | tryOnScopeDispose(() => {
3064 | close();
3065 | });
3066 | return {
3067 | isSupported,
3068 | channel,
3069 | data,
3070 | post,
3071 | close,
3072 | error,
3073 | isClosed
3074 | };
3075 | }
3076 | var WRITABLE_PROPERTIES = [
3077 | "hash",
3078 | "host",
3079 | "hostname",
3080 | "href",
3081 | "pathname",
3082 | "port",
3083 | "protocol",
3084 | "search"
3085 | ];
3086 | function useBrowserLocation(options = {}) {
3087 | const { window: window2 = defaultWindow } = options;
3088 | const refs = Object.fromEntries(
3089 | WRITABLE_PROPERTIES.map((key) => [key, ref()])
3090 | );
3091 | for (const [key, ref2] of objectEntries(refs)) {
3092 | watch(ref2, (value) => {
3093 | if (!(window2 == null ? void 0 : window2.location) || window2.location[key] === value)
3094 | return;
3095 | window2.location[key] = value;
3096 | });
3097 | }
3098 | const buildState = (trigger) => {
3099 | var _a;
3100 | const { state: state2, length } = (window2 == null ? void 0 : window2.history) || {};
3101 | const { origin } = (window2 == null ? void 0 : window2.location) || {};
3102 | for (const key of WRITABLE_PROPERTIES)
3103 | refs[key].value = (_a = window2 == null ? void 0 : window2.location) == null ? void 0 : _a[key];
3104 | return reactive({
3105 | trigger,
3106 | state: state2,
3107 | length,
3108 | origin,
3109 | ...refs
3110 | });
3111 | };
3112 | const state = ref(buildState("load"));
3113 | if (window2) {
3114 | const listenerOptions = { passive: true };
3115 | useEventListener(window2, "popstate", () => state.value = buildState("popstate"), listenerOptions);
3116 | useEventListener(window2, "hashchange", () => state.value = buildState("hashchange"), listenerOptions);
3117 | }
3118 | return state;
3119 | }
3120 | function useCached(refValue, comparator = (a, b) => a === b, options) {
3121 | const { deepRefs = true, ...watchOptions } = options || {};
3122 | const cachedValue = createRef(refValue.value, deepRefs);
3123 | watch(() => refValue.value, (value) => {
3124 | if (!comparator(value, cachedValue.value))
3125 | cachedValue.value = value;
3126 | }, watchOptions);
3127 | return cachedValue;
3128 | }
3129 | function usePermission(permissionDesc, options = {}) {
3130 | const {
3131 | controls = false,
3132 | navigator: navigator2 = defaultNavigator
3133 | } = options;
3134 | const isSupported = useSupported(() => navigator2 && "permissions" in navigator2);
3135 | const permissionStatus = shallowRef();
3136 | const desc = typeof permissionDesc === "string" ? { name: permissionDesc } : permissionDesc;
3137 | const state = shallowRef();
3138 | const update = () => {
3139 | var _a, _b;
3140 | state.value = (_b = (_a = permissionStatus.value) == null ? void 0 : _a.state) != null ? _b : "prompt";
3141 | };
3142 | useEventListener(permissionStatus, "change", update, { passive: true });
3143 | const query = createSingletonPromise(async () => {
3144 | if (!isSupported.value)
3145 | return;
3146 | if (!permissionStatus.value) {
3147 | try {
3148 | permissionStatus.value = await navigator2.permissions.query(desc);
3149 | } catch (e) {
3150 | permissionStatus.value = void 0;
3151 | } finally {
3152 | update();
3153 | }
3154 | }
3155 | if (controls)
3156 | return toRaw(permissionStatus.value);
3157 | });
3158 | query();
3159 | if (controls) {
3160 | return {
3161 | state,
3162 | isSupported,
3163 | query
3164 | };
3165 | } else {
3166 | return state;
3167 | }
3168 | }
3169 | function useClipboard(options = {}) {
3170 | const {
3171 | navigator: navigator2 = defaultNavigator,
3172 | read = false,
3173 | source,
3174 | copiedDuring = 1500,
3175 | legacy = false
3176 | } = options;
3177 | const isClipboardApiSupported = useSupported(() => navigator2 && "clipboard" in navigator2);
3178 | const permissionRead = usePermission("clipboard-read");
3179 | const permissionWrite = usePermission("clipboard-write");
3180 | const isSupported = computed(() => isClipboardApiSupported.value || legacy);
3181 | const text = shallowRef("");
3182 | const copied = shallowRef(false);
3183 | const timeout = useTimeoutFn(() => copied.value = false, copiedDuring, { immediate: false });
3184 | async function updateText() {
3185 | let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionRead.value));
3186 | if (!useLegacy) {
3187 | try {
3188 | text.value = await navigator2.clipboard.readText();
3189 | } catch (e) {
3190 | useLegacy = true;
3191 | }
3192 | }
3193 | if (useLegacy) {
3194 | text.value = legacyRead();
3195 | }
3196 | }
3197 | if (isSupported.value && read)
3198 | useEventListener(["copy", "cut"], updateText, { passive: true });
3199 | async function copy(value = toValue(source)) {
3200 | if (isSupported.value && value != null) {
3201 | let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionWrite.value));
3202 | if (!useLegacy) {
3203 | try {
3204 | await navigator2.clipboard.writeText(value);
3205 | } catch (e) {
3206 | useLegacy = true;
3207 | }
3208 | }
3209 | if (useLegacy)
3210 | legacyCopy(value);
3211 | text.value = value;
3212 | copied.value = true;
3213 | timeout.start();
3214 | }
3215 | }
3216 | function legacyCopy(value) {
3217 | const ta = document.createElement("textarea");
3218 | ta.value = value != null ? value : "";
3219 | ta.style.position = "absolute";
3220 | ta.style.opacity = "0";
3221 | document.body.appendChild(ta);
3222 | ta.select();
3223 | document.execCommand("copy");
3224 | ta.remove();
3225 | }
3226 | function legacyRead() {
3227 | var _a, _b, _c;
3228 | return (_c = (_b = (_a = document == null ? void 0 : document.getSelection) == null ? void 0 : _a.call(document)) == null ? void 0 : _b.toString()) != null ? _c : "";
3229 | }
3230 | function isAllowed(status) {
3231 | return status === "granted" || status === "prompt";
3232 | }
3233 | return {
3234 | isSupported,
3235 | text,
3236 | copied,
3237 | copy
3238 | };
3239 | }
3240 | function useClipboardItems(options = {}) {
3241 | const {
3242 | navigator: navigator2 = defaultNavigator,
3243 | read = false,
3244 | source,
3245 | copiedDuring = 1500
3246 | } = options;
3247 | const isSupported = useSupported(() => navigator2 && "clipboard" in navigator2);
3248 | const content = ref([]);
3249 | const copied = shallowRef(false);
3250 | const timeout = useTimeoutFn(() => copied.value = false, copiedDuring, { immediate: false });
3251 | function updateContent() {
3252 | if (isSupported.value) {
3253 | navigator2.clipboard.read().then((items) => {
3254 | content.value = items;
3255 | });
3256 | }
3257 | }
3258 | if (isSupported.value && read)
3259 | useEventListener(["copy", "cut"], updateContent, { passive: true });
3260 | async function copy(value = toValue(source)) {
3261 | if (isSupported.value && value != null) {
3262 | await navigator2.clipboard.write(value);
3263 | content.value = value;
3264 | copied.value = true;
3265 | timeout.start();
3266 | }
3267 | }
3268 | return {
3269 | isSupported,
3270 | content,
3271 | copied,
3272 | copy
3273 | };
3274 | }
3275 | function cloneFnJSON(source) {
3276 | return JSON.parse(JSON.stringify(source));
3277 | }
3278 | function useCloned(source, options = {}) {
3279 | const cloned = ref({});
3280 | const isModified = shallowRef(false);
3281 | let _lastSync = false;
3282 | const {
3283 | manual,
3284 | clone = cloneFnJSON,
3285 | // watch options
3286 | deep = true,
3287 | immediate = true
3288 | } = options;
3289 | watch(cloned, () => {
3290 | if (_lastSync) {
3291 | _lastSync = false;
3292 | return;
3293 | }
3294 | isModified.value = true;
3295 | }, {
3296 | deep: true,
3297 | flush: "sync"
3298 | });
3299 | function sync() {
3300 | _lastSync = true;
3301 | isModified.value = false;
3302 | cloned.value = clone(toValue(source));
3303 | }
3304 | if (!manual && (isRef(source) || typeof source === "function")) {
3305 | watch(source, sync, {
3306 | ...options,
3307 | deep,
3308 | immediate
3309 | });
3310 | } else {
3311 | sync();
3312 | }
3313 | return { cloned, isModified, sync };
3314 | }
3315 | var _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
3316 | var globalKey = "__vueuse_ssr_handlers__";
3317 | var handlers = getHandlers();
3318 | function getHandlers() {
3319 | if (!(globalKey in _global))
3320 | _global[globalKey] = _global[globalKey] || {};
3321 | return _global[globalKey];
3322 | }
3323 | function getSSRHandler(key, fallback) {
3324 | return handlers[key] || fallback;
3325 | }
3326 | function setSSRHandler(key, fn) {
3327 | handlers[key] = fn;
3328 | }
3329 | function usePreferredDark(options) {
3330 | return useMediaQuery("(prefers-color-scheme: dark)", options);
3331 | }
3332 | function guessSerializerType(rawInit) {
3333 | return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
3334 | }
3335 | var StorageSerializers = {
3336 | boolean: {
3337 | read: (v) => v === "true",
3338 | write: (v) => String(v)
3339 | },
3340 | object: {
3341 | read: (v) => JSON.parse(v),
3342 | write: (v) => JSON.stringify(v)
3343 | },
3344 | number: {
3345 | read: (v) => Number.parseFloat(v),
3346 | write: (v) => String(v)
3347 | },
3348 | any: {
3349 | read: (v) => v,
3350 | write: (v) => String(v)
3351 | },
3352 | string: {
3353 | read: (v) => v,
3354 | write: (v) => String(v)
3355 | },
3356 | map: {
3357 | read: (v) => new Map(JSON.parse(v)),
3358 | write: (v) => JSON.stringify(Array.from(v.entries()))
3359 | },
3360 | set: {
3361 | read: (v) => new Set(JSON.parse(v)),
3362 | write: (v) => JSON.stringify(Array.from(v))
3363 | },
3364 | date: {
3365 | read: (v) => new Date(v),
3366 | write: (v) => v.toISOString()
3367 | }
3368 | };
3369 | var customStorageEventName = "vueuse-storage";
3370 | function useStorage(key, defaults2, storage, options = {}) {
3371 | var _a;
3372 | const {
3373 | flush = "pre",
3374 | deep = true,
3375 | listenToStorageChanges = true,
3376 | writeDefaults = true,
3377 | mergeDefaults = false,
3378 | shallow,
3379 | window: window2 = defaultWindow,
3380 | eventFilter,
3381 | onError = (e) => {
3382 | console.error(e);
3383 | },
3384 | initOnMounted
3385 | } = options;
3386 | const data = (shallow ? shallowRef : ref)(typeof defaults2 === "function" ? defaults2() : defaults2);
3387 | const keyComputed = computed(() => toValue(key));
3388 | if (!storage) {
3389 | try {
3390 | storage = getSSRHandler("getDefaultStorage", () => {
3391 | var _a2;
3392 | return (_a2 = defaultWindow) == null ? void 0 : _a2.localStorage;
3393 | })();
3394 | } catch (e) {
3395 | onError(e);
3396 | }
3397 | }
3398 | if (!storage)
3399 | return data;
3400 | const rawInit = toValue(defaults2);
3401 | const type = guessSerializerType(rawInit);
3402 | const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
3403 | const { pause: pauseWatch, resume: resumeWatch } = watchPausable(
3404 | data,
3405 | () => write(data.value),
3406 | { flush, deep, eventFilter }
3407 | );
3408 | watch(keyComputed, () => update(), { flush });
3409 | if (window2 && listenToStorageChanges) {
3410 | tryOnMounted(() => {
3411 | if (storage instanceof Storage)
3412 | useEventListener(window2, "storage", update, { passive: true });
3413 | else
3414 | useEventListener(window2, customStorageEventName, updateFromCustomEvent);
3415 | if (initOnMounted)
3416 | update();
3417 | });
3418 | }
3419 | if (!initOnMounted)
3420 | update();
3421 | function dispatchWriteEvent(oldValue, newValue) {
3422 | if (window2) {
3423 | const payload = {
3424 | key: keyComputed.value,
3425 | oldValue,
3426 | newValue,
3427 | storageArea: storage
3428 | };
3429 | window2.dispatchEvent(storage instanceof Storage ? new StorageEvent("storage", payload) : new CustomEvent(customStorageEventName, {
3430 | detail: payload
3431 | }));
3432 | }
3433 | }
3434 | function write(v) {
3435 | try {
3436 | const oldValue = storage.getItem(keyComputed.value);
3437 | if (v == null) {
3438 | dispatchWriteEvent(oldValue, null);
3439 | storage.removeItem(keyComputed.value);
3440 | } else {
3441 | const serialized = serializer.write(v);
3442 | if (oldValue !== serialized) {
3443 | storage.setItem(keyComputed.value, serialized);
3444 | dispatchWriteEvent(oldValue, serialized);
3445 | }
3446 | }
3447 | } catch (e) {
3448 | onError(e);
3449 | }
3450 | }
3451 | function read(event) {
3452 | const rawValue = event ? event.newValue : storage.getItem(keyComputed.value);
3453 | if (rawValue == null) {
3454 | if (writeDefaults && rawInit != null)
3455 | storage.setItem(keyComputed.value, serializer.write(rawInit));
3456 | return rawInit;
3457 | } else if (!event && mergeDefaults) {
3458 | const value = serializer.read(rawValue);
3459 | if (typeof mergeDefaults === "function")
3460 | return mergeDefaults(value, rawInit);
3461 | else if (type === "object" && !Array.isArray(value))
3462 | return { ...rawInit, ...value };
3463 | return value;
3464 | } else if (typeof rawValue !== "string") {
3465 | return rawValue;
3466 | } else {
3467 | return serializer.read(rawValue);
3468 | }
3469 | }
3470 | function update(event) {
3471 | if (event && event.storageArea !== storage)
3472 | return;
3473 | if (event && event.key == null) {
3474 | data.value = rawInit;
3475 | return;
3476 | }
3477 | if (event && event.key !== keyComputed.value)
3478 | return;
3479 | pauseWatch();
3480 | try {
3481 | if ((event == null ? void 0 : event.newValue) !== serializer.write(data.value))
3482 | data.value = read(event);
3483 | } catch (e) {
3484 | onError(e);
3485 | } finally {
3486 | if (event)
3487 | nextTick(resumeWatch);
3488 | else
3489 | resumeWatch();
3490 | }
3491 | }
3492 | function updateFromCustomEvent(event) {
3493 | update(event.detail);
3494 | }
3495 | return data;
3496 | }
3497 | var CSS_DISABLE_TRANS = "*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";
3498 | function useColorMode(options = {}) {
3499 | const {
3500 | selector = "html",
3501 | attribute = "class",
3502 | initialValue = "auto",
3503 | window: window2 = defaultWindow,
3504 | storage,
3505 | storageKey = "vueuse-color-scheme",
3506 | listenToStorageChanges = true,
3507 | storageRef,
3508 | emitAuto,
3509 | disableTransition = true
3510 | } = options;
3511 | const modes = {
3512 | auto: "",
3513 | light: "light",
3514 | dark: "dark",
3515 | ...options.modes || {}
3516 | };
3517 | const preferredDark = usePreferredDark({ window: window2 });
3518 | const system = computed(() => preferredDark.value ? "dark" : "light");
3519 | const store = storageRef || (storageKey == null ? toRef2(initialValue) : useStorage(storageKey, initialValue, storage, { window: window2, listenToStorageChanges }));
3520 | const state = computed(() => store.value === "auto" ? system.value : store.value);
3521 | const updateHTMLAttrs = getSSRHandler(
3522 | "updateHTMLAttrs",
3523 | (selector2, attribute2, value) => {
3524 | const el = typeof selector2 === "string" ? window2 == null ? void 0 : window2.document.querySelector(selector2) : unrefElement(selector2);
3525 | if (!el)
3526 | return;
3527 | const classesToAdd = /* @__PURE__ */ new Set();
3528 | const classesToRemove = /* @__PURE__ */ new Set();
3529 | let attributeToChange = null;
3530 | if (attribute2 === "class") {
3531 | const current = value.split(/\s/g);
3532 | Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => {
3533 | if (current.includes(v))
3534 | classesToAdd.add(v);
3535 | else
3536 | classesToRemove.add(v);
3537 | });
3538 | } else {
3539 | attributeToChange = { key: attribute2, value };
3540 | }
3541 | if (classesToAdd.size === 0 && classesToRemove.size === 0 && attributeToChange === null)
3542 | return;
3543 | let style;
3544 | if (disableTransition) {
3545 | style = window2.document.createElement("style");
3546 | style.appendChild(document.createTextNode(CSS_DISABLE_TRANS));
3547 | window2.document.head.appendChild(style);
3548 | }
3549 | for (const c of classesToAdd) {
3550 | el.classList.add(c);
3551 | }
3552 | for (const c of classesToRemove) {
3553 | el.classList.remove(c);
3554 | }
3555 | if (attributeToChange) {
3556 | el.setAttribute(attributeToChange.key, attributeToChange.value);
3557 | }
3558 | if (disableTransition) {
3559 | window2.getComputedStyle(style).opacity;
3560 | document.head.removeChild(style);
3561 | }
3562 | }
3563 | );
3564 | function defaultOnChanged(mode) {
3565 | var _a;
3566 | updateHTMLAttrs(selector, attribute, (_a = modes[mode]) != null ? _a : mode);
3567 | }
3568 | function onChanged(mode) {
3569 | if (options.onChanged)
3570 | options.onChanged(mode, defaultOnChanged);
3571 | else
3572 | defaultOnChanged(mode);
3573 | }
3574 | watch(state, onChanged, { flush: "post", immediate: true });
3575 | tryOnMounted(() => onChanged(state.value));
3576 | const auto = computed({
3577 | get() {
3578 | return emitAuto ? store.value : state.value;
3579 | },
3580 | set(v) {
3581 | store.value = v;
3582 | }
3583 | });
3584 | return Object.assign(auto, { store, system, state });
3585 | }
3586 | function useConfirmDialog(revealed = shallowRef(false)) {
3587 | const confirmHook = createEventHook();
3588 | const cancelHook = createEventHook();
3589 | const revealHook = createEventHook();
3590 | let _resolve = noop;
3591 | const reveal = (data) => {
3592 | revealHook.trigger(data);
3593 | revealed.value = true;
3594 | return new Promise((resolve) => {
3595 | _resolve = resolve;
3596 | });
3597 | };
3598 | const confirm = (data) => {
3599 | revealed.value = false;
3600 | confirmHook.trigger(data);
3601 | _resolve({ data, isCanceled: false });
3602 | };
3603 | const cancel = (data) => {
3604 | revealed.value = false;
3605 | cancelHook.trigger(data);
3606 | _resolve({ data, isCanceled: true });
3607 | };
3608 | return {
3609 | isRevealed: computed(() => revealed.value),
3610 | reveal,
3611 | confirm,
3612 | cancel,
3613 | onReveal: revealHook.on,
3614 | onConfirm: confirmHook.on,
3615 | onCancel: cancelHook.on
3616 | };
3617 | }
3618 | function useCountdown(initialCountdown, options) {
3619 | var _a, _b;
3620 | const remaining = shallowRef(toValue(initialCountdown));
3621 | const intervalController = useIntervalFn(() => {
3622 | var _a2, _b2;
3623 | const value = remaining.value - 1;
3624 | remaining.value = value < 0 ? 0 : value;
3625 | (_a2 = options == null ? void 0 : options.onTick) == null ? void 0 : _a2.call(options);
3626 | if (remaining.value <= 0) {
3627 | intervalController.pause();
3628 | (_b2 = options == null ? void 0 : options.onComplete) == null ? void 0 : _b2.call(options);
3629 | }
3630 | }, (_a = options == null ? void 0 : options.interval) != null ? _a : 1e3, { immediate: (_b = options == null ? void 0 : options.immediate) != null ? _b : false });
3631 | const reset = (countdown) => {
3632 | var _a2;
3633 | remaining.value = (_a2 = toValue(countdown)) != null ? _a2 : toValue(initialCountdown);
3634 | };
3635 | const stop = () => {
3636 | intervalController.pause();
3637 | reset();
3638 | };
3639 | const resume = () => {
3640 | if (!intervalController.isActive.value) {
3641 | if (remaining.value > 0) {
3642 | intervalController.resume();
3643 | }
3644 | }
3645 | };
3646 | const start = (countdown) => {
3647 | reset(countdown);
3648 | intervalController.resume();
3649 | };
3650 | return {
3651 | remaining,
3652 | reset,
3653 | stop,
3654 | start,
3655 | pause: intervalController.pause,
3656 | resume,
3657 | isActive: intervalController.isActive
3658 | };
3659 | }
3660 | function useCssVar(prop, target, options = {}) {
3661 | const { window: window2 = defaultWindow, initialValue, observe = false } = options;
3662 | const variable = shallowRef(initialValue);
3663 | const elRef = computed(() => {
3664 | var _a;
3665 | return unrefElement(target) || ((_a = window2 == null ? void 0 : window2.document) == null ? void 0 : _a.documentElement);
3666 | });
3667 | function updateCssVar() {
3668 | var _a;
3669 | const key = toValue(prop);
3670 | const el = toValue(elRef);
3671 | if (el && window2 && key) {
3672 | const value = (_a = window2.getComputedStyle(el).getPropertyValue(key)) == null ? void 0 : _a.trim();
3673 | variable.value = value || variable.value || initialValue;
3674 | }
3675 | }
3676 | if (observe) {
3677 | useMutationObserver(elRef, updateCssVar, {
3678 | attributeFilter: ["style", "class"],
3679 | window: window2
3680 | });
3681 | }
3682 | watch(
3683 | [elRef, () => toValue(prop)],
3684 | (_, old) => {
3685 | if (old[0] && old[1])
3686 | old[0].style.removeProperty(old[1]);
3687 | updateCssVar();
3688 | },
3689 | { immediate: true }
3690 | );
3691 | watch(
3692 | [variable, elRef],
3693 | ([val, el]) => {
3694 | const raw_prop = toValue(prop);
3695 | if ((el == null ? void 0 : el.style) && raw_prop) {
3696 | if (val == null)
3697 | el.style.removeProperty(raw_prop);
3698 | else
3699 | el.style.setProperty(raw_prop, val);
3700 | }
3701 | },
3702 | { immediate: true }
3703 | );
3704 | return variable;
3705 | }
3706 | function useCurrentElement(rootComponent) {
3707 | const vm = getCurrentInstance();
3708 | const currentElement = computedWithControl(
3709 | () => null,
3710 | () => rootComponent ? unrefElement(rootComponent) : vm.proxy.$el
3711 | );
3712 | onUpdated(currentElement.trigger);
3713 | onMounted(currentElement.trigger);
3714 | return currentElement;
3715 | }
3716 | function useCycleList(list, options) {
3717 | const state = shallowRef(getInitialValue());
3718 | const listRef = toRef2(list);
3719 | const index = computed({
3720 | get() {
3721 | var _a;
3722 | const targetList = listRef.value;
3723 | let index2 = (options == null ? void 0 : options.getIndexOf) ? options.getIndexOf(state.value, targetList) : targetList.indexOf(state.value);
3724 | if (index2 < 0)
3725 | index2 = (_a = options == null ? void 0 : options.fallbackIndex) != null ? _a : 0;
3726 | return index2;
3727 | },
3728 | set(v) {
3729 | set2(v);
3730 | }
3731 | });
3732 | function set2(i) {
3733 | const targetList = listRef.value;
3734 | const length = targetList.length;
3735 | const index2 = (i % length + length) % length;
3736 | const value = targetList[index2];
3737 | state.value = value;
3738 | return value;
3739 | }
3740 | function shift(delta = 1) {
3741 | return set2(index.value + delta);
3742 | }
3743 | function next(n = 1) {
3744 | return shift(n);
3745 | }
3746 | function prev(n = 1) {
3747 | return shift(-n);
3748 | }
3749 | function getInitialValue() {
3750 | var _a, _b;
3751 | return (_b = toValue((_a = options == null ? void 0 : options.initialValue) != null ? _a : toValue(list)[0])) != null ? _b : void 0;
3752 | }
3753 | watch(listRef, () => set2(index.value));
3754 | return {
3755 | state,
3756 | index,
3757 | next,
3758 | prev,
3759 | go: set2
3760 | };
3761 | }
3762 | function useDark(options = {}) {
3763 | const {
3764 | valueDark = "dark",
3765 | valueLight = ""
3766 | } = options;
3767 | const mode = useColorMode({
3768 | ...options,
3769 | onChanged: (mode2, defaultHandler) => {
3770 | var _a;
3771 | if (options.onChanged)
3772 | (_a = options.onChanged) == null ? void 0 : _a.call(options, mode2 === "dark", defaultHandler, mode2);
3773 | else
3774 | defaultHandler(mode2);
3775 | },
3776 | modes: {
3777 | dark: valueDark,
3778 | light: valueLight
3779 | }
3780 | });
3781 | const system = computed(() => mode.system.value);
3782 | const isDark = computed({
3783 | get() {
3784 | return mode.value === "dark";
3785 | },
3786 | set(v) {
3787 | const modeVal = v ? "dark" : "light";
3788 | if (system.value === modeVal)
3789 | mode.value = "auto";
3790 | else
3791 | mode.value = modeVal;
3792 | }
3793 | });
3794 | return isDark;
3795 | }
3796 | function fnBypass(v) {
3797 | return v;
3798 | }
3799 | function fnSetSource(source, value) {
3800 | return source.value = value;
3801 | }
3802 | function defaultDump(clone) {
3803 | return clone ? typeof clone === "function" ? clone : cloneFnJSON : fnBypass;
3804 | }
3805 | function defaultParse(clone) {
3806 | return clone ? typeof clone === "function" ? clone : cloneFnJSON : fnBypass;
3807 | }
3808 | function useManualRefHistory(source, options = {}) {
3809 | const {
3810 | clone = false,
3811 | dump = defaultDump(clone),
3812 | parse = defaultParse(clone),
3813 | setSource = fnSetSource
3814 | } = options;
3815 | function _createHistoryRecord() {
3816 | return markRaw({
3817 | snapshot: dump(source.value),
3818 | timestamp: timestamp()
3819 | });
3820 | }
3821 | const last = ref(_createHistoryRecord());
3822 | const undoStack = ref([]);
3823 | const redoStack = ref([]);
3824 | const _setSource = (record) => {
3825 | setSource(source, parse(record.snapshot));
3826 | last.value = record;
3827 | };
3828 | const commit = () => {
3829 | undoStack.value.unshift(last.value);
3830 | last.value = _createHistoryRecord();
3831 | if (options.capacity && undoStack.value.length > options.capacity)
3832 | undoStack.value.splice(options.capacity, Number.POSITIVE_INFINITY);
3833 | if (redoStack.value.length)
3834 | redoStack.value.splice(0, redoStack.value.length);
3835 | };
3836 | const clear = () => {
3837 | undoStack.value.splice(0, undoStack.value.length);
3838 | redoStack.value.splice(0, redoStack.value.length);
3839 | };
3840 | const undo = () => {
3841 | const state = undoStack.value.shift();
3842 | if (state) {
3843 | redoStack.value.unshift(last.value);
3844 | _setSource(state);
3845 | }
3846 | };
3847 | const redo = () => {
3848 | const state = redoStack.value.shift();
3849 | if (state) {
3850 | undoStack.value.unshift(last.value);
3851 | _setSource(state);
3852 | }
3853 | };
3854 | const reset = () => {
3855 | _setSource(last.value);
3856 | };
3857 | const history = computed(() => [last.value, ...undoStack.value]);
3858 | const canUndo = computed(() => undoStack.value.length > 0);
3859 | const canRedo = computed(() => redoStack.value.length > 0);
3860 | return {
3861 | source,
3862 | undoStack,
3863 | redoStack,
3864 | last,
3865 | history,
3866 | canUndo,
3867 | canRedo,
3868 | clear,
3869 | commit,
3870 | reset,
3871 | undo,
3872 | redo
3873 | };
3874 | }
3875 | function useRefHistory(source, options = {}) {
3876 | const {
3877 | deep = false,
3878 | flush = "pre",
3879 | eventFilter
3880 | } = options;
3881 | const {
3882 | eventFilter: composedFilter,
3883 | pause,
3884 | resume: resumeTracking,
3885 | isActive: isTracking
3886 | } = pausableFilter(eventFilter);
3887 | const {
3888 | ignoreUpdates,
3889 | ignorePrevAsyncUpdates,
3890 | stop
3891 | } = watchIgnorable(
3892 | source,
3893 | commit,
3894 | { deep, flush, eventFilter: composedFilter }
3895 | );
3896 | function setSource(source2, value) {
3897 | ignorePrevAsyncUpdates();
3898 | ignoreUpdates(() => {
3899 | source2.value = value;
3900 | });
3901 | }
3902 | const manualHistory = useManualRefHistory(source, { ...options, clone: options.clone || deep, setSource });
3903 | const { clear, commit: manualCommit } = manualHistory;
3904 | function commit() {
3905 | ignorePrevAsyncUpdates();
3906 | manualCommit();
3907 | }
3908 | function resume(commitNow) {
3909 | resumeTracking();
3910 | if (commitNow)
3911 | commit();
3912 | }
3913 | function batch(fn) {
3914 | let canceled = false;
3915 | const cancel = () => canceled = true;
3916 | ignoreUpdates(() => {
3917 | fn(cancel);
3918 | });
3919 | if (!canceled)
3920 | commit();
3921 | }
3922 | function dispose() {
3923 | stop();
3924 | clear();
3925 | }
3926 | return {
3927 | ...manualHistory,
3928 | isTracking,
3929 | pause,
3930 | resume,
3931 | commit,
3932 | batch,
3933 | dispose
3934 | };
3935 | }
3936 | function useDebouncedRefHistory(source, options = {}) {
3937 | const filter = options.debounce ? debounceFilter(options.debounce) : void 0;
3938 | const history = useRefHistory(source, { ...options, eventFilter: filter });
3939 | return {
3940 | ...history
3941 | };
3942 | }
3943 | function useDeviceMotion(options = {}) {
3944 | const {
3945 | window: window2 = defaultWindow,
3946 | requestPermissions = false,
3947 | eventFilter = bypassFilter
3948 | } = options;
3949 | const isSupported = useSupported(() => typeof DeviceMotionEvent !== "undefined");
3950 | const requirePermissions = useSupported(() => isSupported.value && "requestPermission" in DeviceMotionEvent && typeof DeviceMotionEvent.requestPermission === "function");
3951 | const permissionGranted = shallowRef(false);
3952 | const acceleration = ref({ x: null, y: null, z: null });
3953 | const rotationRate = ref({ alpha: null, beta: null, gamma: null });
3954 | const interval = shallowRef(0);
3955 | const accelerationIncludingGravity = ref({
3956 | x: null,
3957 | y: null,
3958 | z: null
3959 | });
3960 | function init() {
3961 | if (window2) {
3962 | const onDeviceMotion = createFilterWrapper(
3963 | eventFilter,
3964 | (event) => {
3965 | var _a, _b, _c, _d, _e, _f, _g, _h, _i;
3966 | acceleration.value = {
3967 | x: ((_a = event.acceleration) == null ? void 0 : _a.x) || null,
3968 | y: ((_b = event.acceleration) == null ? void 0 : _b.y) || null,
3969 | z: ((_c = event.acceleration) == null ? void 0 : _c.z) || null
3970 | };
3971 | accelerationIncludingGravity.value = {
3972 | x: ((_d = event.accelerationIncludingGravity) == null ? void 0 : _d.x) || null,
3973 | y: ((_e = event.accelerationIncludingGravity) == null ? void 0 : _e.y) || null,
3974 | z: ((_f = event.accelerationIncludingGravity) == null ? void 0 : _f.z) || null
3975 | };
3976 | rotationRate.value = {
3977 | alpha: ((_g = event.rotationRate) == null ? void 0 : _g.alpha) || null,
3978 | beta: ((_h = event.rotationRate) == null ? void 0 : _h.beta) || null,
3979 | gamma: ((_i = event.rotationRate) == null ? void 0 : _i.gamma) || null
3980 | };
3981 | interval.value = event.interval;
3982 | }
3983 | );
3984 | useEventListener(window2, "devicemotion", onDeviceMotion, { passive: true });
3985 | }
3986 | }
3987 | const ensurePermissions = async () => {
3988 | if (!requirePermissions.value)
3989 | permissionGranted.value = true;
3990 | if (permissionGranted.value)
3991 | return;
3992 | if (requirePermissions.value) {
3993 | const requestPermission = DeviceMotionEvent.requestPermission;
3994 | try {
3995 | const response = await requestPermission();
3996 | if (response === "granted") {
3997 | permissionGranted.value = true;
3998 | init();
3999 | }
4000 | } catch (error) {
4001 | console.error(error);
4002 | }
4003 | }
4004 | };
4005 | if (isSupported.value) {
4006 | if (requestPermissions && requirePermissions.value) {
4007 | ensurePermissions().then(() => init());
4008 | } else {
4009 | init();
4010 | }
4011 | }
4012 | return {
4013 | acceleration,
4014 | accelerationIncludingGravity,
4015 | rotationRate,
4016 | interval,
4017 | isSupported,
4018 | requirePermissions,
4019 | ensurePermissions,
4020 | permissionGranted
4021 | };
4022 | }
4023 | function useDeviceOrientation(options = {}) {
4024 | const { window: window2 = defaultWindow } = options;
4025 | const isSupported = useSupported(() => window2 && "DeviceOrientationEvent" in window2);
4026 | const isAbsolute = shallowRef(false);
4027 | const alpha = shallowRef(null);
4028 | const beta = shallowRef(null);
4029 | const gamma = shallowRef(null);
4030 | if (window2 && isSupported.value) {
4031 | useEventListener(window2, "deviceorientation", (event) => {
4032 | isAbsolute.value = event.absolute;
4033 | alpha.value = event.alpha;
4034 | beta.value = event.beta;
4035 | gamma.value = event.gamma;
4036 | }, { passive: true });
4037 | }
4038 | return {
4039 | isSupported,
4040 | isAbsolute,
4041 | alpha,
4042 | beta,
4043 | gamma
4044 | };
4045 | }
4046 | function useDevicePixelRatio(options = {}) {
4047 | const {
4048 | window: window2 = defaultWindow
4049 | } = options;
4050 | const pixelRatio = shallowRef(1);
4051 | const query = useMediaQuery(() => `(resolution: ${pixelRatio.value}dppx)`, options);
4052 | let stop = noop;
4053 | if (window2) {
4054 | stop = watchImmediate(query, () => pixelRatio.value = window2.devicePixelRatio);
4055 | }
4056 | return {
4057 | pixelRatio: readonly(pixelRatio),
4058 | stop
4059 | };
4060 | }
4061 | function useDevicesList(options = {}) {
4062 | const {
4063 | navigator: navigator2 = defaultNavigator,
4064 | requestPermissions = false,
4065 | constraints = { audio: true, video: true },
4066 | onUpdated: onUpdated2
4067 | } = options;
4068 | const devices = ref([]);
4069 | const videoInputs = computed(() => devices.value.filter((i) => i.kind === "videoinput"));
4070 | const audioInputs = computed(() => devices.value.filter((i) => i.kind === "audioinput"));
4071 | const audioOutputs = computed(() => devices.value.filter((i) => i.kind === "audiooutput"));
4072 | const isSupported = useSupported(() => navigator2 && navigator2.mediaDevices && navigator2.mediaDevices.enumerateDevices);
4073 | const permissionGranted = shallowRef(false);
4074 | let stream;
4075 | async function update() {
4076 | if (!isSupported.value)
4077 | return;
4078 | devices.value = await navigator2.mediaDevices.enumerateDevices();
4079 | onUpdated2 == null ? void 0 : onUpdated2(devices.value);
4080 | if (stream) {
4081 | stream.getTracks().forEach((t) => t.stop());
4082 | stream = null;
4083 | }
4084 | }
4085 | async function ensurePermissions() {
4086 | const deviceName = constraints.video ? "camera" : "microphone";
4087 | if (!isSupported.value)
4088 | return false;
4089 | if (permissionGranted.value)
4090 | return true;
4091 | const { state, query } = usePermission(deviceName, { controls: true });
4092 | await query();
4093 | if (state.value !== "granted") {
4094 | let granted = true;
4095 | try {
4096 | stream = await navigator2.mediaDevices.getUserMedia(constraints);
4097 | } catch (e) {
4098 | stream = null;
4099 | granted = false;
4100 | }
4101 | update();
4102 | permissionGranted.value = granted;
4103 | } else {
4104 | permissionGranted.value = true;
4105 | }
4106 | return permissionGranted.value;
4107 | }
4108 | if (isSupported.value) {
4109 | if (requestPermissions)
4110 | ensurePermissions();
4111 | useEventListener(navigator2.mediaDevices, "devicechange", update, { passive: true });
4112 | update();
4113 | }
4114 | return {
4115 | devices,
4116 | ensurePermissions,
4117 | permissionGranted,
4118 | videoInputs,
4119 | audioInputs,
4120 | audioOutputs,
4121 | isSupported
4122 | };
4123 | }
4124 | function useDisplayMedia(options = {}) {
4125 | var _a;
4126 | const enabled = shallowRef((_a = options.enabled) != null ? _a : false);
4127 | const video = options.video;
4128 | const audio = options.audio;
4129 | const { navigator: navigator2 = defaultNavigator } = options;
4130 | const isSupported = useSupported(() => {
4131 | var _a2;
4132 | return (_a2 = navigator2 == null ? void 0 : navigator2.mediaDevices) == null ? void 0 : _a2.getDisplayMedia;
4133 | });
4134 | const constraint = { audio, video };
4135 | const stream = shallowRef();
4136 | async function _start() {
4137 | var _a2;
4138 | if (!isSupported.value || stream.value)
4139 | return;
4140 | stream.value = await navigator2.mediaDevices.getDisplayMedia(constraint);
4141 | (_a2 = stream.value) == null ? void 0 : _a2.getTracks().forEach((t) => useEventListener(t, "ended", stop, { passive: true }));
4142 | return stream.value;
4143 | }
4144 | async function _stop() {
4145 | var _a2;
4146 | (_a2 = stream.value) == null ? void 0 : _a2.getTracks().forEach((t) => t.stop());
4147 | stream.value = void 0;
4148 | }
4149 | function stop() {
4150 | _stop();
4151 | enabled.value = false;
4152 | }
4153 | async function start() {
4154 | await _start();
4155 | if (stream.value)
4156 | enabled.value = true;
4157 | return stream.value;
4158 | }
4159 | watch(
4160 | enabled,
4161 | (v) => {
4162 | if (v)
4163 | _start();
4164 | else
4165 | _stop();
4166 | },
4167 | { immediate: true }
4168 | );
4169 | return {
4170 | isSupported,
4171 | stream,
4172 | start,
4173 | stop,
4174 | enabled
4175 | };
4176 | }
4177 | function useDocumentVisibility(options = {}) {
4178 | const { document: document2 = defaultDocument } = options;
4179 | if (!document2)
4180 | return shallowRef("visible");
4181 | const visibility = shallowRef(document2.visibilityState);
4182 | useEventListener(document2, "visibilitychange", () => {
4183 | visibility.value = document2.visibilityState;
4184 | }, { passive: true });
4185 | return visibility;
4186 | }
4187 | function useDraggable(target, options = {}) {
4188 | var _a;
4189 | const {
4190 | pointerTypes,
4191 | preventDefault: preventDefault2,
4192 | stopPropagation,
4193 | exact,
4194 | onMove,
4195 | onEnd,
4196 | onStart,
4197 | initialValue,
4198 | axis = "both",
4199 | draggingElement = defaultWindow,
4200 | containerElement,
4201 | handle: draggingHandle = target,
4202 | buttons = [0]
4203 | } = options;
4204 | const position = ref(
4205 | (_a = toValue(initialValue)) != null ? _a : { x: 0, y: 0 }
4206 | );
4207 | const pressedDelta = ref();
4208 | const filterEvent = (e) => {
4209 | if (pointerTypes)
4210 | return pointerTypes.includes(e.pointerType);
4211 | return true;
4212 | };
4213 | const handleEvent = (e) => {
4214 | if (toValue(preventDefault2))
4215 | e.preventDefault();
4216 | if (toValue(stopPropagation))
4217 | e.stopPropagation();
4218 | };
4219 | const start = (e) => {
4220 | var _a2;
4221 | if (!toValue(buttons).includes(e.button))
4222 | return;
4223 | if (toValue(options.disabled) || !filterEvent(e))
4224 | return;
4225 | if (toValue(exact) && e.target !== toValue(target))
4226 | return;
4227 | const container = toValue(containerElement);
4228 | const containerRect = (_a2 = container == null ? void 0 : container.getBoundingClientRect) == null ? void 0 : _a2.call(container);
4229 | const targetRect = toValue(target).getBoundingClientRect();
4230 | const pos = {
4231 | x: e.clientX - (container ? targetRect.left - containerRect.left + container.scrollLeft : targetRect.left),
4232 | y: e.clientY - (container ? targetRect.top - containerRect.top + container.scrollTop : targetRect.top)
4233 | };
4234 | if ((onStart == null ? void 0 : onStart(pos, e)) === false)
4235 | return;
4236 | pressedDelta.value = pos;
4237 | handleEvent(e);
4238 | };
4239 | const move = (e) => {
4240 | if (toValue(options.disabled) || !filterEvent(e))
4241 | return;
4242 | if (!pressedDelta.value)
4243 | return;
4244 | const container = toValue(containerElement);
4245 | const targetRect = toValue(target).getBoundingClientRect();
4246 | let { x, y } = position.value;
4247 | if (axis === "x" || axis === "both") {
4248 | x = e.clientX - pressedDelta.value.x;
4249 | if (container)
4250 | x = Math.min(Math.max(0, x), container.scrollWidth - targetRect.width);
4251 | }
4252 | if (axis === "y" || axis === "both") {
4253 | y = e.clientY - pressedDelta.value.y;
4254 | if (container)
4255 | y = Math.min(Math.max(0, y), container.scrollHeight - targetRect.height);
4256 | }
4257 | position.value = {
4258 | x,
4259 | y
4260 | };
4261 | onMove == null ? void 0 : onMove(position.value, e);
4262 | handleEvent(e);
4263 | };
4264 | const end = (e) => {
4265 | if (toValue(options.disabled) || !filterEvent(e))
4266 | return;
4267 | if (!pressedDelta.value)
4268 | return;
4269 | pressedDelta.value = void 0;
4270 | onEnd == null ? void 0 : onEnd(position.value, e);
4271 | handleEvent(e);
4272 | };
4273 | if (isClient) {
4274 | const config = () => {
4275 | var _a2;
4276 | return {
4277 | capture: (_a2 = options.capture) != null ? _a2 : true,
4278 | passive: !toValue(preventDefault2)
4279 | };
4280 | };
4281 | useEventListener(draggingHandle, "pointerdown", start, config);
4282 | useEventListener(draggingElement, "pointermove", move, config);
4283 | useEventListener(draggingElement, "pointerup", end, config);
4284 | }
4285 | return {
4286 | ...toRefs2(position),
4287 | position,
4288 | isDragging: computed(() => !!pressedDelta.value),
4289 | style: computed(
4290 | () => `left:${position.value.x}px;top:${position.value.y}px;`
4291 | )
4292 | };
4293 | }
4294 | function useDropZone(target, options = {}) {
4295 | var _a, _b;
4296 | const isOverDropZone = shallowRef(false);
4297 | const files = shallowRef(null);
4298 | let counter = 0;
4299 | let isValid = true;
4300 | if (isClient) {
4301 | const _options = typeof options === "function" ? { onDrop: options } : options;
4302 | const multiple = (_a = _options.multiple) != null ? _a : true;
4303 | const preventDefaultForUnhandled = (_b = _options.preventDefaultForUnhandled) != null ? _b : false;
4304 | const getFiles = (event) => {
4305 | var _a2, _b2;
4306 | const list = Array.from((_b2 = (_a2 = event.dataTransfer) == null ? void 0 : _a2.files) != null ? _b2 : []);
4307 | return list.length === 0 ? null : multiple ? list : [list[0]];
4308 | };
4309 | const checkDataTypes = (types) => {
4310 | const dataTypes = unref(_options.dataTypes);
4311 | if (typeof dataTypes === "function")
4312 | return dataTypes(types);
4313 | if (!(dataTypes == null ? void 0 : dataTypes.length))
4314 | return true;
4315 | if (types.length === 0)
4316 | return false;
4317 | return types.every(
4318 | (type) => dataTypes.some((allowedType) => type.includes(allowedType))
4319 | );
4320 | };
4321 | const checkValidity = (items) => {
4322 | const types = Array.from(items != null ? items : []).map((item) => item.type);
4323 | const dataTypesValid = checkDataTypes(types);
4324 | const multipleFilesValid = multiple || items.length <= 1;
4325 | return dataTypesValid && multipleFilesValid;
4326 | };
4327 | const isSafari = () => /^(?:(?!chrome|android).)*safari/i.test(navigator.userAgent) && !("chrome" in window);
4328 | const handleDragEvent = (event, eventType) => {
4329 | var _a2, _b2, _c, _d, _e, _f;
4330 | const dataTransferItemList = (_a2 = event.dataTransfer) == null ? void 0 : _a2.items;
4331 | isValid = (_b2 = dataTransferItemList && checkValidity(dataTransferItemList)) != null ? _b2 : false;
4332 | if (preventDefaultForUnhandled) {
4333 | event.preventDefault();
4334 | }
4335 | if (!isSafari() && !isValid) {
4336 | if (event.dataTransfer) {
4337 | event.dataTransfer.dropEffect = "none";
4338 | }
4339 | return;
4340 | }
4341 | event.preventDefault();
4342 | if (event.dataTransfer) {
4343 | event.dataTransfer.dropEffect = "copy";
4344 | }
4345 | const currentFiles = getFiles(event);
4346 | switch (eventType) {
4347 | case "enter":
4348 | counter += 1;
4349 | isOverDropZone.value = true;
4350 | (_c = _options.onEnter) == null ? void 0 : _c.call(_options, null, event);
4351 | break;
4352 | case "over":
4353 | (_d = _options.onOver) == null ? void 0 : _d.call(_options, null, event);
4354 | break;
4355 | case "leave":
4356 | counter -= 1;
4357 | if (counter === 0)
4358 | isOverDropZone.value = false;
4359 | (_e = _options.onLeave) == null ? void 0 : _e.call(_options, null, event);
4360 | break;
4361 | case "drop":
4362 | counter = 0;
4363 | isOverDropZone.value = false;
4364 | if (isValid) {
4365 | files.value = currentFiles;
4366 | (_f = _options.onDrop) == null ? void 0 : _f.call(_options, currentFiles, event);
4367 | }
4368 | break;
4369 | }
4370 | };
4371 | useEventListener(target, "dragenter", (event) => handleDragEvent(event, "enter"));
4372 | useEventListener(target, "dragover", (event) => handleDragEvent(event, "over"));
4373 | useEventListener(target, "dragleave", (event) => handleDragEvent(event, "leave"));
4374 | useEventListener(target, "drop", (event) => handleDragEvent(event, "drop"));
4375 | }
4376 | return {
4377 | files,
4378 | isOverDropZone
4379 | };
4380 | }
4381 | function useResizeObserver(target, callback, options = {}) {
4382 | const { window: window2 = defaultWindow, ...observerOptions } = options;
4383 | let observer;
4384 | const isSupported = useSupported(() => window2 && "ResizeObserver" in window2);
4385 | const cleanup = () => {
4386 | if (observer) {
4387 | observer.disconnect();
4388 | observer = void 0;
4389 | }
4390 | };
4391 | const targets = computed(() => {
4392 | const _targets = toValue(target);
4393 | return Array.isArray(_targets) ? _targets.map((el) => unrefElement(el)) : [unrefElement(_targets)];
4394 | });
4395 | const stopWatch = watch(
4396 | targets,
4397 | (els) => {
4398 | cleanup();
4399 | if (isSupported.value && window2) {
4400 | observer = new ResizeObserver(callback);
4401 | for (const _el of els) {
4402 | if (_el)
4403 | observer.observe(_el, observerOptions);
4404 | }
4405 | }
4406 | },
4407 | { immediate: true, flush: "post" }
4408 | );
4409 | const stop = () => {
4410 | cleanup();
4411 | stopWatch();
4412 | };
4413 | tryOnScopeDispose(stop);
4414 | return {
4415 | isSupported,
4416 | stop
4417 | };
4418 | }
4419 | function useElementBounding(target, options = {}) {
4420 | const {
4421 | reset = true,
4422 | windowResize = true,
4423 | windowScroll = true,
4424 | immediate = true,
4425 | updateTiming = "sync"
4426 | } = options;
4427 | const height = shallowRef(0);
4428 | const bottom = shallowRef(0);
4429 | const left = shallowRef(0);
4430 | const right = shallowRef(0);
4431 | const top = shallowRef(0);
4432 | const width = shallowRef(0);
4433 | const x = shallowRef(0);
4434 | const y = shallowRef(0);
4435 | function recalculate() {
4436 | const el = unrefElement(target);
4437 | if (!el) {
4438 | if (reset) {
4439 | height.value = 0;
4440 | bottom.value = 0;
4441 | left.value = 0;
4442 | right.value = 0;
4443 | top.value = 0;
4444 | width.value = 0;
4445 | x.value = 0;
4446 | y.value = 0;
4447 | }
4448 | return;
4449 | }
4450 | const rect = el.getBoundingClientRect();
4451 | height.value = rect.height;
4452 | bottom.value = rect.bottom;
4453 | left.value = rect.left;
4454 | right.value = rect.right;
4455 | top.value = rect.top;
4456 | width.value = rect.width;
4457 | x.value = rect.x;
4458 | y.value = rect.y;
4459 | }
4460 | function update() {
4461 | if (updateTiming === "sync")
4462 | recalculate();
4463 | else if (updateTiming === "next-frame")
4464 | requestAnimationFrame(() => recalculate());
4465 | }
4466 | useResizeObserver(target, update);
4467 | watch(() => unrefElement(target), (ele) => !ele && update());
4468 | useMutationObserver(target, update, {
4469 | attributeFilter: ["style", "class"]
4470 | });
4471 | if (windowScroll)
4472 | useEventListener("scroll", update, { capture: true, passive: true });
4473 | if (windowResize)
4474 | useEventListener("resize", update, { passive: true });
4475 | tryOnMounted(() => {
4476 | if (immediate)
4477 | update();
4478 | });
4479 | return {
4480 | height,
4481 | bottom,
4482 | left,
4483 | right,
4484 | top,
4485 | width,
4486 | x,
4487 | y,
4488 | update
4489 | };
4490 | }
4491 | function useElementByPoint(options) {
4492 | const {
4493 | x,
4494 | y,
4495 | document: document2 = defaultDocument,
4496 | multiple,
4497 | interval = "requestAnimationFrame",
4498 | immediate = true
4499 | } = options;
4500 | const isSupported = useSupported(() => {
4501 | if (toValue(multiple))
4502 | return document2 && "elementsFromPoint" in document2;
4503 | return document2 && "elementFromPoint" in document2;
4504 | });
4505 | const element = shallowRef(null);
4506 | const cb = () => {
4507 | var _a, _b;
4508 | element.value = toValue(multiple) ? (_a = document2 == null ? void 0 : document2.elementsFromPoint(toValue(x), toValue(y))) != null ? _a : [] : (_b = document2 == null ? void 0 : document2.elementFromPoint(toValue(x), toValue(y))) != null ? _b : null;
4509 | };
4510 | const controls = interval === "requestAnimationFrame" ? useRafFn(cb, { immediate }) : useIntervalFn(cb, interval, { immediate });
4511 | return {
4512 | isSupported,
4513 | element,
4514 | ...controls
4515 | };
4516 | }
4517 | function useElementHover(el, options = {}) {
4518 | const {
4519 | delayEnter = 0,
4520 | delayLeave = 0,
4521 | triggerOnRemoval = false,
4522 | window: window2 = defaultWindow
4523 | } = options;
4524 | const isHovered = shallowRef(false);
4525 | let timer;
4526 | const toggle = (entering) => {
4527 | const delay = entering ? delayEnter : delayLeave;
4528 | if (timer) {
4529 | clearTimeout(timer);
4530 | timer = void 0;
4531 | }
4532 | if (delay)
4533 | timer = setTimeout(() => isHovered.value = entering, delay);
4534 | else
4535 | isHovered.value = entering;
4536 | };
4537 | if (!window2)
4538 | return isHovered;
4539 | useEventListener(el, "mouseenter", () => toggle(true), { passive: true });
4540 | useEventListener(el, "mouseleave", () => toggle(false), { passive: true });
4541 | if (triggerOnRemoval) {
4542 | onElementRemoval(
4543 | computed(() => unrefElement(el)),
4544 | () => toggle(false)
4545 | );
4546 | }
4547 | return isHovered;
4548 | }
4549 | function useElementSize(target, initialSize = { width: 0, height: 0 }, options = {}) {
4550 | const { window: window2 = defaultWindow, box = "content-box" } = options;
4551 | const isSVG = computed(() => {
4552 | var _a, _b;
4553 | return (_b = (_a = unrefElement(target)) == null ? void 0 : _a.namespaceURI) == null ? void 0 : _b.includes("svg");
4554 | });
4555 | const width = shallowRef(initialSize.width);
4556 | const height = shallowRef(initialSize.height);
4557 | const { stop: stop1 } = useResizeObserver(
4558 | target,
4559 | ([entry]) => {
4560 | const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
4561 | if (window2 && isSVG.value) {
4562 | const $elem = unrefElement(target);
4563 | if ($elem) {
4564 | const rect = $elem.getBoundingClientRect();
4565 | width.value = rect.width;
4566 | height.value = rect.height;
4567 | }
4568 | } else {
4569 | if (boxSize) {
4570 | const formatBoxSize = toArray(boxSize);
4571 | width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
4572 | height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
4573 | } else {
4574 | width.value = entry.contentRect.width;
4575 | height.value = entry.contentRect.height;
4576 | }
4577 | }
4578 | },
4579 | options
4580 | );
4581 | tryOnMounted(() => {
4582 | const ele = unrefElement(target);
4583 | if (ele) {
4584 | width.value = "offsetWidth" in ele ? ele.offsetWidth : initialSize.width;
4585 | height.value = "offsetHeight" in ele ? ele.offsetHeight : initialSize.height;
4586 | }
4587 | });
4588 | const stop2 = watch(
4589 | () => unrefElement(target),
4590 | (ele) => {
4591 | width.value = ele ? initialSize.width : 0;
4592 | height.value = ele ? initialSize.height : 0;
4593 | }
4594 | );
4595 | function stop() {
4596 | stop1();
4597 | stop2();
4598 | }
4599 | return {
4600 | width,
4601 | height,
4602 | stop
4603 | };
4604 | }
4605 | function useIntersectionObserver(target, callback, options = {}) {
4606 | const {
4607 | root,
4608 | rootMargin = "0px",
4609 | threshold = 0,
4610 | window: window2 = defaultWindow,
4611 | immediate = true
4612 | } = options;
4613 | const isSupported = useSupported(() => window2 && "IntersectionObserver" in window2);
4614 | const targets = computed(() => {
4615 | const _target = toValue(target);
4616 | return toArray(_target).map(unrefElement).filter(notNullish);
4617 | });
4618 | let cleanup = noop;
4619 | const isActive = shallowRef(immediate);
4620 | const stopWatch = isSupported.value ? watch(
4621 | () => [targets.value, unrefElement(root), isActive.value],
4622 | ([targets2, root2]) => {
4623 | cleanup();
4624 | if (!isActive.value)
4625 | return;
4626 | if (!targets2.length)
4627 | return;
4628 | const observer = new IntersectionObserver(
4629 | callback,
4630 | {
4631 | root: unrefElement(root2),
4632 | rootMargin,
4633 | threshold
4634 | }
4635 | );
4636 | targets2.forEach((el) => el && observer.observe(el));
4637 | cleanup = () => {
4638 | observer.disconnect();
4639 | cleanup = noop;
4640 | };
4641 | },
4642 | { immediate, flush: "post" }
4643 | ) : noop;
4644 | const stop = () => {
4645 | cleanup();
4646 | stopWatch();
4647 | isActive.value = false;
4648 | };
4649 | tryOnScopeDispose(stop);
4650 | return {
4651 | isSupported,
4652 | isActive,
4653 | pause() {
4654 | cleanup();
4655 | isActive.value = false;
4656 | },
4657 | resume() {
4658 | isActive.value = true;
4659 | },
4660 | stop
4661 | };
4662 | }
4663 | function useElementVisibility(element, options = {}) {
4664 | const {
4665 | window: window2 = defaultWindow,
4666 | scrollTarget,
4667 | threshold = 0,
4668 | rootMargin,
4669 | once = false
4670 | } = options;
4671 | const elementIsVisible = shallowRef(false);
4672 | const { stop } = useIntersectionObserver(
4673 | element,
4674 | (intersectionObserverEntries) => {
4675 | let isIntersecting = elementIsVisible.value;
4676 | let latestTime = 0;
4677 | for (const entry of intersectionObserverEntries) {
4678 | if (entry.time >= latestTime) {
4679 | latestTime = entry.time;
4680 | isIntersecting = entry.isIntersecting;
4681 | }
4682 | }
4683 | elementIsVisible.value = isIntersecting;
4684 | if (once) {
4685 | watchOnce(elementIsVisible, () => {
4686 | stop();
4687 | });
4688 | }
4689 | },
4690 | {
4691 | root: scrollTarget,
4692 | window: window2,
4693 | threshold,
4694 | rootMargin: toValue(rootMargin)
4695 | }
4696 | );
4697 | return elementIsVisible;
4698 | }
4699 | var events = /* @__PURE__ */ new Map();
4700 | function useEventBus(key) {
4701 | const scope = getCurrentScope();
4702 | function on(listener) {
4703 | var _a;
4704 | const listeners = events.get(key) || /* @__PURE__ */ new Set();
4705 | listeners.add(listener);
4706 | events.set(key, listeners);
4707 | const _off = () => off(listener);
4708 | (_a = scope == null ? void 0 : scope.cleanups) == null ? void 0 : _a.push(_off);
4709 | return _off;
4710 | }
4711 | function once(listener) {
4712 | function _listener(...args) {
4713 | off(_listener);
4714 | listener(...args);
4715 | }
4716 | return on(_listener);
4717 | }
4718 | function off(listener) {
4719 | const listeners = events.get(key);
4720 | if (!listeners)
4721 | return;
4722 | listeners.delete(listener);
4723 | if (!listeners.size)
4724 | reset();
4725 | }
4726 | function reset() {
4727 | events.delete(key);
4728 | }
4729 | function emit(event, payload) {
4730 | var _a;
4731 | (_a = events.get(key)) == null ? void 0 : _a.forEach((v) => v(event, payload));
4732 | }
4733 | return { on, once, off, emit, reset };
4734 | }
4735 | function resolveNestedOptions$1(options) {
4736 | if (options === true)
4737 | return {};
4738 | return options;
4739 | }
4740 | function useEventSource(url, events2 = [], options = {}) {
4741 | const event = shallowRef(null);
4742 | const data = shallowRef(null);
4743 | const status = shallowRef("CONNECTING");
4744 | const eventSource = ref(null);
4745 | const error = shallowRef(null);
4746 | const urlRef = toRef2(url);
4747 | const lastEventId = shallowRef(null);
4748 | let explicitlyClosed = false;
4749 | let retried = 0;
4750 | const {
4751 | withCredentials = false,
4752 | immediate = true,
4753 | autoConnect = true,
4754 | autoReconnect
4755 | } = options;
4756 | const close = () => {
4757 | if (isClient && eventSource.value) {
4758 | eventSource.value.close();
4759 | eventSource.value = null;
4760 | status.value = "CLOSED";
4761 | explicitlyClosed = true;
4762 | }
4763 | };
4764 | const _init = () => {
4765 | if (explicitlyClosed || typeof urlRef.value === "undefined")
4766 | return;
4767 | const es = new EventSource(urlRef.value, { withCredentials });
4768 | status.value = "CONNECTING";
4769 | eventSource.value = es;
4770 | es.onopen = () => {
4771 | status.value = "OPEN";
4772 | error.value = null;
4773 | };
4774 | es.onerror = (e) => {
4775 | status.value = "CLOSED";
4776 | error.value = e;
4777 | if (es.readyState === 2 && !explicitlyClosed && autoReconnect) {
4778 | es.close();
4779 | const {
4780 | retries = -1,
4781 | delay = 1e3,
4782 | onFailed
4783 | } = resolveNestedOptions$1(autoReconnect);
4784 | retried += 1;
4785 | if (typeof retries === "number" && (retries < 0 || retried < retries))
4786 | setTimeout(_init, delay);
4787 | else if (typeof retries === "function" && retries())
4788 | setTimeout(_init, delay);
4789 | else
4790 | onFailed == null ? void 0 : onFailed();
4791 | }
4792 | };
4793 | es.onmessage = (e) => {
4794 | event.value = null;
4795 | data.value = e.data;
4796 | lastEventId.value = e.lastEventId;
4797 | };
4798 | for (const event_name of events2) {
4799 | useEventListener(es, event_name, (e) => {
4800 | event.value = event_name;
4801 | data.value = e.data || null;
4802 | }, { passive: true });
4803 | }
4804 | };
4805 | const open = () => {
4806 | if (!isClient)
4807 | return;
4808 | close();
4809 | explicitlyClosed = false;
4810 | retried = 0;
4811 | _init();
4812 | };
4813 | if (immediate)
4814 | open();
4815 | if (autoConnect)
4816 | watch(urlRef, open);
4817 | tryOnScopeDispose(close);
4818 | return {
4819 | eventSource,
4820 | event,
4821 | data,
4822 | status,
4823 | error,
4824 | open,
4825 | close,
4826 | lastEventId
4827 | };
4828 | }
4829 | function useEyeDropper(options = {}) {
4830 | const { initialValue = "" } = options;
4831 | const isSupported = useSupported(() => typeof window !== "undefined" && "EyeDropper" in window);
4832 | const sRGBHex = shallowRef(initialValue);
4833 | async function open(openOptions) {
4834 | if (!isSupported.value)
4835 | return;
4836 | const eyeDropper = new window.EyeDropper();
4837 | const result = await eyeDropper.open(openOptions);
4838 | sRGBHex.value = result.sRGBHex;
4839 | return result;
4840 | }
4841 | return { isSupported, sRGBHex, open };
4842 | }
4843 | function useFavicon(newIcon = null, options = {}) {
4844 | const {
4845 | baseUrl = "",
4846 | rel = "icon",
4847 | document: document2 = defaultDocument
4848 | } = options;
4849 | const favicon = toRef2(newIcon);
4850 | const applyIcon = (icon) => {
4851 | const elements = document2 == null ? void 0 : document2.head.querySelectorAll(`link[rel*="${rel}"]`);
4852 | if (!elements || elements.length === 0) {
4853 | const link = document2 == null ? void 0 : document2.createElement("link");
4854 | if (link) {
4855 | link.rel = rel;
4856 | link.href = `${baseUrl}${icon}`;
4857 | link.type = `image/${icon.split(".").pop()}`;
4858 | document2 == null ? void 0 : document2.head.append(link);
4859 | }
4860 | return;
4861 | }
4862 | elements == null ? void 0 : elements.forEach((el) => el.href = `${baseUrl}${icon}`);
4863 | };
4864 | watch(
4865 | favicon,
4866 | (i, o) => {
4867 | if (typeof i === "string" && i !== o)
4868 | applyIcon(i);
4869 | },
4870 | { immediate: true }
4871 | );
4872 | return favicon;
4873 | }
4874 | var payloadMapping = {
4875 | json: "application/json",
4876 | text: "text/plain"
4877 | };
4878 | function isFetchOptions(obj) {
4879 | return obj && containsProp(obj, "immediate", "refetch", "initialData", "timeout", "beforeFetch", "afterFetch", "onFetchError", "fetch", "updateDataOnError");
4880 | }
4881 | var reAbsolute = /^(?:[a-z][a-z\d+\-.]*:)?\/\//i;
4882 | function isAbsoluteURL(url) {
4883 | return reAbsolute.test(url);
4884 | }
4885 | function headersToObject(headers) {
4886 | if (typeof Headers !== "undefined" && headers instanceof Headers)
4887 | return Object.fromEntries(headers.entries());
4888 | return headers;
4889 | }
4890 | function combineCallbacks(combination, ...callbacks) {
4891 | if (combination === "overwrite") {
4892 | return async (ctx) => {
4893 | let callback;
4894 | for (let i = callbacks.length - 1; i >= 0; i--) {
4895 | if (callbacks[i] != null) {
4896 | callback = callbacks[i];
4897 | break;
4898 | }
4899 | }
4900 | if (callback)
4901 | return { ...ctx, ...await callback(ctx) };
4902 | return ctx;
4903 | };
4904 | } else {
4905 | return async (ctx) => {
4906 | for (const callback of callbacks) {
4907 | if (callback)
4908 | ctx = { ...ctx, ...await callback(ctx) };
4909 | }
4910 | return ctx;
4911 | };
4912 | }
4913 | }
4914 | function createFetch(config = {}) {
4915 | const _combination = config.combination || "chain";
4916 | const _options = config.options || {};
4917 | const _fetchOptions = config.fetchOptions || {};
4918 | function useFactoryFetch(url, ...args) {
4919 | const computedUrl = computed(() => {
4920 | const baseUrl = toValue(config.baseUrl);
4921 | const targetUrl = toValue(url);
4922 | return baseUrl && !isAbsoluteURL(targetUrl) ? joinPaths(baseUrl, targetUrl) : targetUrl;
4923 | });
4924 | let options = _options;
4925 | let fetchOptions = _fetchOptions;
4926 | if (args.length > 0) {
4927 | if (isFetchOptions(args[0])) {
4928 | options = {
4929 | ...options,
4930 | ...args[0],
4931 | beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[0].beforeFetch),
4932 | afterFetch: combineCallbacks(_combination, _options.afterFetch, args[0].afterFetch),
4933 | onFetchError: combineCallbacks(_combination, _options.onFetchError, args[0].onFetchError)
4934 | };
4935 | } else {
4936 | fetchOptions = {
4937 | ...fetchOptions,
4938 | ...args[0],
4939 | headers: {
4940 | ...headersToObject(fetchOptions.headers) || {},
4941 | ...headersToObject(args[0].headers) || {}
4942 | }
4943 | };
4944 | }
4945 | }
4946 | if (args.length > 1 && isFetchOptions(args[1])) {
4947 | options = {
4948 | ...options,
4949 | ...args[1],
4950 | beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[1].beforeFetch),
4951 | afterFetch: combineCallbacks(_combination, _options.afterFetch, args[1].afterFetch),
4952 | onFetchError: combineCallbacks(_combination, _options.onFetchError, args[1].onFetchError)
4953 | };
4954 | }
4955 | return useFetch(computedUrl, fetchOptions, options);
4956 | }
4957 | return useFactoryFetch;
4958 | }
4959 | function useFetch(url, ...args) {
4960 | var _a;
4961 | const supportsAbort = typeof AbortController === "function";
4962 | let fetchOptions = {};
4963 | let options = {
4964 | immediate: true,
4965 | refetch: false,
4966 | timeout: 0,
4967 | updateDataOnError: false
4968 | };
4969 | const config = {
4970 | method: "GET",
4971 | type: "text",
4972 | payload: void 0
4973 | };
4974 | if (args.length > 0) {
4975 | if (isFetchOptions(args[0]))
4976 | options = { ...options, ...args[0] };
4977 | else
4978 | fetchOptions = args[0];
4979 | }
4980 | if (args.length > 1) {
4981 | if (isFetchOptions(args[1]))
4982 | options = { ...options, ...args[1] };
4983 | }
4984 | const {
4985 | fetch = (_a = defaultWindow) == null ? void 0 : _a.fetch,
4986 | initialData,
4987 | timeout
4988 | } = options;
4989 | const responseEvent = createEventHook();
4990 | const errorEvent = createEventHook();
4991 | const finallyEvent = createEventHook();
4992 | const isFinished = shallowRef(false);
4993 | const isFetching = shallowRef(false);
4994 | const aborted = shallowRef(false);
4995 | const statusCode = shallowRef(null);
4996 | const response = shallowRef(null);
4997 | const error = shallowRef(null);
4998 | const data = shallowRef(initialData || null);
4999 | const canAbort = computed(() => supportsAbort && isFetching.value);
5000 | let controller;
5001 | let timer;
5002 | const abort = () => {
5003 | if (supportsAbort) {
5004 | controller == null ? void 0 : controller.abort();
5005 | controller = new AbortController();
5006 | controller.signal.onabort = () => aborted.value = true;
5007 | fetchOptions = {
5008 | ...fetchOptions,
5009 | signal: controller.signal
5010 | };
5011 | }
5012 | };
5013 | const loading = (isLoading) => {
5014 | isFetching.value = isLoading;
5015 | isFinished.value = !isLoading;
5016 | };
5017 | if (timeout)
5018 | timer = useTimeoutFn(abort, timeout, { immediate: false });
5019 | let executeCounter = 0;
5020 | const execute = async (throwOnFailed = false) => {
5021 | var _a2, _b;
5022 | abort();
5023 | loading(true);
5024 | error.value = null;
5025 | statusCode.value = null;
5026 | aborted.value = false;
5027 | executeCounter += 1;
5028 | const currentExecuteCounter = executeCounter;
5029 | const defaultFetchOptions = {
5030 | method: config.method,
5031 | headers: {}
5032 | };
5033 | const payload = toValue(config.payload);
5034 | if (payload) {
5035 | const headers = headersToObject(defaultFetchOptions.headers);
5036 | const proto = Object.getPrototypeOf(payload);
5037 | if (!config.payloadType && payload && (proto === Object.prototype || Array.isArray(proto)) && !(payload instanceof FormData))
5038 | config.payloadType = "json";
5039 | if (config.payloadType)
5040 | headers["Content-Type"] = (_a2 = payloadMapping[config.payloadType]) != null ? _a2 : config.payloadType;
5041 | defaultFetchOptions.body = config.payloadType === "json" ? JSON.stringify(payload) : payload;
5042 | }
5043 | let isCanceled = false;
5044 | const context = {
5045 | url: toValue(url),
5046 | options: {
5047 | ...defaultFetchOptions,
5048 | ...fetchOptions
5049 | },
5050 | cancel: () => {
5051 | isCanceled = true;
5052 | }
5053 | };
5054 | if (options.beforeFetch)
5055 | Object.assign(context, await options.beforeFetch(context));
5056 | if (isCanceled || !fetch) {
5057 | loading(false);
5058 | return Promise.resolve(null);
5059 | }
5060 | let responseData = null;
5061 | if (timer)
5062 | timer.start();
5063 | return fetch(
5064 | context.url,
5065 | {
5066 | ...defaultFetchOptions,
5067 | ...context.options,
5068 | headers: {
5069 | ...headersToObject(defaultFetchOptions.headers),
5070 | ...headersToObject((_b = context.options) == null ? void 0 : _b.headers)
5071 | }
5072 | }
5073 | ).then(async (fetchResponse) => {
5074 | response.value = fetchResponse;
5075 | statusCode.value = fetchResponse.status;
5076 | responseData = await fetchResponse.clone()[config.type]();
5077 | if (!fetchResponse.ok) {
5078 | data.value = initialData || null;
5079 | throw new Error(fetchResponse.statusText);
5080 | }
5081 | if (options.afterFetch) {
5082 | ({ data: responseData } = await options.afterFetch({
5083 | data: responseData,
5084 | response: fetchResponse,
5085 | context,
5086 | execute
5087 | }));
5088 | }
5089 | data.value = responseData;
5090 | responseEvent.trigger(fetchResponse);
5091 | return fetchResponse;
5092 | }).catch(async (fetchError) => {
5093 | let errorData = fetchError.message || fetchError.name;
5094 | if (options.onFetchError) {
5095 | ({ error: errorData, data: responseData } = await options.onFetchError({
5096 | data: responseData,
5097 | error: fetchError,
5098 | response: response.value,
5099 | context,
5100 | execute
5101 | }));
5102 | }
5103 | error.value = errorData;
5104 | if (options.updateDataOnError)
5105 | data.value = responseData;
5106 | errorEvent.trigger(fetchError);
5107 | if (throwOnFailed)
5108 | throw fetchError;
5109 | return null;
5110 | }).finally(() => {
5111 | if (currentExecuteCounter === executeCounter)
5112 | loading(false);
5113 | if (timer)
5114 | timer.stop();
5115 | finallyEvent.trigger(null);
5116 | });
5117 | };
5118 | const refetch = toRef2(options.refetch);
5119 | watch(
5120 | [
5121 | refetch,
5122 | toRef2(url)
5123 | ],
5124 | ([refetch2]) => refetch2 && execute(),
5125 | { deep: true }
5126 | );
5127 | const shell = {
5128 | isFinished: readonly(isFinished),
5129 | isFetching: readonly(isFetching),
5130 | statusCode,
5131 | response,
5132 | error,
5133 | data,
5134 | canAbort,
5135 | aborted,
5136 | abort,
5137 | execute,
5138 | onFetchResponse: responseEvent.on,
5139 | onFetchError: errorEvent.on,
5140 | onFetchFinally: finallyEvent.on,
5141 | // method
5142 | get: setMethod("GET"),
5143 | put: setMethod("PUT"),
5144 | post: setMethod("POST"),
5145 | delete: setMethod("DELETE"),
5146 | patch: setMethod("PATCH"),
5147 | head: setMethod("HEAD"),
5148 | options: setMethod("OPTIONS"),
5149 | // type
5150 | json: setType("json"),
5151 | text: setType("text"),
5152 | blob: setType("blob"),
5153 | arrayBuffer: setType("arrayBuffer"),
5154 | formData: setType("formData")
5155 | };
5156 | function setMethod(method) {
5157 | return (payload, payloadType) => {
5158 | if (!isFetching.value) {
5159 | config.method = method;
5160 | config.payload = payload;
5161 | config.payloadType = payloadType;
5162 | if (isRef(config.payload)) {
5163 | watch(
5164 | [
5165 | refetch,
5166 | toRef2(config.payload)
5167 | ],
5168 | ([refetch2]) => refetch2 && execute(),
5169 | { deep: true }
5170 | );
5171 | }
5172 | return {
5173 | ...shell,
5174 | then(onFulfilled, onRejected) {
5175 | return waitUntilFinished().then(onFulfilled, onRejected);
5176 | }
5177 | };
5178 | }
5179 | return void 0;
5180 | };
5181 | }
5182 | function waitUntilFinished() {
5183 | return new Promise((resolve, reject) => {
5184 | until(isFinished).toBe(true).then(() => resolve(shell)).catch(reject);
5185 | });
5186 | }
5187 | function setType(type) {
5188 | return () => {
5189 | if (!isFetching.value) {
5190 | config.type = type;
5191 | return {
5192 | ...shell,
5193 | then(onFulfilled, onRejected) {
5194 | return waitUntilFinished().then(onFulfilled, onRejected);
5195 | }
5196 | };
5197 | }
5198 | return void 0;
5199 | };
5200 | }
5201 | if (options.immediate)
5202 | Promise.resolve().then(() => execute());
5203 | return {
5204 | ...shell,
5205 | then(onFulfilled, onRejected) {
5206 | return waitUntilFinished().then(onFulfilled, onRejected);
5207 | }
5208 | };
5209 | }
5210 | function joinPaths(start, end) {
5211 | if (!start.endsWith("/") && !end.startsWith("/")) {
5212 | return `${start}/${end}`;
5213 | }
5214 | if (start.endsWith("/") && end.startsWith("/")) {
5215 | return `${start.slice(0, -1)}${end}`;
5216 | }
5217 | return `${start}${end}`;
5218 | }
5219 | var DEFAULT_OPTIONS = {
5220 | multiple: true,
5221 | accept: "*",
5222 | reset: false,
5223 | directory: false
5224 | };
5225 | function prepareInitialFiles(files) {
5226 | if (!files)
5227 | return null;
5228 | if (files instanceof FileList)
5229 | return files;
5230 | const dt = new DataTransfer();
5231 | for (const file of files) {
5232 | dt.items.add(file);
5233 | }
5234 | return dt.files;
5235 | }
5236 | function useFileDialog(options = {}) {
5237 | const {
5238 | document: document2 = defaultDocument
5239 | } = options;
5240 | const files = ref(prepareInitialFiles(options.initialFiles));
5241 | const { on: onChange, trigger: changeTrigger } = createEventHook();
5242 | const { on: onCancel, trigger: cancelTrigger } = createEventHook();
5243 | let input;
5244 | if (document2) {
5245 | input = document2.createElement("input");
5246 | input.type = "file";
5247 | input.onchange = (event) => {
5248 | const result = event.target;
5249 | files.value = result.files;
5250 | changeTrigger(files.value);
5251 | };
5252 | input.oncancel = () => {
5253 | cancelTrigger();
5254 | };
5255 | }
5256 | const reset = () => {
5257 | files.value = null;
5258 | if (input && input.value) {
5259 | input.value = "";
5260 | changeTrigger(null);
5261 | }
5262 | };
5263 | const open = (localOptions) => {
5264 | if (!input)
5265 | return;
5266 | const _options = {
5267 | ...DEFAULT_OPTIONS,
5268 | ...options,
5269 | ...localOptions
5270 | };
5271 | input.multiple = _options.multiple;
5272 | input.accept = _options.accept;
5273 | input.webkitdirectory = _options.directory;
5274 | if (hasOwn(_options, "capture"))
5275 | input.capture = _options.capture;
5276 | if (_options.reset)
5277 | reset();
5278 | input.click();
5279 | };
5280 | return {
5281 | files: readonly(files),
5282 | open,
5283 | reset,
5284 | onCancel,
5285 | onChange
5286 | };
5287 | }
5288 | function useFileSystemAccess(options = {}) {
5289 | const {
5290 | window: _window = defaultWindow,
5291 | dataType = "Text"
5292 | } = options;
5293 | const window2 = _window;
5294 | const isSupported = useSupported(() => window2 && "showSaveFilePicker" in window2 && "showOpenFilePicker" in window2);
5295 | const fileHandle = shallowRef();
5296 | const data = shallowRef();
5297 | const file = shallowRef();
5298 | const fileName = computed(() => {
5299 | var _a, _b;
5300 | return (_b = (_a = file.value) == null ? void 0 : _a.name) != null ? _b : "";
5301 | });
5302 | const fileMIME = computed(() => {
5303 | var _a, _b;
5304 | return (_b = (_a = file.value) == null ? void 0 : _a.type) != null ? _b : "";
5305 | });
5306 | const fileSize = computed(() => {
5307 | var _a, _b;
5308 | return (_b = (_a = file.value) == null ? void 0 : _a.size) != null ? _b : 0;
5309 | });
5310 | const fileLastModified = computed(() => {
5311 | var _a, _b;
5312 | return (_b = (_a = file.value) == null ? void 0 : _a.lastModified) != null ? _b : 0;
5313 | });
5314 | async function open(_options = {}) {
5315 | if (!isSupported.value)
5316 | return;
5317 | const [handle] = await window2.showOpenFilePicker({ ...toValue(options), ..._options });
5318 | fileHandle.value = handle;
5319 | await updateData();
5320 | }
5321 | async function create(_options = {}) {
5322 | if (!isSupported.value)
5323 | return;
5324 | fileHandle.value = await window2.showSaveFilePicker({ ...options, ..._options });
5325 | data.value = void 0;
5326 | await updateData();
5327 | }
5328 | async function save(_options = {}) {
5329 | if (!isSupported.value)
5330 | return;
5331 | if (!fileHandle.value)
5332 | return saveAs(_options);
5333 | if (data.value) {
5334 | const writableStream = await fileHandle.value.createWritable();
5335 | await writableStream.write(data.value);
5336 | await writableStream.close();
5337 | }
5338 | await updateFile();
5339 | }
5340 | async function saveAs(_options = {}) {
5341 | if (!isSupported.value)
5342 | return;
5343 | fileHandle.value = await window2.showSaveFilePicker({ ...options, ..._options });
5344 | if (data.value) {
5345 | const writableStream = await fileHandle.value.createWritable();
5346 | await writableStream.write(data.value);
5347 | await writableStream.close();
5348 | }
5349 | await updateFile();
5350 | }
5351 | async function updateFile() {
5352 | var _a;
5353 | file.value = await ((_a = fileHandle.value) == null ? void 0 : _a.getFile());
5354 | }
5355 | async function updateData() {
5356 | var _a, _b;
5357 | await updateFile();
5358 | const type = toValue(dataType);
5359 | if (type === "Text")
5360 | data.value = await ((_a = file.value) == null ? void 0 : _a.text());
5361 | else if (type === "ArrayBuffer")
5362 | data.value = await ((_b = file.value) == null ? void 0 : _b.arrayBuffer());
5363 | else if (type === "Blob")
5364 | data.value = file.value;
5365 | }
5366 | watch(() => toValue(dataType), updateData);
5367 | return {
5368 | isSupported,
5369 | data,
5370 | file,
5371 | fileName,
5372 | fileMIME,
5373 | fileSize,
5374 | fileLastModified,
5375 | open,
5376 | create,
5377 | save,
5378 | saveAs,
5379 | updateData
5380 | };
5381 | }
5382 | function useFocus(target, options = {}) {
5383 | const { initialValue = false, focusVisible = false, preventScroll = false } = options;
5384 | const innerFocused = shallowRef(false);
5385 | const targetElement = computed(() => unrefElement(target));
5386 | const listenerOptions = { passive: true };
5387 | useEventListener(targetElement, "focus", (event) => {
5388 | var _a, _b;
5389 | if (!focusVisible || ((_b = (_a = event.target).matches) == null ? void 0 : _b.call(_a, ":focus-visible")))
5390 | innerFocused.value = true;
5391 | }, listenerOptions);
5392 | useEventListener(targetElement, "blur", () => innerFocused.value = false, listenerOptions);
5393 | const focused = computed({
5394 | get: () => innerFocused.value,
5395 | set(value) {
5396 | var _a, _b;
5397 | if (!value && innerFocused.value)
5398 | (_a = targetElement.value) == null ? void 0 : _a.blur();
5399 | else if (value && !innerFocused.value)
5400 | (_b = targetElement.value) == null ? void 0 : _b.focus({ preventScroll });
5401 | }
5402 | });
5403 | watch(
5404 | targetElement,
5405 | () => {
5406 | focused.value = initialValue;
5407 | },
5408 | { immediate: true, flush: "post" }
5409 | );
5410 | return { focused };
5411 | }
5412 | var EVENT_FOCUS_IN = "focusin";
5413 | var EVENT_FOCUS_OUT = "focusout";
5414 | var PSEUDO_CLASS_FOCUS_WITHIN = ":focus-within";
5415 | function useFocusWithin(target, options = {}) {
5416 | const { window: window2 = defaultWindow } = options;
5417 | const targetElement = computed(() => unrefElement(target));
5418 | const _focused = shallowRef(false);
5419 | const focused = computed(() => _focused.value);
5420 | const activeElement = useActiveElement(options);
5421 | if (!window2 || !activeElement.value) {
5422 | return { focused };
5423 | }
5424 | const listenerOptions = { passive: true };
5425 | useEventListener(targetElement, EVENT_FOCUS_IN, () => _focused.value = true, listenerOptions);
5426 | useEventListener(targetElement, EVENT_FOCUS_OUT, () => {
5427 | var _a, _b, _c;
5428 | return _focused.value = (_c = (_b = (_a = targetElement.value) == null ? void 0 : _a.matches) == null ? void 0 : _b.call(_a, PSEUDO_CLASS_FOCUS_WITHIN)) != null ? _c : false;
5429 | }, listenerOptions);
5430 | return { focused };
5431 | }
5432 | function useFps(options) {
5433 | var _a;
5434 | const fps = shallowRef(0);
5435 | if (typeof performance === "undefined")
5436 | return fps;
5437 | const every = (_a = options == null ? void 0 : options.every) != null ? _a : 10;
5438 | let last = performance.now();
5439 | let ticks = 0;
5440 | useRafFn(() => {
5441 | ticks += 1;
5442 | if (ticks >= every) {
5443 | const now2 = performance.now();
5444 | const diff = now2 - last;
5445 | fps.value = Math.round(1e3 / (diff / ticks));
5446 | last = now2;
5447 | ticks = 0;
5448 | }
5449 | });
5450 | return fps;
5451 | }
5452 | var eventHandlers = [
5453 | "fullscreenchange",
5454 | "webkitfullscreenchange",
5455 | "webkitendfullscreen",
5456 | "mozfullscreenchange",
5457 | "MSFullscreenChange"
5458 | ];
5459 | function useFullscreen(target, options = {}) {
5460 | const {
5461 | document: document2 = defaultDocument,
5462 | autoExit = false
5463 | } = options;
5464 | const targetRef = computed(() => {
5465 | var _a;
5466 | return (_a = unrefElement(target)) != null ? _a : document2 == null ? void 0 : document2.documentElement;
5467 | });
5468 | const isFullscreen = shallowRef(false);
5469 | const requestMethod = computed(() => {
5470 | return [
5471 | "requestFullscreen",
5472 | "webkitRequestFullscreen",
5473 | "webkitEnterFullscreen",
5474 | "webkitEnterFullScreen",
5475 | "webkitRequestFullScreen",
5476 | "mozRequestFullScreen",
5477 | "msRequestFullscreen"
5478 | ].find((m) => document2 && m in document2 || targetRef.value && m in targetRef.value);
5479 | });
5480 | const exitMethod = computed(() => {
5481 | return [
5482 | "exitFullscreen",
5483 | "webkitExitFullscreen",
5484 | "webkitExitFullScreen",
5485 | "webkitCancelFullScreen",
5486 | "mozCancelFullScreen",
5487 | "msExitFullscreen"
5488 | ].find((m) => document2 && m in document2 || targetRef.value && m in targetRef.value);
5489 | });
5490 | const fullscreenEnabled = computed(() => {
5491 | return [
5492 | "fullScreen",
5493 | "webkitIsFullScreen",
5494 | "webkitDisplayingFullscreen",
5495 | "mozFullScreen",
5496 | "msFullscreenElement"
5497 | ].find((m) => document2 && m in document2 || targetRef.value && m in targetRef.value);
5498 | });
5499 | const fullscreenElementMethod = [
5500 | "fullscreenElement",
5501 | "webkitFullscreenElement",
5502 | "mozFullScreenElement",
5503 | "msFullscreenElement"
5504 | ].find((m) => document2 && m in document2);
5505 | const isSupported = useSupported(() => targetRef.value && document2 && requestMethod.value !== void 0 && exitMethod.value !== void 0 && fullscreenEnabled.value !== void 0);
5506 | const isCurrentElementFullScreen = () => {
5507 | if (fullscreenElementMethod)
5508 | return (document2 == null ? void 0 : document2[fullscreenElementMethod]) === targetRef.value;
5509 | return false;
5510 | };
5511 | const isElementFullScreen = () => {
5512 | if (fullscreenEnabled.value) {
5513 | if (document2 && document2[fullscreenEnabled.value] != null) {
5514 | return document2[fullscreenEnabled.value];
5515 | } else {
5516 | const target2 = targetRef.value;
5517 | if ((target2 == null ? void 0 : target2[fullscreenEnabled.value]) != null) {
5518 | return Boolean(target2[fullscreenEnabled.value]);
5519 | }
5520 | }
5521 | }
5522 | return false;
5523 | };
5524 | async function exit() {
5525 | if (!isSupported.value || !isFullscreen.value)
5526 | return;
5527 | if (exitMethod.value) {
5528 | if ((document2 == null ? void 0 : document2[exitMethod.value]) != null) {
5529 | await document2[exitMethod.value]();
5530 | } else {
5531 | const target2 = targetRef.value;
5532 | if ((target2 == null ? void 0 : target2[exitMethod.value]) != null)
5533 | await target2[exitMethod.value]();
5534 | }
5535 | }
5536 | isFullscreen.value = false;
5537 | }
5538 | async function enter() {
5539 | if (!isSupported.value || isFullscreen.value)
5540 | return;
5541 | if (isElementFullScreen())
5542 | await exit();
5543 | const target2 = targetRef.value;
5544 | if (requestMethod.value && (target2 == null ? void 0 : target2[requestMethod.value]) != null) {
5545 | await target2[requestMethod.value]();
5546 | isFullscreen.value = true;
5547 | }
5548 | }
5549 | async function toggle() {
5550 | await (isFullscreen.value ? exit() : enter());
5551 | }
5552 | const handlerCallback = () => {
5553 | const isElementFullScreenValue = isElementFullScreen();
5554 | if (!isElementFullScreenValue || isElementFullScreenValue && isCurrentElementFullScreen())
5555 | isFullscreen.value = isElementFullScreenValue;
5556 | };
5557 | const listenerOptions = { capture: false, passive: true };
5558 | useEventListener(document2, eventHandlers, handlerCallback, listenerOptions);
5559 | useEventListener(() => unrefElement(targetRef), eventHandlers, handlerCallback, listenerOptions);
5560 | if (autoExit)
5561 | tryOnScopeDispose(exit);
5562 | return {
5563 | isSupported,
5564 | isFullscreen,
5565 | enter,
5566 | exit,
5567 | toggle
5568 | };
5569 | }
5570 | function mapGamepadToXbox360Controller(gamepad) {
5571 | return computed(() => {
5572 | if (gamepad.value) {
5573 | return {
5574 | buttons: {
5575 | a: gamepad.value.buttons[0],
5576 | b: gamepad.value.buttons[1],
5577 | x: gamepad.value.buttons[2],
5578 | y: gamepad.value.buttons[3]
5579 | },
5580 | bumper: {
5581 | left: gamepad.value.buttons[4],
5582 | right: gamepad.value.buttons[5]
5583 | },
5584 | triggers: {
5585 | left: gamepad.value.buttons[6],
5586 | right: gamepad.value.buttons[7]
5587 | },
5588 | stick: {
5589 | left: {
5590 | horizontal: gamepad.value.axes[0],
5591 | vertical: gamepad.value.axes[1],
5592 | button: gamepad.value.buttons[10]
5593 | },
5594 | right: {
5595 | horizontal: gamepad.value.axes[2],
5596 | vertical: gamepad.value.axes[3],
5597 | button: gamepad.value.buttons[11]
5598 | }
5599 | },
5600 | dpad: {
5601 | up: gamepad.value.buttons[12],
5602 | down: gamepad.value.buttons[13],
5603 | left: gamepad.value.buttons[14],
5604 | right: gamepad.value.buttons[15]
5605 | },
5606 | back: gamepad.value.buttons[8],
5607 | start: gamepad.value.buttons[9]
5608 | };
5609 | }
5610 | return null;
5611 | });
5612 | }
5613 | function useGamepad(options = {}) {
5614 | const {
5615 | navigator: navigator2 = defaultNavigator
5616 | } = options;
5617 | const isSupported = useSupported(() => navigator2 && "getGamepads" in navigator2);
5618 | const gamepads = ref([]);
5619 | const onConnectedHook = createEventHook();
5620 | const onDisconnectedHook = createEventHook();
5621 | const stateFromGamepad = (gamepad) => {
5622 | const hapticActuators = [];
5623 | const vibrationActuator = "vibrationActuator" in gamepad ? gamepad.vibrationActuator : null;
5624 | if (vibrationActuator)
5625 | hapticActuators.push(vibrationActuator);
5626 | if (gamepad.hapticActuators)
5627 | hapticActuators.push(...gamepad.hapticActuators);
5628 | return {
5629 | id: gamepad.id,
5630 | index: gamepad.index,
5631 | connected: gamepad.connected,
5632 | mapping: gamepad.mapping,
5633 | timestamp: gamepad.timestamp,
5634 | vibrationActuator: gamepad.vibrationActuator,
5635 | hapticActuators,
5636 | axes: gamepad.axes.map((axes) => axes),
5637 | buttons: gamepad.buttons.map((button) => ({ pressed: button.pressed, touched: button.touched, value: button.value }))
5638 | };
5639 | };
5640 | const updateGamepadState = () => {
5641 | const _gamepads = (navigator2 == null ? void 0 : navigator2.getGamepads()) || [];
5642 | for (const gamepad of _gamepads) {
5643 | if (gamepad && gamepads.value[gamepad.index])
5644 | gamepads.value[gamepad.index] = stateFromGamepad(gamepad);
5645 | }
5646 | };
5647 | const { isActive, pause, resume } = useRafFn(updateGamepadState);
5648 | const onGamepadConnected = (gamepad) => {
5649 | if (!gamepads.value.some(({ index }) => index === gamepad.index)) {
5650 | gamepads.value.push(stateFromGamepad(gamepad));
5651 | onConnectedHook.trigger(gamepad.index);
5652 | }
5653 | resume();
5654 | };
5655 | const onGamepadDisconnected = (gamepad) => {
5656 | gamepads.value = gamepads.value.filter((x) => x.index !== gamepad.index);
5657 | onDisconnectedHook.trigger(gamepad.index);
5658 | };
5659 | const listenerOptions = { passive: true };
5660 | useEventListener("gamepadconnected", (e) => onGamepadConnected(e.gamepad), listenerOptions);
5661 | useEventListener("gamepaddisconnected", (e) => onGamepadDisconnected(e.gamepad), listenerOptions);
5662 | tryOnMounted(() => {
5663 | const _gamepads = (navigator2 == null ? void 0 : navigator2.getGamepads()) || [];
5664 | for (const gamepad of _gamepads) {
5665 | if (gamepad && gamepads.value[gamepad.index])
5666 | onGamepadConnected(gamepad);
5667 | }
5668 | });
5669 | pause();
5670 | return {
5671 | isSupported,
5672 | onConnected: onConnectedHook.on,
5673 | onDisconnected: onDisconnectedHook.on,
5674 | gamepads,
5675 | pause,
5676 | resume,
5677 | isActive
5678 | };
5679 | }
5680 | function useGeolocation(options = {}) {
5681 | const {
5682 | enableHighAccuracy = true,
5683 | maximumAge = 3e4,
5684 | timeout = 27e3,
5685 | navigator: navigator2 = defaultNavigator,
5686 | immediate = true
5687 | } = options;
5688 | const isSupported = useSupported(() => navigator2 && "geolocation" in navigator2);
5689 | const locatedAt = shallowRef(null);
5690 | const error = shallowRef(null);
5691 | const coords = ref({
5692 | accuracy: 0,
5693 | latitude: Number.POSITIVE_INFINITY,
5694 | longitude: Number.POSITIVE_INFINITY,
5695 | altitude: null,
5696 | altitudeAccuracy: null,
5697 | heading: null,
5698 | speed: null
5699 | });
5700 | function updatePosition(position) {
5701 | locatedAt.value = position.timestamp;
5702 | coords.value = position.coords;
5703 | error.value = null;
5704 | }
5705 | let watcher;
5706 | function resume() {
5707 | if (isSupported.value) {
5708 | watcher = navigator2.geolocation.watchPosition(
5709 | updatePosition,
5710 | (err) => error.value = err,
5711 | {
5712 | enableHighAccuracy,
5713 | maximumAge,
5714 | timeout
5715 | }
5716 | );
5717 | }
5718 | }
5719 | if (immediate)
5720 | resume();
5721 | function pause() {
5722 | if (watcher && navigator2)
5723 | navigator2.geolocation.clearWatch(watcher);
5724 | }
5725 | tryOnScopeDispose(() => {
5726 | pause();
5727 | });
5728 | return {
5729 | isSupported,
5730 | coords,
5731 | locatedAt,
5732 | error,
5733 | resume,
5734 | pause
5735 | };
5736 | }
5737 | var defaultEvents$1 = ["mousemove", "mousedown", "resize", "keydown", "touchstart", "wheel"];
5738 | var oneMinute = 6e4;
5739 | function useIdle(timeout = oneMinute, options = {}) {
5740 | const {
5741 | initialState = false,
5742 | listenForVisibilityChange = true,
5743 | events: events2 = defaultEvents$1,
5744 | window: window2 = defaultWindow,
5745 | eventFilter = throttleFilter(50)
5746 | } = options;
5747 | const idle = shallowRef(initialState);
5748 | const lastActive = shallowRef(timestamp());
5749 | let timer;
5750 | const reset = () => {
5751 | idle.value = false;
5752 | clearTimeout(timer);
5753 | timer = setTimeout(() => idle.value = true, timeout);
5754 | };
5755 | const onEvent = createFilterWrapper(
5756 | eventFilter,
5757 | () => {
5758 | lastActive.value = timestamp();
5759 | reset();
5760 | }
5761 | );
5762 | if (window2) {
5763 | const document2 = window2.document;
5764 | const listenerOptions = { passive: true };
5765 | for (const event of events2)
5766 | useEventListener(window2, event, onEvent, listenerOptions);
5767 | if (listenForVisibilityChange) {
5768 | useEventListener(document2, "visibilitychange", () => {
5769 | if (!document2.hidden)
5770 | onEvent();
5771 | }, listenerOptions);
5772 | }
5773 | reset();
5774 | }
5775 | return {
5776 | idle,
5777 | lastActive,
5778 | reset
5779 | };
5780 | }
5781 | async function loadImage(options) {
5782 | return new Promise((resolve, reject) => {
5783 | const img = new Image();
5784 | const { src, srcset, sizes, class: clazz, loading, crossorigin, referrerPolicy, width, height, decoding, fetchPriority, ismap, usemap } = options;
5785 | img.src = src;
5786 | if (srcset != null)
5787 | img.srcset = srcset;
5788 | if (sizes != null)
5789 | img.sizes = sizes;
5790 | if (clazz != null)
5791 | img.className = clazz;
5792 | if (loading != null)
5793 | img.loading = loading;
5794 | if (crossorigin != null)
5795 | img.crossOrigin = crossorigin;
5796 | if (referrerPolicy != null)
5797 | img.referrerPolicy = referrerPolicy;
5798 | if (width != null)
5799 | img.width = width;
5800 | if (height != null)
5801 | img.height = height;
5802 | if (decoding != null)
5803 | img.decoding = decoding;
5804 | if (fetchPriority != null)
5805 | img.fetchPriority = fetchPriority;
5806 | if (ismap != null)
5807 | img.isMap = ismap;
5808 | if (usemap != null)
5809 | img.useMap = usemap;
5810 | img.onload = () => resolve(img);
5811 | img.onerror = reject;
5812 | });
5813 | }
5814 | function useImage(options, asyncStateOptions = {}) {
5815 | const state = useAsyncState(
5816 | () => loadImage(toValue(options)),
5817 | void 0,
5818 | {
5819 | resetOnExecute: true,
5820 | ...asyncStateOptions
5821 | }
5822 | );
5823 | watch(
5824 | () => toValue(options),
5825 | () => state.execute(asyncStateOptions.delay),
5826 | { deep: true }
5827 | );
5828 | return state;
5829 | }
5830 | function resolveElement(el) {
5831 | if (typeof Window !== "undefined" && el instanceof Window)
5832 | return el.document.documentElement;
5833 | if (typeof Document !== "undefined" && el instanceof Document)
5834 | return el.documentElement;
5835 | return el;
5836 | }
5837 | var ARRIVED_STATE_THRESHOLD_PIXELS = 1;
5838 | function useScroll(element, options = {}) {
5839 | const {
5840 | throttle = 0,
5841 | idle = 200,
5842 | onStop = noop,
5843 | onScroll = noop,
5844 | offset = {
5845 | left: 0,
5846 | right: 0,
5847 | top: 0,
5848 | bottom: 0
5849 | },
5850 | eventListenerOptions = {
5851 | capture: false,
5852 | passive: true
5853 | },
5854 | behavior = "auto",
5855 | window: window2 = defaultWindow,
5856 | onError = (e) => {
5857 | console.error(e);
5858 | }
5859 | } = options;
5860 | const internalX = shallowRef(0);
5861 | const internalY = shallowRef(0);
5862 | const x = computed({
5863 | get() {
5864 | return internalX.value;
5865 | },
5866 | set(x2) {
5867 | scrollTo(x2, void 0);
5868 | }
5869 | });
5870 | const y = computed({
5871 | get() {
5872 | return internalY.value;
5873 | },
5874 | set(y2) {
5875 | scrollTo(void 0, y2);
5876 | }
5877 | });
5878 | function scrollTo(_x, _y) {
5879 | var _a, _b, _c, _d;
5880 | if (!window2)
5881 | return;
5882 | const _element = toValue(element);
5883 | if (!_element)
5884 | return;
5885 | (_c = _element instanceof Document ? window2.document.body : _element) == null ? void 0 : _c.scrollTo({
5886 | top: (_a = toValue(_y)) != null ? _a : y.value,
5887 | left: (_b = toValue(_x)) != null ? _b : x.value,
5888 | behavior: toValue(behavior)
5889 | });
5890 | const scrollContainer = ((_d = _element == null ? void 0 : _element.document) == null ? void 0 : _d.documentElement) || (_element == null ? void 0 : _element.documentElement) || _element;
5891 | if (x != null)
5892 | internalX.value = scrollContainer.scrollLeft;
5893 | if (y != null)
5894 | internalY.value = scrollContainer.scrollTop;
5895 | }
5896 | const isScrolling = shallowRef(false);
5897 | const arrivedState = reactive({
5898 | left: true,
5899 | right: false,
5900 | top: true,
5901 | bottom: false
5902 | });
5903 | const directions = reactive({
5904 | left: false,
5905 | right: false,
5906 | top: false,
5907 | bottom: false
5908 | });
5909 | const onScrollEnd = (e) => {
5910 | if (!isScrolling.value)
5911 | return;
5912 | isScrolling.value = false;
5913 | directions.left = false;
5914 | directions.right = false;
5915 | directions.top = false;
5916 | directions.bottom = false;
5917 | onStop(e);
5918 | };
5919 | const onScrollEndDebounced = useDebounceFn(onScrollEnd, throttle + idle);
5920 | const setArrivedState = (target) => {
5921 | var _a;
5922 | if (!window2)
5923 | return;
5924 | const el = ((_a = target == null ? void 0 : target.document) == null ? void 0 : _a.documentElement) || (target == null ? void 0 : target.documentElement) || unrefElement(target);
5925 | const { display, flexDirection, direction } = getComputedStyle(el);
5926 | const directionMultipler = direction === "rtl" ? -1 : 1;
5927 | const scrollLeft = el.scrollLeft;
5928 | directions.left = scrollLeft < internalX.value;
5929 | directions.right = scrollLeft > internalX.value;
5930 | const left = Math.abs(scrollLeft * directionMultipler) <= (offset.left || 0);
5931 | const right = Math.abs(scrollLeft * directionMultipler) + el.clientWidth >= el.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
5932 | if (display === "flex" && flexDirection === "row-reverse") {
5933 | arrivedState.left = right;
5934 | arrivedState.right = left;
5935 | } else {
5936 | arrivedState.left = left;
5937 | arrivedState.right = right;
5938 | }
5939 | internalX.value = scrollLeft;
5940 | let scrollTop = el.scrollTop;
5941 | if (target === window2.document && !scrollTop)
5942 | scrollTop = window2.document.body.scrollTop;
5943 | directions.top = scrollTop < internalY.value;
5944 | directions.bottom = scrollTop > internalY.value;
5945 | const top = Math.abs(scrollTop) <= (offset.top || 0);
5946 | const bottom = Math.abs(scrollTop) + el.clientHeight >= el.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
5947 | if (display === "flex" && flexDirection === "column-reverse") {
5948 | arrivedState.top = bottom;
5949 | arrivedState.bottom = top;
5950 | } else {
5951 | arrivedState.top = top;
5952 | arrivedState.bottom = bottom;
5953 | }
5954 | internalY.value = scrollTop;
5955 | };
5956 | const onScrollHandler = (e) => {
5957 | var _a;
5958 | if (!window2)
5959 | return;
5960 | const eventTarget = (_a = e.target.documentElement) != null ? _a : e.target;
5961 | setArrivedState(eventTarget);
5962 | isScrolling.value = true;
5963 | onScrollEndDebounced(e);
5964 | onScroll(e);
5965 | };
5966 | useEventListener(
5967 | element,
5968 | "scroll",
5969 | throttle ? useThrottleFn(onScrollHandler, throttle, true, false) : onScrollHandler,
5970 | eventListenerOptions
5971 | );
5972 | tryOnMounted(() => {
5973 | try {
5974 | const _element = toValue(element);
5975 | if (!_element)
5976 | return;
5977 | setArrivedState(_element);
5978 | } catch (e) {
5979 | onError(e);
5980 | }
5981 | });
5982 | useEventListener(
5983 | element,
5984 | "scrollend",
5985 | onScrollEnd,
5986 | eventListenerOptions
5987 | );
5988 | return {
5989 | x,
5990 | y,
5991 | isScrolling,
5992 | arrivedState,
5993 | directions,
5994 | measure() {
5995 | const _element = toValue(element);
5996 | if (window2 && _element)
5997 | setArrivedState(_element);
5998 | }
5999 | };
6000 | }
6001 | function useInfiniteScroll(element, onLoadMore, options = {}) {
6002 | var _a;
6003 | const {
6004 | direction = "bottom",
6005 | interval = 100,
6006 | canLoadMore = () => true
6007 | } = options;
6008 | const state = reactive(useScroll(
6009 | element,
6010 | {
6011 | ...options,
6012 | offset: {
6013 | [direction]: (_a = options.distance) != null ? _a : 0,
6014 | ...options.offset
6015 | }
6016 | }
6017 | ));
6018 | const promise = ref();
6019 | const isLoading = computed(() => !!promise.value);
6020 | const observedElement = computed(() => {
6021 | return resolveElement(toValue(element));
6022 | });
6023 | const isElementVisible = useElementVisibility(observedElement);
6024 | function checkAndLoad() {
6025 | state.measure();
6026 | if (!observedElement.value || !isElementVisible.value || !canLoadMore(observedElement.value))
6027 | return;
6028 | const { scrollHeight, clientHeight, scrollWidth, clientWidth } = observedElement.value;
6029 | const isNarrower = direction === "bottom" || direction === "top" ? scrollHeight <= clientHeight : scrollWidth <= clientWidth;
6030 | if (state.arrivedState[direction] || isNarrower) {
6031 | if (!promise.value) {
6032 | promise.value = Promise.all([
6033 | onLoadMore(state),
6034 | new Promise((resolve) => setTimeout(resolve, interval))
6035 | ]).finally(() => {
6036 | promise.value = null;
6037 | nextTick(() => checkAndLoad());
6038 | });
6039 | }
6040 | }
6041 | }
6042 | const stop = watch(
6043 | () => [state.arrivedState[direction], isElementVisible.value],
6044 | checkAndLoad,
6045 | { immediate: true }
6046 | );
6047 | tryOnUnmounted(stop);
6048 | return {
6049 | isLoading,
6050 | reset() {
6051 | nextTick(() => checkAndLoad());
6052 | }
6053 | };
6054 | }
6055 | var defaultEvents = ["mousedown", "mouseup", "keydown", "keyup"];
6056 | function useKeyModifier(modifier, options = {}) {
6057 | const {
6058 | events: events2 = defaultEvents,
6059 | document: document2 = defaultDocument,
6060 | initial = null
6061 | } = options;
6062 | const state = shallowRef(initial);
6063 | if (document2) {
6064 | events2.forEach((listenerEvent) => {
6065 | useEventListener(document2, listenerEvent, (evt) => {
6066 | if (typeof evt.getModifierState === "function")
6067 | state.value = evt.getModifierState(modifier);
6068 | }, { passive: true });
6069 | });
6070 | }
6071 | return state;
6072 | }
6073 | function useLocalStorage(key, initialValue, options = {}) {
6074 | const { window: window2 = defaultWindow } = options;
6075 | return useStorage(key, initialValue, window2 == null ? void 0 : window2.localStorage, options);
6076 | }
6077 | var DefaultMagicKeysAliasMap = {
6078 | ctrl: "control",
6079 | command: "meta",
6080 | cmd: "meta",
6081 | option: "alt",
6082 | up: "arrowup",
6083 | down: "arrowdown",
6084 | left: "arrowleft",
6085 | right: "arrowright"
6086 | };
6087 | function useMagicKeys(options = {}) {
6088 | const {
6089 | reactive: useReactive = false,
6090 | target = defaultWindow,
6091 | aliasMap = DefaultMagicKeysAliasMap,
6092 | passive = true,
6093 | onEventFired = noop
6094 | } = options;
6095 | const current = reactive(/* @__PURE__ */ new Set());
6096 | const obj = {
6097 | toJSON() {
6098 | return {};
6099 | },
6100 | current
6101 | };
6102 | const refs = useReactive ? reactive(obj) : obj;
6103 | const metaDeps = /* @__PURE__ */ new Set();
6104 | const usedKeys = /* @__PURE__ */ new Set();
6105 | function setRefs(key, value) {
6106 | if (key in refs) {
6107 | if (useReactive)
6108 | refs[key] = value;
6109 | else
6110 | refs[key].value = value;
6111 | }
6112 | }
6113 | function reset() {
6114 | current.clear();
6115 | for (const key of usedKeys)
6116 | setRefs(key, false);
6117 | }
6118 | function updateRefs(e, value) {
6119 | var _a, _b;
6120 | const key = (_a = e.key) == null ? void 0 : _a.toLowerCase();
6121 | const code = (_b = e.code) == null ? void 0 : _b.toLowerCase();
6122 | const values = [code, key].filter(Boolean);
6123 | if (key) {
6124 | if (value)
6125 | current.add(key);
6126 | else
6127 | current.delete(key);
6128 | }
6129 | for (const key2 of values) {
6130 | usedKeys.add(key2);
6131 | setRefs(key2, value);
6132 | }
6133 | if (key === "meta" && !value) {
6134 | metaDeps.forEach((key2) => {
6135 | current.delete(key2);
6136 | setRefs(key2, false);
6137 | });
6138 | metaDeps.clear();
6139 | } else if (typeof e.getModifierState === "function" && e.getModifierState("Meta") && value) {
6140 | [...current, ...values].forEach((key2) => metaDeps.add(key2));
6141 | }
6142 | }
6143 | useEventListener(target, "keydown", (e) => {
6144 | updateRefs(e, true);
6145 | return onEventFired(e);
6146 | }, { passive });
6147 | useEventListener(target, "keyup", (e) => {
6148 | updateRefs(e, false);
6149 | return onEventFired(e);
6150 | }, { passive });
6151 | useEventListener("blur", reset, { passive });
6152 | useEventListener("focus", reset, { passive });
6153 | const proxy = new Proxy(
6154 | refs,
6155 | {
6156 | get(target2, prop, rec) {
6157 | if (typeof prop !== "string")
6158 | return Reflect.get(target2, prop, rec);
6159 | prop = prop.toLowerCase();
6160 | if (prop in aliasMap)
6161 | prop = aliasMap[prop];
6162 | if (!(prop in refs)) {
6163 | if (/[+_-]/.test(prop)) {
6164 | const keys2 = prop.split(/[+_-]/g).map((i) => i.trim());
6165 | refs[prop] = computed(() => keys2.map((key) => toValue(proxy[key])).every(Boolean));
6166 | } else {
6167 | refs[prop] = shallowRef(false);
6168 | }
6169 | }
6170 | const r = Reflect.get(target2, prop, rec);
6171 | return useReactive ? toValue(r) : r;
6172 | }
6173 | }
6174 | );
6175 | return proxy;
6176 | }
6177 | function usingElRef(source, cb) {
6178 | if (toValue(source))
6179 | cb(toValue(source));
6180 | }
6181 | function timeRangeToArray(timeRanges) {
6182 | let ranges = [];
6183 | for (let i = 0; i < timeRanges.length; ++i)
6184 | ranges = [...ranges, [timeRanges.start(i), timeRanges.end(i)]];
6185 | return ranges;
6186 | }
6187 | function tracksToArray(tracks) {
6188 | return Array.from(tracks).map(({ label, kind, language, mode, activeCues, cues, inBandMetadataTrackDispatchType }, id) => ({ id, label, kind, language, mode, activeCues, cues, inBandMetadataTrackDispatchType }));
6189 | }
6190 | var defaultOptions = {
6191 | src: "",
6192 | tracks: []
6193 | };
6194 | function useMediaControls(target, options = {}) {
6195 | target = toRef2(target);
6196 | options = {
6197 | ...defaultOptions,
6198 | ...options
6199 | };
6200 | const {
6201 | document: document2 = defaultDocument
6202 | } = options;
6203 | const listenerOptions = { passive: true };
6204 | const currentTime = shallowRef(0);
6205 | const duration = shallowRef(0);
6206 | const seeking = shallowRef(false);
6207 | const volume = shallowRef(1);
6208 | const waiting = shallowRef(false);
6209 | const ended = shallowRef(false);
6210 | const playing = shallowRef(false);
6211 | const rate = shallowRef(1);
6212 | const stalled = shallowRef(false);
6213 | const buffered = ref([]);
6214 | const tracks = ref([]);
6215 | const selectedTrack = shallowRef(-1);
6216 | const isPictureInPicture = shallowRef(false);
6217 | const muted = shallowRef(false);
6218 | const supportsPictureInPicture = document2 && "pictureInPictureEnabled" in document2;
6219 | const sourceErrorEvent = createEventHook();
6220 | const playbackErrorEvent = createEventHook();
6221 | const disableTrack = (track) => {
6222 | usingElRef(target, (el) => {
6223 | if (track) {
6224 | const id = typeof track === "number" ? track : track.id;
6225 | el.textTracks[id].mode = "disabled";
6226 | } else {
6227 | for (let i = 0; i < el.textTracks.length; ++i)
6228 | el.textTracks[i].mode = "disabled";
6229 | }
6230 | selectedTrack.value = -1;
6231 | });
6232 | };
6233 | const enableTrack = (track, disableTracks = true) => {
6234 | usingElRef(target, (el) => {
6235 | const id = typeof track === "number" ? track : track.id;
6236 | if (disableTracks)
6237 | disableTrack();
6238 | el.textTracks[id].mode = "showing";
6239 | selectedTrack.value = id;
6240 | });
6241 | };
6242 | const togglePictureInPicture = () => {
6243 | return new Promise((resolve, reject) => {
6244 | usingElRef(target, async (el) => {
6245 | if (supportsPictureInPicture) {
6246 | if (!isPictureInPicture.value) {
6247 | el.requestPictureInPicture().then(resolve).catch(reject);
6248 | } else {
6249 | document2.exitPictureInPicture().then(resolve).catch(reject);
6250 | }
6251 | }
6252 | });
6253 | });
6254 | };
6255 | watchEffect(() => {
6256 | if (!document2)
6257 | return;
6258 | const el = toValue(target);
6259 | if (!el)
6260 | return;
6261 | const src = toValue(options.src);
6262 | let sources = [];
6263 | if (!src)
6264 | return;
6265 | if (typeof src === "string")
6266 | sources = [{ src }];
6267 | else if (Array.isArray(src))
6268 | sources = src;
6269 | else if (isObject(src))
6270 | sources = [src];
6271 | el.querySelectorAll("source").forEach((e) => {
6272 | e.remove();
6273 | });
6274 | sources.forEach(({ src: src2, type, media }) => {
6275 | const source = document2.createElement("source");
6276 | source.setAttribute("src", src2);
6277 | source.setAttribute("type", type || "");
6278 | source.setAttribute("media", media || "");
6279 | useEventListener(source, "error", sourceErrorEvent.trigger, listenerOptions);
6280 | el.appendChild(source);
6281 | });
6282 | el.load();
6283 | });
6284 | watch([target, volume], () => {
6285 | const el = toValue(target);
6286 | if (!el)
6287 | return;
6288 | el.volume = volume.value;
6289 | });
6290 | watch([target, muted], () => {
6291 | const el = toValue(target);
6292 | if (!el)
6293 | return;
6294 | el.muted = muted.value;
6295 | });
6296 | watch([target, rate], () => {
6297 | const el = toValue(target);
6298 | if (!el)
6299 | return;
6300 | el.playbackRate = rate.value;
6301 | });
6302 | watchEffect(() => {
6303 | if (!document2)
6304 | return;
6305 | const textTracks = toValue(options.tracks);
6306 | const el = toValue(target);
6307 | if (!textTracks || !textTracks.length || !el)
6308 | return;
6309 | el.querySelectorAll("track").forEach((e) => e.remove());
6310 | textTracks.forEach(({ default: isDefault, kind, label, src, srcLang }, i) => {
6311 | const track = document2.createElement("track");
6312 | track.default = isDefault || false;
6313 | track.kind = kind;
6314 | track.label = label;
6315 | track.src = src;
6316 | track.srclang = srcLang;
6317 | if (track.default)
6318 | selectedTrack.value = i;
6319 | el.appendChild(track);
6320 | });
6321 | });
6322 | const { ignoreUpdates: ignoreCurrentTimeUpdates } = watchIgnorable(currentTime, (time) => {
6323 | const el = toValue(target);
6324 | if (!el)
6325 | return;
6326 | el.currentTime = time;
6327 | });
6328 | const { ignoreUpdates: ignorePlayingUpdates } = watchIgnorable(playing, (isPlaying) => {
6329 | const el = toValue(target);
6330 | if (!el)
6331 | return;
6332 | if (isPlaying) {
6333 | el.play().catch((e) => {
6334 | playbackErrorEvent.trigger(e);
6335 | throw e;
6336 | });
6337 | } else {
6338 | el.pause();
6339 | }
6340 | });
6341 | useEventListener(
6342 | target,
6343 | "timeupdate",
6344 | () => ignoreCurrentTimeUpdates(() => currentTime.value = toValue(target).currentTime),
6345 | listenerOptions
6346 | );
6347 | useEventListener(
6348 | target,
6349 | "durationchange",
6350 | () => duration.value = toValue(target).duration,
6351 | listenerOptions
6352 | );
6353 | useEventListener(
6354 | target,
6355 | "progress",
6356 | () => buffered.value = timeRangeToArray(toValue(target).buffered),
6357 | listenerOptions
6358 | );
6359 | useEventListener(
6360 | target,
6361 | "seeking",
6362 | () => seeking.value = true,
6363 | listenerOptions
6364 | );
6365 | useEventListener(
6366 | target,
6367 | "seeked",
6368 | () => seeking.value = false,
6369 | listenerOptions
6370 | );
6371 | useEventListener(
6372 | target,
6373 | ["waiting", "loadstart"],
6374 | () => {
6375 | waiting.value = true;
6376 | ignorePlayingUpdates(() => playing.value = false);
6377 | },
6378 | listenerOptions
6379 | );
6380 | useEventListener(
6381 | target,
6382 | "loadeddata",
6383 | () => waiting.value = false,
6384 | listenerOptions
6385 | );
6386 | useEventListener(
6387 | target,
6388 | "playing",
6389 | () => {
6390 | waiting.value = false;
6391 | ended.value = false;
6392 | ignorePlayingUpdates(() => playing.value = true);
6393 | },
6394 | listenerOptions
6395 | );
6396 | useEventListener(
6397 | target,
6398 | "ratechange",
6399 | () => rate.value = toValue(target).playbackRate,
6400 | listenerOptions
6401 | );
6402 | useEventListener(
6403 | target,
6404 | "stalled",
6405 | () => stalled.value = true,
6406 | listenerOptions
6407 | );
6408 | useEventListener(
6409 | target,
6410 | "ended",
6411 | () => ended.value = true,
6412 | listenerOptions
6413 | );
6414 | useEventListener(
6415 | target,
6416 | "pause",
6417 | () => ignorePlayingUpdates(() => playing.value = false),
6418 | listenerOptions
6419 | );
6420 | useEventListener(
6421 | target,
6422 | "play",
6423 | () => ignorePlayingUpdates(() => playing.value = true),
6424 | listenerOptions
6425 | );
6426 | useEventListener(
6427 | target,
6428 | "enterpictureinpicture",
6429 | () => isPictureInPicture.value = true,
6430 | listenerOptions
6431 | );
6432 | useEventListener(
6433 | target,
6434 | "leavepictureinpicture",
6435 | () => isPictureInPicture.value = false,
6436 | listenerOptions
6437 | );
6438 | useEventListener(
6439 | target,
6440 | "volumechange",
6441 | () => {
6442 | const el = toValue(target);
6443 | if (!el)
6444 | return;
6445 | volume.value = el.volume;
6446 | muted.value = el.muted;
6447 | },
6448 | listenerOptions
6449 | );
6450 | const listeners = [];
6451 | const stop = watch([target], () => {
6452 | const el = toValue(target);
6453 | if (!el)
6454 | return;
6455 | stop();
6456 | listeners[0] = useEventListener(el.textTracks, "addtrack", () => tracks.value = tracksToArray(el.textTracks), listenerOptions);
6457 | listeners[1] = useEventListener(el.textTracks, "removetrack", () => tracks.value = tracksToArray(el.textTracks), listenerOptions);
6458 | listeners[2] = useEventListener(el.textTracks, "change", () => tracks.value = tracksToArray(el.textTracks), listenerOptions);
6459 | });
6460 | tryOnScopeDispose(() => listeners.forEach((listener) => listener()));
6461 | return {
6462 | currentTime,
6463 | duration,
6464 | waiting,
6465 | seeking,
6466 | ended,
6467 | stalled,
6468 | buffered,
6469 | playing,
6470 | rate,
6471 | // Volume
6472 | volume,
6473 | muted,
6474 | // Tracks
6475 | tracks,
6476 | selectedTrack,
6477 | enableTrack,
6478 | disableTrack,
6479 | // Picture in Picture
6480 | supportsPictureInPicture,
6481 | togglePictureInPicture,
6482 | isPictureInPicture,
6483 | // Events
6484 | onSourceError: sourceErrorEvent.on,
6485 | onPlaybackError: playbackErrorEvent.on
6486 | };
6487 | }
6488 | function useMemoize(resolver, options) {
6489 | const initCache = () => {
6490 | if (options == null ? void 0 : options.cache)
6491 | return shallowReactive(options.cache);
6492 | return shallowReactive(/* @__PURE__ */ new Map());
6493 | };
6494 | const cache = initCache();
6495 | const generateKey = (...args) => (options == null ? void 0 : options.getKey) ? options.getKey(...args) : JSON.stringify(args);
6496 | const _loadData = (key, ...args) => {
6497 | cache.set(key, resolver(...args));
6498 | return cache.get(key);
6499 | };
6500 | const loadData = (...args) => _loadData(generateKey(...args), ...args);
6501 | const deleteData = (...args) => {
6502 | cache.delete(generateKey(...args));
6503 | };
6504 | const clearData = () => {
6505 | cache.clear();
6506 | };
6507 | const memoized = (...args) => {
6508 | const key = generateKey(...args);
6509 | if (cache.has(key))
6510 | return cache.get(key);
6511 | return _loadData(key, ...args);
6512 | };
6513 | memoized.load = loadData;
6514 | memoized.delete = deleteData;
6515 | memoized.clear = clearData;
6516 | memoized.generateKey = generateKey;
6517 | memoized.cache = cache;
6518 | return memoized;
6519 | }
6520 | function useMemory(options = {}) {
6521 | const memory = ref();
6522 | const isSupported = useSupported(() => typeof performance !== "undefined" && "memory" in performance);
6523 | if (isSupported.value) {
6524 | const { interval = 1e3 } = options;
6525 | useIntervalFn(() => {
6526 | memory.value = performance.memory;
6527 | }, interval, { immediate: options.immediate, immediateCallback: options.immediateCallback });
6528 | }
6529 | return { isSupported, memory };
6530 | }
6531 | var UseMouseBuiltinExtractors = {
6532 | page: (event) => [event.pageX, event.pageY],
6533 | client: (event) => [event.clientX, event.clientY],
6534 | screen: (event) => [event.screenX, event.screenY],
6535 | movement: (event) => event instanceof MouseEvent ? [event.movementX, event.movementY] : null
6536 | };
6537 | function useMouse(options = {}) {
6538 | const {
6539 | type = "page",
6540 | touch = true,
6541 | resetOnTouchEnds = false,
6542 | initialValue = { x: 0, y: 0 },
6543 | window: window2 = defaultWindow,
6544 | target = window2,
6545 | scroll = true,
6546 | eventFilter
6547 | } = options;
6548 | let _prevMouseEvent = null;
6549 | let _prevScrollX = 0;
6550 | let _prevScrollY = 0;
6551 | const x = shallowRef(initialValue.x);
6552 | const y = shallowRef(initialValue.y);
6553 | const sourceType = shallowRef(null);
6554 | const extractor = typeof type === "function" ? type : UseMouseBuiltinExtractors[type];
6555 | const mouseHandler = (event) => {
6556 | const result = extractor(event);
6557 | _prevMouseEvent = event;
6558 | if (result) {
6559 | [x.value, y.value] = result;
6560 | sourceType.value = "mouse";
6561 | }
6562 | if (window2) {
6563 | _prevScrollX = window2.scrollX;
6564 | _prevScrollY = window2.scrollY;
6565 | }
6566 | };
6567 | const touchHandler = (event) => {
6568 | if (event.touches.length > 0) {
6569 | const result = extractor(event.touches[0]);
6570 | if (result) {
6571 | [x.value, y.value] = result;
6572 | sourceType.value = "touch";
6573 | }
6574 | }
6575 | };
6576 | const scrollHandler = () => {
6577 | if (!_prevMouseEvent || !window2)
6578 | return;
6579 | const pos = extractor(_prevMouseEvent);
6580 | if (_prevMouseEvent instanceof MouseEvent && pos) {
6581 | x.value = pos[0] + window2.scrollX - _prevScrollX;
6582 | y.value = pos[1] + window2.scrollY - _prevScrollY;
6583 | }
6584 | };
6585 | const reset = () => {
6586 | x.value = initialValue.x;
6587 | y.value = initialValue.y;
6588 | };
6589 | const mouseHandlerWrapper = eventFilter ? (event) => eventFilter(() => mouseHandler(event), {}) : (event) => mouseHandler(event);
6590 | const touchHandlerWrapper = eventFilter ? (event) => eventFilter(() => touchHandler(event), {}) : (event) => touchHandler(event);
6591 | const scrollHandlerWrapper = eventFilter ? () => eventFilter(() => scrollHandler(), {}) : () => scrollHandler();
6592 | if (target) {
6593 | const listenerOptions = { passive: true };
6594 | useEventListener(target, ["mousemove", "dragover"], mouseHandlerWrapper, listenerOptions);
6595 | if (touch && type !== "movement") {
6596 | useEventListener(target, ["touchstart", "touchmove"], touchHandlerWrapper, listenerOptions);
6597 | if (resetOnTouchEnds)
6598 | useEventListener(target, "touchend", reset, listenerOptions);
6599 | }
6600 | if (scroll && type === "page")
6601 | useEventListener(window2, "scroll", scrollHandlerWrapper, listenerOptions);
6602 | }
6603 | return {
6604 | x,
6605 | y,
6606 | sourceType
6607 | };
6608 | }
6609 | function useMouseInElement(target, options = {}) {
6610 | const {
6611 | handleOutside = true,
6612 | window: window2 = defaultWindow
6613 | } = options;
6614 | const type = options.type || "page";
6615 | const { x, y, sourceType } = useMouse(options);
6616 | const targetRef = shallowRef(target != null ? target : window2 == null ? void 0 : window2.document.body);
6617 | const elementX = shallowRef(0);
6618 | const elementY = shallowRef(0);
6619 | const elementPositionX = shallowRef(0);
6620 | const elementPositionY = shallowRef(0);
6621 | const elementHeight = shallowRef(0);
6622 | const elementWidth = shallowRef(0);
6623 | const isOutside = shallowRef(true);
6624 | let stop = () => {
6625 | };
6626 | if (window2) {
6627 | stop = watch(
6628 | [targetRef, x, y],
6629 | () => {
6630 | const el = unrefElement(targetRef);
6631 | if (!el || !(el instanceof Element))
6632 | return;
6633 | const {
6634 | left,
6635 | top,
6636 | width,
6637 | height
6638 | } = el.getBoundingClientRect();
6639 | elementPositionX.value = left + (type === "page" ? window2.pageXOffset : 0);
6640 | elementPositionY.value = top + (type === "page" ? window2.pageYOffset : 0);
6641 | elementHeight.value = height;
6642 | elementWidth.value = width;
6643 | const elX = x.value - elementPositionX.value;
6644 | const elY = y.value - elementPositionY.value;
6645 | isOutside.value = width === 0 || height === 0 || elX < 0 || elY < 0 || elX > width || elY > height;
6646 | if (handleOutside || !isOutside.value) {
6647 | elementX.value = elX;
6648 | elementY.value = elY;
6649 | }
6650 | },
6651 | { immediate: true }
6652 | );
6653 | useEventListener(
6654 | document,
6655 | "mouseleave",
6656 | () => isOutside.value = true,
6657 | { passive: true }
6658 | );
6659 | }
6660 | return {
6661 | x,
6662 | y,
6663 | sourceType,
6664 | elementX,
6665 | elementY,
6666 | elementPositionX,
6667 | elementPositionY,
6668 | elementHeight,
6669 | elementWidth,
6670 | isOutside,
6671 | stop
6672 | };
6673 | }
6674 | function useMousePressed(options = {}) {
6675 | const {
6676 | touch = true,
6677 | drag = true,
6678 | capture = false,
6679 | initialValue = false,
6680 | window: window2 = defaultWindow
6681 | } = options;
6682 | const pressed = shallowRef(initialValue);
6683 | const sourceType = shallowRef(null);
6684 | if (!window2) {
6685 | return {
6686 | pressed,
6687 | sourceType
6688 | };
6689 | }
6690 | const onPressed = (srcType) => (event) => {
6691 | var _a;
6692 | pressed.value = true;
6693 | sourceType.value = srcType;
6694 | (_a = options.onPressed) == null ? void 0 : _a.call(options, event);
6695 | };
6696 | const onReleased = (event) => {
6697 | var _a;
6698 | pressed.value = false;
6699 | sourceType.value = null;
6700 | (_a = options.onReleased) == null ? void 0 : _a.call(options, event);
6701 | };
6702 | const target = computed(() => unrefElement(options.target) || window2);
6703 | const listenerOptions = { passive: true, capture };
6704 | useEventListener(target, "mousedown", onPressed("mouse"), listenerOptions);
6705 | useEventListener(window2, "mouseleave", onReleased, listenerOptions);
6706 | useEventListener(window2, "mouseup", onReleased, listenerOptions);
6707 | if (drag) {
6708 | useEventListener(target, "dragstart", onPressed("mouse"), listenerOptions);
6709 | useEventListener(window2, "drop", onReleased, listenerOptions);
6710 | useEventListener(window2, "dragend", onReleased, listenerOptions);
6711 | }
6712 | if (touch) {
6713 | useEventListener(target, "touchstart", onPressed("touch"), listenerOptions);
6714 | useEventListener(window2, "touchend", onReleased, listenerOptions);
6715 | useEventListener(window2, "touchcancel", onReleased, listenerOptions);
6716 | }
6717 | return {
6718 | pressed,
6719 | sourceType
6720 | };
6721 | }
6722 | function useNavigatorLanguage(options = {}) {
6723 | const { window: window2 = defaultWindow } = options;
6724 | const navigator2 = window2 == null ? void 0 : window2.navigator;
6725 | const isSupported = useSupported(() => navigator2 && "language" in navigator2);
6726 | const language = shallowRef(navigator2 == null ? void 0 : navigator2.language);
6727 | useEventListener(window2, "languagechange", () => {
6728 | if (navigator2)
6729 | language.value = navigator2.language;
6730 | }, { passive: true });
6731 | return {
6732 | isSupported,
6733 | language
6734 | };
6735 | }
6736 | function useNetwork(options = {}) {
6737 | const { window: window2 = defaultWindow } = options;
6738 | const navigator2 = window2 == null ? void 0 : window2.navigator;
6739 | const isSupported = useSupported(() => navigator2 && "connection" in navigator2);
6740 | const isOnline = shallowRef(true);
6741 | const saveData = shallowRef(false);
6742 | const offlineAt = shallowRef(void 0);
6743 | const onlineAt = shallowRef(void 0);
6744 | const downlink = shallowRef(void 0);
6745 | const downlinkMax = shallowRef(void 0);
6746 | const rtt = shallowRef(void 0);
6747 | const effectiveType = shallowRef(void 0);
6748 | const type = shallowRef("unknown");
6749 | const connection = isSupported.value && navigator2.connection;
6750 | function updateNetworkInformation() {
6751 | if (!navigator2)
6752 | return;
6753 | isOnline.value = navigator2.onLine;
6754 | offlineAt.value = isOnline.value ? void 0 : Date.now();
6755 | onlineAt.value = isOnline.value ? Date.now() : void 0;
6756 | if (connection) {
6757 | downlink.value = connection.downlink;
6758 | downlinkMax.value = connection.downlinkMax;
6759 | effectiveType.value = connection.effectiveType;
6760 | rtt.value = connection.rtt;
6761 | saveData.value = connection.saveData;
6762 | type.value = connection.type;
6763 | }
6764 | }
6765 | const listenerOptions = { passive: true };
6766 | if (window2) {
6767 | useEventListener(window2, "offline", () => {
6768 | isOnline.value = false;
6769 | offlineAt.value = Date.now();
6770 | }, listenerOptions);
6771 | useEventListener(window2, "online", () => {
6772 | isOnline.value = true;
6773 | onlineAt.value = Date.now();
6774 | }, listenerOptions);
6775 | }
6776 | if (connection)
6777 | useEventListener(connection, "change", updateNetworkInformation, listenerOptions);
6778 | updateNetworkInformation();
6779 | return {
6780 | isSupported,
6781 | isOnline: readonly(isOnline),
6782 | saveData: readonly(saveData),
6783 | offlineAt: readonly(offlineAt),
6784 | onlineAt: readonly(onlineAt),
6785 | downlink: readonly(downlink),
6786 | downlinkMax: readonly(downlinkMax),
6787 | effectiveType: readonly(effectiveType),
6788 | rtt: readonly(rtt),
6789 | type: readonly(type)
6790 | };
6791 | }
6792 | function useNow(options = {}) {
6793 | const {
6794 | controls: exposeControls = false,
6795 | interval = "requestAnimationFrame"
6796 | } = options;
6797 | const now2 = ref(/* @__PURE__ */ new Date());
6798 | const update = () => now2.value = /* @__PURE__ */ new Date();
6799 | const controls = interval === "requestAnimationFrame" ? useRafFn(update, { immediate: true }) : useIntervalFn(update, interval, { immediate: true });
6800 | if (exposeControls) {
6801 | return {
6802 | now: now2,
6803 | ...controls
6804 | };
6805 | } else {
6806 | return now2;
6807 | }
6808 | }
6809 | function useObjectUrl(object) {
6810 | const url = shallowRef();
6811 | const release = () => {
6812 | if (url.value)
6813 | URL.revokeObjectURL(url.value);
6814 | url.value = void 0;
6815 | };
6816 | watch(
6817 | () => toValue(object),
6818 | (newObject) => {
6819 | release();
6820 | if (newObject)
6821 | url.value = URL.createObjectURL(newObject);
6822 | },
6823 | { immediate: true }
6824 | );
6825 | tryOnScopeDispose(release);
6826 | return readonly(url);
6827 | }
6828 | function useClamp(value, min, max) {
6829 | if (typeof value === "function" || isReadonly(value))
6830 | return computed(() => clamp(toValue(value), toValue(min), toValue(max)));
6831 | const _value = ref(value);
6832 | return computed({
6833 | get() {
6834 | return _value.value = clamp(_value.value, toValue(min), toValue(max));
6835 | },
6836 | set(value2) {
6837 | _value.value = clamp(value2, toValue(min), toValue(max));
6838 | }
6839 | });
6840 | }
6841 | function useOffsetPagination(options) {
6842 | const {
6843 | total = Number.POSITIVE_INFINITY,
6844 | pageSize = 10,
6845 | page = 1,
6846 | onPageChange = noop,
6847 | onPageSizeChange = noop,
6848 | onPageCountChange = noop
6849 | } = options;
6850 | const currentPageSize = useClamp(pageSize, 1, Number.POSITIVE_INFINITY);
6851 | const pageCount = computed(() => Math.max(
6852 | 1,
6853 | Math.ceil(toValue(total) / toValue(currentPageSize))
6854 | ));
6855 | const currentPage = useClamp(page, 1, pageCount);
6856 | const isFirstPage = computed(() => currentPage.value === 1);
6857 | const isLastPage = computed(() => currentPage.value === pageCount.value);
6858 | if (isRef(page)) {
6859 | syncRef(page, currentPage, {
6860 | direction: isReadonly(page) ? "ltr" : "both"
6861 | });
6862 | }
6863 | if (isRef(pageSize)) {
6864 | syncRef(pageSize, currentPageSize, {
6865 | direction: isReadonly(pageSize) ? "ltr" : "both"
6866 | });
6867 | }
6868 | function prev() {
6869 | currentPage.value--;
6870 | }
6871 | function next() {
6872 | currentPage.value++;
6873 | }
6874 | const returnValue = {
6875 | currentPage,
6876 | currentPageSize,
6877 | pageCount,
6878 | isFirstPage,
6879 | isLastPage,
6880 | prev,
6881 | next
6882 | };
6883 | watch(currentPage, () => {
6884 | onPageChange(reactive(returnValue));
6885 | });
6886 | watch(currentPageSize, () => {
6887 | onPageSizeChange(reactive(returnValue));
6888 | });
6889 | watch(pageCount, () => {
6890 | onPageCountChange(reactive(returnValue));
6891 | });
6892 | return returnValue;
6893 | }
6894 | function useOnline(options = {}) {
6895 | const { isOnline } = useNetwork(options);
6896 | return isOnline;
6897 | }
6898 | function usePageLeave(options = {}) {
6899 | const { window: window2 = defaultWindow } = options;
6900 | const isLeft = shallowRef(false);
6901 | const handler = (event) => {
6902 | if (!window2)
6903 | return;
6904 | event = event || window2.event;
6905 | const from = event.relatedTarget || event.toElement;
6906 | isLeft.value = !from;
6907 | };
6908 | if (window2) {
6909 | const listenerOptions = { passive: true };
6910 | useEventListener(window2, "mouseout", handler, listenerOptions);
6911 | useEventListener(window2.document, "mouseleave", handler, listenerOptions);
6912 | useEventListener(window2.document, "mouseenter", handler, listenerOptions);
6913 | }
6914 | return isLeft;
6915 | }
6916 | function useScreenOrientation(options = {}) {
6917 | const {
6918 | window: window2 = defaultWindow
6919 | } = options;
6920 | const isSupported = useSupported(() => window2 && "screen" in window2 && "orientation" in window2.screen);
6921 | const screenOrientation = isSupported.value ? window2.screen.orientation : {};
6922 | const orientation = ref(screenOrientation.type);
6923 | const angle = shallowRef(screenOrientation.angle || 0);
6924 | if (isSupported.value) {
6925 | useEventListener(window2, "orientationchange", () => {
6926 | orientation.value = screenOrientation.type;
6927 | angle.value = screenOrientation.angle;
6928 | }, { passive: true });
6929 | }
6930 | const lockOrientation = (type) => {
6931 | if (isSupported.value && typeof screenOrientation.lock === "function")
6932 | return screenOrientation.lock(type);
6933 | return Promise.reject(new Error("Not supported"));
6934 | };
6935 | const unlockOrientation = () => {
6936 | if (isSupported.value && typeof screenOrientation.unlock === "function")
6937 | screenOrientation.unlock();
6938 | };
6939 | return {
6940 | isSupported,
6941 | orientation,
6942 | angle,
6943 | lockOrientation,
6944 | unlockOrientation
6945 | };
6946 | }
6947 | function useParallax(target, options = {}) {
6948 | const {
6949 | deviceOrientationTiltAdjust = (i) => i,
6950 | deviceOrientationRollAdjust = (i) => i,
6951 | mouseTiltAdjust = (i) => i,
6952 | mouseRollAdjust = (i) => i,
6953 | window: window2 = defaultWindow
6954 | } = options;
6955 | const orientation = reactive(useDeviceOrientation({ window: window2 }));
6956 | const screenOrientation = reactive(useScreenOrientation({ window: window2 }));
6957 | const {
6958 | elementX: x,
6959 | elementY: y,
6960 | elementWidth: width,
6961 | elementHeight: height
6962 | } = useMouseInElement(target, { handleOutside: false, window: window2 });
6963 | const source = computed(() => {
6964 | if (orientation.isSupported && (orientation.alpha != null && orientation.alpha !== 0 || orientation.gamma != null && orientation.gamma !== 0)) {
6965 | return "deviceOrientation";
6966 | }
6967 | return "mouse";
6968 | });
6969 | const roll = computed(() => {
6970 | if (source.value === "deviceOrientation") {
6971 | let value;
6972 | switch (screenOrientation.orientation) {
6973 | case "landscape-primary":
6974 | value = orientation.gamma / 90;
6975 | break;
6976 | case "landscape-secondary":
6977 | value = -orientation.gamma / 90;
6978 | break;
6979 | case "portrait-primary":
6980 | value = -orientation.beta / 90;
6981 | break;
6982 | case "portrait-secondary":
6983 | value = orientation.beta / 90;
6984 | break;
6985 | default:
6986 | value = -orientation.beta / 90;
6987 | }
6988 | return deviceOrientationRollAdjust(value);
6989 | } else {
6990 | const value = -(y.value - height.value / 2) / height.value;
6991 | return mouseRollAdjust(value);
6992 | }
6993 | });
6994 | const tilt = computed(() => {
6995 | if (source.value === "deviceOrientation") {
6996 | let value;
6997 | switch (screenOrientation.orientation) {
6998 | case "landscape-primary":
6999 | value = orientation.beta / 90;
7000 | break;
7001 | case "landscape-secondary":
7002 | value = -orientation.beta / 90;
7003 | break;
7004 | case "portrait-primary":
7005 | value = orientation.gamma / 90;
7006 | break;
7007 | case "portrait-secondary":
7008 | value = -orientation.gamma / 90;
7009 | break;
7010 | default:
7011 | value = orientation.gamma / 90;
7012 | }
7013 | return deviceOrientationTiltAdjust(value);
7014 | } else {
7015 | const value = (x.value - width.value / 2) / width.value;
7016 | return mouseTiltAdjust(value);
7017 | }
7018 | });
7019 | return { roll, tilt, source };
7020 | }
7021 | function useParentElement(element = useCurrentElement()) {
7022 | const parentElement = shallowRef();
7023 | const update = () => {
7024 | const el = unrefElement(element);
7025 | if (el)
7026 | parentElement.value = el.parentElement;
7027 | };
7028 | tryOnMounted(update);
7029 | watch(() => toValue(element), update);
7030 | return parentElement;
7031 | }
7032 | function usePerformanceObserver(options, callback) {
7033 | const {
7034 | window: window2 = defaultWindow,
7035 | immediate = true,
7036 | ...performanceOptions
7037 | } = options;
7038 | const isSupported = useSupported(() => window2 && "PerformanceObserver" in window2);
7039 | let observer;
7040 | const stop = () => {
7041 | observer == null ? void 0 : observer.disconnect();
7042 | };
7043 | const start = () => {
7044 | if (isSupported.value) {
7045 | stop();
7046 | observer = new PerformanceObserver(callback);
7047 | observer.observe(performanceOptions);
7048 | }
7049 | };
7050 | tryOnScopeDispose(stop);
7051 | if (immediate)
7052 | start();
7053 | return {
7054 | isSupported,
7055 | start,
7056 | stop
7057 | };
7058 | }
7059 | var defaultState = {
7060 | x: 0,
7061 | y: 0,
7062 | pointerId: 0,
7063 | pressure: 0,
7064 | tiltX: 0,
7065 | tiltY: 0,
7066 | width: 0,
7067 | height: 0,
7068 | twist: 0,
7069 | pointerType: null
7070 | };
7071 | var keys = Object.keys(defaultState);
7072 | function usePointer(options = {}) {
7073 | const {
7074 | target = defaultWindow
7075 | } = options;
7076 | const isInside = shallowRef(false);
7077 | const state = ref(options.initialValue || {});
7078 | Object.assign(state.value, defaultState, state.value);
7079 | const handler = (event) => {
7080 | isInside.value = true;
7081 | if (options.pointerTypes && !options.pointerTypes.includes(event.pointerType))
7082 | return;
7083 | state.value = objectPick(event, keys, false);
7084 | };
7085 | if (target) {
7086 | const listenerOptions = { passive: true };
7087 | useEventListener(target, ["pointerdown", "pointermove", "pointerup"], handler, listenerOptions);
7088 | useEventListener(target, "pointerleave", () => isInside.value = false, listenerOptions);
7089 | }
7090 | return {
7091 | ...toRefs2(state),
7092 | isInside
7093 | };
7094 | }
7095 | function usePointerLock(target, options = {}) {
7096 | const { document: document2 = defaultDocument } = options;
7097 | const isSupported = useSupported(() => document2 && "pointerLockElement" in document2);
7098 | const element = shallowRef();
7099 | const triggerElement = shallowRef();
7100 | let targetElement;
7101 | if (isSupported.value) {
7102 | const listenerOptions = { passive: true };
7103 | useEventListener(document2, "pointerlockchange", () => {
7104 | var _a;
7105 | const currentElement = (_a = document2.pointerLockElement) != null ? _a : element.value;
7106 | if (targetElement && currentElement === targetElement) {
7107 | element.value = document2.pointerLockElement;
7108 | if (!element.value)
7109 | targetElement = triggerElement.value = null;
7110 | }
7111 | }, listenerOptions);
7112 | useEventListener(document2, "pointerlockerror", () => {
7113 | var _a;
7114 | const currentElement = (_a = document2.pointerLockElement) != null ? _a : element.value;
7115 | if (targetElement && currentElement === targetElement) {
7116 | const action = document2.pointerLockElement ? "release" : "acquire";
7117 | throw new Error(`Failed to ${action} pointer lock.`);
7118 | }
7119 | }, listenerOptions);
7120 | }
7121 | async function lock(e) {
7122 | var _a;
7123 | if (!isSupported.value)
7124 | throw new Error("Pointer Lock API is not supported by your browser.");
7125 | triggerElement.value = e instanceof Event ? e.currentTarget : null;
7126 | targetElement = e instanceof Event ? (_a = unrefElement(target)) != null ? _a : triggerElement.value : unrefElement(e);
7127 | if (!targetElement)
7128 | throw new Error("Target element undefined.");
7129 | targetElement.requestPointerLock();
7130 | return await until(element).toBe(targetElement);
7131 | }
7132 | async function unlock() {
7133 | if (!element.value)
7134 | return false;
7135 | document2.exitPointerLock();
7136 | await until(element).toBeNull();
7137 | return true;
7138 | }
7139 | return {
7140 | isSupported,
7141 | element,
7142 | triggerElement,
7143 | lock,
7144 | unlock
7145 | };
7146 | }
7147 | function usePointerSwipe(target, options = {}) {
7148 | const targetRef = toRef2(target);
7149 | const {
7150 | threshold = 50,
7151 | onSwipe,
7152 | onSwipeEnd,
7153 | onSwipeStart,
7154 | disableTextSelect = false
7155 | } = options;
7156 | const posStart = reactive({ x: 0, y: 0 });
7157 | const updatePosStart = (x, y) => {
7158 | posStart.x = x;
7159 | posStart.y = y;
7160 | };
7161 | const posEnd = reactive({ x: 0, y: 0 });
7162 | const updatePosEnd = (x, y) => {
7163 | posEnd.x = x;
7164 | posEnd.y = y;
7165 | };
7166 | const distanceX = computed(() => posStart.x - posEnd.x);
7167 | const distanceY = computed(() => posStart.y - posEnd.y);
7168 | const { max, abs } = Math;
7169 | const isThresholdExceeded = computed(() => max(abs(distanceX.value), abs(distanceY.value)) >= threshold);
7170 | const isSwiping = shallowRef(false);
7171 | const isPointerDown = shallowRef(false);
7172 | const direction = computed(() => {
7173 | if (!isThresholdExceeded.value)
7174 | return "none";
7175 | if (abs(distanceX.value) > abs(distanceY.value)) {
7176 | return distanceX.value > 0 ? "left" : "right";
7177 | } else {
7178 | return distanceY.value > 0 ? "up" : "down";
7179 | }
7180 | });
7181 | const eventIsAllowed = (e) => {
7182 | var _a, _b, _c;
7183 | const isReleasingButton = e.buttons === 0;
7184 | const isPrimaryButton = e.buttons === 1;
7185 | return (_c = (_b = (_a = options.pointerTypes) == null ? void 0 : _a.includes(e.pointerType)) != null ? _b : isReleasingButton || isPrimaryButton) != null ? _c : true;
7186 | };
7187 | const listenerOptions = { passive: true };
7188 | const stops = [
7189 | useEventListener(target, "pointerdown", (e) => {
7190 | if (!eventIsAllowed(e))
7191 | return;
7192 | isPointerDown.value = true;
7193 | const eventTarget = e.target;
7194 | eventTarget == null ? void 0 : eventTarget.setPointerCapture(e.pointerId);
7195 | const { clientX: x, clientY: y } = e;
7196 | updatePosStart(x, y);
7197 | updatePosEnd(x, y);
7198 | onSwipeStart == null ? void 0 : onSwipeStart(e);
7199 | }, listenerOptions),
7200 | useEventListener(target, "pointermove", (e) => {
7201 | if (!eventIsAllowed(e))
7202 | return;
7203 | if (!isPointerDown.value)
7204 | return;
7205 | const { clientX: x, clientY: y } = e;
7206 | updatePosEnd(x, y);
7207 | if (!isSwiping.value && isThresholdExceeded.value)
7208 | isSwiping.value = true;
7209 | if (isSwiping.value)
7210 | onSwipe == null ? void 0 : onSwipe(e);
7211 | }, listenerOptions),
7212 | useEventListener(target, "pointerup", (e) => {
7213 | if (!eventIsAllowed(e))
7214 | return;
7215 | if (isSwiping.value)
7216 | onSwipeEnd == null ? void 0 : onSwipeEnd(e, direction.value);
7217 | isPointerDown.value = false;
7218 | isSwiping.value = false;
7219 | }, listenerOptions)
7220 | ];
7221 | tryOnMounted(() => {
7222 | var _a, _b, _c, _d, _e, _f, _g, _h;
7223 | (_b = (_a = targetRef.value) == null ? void 0 : _a.style) == null ? void 0 : _b.setProperty("touch-action", "none");
7224 | if (disableTextSelect) {
7225 | (_d = (_c = targetRef.value) == null ? void 0 : _c.style) == null ? void 0 : _d.setProperty("-webkit-user-select", "none");
7226 | (_f = (_e = targetRef.value) == null ? void 0 : _e.style) == null ? void 0 : _f.setProperty("-ms-user-select", "none");
7227 | (_h = (_g = targetRef.value) == null ? void 0 : _g.style) == null ? void 0 : _h.setProperty("user-select", "none");
7228 | }
7229 | });
7230 | const stop = () => stops.forEach((s) => s());
7231 | return {
7232 | isSwiping: readonly(isSwiping),
7233 | direction: readonly(direction),
7234 | posStart: readonly(posStart),
7235 | posEnd: readonly(posEnd),
7236 | distanceX,
7237 | distanceY,
7238 | stop
7239 | };
7240 | }
7241 | function usePreferredColorScheme(options) {
7242 | const isLight = useMediaQuery("(prefers-color-scheme: light)", options);
7243 | const isDark = useMediaQuery("(prefers-color-scheme: dark)", options);
7244 | return computed(() => {
7245 | if (isDark.value)
7246 | return "dark";
7247 | if (isLight.value)
7248 | return "light";
7249 | return "no-preference";
7250 | });
7251 | }
7252 | function usePreferredContrast(options) {
7253 | const isMore = useMediaQuery("(prefers-contrast: more)", options);
7254 | const isLess = useMediaQuery("(prefers-contrast: less)", options);
7255 | const isCustom = useMediaQuery("(prefers-contrast: custom)", options);
7256 | return computed(() => {
7257 | if (isMore.value)
7258 | return "more";
7259 | if (isLess.value)
7260 | return "less";
7261 | if (isCustom.value)
7262 | return "custom";
7263 | return "no-preference";
7264 | });
7265 | }
7266 | function usePreferredLanguages(options = {}) {
7267 | const { window: window2 = defaultWindow } = options;
7268 | if (!window2)
7269 | return ref(["en"]);
7270 | const navigator2 = window2.navigator;
7271 | const value = ref(navigator2.languages);
7272 | useEventListener(window2, "languagechange", () => {
7273 | value.value = navigator2.languages;
7274 | }, { passive: true });
7275 | return value;
7276 | }
7277 | function usePreferredReducedMotion(options) {
7278 | const isReduced = useMediaQuery("(prefers-reduced-motion: reduce)", options);
7279 | return computed(() => {
7280 | if (isReduced.value)
7281 | return "reduce";
7282 | return "no-preference";
7283 | });
7284 | }
7285 | function usePreferredReducedTransparency(options) {
7286 | const isReduced = useMediaQuery("(prefers-reduced-transparency: reduce)", options);
7287 | return computed(() => {
7288 | if (isReduced.value)
7289 | return "reduce";
7290 | return "no-preference";
7291 | });
7292 | }
7293 | function usePrevious(value, initialValue) {
7294 | const previous = shallowRef(initialValue);
7295 | watch(
7296 | toRef2(value),
7297 | (_, oldValue) => {
7298 | previous.value = oldValue;
7299 | },
7300 | { flush: "sync" }
7301 | );
7302 | return readonly(previous);
7303 | }
7304 | var topVarName = "--vueuse-safe-area-top";
7305 | var rightVarName = "--vueuse-safe-area-right";
7306 | var bottomVarName = "--vueuse-safe-area-bottom";
7307 | var leftVarName = "--vueuse-safe-area-left";
7308 | function useScreenSafeArea() {
7309 | const top = shallowRef("");
7310 | const right = shallowRef("");
7311 | const bottom = shallowRef("");
7312 | const left = shallowRef("");
7313 | if (isClient) {
7314 | const topCssVar = useCssVar(topVarName);
7315 | const rightCssVar = useCssVar(rightVarName);
7316 | const bottomCssVar = useCssVar(bottomVarName);
7317 | const leftCssVar = useCssVar(leftVarName);
7318 | topCssVar.value = "env(safe-area-inset-top, 0px)";
7319 | rightCssVar.value = "env(safe-area-inset-right, 0px)";
7320 | bottomCssVar.value = "env(safe-area-inset-bottom, 0px)";
7321 | leftCssVar.value = "env(safe-area-inset-left, 0px)";
7322 | update();
7323 | useEventListener("resize", useDebounceFn(update), { passive: true });
7324 | }
7325 | function update() {
7326 | top.value = getValue(topVarName);
7327 | right.value = getValue(rightVarName);
7328 | bottom.value = getValue(bottomVarName);
7329 | left.value = getValue(leftVarName);
7330 | }
7331 | return {
7332 | top,
7333 | right,
7334 | bottom,
7335 | left,
7336 | update
7337 | };
7338 | }
7339 | function getValue(position) {
7340 | return getComputedStyle(document.documentElement).getPropertyValue(position);
7341 | }
7342 | function useScriptTag(src, onLoaded = noop, options = {}) {
7343 | const {
7344 | immediate = true,
7345 | manual = false,
7346 | type = "text/javascript",
7347 | async = true,
7348 | crossOrigin,
7349 | referrerPolicy,
7350 | noModule,
7351 | defer,
7352 | document: document2 = defaultDocument,
7353 | attrs = {}
7354 | } = options;
7355 | const scriptTag = shallowRef(null);
7356 | let _promise = null;
7357 | const loadScript = (waitForScriptLoad) => new Promise((resolve, reject) => {
7358 | const resolveWithElement = (el2) => {
7359 | scriptTag.value = el2;
7360 | resolve(el2);
7361 | return el2;
7362 | };
7363 | if (!document2) {
7364 | resolve(false);
7365 | return;
7366 | }
7367 | let shouldAppend = false;
7368 | let el = document2.querySelector(`script[src="${toValue(src)}"]`);
7369 | if (!el) {
7370 | el = document2.createElement("script");
7371 | el.type = type;
7372 | el.async = async;
7373 | el.src = toValue(src);
7374 | if (defer)
7375 | el.defer = defer;
7376 | if (crossOrigin)
7377 | el.crossOrigin = crossOrigin;
7378 | if (noModule)
7379 | el.noModule = noModule;
7380 | if (referrerPolicy)
7381 | el.referrerPolicy = referrerPolicy;
7382 | Object.entries(attrs).forEach(([name, value]) => el == null ? void 0 : el.setAttribute(name, value));
7383 | shouldAppend = true;
7384 | } else if (el.hasAttribute("data-loaded")) {
7385 | resolveWithElement(el);
7386 | }
7387 | const listenerOptions = {
7388 | passive: true
7389 | };
7390 | useEventListener(el, "error", (event) => reject(event), listenerOptions);
7391 | useEventListener(el, "abort", (event) => reject(event), listenerOptions);
7392 | useEventListener(el, "load", () => {
7393 | el.setAttribute("data-loaded", "true");
7394 | onLoaded(el);
7395 | resolveWithElement(el);
7396 | }, listenerOptions);
7397 | if (shouldAppend)
7398 | el = document2.head.appendChild(el);
7399 | if (!waitForScriptLoad)
7400 | resolveWithElement(el);
7401 | });
7402 | const load = (waitForScriptLoad = true) => {
7403 | if (!_promise)
7404 | _promise = loadScript(waitForScriptLoad);
7405 | return _promise;
7406 | };
7407 | const unload = () => {
7408 | if (!document2)
7409 | return;
7410 | _promise = null;
7411 | if (scriptTag.value)
7412 | scriptTag.value = null;
7413 | const el = document2.querySelector(`script[src="${toValue(src)}"]`);
7414 | if (el)
7415 | document2.head.removeChild(el);
7416 | };
7417 | if (immediate && !manual)
7418 | tryOnMounted(load);
7419 | if (!manual)
7420 | tryOnUnmounted(unload);
7421 | return { scriptTag, load, unload };
7422 | }
7423 | function checkOverflowScroll(ele) {
7424 | const style = window.getComputedStyle(ele);
7425 | if (style.overflowX === "scroll" || style.overflowY === "scroll" || style.overflowX === "auto" && ele.clientWidth < ele.scrollWidth || style.overflowY === "auto" && ele.clientHeight < ele.scrollHeight) {
7426 | return true;
7427 | } else {
7428 | const parent = ele.parentNode;
7429 | if (!parent || parent.tagName === "BODY")
7430 | return false;
7431 | return checkOverflowScroll(parent);
7432 | }
7433 | }
7434 | function preventDefault(rawEvent) {
7435 | const e = rawEvent || window.event;
7436 | const _target = e.target;
7437 | if (checkOverflowScroll(_target))
7438 | return false;
7439 | if (e.touches.length > 1)
7440 | return true;
7441 | if (e.preventDefault)
7442 | e.preventDefault();
7443 | return false;
7444 | }
7445 | var elInitialOverflow = /* @__PURE__ */ new WeakMap();
7446 | function useScrollLock(element, initialState = false) {
7447 | const isLocked = shallowRef(initialState);
7448 | let stopTouchMoveListener = null;
7449 | let initialOverflow = "";
7450 | watch(toRef2(element), (el) => {
7451 | const target = resolveElement(toValue(el));
7452 | if (target) {
7453 | const ele = target;
7454 | if (!elInitialOverflow.get(ele))
7455 | elInitialOverflow.set(ele, ele.style.overflow);
7456 | if (ele.style.overflow !== "hidden")
7457 | initialOverflow = ele.style.overflow;
7458 | if (ele.style.overflow === "hidden")
7459 | return isLocked.value = true;
7460 | if (isLocked.value)
7461 | return ele.style.overflow = "hidden";
7462 | }
7463 | }, {
7464 | immediate: true
7465 | });
7466 | const lock = () => {
7467 | const el = resolveElement(toValue(element));
7468 | if (!el || isLocked.value)
7469 | return;
7470 | if (isIOS) {
7471 | stopTouchMoveListener = useEventListener(
7472 | el,
7473 | "touchmove",
7474 | (e) => {
7475 | preventDefault(e);
7476 | },
7477 | { passive: false }
7478 | );
7479 | }
7480 | el.style.overflow = "hidden";
7481 | isLocked.value = true;
7482 | };
7483 | const unlock = () => {
7484 | const el = resolveElement(toValue(element));
7485 | if (!el || !isLocked.value)
7486 | return;
7487 | if (isIOS)
7488 | stopTouchMoveListener == null ? void 0 : stopTouchMoveListener();
7489 | el.style.overflow = initialOverflow;
7490 | elInitialOverflow.delete(el);
7491 | isLocked.value = false;
7492 | };
7493 | tryOnScopeDispose(unlock);
7494 | return computed({
7495 | get() {
7496 | return isLocked.value;
7497 | },
7498 | set(v) {
7499 | if (v)
7500 | lock();
7501 | else unlock();
7502 | }
7503 | });
7504 | }
7505 | function useSessionStorage(key, initialValue, options = {}) {
7506 | const { window: window2 = defaultWindow } = options;
7507 | return useStorage(key, initialValue, window2 == null ? void 0 : window2.sessionStorage, options);
7508 | }
7509 | function useShare(shareOptions = {}, options = {}) {
7510 | const { navigator: navigator2 = defaultNavigator } = options;
7511 | const _navigator = navigator2;
7512 | const isSupported = useSupported(() => _navigator && "canShare" in _navigator);
7513 | const share = async (overrideOptions = {}) => {
7514 | if (isSupported.value) {
7515 | const data = {
7516 | ...toValue(shareOptions),
7517 | ...toValue(overrideOptions)
7518 | };
7519 | let granted = true;
7520 | if (data.files && _navigator.canShare)
7521 | granted = _navigator.canShare({ files: data.files });
7522 | if (granted)
7523 | return _navigator.share(data);
7524 | }
7525 | };
7526 | return {
7527 | isSupported,
7528 | share
7529 | };
7530 | }
7531 | var defaultSortFn = (source, compareFn) => source.sort(compareFn);
7532 | var defaultCompare = (a, b) => a - b;
7533 | function useSorted(...args) {
7534 | var _a, _b, _c, _d;
7535 | const [source] = args;
7536 | let compareFn = defaultCompare;
7537 | let options = {};
7538 | if (args.length === 2) {
7539 | if (typeof args[1] === "object") {
7540 | options = args[1];
7541 | compareFn = (_a = options.compareFn) != null ? _a : defaultCompare;
7542 | } else {
7543 | compareFn = (_b = args[1]) != null ? _b : defaultCompare;
7544 | }
7545 | } else if (args.length > 2) {
7546 | compareFn = (_c = args[1]) != null ? _c : defaultCompare;
7547 | options = (_d = args[2]) != null ? _d : {};
7548 | }
7549 | const {
7550 | dirty = false,
7551 | sortFn = defaultSortFn
7552 | } = options;
7553 | if (!dirty)
7554 | return computed(() => sortFn([...toValue(source)], compareFn));
7555 | watchEffect(() => {
7556 | const result = sortFn(toValue(source), compareFn);
7557 | if (isRef(source))
7558 | source.value = result;
7559 | else
7560 | source.splice(0, source.length, ...result);
7561 | });
7562 | return source;
7563 | }
7564 | function useSpeechRecognition(options = {}) {
7565 | const {
7566 | interimResults = true,
7567 | continuous = true,
7568 | maxAlternatives = 1,
7569 | window: window2 = defaultWindow
7570 | } = options;
7571 | const lang = toRef2(options.lang || "en-US");
7572 | const isListening = shallowRef(false);
7573 | const isFinal = shallowRef(false);
7574 | const result = shallowRef("");
7575 | const error = shallowRef(void 0);
7576 | let recognition;
7577 | const start = () => {
7578 | isListening.value = true;
7579 | };
7580 | const stop = () => {
7581 | isListening.value = false;
7582 | };
7583 | const toggle = (value = !isListening.value) => {
7584 | if (value) {
7585 | start();
7586 | } else {
7587 | stop();
7588 | }
7589 | };
7590 | const SpeechRecognition = window2 && (window2.SpeechRecognition || window2.webkitSpeechRecognition);
7591 | const isSupported = useSupported(() => SpeechRecognition);
7592 | if (isSupported.value) {
7593 | recognition = new SpeechRecognition();
7594 | recognition.continuous = continuous;
7595 | recognition.interimResults = interimResults;
7596 | recognition.lang = toValue(lang);
7597 | recognition.maxAlternatives = maxAlternatives;
7598 | recognition.onstart = () => {
7599 | isListening.value = true;
7600 | isFinal.value = false;
7601 | };
7602 | watch(lang, (lang2) => {
7603 | if (recognition && !isListening.value)
7604 | recognition.lang = lang2;
7605 | });
7606 | recognition.onresult = (event) => {
7607 | const currentResult = event.results[event.resultIndex];
7608 | const { transcript } = currentResult[0];
7609 | isFinal.value = currentResult.isFinal;
7610 | result.value = transcript;
7611 | error.value = void 0;
7612 | };
7613 | recognition.onerror = (event) => {
7614 | error.value = event;
7615 | };
7616 | recognition.onend = () => {
7617 | isListening.value = false;
7618 | recognition.lang = toValue(lang);
7619 | };
7620 | watch(isListening, (newValue, oldValue) => {
7621 | if (newValue === oldValue)
7622 | return;
7623 | if (newValue)
7624 | recognition.start();
7625 | else
7626 | recognition.stop();
7627 | });
7628 | }
7629 | tryOnScopeDispose(() => {
7630 | stop();
7631 | });
7632 | return {
7633 | isSupported,
7634 | isListening,
7635 | isFinal,
7636 | recognition,
7637 | result,
7638 | error,
7639 | toggle,
7640 | start,
7641 | stop
7642 | };
7643 | }
7644 | function useSpeechSynthesis(text, options = {}) {
7645 | const {
7646 | pitch = 1,
7647 | rate = 1,
7648 | volume = 1,
7649 | window: window2 = defaultWindow
7650 | } = options;
7651 | const synth = window2 && window2.speechSynthesis;
7652 | const isSupported = useSupported(() => synth);
7653 | const isPlaying = shallowRef(false);
7654 | const status = shallowRef("init");
7655 | const spokenText = toRef2(text || "");
7656 | const lang = toRef2(options.lang || "en-US");
7657 | const error = shallowRef(void 0);
7658 | const toggle = (value = !isPlaying.value) => {
7659 | isPlaying.value = value;
7660 | };
7661 | const bindEventsForUtterance = (utterance2) => {
7662 | utterance2.lang = toValue(lang);
7663 | utterance2.voice = toValue(options.voice) || null;
7664 | utterance2.pitch = toValue(pitch);
7665 | utterance2.rate = toValue(rate);
7666 | utterance2.volume = volume;
7667 | utterance2.onstart = () => {
7668 | isPlaying.value = true;
7669 | status.value = "play";
7670 | };
7671 | utterance2.onpause = () => {
7672 | isPlaying.value = false;
7673 | status.value = "pause";
7674 | };
7675 | utterance2.onresume = () => {
7676 | isPlaying.value = true;
7677 | status.value = "play";
7678 | };
7679 | utterance2.onend = () => {
7680 | isPlaying.value = false;
7681 | status.value = "end";
7682 | };
7683 | utterance2.onerror = (event) => {
7684 | error.value = event;
7685 | };
7686 | };
7687 | const utterance = computed(() => {
7688 | isPlaying.value = false;
7689 | status.value = "init";
7690 | const newUtterance = new SpeechSynthesisUtterance(spokenText.value);
7691 | bindEventsForUtterance(newUtterance);
7692 | return newUtterance;
7693 | });
7694 | const speak = () => {
7695 | synth.cancel();
7696 | if (utterance)
7697 | synth.speak(utterance.value);
7698 | };
7699 | const stop = () => {
7700 | synth.cancel();
7701 | isPlaying.value = false;
7702 | };
7703 | if (isSupported.value) {
7704 | bindEventsForUtterance(utterance.value);
7705 | watch(lang, (lang2) => {
7706 | if (utterance.value && !isPlaying.value)
7707 | utterance.value.lang = lang2;
7708 | });
7709 | if (options.voice) {
7710 | watch(options.voice, () => {
7711 | synth.cancel();
7712 | });
7713 | }
7714 | watch(isPlaying, () => {
7715 | if (isPlaying.value)
7716 | synth.resume();
7717 | else
7718 | synth.pause();
7719 | });
7720 | }
7721 | tryOnScopeDispose(() => {
7722 | isPlaying.value = false;
7723 | });
7724 | return {
7725 | isSupported,
7726 | isPlaying,
7727 | status,
7728 | utterance,
7729 | error,
7730 | stop,
7731 | toggle,
7732 | speak
7733 | };
7734 | }
7735 | function useStepper(steps, initialStep) {
7736 | const stepsRef = ref(steps);
7737 | const stepNames = computed(() => Array.isArray(stepsRef.value) ? stepsRef.value : Object.keys(stepsRef.value));
7738 | const index = ref(stepNames.value.indexOf(initialStep != null ? initialStep : stepNames.value[0]));
7739 | const current = computed(() => at(index.value));
7740 | const isFirst = computed(() => index.value === 0);
7741 | const isLast = computed(() => index.value === stepNames.value.length - 1);
7742 | const next = computed(() => stepNames.value[index.value + 1]);
7743 | const previous = computed(() => stepNames.value[index.value - 1]);
7744 | function at(index2) {
7745 | if (Array.isArray(stepsRef.value))
7746 | return stepsRef.value[index2];
7747 | return stepsRef.value[stepNames.value[index2]];
7748 | }
7749 | function get2(step) {
7750 | if (!stepNames.value.includes(step))
7751 | return;
7752 | return at(stepNames.value.indexOf(step));
7753 | }
7754 | function goTo(step) {
7755 | if (stepNames.value.includes(step))
7756 | index.value = stepNames.value.indexOf(step);
7757 | }
7758 | function goToNext() {
7759 | if (isLast.value)
7760 | return;
7761 | index.value++;
7762 | }
7763 | function goToPrevious() {
7764 | if (isFirst.value)
7765 | return;
7766 | index.value--;
7767 | }
7768 | function goBackTo(step) {
7769 | if (isAfter(step))
7770 | goTo(step);
7771 | }
7772 | function isNext(step) {
7773 | return stepNames.value.indexOf(step) === index.value + 1;
7774 | }
7775 | function isPrevious(step) {
7776 | return stepNames.value.indexOf(step) === index.value - 1;
7777 | }
7778 | function isCurrent(step) {
7779 | return stepNames.value.indexOf(step) === index.value;
7780 | }
7781 | function isBefore(step) {
7782 | return index.value < stepNames.value.indexOf(step);
7783 | }
7784 | function isAfter(step) {
7785 | return index.value > stepNames.value.indexOf(step);
7786 | }
7787 | return {
7788 | steps: stepsRef,
7789 | stepNames,
7790 | index,
7791 | current,
7792 | next,
7793 | previous,
7794 | isFirst,
7795 | isLast,
7796 | at,
7797 | get: get2,
7798 | goTo,
7799 | goToNext,
7800 | goToPrevious,
7801 | goBackTo,
7802 | isNext,
7803 | isPrevious,
7804 | isCurrent,
7805 | isBefore,
7806 | isAfter
7807 | };
7808 | }
7809 | function useStorageAsync(key, initialValue, storage, options = {}) {
7810 | var _a;
7811 | const {
7812 | flush = "pre",
7813 | deep = true,
7814 | listenToStorageChanges = true,
7815 | writeDefaults = true,
7816 | mergeDefaults = false,
7817 | shallow,
7818 | window: window2 = defaultWindow,
7819 | eventFilter,
7820 | onError = (e) => {
7821 | console.error(e);
7822 | }
7823 | } = options;
7824 | const rawInit = toValue(initialValue);
7825 | const type = guessSerializerType(rawInit);
7826 | const data = (shallow ? shallowRef : ref)(toValue(initialValue));
7827 | const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
7828 | if (!storage) {
7829 | try {
7830 | storage = getSSRHandler("getDefaultStorageAsync", () => {
7831 | var _a2;
7832 | return (_a2 = defaultWindow) == null ? void 0 : _a2.localStorage;
7833 | })();
7834 | } catch (e) {
7835 | onError(e);
7836 | }
7837 | }
7838 | async function read(event) {
7839 | if (!storage || event && event.key !== key)
7840 | return;
7841 | try {
7842 | const rawValue = event ? event.newValue : await storage.getItem(key);
7843 | if (rawValue == null) {
7844 | data.value = rawInit;
7845 | if (writeDefaults && rawInit !== null)
7846 | await storage.setItem(key, await serializer.write(rawInit));
7847 | } else if (mergeDefaults) {
7848 | const value = await serializer.read(rawValue);
7849 | if (typeof mergeDefaults === "function")
7850 | data.value = mergeDefaults(value, rawInit);
7851 | else if (type === "object" && !Array.isArray(value))
7852 | data.value = { ...rawInit, ...value };
7853 | else data.value = value;
7854 | } else {
7855 | data.value = await serializer.read(rawValue);
7856 | }
7857 | } catch (e) {
7858 | onError(e);
7859 | }
7860 | }
7861 | read();
7862 | if (window2 && listenToStorageChanges)
7863 | useEventListener(window2, "storage", (e) => Promise.resolve().then(() => read(e)), { passive: true });
7864 | if (storage) {
7865 | watchWithFilter(
7866 | data,
7867 | async () => {
7868 | try {
7869 | if (data.value == null)
7870 | await storage.removeItem(key);
7871 | else
7872 | await storage.setItem(key, await serializer.write(data.value));
7873 | } catch (e) {
7874 | onError(e);
7875 | }
7876 | },
7877 | {
7878 | flush,
7879 | deep,
7880 | eventFilter
7881 | }
7882 | );
7883 | }
7884 | return data;
7885 | }
7886 | var _id = 0;
7887 | function useStyleTag(css, options = {}) {
7888 | const isLoaded = shallowRef(false);
7889 | const {
7890 | document: document2 = defaultDocument,
7891 | immediate = true,
7892 | manual = false,
7893 | id = `vueuse_styletag_${++_id}`
7894 | } = options;
7895 | const cssRef = shallowRef(css);
7896 | let stop = () => {
7897 | };
7898 | const load = () => {
7899 | if (!document2)
7900 | return;
7901 | const el = document2.getElementById(id) || document2.createElement("style");
7902 | if (!el.isConnected) {
7903 | el.id = id;
7904 | if (options.media)
7905 | el.media = options.media;
7906 | document2.head.appendChild(el);
7907 | }
7908 | if (isLoaded.value)
7909 | return;
7910 | stop = watch(
7911 | cssRef,
7912 | (value) => {
7913 | el.textContent = value;
7914 | },
7915 | { immediate: true }
7916 | );
7917 | isLoaded.value = true;
7918 | };
7919 | const unload = () => {
7920 | if (!document2 || !isLoaded.value)
7921 | return;
7922 | stop();
7923 | document2.head.removeChild(document2.getElementById(id));
7924 | isLoaded.value = false;
7925 | };
7926 | if (immediate && !manual)
7927 | tryOnMounted(load);
7928 | if (!manual)
7929 | tryOnScopeDispose(unload);
7930 | return {
7931 | id,
7932 | css: cssRef,
7933 | unload,
7934 | load,
7935 | isLoaded: readonly(isLoaded)
7936 | };
7937 | }
7938 | function useSwipe(target, options = {}) {
7939 | const {
7940 | threshold = 50,
7941 | onSwipe,
7942 | onSwipeEnd,
7943 | onSwipeStart,
7944 | passive = true
7945 | } = options;
7946 | const coordsStart = reactive({ x: 0, y: 0 });
7947 | const coordsEnd = reactive({ x: 0, y: 0 });
7948 | const diffX = computed(() => coordsStart.x - coordsEnd.x);
7949 | const diffY = computed(() => coordsStart.y - coordsEnd.y);
7950 | const { max, abs } = Math;
7951 | const isThresholdExceeded = computed(() => max(abs(diffX.value), abs(diffY.value)) >= threshold);
7952 | const isSwiping = shallowRef(false);
7953 | const direction = computed(() => {
7954 | if (!isThresholdExceeded.value)
7955 | return "none";
7956 | if (abs(diffX.value) > abs(diffY.value)) {
7957 | return diffX.value > 0 ? "left" : "right";
7958 | } else {
7959 | return diffY.value > 0 ? "up" : "down";
7960 | }
7961 | });
7962 | const getTouchEventCoords = (e) => [e.touches[0].clientX, e.touches[0].clientY];
7963 | const updateCoordsStart = (x, y) => {
7964 | coordsStart.x = x;
7965 | coordsStart.y = y;
7966 | };
7967 | const updateCoordsEnd = (x, y) => {
7968 | coordsEnd.x = x;
7969 | coordsEnd.y = y;
7970 | };
7971 | const listenerOptions = { passive, capture: !passive };
7972 | const onTouchEnd = (e) => {
7973 | if (isSwiping.value)
7974 | onSwipeEnd == null ? void 0 : onSwipeEnd(e, direction.value);
7975 | isSwiping.value = false;
7976 | };
7977 | const stops = [
7978 | useEventListener(target, "touchstart", (e) => {
7979 | if (e.touches.length !== 1)
7980 | return;
7981 | const [x, y] = getTouchEventCoords(e);
7982 | updateCoordsStart(x, y);
7983 | updateCoordsEnd(x, y);
7984 | onSwipeStart == null ? void 0 : onSwipeStart(e);
7985 | }, listenerOptions),
7986 | useEventListener(target, "touchmove", (e) => {
7987 | if (e.touches.length !== 1)
7988 | return;
7989 | const [x, y] = getTouchEventCoords(e);
7990 | updateCoordsEnd(x, y);
7991 | if (listenerOptions.capture && !listenerOptions.passive && Math.abs(diffX.value) > Math.abs(diffY.value))
7992 | e.preventDefault();
7993 | if (!isSwiping.value && isThresholdExceeded.value)
7994 | isSwiping.value = true;
7995 | if (isSwiping.value)
7996 | onSwipe == null ? void 0 : onSwipe(e);
7997 | }, listenerOptions),
7998 | useEventListener(target, ["touchend", "touchcancel"], onTouchEnd, listenerOptions)
7999 | ];
8000 | const stop = () => stops.forEach((s) => s());
8001 | return {
8002 | isSwiping,
8003 | direction,
8004 | coordsStart,
8005 | coordsEnd,
8006 | lengthX: diffX,
8007 | lengthY: diffY,
8008 | stop,
8009 | // TODO: Remove in the next major version
8010 | isPassiveEventSupported: true
8011 | };
8012 | }
8013 | function useTemplateRefsList() {
8014 | const refs = ref([]);
8015 | refs.value.set = (el) => {
8016 | if (el)
8017 | refs.value.push(el);
8018 | };
8019 | onBeforeUpdate(() => {
8020 | refs.value.length = 0;
8021 | });
8022 | return refs;
8023 | }
8024 | function useTextDirection(options = {}) {
8025 | const {
8026 | document: document2 = defaultDocument,
8027 | selector = "html",
8028 | observe = false,
8029 | initialValue = "ltr"
8030 | } = options;
8031 | function getValue2() {
8032 | var _a, _b;
8033 | return (_b = (_a = document2 == null ? void 0 : document2.querySelector(selector)) == null ? void 0 : _a.getAttribute("dir")) != null ? _b : initialValue;
8034 | }
8035 | const dir = ref(getValue2());
8036 | tryOnMounted(() => dir.value = getValue2());
8037 | if (observe && document2) {
8038 | useMutationObserver(
8039 | document2.querySelector(selector),
8040 | () => dir.value = getValue2(),
8041 | { attributes: true }
8042 | );
8043 | }
8044 | return computed({
8045 | get() {
8046 | return dir.value;
8047 | },
8048 | set(v) {
8049 | var _a, _b;
8050 | dir.value = v;
8051 | if (!document2)
8052 | return;
8053 | if (dir.value)
8054 | (_a = document2.querySelector(selector)) == null ? void 0 : _a.setAttribute("dir", dir.value);
8055 | else
8056 | (_b = document2.querySelector(selector)) == null ? void 0 : _b.removeAttribute("dir");
8057 | }
8058 | });
8059 | }
8060 | function getRangesFromSelection(selection) {
8061 | var _a;
8062 | const rangeCount = (_a = selection.rangeCount) != null ? _a : 0;
8063 | return Array.from({ length: rangeCount }, (_, i) => selection.getRangeAt(i));
8064 | }
8065 | function useTextSelection(options = {}) {
8066 | const {
8067 | window: window2 = defaultWindow
8068 | } = options;
8069 | const selection = ref(null);
8070 | const text = computed(() => {
8071 | var _a, _b;
8072 | return (_b = (_a = selection.value) == null ? void 0 : _a.toString()) != null ? _b : "";
8073 | });
8074 | const ranges = computed(() => selection.value ? getRangesFromSelection(selection.value) : []);
8075 | const rects = computed(() => ranges.value.map((range) => range.getBoundingClientRect()));
8076 | function onSelectionChange() {
8077 | selection.value = null;
8078 | if (window2)
8079 | selection.value = window2.getSelection();
8080 | }
8081 | if (window2)
8082 | useEventListener(window2.document, "selectionchange", onSelectionChange, { passive: true });
8083 | return {
8084 | text,
8085 | rects,
8086 | ranges,
8087 | selection
8088 | };
8089 | }
8090 | function tryRequestAnimationFrame(window2 = defaultWindow, fn) {
8091 | if (window2 && typeof window2.requestAnimationFrame === "function") {
8092 | window2.requestAnimationFrame(fn);
8093 | } else {
8094 | fn();
8095 | }
8096 | }
8097 | function useTextareaAutosize(options = {}) {
8098 | var _a, _b;
8099 | const { window: window2 = defaultWindow } = options;
8100 | const textarea = toRef2(options == null ? void 0 : options.element);
8101 | const input = toRef2((_a = options == null ? void 0 : options.input) != null ? _a : "");
8102 | const styleProp = (_b = options == null ? void 0 : options.styleProp) != null ? _b : "height";
8103 | const textareaScrollHeight = shallowRef(1);
8104 | const textareaOldWidth = shallowRef(0);
8105 | function triggerResize() {
8106 | var _a2;
8107 | if (!textarea.value)
8108 | return;
8109 | let height = "";
8110 | textarea.value.style[styleProp] = "1px";
8111 | textareaScrollHeight.value = (_a2 = textarea.value) == null ? void 0 : _a2.scrollHeight;
8112 | const _styleTarget = toValue(options == null ? void 0 : options.styleTarget);
8113 | if (_styleTarget)
8114 | _styleTarget.style[styleProp] = `${textareaScrollHeight.value}px`;
8115 | else
8116 | height = `${textareaScrollHeight.value}px`;
8117 | textarea.value.style[styleProp] = height;
8118 | }
8119 | watch([input, textarea], () => nextTick(triggerResize), { immediate: true });
8120 | watch(textareaScrollHeight, () => {
8121 | var _a2;
8122 | return (_a2 = options == null ? void 0 : options.onResize) == null ? void 0 : _a2.call(options);
8123 | });
8124 | useResizeObserver(textarea, ([{ contentRect }]) => {
8125 | if (textareaOldWidth.value === contentRect.width)
8126 | return;
8127 | tryRequestAnimationFrame(window2, () => {
8128 | textareaOldWidth.value = contentRect.width;
8129 | triggerResize();
8130 | });
8131 | });
8132 | if (options == null ? void 0 : options.watch)
8133 | watch(options.watch, triggerResize, { immediate: true, deep: true });
8134 | return {
8135 | textarea,
8136 | input,
8137 | triggerResize
8138 | };
8139 | }
8140 | function useThrottledRefHistory(source, options = {}) {
8141 | const { throttle = 200, trailing = true } = options;
8142 | const filter = throttleFilter(throttle, trailing);
8143 | const history = useRefHistory(source, { ...options, eventFilter: filter });
8144 | return {
8145 | ...history
8146 | };
8147 | }
8148 | var DEFAULT_UNITS = [
8149 | { max: 6e4, value: 1e3, name: "second" },
8150 | { max: 276e4, value: 6e4, name: "minute" },
8151 | { max: 72e6, value: 36e5, name: "hour" },
8152 | { max: 5184e5, value: 864e5, name: "day" },
8153 | { max: 24192e5, value: 6048e5, name: "week" },
8154 | { max: 28512e6, value: 2592e6, name: "month" },
8155 | { max: Number.POSITIVE_INFINITY, value: 31536e6, name: "year" }
8156 | ];
8157 | var DEFAULT_MESSAGES = {
8158 | justNow: "just now",
8159 | past: (n) => n.match(/\d/) ? `${n} ago` : n,
8160 | future: (n) => n.match(/\d/) ? `in ${n}` : n,
8161 | month: (n, past) => n === 1 ? past ? "last month" : "next month" : `${n} month${n > 1 ? "s" : ""}`,
8162 | year: (n, past) => n === 1 ? past ? "last year" : "next year" : `${n} year${n > 1 ? "s" : ""}`,
8163 | day: (n, past) => n === 1 ? past ? "yesterday" : "tomorrow" : `${n} day${n > 1 ? "s" : ""}`,
8164 | week: (n, past) => n === 1 ? past ? "last week" : "next week" : `${n} week${n > 1 ? "s" : ""}`,
8165 | hour: (n) => `${n} hour${n > 1 ? "s" : ""}`,
8166 | minute: (n) => `${n} minute${n > 1 ? "s" : ""}`,
8167 | second: (n) => `${n} second${n > 1 ? "s" : ""}`,
8168 | invalid: ""
8169 | };
8170 | function DEFAULT_FORMATTER(date) {
8171 | return date.toISOString().slice(0, 10);
8172 | }
8173 | function useTimeAgo(time, options = {}) {
8174 | const {
8175 | controls: exposeControls = false,
8176 | updateInterval = 3e4
8177 | } = options;
8178 | const { now: now2, ...controls } = useNow({ interval: updateInterval, controls: true });
8179 | const timeAgo = computed(() => formatTimeAgo(new Date(toValue(time)), options, toValue(now2)));
8180 | if (exposeControls) {
8181 | return {
8182 | timeAgo,
8183 | ...controls
8184 | };
8185 | } else {
8186 | return timeAgo;
8187 | }
8188 | }
8189 | function formatTimeAgo(from, options = {}, now2 = Date.now()) {
8190 | var _a;
8191 | const {
8192 | max,
8193 | messages = DEFAULT_MESSAGES,
8194 | fullDateFormatter = DEFAULT_FORMATTER,
8195 | units = DEFAULT_UNITS,
8196 | showSecond = false,
8197 | rounding = "round"
8198 | } = options;
8199 | const roundFn = typeof rounding === "number" ? (n) => +n.toFixed(rounding) : Math[rounding];
8200 | const diff = +now2 - +from;
8201 | const absDiff = Math.abs(diff);
8202 | function getValue2(diff2, unit) {
8203 | return roundFn(Math.abs(diff2) / unit.value);
8204 | }
8205 | function format(diff2, unit) {
8206 | const val = getValue2(diff2, unit);
8207 | const past = diff2 > 0;
8208 | const str = applyFormat(unit.name, val, past);
8209 | return applyFormat(past ? "past" : "future", str, past);
8210 | }
8211 | function applyFormat(name, val, isPast) {
8212 | const formatter = messages[name];
8213 | if (typeof formatter === "function")
8214 | return formatter(val, isPast);
8215 | return formatter.replace("{0}", val.toString());
8216 | }
8217 | if (absDiff < 6e4 && !showSecond)
8218 | return messages.justNow;
8219 | if (typeof max === "number" && absDiff > max)
8220 | return fullDateFormatter(new Date(from));
8221 | if (typeof max === "string") {
8222 | const unitMax = (_a = units.find((i) => i.name === max)) == null ? void 0 : _a.max;
8223 | if (unitMax && absDiff > unitMax)
8224 | return fullDateFormatter(new Date(from));
8225 | }
8226 | for (const [idx, unit] of units.entries()) {
8227 | const val = getValue2(diff, unit);
8228 | if (val <= 0 && units[idx - 1])
8229 | return format(diff, units[idx - 1]);
8230 | if (absDiff < unit.max)
8231 | return format(diff, unit);
8232 | }
8233 | return messages.invalid;
8234 | }
8235 | function useTimeoutPoll(fn, interval, options = {}) {
8236 | const {
8237 | immediate = true,
8238 | immediateCallback = false
8239 | } = options;
8240 | const { start } = useTimeoutFn(loop, interval, { immediate });
8241 | const isActive = shallowRef(false);
8242 | async function loop() {
8243 | if (!isActive.value)
8244 | return;
8245 | await fn();
8246 | start();
8247 | }
8248 | function resume() {
8249 | if (!isActive.value) {
8250 | isActive.value = true;
8251 | if (immediateCallback)
8252 | fn();
8253 | start();
8254 | }
8255 | }
8256 | function pause() {
8257 | isActive.value = false;
8258 | }
8259 | if (immediate && isClient)
8260 | resume();
8261 | tryOnScopeDispose(pause);
8262 | return {
8263 | isActive,
8264 | pause,
8265 | resume
8266 | };
8267 | }
8268 | function useTimestamp(options = {}) {
8269 | const {
8270 | controls: exposeControls = false,
8271 | offset = 0,
8272 | immediate = true,
8273 | interval = "requestAnimationFrame",
8274 | callback
8275 | } = options;
8276 | const ts = shallowRef(timestamp() + offset);
8277 | const update = () => ts.value = timestamp() + offset;
8278 | const cb = callback ? () => {
8279 | update();
8280 | callback(ts.value);
8281 | } : update;
8282 | const controls = interval === "requestAnimationFrame" ? useRafFn(cb, { immediate }) : useIntervalFn(cb, interval, { immediate });
8283 | if (exposeControls) {
8284 | return {
8285 | timestamp: ts,
8286 | ...controls
8287 | };
8288 | } else {
8289 | return ts;
8290 | }
8291 | }
8292 | function useTitle(newTitle = null, options = {}) {
8293 | var _a, _b, _c;
8294 | const {
8295 | document: document2 = defaultDocument,
8296 | restoreOnUnmount = (t) => t
8297 | } = options;
8298 | const originalTitle = (_a = document2 == null ? void 0 : document2.title) != null ? _a : "";
8299 | const title = toRef2((_b = newTitle != null ? newTitle : document2 == null ? void 0 : document2.title) != null ? _b : null);
8300 | const isReadonly2 = !!(newTitle && typeof newTitle === "function");
8301 | function format(t) {
8302 | if (!("titleTemplate" in options))
8303 | return t;
8304 | const template = options.titleTemplate || "%s";
8305 | return typeof template === "function" ? template(t) : toValue(template).replace(/%s/g, t);
8306 | }
8307 | watch(
8308 | title,
8309 | (newValue, oldValue) => {
8310 | if (newValue !== oldValue && document2)
8311 | document2.title = format(newValue != null ? newValue : "");
8312 | },
8313 | { immediate: true }
8314 | );
8315 | if (options.observe && !options.titleTemplate && document2 && !isReadonly2) {
8316 | useMutationObserver(
8317 | (_c = document2.head) == null ? void 0 : _c.querySelector("title"),
8318 | () => {
8319 | if (document2 && document2.title !== title.value)
8320 | title.value = format(document2.title);
8321 | },
8322 | { childList: true }
8323 | );
8324 | }
8325 | tryOnScopeDispose(() => {
8326 | if (restoreOnUnmount) {
8327 | const restoredTitle = restoreOnUnmount(originalTitle, title.value || "");
8328 | if (restoredTitle != null && document2)
8329 | document2.title = restoredTitle;
8330 | }
8331 | });
8332 | return title;
8333 | }
8334 | var _TransitionPresets = {
8335 | easeInSine: [0.12, 0, 0.39, 0],
8336 | easeOutSine: [0.61, 1, 0.88, 1],
8337 | easeInOutSine: [0.37, 0, 0.63, 1],
8338 | easeInQuad: [0.11, 0, 0.5, 0],
8339 | easeOutQuad: [0.5, 1, 0.89, 1],
8340 | easeInOutQuad: [0.45, 0, 0.55, 1],
8341 | easeInCubic: [0.32, 0, 0.67, 0],
8342 | easeOutCubic: [0.33, 1, 0.68, 1],
8343 | easeInOutCubic: [0.65, 0, 0.35, 1],
8344 | easeInQuart: [0.5, 0, 0.75, 0],
8345 | easeOutQuart: [0.25, 1, 0.5, 1],
8346 | easeInOutQuart: [0.76, 0, 0.24, 1],
8347 | easeInQuint: [0.64, 0, 0.78, 0],
8348 | easeOutQuint: [0.22, 1, 0.36, 1],
8349 | easeInOutQuint: [0.83, 0, 0.17, 1],
8350 | easeInExpo: [0.7, 0, 0.84, 0],
8351 | easeOutExpo: [0.16, 1, 0.3, 1],
8352 | easeInOutExpo: [0.87, 0, 0.13, 1],
8353 | easeInCirc: [0.55, 0, 1, 0.45],
8354 | easeOutCirc: [0, 0.55, 0.45, 1],
8355 | easeInOutCirc: [0.85, 0, 0.15, 1],
8356 | easeInBack: [0.36, 0, 0.66, -0.56],
8357 | easeOutBack: [0.34, 1.56, 0.64, 1],
8358 | easeInOutBack: [0.68, -0.6, 0.32, 1.6]
8359 | };
8360 | var TransitionPresets = Object.assign({}, { linear: identity }, _TransitionPresets);
8361 | function createEasingFunction([p0, p1, p2, p3]) {
8362 | const a = (a1, a2) => 1 - 3 * a2 + 3 * a1;
8363 | const b = (a1, a2) => 3 * a2 - 6 * a1;
8364 | const c = (a1) => 3 * a1;
8365 | const calcBezier = (t, a1, a2) => ((a(a1, a2) * t + b(a1, a2)) * t + c(a1)) * t;
8366 | const getSlope = (t, a1, a2) => 3 * a(a1, a2) * t * t + 2 * b(a1, a2) * t + c(a1);
8367 | const getTforX = (x) => {
8368 | let aGuessT = x;
8369 | for (let i = 0; i < 4; ++i) {
8370 | const currentSlope = getSlope(aGuessT, p0, p2);
8371 | if (currentSlope === 0)
8372 | return aGuessT;
8373 | const currentX = calcBezier(aGuessT, p0, p2) - x;
8374 | aGuessT -= currentX / currentSlope;
8375 | }
8376 | return aGuessT;
8377 | };
8378 | return (x) => p0 === p1 && p2 === p3 ? x : calcBezier(getTforX(x), p1, p3);
8379 | }
8380 | function lerp(a, b, alpha) {
8381 | return a + alpha * (b - a);
8382 | }
8383 | function toVec(t) {
8384 | return (typeof t === "number" ? [t] : t) || [];
8385 | }
8386 | function executeTransition(source, from, to, options = {}) {
8387 | var _a, _b;
8388 | const fromVal = toValue(from);
8389 | const toVal = toValue(to);
8390 | const v1 = toVec(fromVal);
8391 | const v2 = toVec(toVal);
8392 | const duration = (_a = toValue(options.duration)) != null ? _a : 1e3;
8393 | const startedAt = Date.now();
8394 | const endAt = Date.now() + duration;
8395 | const trans = typeof options.transition === "function" ? options.transition : (_b = toValue(options.transition)) != null ? _b : identity;
8396 | const ease = typeof trans === "function" ? trans : createEasingFunction(trans);
8397 | return new Promise((resolve) => {
8398 | source.value = fromVal;
8399 | const tick = () => {
8400 | var _a2;
8401 | if ((_a2 = options.abort) == null ? void 0 : _a2.call(options)) {
8402 | resolve();
8403 | return;
8404 | }
8405 | const now2 = Date.now();
8406 | const alpha = ease((now2 - startedAt) / duration);
8407 | const arr = toVec(source.value).map((n, i) => lerp(v1[i], v2[i], alpha));
8408 | if (Array.isArray(source.value))
8409 | source.value = arr.map((n, i) => {
8410 | var _a3, _b2;
8411 | return lerp((_a3 = v1[i]) != null ? _a3 : 0, (_b2 = v2[i]) != null ? _b2 : 0, alpha);
8412 | });
8413 | else if (typeof source.value === "number")
8414 | source.value = arr[0];
8415 | if (now2 < endAt) {
8416 | requestAnimationFrame(tick);
8417 | } else {
8418 | source.value = toVal;
8419 | resolve();
8420 | }
8421 | };
8422 | tick();
8423 | });
8424 | }
8425 | function useTransition(source, options = {}) {
8426 | let currentId = 0;
8427 | const sourceVal = () => {
8428 | const v = toValue(source);
8429 | return typeof v === "number" ? v : v.map(toValue);
8430 | };
8431 | const outputRef = ref(sourceVal());
8432 | watch(sourceVal, async (to) => {
8433 | var _a, _b;
8434 | if (toValue(options.disabled))
8435 | return;
8436 | const id = ++currentId;
8437 | if (options.delay)
8438 | await promiseTimeout(toValue(options.delay));
8439 | if (id !== currentId)
8440 | return;
8441 | const toVal = Array.isArray(to) ? to.map(toValue) : toValue(to);
8442 | (_a = options.onStarted) == null ? void 0 : _a.call(options);
8443 | await executeTransition(outputRef, outputRef.value, toVal, {
8444 | ...options,
8445 | abort: () => {
8446 | var _a2;
8447 | return id !== currentId || ((_a2 = options.abort) == null ? void 0 : _a2.call(options));
8448 | }
8449 | });
8450 | (_b = options.onFinished) == null ? void 0 : _b.call(options);
8451 | }, { deep: true });
8452 | watch(() => toValue(options.disabled), (disabled) => {
8453 | if (disabled) {
8454 | currentId++;
8455 | outputRef.value = sourceVal();
8456 | }
8457 | });
8458 | tryOnScopeDispose(() => {
8459 | currentId++;
8460 | });
8461 | return computed(() => toValue(options.disabled) ? sourceVal() : outputRef.value);
8462 | }
8463 | function useUrlSearchParams(mode = "history", options = {}) {
8464 | const {
8465 | initialValue = {},
8466 | removeNullishValues = true,
8467 | removeFalsyValues = false,
8468 | write: enableWrite = true,
8469 | writeMode = "replace",
8470 | window: window2 = defaultWindow
8471 | } = options;
8472 | if (!window2)
8473 | return reactive(initialValue);
8474 | const state = reactive({});
8475 | function getRawParams() {
8476 | if (mode === "history") {
8477 | return window2.location.search || "";
8478 | } else if (mode === "hash") {
8479 | const hash = window2.location.hash || "";
8480 | const index = hash.indexOf("?");
8481 | return index > 0 ? hash.slice(index) : "";
8482 | } else {
8483 | return (window2.location.hash || "").replace(/^#/, "");
8484 | }
8485 | }
8486 | function constructQuery(params) {
8487 | const stringified = params.toString();
8488 | if (mode === "history")
8489 | return `${stringified ? `?${stringified}` : ""}${window2.location.hash || ""}`;
8490 | if (mode === "hash-params")
8491 | return `${window2.location.search || ""}${stringified ? `#${stringified}` : ""}`;
8492 | const hash = window2.location.hash || "#";
8493 | const index = hash.indexOf("?");
8494 | if (index > 0)
8495 | return `${window2.location.search || ""}${hash.slice(0, index)}${stringified ? `?${stringified}` : ""}`;
8496 | return `${window2.location.search || ""}${hash}${stringified ? `?${stringified}` : ""}`;
8497 | }
8498 | function read() {
8499 | return new URLSearchParams(getRawParams());
8500 | }
8501 | function updateState(params) {
8502 | const unusedKeys = new Set(Object.keys(state));
8503 | for (const key of params.keys()) {
8504 | const paramsForKey = params.getAll(key);
8505 | state[key] = paramsForKey.length > 1 ? paramsForKey : params.get(key) || "";
8506 | unusedKeys.delete(key);
8507 | }
8508 | Array.from(unusedKeys).forEach((key) => delete state[key]);
8509 | }
8510 | const { pause, resume } = watchPausable(
8511 | state,
8512 | () => {
8513 | const params = new URLSearchParams("");
8514 | Object.keys(state).forEach((key) => {
8515 | const mapEntry = state[key];
8516 | if (Array.isArray(mapEntry))
8517 | mapEntry.forEach((value) => params.append(key, value));
8518 | else if (removeNullishValues && mapEntry == null)
8519 | params.delete(key);
8520 | else if (removeFalsyValues && !mapEntry)
8521 | params.delete(key);
8522 | else
8523 | params.set(key, mapEntry);
8524 | });
8525 | write(params, false);
8526 | },
8527 | { deep: true }
8528 | );
8529 | function write(params, shouldUpdate) {
8530 | pause();
8531 | if (shouldUpdate)
8532 | updateState(params);
8533 | if (writeMode === "replace") {
8534 | window2.history.replaceState(
8535 | window2.history.state,
8536 | window2.document.title,
8537 | window2.location.pathname + constructQuery(params)
8538 | );
8539 | } else {
8540 | window2.history.pushState(
8541 | window2.history.state,
8542 | window2.document.title,
8543 | window2.location.pathname + constructQuery(params)
8544 | );
8545 | }
8546 | resume();
8547 | }
8548 | function onChanged() {
8549 | if (!enableWrite)
8550 | return;
8551 | write(read(), true);
8552 | }
8553 | const listenerOptions = { passive: true };
8554 | useEventListener(window2, "popstate", onChanged, listenerOptions);
8555 | if (mode !== "history")
8556 | useEventListener(window2, "hashchange", onChanged, listenerOptions);
8557 | const initial = read();
8558 | if (initial.keys().next().value)
8559 | updateState(initial);
8560 | else
8561 | Object.assign(state, initialValue);
8562 | return state;
8563 | }
8564 | function useUserMedia(options = {}) {
8565 | var _a, _b;
8566 | const enabled = shallowRef((_a = options.enabled) != null ? _a : false);
8567 | const autoSwitch = shallowRef((_b = options.autoSwitch) != null ? _b : true);
8568 | const constraints = ref(options.constraints);
8569 | const { navigator: navigator2 = defaultNavigator } = options;
8570 | const isSupported = useSupported(() => {
8571 | var _a2;
8572 | return (_a2 = navigator2 == null ? void 0 : navigator2.mediaDevices) == null ? void 0 : _a2.getUserMedia;
8573 | });
8574 | const stream = shallowRef();
8575 | function getDeviceOptions(type) {
8576 | switch (type) {
8577 | case "video": {
8578 | if (constraints.value)
8579 | return constraints.value.video || false;
8580 | break;
8581 | }
8582 | case "audio": {
8583 | if (constraints.value)
8584 | return constraints.value.audio || false;
8585 | break;
8586 | }
8587 | }
8588 | }
8589 | async function _start() {
8590 | if (!isSupported.value || stream.value)
8591 | return;
8592 | stream.value = await navigator2.mediaDevices.getUserMedia({
8593 | video: getDeviceOptions("video"),
8594 | audio: getDeviceOptions("audio")
8595 | });
8596 | return stream.value;
8597 | }
8598 | function _stop() {
8599 | var _a2;
8600 | (_a2 = stream.value) == null ? void 0 : _a2.getTracks().forEach((t) => t.stop());
8601 | stream.value = void 0;
8602 | }
8603 | function stop() {
8604 | _stop();
8605 | enabled.value = false;
8606 | }
8607 | async function start() {
8608 | await _start();
8609 | if (stream.value)
8610 | enabled.value = true;
8611 | return stream.value;
8612 | }
8613 | async function restart() {
8614 | _stop();
8615 | return await start();
8616 | }
8617 | watch(
8618 | enabled,
8619 | (v) => {
8620 | if (v)
8621 | _start();
8622 | else _stop();
8623 | },
8624 | { immediate: true }
8625 | );
8626 | watch(
8627 | constraints,
8628 | () => {
8629 | if (autoSwitch.value && stream.value)
8630 | restart();
8631 | },
8632 | { immediate: true }
8633 | );
8634 | tryOnScopeDispose(() => {
8635 | stop();
8636 | });
8637 | return {
8638 | isSupported,
8639 | stream,
8640 | start,
8641 | stop,
8642 | restart,
8643 | constraints,
8644 | enabled,
8645 | autoSwitch
8646 | };
8647 | }
8648 | function useVModel(props, key, emit, options = {}) {
8649 | var _a, _b, _c;
8650 | const {
8651 | clone = false,
8652 | passive = false,
8653 | eventName,
8654 | deep = false,
8655 | defaultValue,
8656 | shouldEmit
8657 | } = options;
8658 | const vm = getCurrentInstance();
8659 | const _emit = emit || (vm == null ? void 0 : vm.emit) || ((_a = vm == null ? void 0 : vm.$emit) == null ? void 0 : _a.bind(vm)) || ((_c = (_b = vm == null ? void 0 : vm.proxy) == null ? void 0 : _b.$emit) == null ? void 0 : _c.bind(vm == null ? void 0 : vm.proxy));
8660 | let event = eventName;
8661 | if (!key) {
8662 | key = "modelValue";
8663 | }
8664 | event = event || `update:${key.toString()}`;
8665 | const cloneFn = (val) => !clone ? val : typeof clone === "function" ? clone(val) : cloneFnJSON(val);
8666 | const getValue2 = () => isDef(props[key]) ? cloneFn(props[key]) : defaultValue;
8667 | const triggerEmit = (value) => {
8668 | if (shouldEmit) {
8669 | if (shouldEmit(value))
8670 | _emit(event, value);
8671 | } else {
8672 | _emit(event, value);
8673 | }
8674 | };
8675 | if (passive) {
8676 | const initialValue = getValue2();
8677 | const proxy = ref(initialValue);
8678 | let isUpdating = false;
8679 | watch(
8680 | () => props[key],
8681 | (v) => {
8682 | if (!isUpdating) {
8683 | isUpdating = true;
8684 | proxy.value = cloneFn(v);
8685 | nextTick(() => isUpdating = false);
8686 | }
8687 | }
8688 | );
8689 | watch(
8690 | proxy,
8691 | (v) => {
8692 | if (!isUpdating && (v !== props[key] || deep))
8693 | triggerEmit(v);
8694 | },
8695 | { deep }
8696 | );
8697 | return proxy;
8698 | } else {
8699 | return computed({
8700 | get() {
8701 | return getValue2();
8702 | },
8703 | set(value) {
8704 | triggerEmit(value);
8705 | }
8706 | });
8707 | }
8708 | }
8709 | function useVModels(props, emit, options = {}) {
8710 | const ret = {};
8711 | for (const key in props) {
8712 | ret[key] = useVModel(
8713 | props,
8714 | key,
8715 | emit,
8716 | options
8717 | );
8718 | }
8719 | return ret;
8720 | }
8721 | function useVibrate(options) {
8722 | const {
8723 | pattern = [],
8724 | interval = 0,
8725 | navigator: navigator2 = defaultNavigator
8726 | } = options || {};
8727 | const isSupported = useSupported(() => typeof navigator2 !== "undefined" && "vibrate" in navigator2);
8728 | const patternRef = toRef2(pattern);
8729 | let intervalControls;
8730 | const vibrate = (pattern2 = patternRef.value) => {
8731 | if (isSupported.value)
8732 | navigator2.vibrate(pattern2);
8733 | };
8734 | const stop = () => {
8735 | if (isSupported.value)
8736 | navigator2.vibrate(0);
8737 | intervalControls == null ? void 0 : intervalControls.pause();
8738 | };
8739 | if (interval > 0) {
8740 | intervalControls = useIntervalFn(
8741 | vibrate,
8742 | interval,
8743 | {
8744 | immediate: false,
8745 | immediateCallback: false
8746 | }
8747 | );
8748 | }
8749 | return {
8750 | isSupported,
8751 | pattern,
8752 | intervalControls,
8753 | vibrate,
8754 | stop
8755 | };
8756 | }
8757 | function useVirtualList(list, options) {
8758 | const { containerStyle, wrapperProps, scrollTo, calculateRange, currentList, containerRef } = "itemHeight" in options ? useVerticalVirtualList(options, list) : useHorizontalVirtualList(options, list);
8759 | return {
8760 | list: currentList,
8761 | scrollTo,
8762 | containerProps: {
8763 | ref: containerRef,
8764 | onScroll: () => {
8765 | calculateRange();
8766 | },
8767 | style: containerStyle
8768 | },
8769 | wrapperProps
8770 | };
8771 | }
8772 | function useVirtualListResources(list) {
8773 | const containerRef = shallowRef(null);
8774 | const size = useElementSize(containerRef);
8775 | const currentList = ref([]);
8776 | const source = shallowRef(list);
8777 | const state = ref({ start: 0, end: 10 });
8778 | return { state, source, currentList, size, containerRef };
8779 | }
8780 | function createGetViewCapacity(state, source, itemSize) {
8781 | return (containerSize) => {
8782 | if (typeof itemSize === "number")
8783 | return Math.ceil(containerSize / itemSize);
8784 | const { start = 0 } = state.value;
8785 | let sum = 0;
8786 | let capacity = 0;
8787 | for (let i = start; i < source.value.length; i++) {
8788 | const size = itemSize(i);
8789 | sum += size;
8790 | capacity = i;
8791 | if (sum > containerSize)
8792 | break;
8793 | }
8794 | return capacity - start;
8795 | };
8796 | }
8797 | function createGetOffset(source, itemSize) {
8798 | return (scrollDirection) => {
8799 | if (typeof itemSize === "number")
8800 | return Math.floor(scrollDirection / itemSize) + 1;
8801 | let sum = 0;
8802 | let offset = 0;
8803 | for (let i = 0; i < source.value.length; i++) {
8804 | const size = itemSize(i);
8805 | sum += size;
8806 | if (sum >= scrollDirection) {
8807 | offset = i;
8808 | break;
8809 | }
8810 | }
8811 | return offset + 1;
8812 | };
8813 | }
8814 | function createCalculateRange(type, overscan, getOffset, getViewCapacity, { containerRef, state, currentList, source }) {
8815 | return () => {
8816 | const element = containerRef.value;
8817 | if (element) {
8818 | const offset = getOffset(type === "vertical" ? element.scrollTop : element.scrollLeft);
8819 | const viewCapacity = getViewCapacity(type === "vertical" ? element.clientHeight : element.clientWidth);
8820 | const from = offset - overscan;
8821 | const to = offset + viewCapacity + overscan;
8822 | state.value = {
8823 | start: from < 0 ? 0 : from,
8824 | end: to > source.value.length ? source.value.length : to
8825 | };
8826 | currentList.value = source.value.slice(state.value.start, state.value.end).map((ele, index) => ({
8827 | data: ele,
8828 | index: index + state.value.start
8829 | }));
8830 | }
8831 | };
8832 | }
8833 | function createGetDistance(itemSize, source) {
8834 | return (index) => {
8835 | if (typeof itemSize === "number") {
8836 | const size2 = index * itemSize;
8837 | return size2;
8838 | }
8839 | const size = source.value.slice(0, index).reduce((sum, _, i) => sum + itemSize(i), 0);
8840 | return size;
8841 | };
8842 | }
8843 | function useWatchForSizes(size, list, containerRef, calculateRange) {
8844 | watch([size.width, size.height, list, containerRef], () => {
8845 | calculateRange();
8846 | });
8847 | }
8848 | function createComputedTotalSize(itemSize, source) {
8849 | return computed(() => {
8850 | if (typeof itemSize === "number")
8851 | return source.value.length * itemSize;
8852 | return source.value.reduce((sum, _, index) => sum + itemSize(index), 0);
8853 | });
8854 | }
8855 | var scrollToDictionaryForElementScrollKey = {
8856 | horizontal: "scrollLeft",
8857 | vertical: "scrollTop"
8858 | };
8859 | function createScrollTo(type, calculateRange, getDistance, containerRef) {
8860 | return (index) => {
8861 | if (containerRef.value) {
8862 | containerRef.value[scrollToDictionaryForElementScrollKey[type]] = getDistance(index);
8863 | calculateRange();
8864 | }
8865 | };
8866 | }
8867 | function useHorizontalVirtualList(options, list) {
8868 | const resources = useVirtualListResources(list);
8869 | const { state, source, currentList, size, containerRef } = resources;
8870 | const containerStyle = { overflowX: "auto" };
8871 | const { itemWidth, overscan = 5 } = options;
8872 | const getViewCapacity = createGetViewCapacity(state, source, itemWidth);
8873 | const getOffset = createGetOffset(source, itemWidth);
8874 | const calculateRange = createCalculateRange("horizontal", overscan, getOffset, getViewCapacity, resources);
8875 | const getDistanceLeft = createGetDistance(itemWidth, source);
8876 | const offsetLeft = computed(() => getDistanceLeft(state.value.start));
8877 | const totalWidth = createComputedTotalSize(itemWidth, source);
8878 | useWatchForSizes(size, list, containerRef, calculateRange);
8879 | const scrollTo = createScrollTo("horizontal", calculateRange, getDistanceLeft, containerRef);
8880 | const wrapperProps = computed(() => {
8881 | return {
8882 | style: {
8883 | height: "100%",
8884 | width: `${totalWidth.value - offsetLeft.value}px`,
8885 | marginLeft: `${offsetLeft.value}px`,
8886 | display: "flex"
8887 | }
8888 | };
8889 | });
8890 | return {
8891 | scrollTo,
8892 | calculateRange,
8893 | wrapperProps,
8894 | containerStyle,
8895 | currentList,
8896 | containerRef
8897 | };
8898 | }
8899 | function useVerticalVirtualList(options, list) {
8900 | const resources = useVirtualListResources(list);
8901 | const { state, source, currentList, size, containerRef } = resources;
8902 | const containerStyle = { overflowY: "auto" };
8903 | const { itemHeight, overscan = 5 } = options;
8904 | const getViewCapacity = createGetViewCapacity(state, source, itemHeight);
8905 | const getOffset = createGetOffset(source, itemHeight);
8906 | const calculateRange = createCalculateRange("vertical", overscan, getOffset, getViewCapacity, resources);
8907 | const getDistanceTop = createGetDistance(itemHeight, source);
8908 | const offsetTop = computed(() => getDistanceTop(state.value.start));
8909 | const totalHeight = createComputedTotalSize(itemHeight, source);
8910 | useWatchForSizes(size, list, containerRef, calculateRange);
8911 | const scrollTo = createScrollTo("vertical", calculateRange, getDistanceTop, containerRef);
8912 | const wrapperProps = computed(() => {
8913 | return {
8914 | style: {
8915 | width: "100%",
8916 | height: `${totalHeight.value - offsetTop.value}px`,
8917 | marginTop: `${offsetTop.value}px`
8918 | }
8919 | };
8920 | });
8921 | return {
8922 | calculateRange,
8923 | scrollTo,
8924 | containerStyle,
8925 | wrapperProps,
8926 | currentList,
8927 | containerRef
8928 | };
8929 | }
8930 | function useWakeLock(options = {}) {
8931 | const {
8932 | navigator: navigator2 = defaultNavigator,
8933 | document: document2 = defaultDocument
8934 | } = options;
8935 | const requestedType = shallowRef(false);
8936 | const sentinel = shallowRef(null);
8937 | const documentVisibility = useDocumentVisibility({ document: document2 });
8938 | const isSupported = useSupported(() => navigator2 && "wakeLock" in navigator2);
8939 | const isActive = computed(() => !!sentinel.value && documentVisibility.value === "visible");
8940 | if (isSupported.value) {
8941 | useEventListener(sentinel, "release", () => {
8942 | var _a, _b;
8943 | requestedType.value = (_b = (_a = sentinel.value) == null ? void 0 : _a.type) != null ? _b : false;
8944 | }, { passive: true });
8945 | whenever(
8946 | () => documentVisibility.value === "visible" && (document2 == null ? void 0 : document2.visibilityState) === "visible" && requestedType.value,
8947 | (type) => {
8948 | requestedType.value = false;
8949 | forceRequest(type);
8950 | }
8951 | );
8952 | }
8953 | async function forceRequest(type) {
8954 | var _a;
8955 | await ((_a = sentinel.value) == null ? void 0 : _a.release());
8956 | sentinel.value = isSupported.value ? await navigator2.wakeLock.request(type) : null;
8957 | }
8958 | async function request(type) {
8959 | if (documentVisibility.value === "visible")
8960 | await forceRequest(type);
8961 | else
8962 | requestedType.value = type;
8963 | }
8964 | async function release() {
8965 | requestedType.value = false;
8966 | const s = sentinel.value;
8967 | sentinel.value = null;
8968 | await (s == null ? void 0 : s.release());
8969 | }
8970 | return {
8971 | sentinel,
8972 | isSupported,
8973 | isActive,
8974 | request,
8975 | forceRequest,
8976 | release
8977 | };
8978 | }
8979 | function useWebNotification(options = {}) {
8980 | const {
8981 | window: window2 = defaultWindow,
8982 | requestPermissions: _requestForPermissions = true
8983 | } = options;
8984 | const defaultWebNotificationOptions = options;
8985 | const isSupported = useSupported(() => {
8986 | if (!window2 || !("Notification" in window2))
8987 | return false;
8988 | if (Notification.permission === "granted")
8989 | return true;
8990 | try {
8991 | const notification2 = new Notification("");
8992 | notification2.onshow = () => {
8993 | notification2.close();
8994 | };
8995 | } catch (e) {
8996 | if (e.name === "TypeError")
8997 | return false;
8998 | }
8999 | return true;
9000 | });
9001 | const permissionGranted = shallowRef(isSupported.value && "permission" in Notification && Notification.permission === "granted");
9002 | const notification = ref(null);
9003 | const ensurePermissions = async () => {
9004 | if (!isSupported.value)
9005 | return;
9006 | if (!permissionGranted.value && Notification.permission !== "denied") {
9007 | const result = await Notification.requestPermission();
9008 | if (result === "granted")
9009 | permissionGranted.value = true;
9010 | }
9011 | return permissionGranted.value;
9012 | };
9013 | const { on: onClick, trigger: clickTrigger } = createEventHook();
9014 | const { on: onShow, trigger: showTrigger } = createEventHook();
9015 | const { on: onError, trigger: errorTrigger } = createEventHook();
9016 | const { on: onClose, trigger: closeTrigger } = createEventHook();
9017 | const show = async (overrides) => {
9018 | if (!isSupported.value || !permissionGranted.value)
9019 | return;
9020 | const options2 = Object.assign({}, defaultWebNotificationOptions, overrides);
9021 | notification.value = new Notification(options2.title || "", options2);
9022 | notification.value.onclick = clickTrigger;
9023 | notification.value.onshow = showTrigger;
9024 | notification.value.onerror = errorTrigger;
9025 | notification.value.onclose = closeTrigger;
9026 | return notification.value;
9027 | };
9028 | const close = () => {
9029 | if (notification.value)
9030 | notification.value.close();
9031 | notification.value = null;
9032 | };
9033 | if (_requestForPermissions)
9034 | tryOnMounted(ensurePermissions);
9035 | tryOnScopeDispose(close);
9036 | if (isSupported.value && window2) {
9037 | const document2 = window2.document;
9038 | useEventListener(document2, "visibilitychange", (e) => {
9039 | e.preventDefault();
9040 | if (document2.visibilityState === "visible") {
9041 | close();
9042 | }
9043 | });
9044 | }
9045 | return {
9046 | isSupported,
9047 | notification,
9048 | ensurePermissions,
9049 | permissionGranted,
9050 | show,
9051 | close,
9052 | onClick,
9053 | onShow,
9054 | onError,
9055 | onClose
9056 | };
9057 | }
9058 | var DEFAULT_PING_MESSAGE = "ping";
9059 | function resolveNestedOptions(options) {
9060 | if (options === true)
9061 | return {};
9062 | return options;
9063 | }
9064 | function useWebSocket(url, options = {}) {
9065 | const {
9066 | onConnected,
9067 | onDisconnected,
9068 | onError,
9069 | onMessage,
9070 | immediate = true,
9071 | autoConnect = true,
9072 | autoClose = true,
9073 | protocols = []
9074 | } = options;
9075 | const data = ref(null);
9076 | const status = shallowRef("CLOSED");
9077 | const wsRef = ref();
9078 | const urlRef = toRef2(url);
9079 | let heartbeatPause;
9080 | let heartbeatResume;
9081 | let explicitlyClosed = false;
9082 | let retried = 0;
9083 | let bufferedData = [];
9084 | let retryTimeout;
9085 | let pongTimeoutWait;
9086 | const _sendBuffer = () => {
9087 | if (bufferedData.length && wsRef.value && status.value === "OPEN") {
9088 | for (const buffer of bufferedData)
9089 | wsRef.value.send(buffer);
9090 | bufferedData = [];
9091 | }
9092 | };
9093 | const resetRetry = () => {
9094 | if (retryTimeout != null) {
9095 | clearTimeout(retryTimeout);
9096 | retryTimeout = void 0;
9097 | }
9098 | };
9099 | const resetHeartbeat = () => {
9100 | clearTimeout(pongTimeoutWait);
9101 | pongTimeoutWait = void 0;
9102 | };
9103 | const close = (code = 1e3, reason) => {
9104 | resetRetry();
9105 | if (!isClient && !isWorker || !wsRef.value)
9106 | return;
9107 | explicitlyClosed = true;
9108 | resetHeartbeat();
9109 | heartbeatPause == null ? void 0 : heartbeatPause();
9110 | wsRef.value.close(code, reason);
9111 | wsRef.value = void 0;
9112 | };
9113 | const send = (data2, useBuffer = true) => {
9114 | if (!wsRef.value || status.value !== "OPEN") {
9115 | if (useBuffer)
9116 | bufferedData.push(data2);
9117 | return false;
9118 | }
9119 | _sendBuffer();
9120 | wsRef.value.send(data2);
9121 | return true;
9122 | };
9123 | const _init = () => {
9124 | if (explicitlyClosed || typeof urlRef.value === "undefined")
9125 | return;
9126 | const ws = new WebSocket(urlRef.value, protocols);
9127 | wsRef.value = ws;
9128 | status.value = "CONNECTING";
9129 | ws.onopen = () => {
9130 | status.value = "OPEN";
9131 | retried = 0;
9132 | onConnected == null ? void 0 : onConnected(ws);
9133 | heartbeatResume == null ? void 0 : heartbeatResume();
9134 | _sendBuffer();
9135 | };
9136 | ws.onclose = (ev) => {
9137 | status.value = "CLOSED";
9138 | resetHeartbeat();
9139 | heartbeatPause == null ? void 0 : heartbeatPause();
9140 | onDisconnected == null ? void 0 : onDisconnected(ws, ev);
9141 | if (!explicitlyClosed && options.autoReconnect && (wsRef.value == null || ws === wsRef.value)) {
9142 | const {
9143 | retries = -1,
9144 | delay = 1e3,
9145 | onFailed
9146 | } = resolveNestedOptions(options.autoReconnect);
9147 | const checkRetires = typeof retries === "function" ? retries : () => typeof retries === "number" && (retries < 0 || retried < retries);
9148 | if (checkRetires(retried)) {
9149 | retried += 1;
9150 | retryTimeout = setTimeout(_init, delay);
9151 | } else {
9152 | onFailed == null ? void 0 : onFailed();
9153 | }
9154 | }
9155 | };
9156 | ws.onerror = (e) => {
9157 | onError == null ? void 0 : onError(ws, e);
9158 | };
9159 | ws.onmessage = (e) => {
9160 | if (options.heartbeat) {
9161 | resetHeartbeat();
9162 | const {
9163 | message = DEFAULT_PING_MESSAGE,
9164 | responseMessage = message
9165 | } = resolveNestedOptions(options.heartbeat);
9166 | if (e.data === toValue(responseMessage))
9167 | return;
9168 | }
9169 | data.value = e.data;
9170 | onMessage == null ? void 0 : onMessage(ws, e);
9171 | };
9172 | };
9173 | if (options.heartbeat) {
9174 | const {
9175 | message = DEFAULT_PING_MESSAGE,
9176 | interval = 1e3,
9177 | pongTimeout = 1e3
9178 | } = resolveNestedOptions(options.heartbeat);
9179 | const { pause, resume } = useIntervalFn(
9180 | () => {
9181 | send(toValue(message), false);
9182 | if (pongTimeoutWait != null)
9183 | return;
9184 | pongTimeoutWait = setTimeout(() => {
9185 | close();
9186 | explicitlyClosed = false;
9187 | }, pongTimeout);
9188 | },
9189 | interval,
9190 | { immediate: false }
9191 | );
9192 | heartbeatPause = pause;
9193 | heartbeatResume = resume;
9194 | }
9195 | if (autoClose) {
9196 | if (isClient)
9197 | useEventListener("beforeunload", () => close(), { passive: true });
9198 | tryOnScopeDispose(close);
9199 | }
9200 | const open = () => {
9201 | if (!isClient && !isWorker)
9202 | return;
9203 | close();
9204 | explicitlyClosed = false;
9205 | retried = 0;
9206 | _init();
9207 | };
9208 | if (immediate)
9209 | open();
9210 | if (autoConnect)
9211 | watch(urlRef, open);
9212 | return {
9213 | data,
9214 | status,
9215 | close,
9216 | send,
9217 | open,
9218 | ws: wsRef
9219 | };
9220 | }
9221 | function useWebWorker(arg0, workerOptions, options) {
9222 | const {
9223 | window: window2 = defaultWindow
9224 | } = options != null ? options : {};
9225 | const data = ref(null);
9226 | const worker = shallowRef();
9227 | const post = (...args) => {
9228 | if (!worker.value)
9229 | return;
9230 | worker.value.postMessage(...args);
9231 | };
9232 | const terminate = function terminate2() {
9233 | if (!worker.value)
9234 | return;
9235 | worker.value.terminate();
9236 | };
9237 | if (window2) {
9238 | if (typeof arg0 === "string")
9239 | worker.value = new Worker(arg0, workerOptions);
9240 | else if (typeof arg0 === "function")
9241 | worker.value = arg0();
9242 | else
9243 | worker.value = arg0;
9244 | worker.value.onmessage = (e) => {
9245 | data.value = e.data;
9246 | };
9247 | tryOnScopeDispose(() => {
9248 | if (worker.value)
9249 | worker.value.terminate();
9250 | });
9251 | }
9252 | return {
9253 | data,
9254 | post,
9255 | terminate,
9256 | worker
9257 | };
9258 | }
9259 | function depsParser(deps, localDeps) {
9260 | if (deps.length === 0 && localDeps.length === 0)
9261 | return "";
9262 | const depsString = deps.map((dep) => `'${dep}'`).toString();
9263 | const depsFunctionString = localDeps.filter((dep) => typeof dep === "function").map((fn) => {
9264 | const str = fn.toString();
9265 | if (str.trim().startsWith("function")) {
9266 | return str;
9267 | } else {
9268 | const name = fn.name;
9269 | return `const ${name} = ${str}`;
9270 | }
9271 | }).join(";");
9272 | const importString = `importScripts(${depsString});`;
9273 | return `${depsString.trim() === "" ? "" : importString} ${depsFunctionString}`;
9274 | }
9275 | function jobRunner(userFunc) {
9276 | return (e) => {
9277 | const userFuncArgs = e.data[0];
9278 | return Promise.resolve(userFunc.apply(void 0, userFuncArgs)).then((result) => {
9279 | postMessage(["SUCCESS", result]);
9280 | }).catch((error) => {
9281 | postMessage(["ERROR", error]);
9282 | });
9283 | };
9284 | }
9285 | function createWorkerBlobUrl(fn, deps, localDeps) {
9286 | const blobCode = `${depsParser(deps, localDeps)}; onmessage=(${jobRunner})(${fn})`;
9287 | const blob = new Blob([blobCode], { type: "text/javascript" });
9288 | const url = URL.createObjectURL(blob);
9289 | return url;
9290 | }
9291 | function useWebWorkerFn(fn, options = {}) {
9292 | const {
9293 | dependencies = [],
9294 | localDependencies = [],
9295 | timeout,
9296 | window: window2 = defaultWindow
9297 | } = options;
9298 | const worker = ref();
9299 | const workerStatus = shallowRef("PENDING");
9300 | const promise = ref({});
9301 | const timeoutId = shallowRef();
9302 | const workerTerminate = (status = "PENDING") => {
9303 | if (worker.value && worker.value._url && window2) {
9304 | worker.value.terminate();
9305 | URL.revokeObjectURL(worker.value._url);
9306 | promise.value = {};
9307 | worker.value = void 0;
9308 | window2.clearTimeout(timeoutId.value);
9309 | workerStatus.value = status;
9310 | }
9311 | };
9312 | workerTerminate();
9313 | tryOnScopeDispose(workerTerminate);
9314 | const generateWorker = () => {
9315 | const blobUrl = createWorkerBlobUrl(fn, dependencies, localDependencies);
9316 | const newWorker = new Worker(blobUrl);
9317 | newWorker._url = blobUrl;
9318 | newWorker.onmessage = (e) => {
9319 | const { resolve = () => {
9320 | }, reject = () => {
9321 | } } = promise.value;
9322 | const [status, result] = e.data;
9323 | switch (status) {
9324 | case "SUCCESS":
9325 | resolve(result);
9326 | workerTerminate(status);
9327 | break;
9328 | default:
9329 | reject(result);
9330 | workerTerminate("ERROR");
9331 | break;
9332 | }
9333 | };
9334 | newWorker.onerror = (e) => {
9335 | const { reject = () => {
9336 | } } = promise.value;
9337 | e.preventDefault();
9338 | reject(e);
9339 | workerTerminate("ERROR");
9340 | };
9341 | if (timeout) {
9342 | timeoutId.value = setTimeout(
9343 | () => workerTerminate("TIMEOUT_EXPIRED"),
9344 | timeout
9345 | );
9346 | }
9347 | return newWorker;
9348 | };
9349 | const callWorker = (...fnArgs) => new Promise((resolve, reject) => {
9350 | var _a;
9351 | promise.value = {
9352 | resolve,
9353 | reject
9354 | };
9355 | (_a = worker.value) == null ? void 0 : _a.postMessage([[...fnArgs]]);
9356 | workerStatus.value = "RUNNING";
9357 | });
9358 | const workerFn = (...fnArgs) => {
9359 | if (workerStatus.value === "RUNNING") {
9360 | console.error(
9361 | "[useWebWorkerFn] You can only run one instance of the worker at a time."
9362 | );
9363 | return Promise.reject();
9364 | }
9365 | worker.value = generateWorker();
9366 | return callWorker(...fnArgs);
9367 | };
9368 | return {
9369 | workerFn,
9370 | workerStatus,
9371 | workerTerminate
9372 | };
9373 | }
9374 | function useWindowFocus(options = {}) {
9375 | const { window: window2 = defaultWindow } = options;
9376 | if (!window2)
9377 | return shallowRef(false);
9378 | const focused = shallowRef(window2.document.hasFocus());
9379 | const listenerOptions = { passive: true };
9380 | useEventListener(window2, "blur", () => {
9381 | focused.value = false;
9382 | }, listenerOptions);
9383 | useEventListener(window2, "focus", () => {
9384 | focused.value = true;
9385 | }, listenerOptions);
9386 | return focused;
9387 | }
9388 | function useWindowScroll(options = {}) {
9389 | const { window: window2 = defaultWindow, ...rest } = options;
9390 | return useScroll(window2, rest);
9391 | }
9392 | function useWindowSize(options = {}) {
9393 | const {
9394 | window: window2 = defaultWindow,
9395 | initialWidth = Number.POSITIVE_INFINITY,
9396 | initialHeight = Number.POSITIVE_INFINITY,
9397 | listenOrientation = true,
9398 | includeScrollbar = true,
9399 | type = "inner"
9400 | } = options;
9401 | const width = shallowRef(initialWidth);
9402 | const height = shallowRef(initialHeight);
9403 | const update = () => {
9404 | if (window2) {
9405 | if (type === "outer") {
9406 | width.value = window2.outerWidth;
9407 | height.value = window2.outerHeight;
9408 | } else if (type === "visual" && window2.visualViewport) {
9409 | const { width: visualViewportWidth, height: visualViewportHeight, scale } = window2.visualViewport;
9410 | width.value = Math.round(visualViewportWidth * scale);
9411 | height.value = Math.round(visualViewportHeight * scale);
9412 | } else if (includeScrollbar) {
9413 | width.value = window2.innerWidth;
9414 | height.value = window2.innerHeight;
9415 | } else {
9416 | width.value = window2.document.documentElement.clientWidth;
9417 | height.value = window2.document.documentElement.clientHeight;
9418 | }
9419 | }
9420 | };
9421 | update();
9422 | tryOnMounted(update);
9423 | const listenerOptions = { passive: true };
9424 | useEventListener("resize", update, listenerOptions);
9425 | if (window2 && type === "visual" && window2.visualViewport) {
9426 | useEventListener(window2.visualViewport, "resize", update, listenerOptions);
9427 | }
9428 | if (listenOrientation) {
9429 | const matches = useMediaQuery("(orientation: portrait)");
9430 | watch(matches, () => update());
9431 | }
9432 | return { width, height };
9433 | }
9434 |
9435 | export {
9436 | computedEager,
9437 | computedWithControl,
9438 | tryOnScopeDispose,
9439 | createEventHook,
9440 | createGlobalState,
9441 | injectLocal,
9442 | provideLocal,
9443 | createInjectionState,
9444 | createRef,
9445 | createSharedComposable,
9446 | extendRef,
9447 | get,
9448 | isDefined,
9449 | makeDestructurable,
9450 | reactify,
9451 | reactifyObject,
9452 | toReactive,
9453 | reactiveComputed,
9454 | reactiveOmit,
9455 | isClient,
9456 | isWorker,
9457 | isDef,
9458 | notNullish,
9459 | assert,
9460 | isObject,
9461 | now,
9462 | timestamp,
9463 | clamp,
9464 | noop,
9465 | rand,
9466 | hasOwn,
9467 | isIOS,
9468 | createFilterWrapper,
9469 | bypassFilter,
9470 | debounceFilter,
9471 | throttleFilter,
9472 | pausableFilter,
9473 | hyphenate,
9474 | camelize,
9475 | promiseTimeout,
9476 | identity,
9477 | createSingletonPromise,
9478 | invoke,
9479 | containsProp,
9480 | increaseWithUnit,
9481 | pxValue,
9482 | objectPick,
9483 | objectOmit,
9484 | objectEntries,
9485 | getLifeCycleTarget,
9486 | toArray,
9487 | toRef2 as toRef,
9488 | resolveRef,
9489 | reactivePick,
9490 | refAutoReset,
9491 | useDebounceFn,
9492 | refDebounced,
9493 | refDefault,
9494 | useThrottleFn,
9495 | refThrottled,
9496 | refWithControl,
9497 | controlledRef,
9498 | set,
9499 | watchWithFilter,
9500 | watchPausable,
9501 | syncRef,
9502 | syncRefs,
9503 | toRefs2 as toRefs,
9504 | toValue2 as toValue,
9505 | resolveUnref,
9506 | tryOnBeforeMount,
9507 | tryOnBeforeUnmount,
9508 | tryOnMounted,
9509 | tryOnUnmounted,
9510 | until,
9511 | useArrayDifference,
9512 | useArrayEvery,
9513 | useArrayFilter,
9514 | useArrayFind,
9515 | useArrayFindIndex,
9516 | useArrayFindLast,
9517 | useArrayIncludes,
9518 | useArrayJoin,
9519 | useArrayMap,
9520 | useArrayReduce,
9521 | useArraySome,
9522 | useArrayUnique,
9523 | useCounter,
9524 | formatDate,
9525 | normalizeDate,
9526 | useDateFormat,
9527 | useIntervalFn,
9528 | useInterval,
9529 | useLastChanged,
9530 | useTimeoutFn,
9531 | useTimeout,
9532 | useToNumber,
9533 | useToString,
9534 | useToggle,
9535 | watchArray,
9536 | watchAtMost,
9537 | watchDebounced,
9538 | watchDeep,
9539 | watchIgnorable,
9540 | watchImmediate,
9541 | watchOnce,
9542 | watchThrottled,
9543 | watchTriggerable,
9544 | whenever,
9545 | computedAsync,
9546 | computedInject,
9547 | createReusableTemplate,
9548 | createTemplatePromise,
9549 | createUnrefFn,
9550 | defaultWindow,
9551 | defaultDocument,
9552 | defaultNavigator,
9553 | defaultLocation,
9554 | unrefElement,
9555 | useEventListener,
9556 | onClickOutside,
9557 | useMounted,
9558 | useSupported,
9559 | useMutationObserver,
9560 | onElementRemoval,
9561 | onKeyStroke,
9562 | onKeyDown,
9563 | onKeyPressed,
9564 | onKeyUp,
9565 | onLongPress,
9566 | onStartTyping,
9567 | templateRef,
9568 | useActiveElement,
9569 | useRafFn,
9570 | useAnimate,
9571 | useAsyncQueue,
9572 | useAsyncState,
9573 | useBase64,
9574 | useBattery,
9575 | useBluetooth,
9576 | useSSRWidth,
9577 | provideSSRWidth,
9578 | useMediaQuery,
9579 | breakpointsTailwind,
9580 | breakpointsBootstrapV5,
9581 | breakpointsVuetifyV2,
9582 | breakpointsVuetifyV3,
9583 | breakpointsVuetify,
9584 | breakpointsAntDesign,
9585 | breakpointsQuasar,
9586 | breakpointsSematic,
9587 | breakpointsMasterCss,
9588 | breakpointsPrimeFlex,
9589 | breakpointsElement,
9590 | useBreakpoints,
9591 | useBroadcastChannel,
9592 | useBrowserLocation,
9593 | useCached,
9594 | usePermission,
9595 | useClipboard,
9596 | useClipboardItems,
9597 | cloneFnJSON,
9598 | useCloned,
9599 | getSSRHandler,
9600 | setSSRHandler,
9601 | usePreferredDark,
9602 | StorageSerializers,
9603 | customStorageEventName,
9604 | useStorage,
9605 | useColorMode,
9606 | useConfirmDialog,
9607 | useCountdown,
9608 | useCssVar,
9609 | useCurrentElement,
9610 | useCycleList,
9611 | useDark,
9612 | useManualRefHistory,
9613 | useRefHistory,
9614 | useDebouncedRefHistory,
9615 | useDeviceMotion,
9616 | useDeviceOrientation,
9617 | useDevicePixelRatio,
9618 | useDevicesList,
9619 | useDisplayMedia,
9620 | useDocumentVisibility,
9621 | useDraggable,
9622 | useDropZone,
9623 | useResizeObserver,
9624 | useElementBounding,
9625 | useElementByPoint,
9626 | useElementHover,
9627 | useElementSize,
9628 | useIntersectionObserver,
9629 | useElementVisibility,
9630 | useEventBus,
9631 | useEventSource,
9632 | useEyeDropper,
9633 | useFavicon,
9634 | createFetch,
9635 | useFetch,
9636 | useFileDialog,
9637 | useFileSystemAccess,
9638 | useFocus,
9639 | useFocusWithin,
9640 | useFps,
9641 | useFullscreen,
9642 | mapGamepadToXbox360Controller,
9643 | useGamepad,
9644 | useGeolocation,
9645 | useIdle,
9646 | useImage,
9647 | useScroll,
9648 | useInfiniteScroll,
9649 | useKeyModifier,
9650 | useLocalStorage,
9651 | DefaultMagicKeysAliasMap,
9652 | useMagicKeys,
9653 | useMediaControls,
9654 | useMemoize,
9655 | useMemory,
9656 | useMouse,
9657 | useMouseInElement,
9658 | useMousePressed,
9659 | useNavigatorLanguage,
9660 | useNetwork,
9661 | useNow,
9662 | useObjectUrl,
9663 | useOffsetPagination,
9664 | useOnline,
9665 | usePageLeave,
9666 | useScreenOrientation,
9667 | useParallax,
9668 | useParentElement,
9669 | usePerformanceObserver,
9670 | usePointer,
9671 | usePointerLock,
9672 | usePointerSwipe,
9673 | usePreferredColorScheme,
9674 | usePreferredContrast,
9675 | usePreferredLanguages,
9676 | usePreferredReducedMotion,
9677 | usePreferredReducedTransparency,
9678 | usePrevious,
9679 | useScreenSafeArea,
9680 | useScriptTag,
9681 | useScrollLock,
9682 | useSessionStorage,
9683 | useShare,
9684 | useSorted,
9685 | useSpeechRecognition,
9686 | useSpeechSynthesis,
9687 | useStepper,
9688 | useStorageAsync,
9689 | useStyleTag,
9690 | useSwipe,
9691 | useTemplateRefsList,
9692 | useTextDirection,
9693 | useTextSelection,
9694 | useTextareaAutosize,
9695 | useThrottledRefHistory,
9696 | useTimeAgo,
9697 | formatTimeAgo,
9698 | useTimeoutPoll,
9699 | useTimestamp,
9700 | useTitle,
9701 | TransitionPresets,
9702 | executeTransition,
9703 | useTransition,
9704 | useUrlSearchParams,
9705 | useUserMedia,
9706 | useVModel,
9707 | useVModels,
9708 | useVibrate,
9709 | useVirtualList,
9710 | useWakeLock,
9711 | useWebNotification,
9712 | useWebSocket,
9713 | useWebWorker,
9714 | useWebWorkerFn,
9715 | useWindowFocus,
9716 | useWindowScroll,
9717 | useWindowSize
9718 | };
9719 | //# sourceMappingURL=chunk-P2XGSYO7.js.map
9720 |
```