agenttwin 0.3.21 → 0.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +2113 -609
- package/dist/dashboard/assets/dashboard/agent-home.css +7 -7
- package/dist/dashboard/assets/dashboard/bay-morning.webp +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-afternoon.webp +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-portrait.webp +0 -0
- package/dist/dashboard/assets/dashboard/moonlit-coast.webp +0 -0
- package/dist/dashboard/assets/next/static/chunks/5663-403316746afad10e.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/dashboard/{page-9c11295678539a5f.js → page-0e0392368e0a891e.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-4981ea4966b19e3e.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-dd4ac0f5f36e6bfa.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/{page-34574448d210c775.js → page-de0fe6d84be21e6a.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-360cbffc57981f6b.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/{page-07c8054d57c9089b.js → page-3e86fffabfa87d88.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/{webpack-40324749d289e4a5.js → webpack-be6e526fd530c797.js} +1 -1
- package/dist/dashboard/assets/next/static/css/{42045de5f39b50ca.css → 37d81e1d2804cc5f.css} +1 -1
- package/dist/dashboard/assets/next/static/css/69ec1bae997c3bb0.css +1 -0
- package/dist/dashboard/assets/next/static/css/ad85402a1595e56e.css +1 -0
- package/dist/dashboard/assets/next/static/css/{4bbe78c2fe206b92.css → da981fb878a02b8c.css} +1 -1
- package/dist/dashboard/assets/next/static/media/bay-morning.82669113.webp +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-afternoon.0aa49492.webp +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-portrait.89fc667a.webp +0 -0
- package/dist/dashboard/assets/next/static/media/moonlit-coast.09739ef4.webp +0 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/engine.js +6385 -4973
- package/dist/gateway.js +2194 -604
- package/dist/twins/catalog.json +6020 -0
- package/dist/twins/engine/v2/THIRD-PARTY.txt +25 -0
- package/dist/twins/engine/v2/chunks/2CHBP57N.mjs +8 -0
- package/dist/twins/engine/v2/chunks/4CPL6MPF.mjs +30 -0
- package/dist/twins/engine/v2/chunks/OYLYKZGD.mjs +2 -0
- package/dist/twins/engine/v2/chunks/SQSP35HM.mjs +38 -0
- package/dist/twins/engine/v2/chunks/YSJQQVUM.mjs +2 -0
- package/dist/twins/engine/v2/react-dom_client.mjs +272 -0
- package/dist/twins/engine/v2/react-dom_server.mjs +263 -0
- package/dist/twins/engine/v2/react.mjs +2 -0
- package/dist/twins/engine/v2/react_jsx-runtime.mjs +31 -0
- package/dist/twins/engine/v2/volter_world-core.mjs +195 -0
- package/dist/twins/engine/v2/volter_world-core_app-route.mjs +2 -0
- package/dist/twins/engine/v2/volter_world-core_network-policy.mjs +2 -0
- package/dist/twins/engine/v3/THIRD-PARTY.txt +65 -0
- package/dist/twins/engine/v3/chunks/2CHBP57N.mjs +8 -0
- package/dist/twins/engine/v3/chunks/2YSSPA5O.mjs +65 -0
- package/dist/twins/engine/v3/chunks/5PWRY4UK.mjs +154 -0
- package/dist/twins/engine/v3/chunks/7XRKSFFJ.mjs +2 -0
- package/dist/twins/engine/v3/chunks/AWOWH2H5.mjs +2 -0
- package/dist/twins/engine/v3/chunks/C46M5U3Q.mjs +2 -0
- package/dist/twins/engine/v3/chunks/MFH2VZPP.mjs +2 -0
- package/dist/twins/engine/v3/chunks/MWCO5UV3.mjs +2 -0
- package/dist/twins/engine/v3/chunks/N5BL5RDF.mjs +313 -0
- package/dist/twins/engine/v3/chunks/O7HGPMXG.mjs +2 -0
- package/dist/twins/engine/v3/chunks/OYLYKZGD.mjs +2 -0
- package/dist/twins/engine/v3/chunks/PLB7HTON.mjs +8 -0
- package/dist/twins/engine/v3/chunks/TY4LDBVH.mjs +7 -0
- package/dist/twins/engine/v3/chunks/VDIRUSCM.mjs +2 -0
- package/dist/twins/engine/v3/chunks/WGUCFQK6.mjs +2 -0
- package/dist/twins/engine/v3/chunks/WPATONSC.mjs +2 -0
- package/dist/twins/engine/v3/react_jsx-runtime.mjs +2 -0
- package/dist/twins/engine/v3/volter_world-core.mjs +2 -0
- package/dist/twins/engine/v3/volter_world-ui.mjs +559 -0
- package/dist/twins/packs/ahrefs/LICENSE +202 -0
- package/dist/twins/packs/ahrefs/NOTICE +7 -0
- package/dist/twins/packs/ahrefs/index.mjs +2 -0
- package/dist/twins/packs/ai-gateway/LICENSE +202 -0
- package/dist/twins/packs/ai-gateway/NOTICE +7 -0
- package/dist/twins/packs/ai-gateway/index.mjs +14 -0
- package/dist/twins/packs/airtable/LICENSE +202 -0
- package/dist/twins/packs/airtable/NOTICE +7 -0
- package/dist/twins/packs/airtable/index.mjs +2 -0
- package/dist/twins/packs/algolia/LICENSE +202 -0
- package/dist/twins/packs/algolia/NOTICE +7 -0
- package/dist/twins/packs/algolia/index.mjs +2 -0
- package/dist/twins/packs/ambientcg/LICENSE +202 -0
- package/dist/twins/packs/ambientcg/NOTICE +7 -0
- package/dist/twins/packs/ambientcg/index.mjs +2 -0
- package/dist/twins/packs/anthropic/LICENSE +202 -0
- package/dist/twins/packs/anthropic/NOTICE +7 -0
- package/dist/twins/packs/anthropic/index.mjs +18 -0
- package/dist/twins/packs/assemblyai/LICENSE +202 -0
- package/dist/twins/packs/assemblyai/NOTICE +7 -0
- package/dist/twins/packs/assemblyai/index.mjs +11 -0
- package/dist/twins/packs/aws/LICENSE +202 -0
- package/dist/twins/packs/aws/NOTICE +7 -0
- package/dist/twins/packs/aws/index.mjs +2 -0
- package/dist/twins/packs/azure/LICENSE +202 -0
- package/dist/twins/packs/azure/NOTICE +7 -0
- package/dist/twins/packs/azure/index.mjs +38 -0
- package/dist/twins/packs/azureformrecognizer/LICENSE +202 -0
- package/dist/twins/packs/azureformrecognizer/NOTICE +7 -0
- package/dist/twins/packs/azureformrecognizer/index.mjs +3 -0
- package/dist/twins/packs/bitly/LICENSE +202 -0
- package/dist/twins/packs/bitly/NOTICE +7 -0
- package/dist/twins/packs/bitly/index.mjs +2 -0
- package/dist/twins/packs/bluesky/LICENSE +202 -0
- package/dist/twins/packs/bluesky/NOTICE +7 -0
- package/dist/twins/packs/bluesky/index.mjs +30 -0
- package/dist/twins/packs/calcom/LICENSE +202 -0
- package/dist/twins/packs/calcom/NOTICE +7 -0
- package/dist/twins/packs/calcom/index.mjs +2 -0
- package/dist/twins/packs/clerk/LICENSE +202 -0
- package/dist/twins/packs/clerk/NOTICE +7 -0
- package/dist/twins/packs/clerk/index.mjs +5 -0
- package/dist/twins/packs/cloudflare/LICENSE +202 -0
- package/dist/twins/packs/cloudflare/NOTICE +7 -0
- package/dist/twins/packs/cloudflare/index.mjs +79 -0
- package/dist/twins/packs/cohere/LICENSE +202 -0
- package/dist/twins/packs/cohere/NOTICE +7 -0
- package/dist/twins/packs/cohere/index.mjs +2 -0
- package/dist/twins/packs/datadog/LICENSE +202 -0
- package/dist/twins/packs/datadog/NOTICE +7 -0
- package/dist/twins/packs/datadog/index.mjs +3 -0
- package/dist/twins/packs/deepinfra/LICENSE +202 -0
- package/dist/twins/packs/deepinfra/NOTICE +7 -0
- package/dist/twins/packs/deepinfra/index.mjs +13 -0
- package/dist/twins/packs/deepseek/LICENSE +202 -0
- package/dist/twins/packs/deepseek/NOTICE +7 -0
- package/dist/twins/packs/deepseek/index.mjs +12 -0
- package/dist/twins/packs/discord/LICENSE +202 -0
- package/dist/twins/packs/discord/NOTICE +7 -0
- package/dist/twins/packs/discord/index.mjs +2 -0
- package/dist/twins/packs/duckduckgo/LICENSE +202 -0
- package/dist/twins/packs/duckduckgo/NOTICE +7 -0
- package/dist/twins/packs/duckduckgo/index.mjs +532 -0
- package/dist/twins/packs/dynadot/LICENSE +202 -0
- package/dist/twins/packs/dynadot/NOTICE +7 -0
- package/dist/twins/packs/dynadot/index.mjs +2 -0
- package/dist/twins/packs/e2b/LICENSE +202 -0
- package/dist/twins/packs/e2b/NOTICE +7 -0
- package/dist/twins/packs/e2b/index.mjs +2 -0
- package/dist/twins/packs/elevenlabs/LICENSE +202 -0
- package/dist/twins/packs/elevenlabs/NOTICE +7 -0
- package/dist/twins/packs/elevenlabs/index.mjs +4 -0
- package/dist/twins/packs/expo/LICENSE +202 -0
- package/dist/twins/packs/expo/NOTICE +7 -0
- package/dist/twins/packs/expo/index.mjs +2 -0
- package/dist/twins/packs/fal/LICENSE +202 -0
- package/dist/twins/packs/fal/NOTICE +7 -0
- package/dist/twins/packs/fal/index.mjs +2 -0
- package/dist/twins/packs/figma/LICENSE +202 -0
- package/dist/twins/packs/figma/NOTICE +7 -0
- package/dist/twins/packs/figma/index.mjs +2 -0
- package/dist/twins/packs/firecrawl/LICENSE +202 -0
- package/dist/twins/packs/firecrawl/NOTICE +7 -0
- package/dist/twins/packs/firecrawl/index.mjs +9 -0
- package/dist/twins/packs/fireworks/LICENSE +202 -0
- package/dist/twins/packs/fireworks/NOTICE +7 -0
- package/dist/twins/packs/fireworks/index.mjs +13 -0
- package/dist/twins/packs/fly/LICENSE +202 -0
- package/dist/twins/packs/fly/NOTICE +7 -0
- package/dist/twins/packs/fly/index.mjs +2 -0
- package/dist/twins/packs/gcs/LICENSE +202 -0
- package/dist/twins/packs/gcs/NOTICE +7 -0
- package/dist/twins/packs/gcs/index.mjs +8 -0
- package/dist/twins/packs/gemini/LICENSE +202 -0
- package/dist/twins/packs/gemini/NOTICE +7 -0
- package/dist/twins/packs/gemini/index.mjs +7 -0
- package/dist/twins/packs/github/LICENSE +202 -0
- package/dist/twins/packs/github/NOTICE +7 -0
- package/dist/twins/packs/github/index.mjs +75153 -0
- package/dist/twins/packs/googleads/LICENSE +202 -0
- package/dist/twins/packs/googleads/NOTICE +7 -0
- package/dist/twins/packs/googleads/index.mjs +3 -0
- package/dist/twins/packs/googlemaps/LICENSE +202 -0
- package/dist/twins/packs/googlemaps/NOTICE +7 -0
- package/dist/twins/packs/googlemaps/index.mjs +2 -0
- package/dist/twins/packs/googleoauth/LICENSE +202 -0
- package/dist/twins/packs/googleoauth/NOTICE +7 -0
- package/dist/twins/packs/googleoauth/index.mjs +2 -0
- package/dist/twins/packs/hackernews/LICENSE +202 -0
- package/dist/twins/packs/hackernews/NOTICE +7 -0
- package/dist/twins/packs/hackernews/index.mjs +35 -0
- package/dist/twins/packs/huggingface/LICENSE +202 -0
- package/dist/twins/packs/huggingface/NOTICE +7 -0
- package/dist/twins/packs/huggingface/index.mjs +9 -0
- package/dist/twins/packs/inngest/LICENSE +202 -0
- package/dist/twins/packs/inngest/NOTICE +7 -0
- package/dist/twins/packs/inngest/index.mjs +2 -0
- package/dist/twins/packs/instagram/LICENSE +202 -0
- package/dist/twins/packs/instagram/NOTICE +7 -0
- package/dist/twins/packs/instagram/index.mjs +2 -0
- package/dist/twins/packs/jira/LICENSE +202 -0
- package/dist/twins/packs/jira/NOTICE +7 -0
- package/dist/twins/packs/jira/index.mjs +2 -0
- package/dist/twins/packs/langfuse/LICENSE +202 -0
- package/dist/twins/packs/langfuse/NOTICE +7 -0
- package/dist/twins/packs/langfuse/index.mjs +2 -0
- package/dist/twins/packs/linear/LICENSE +202 -0
- package/dist/twins/packs/linear/NOTICE +7 -0
- package/dist/twins/packs/linear/index.mjs +52866 -0
- package/dist/twins/packs/linkedin/LICENSE +202 -0
- package/dist/twins/packs/linkedin/NOTICE +7 -0
- package/dist/twins/packs/linkedin/index.mjs +78 -0
- package/dist/twins/packs/livekit/LICENSE +202 -0
- package/dist/twins/packs/livekit/NOTICE +7 -0
- package/dist/twins/packs/livekit/index.mjs +2 -0
- package/dist/twins/packs/mailgun/LICENSE +202 -0
- package/dist/twins/packs/mailgun/NOTICE +7 -0
- package/dist/twins/packs/mailgun/index.mjs +13 -0
- package/dist/twins/packs/mapbox/LICENSE +202 -0
- package/dist/twins/packs/mapbox/NOTICE +7 -0
- package/dist/twins/packs/mapbox/index.mjs +2 -0
- package/dist/twins/packs/merge/LICENSE +202 -0
- package/dist/twins/packs/merge/NOTICE +7 -0
- package/dist/twins/packs/merge/index.mjs +4 -0
- package/dist/twins/packs/mistral/LICENSE +202 -0
- package/dist/twins/packs/mistral/NOTICE +7 -0
- package/dist/twins/packs/mistral/index.mjs +6 -0
- package/dist/twins/packs/mixpanel/LICENSE +202 -0
- package/dist/twins/packs/mixpanel/NOTICE +8 -0
- package/dist/twins/packs/mixpanel/index.mjs +2 -0
- package/dist/twins/packs/mongodb/LICENSE +202 -0
- package/dist/twins/packs/mongodb/NOTICE +7 -0
- package/dist/twins/packs/mongodb/index.mjs +8 -0
- package/dist/twins/packs/moonshot/LICENSE +202 -0
- package/dist/twins/packs/moonshot/NOTICE +7 -0
- package/dist/twins/packs/moonshot/index.mjs +18 -0
- package/dist/twins/packs/notion/LICENSE +202 -0
- package/dist/twins/packs/notion/NOTICE +7 -0
- package/dist/twins/packs/notion/index.mjs +2 -0
- package/dist/twins/packs/npm-registry/LICENSE +202 -0
- package/dist/twins/packs/npm-registry/NOTICE +7 -0
- package/dist/twins/packs/npm-registry/index.mjs +2 -0
- package/dist/twins/packs/oa-treasury/LICENSE +202 -0
- package/dist/twins/packs/oa-treasury/NOTICE +8 -0
- package/dist/twins/packs/oa-treasury/index.mjs +16 -0
- package/dist/twins/packs/openai/LICENSE +202 -0
- package/dist/twins/packs/openai/NOTICE +7 -0
- package/dist/twins/packs/openai/index.mjs +3473 -0
- package/dist/twins/packs/openrouter/LICENSE +202 -0
- package/dist/twins/packs/openrouter/NOTICE +7 -0
- package/dist/twins/packs/openrouter/index.mjs +2 -0
- package/dist/twins/packs/openweather/LICENSE +202 -0
- package/dist/twins/packs/openweather/NOTICE +7 -0
- package/dist/twins/packs/openweather/index.mjs +2 -0
- package/dist/twins/packs/paypal/LICENSE +202 -0
- package/dist/twins/packs/paypal/NOTICE +7 -0
- package/dist/twins/packs/paypal/index.mjs +51 -0
- package/dist/twins/packs/pinecone/LICENSE +202 -0
- package/dist/twins/packs/pinecone/NOTICE +7 -0
- package/dist/twins/packs/pinecone/index.mjs +2 -0
- package/dist/twins/packs/plain/LICENSE +202 -0
- package/dist/twins/packs/plain/NOTICE +8 -0
- package/dist/twins/packs/plain/index.mjs +18426 -0
- package/dist/twins/packs/planetscale/LICENSE +202 -0
- package/dist/twins/packs/planetscale/NOTICE +7 -0
- package/dist/twins/packs/planetscale/index.mjs +18 -0
- package/dist/twins/packs/polar/LICENSE +202 -0
- package/dist/twins/packs/polar/NOTICE +7 -0
- package/dist/twins/packs/polar/index.mjs +2 -0
- package/dist/twins/packs/polyhaven/LICENSE +202 -0
- package/dist/twins/packs/polyhaven/NOTICE +7 -0
- package/dist/twins/packs/polyhaven/index.mjs +3 -0
- package/dist/twins/packs/postmark/LICENSE +202 -0
- package/dist/twins/packs/postmark/NOTICE +7 -0
- package/dist/twins/packs/postmark/index.mjs +12 -0
- package/dist/twins/packs/reddit/LICENSE +202 -0
- package/dist/twins/packs/reddit/NOTICE +7 -0
- package/dist/twins/packs/reddit/index.mjs +324 -0
- package/dist/twins/packs/redis/LICENSE +202 -0
- package/dist/twins/packs/redis/NOTICE +7 -0
- package/dist/twins/packs/redis/index.mjs +2 -0
- package/dist/twins/packs/replicate/LICENSE +202 -0
- package/dist/twins/packs/replicate/NOTICE +7 -0
- package/dist/twins/packs/replicate/index.mjs +2 -0
- package/dist/twins/packs/resend/LICENSE +202 -0
- package/dist/twins/packs/resend/NOTICE +7 -0
- package/dist/twins/packs/resend/index.mjs +139 -0
- package/dist/twins/packs/runhuman/LICENSE +202 -0
- package/dist/twins/packs/runhuman/NOTICE +7 -0
- package/dist/twins/packs/runhuman/index.mjs +3 -0
- package/dist/twins/packs/scrapecreators/LICENSE +202 -0
- package/dist/twins/packs/scrapecreators/NOTICE +7 -0
- package/dist/twins/packs/scrapecreators/index.mjs +2 -0
- package/dist/twins/packs/segment/LICENSE +202 -0
- package/dist/twins/packs/segment/NOTICE +8 -0
- package/dist/twins/packs/segment/index.mjs +2 -0
- package/dist/twins/packs/sendblue/LICENSE +202 -0
- package/dist/twins/packs/sendblue/NOTICE +7 -0
- package/dist/twins/packs/sendblue/index.mjs +2 -0
- package/dist/twins/packs/sendgrid/LICENSE +202 -0
- package/dist/twins/packs/sendgrid/NOTICE +8 -0
- package/dist/twins/packs/sendgrid/index.mjs +4 -0
- package/dist/twins/packs/sentry/LICENSE +202 -0
- package/dist/twins/packs/sentry/NOTICE +7 -0
- package/dist/twins/packs/sentry/index.mjs +5 -0
- package/dist/twins/packs/sigstore/LICENSE +202 -0
- package/dist/twins/packs/sigstore/NOTICE +7 -0
- package/dist/twins/packs/sigstore/index.mjs +12 -0
- package/dist/twins/packs/slack/LICENSE +202 -0
- package/dist/twins/packs/slack/NOTICE +7 -0
- package/dist/twins/packs/slack/index.mjs +66 -0
- package/dist/twins/packs/smtp/LICENSE +202 -0
- package/dist/twins/packs/smtp/NOTICE +7 -0
- package/dist/twins/packs/smtp/index.mjs +3 -0
- package/dist/twins/packs/snowflake/LICENSE +202 -0
- package/dist/twins/packs/snowflake/NOTICE +8 -0
- package/dist/twins/packs/snowflake/index.mjs +30 -0
- package/dist/twins/packs/stigg/LICENSE +202 -0
- package/dist/twins/packs/stigg/NOTICE +8 -0
- package/dist/twins/packs/stigg/index.mjs +22194 -0
- package/dist/twins/packs/stream/LICENSE +202 -0
- package/dist/twins/packs/stream/NOTICE +7 -0
- package/dist/twins/packs/stream/index.mjs +2 -0
- package/dist/twins/packs/stripe/LICENSE +202 -0
- package/dist/twins/packs/stripe/NOTICE +7 -0
- package/dist/twins/packs/stripe/index.mjs +211 -0
- package/dist/twins/packs/supabase/LICENSE +202 -0
- package/dist/twins/packs/supabase/NOTICE +7 -0
- package/dist/twins/packs/supabase/index.mjs +2 -0
- package/dist/twins/packs/supermemory/LICENSE +202 -0
- package/dist/twins/packs/supermemory/NOTICE +7 -0
- package/dist/twins/packs/supermemory/index.mjs +2 -0
- package/dist/twins/packs/svix/LICENSE +202 -0
- package/dist/twins/packs/svix/NOTICE +7 -0
- package/dist/twins/packs/svix/index.mjs +2 -0
- package/dist/twins/packs/tavily/LICENSE +202 -0
- package/dist/twins/packs/tavily/NOTICE +7 -0
- package/dist/twins/packs/tavily/index.mjs +2 -0
- package/dist/twins/packs/telegram/LICENSE +202 -0
- package/dist/twins/packs/telegram/NOTICE +7 -0
- package/dist/twins/packs/telegram/index.mjs +11 -0
- package/dist/twins/packs/temporal/LICENSE +202 -0
- package/dist/twins/packs/temporal/NOTICE +7 -0
- package/dist/twins/packs/temporal/index.mjs +44 -0
- package/dist/twins/packs/tiktok/LICENSE +202 -0
- package/dist/twins/packs/tiktok/NOTICE +7 -0
- package/dist/twins/packs/tiktok/index.mjs +2 -0
- package/dist/twins/packs/tinybird/LICENSE +202 -0
- package/dist/twins/packs/tinybird/NOTICE +7 -0
- package/dist/twins/packs/tinybird/index.mjs +50 -0
- package/dist/twins/packs/togetherai/LICENSE +202 -0
- package/dist/twins/packs/togetherai/NOTICE +7 -0
- package/dist/twins/packs/togetherai/index.mjs +11 -0
- package/dist/twins/packs/tremendous/LICENSE +202 -0
- package/dist/twins/packs/tremendous/NOTICE +7 -0
- package/dist/twins/packs/tremendous/index.mjs +2 -0
- package/dist/twins/packs/tripo/LICENSE +202 -0
- package/dist/twins/packs/tripo/NOTICE +7 -0
- package/dist/twins/packs/tripo/index.mjs +9 -0
- package/dist/twins/packs/tunnel/LICENSE +202 -0
- package/dist/twins/packs/tunnel/NOTICE +7 -0
- package/dist/twins/packs/tunnel/index.mjs +2 -0
- package/dist/twins/packs/twelvelabs/LICENSE +202 -0
- package/dist/twins/packs/twelvelabs/NOTICE +7 -0
- package/dist/twins/packs/twelvelabs/index.mjs +5 -0
- package/dist/twins/packs/twilio/LICENSE +202 -0
- package/dist/twins/packs/twilio/NOTICE +7 -0
- package/dist/twins/packs/twilio/index.mjs +2 -0
- package/dist/twins/packs/twitch/LICENSE +202 -0
- package/dist/twins/packs/twitch/NOTICE +7 -0
- package/dist/twins/packs/twitch/index.mjs +68 -0
- package/dist/twins/packs/upstash/LICENSE +202 -0
- package/dist/twins/packs/upstash/NOTICE +7 -0
- package/dist/twins/packs/upstash/index.mjs +14 -0
- package/dist/twins/packs/upstashvector/LICENSE +202 -0
- package/dist/twins/packs/upstashvector/NOTICE +7 -0
- package/dist/twins/packs/upstashvector/index.mjs +3 -0
- package/dist/twins/packs/vercel/LICENSE +202 -0
- package/dist/twins/packs/vercel/NOTICE +7 -0
- package/dist/twins/packs/vercel/index.mjs +10 -0
- package/dist/twins/packs/veriff/LICENSE +202 -0
- package/dist/twins/packs/veriff/NOTICE +7 -0
- package/dist/twins/packs/veriff/index.mjs +2 -0
- package/dist/twins/packs/vgauth/LICENSE +202 -0
- package/dist/twins/packs/vgauth/NOTICE +7 -0
- package/dist/twins/packs/vgauth/index.mjs +2 -0
- package/dist/twins/packs/vital/LICENSE +202 -0
- package/dist/twins/packs/vital/NOTICE +7 -0
- package/dist/twins/packs/vital/index.mjs +2 -0
- package/dist/twins/packs/volteridentity/LICENSE +202 -0
- package/dist/twins/packs/volteridentity/NOTICE +7 -0
- package/dist/twins/packs/volteridentity/index.mjs +2 -0
- package/dist/twins/packs/webrisk/LICENSE +202 -0
- package/dist/twins/packs/webrisk/NOTICE +7 -0
- package/dist/twins/packs/webrisk/index.mjs +2 -0
- package/dist/twins/packs/worldlabs/LICENSE +202 -0
- package/dist/twins/packs/worldlabs/NOTICE +7 -0
- package/dist/twins/packs/worldlabs/index.mjs +2 -0
- package/dist/twins/packs/x/LICENSE +202 -0
- package/dist/twins/packs/x/NOTICE +7 -0
- package/dist/twins/packs/x/index.mjs +63 -0
- package/dist/twins/packs/xai/LICENSE +202 -0
- package/dist/twins/packs/xai/NOTICE +7 -0
- package/dist/twins/packs/xai/index.mjs +4 -0
- package/dist/twins/packs/xidentity/LICENSE +202 -0
- package/dist/twins/packs/xidentity/NOTICE +8 -0
- package/dist/twins/packs/xidentity/index.mjs +209 -0
- package/dist/twins/packs/youtube/LICENSE +202 -0
- package/dist/twins/packs/youtube/NOTICE +7 -0
- package/dist/twins/packs/youtube/index.mjs +5 -0
- package/dist/worker.js +442 -18
- package/dist/world-host.js +928 -91
- package/package.json +5 -4
- package/dist/dashboard/assets/dashboard/bay-morning.png +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-afternoon.png +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-portrait.png +0 -0
- package/dist/dashboard/assets/dashboard/moonlit-coast.png +0 -0
- package/dist/dashboard/assets/next/static/chunks/2868-424d32cfc8ae81c9.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-f9fca2c08f779fa0.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-bc480c9258e5cc4d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-f04c0b236abaead3.js +0 -1
- package/dist/dashboard/assets/next/static/css/4af3c8ca0da0f48b.css +0 -1
- package/dist/dashboard/assets/next/static/css/6b8edde77e493a51.css +0 -1
- package/dist/dashboard/assets/next/static/media/bay-morning.1a9f358c.png +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-afternoon.3e7cea58.png +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-portrait.7941528f.png +0 -0
- package/dist/dashboard/assets/next/static/media/moonlit-coast.bbe901a1.png +0 -0
- /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → 8f121VqXS9LLPMmYd1SRn}/_buildManifest.js +0 -0
- /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → 8f121VqXS9LLPMmYd1SRn}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
@agenttwin/twin-youtube
|
|
2
|
+
|
|
3
|
+
Contains @volter/twin-youtube 0.1.37 by Volter (https://github.com/volter-ai),
|
|
4
|
+
licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
Modified by AgentTwin: bundled and minified into one file; only code reachable from the pack's
|
|
7
|
+
fetch factory is included; shared modules are imported from the AgentTwin twin engine.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{createRequire as __atReq}from'node:module';const require=__atReq(import.meta.url);
|
|
2
|
+
import{createHash as Qn,randomBytes as Xn}from"node:crypto";import{applyTwinWrite as Zn,projectResources as cn}from"../../engine/v2/volter_world-core.mjs";var wt="invalid-api-key",Tt="quota-exceeded-key",vt="rate-limited-key";function U(e,t){if(!e)return;let n=t.toLowerCase();for(let[i,o]of Object.entries(e))if(i.toLowerCase()===n)return o}function O(e,t,n,i){return{error:{code:e,message:t,errors:n,...i?{status:i}:{}}}}function It(e,t){return e.searchParams.get("key")??U(t,"x-goog-api-key")??void 0}function M(e){let t=U(e,"authorization");if(!t)return;let n=/^Bearer\s+(.+)$/i.exec(t.trim());return n?n[1]:void 0}function Sn(){let e="The request is missing a valid API key.";return O(403,e,[{message:e,domain:"global",reason:"forbidden"}],"PERMISSION_DENIED")}function An(){let e="API key not valid. Please pass a valid API key.";return O(400,e,[{message:e,domain:"global",reason:"badRequest"}],"INVALID_ARGUMENT")}function W(){let e="The request cannot be completed because you have exceeded your quota.";return O(403,e,[{domain:"youtube.quota",reason:"quotaExceeded",message:e}])}function En(){let e="Too many requests have been sent by this client in a given period of time.";return O(403,e,[{domain:"youtube.quota",reason:"rateLimitExceeded",message:e}])}function Re(e,t){let n=It(e,t);if(n===void 0){let i=M(t);return i?{ok:!0,key:`oauth:${i}`}:t===void 0?{ok:!0,key:"twin-implicit"}:{ok:!1,status:403,error:Sn()}}return!n.trim()||n===wt?{ok:!1,status:400,error:An()}:n===Tt?{ok:!1,status:403,error:W()}:n===vt?{ok:!1,status:403,error:En()}:{ok:!0,key:n}}import{join as N}from"node:path";import{blobDigest as St,getActiveBlobStore as S,readResourceBlobRange as Cn,resourceBlobSize as _n,worldPaths as Pn}from"../../engine/v2/volter_world-core.mjs";var Ue="youtube",At=/^[0-9a-f]{64}$/,Et=/^[A-Za-z0-9_-]+$/,$e=10080*60*1e3;function Oe(e){return Pn(Ue,e).resources}function De(e){return N("blobs","sha256",e.slice(0,2),e)}async function ke(e,t){let n=St(e),i=N(Oe(t),De(n));return await S().exists(i)||await S().put(i,e),{sha256:n,size:e.length}}async function j(e,t){return typeof e!="string"||!At.test(e)?null:_n(Ue,De(e),t)}async function G(e,t,n,i){return typeof e!="string"||!At.test(e)?null:Cn(Ue,De(e),t,n,i)}function Ct(e){if(!Et.test(e))throw new Error(`invalid YouTube upload session id: ${JSON.stringify(e)}`);return e}function xe(e){return N(Oe(e),"upload-sessions")}function Le(e,t){return N(xe(t),`${Ct(e)}.json`)}function re(e,t){return N(xe(t),Ct(e))}function Rn(e,t,n){return N(re(e,n),`${String(t).padStart(16,"0")}.part`)}async function Ne(e,t){await S().put(Le(e.id,t),new TextEncoder().encode(JSON.stringify(e)))}async function Be(e,t){if(!Et.test(e))return null;try{let n=await S().get(Le(e,t));if(n===null)return null;let i=JSON.parse(new TextDecoder().decode(n));return typeof i.id=="string"?i:null}catch{return null}}async function qe(e,t){try{await S().remove(`${re(e,t)}/`)}catch{}try{await S().remove(Le(e,t))}catch{}}async function _t(e,t){let n=`${xe(t)}/`,i=(await S().list(n)).filter(o=>o.startsWith(n)&&!o.slice(n.length).includes("/")&&o.endsWith(".json")).map(o=>o.slice(n.length,-5));for(let o of i){let r=await Be(o,t);(r===null||e-r.openedAt>$e)&&await qe(o,t)}}async function Pt(e,t){let n=`${re(e,t)}/`,i=[];for(let o of await S().list(n)){let r=/(\d{16})\.part$/.exec(o);r&&i.push({key:o,offset:Number(r[1]),size:await S().size(o)??0})}return i.sort((o,r)=>o.offset-r.offset)}async function Rt(e,t){let n=0;for(let i of await Pt(e,t)){if(i.offset!==n)break;n+=i.size}return n}async function Ut(e,t,n,i){n.length>0&&await S().put(Rn(e,t,i),n)}async function $t(e,t){let n=await Pt(e,t),i=n.reduce((a,s)=>a+s.size,0),o=new Uint8Array(i),r=0;for(let a of n){let s=await S().get(a.key);s!==null&&(o.set(s,r),r+=s.length)}return o.subarray(0,r)}async function Ot(e,t){try{await S().remove(`${re(e,t)}/`)}catch{}}function J(e,t,n){return N(Oe(n),`perform-${e}`,`${St(new TextEncoder().encode(t))}.json`)}async function Dt(e){try{let t=await S().get(e);return t===null?null:JSON.parse(new TextDecoder().decode(t))}catch{return null}}async function kt(e,t){return Dt(J("sessions",e,t))}async function xt(e,t,n){await S().put(J("sessions",e,n),new TextEncoder().encode(JSON.stringify(t)))}async function Lt(e,t){try{await S().remove(J("sessions",e,t))}catch{}}async function Nt(e,t){return(await Dt(J("thumbnails",e,t)))?.covered===!0}async function Bt(e,t){await S().put(J("thumbnails",e,t),new TextEncoder().encode(JSON.stringify({covered:!0})))}function Fe(e,t,n){let i=[],o=t;for(;o+8<=n;){let r=e.getUint32(o),a=String.fromCharCode(e.getUint8(o+4),e.getUint8(o+5),e.getUint8(o+6),e.getUint8(o+7)),s=8;if(r===1){if(o+16>n)break;r=Number(e.getBigUint64(o+8)),s=16}else r===0&&(r=n-o);if(r<s||o+r>n)break;i.push({type:a,start:o+s,end:o+r}),o+=r}return i}function qt(e){try{let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=Fe(t,0,e.byteLength).find(a=>a.type==="moov");if(!n)return{};let i={},o=Fe(t,n.start,n.end),r=o.find(a=>a.type==="mvhd");if(r){let a=t.getUint8(r.start),s=t.getUint32(r.start+(a===1?20:12)),u=a===1?Number(t.getBigUint64(r.start+24)):t.getUint32(r.start+16);s>0&&(i.durationSeconds=u/s)}for(let a of o.filter(s=>s.type==="trak")){let s=Fe(t,a.start,a.end).find(p=>p.type==="tkhd");if(!s)continue;let u=t.getUint8(s.start),f=s.start+(u===1?88:76);if(f+8>s.end)continue;let l=t.getUint32(f)/65536,h=t.getUint32(f+4)/65536;if(l>0&&h>0){i.width=Math.round(l),i.height=Math.round(h);break}}return i}catch{return{}}}import{RefusedWriteError as kn,assertBudgetGuardIntact as xn,confirmAction as Zi,deployableEntries as rt,observeResources as Ln,parentEntries as Nn,projectResources as Bn,twinResources as qn}from"../../engine/v2/volter_world-core.mjs";function ae(e){let t=typeof e=="string"?e:JSON.stringify(e),n=2166136261,i=16777619;for(let o=0;o<t.length;o++){let r=t.charCodeAt(o);n=Math.imul(n^r,16777619)>>>0,i=Math.imul(i+r+o,2246822507)>>>0}return(n.toString(16).padStart(8,"0")+i.toString(16).padStart(8,"0")).repeat(3).slice(0,24)}function B(e,t){let n=parseInt(ae(e).slice(0,8),16);return t<=0?0:n%t}var Yt={"activities.list":1,"captions.list":50,"captions.insert":400,"captions.update":450,"captions.delete":50,"channelBanners.insert":50,"channels.list":1,"channels.update":50,"channelSections.list":1,"channelSections.insert":50,"channelSections.update":50,"channelSections.delete":50,"comments.list":1,"comments.insert":50,"comments.update":50,"comments.setModerationStatus":50,"comments.delete":50,"commentThreads.list":1,"commentThreads.insert":50,"commentThreads.update":50,"guideCategories.list":1,"i18nLanguages.list":1,"i18nRegions.list":1,"members.list":1,"membershipsLevels.list":1,"playlistItems.list":1,"playlistItems.insert":50,"playlistItems.update":50,"playlistItems.delete":50,"playlists.list":1,"playlists.insert":50,"playlists.update":50,"playlists.delete":50,"search.list":1,"subscriptions.list":1,"subscriptions.insert":50,"subscriptions.delete":50,"thumbnails.set":50,"videoAbuseReportReasons.list":1,"videoCategories.list":1,"videos.list":1,"videos.insert":1,"videos.update":50,"videos.rate":50,"videos.getRating":1,"videos.reportAbuse":50,"videos.delete":50,"watermarks.set":50,"watermarks.unset":50},Ye=1e4,Me=100,je=100;function Ge(e,t){return e==="search"&&t==="list"?"search":e==="videos"&&t==="insert"?"upload":"units"}function Ve(e,t){return Yt[`${e}.${t}`]??1}var He=["auditDetails","brandingSettings","contentDetails","contentOwnerDetails","id","localizations","snippet","statistics","status","topicDetails"],ue=["contentDetails","fileDetails","id","liveStreamingDetails","localizations","paidProductPlacementDetails","player","processingDetails","recordingDetails","snippet","statistics","status","suggestions","topicDetails"],Q=["contentDetails","id","localizations","player","snippet","status"],le=["contentDetails","id","snippet","status"],Ke=["id","snippet"];function ze(e){return e===null?[]:e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}var Ft="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";function Un(e,t){let n="",i=0;for(;n.length<t;){let o=ae(`${e}:${i++}`);for(let r=0;r+1<o.length&&!(n.length>=t);r+=2)n+=Ft[parseInt(o.slice(r,r+2),16)%Ft.length]}return n}function de(e,t,n,i){for(let o=0;o<1e3;o++){let r=e+Un(`${e}:${n}:${o}`,t-e.length);if(!i.has(r))return r}throw new Error(`youtube: could not mint a free ${e} id after 1000 probes`)}var We=(e,t)=>de("UC",24,e,t),ce=(e,t)=>de("",11,e,t),Je=(e,t)=>de("PL",34,e,t),Qe=(e,t)=>de("",48,e,t);function Mt(e){return e.startsWith("UC")?`UU${e.slice(2)}`:`UU${e}`}function C(e){return`"${ae(e)}"`}function pe(e){return Buffer.from(`yt.offset:${e}`,"utf8").toString("base64url")}function Xe(e){let t;try{t=Buffer.from(e,"base64url").toString("utf8")}catch{return null}let n=/^yt\.offset:(\d+)$/.exec(t);if(!n)return null;let i=Number(n[1]);return Number.isSafeInteger(i)&&i>=0?i:null}function jt(e,t){let n=e==="channel"?`https://yt3.ggpht.com/ytc/${t}`:`https://i.ytimg.com/vi/${t}`;return e==="channel"?{default:{url:`${n}=s88-c-k-c0x00ffffff-no-rj`,width:88,height:88},medium:{url:`${n}=s240-c-k-c0x00ffffff-no-rj`,width:240,height:240},high:{url:`${n}=s800-c-k-c0x00ffffff-no-rj`,width:800,height:800}}:{default:{url:`${n}/default.jpg`,width:120,height:90},medium:{url:`${n}/mqdefault.jpg`,width:320,height:180},high:{url:`${n}/hqdefault.jpg`,width:480,height:360}}}var fe=[{id:"1",title:"Film & Animation",assignable:!0},{id:"2",title:"Autos & Vehicles",assignable:!0},{id:"10",title:"Music",assignable:!0},{id:"15",title:"Pets & Animals",assignable:!0},{id:"17",title:"Sports",assignable:!0},{id:"19",title:"Travel & Events",assignable:!0},{id:"20",title:"Gaming",assignable:!0},{id:"22",title:"People & Blogs",assignable:!0},{id:"23",title:"Comedy",assignable:!0},{id:"24",title:"Entertainment",assignable:!0},{id:"25",title:"News & Politics",assignable:!0},{id:"26",title:"Howto & Style",assignable:!0},{id:"27",title:"Education",assignable:!0},{id:"28",title:"Science & Technology",assignable:!0},{id:"29",title:"Nonprofits & Activism",assignable:!0},{id:"30",title:"Movies",assignable:!1}],Ze=[{id:"en",hl:"en",name:"English"},{id:"en-GB",hl:"en-GB",name:"English (United Kingdom)"},{id:"es",hl:"es",name:"Spanish"},{id:"fr",hl:"fr",name:"French"},{id:"de",hl:"de",name:"German"},{id:"ja",hl:"ja",name:"Japanese"},{id:"pt-BR",hl:"pt-BR",name:"Portuguese (Brazil)"}],X=[{id:"US",gl:"US",name:"United States"},{id:"GB",gl:"GB",name:"United Kingdom"},{id:"CA",gl:"CA",name:"Canada"},{id:"DE",gl:"DE",name:"Germany"},{id:"FR",gl:"FR",name:"France"},{id:"JP",gl:"JP",name:"Japan"},{id:"BR",gl:"BR",name:"Brazil"}],et=[{id:"N",label:"Sex or nudity"},{id:"V",label:"Violent or repulsive content"},{id:"H",label:"Hateful or abusive content"},{id:"S",label:"Spam or misleading"},{id:"C",label:"Child abuse"}];function he(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),i=Math.floor(t%3600/60),o=t%60;return`PT${n>0?`${n}H`:""}${i>0?`${i}M`:""}${o>0||n===0&&i===0?`${o}S`:""}`}function ye(e,t){let n=typeof t.title=="string"?t.title:`Channel ${e.slice(2,8)}`,i=typeof t.customUrl=="string"?t.customUrl:`@${n.toLowerCase().replace(/[^a-z0-9]+/g,"").slice(0,20)||"channel"}`;return{id:e,title:n,description:typeof t.description=="string"?t.description:`${n} on YouTube.`,customUrl:i,publishedAt:typeof t.publishedAt=="string"?t.publishedAt:"2015-03-04T12:00:00Z",...typeof t.country=="string"?{country:t.country}:{},thumbnails:t.thumbnails??jt("channel",e),viewCount:q(t.viewCount,B(`views:${e}`,9e7)+1e4),subscriberCount:q(t.subscriberCount,B(`subs:${e}`,9e5)+100),hiddenSubscriberCount:t.hiddenSubscriberCount===!0,videoCount:q(t.videoCount,B(`vids:${e}`,900)+1),uploadsPlaylistId:Mt(e),privacyStatus:typeof t.privacyStatus=="string"?t.privacyStatus:"public",topicCategories:Array.isArray(t.topicCategories)?t.topicCategories:["https://en.wikipedia.org/wiki/Technology"],...typeof t.keywords=="string"?{keywords:t.keywords}:{}}}function Z(e,t,n){let i=typeof n.title=="string"?n.title:`Video ${e}`;return{id:e,channelId:t.id,channelTitle:t.title,title:i,description:typeof n.description=="string"?n.description:`${i} \u2014 uploaded to YouTube.`,publishedAt:typeof n.publishedAt=="string"?n.publishedAt:"2021-06-01T09:00:00Z",thumbnails:n.thumbnails??jt("video",e),tags:Array.isArray(n.tags)?n.tags:[],categoryId:typeof n.categoryId=="string"?n.categoryId:"22",liveBroadcastContent:typeof n.liveBroadcastContent=="string"?n.liveBroadcastContent:"none",...typeof n.defaultAudioLanguage=="string"?{defaultAudioLanguage:n.defaultAudioLanguage}:{},duration:typeof n.duration=="string"?n.duration:he(B(`dur:${e}`,1200)+30),dimension:typeof n.dimension=="string"?n.dimension:"2d",definition:typeof n.definition=="string"?n.definition:"hd",caption:n.caption===!0,licensedContent:n.licensedContent!==!1,projection:typeof n.projection=="string"?n.projection:"rectangular",viewCount:q(n.viewCount,B(`vview:${e}`,5e6)+1),likeCount:q(n.likeCount,B(`vlike:${e}`,9e4)),favoriteCount:q(n.favoriteCount,0),commentCount:q(n.commentCount,B(`vcom:${e}`,4e3)),uploadStatus:typeof n.uploadStatus=="string"?n.uploadStatus:"processed",privacyStatus:typeof n.privacyStatus=="string"?n.privacyStatus:"public",license:typeof n.license=="string"?n.license:"youtube",embeddable:n.embeddable!==!1,publicStatsViewable:n.publicStatsViewable!==!1,madeForKids:n.madeForKids===!0}}function Gt(e,t,n){let i=typeof n.title=="string"?n.title:"Untitled playlist";return{id:e,channelId:t.id,channelTitle:t.title,title:i,description:typeof n.description=="string"?n.description:"",publishedAt:typeof n.publishedAt=="string"?n.publishedAt:"2021-06-01T09:00:00Z",privacyStatus:typeof n.privacyStatus=="string"?n.privacyStatus:"private",thumbnails:n.thumbnails??{},itemCount:0}}function Vt(e,t,n,i,o){return{id:e,playlistId:t.id,videoId:n.id,channelId:t.channelId,position:i,publishedAt:typeof o.publishedAt=="string"?o.publishedAt:"2021-06-01T09:00:00Z",title:n.title,description:n.description,thumbnails:n.thumbnails}}function q(e,t){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e))?Math.max(0,Math.floor(Number(e))):t}import{declareRateBudget as $n,rateBudgetPath as Wi,rateBudgetWeight as On,RateBudget as Dn}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as it}from"../../engine/v2/volter_world-core.mjs";var tt="youtube",Ht=3600*1e3,Kt=400,zt=60,Wt=300,F={list:1,write:50,caption:400,upload:1,thumbnail:50,other:2},me={windowMs:Ht,ceiling:Kt,burstCeiling:zt,defaultWeight:F.other,maxRetryAfterSeconds:Wt,rules:[{match:"^POST (/resumable)?/upload/youtube/v3/videos$",weight:F.upload},{match:"^POST (/resumable)?/upload/youtube/v3/thumbnails/set$",weight:F.thumbnail},{match:"^(POST|PUT|DELETE) /youtube/v3/captions",weight:F.caption},{match:"^(POST|PUT|DELETE) /youtube/v3/",weight:F.write},{match:"^GET /youtube/v3/",weight:F.list}],reason:`YouTube publishes a per-method QUOTA UNIT table (developers.google.com/youtube/v3/determine_quota_cost) and a daily allowance of "100 search.list calls, 100 videos.insert calls, and 10,000 units per day combined for all other endpoints" (developers.google.com/youtube/v3/getting-started, \xA7Quota usage). The weights below ARE those published units \u2014 a read 1, a write 50 \u2014 so this declaration reproduces the vendor's own currency rather than proxying it. The ceiling is that daily allowance spread evenly over a day and rounded down: 10,000/24 = 416.7, so 400 units per hour = 9,600 units/day, under the real quota even at a full-day sprint. The window is one hour because the kernel caps windows there and YouTube's limit is DAILY \u2014 the same mismatch webrisk records. The 60-unit/60s burst sub-ceiling is a SIZING DECISION, not a vendor figure (YouTube publishes no per-minute rate): it is exactly the austere fallback's burst at this pack's default weight, and no smaller, because one write costs 50 and a guard that refused every write would be broken rather than strict. UPLOADS (determine_quota_cost, updated 2026-09-15: "The search.list and videos.insert methods have their own quota buckets. Each of these methods has a default daily limit of 100 per day"; videos.insert: "Each call costs 1 quota"; thumbnails.set: 50): the kernel ledger has one currency and at most an hour's window, so the insert is priced at its own 1 and charged ONCE per upload, at the session start; the session's chunk PUTs are never charged. At 1 an insert, the 400-unit hour admits Google's whole documented day of 100 uploads inside any single hour, so the ledger never refuses an upload the vendor would take; the 100/day bucket itself is the vendor's, and its quotaExceeded answer arms the cooldown.`};$n(tt,me);function Jt(e){let t=e.indexOf("?");if(t<0)return{pathname:e,query:{}};let n={};for(let[i,o]of new URLSearchParams(e.slice(t+1)))n[i]=o;return{pathname:e.slice(0,t),query:n}}function nt(e,t){let{pathname:n,query:i}=Jt(t);return On(tt,`${(e||"GET").toUpperCase()} ${n}`,i)}var Y=class extends Dn{constructor(t={}){super({...t,vendor:tt})}};var Fn="1970-01-01T00:00:00.000Z",Te="https://www.googleapis.com";var ve=50;function at(e,t){let n=[];for(let i=0;i<e.length;i+=t)n.push(e.slice(i,i+t));return n}async function Yn(e,t){let n=[];for(let i of at(t.filter(Boolean),ve)){let r=await e({method:"GET",path:`/youtube/v3/channels?part=${encodeURIComponent("snippet,statistics,contentDetails,topicDetails")}&id=${encodeURIComponent(i.join(","))}&maxResults=50`});if(r.status<200||r.status>=300)continue;let a=r.data?.items??[];for(let s of a){if(!s.id)continue;let u=ye(s.id,{title:s.snippet?.title,description:s.snippet?.description,customUrl:s.snippet?.customUrl,publishedAt:s.snippet?.publishedAt,country:s.snippet?.country,thumbnails:s.snippet?.thumbnails,viewCount:s.statistics?.viewCount,subscriberCount:s.statistics?.subscriberCount,videoCount:s.statistics?.videoCount,hiddenSubscriberCount:s.statistics?.hiddenSubscriberCount,topicCategories:s.topicDetails?.topicCategories});n.push({type:"channel",id:s.id,fields:{...u}})}}return n}async function Mn(e,t){let n=[];for(let i of at(t.filter(Boolean),ve)){let r=await e({method:"GET",path:`/youtube/v3/playlists?part=${encodeURIComponent("snippet,status,contentDetails")}&id=${encodeURIComponent(i.join(","))}&maxResults=50`});if(r.status<200||r.status>=300)continue;let a=r.data?.items??[];for(let s of a){if(typeof s.id!="string"||!s.id)continue;let u=s.snippet??{};n.push({type:"playlist",id:s.id,fields:{id:s.id,channelId:u.channelId??"",channelTitle:u.channelTitle??"",title:u.title??"Untitled playlist",description:u.description??"",publishedAt:u.publishedAt??"2021-06-01T09:00:00Z",privacyStatus:(s.status??{}).privacyStatus??"private",thumbnails:u.thumbnails??{},itemCount:Number((s.contentDetails??{}).itemCount??0)}})}}return n}async function jn(e,t){let n=[];for(let i of at(t.filter(Boolean),ve)){let r=await e({method:"GET",path:`/youtube/v3/videos?part=${encodeURIComponent("snippet,contentDetails,statistics,status")}&id=${encodeURIComponent(i.join(","))}&maxResults=50`});if(r.status<200||r.status>=300)continue;let a=r.data?.items??[];for(let s of a){if(!s.id)continue;let u={id:s.snippet?.channelId??"",title:s.snippet?.channelTitle??""},f=Z(s.id,u,{title:s.snippet?.title,description:s.snippet?.description,publishedAt:s.snippet?.publishedAt,thumbnails:s.snippet?.thumbnails,tags:s.snippet?.tags,categoryId:s.snippet?.categoryId,liveBroadcastContent:s.snippet?.liveBroadcastContent,duration:s.contentDetails?.duration,dimension:s.contentDetails?.dimension,definition:s.contentDetails?.definition,caption:s.contentDetails?.caption==="true",licensedContent:s.contentDetails?.licensedContent,projection:s.contentDetails?.projection,viewCount:s.statistics?.viewCount,likeCount:s.statistics?.likeCount,favoriteCount:s.statistics?.favoriteCount,commentCount:s.statistics?.commentCount,uploadStatus:s.status?.uploadStatus,privacyStatus:s.status?.privacyStatus,license:s.status?.license,embeddable:s.status?.embeddable,publicStatsViewable:s.status?.publicStatsViewable,madeForKids:s.status?.madeForKids});n.push({type:"video",id:s.id,fields:{...f}})}}return n}async function Qt(e,t={}){let n=await Yn(e,t.channelIds??[]),i=await jn(e,t.videoIds??[]),o=await Mn(e,t.playlistIds??[]),r=[...n,...i,...o],a=(s=>Ln("youtube",r,{...t.root!==void 0?{root:t.root}:{},at:s,batch:`obs:youtube:${s}`}))(t.occurredAt??Fn);return{observed:r.length,deltasAppended:a.appended}}function Xt(e){return null}function Zt(e){return async t=>{let n=await e({method:t.method,path:t.path,headers:{accept:"application/json","content-type":"application/json",authorization:"Bearer twin"},...t.body===void 0?{}:{body:JSON.stringify(t.body)}}),i={};try{i=JSON.parse(n.body||"{}")}catch{i={}}return{status:n.status,data:i}}}async function en(e,t={}){let n=[],i=[],o=[];for(let r of qn("youtube",t.root))r.type==="channel"?n.push(r.id):r.type==="video"?i.push(r.id):r.type==="playlist"&&o.push(r.id);return Qt(Zt(e),{channelIds:[...new Set(n)].sort(),videoIds:[...new Set(i)].sort(),playlistIds:[...new Set(o)].sort(),...t.root!==void 0?{root:t.root}:{},occurredAt:t.occurredAt??new Date().toISOString()})}var Gn=16*256*1024,be=5,ge=500,Vn=6e4,ee=e=>new Promise(t=>setTimeout(t,e));function tn(e,t){if(e){for(let[n,i]of Object.entries(e))if(n.toLowerCase()===t)return i}}function Hn(e,t=new Y){let n=xn(t,Y,"budgetedYouTubeExecute");return async i=>{let o=nt(i.method,i.path),r=n.checkBudget(o),a=await e(i);try{n.recordCall(o,Object.fromEntries(Object.entries(a.headers??{}).map(([s,u])=>[s.toLowerCase(),u])),{status:a.status,reservation:r})}catch(s){if(a.status<200||a.status>=300)throw s}return a}}function Kn(e){let t=new URL(e,Te),n=t.pathname.indexOf("/upload/youtube/v3/");if(n<0)throw new Error(`youtube videos.insert answered a session URI outside /upload/youtube/v3/: ${t.pathname}`);return`${t.pathname.slice(n)}${t.search}`}async function we(e,t){for(let n=0;;)try{return await e(t)}catch(i){if(i instanceof it){if(i.kind!=="burst"||n+i.retryAfterMs>Vn)throw i;await ee(i.retryAfterMs),n+=i.retryAfterMs;continue}return null}}function ot(e){let t=/bytes=0-(\d+)/.exec(tn(e.headers,"range")??"");return t?Number(t[1])+1:0}function st(e){let t={};try{t=JSON.parse(e.body||"{}")}catch{}if(typeof t.id!="string")throw new Error(`youtube videos.insert answered ${e.status} without a video id`);return t}async function zn(e,t,n,i){let o=n.fields??{},r=o._content_sha256,a=await j(r,i);if(a===null)throw new Error(`youtube: video ${n.subject.id} has no stored media to upload (_content_sha256 ${String(r??"absent")})`);let s=typeof o._content_type=="string"?o._content_type:"video/*",u={snippet:{title:o.title,description:o.description??"",...Array.isArray(o.tags)&&o.tags.length>0?{tags:o.tags}:{},...typeof o.categoryId=="string"?{categoryId:o.categoryId}:{},...typeof o.defaultAudioLanguage=="string"?{defaultAudioLanguage:o.defaultAudioLanguage}:{}},status:{privacyStatus:o.privacyStatus??"private",...typeof o.license=="string"?{license:o.license}:{},...typeof o.embeddable=="boolean"?{embeddable:o.embeddable}:{},...typeof o.publicStatsViewable=="boolean"?{publicStatsViewable:o.publicStatsViewable}:{},selfDeclaredMadeForKids:o.madeForKids===!0}},f=b=>we(t,{method:"PUT",path:b,headers:{"content-range":`bytes */${a}`},body:new Uint8Array(0)}),l=null,h=0,p=null,d=await kt(n.id,i);if(d&&d.sha256===r&&d.size===a){let b=null;for(let T=0;b=await f(d.session),!(b!==null&&b.status<500);T+=1){if(T>=be)throw new Error(`youtube videos.insert: the saved upload session did not answer ${T+1} status queries${b?` (HTTP ${b.status})`:""}; it may have completed, so no new session is opened \u2014 perform again`);await ee(ge*2**T)}if(b.status===200||b.status===201)p=st(b);else if(b.status===308)l=d.session,h=ot(b);else if(b.status!==404)throw new Error(`youtube videos.insert: the saved upload session answered HTTP ${b.status} ${b.body.slice(0,200)}`)}if(p===null&&l===null){let b=null;for(let c=0;b=await we(e,{method:"POST",path:"/upload/youtube/v3/videos?uploadType=resumable&part=snippet,status,contentDetails",headers:{accept:"application/json","content-type":"application/json; charset=UTF-8","x-upload-content-length":String(a),"x-upload-content-type":s},body:JSON.stringify(u)}),!(b!==null&&b.status<500);c+=1){if(c>=be)throw new Error(`youtube videos.insert (resumable start) failed ${c+1} times: ${b?`HTTP ${b.status}`:"no answer"}`);await ee(ge*2**c)}let T=tn(b.headers,"location");if(b.status!==200||!T)throw new Error(`youtube videos.insert (resumable start) refused: HTTP ${b.status} ${b.body.slice(0,300)}`);l=Kn(T),await xt(n.id,{session:l,sha256:String(r),size:a},i)}let y=0,m=0;for(;p===null;){let b=Math.min(a,h+Gn),T=await G(r,h,b-1,i)??new Uint8Array(0),c=await we(t,{method:"PUT",path:l,headers:{"content-type":s,"content-range":`bytes ${h}-${b-1}/${a}`},body:T});if(c!==null&&(c.status===200||c.status===201)){p=st(c);break}if(c!==null&&c.status===308){let v=ot(c);if(m=v>h?0:m+1,m>=2)throw new Error(`youtube videos.insert: the session held ${v} bytes after two chunks sent from byte ${h}; the upload is not advancing`);h=v,y=0;continue}if(c!==null&&c.status<500)throw new Error(`youtube videos.insert (chunk ${h}-${b-1}) refused: HTTP ${c.status} ${c.body.slice(0,300)}`);for(;;){if(y+=1,y>be)throw new Error(`youtube videos.insert: the upload failed ${y} times in a row at byte ${h}${c?` (HTTP ${c.status})`:""}`);await ee(ge*2**(y-1));let v=await f(l);if(!(v===null||v.status>=500)){if(v.status===200||v.status===201){p=st(v);break}if(v.status===308){h=ot(v);break}throw new Error(`youtube videos.insert (status query) refused: HTTP ${v.status} ${v.body.slice(0,300)}`)}}}await Lt(n.id,i);let w=String(p.id),R=Bn("youtube",i).find(b=>b.type==="video"&&b.id===n.subject.id);if(R&&typeof R._thumbnail_sha256=="string"){let b=rt("youtube",i).filter(T=>T.operation==="video.thumbnail"&&T.subject.id===n.subject.id);try{await nn(e,w,R._thumbnail_sha256,String(R._thumbnail_type??"image/jpeg"),i);for(let T of b)await Bt(T.id,i)}catch{}}return{externalId:w,data:p}}async function nn(e,t,n,i,o){let r=await j(n,o),a=r===null?null:await G(n,0,r-1,o);if(!a)throw new Error("youtube thumbnails.set: the custom thumbnail has no stored image");for(let s=0;;s+=1){let u=await we(e,{method:"POST",path:`/upload/youtube/v3/thumbnails/set?videoId=${encodeURIComponent(t)}&uploadType=media`,headers:{"content-type":i},body:a});if(u!==null&&u.status>=200&&u.status<300)try{return JSON.parse(u.body||"{}")}catch{return{}}if(u!==null&&u.status<500||s>=be)throw new Error(`youtube thumbnails.set refused: ${u?`HTTP ${u.status} ${u.body.slice(0,200)}`:"no answer"}`);await ee(ge*2**s)}}async function Wn(e,t,n){let i=t.fields??{},o=String(t.subject.id),r=n.resolve("video",o);if(r===o&&!Jn(o,n.root))throw rt(n.service??"youtube",n.root).some(f=>f.operation==="video.create"&&String(f.subject?.id)===o)?new Error(`youtube: video ${o} is not uploaded yet; its thumbnail is set once the upload is performed`):new kn("youtube.video.thumbnail",`video ${o} is not at YouTube (its upload was reverted or refused), so there is no video to set a thumbnail on`,t.id);let a=i._thumbnail_sha256;if(typeof a!="string")throw new Error(`youtube: video.thumbnail ${o} names no stored image`);return await Nt(t.id,n.root)?{externalId:r}:rt("youtube",n.root).some(u=>u.operation==="video.thumbnail"&&u.subject.id===o&&u.id!==t.id&&u.occurredAt>t.occurredAt)?{externalId:r}:(await nn(e,r,a,String(i._thumbnail_type??"image/jpeg"),n.root),{externalId:r})}function Jn(e,t){return Nn("youtube",t).some(n=>n.subject.type==="video"&&n.subject.id===e&&n.batch!==void 0)}async function on(e,t,n,i){let o=Hn(e,i??new Y(n.credential!==void 0?{token:n.credential}:n.root!==void 0?{root:n.root}:{}));if(t.operation==="video.create")return zn(o,e,t,n.root);if(t.operation==="video.thumbnail")return Wn(o,t,n);let r=Zt(o),a=Xt(t);if(!a)return{externalId:t.subject.id};let s=await r(a);if(s.status<200||s.status>=300)throw new Error(`youtube ${a.method} ${a.path} refused: HTTP ${s.status}`);return{externalId:t.subject.id,data:s.data??{}}}var ct="youtube",L="1970-01-01T00:00:00.000Z",ne="daily";function E(e,t,n,i){return{status:e,body:O(e,t,n,i)}}function g(e,t,n,i="youtube.parameter"){return E(400,t,[{domain:i,reason:e,message:t,...n!==void 0?{location:n,locationType:"parameter"}:{}}])}function A(e,t,n){return E(404,t,[{domain:n,reason:e,message:t}])}function D(e,t,n){return E(403,t,[{domain:n,reason:e,message:t}])}function ei(e){return g("unknownPart",`'${e}'`,"part","youtube.part")}function ti(){return g("missingRequiredParameter","No part selected.","part")}function oe(){let e="Login Required.";return E(401,e,[{domain:"global",reason:"required",message:e,locationType:"header",location:"Authorization"}],"UNAUTHENTICATED")}function pn(){return E(401,"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential.",[{domain:"global",reason:"authError",message:"Invalid Credentials",locationType:"header",location:"Authorization"}],"UNAUTHENTICATED")}function te(e){let{type:t,updatedAt:n,deleted:i,...o}=e;return o}function k(e,t){let n=cn(ct,e),i=new Set;for(let a of n)String(a.type).startsWith("_")||i.add(String(a.id));let o=a=>n.filter(s=>s.type===a&&s.deleted!==!0),r=new Map(o(hn).map(a=>[String(a.id),a]));return{channels:o("channel").map(a=>{let s=te(a),u=r.get(s.id);return u&&typeof u.videoCount=="number"?{...s,videoCount:u.videoCount}:s}),videos:o("video").map(a=>{let s=te(a);return t===void 0?s:bn(s,t)}),playlists:o("playlist").map(a=>te(a)),playlistItems:o("playlistItem").map(a=>te(a)),tokens:o(fn).map(a=>te(a)),taken:i}}var fn="_token",ie="_quota",hn="_channelStats";function pt(e){return Qn("sha256").update(e).digest("hex")}function Ce(e,t){let n=M(t);if(n===void 0)return;let i=pt(n);return e.tokens.find(o=>o.id===i)}function ni(e){return{req:e,seq:0}}function ii(e){let t=Date.parse(e.req.occurredAt??L),n=Number.isFinite(t)?t:Date.parse(L);return new Date(n+e.seq++).toISOString()}async function I(e,t,n,i,o){await Zn(ct,{operation:t,subjectType:n,subjectId:i,fields:o,occurredAt:ii(e),actor:{kind:"system"}},e.req.root)}async function ut(e,t,n,i){await I(e,t,n,i,{deleted:!0})}function ft(e){let t=cn(ct,e).find(n=>n.type===ie&&n.id===ne);return{unitsUsed:P(t?.unitsUsed,0),searchCalls:P(t?.searchCalls,0),uploadCalls:P(t?.uploadCalls,0),unitsAllowance:P(t?.unitsAllowance,Ye),searchAllowance:P(t?.searchAllowance,Me),uploadAllowance:P(t?.uploadAllowance,je)}}function P(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}async function Se(e,t,n){if(e.req.readOnly)return null;let i=ft(e.req.root),o=Ge(t,n),r=Ve(t,n);return o==="search"?i.searchCalls+1>i.searchAllowance?{status:403,body:W()}:(await I(e,"quota.spend",ie,ne,{...i,searchCalls:i.searchCalls+1}),null):o==="upload"?i.uploadCalls+1>i.uploadAllowance?{status:403,body:W()}:(await I(e,"quota.spend",ie,ne,{...i,uploadCalls:i.uploadCalls+1}),null):i.unitsUsed+r>i.unitsAllowance?{status:403,body:W()}:(await I(e,"quota.spend",ie,ne,{...i,unitsUsed:i.unitsUsed+r}),null)}function $(e,t,n,i={}){return{status:200,body:{kind:e,etag:C([e,t,n]),...i,pageInfo:n,items:t}}}function V(e,t,n){let o={page:e.slice(n,n+t)};return n+t<e.length&&(o.next=pe(n+t)),n>0&&(o.prev=pe(Math.max(0,n-t))),o}function H(e,t){return{...t.next!==void 0?{nextPageToken:t.next}:{},...t.prev!==void 0?{prevPageToken:t.prev}:{},...e}}function ht(e,t){return e.searchParams.getAll(t).flatMap(n=>ze(n))}function _(e,t){let n=ht(e,"part");if(n.length===0)return{error:ti()};for(let i of n)if(!t.includes(i))return{error:ei(i)};return{parts:n}}function K(e,t){let n=e.searchParams.get("maxResults");if(n===null)return t;let i=Number(n);return Number.isFinite(i)?Math.max(0,Math.min(50,Math.floor(i))):t}function z(e){let t=e.searchParams.get("pageToken");if(t===null)return{offset:0};let n=Xe(t);return n===null?{error:g("invalidPageToken","The request specifies an invalid page token.","pageToken")}:{offset:n}}function _e(e,t){let n=t.filter(o=>e.searchParams.getAll(o).length>0);if(n.length===0)return"none";if(n.length>1)return"many";let i=n[0];return{name:i,value:e.searchParams.getAll(i).join(",")}}function yt(e){let t=`Incompatible parameters specified in the request: ${e.join(", ")}`;return g("incompatibleParameters",t)}function oi(e,t){let n={kind:"youtube#channel",etag:C(e),id:e.id};return t.includes("snippet")&&(n.snippet={title:e.title,description:e.description,customUrl:e.customUrl,publishedAt:e.publishedAt,thumbnails:e.thumbnails,localized:{title:e.title,description:e.description},...e.country!==void 0?{country:e.country}:{}}),t.includes("statistics")&&(n.statistics={viewCount:String(e.viewCount),subscriberCount:String(e.subscriberCount),hiddenSubscriberCount:e.hiddenSubscriberCount,videoCount:String(e.videoCount)}),t.includes("contentDetails")&&(n.contentDetails={relatedPlaylists:{likes:`LL${e.id.startsWith("UC")?e.id.slice(2):e.id}`,uploads:e.uploadsPlaylistId}}),t.includes("status")&&(n.status={privacyStatus:e.privacyStatus,isLinked:!0,longUploadsStatus:"allowed",madeForKids:!1}),t.includes("topicDetails")&&(n.topicDetails={topicCategories:e.topicCategories}),t.includes("brandingSettings")&&(n.brandingSettings={channel:{title:e.title,description:e.description,...e.keywords!==void 0?{keywords:e.keywords}:{},...e.country!==void 0?{country:e.country}:{}}}),t.includes("localizations")&&(n.localizations={}),n}function Pe(e,t){if(e._thumbnail_sha256===void 0)return e.thumbnails;let n=`${t??"https://i.ytimg.com"}/vi/${e.id}`;return{default:{url:`${n}/default.jpg`,width:120,height:90},medium:{url:`${n}/mqdefault.jpg`,width:320,height:180},high:{url:`${n}/hqdefault.jpg`,width:480,height:360},standard:{url:`${n}/sddefault.jpg`,width:640,height:480},maxres:{url:`${n}/maxresdefault.jpg`,width:1280,height:720}}}function Ae(e,t,n){let i={kind:"youtube#video",etag:C(e),id:e.id};return t.includes("snippet")&&(i.snippet={publishedAt:e.publishedAt,channelId:e.channelId,title:e.title,description:e.description,thumbnails:Pe(e,n),channelTitle:e.channelTitle,tags:e.tags,categoryId:e.categoryId,liveBroadcastContent:e.liveBroadcastContent,localized:{title:e.title,description:e.description},...e.defaultAudioLanguage!==void 0?{defaultAudioLanguage:e.defaultAudioLanguage}:{}}),t.includes("contentDetails")&&(i.contentDetails={duration:e.duration,dimension:e.dimension,definition:e.definition,caption:String(e.caption),licensedContent:e.licensedContent,contentRating:{},projection:e.projection}),t.includes("statistics")&&(i.statistics={viewCount:String(e.viewCount),likeCount:String(e.likeCount),favoriteCount:String(e.favoriteCount),commentCount:String(e.commentCount)}),t.includes("status")&&(i.status={uploadStatus:e.uploadStatus,privacyStatus:e.privacyStatus,license:e.license,embeddable:e.embeddable,publicStatsViewable:e.publicStatsViewable,madeForKids:e.madeForKids}),t.includes("player")&&(i.player={embedHtml:`<iframe width="480" height="270" src="//www.youtube.com/embed/${e.id}" frameborder="0" allowfullscreen></iframe>`}),t.includes("topicDetails")&&(i.topicDetails={topicCategories:[]}),t.includes("localizations")&&(i.localizations={}),t.includes("liveStreamingDetails")&&(i.liveStreamingDetails={}),t.includes("recordingDetails")&&(i.recordingDetails={}),t.includes("paidProductPlacementDetails")&&(i.paidProductPlacementDetails={hasPaidProductPlacement:!1}),i}function mt(e,t){let n={kind:"youtube#playlist",etag:C(e),id:e.id};return t.includes("snippet")&&(n.snippet={publishedAt:e.publishedAt,channelId:e.channelId,title:e.title,description:e.description,thumbnails:e.thumbnails,channelTitle:e.channelTitle,localized:{title:e.title,description:e.description}}),t.includes("status")&&(n.status={privacyStatus:e.privacyStatus}),t.includes("contentDetails")&&(n.contentDetails={itemCount:e.itemCount}),t.includes("player")&&(n.player={embedHtml:`<iframe width="640" height="360" src="//www.youtube.com/embed/videoseries?list=${e.id}" frameborder="0" allowfullscreen></iframe>`}),t.includes("localizations")&&(n.localizations={}),n}function lt(e,t){let n={kind:"youtube#playlistItem",etag:C(e),id:e.id};return t.includes("snippet")&&(n.snippet={publishedAt:e.publishedAt,channelId:e.channelId,title:e.title,description:e.description,thumbnails:e.thumbnails,playlistId:e.playlistId,position:e.position,resourceId:{kind:"youtube#video",videoId:e.videoId}}),t.includes("contentDetails")&&(n.contentDetails={videoId:e.videoId,videoPublishedAt:e.publishedAt}),t.includes("status")&&(n.status={privacyStatus:e.privacyStatus??"public"}),n}var si=["fileDetails","processingDetails","suggestions"],ri=["auditDetails","contentOwnerDetails"];function ai(e,t,n){let i=_(e,He);if("error"in i)return i.error;let o=i.parts.find(p=>ri.includes(p));if(o)return D("forbidden",`The request is not properly authorized to retrieve the channel's ${o}.`,"youtube.channel");let r=_e(e,["id","forHandle","forUsername","mine","managedByMe"]);if(r==="none")return g("missingRequiredParameter","No filter selected. Expected one of: forUsername, managedByMe, id, mine, forHandle","");if(r==="many"){let p="A maximum of one of the following filters may be specified: id, categoryId, mine, managedByMe, forHandle, forUsername.";return E(400,p,[{domain:"youtube.channel",reason:"invalidCriteria",message:p}])}if(r.name==="managedByMe")return oe();let a;if(r.name==="mine"){if(M(n)===void 0)return oe();let p=Ce(t,n);if(!p)return pn();a=t.channels.filter(d=>d.id===p.channelId)}else if(r.name==="id")a=r.value.split(",").map(d=>d.trim()).filter(Boolean).map(d=>t.channels.find(y=>y.id===d)).filter(d=>d!==void 0);else if(r.name==="forHandle"){let p=r.value.startsWith("@")?r.value:`@${r.value}`;a=t.channels.filter(d=>d.customUrl.toLowerCase()===p.toLowerCase())}else a=t.channels.filter(p=>p.customUrl.replace(/^@/,"").toLowerCase()===r.value.toLowerCase());let s=K(e,5),u=z(e);if("error"in u)return u.error;let{page:f,next:l,prev:h}=V(a,s,u.offset);return $("youtube#channelListResponse",f.map(p=>oi(p,i.parts)),{totalResults:a.length,resultsPerPage:s},H({},{next:l,prev:h}))}function ui(e,t,n){let i=_(e,ue);if("error"in i)return i.error;if(i.parts.find(p=>si.includes(p)))return D("forbidden","The request is not properly authorized to access video file or processing information. Note that the fileDetails, processingDetails, and suggestions parts are only available to that video's owner.","youtube.video");let r=_e(e,["id","chart","myRating"]);if(r==="none")return g("missingRequiredParameter","No filter selected. Expected one of: myRating, chart, id","");if(r==="many")return yt(["id","chart","myRating"].filter(p=>e.searchParams.get(p)!==null));if(r.name==="myRating")return oe();let a;if(r.name==="id")a=r.value.split(",").map(d=>d.trim()).filter(Boolean).map(d=>t.videos.find(y=>y.id===d)).filter(d=>d!==void 0);else{if(r.value!=="mostPopular"){let y="The requested video chart is unsupported or is not available.";return E(400,y,[{domain:"youtube.video",reason:"videoChartNotFound",message:y,location:"chart",locationType:"parameter"}])}let p=e.searchParams.get("regionCode"),d=e.searchParams.get("videoCategoryId");if(a=t.videos.filter(y=>d===null||d==="0"||y.categoryId===d).slice().sort((y,m)=>m.viewCount-y.viewCount||y.id.localeCompare(m.id)),p!==null&&!X.some(y=>y.gl===p))return g("invalidFilters","The request specifies an invalid filter parameter.","regionCode")}let s=K(e,5),u=z(e);if("error"in u)return u.error;let{page:f,next:l,prev:h}=V(a,s,u.offset);return $("youtube#videoListResponse",f.map(p=>Ae(p,i.parts,n)),{totalResults:a.length,resultsPerPage:s},H({},{next:l,prev:h}))}function li(e,t,n){let i=_(e,Ke);if("error"in i)return i.error;let o=(e.searchParams.get("q")??"").trim().toLowerCase(),r=ht(e,"type"),a=r.length>0?r:["video","channel","playlist"];for(let c of a)if(!["video","channel","playlist"].includes(c))return g("invalidFilters","The request specifies an invalid filter parameter.","type");let s=e.searchParams.get("channelId"),u=e.searchParams.get("publishedAfter"),f=e.searchParams.get("publishedBefore"),l=e.searchParams.get("order")??"relevance";if(!["date","rating","relevance","title","videoCount","viewCount"].includes(l))return g("invalidFilters","The request specifies an invalid filter parameter.","order");let h=c=>o===""||c.toLowerCase().includes(o),p=c=>(u===null||c>=u)&&(f===null||c<=f),d=[];if(a.includes("video"))for(let c of t.videos)!h(`${c.title} ${c.description}`)||!p(c.publishedAt)||s!==null&&c.channelId!==s||d.push({kind:"youtube#video",idField:"videoId",id:c.id,publishedAt:c.publishedAt,channelId:c.channelId,title:c.title,description:c.description,thumbnails:Pe(c,n),channelTitle:c.channelTitle,sortViews:c.viewCount});if(a.includes("channel"))for(let c of t.channels)!h(`${c.title} ${c.description}`)||!p(c.publishedAt)||s!==null&&c.id!==s||d.push({kind:"youtube#channel",idField:"channelId",id:c.id,publishedAt:c.publishedAt,channelId:c.id,title:c.title,description:c.description,thumbnails:c.thumbnails,channelTitle:c.title,sortViews:c.viewCount});if(a.includes("playlist"))for(let c of t.playlists)!h(`${c.title} ${c.description}`)||!p(c.publishedAt)||s!==null&&c.channelId!==s||d.push({kind:"youtube#playlist",idField:"playlistId",id:c.id,publishedAt:c.publishedAt,channelId:c.channelId,title:c.title,description:c.description,thumbnails:c.thumbnails,channelTitle:c.channelTitle,sortViews:0});d.sort((c,v)=>l==="date"?v.publishedAt.localeCompare(c.publishedAt)||c.id.localeCompare(v.id):l==="title"?c.title.localeCompare(v.title)||c.id.localeCompare(v.id):l==="viewCount"&&v.sortViews-c.sortViews||c.id.localeCompare(v.id));let y=K(e,5),m=z(e);if("error"in m)return m.error;let{page:w,next:R,prev:b}=V(d,y,m.offset),T=w.map(c=>({kind:"youtube#searchResult",etag:C(c),id:{kind:c.kind,[c.idField]:c.id},...i.parts.includes("snippet")?{snippet:{publishedAt:c.publishedAt,channelId:c.channelId,title:c.title,description:c.description,thumbnails:c.thumbnails,channelTitle:c.channelTitle,liveBroadcastContent:"none"}}:{}}));return $("youtube#searchListResponse",T,{totalResults:d.length,resultsPerPage:y},H({regionCode:e.searchParams.get("regionCode")??"US"},{next:R,prev:b}))}function di(e,t){let n=_(e,Q);if("error"in n)return n.error;let i=_e(e,["id","channelId","mine"]);if(i==="none")return g("missingRequiredParameter","No filter selected. Expected one of: channelId, id, mine","");if(i==="many")return yt(["id","channelId","mine"].filter(l=>e.searchParams.get(l)!==null));if(i.name==="mine")return oe();let o=i.name==="id"?i.value.split(",").map(l=>l.trim()).filter(Boolean).map(l=>t.playlists.find(h=>h.id===l)).filter(l=>l!==void 0):t.playlists.filter(l=>l.channelId===i.value),r=K(e,5),a=z(e);if("error"in a)return a.error;let{page:s,next:u,prev:f}=V(o,r,a.offset);return $("youtube#playlistListResponse",s.map(l=>mt(l,n.parts)),{totalResults:o.length,resultsPerPage:r},H({},{next:u,prev:f}))}function ci(e,t,n){let i=_(e,le);if("error"in i)return i.error;let o=_e(e,["id","playlistId"]);if(o==="none")return g("missingRequiredParameter","No filter selected. Expected one of: id, playlistId","");if(o==="many")return yt(["id","playlistId"]);let r;if(o.name==="id")r=o.value.split(",").map(p=>p.trim()).filter(Boolean).map(p=>t.playlistItems.find(d=>d.id===p)).filter(p=>p!==void 0);else{let h=t.channels.find(p=>p.uploadsPlaylistId===o.value);if(h){let d=t.videos.filter(T=>T.channelId===h.id).sort((T,c)=>c.publishedAt.localeCompare(T.publishedAt)||T.id.localeCompare(c.id)).map((T,c)=>({id:btoa(`${o.value}.${T.id}`).replace(/=+$/,""),privacyStatus:T.privacyStatus,playlistId:o.value,videoId:T.id,channelId:h.id,position:c,publishedAt:T.publishedAt,title:T.title,description:T.description,thumbnails:Pe(T,n)})),y=K(e,5),m=z(e);if("error"in m)return m.error;let{page:w,next:R,prev:b}=V(d,y,m.offset);return $("youtube#playlistItemListResponse",w.map(T=>lt(T,i.parts)),{totalResults:d.length,resultsPerPage:y},H({},{next:R,prev:b}))}if(!t.playlists.some(p=>p.id===o.value))return A("playlistNotFound","The playlist identified with the request's playlistId parameter cannot be found.","youtube.playlistItem");r=t.playlistItems.filter(p=>p.playlistId===o.value).sort((p,d)=>p.position-d.position)}let a=K(e,5),s=z(e);if("error"in s)return s.error;let{page:u,next:f,prev:l}=V(r,a,s.offset);return $("youtube#playlistItemListResponse",u.map(h=>lt(h,i.parts)),{totalResults:r.length,resultsPerPage:a},H({},{next:f,prev:l}))}function pi(e){let t=_(e,["snippet","id"]);if("error"in t)return t.error;let n=ht(e,"id"),i=e.searchParams.get("regionCode");if(n.length===0&&i===null)return g("missingRequiredParameter","No filter selected. Expected one of: id, regionCode","");if(i!==null&&!X.some(a=>a.gl===i))return g("invalidFilters","The request specifies an invalid filter parameter.","regionCode");let o=n.length===0?null:new Set(n),r=fe.filter(a=>o===null||o.has(a.id)).map(a=>({kind:"youtube#videoCategory",etag:C(a),id:a.id,...t.parts.includes("snippet")?{snippet:{title:a.title,assignable:a.assignable,channelId:"UCBR8-60-B28hp2BmDPdntcQ"}}:{}}));return $("youtube#videoCategoryListResponse",r,{totalResults:r.length,resultsPerPage:r.length})}function fi(e){let t=_(e,["snippet"]);if("error"in t)return t.error;let n=Ze.map(i=>({kind:"youtube#i18nLanguage",etag:C(i),id:i.id,snippet:{hl:i.hl,name:i.name}}));return $("youtube#i18nLanguageListResponse",n,{totalResults:n.length,resultsPerPage:n.length})}function hi(e){let t=_(e,["snippet"]);if("error"in t)return t.error;let n=X.map(i=>({kind:"youtube#i18nRegion",etag:C(i),id:i.id,snippet:{gl:i.gl,name:i.name}}));return $("youtube#i18nRegionListResponse",n,{totalResults:n.length,resultsPerPage:n.length})}function yi(e){let t=_(e,["snippet","id"]);if("error"in t)return t.error;let n=et.map(i=>({kind:"youtube#videoAbuseReportReason",etag:C(i),id:i.id,...t.parts.includes("snippet")?{snippet:{label:i.label,secondaryReasons:[]}}:{}}));return $("youtube#videoAbuseReportReasonListResponse",n,{totalResults:n.length,resultsPerPage:n.length})}function x(e){if(!e?.trim())return{};try{let t=JSON.parse(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function Ee(e,t){let n=Ce(e,t),i=n?e.channels.find(r=>r.id===n.channelId):void 0;if(i)return{id:i.id,title:i.title};let o=e.channels[0];return o?{id:o.id,title:o.title}:{id:"UCtwinDefaultChannel00",title:"Twin Channel"}}function se(e,t,n){return e.req.headers===void 0?!0:Ce(t,e.req.headers)?.channelId===n}function yn(){return D("playlistForbidden","This operation is forbidden or the request is not properly authorized.","youtube.playlist")}function mn(e){return D("playlistItemsNotAccessible",`The request is not properly authorized to ${e} the specified playlist item.`,"youtube.playlistItem")}async function mi(e,t,n){let i=_(t,Q);if("error"in i)return i.error;let o=x(e.req.body);if(o===null)return g("badRequest","The request body is not valid JSON.");let r=o.snippet??{};if(typeof r.title!="string"||r.title.trim()==="")return g("playlistTitleRequired","The playlist must have a title.","snippet.title","youtube.playlist");let a=Ee(n,e.req.headers),s=Je(`${r.title}:${e.req.occurredAt??L}`,n.taken),u=Gt(s,a,{...r,...typeof o.status?.privacyStatus=="string"?{privacyStatus:o.status.privacyStatus}:{},publishedAt:e.req.occurredAt??L});return await I(e,"playlist.create","playlist",s,{...u}),{status:200,body:mt(u,i.parts)}}async function bi(e,t,n){let i=_(t,Q);if("error"in i)return i.error;let o=x(e.req.body);if(o===null)return g("badRequest","The request body is not valid JSON.");if(typeof o.id!="string"||o.id==="")return g("missingRequiredParameter","The request is missing a required parameter.","id");let r=n.playlists.find(u=>u.id===o.id);if(!r)return A("playlistNotFound","The playlist identified with the request's id parameter cannot be found.","youtube.playlist");if(!se(e,n,r.channelId))return yn();let a=o.snippet??{};if(typeof a.title!="string"||a.title.trim()==="")return g("playlistTitleRequired","The playlist must have a title.","snippet.title","youtube.playlist");let s={...r,title:a.title,description:typeof a.description=="string"?a.description:r.description,privacyStatus:typeof o.status?.privacyStatus=="string"?o.status.privacyStatus:r.privacyStatus};return await I(e,"playlist.update","playlist",s.id,{...s}),{status:200,body:mt(s,i.parts)}}async function gi(e,t,n){let i=t.searchParams.get("id");if(i===null||i==="")return g("missingRequiredParameter","The request is missing a required parameter.","id");let o=n.playlists.find(r=>r.id===i);if(!o)return A("playlistNotFound","The playlist identified with the request's id parameter cannot be found.","youtube.playlist");if(!se(e,n,o.channelId))return yn();for(let r of n.playlistItems.filter(a=>a.playlistId===i))await ut(e,"playlistItem.delete","playlistItem",r.id);return await ut(e,"playlist.delete","playlist",i),{status:204,body:null}}async function wi(e,t,n){let i=_(t,le);if("error"in i)return i.error;let o=x(e.req.body);if(o===null)return g("badRequest","The request body is not valid JSON.");let r=o.snippet??{},a=typeof r.playlistId=="string"?r.playlistId:"",s=r.resourceId??{},u=typeof s.videoId=="string"?s.videoId:"";if(!a){let w="The request does not specify a value for the required snippet.playlistId property.";return E(400,w,[{domain:"youtube.playlistItem",reason:"playlistIdRequired",message:w,location:"snippet.playlistId",locationType:"other"}])}if(!u){let w="The request does not specify a value for the required snippet.resourceId property.";return E(400,w,[{domain:"youtube.playlistItem",reason:"resourceIdRequired",message:w,location:"snippet.resourceId",locationType:"other"}])}let f=n.playlists.find(w=>w.id===a);if(!f)return A("playlistNotFound","The playlist identified with the request's snippet.playlistId parameter cannot be found.","youtube.playlistItem");if(!se(e,n,f.channelId))return mn("insert");let l=n.videos.find(w=>w.id===u);if(!l)return A("videoNotFound","The video that you are trying to add to the playlist cannot be found.","youtube.playlistItem");let h=n.playlistItems.filter(w=>w.playlistId===a),p=typeof r.position=="number"?Math.max(0,Math.floor(r.position)):h.length,d=Math.min(p,h.length),y=Qe(`${a}:${u}:${e.req.occurredAt??L}`,n.taken),m=Vt(y,f,l,d,{publishedAt:e.req.occurredAt??L});for(let w of h)w.position>=d&&await I(e,"playlistItem.reposition","playlistItem",w.id,{position:w.position+1});return await I(e,"playlistItem.create","playlistItem",y,{...m}),await I(e,"playlist.itemCount","playlist",a,{itemCount:h.length+1}),{status:200,body:lt(m,i.parts)}}async function Ti(e,t,n){let i=t.searchParams.get("id");if(i===null||i==="")return g("missingRequiredParameter","The request is missing a required parameter.","id");let o=n.playlistItems.find(s=>s.id===i);if(!o)return A("playlistItemNotFound","The playlist item identified with the request's id parameter cannot be found.","youtube.playlistItem");let r=n.playlists.find(s=>s.id===o.playlistId)?.channelId??o.channelId;if(!se(e,n,r))return mn("delete");await ut(e,"playlistItem.delete","playlistItem",i);for(let s of n.playlistItems.filter(u=>u.playlistId===o.playlistId&&u.position>o.position))await I(e,"playlistItem.reposition","playlistItem",s.id,{position:s.position-1});let a=n.playlistItems.filter(s=>s.playlistId===o.playlistId&&s.id!==i).length;return await I(e,"playlist.itemCount","playlist",o.playlistId,{itemCount:a}),{status:204,body:null}}var vi=Te,Ii=["public","private","unlisted"],sn=256*1024;function Si(e){return 5e3+Math.ceil(e/(1024*1024))*1e3}function bn(e,t){return e._processed_at===void 0?e:t!==void 0&&Date.parse(t)>=Date.parse(e._processed_at)?{...e,uploadStatus:"processed",duration:e._probe_duration??"P0D",definition:e._probe_definition??"sd"}:{...e,uploadStatus:"uploaded",duration:"P0D",definition:"sd"}}function rn(e){let t=e.snippet??{},n=t.title;if(typeof n!="string"||n.trim()===""||n.length>100||/[<>]/.test(n)){let i="The request metadata specifies an invalid or empty video title.";return E(400,i,[{domain:"youtube.video",reason:"invalidTitle",message:i,location:"body.snippet.title",locationType:"other"}])}if(t.description!==void 0&&(typeof t.description!="string"||new TextEncoder().encode(t.description).length>5e3||/[<>]/.test(t.description))){let i="The request metadata specifies an invalid video description.";return E(400,i,[{domain:"youtube.video",reason:"invalidDescription",message:i,location:"body.snippet.description",locationType:"other"}])}if(t.categoryId!==void 0&&!fe.some(i=>i.id===String(t.categoryId)&&i.assignable)){let i="The video category specified is invalid.";return E(400,i,[{domain:"youtube.video",reason:"invalidCategoryId",message:i,location:"body.snippet.categoryId",locationType:"other"}])}return null}function bt(e,t){let n=`The request does not include the ${t} content.`;return E(400,n,[{domain:e,reason:"mediaBodyRequired",message:n,location:"body",locationType:"other"}])}async function gn(e,t,n,i,o,r){if(i.length===0)return bt("youtube.video","video");let a=k(e.req.root),s=a.channels.find(w=>w.id===n)??Ee(a,e.req.headers),u=await ke(i,e.req.root),f=qt(i),l=t.snippet??{},h=t.status??{},p=e.req.occurredAt??L,d=ce(`${s.id}:${r}:${p}`,a.taken),y={...Z(d,{id:s.id,title:s.title},{title:l.title,description:typeof l.description=="string"?l.description:"",tags:Array.isArray(l.tags)?l.tags.map(String):[],...l.categoryId!==void 0?{categoryId:String(l.categoryId)}:{},...typeof l.defaultAudioLanguage=="string"?{defaultAudioLanguage:l.defaultAudioLanguage}:{},publishedAt:p,duration:"P0D",definition:"sd",caption:!1,licensedContent:!1,viewCount:0,likeCount:0,favoriteCount:0,commentCount:0,uploadStatus:"uploaded",privacyStatus:Ii.includes(String(h.privacyStatus))?h.privacyStatus:"public",...h.license==="creativeCommon"?{license:"creativeCommon"}:{},...typeof h.embeddable=="boolean"?{embeddable:h.embeddable}:{},...typeof h.publicStatsViewable=="boolean"?{publicStatsViewable:h.publicStatsViewable}:{},madeForKids:h.selfDeclaredMadeForKids===!0}),_content_sha256:u.sha256,_content_size:u.size,_content_type:o,_processed_at:new Date(Date.parse(p)+Si(u.size)).toISOString(),...f.durationSeconds!==void 0?{_probe_duration:he(Math.round(f.durationSeconds))}:{},...f.height!==void 0?{_probe_definition:f.height>=720?"hd":"sd"}:{}};await I(e,"video.create","video",d,{...y});let m=a.channels.find(w=>w.id===s.id);return m&&await I(e,"channel.videoCount",hn,m.id,{videoCount:m.videoCount+1}),y}function wn(e){return typeof e.id=="string"&&e.status===void 0}function Ai(){return`ytupload_${Xn(24).toString("base64url")}`}function Ei(e,t,n){return`${e??vi}/upload/youtube/v3/videos?uploadType=resumable&part=${encodeURIComponent(t.join(","))}&upload_id=${n}`}function dt(e){let t=Date.parse(e.occurredAt??L);return Number.isFinite(t)?t:0}async function Ci(e,t,n){let i=t.searchParams.get("uploadType")??"",o=t.searchParams.get("upload_id"),r=e.req.method.toUpperCase();if(o!==null&&(r==="PUT"||r==="POST"))return Tn(e,o);if(r!=="POST")return A("notFound",`Not Found: ${r} ${t.pathname}`,"global");let a=_(t,ue);if("error"in a)return a.error;let s=e.req.headers;if(i==="resumable"){let f=x(e.req.bytes?new TextDecoder().decode(e.req.bytes):e.req.body);if(f===null)return g("parseError","Parse Error");let l=rn(f);if(l)return l;let h=await Se(e,"videos","insert");if(h)return h;await _t(dt(e.req),e.req.root);let p=Ee(n,s),d=Ai(),y=U(s,"x-upload-content-length"),m=Number(y),w=U(s,"x-upload-content-type"),R={id:d,parts:a.parts,resource:f,channelId:p.id,openedAt:dt(e.req),...y!==void 0&&Number.isSafeInteger(m)&&m>=0?{total:m}:{},...w?{contentType:w}:{}};return await Ne(R,e.req.root),{status:200,body:null,headers:{location:Ei(e.req.publicBase,a.parts,d),"x-guploader-uploadid":d}}}if(i==="multipart"||i==="media"){let f={},l,h=U(s,"content-type")??"application/octet-stream";if(i==="multipart"){let w=vn(e.req.bytes??new TextEncoder().encode(e.req.body??""),h);if(!w)return g("parseError","Parse Error");f=w.meta,l=w.media,h=w.mediaType??"application/octet-stream"}else f={snippet:{title:"unknown"}},l=e.req.bytes??new Uint8Array(0);let p=rn(f);if(p)return p;if(l.length===0)return bt("youtube.video","video");let d=await Se(e,"videos","insert");if(d)return d;let y=Ee(n,s),m=await gn(e,f,y.id,l,h,`${i}:${n.videos.length}`);return wn(m)?{status:200,body:Ae(m,a.parts,e.req.publicBase)}:m}let u=`Invalid value '${i}'. Values must match the following regular expression: '(media|multipart|resumable)'`;return E(400,u,[{domain:"global",reason:"invalidParameter",message:u,location:"uploadType",locationType:"parameter"}])}async function Tn(e,t){let n=e.req.root,i=await Be(t,n);if(!i)return A("notFound","Not Found","global");if(dt(e.req)-i.openedAt>$e)return await qe(t,n),A("notFound","Not Found","global");if(i.videoId!==void 0){let y=k(n).videos.find(m=>m.id===i.videoId);return y?{status:200,body:Ae(bn(y,e.req.occurredAt),i.parts,e.req.publicBase)}:A("notFound","Not Found","global")}let o=e.req.bytes??new Uint8Array(0),r=U(e.req.headers,"content-range"),a=i.total,s=!1,u=null,f=null;if(r!==void 0){let y=/^bytes (?:(\d+)-(\d+)|\*)\/(\d+|\*)$/.exec(r.trim());if(!y)return g("badContent",`Invalid Content-Range header: ${r}`);if(y[1]===void 0?s=!0:(u=Number(y[1]),f=Number(y[2])),y[3]!=="*"){let m=Number(y[3]);if(i.total!==void 0&&m!==i.total)return g("badContent",`The Content-Range total ${m} does not match the X-Upload-Content-Length ${i.total} the upload was started with.`);a=m}}if(f!==null&&a!==void 0&&f>=a)return g("badContent",`Content-Range ends at byte ${f}, past the upload's length ${a}.`);let l=await Rt(t,n);if(!s&&o.length>0){if(u!==null&&f!==null&&f<l)return{status:308,body:null,headers:{range:`bytes=0-${l-1}`}};if(u!==null&&u!==l)return g("badContent",`Upload request started at byte ${u}, but the session expected byte ${l}.`);if(u!==null&&f!==null&&f-u+1!==o.length)return g("badContent","Content-Range byte count does not match the request body length.");if(i.total!==void 0&&l+o.length>i.total)return g("badContent",`The session holds ${l} bytes; ${o.length} more pass the X-Upload-Content-Length ${i.total} the upload was started with.`);let m=r===void 0||a!==void 0&&l+o.length>=a?o.length:Math.floor(o.length/sn)*sn;await Ut(t,l,o.subarray(0,m),n),l+=m}if(!(r===void 0?!0:a!==void 0&&l>=a&&a>0))return{status:308,body:null,headers:l>0?{range:`bytes=0-${l-1}`}:{}};let p=await $t(t,n),d=await gn(e,i.resource,i.channelId,p,i.contentType??U(e.req.headers,"content-type")??"application/octet-stream",t);return wn(d)?(await Ne({...i,videoId:d.id},n),await Ot(t,n),{status:201,body:Ae(d,i.parts,e.req.publicBase)}):d}function vn(e,t){let n=/boundary=(?:"([^"]+)"|([^;]+))/i.exec(t),i=(n?.[1]??n?.[2])?.trim();if(!i)return null;let o=Buffer.from(e.buffer,e.byteOffset,e.byteLength),r=Buffer.from(`--${i}`),a=[],s=o.indexOf(r);for(;s>=0;){let l=o.indexOf(r,s+r.length);if(l<0)break;let h=o.subarray(s+r.length,l);h[0]===13&&h[1]===10&&(h=h.subarray(2)),h[h.length-2]===13&&h[h.length-1]===10&&(h=h.subarray(0,h.length-2));let p=h.indexOf(`\r
|
|
3
|
+
\r
|
|
4
|
+
`);if(p>=0){let d={};for(let y of h.subarray(0,p).toString("utf8").split(`\r
|
|
5
|
+
`)){let m=y.indexOf(":");m>0&&(d[y.slice(0,m).trim().toLowerCase()]=y.slice(m+1).trim())}a.push({headers:d,body:h.subarray(p+4)})}s=l}if(a.length<2)return null;let u=x(a[0].body.toString("utf8"));if(u===null)return null;let f=a[1];return{meta:u,media:new Uint8Array(f.body),...f.headers["content-type"]?{mediaType:f.headers["content-type"]}:{}}}async function _i(e,t,n){let i=t.searchParams.get("videoId");if(!i)return g("missingRequiredParameter","No filter selected. Expected one of: videoId","videoId");let o=t.searchParams.get("uploadType")??"media";if(o!=="media"&&o!=="multipart"){let d=`Invalid value '${o}'. Values must match the following regular expression: '(media|multipart)'`;return E(400,d,[{domain:"global",reason:"invalidParameter",message:d,location:"uploadType",locationType:"parameter"}])}let r=n.videos.find(d=>d.id===i);if(!r)return A("videoNotFound","The video that you are trying to update cannot be found.","youtube.thumbnail");if(!se(e,n,r.channelId))return D("forbidden","The thumbnail can't be set for the specified video. The request might not be properly authorized.","youtube.thumbnail");let a=e.req.bytes??new Uint8Array(0);if(o==="multipart"){let d=vn(a,U(e.req.headers,"content-type")??"");if(!d)return g("parseError","Parse Error");a=d.media}if(a.length===0)return bt("youtube.thumbnail","image");let s=a[0]===255&&a[1]===216&&a[2]===255,u=a[0]===137&&a[1]===80&&a[2]===78&&a[3]===71;if(!s&&!u){let d="The thumbnail image file you have provided is corrupted or of an unsupported format.";return E(400,d,[{domain:"youtube.thumbnail",reason:"invalidImage",message:d,location:"body",locationType:"other"}])}let f=await Se(e,"thumbnails","set");if(f)return f;let l=await ke(a,e.req.root),h=u?"image/png":"image/jpeg";await I(e,"video.thumbnail","video",r.id,{_thumbnail_sha256:l.sha256,_thumbnail_type:h});let p=[Pe({...r,_thumbnail_sha256:l.sha256,_thumbnail_type:h},e.req.publicBase)];return{status:200,body:{kind:"youtube#thumbnailSetResponse",etag:C(p),items:p}}}var Ie=8*1024*1024;function Pi(e,t){if(!e)return null;let n=/^bytes=(\d*)-(\d*)$/.exec(e.trim());if(!n||n[1]===""&&n[2]==="")return null;if(n[1]===""){let r=Number(n[2]);return r===0||t===0?"unsatisfiable":{start:Math.max(0,t-Math.min(r,Ie)),end:t-1}}let i=Number(n[1]);if(i>=t)return"unsatisfiable";let o=n[2]===""?Math.min(t-1,i+Ie-1):Math.min(Number(n[2]),t-1,i+Ie-1);return o<i?"unsatisfiable":{start:i,end:o}}async function an(e,t,n,i){let o={"content-type":i,"accept-ranges":"bytes",etag:`"${t}"`,"cache-control":"private, max-age=0"},r=e.method.toUpperCase()==="HEAD",a=Pi(U(e.headers,"range"),n);if(a==="unsatisfiable")return{status:416,body:new Uint8Array(0),headers:{...o,"content-range":`bytes */${n}`}};if(a){let h=a.end-a.start+1,p={...o,"content-range":`bytes ${a.start}-${a.end}/${n}`,"content-length":String(h)};return r?{status:206,body:new Uint8Array(0),headers:p}:{status:206,body:await G(t,a.start,a.end,e.root)??new Uint8Array(0),headers:p}}let s={...o,"content-length":String(n)};if(r)return{status:200,body:new Uint8Array(0),headers:s};let u=0,f=e.root;return{status:200,body:new ReadableStream({async pull(h){if(u>=n){h.close();return}let p=Math.min(n-1,u+Ie-1),d=await G(t,u,p,f);if(!d||d.length===0){h.close();return}h.enqueue(d),u+=d.length}}),headers:s}}function un(){return{status:404,body:new Uint8Array(0),headers:{"content-type":"text/plain"}}}async function Ri(e,t,n){if(n==="/videoplayback"){let o=t.searchParams.get("v")??"",r=k(e.root),a=r.videos.find(u=>u.id===o),s=a?await j(a._content_sha256,e.root):null;if(!a||s===null)return un();if(a.privacyStatus==="private"){let u=t.searchParams.get("access_token")??M(e.headers),f=u==null?void 0:r.tokens.find(l=>l.id===pt(u));if(!f||f.channelId!==a.channelId)return{status:403,body:new TextEncoder().encode("This video is private."),headers:{"content-type":"text/plain"}}}return an(e,String(a._content_sha256),s,a._content_type??"video/mp4")}let i=/^\/vi\/([A-Za-z0-9_-]{1,64})\/(default|mqdefault|hqdefault|sddefault|maxresdefault)\.jpg$/.exec(n);if(i){let o=k(e.root).videos.find(a=>a.id===i[1]),r=o?await j(o._thumbnail_sha256,e.root):null;return!o||r===null?un():an(e,String(o._thumbnail_sha256),r,o._thumbnail_type??"image/jpeg")}return null}async function Ui(e,t){let n=x(e.req.body);if(n===null)return g("badRequest","The request body is not valid JSON.");let i=typeof n.id=="string"&&n.id?n.id:We(JSON.stringify(n),t.taken),o=ye(i,n);return await I(e,"channel.upsert","channel",i,{...o}),{status:200,body:o}}async function $i(e,t){let n=x(e.req.body);if(n===null)return g("badRequest","The request body is not valid JSON.");let i=typeof n.channelId=="string"?n.channelId:"",o=t.channels.find(s=>s.id===i)??t.channels[0];if(!o)return g("badRequest","Seed a channel before seeding a video.","channelId");let r=typeof n.id=="string"&&n.id?n.id:ce(JSON.stringify(n),t.taken),a=Z(r,{id:o.id,title:o.title},n);return await I(e,"video.upsert","video",r,{...a}),{status:200,body:a}}async function Oi(e,t){let n=x(e.req.body);if(n===null)return g("badRequest","The request body is not valid JSON.");let i=typeof n.token=="string"?n.token.trim():"",o=typeof n.channelId=="string"?n.channelId:"";return i===""||/\s/.test(i)?g("badRequest","A twin token requires a non-empty `token` with no whitespace.","token"):t.channels.some(r=>r.id===o)?(await I(e,"token.register",fn,pt(i),{channelId:o}),{status:200,body:{channelId:o}}):g("badRequest","A twin token must name a channel seeded through /_twin/channels.","channelId")}async function Di(e){let t=x(e.req.body);if(t===null)return g("badRequest","The request body is not valid JSON.");let n=ft(e.req.root),i={unitsUsed:P(t.unitsUsed,n.unitsUsed),searchCalls:P(t.searchCalls,n.searchCalls),uploadCalls:P(t.uploadCalls,n.uploadCalls),unitsAllowance:P(t.unitsAllowance,n.unitsAllowance),searchAllowance:P(t.searchAllowance,n.searchAllowance),uploadAllowance:P(t.uploadAllowance,n.uploadAllowance)};return await I(e,"quota.set",ie,ne,{...i}),{status:200,body:i}}function ki(e){return e==="POST"?"insert":e==="PUT"?"update":e==="DELETE"?"delete":"list"}function ln(e,t){if(t===void 0)return null;if(M(t)===void 0)return oe();let n=Ce(e,t);return!n||!e.channels.some(i=>i.id===n.channelId)?pn():null}var dn=new Set(["POST","PUT","DELETE"]);async function gt(e){let t=e.method.toUpperCase(),n=new URL(e.path,"http://twin.local"),i=n.pathname.replace(/\/+$/,"")||"/",o=ni(e);if(t==="GET"||t==="HEAD"){let y=await Ri(e,n,i);if(y)return y}if(/^\/(?:resumable\/)?upload\/youtube\/v3\/videos$/.test(i)&&n.searchParams.get("upload_id")!==null&&(t==="PUT"||t==="POST"))return e.readOnly?D("forbidden","twin is read-only; omit readOnly to accept writes","global"):Tn(o,n.searchParams.get("upload_id"));let a=Re(n,e.headers);if(!a.ok)return{status:a.status,body:a.error};let s=/^\/(?:resumable\/)?upload\/youtube\/v3\/(videos|thumbnails\/set)$/.exec(i);if(s){if(e.readOnly)return D("forbidden","twin is read-only; omit readOnly to accept writes","global");let y=k(e.root,e.occurredAt),m=ln(y,e.headers);return m||(s[1]==="videos"?Ci(o,n,y):t!=="POST"?A("notFound",`Not Found: ${t} ${i}`,"global"):_i(o,n,y))}let u=/^\/youtube\/v3\/(.+)$/.exec(i);if(!u)return A("notFound",`Not Found: ${t} ${i}`,"global");let f=u[1];if(f.startsWith("_twin/")){if(e.readOnly)return D("forbidden","twin is read-only","global");let y=k(e.root);return t==="POST"&&f==="_twin/channels"?Ui(o,y):t==="POST"&&f==="_twin/videos"?$i(o,y):t==="POST"&&f==="_twin/tokens"?Oi(o,y):t==="POST"&&f==="_twin/quota"?Di(o):t==="GET"&&f==="_twin/quota"?{status:200,body:ft(e.root)}:A("notFound",`Not Found: ${t} ${i}`,"global")}let l=f.split("/")[0];if(!["channels","videos","search","playlists","playlistItems","videoCategories","i18nLanguages","i18nRegions","videoAbuseReportReasons"].includes(l)||f!==l)return A("notFound",`Not Found: ${t} ${i}`,"global");if(dn.has(t)&&e.readOnly)return D("forbidden","twin is read-only; omit readOnly to accept writes","global");if(dn.has(t)){let y=ln(k(e.root),e.headers);if(y)return y}let p=await Se(o,l,ki(t));if(p)return p;let d=k(e.root,e.occurredAt);if(t==="GET"){if(l==="channels")return ai(n,d,e.headers);if(l==="videos")return ui(n,d,e.publicBase);if(l==="search")return li(n,d,e.publicBase);if(l==="playlists")return di(n,d);if(l==="playlistItems")return ci(n,d,e.publicBase);if(l==="videoCategories")return pi(n);if(l==="i18nLanguages")return fi(n);if(l==="i18nRegions")return hi(n);if(l==="videoAbuseReportReasons")return yi(n)}return t==="POST"&&l==="playlists"?mi(o,n,d):t==="PUT"&&l==="playlists"?bi(o,n,d):t==="DELETE"&&l==="playlists"?gi(o,n,d):t==="POST"&&l==="playlistItems"?wi(o,n,d):t==="DELETE"&&l==="playlistItems"?Ti(o,n,d):A("notFound",`Not Found: ${t} ${i}`,"global")}import{isReadOnlyRequest as xi,serveHttp as ho,withRequestScopes as Li}from"../../engine/v2/volter_world-core.mjs";import{worldNow as Ni,statefulTwinManifest as Bi,twinPublicBase as qi}from"../../engine/v2/volter_world-core.mjs";function In(e={}){return Li(async function(n){let i=new URL(n.url);if(n.method==="GET"&&i.pathname.replace(/\/+$/,"")==="/twin")return Response.json(Bi({vendor:"youtube",twinOf:"the YouTube Data API v3",stores:"channels, videos (with their uploaded media and thumbnails), playlists and their metadata"}));let o=/^\/(?:resumable\/)?upload\//.test(i.pathname),r=n.method==="GET"||n.method==="HEAD"?new Uint8Array(0):new Uint8Array(await n.arrayBuffer()),a={};n.headers.forEach((f,l)=>{a[l]=f});let s=await gt({method:n.method,path:i.pathname+i.search,body:o?"":new TextDecoder().decode(r),...o?{bytes:r}:{},publicBase:qi(n),readOnly:(e.readOnly??!1)||xi(n),occurredAt:Ni(),headers:a,...e.root!==void 0?{root:e.root}:{}}),u=s.headers??{};if(s.body instanceof Uint8Array||s.body instanceof ReadableStream){let f=n.method==="HEAD"?null:(s.body instanceof Uint8Array,s.body);return new Response(f,{status:s.status,headers:u})}if(s.status===204||s.body===null){let f=s.status===308?"Resume Incomplete":void 0;return new Response(null,{status:s.status,...f?{statusText:f}:{},headers:{...s.status===204?{}:{"content-length":"0"},...u}})}return new Response(JSON.stringify(s.body),{status:s.status,headers:{"content-type":"application/json; charset=UTF-8",...u}})},{refuse:()=>new Response(JSON.stringify(O(403,"this request is read-only",[{domain:"global",reason:"forbidden",message:"this request is read-only"}])),{status:403,headers:{"content-type":"application/json; charset=UTF-8"}})})}import{registerPack as Fi}from"../../engine/v2/volter_world-core.mjs";var Yi={protocol:"2",refresh:{every:"1h",webhook:!1,onDemand:{atMost:"60s"}},stateSystem:{perform:on,refresh:en},roundTrip:[{method:"POST",path:"/youtube/v3/_twin/channels?key=round-trip",body:{id:"UCroundtripchannel000001",title:"Round Trip"}},{method:"POST",path:"/youtube/v3/_twin/tokens?key=round-trip",body:{token:"round-trip",channelId:"UCroundtripchannel000001"}},{method:"POST",path:"/youtube/v3/playlists?part=snippet&key=round-trip",body:{snippet:{title:"round trip"}},headers:{authorization:"Bearer round-trip"}}],parityOrigin:"http://twin",vendor:"youtube",rateBudget:me,transport:"rest",archetype:"crud",bin:"world-youtube",resources:["channel","video","playlist","playlistItem"],specSource:"YouTube Data API v3 reference (developers.google.com/youtube/v3/docs) \u2014 channels, videos, search, playlists, playlistItems, videoCategories, i18nLanguages, i18nRegions, videoAbuseReportReasons + the published quota cost table",description:"YouTube Data API v3 twin \u2014 vendor-faithful list envelopes, part selection, string-typed statistics, the real Google error envelope and a modeled daily quota ledger.",adoption:{pypi:[],sdks:["@googleapis/youtube"],envStems:["YOUTUBE"]},hosts:[{host:"youtube.googleapis.com"},{host:"www.googleapis.com",pathPattern:"^/(upload/)?youtube/v3(/|$)"}],browserRouting:{apiPathPrefix:"/youtube/v3/",loaderHost:"https://www.googleapis.com"}};Fi(Yi);export{In as createTwinFetch};
|