@adminide-stack/yantra-mobile 12.0.194-alpha.0 → 12.0.194

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/lib/bridge/handlers/NavigationBridgeHandler.js +6 -9
  2. package/lib/bridge/handlers/NavigationBridgeHandler.js.map +1 -1
  3. package/lib/components/BrandBar/BrandBarBackground.js +27 -0
  4. package/lib/components/BrandBar/BrandBarBackground.js.map +1 -0
  5. package/lib/components/BrandBar/MenuToggle.js +73 -0
  6. package/lib/components/BrandBar/MenuToggle.js.map +1 -0
  7. package/lib/components/CustomDrawer.js +6 -6
  8. package/lib/components/CustomDrawer.js.map +1 -1
  9. package/lib/components/GatewayConnector/GatewayConnector.js +3 -2
  10. package/lib/components/GatewayConnector/GatewayConnector.js.map +1 -1
  11. package/lib/components/GatewayToolbarButtonMobile.js +12 -2
  12. package/lib/components/GatewayToolbarButtonMobile.js.map +1 -1
  13. package/lib/components/NavigationHeader/HeaderChip.js +76 -0
  14. package/lib/components/NavigationHeader/HeaderChip.js.map +1 -0
  15. package/lib/components/NavigationHeader/HeaderSkillsButton.js +4 -3
  16. package/lib/components/NavigationHeader/HeaderSkillsButton.js.map +1 -1
  17. package/lib/components/NavigationHeader/HeaderTasksButton.js +4 -3
  18. package/lib/components/NavigationHeader/HeaderTasksButton.js.map +1 -1
  19. package/lib/components/NavigationHeader/NavigationHeader.js +96 -41
  20. package/lib/components/NavigationHeader/NavigationHeader.js.map +1 -1
  21. package/lib/components/YantraTopBar/YantraTopBar.js +98 -0
  22. package/lib/components/YantraTopBar/YantraTopBar.js.map +1 -0
  23. package/lib/compute.js +18 -25
  24. package/lib/compute.js.map +1 -1
  25. package/lib/features/apps/AppsCatalog.js +7 -4
  26. package/lib/features/apps/AppsCatalog.js.map +1 -1
  27. package/lib/features/apps/MarketplaceGallery.js +6 -3
  28. package/lib/features/apps/MarketplaceGallery.js.map +1 -1
  29. package/lib/features/apps/nativeSurfaceTwin.js +1 -1
  30. package/lib/features/apps/nativeSurfaceTwin.js.map +1 -1
  31. package/lib/features/apps/useMarketplaceApps.js +6 -2
  32. package/lib/features/apps/useMarketplaceApps.js.map +1 -1
  33. package/lib/features/attachments/useImageAttachments.js +44 -1
  34. package/lib/features/attachments/useImageAttachments.js.map +1 -1
  35. package/lib/features/credits/FreeCreditsPhoneStepHost.js +67 -0
  36. package/lib/features/credits/FreeCreditsPhoneStepHost.js.map +1 -0
  37. package/lib/features/credits/freeCredits.js +52 -13
  38. package/lib/features/credits/freeCredits.js.map +1 -1
  39. package/lib/features/credits/freeCreditsPhoneStep.js +55 -0
  40. package/lib/features/credits/freeCreditsPhoneStep.js.map +1 -0
  41. package/lib/features/credits/useFreeCredits.js +29 -3
  42. package/lib/features/credits/useFreeCredits.js.map +1 -1
  43. package/lib/features/links/openInApp.js +3 -6
  44. package/lib/features/links/openInApp.js.map +1 -1
  45. package/lib/features/webbuilder/WebBuilderExperience.js +88 -28
  46. package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
  47. package/lib/features/webbuilder/appPreview.js +70 -0
  48. package/lib/features/webbuilder/appPreview.js.map +1 -0
  49. package/lib/features/webbuilder/buildFragments.js +33 -12
  50. package/lib/features/webbuilder/buildFragments.js.map +1 -1
  51. package/lib/features/webbuilder/components/AppPhoneSheet.js +127 -0
  52. package/lib/features/webbuilder/components/AppPhoneSheet.js.map +1 -0
  53. package/lib/features/webbuilder/components/BottomTabs.js +32 -21
  54. package/lib/features/webbuilder/components/BottomTabs.js.map +1 -1
  55. package/lib/features/webbuilder/components/Composer.js +144 -47
  56. package/lib/features/webbuilder/components/Composer.js.map +1 -1
  57. package/lib/features/webbuilder/components/PreviewFrame.js +1 -1
  58. package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -1
  59. package/lib/features/webbuilder/components/PreviewScreen.js +9 -4
  60. package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
  61. package/lib/features/webbuilder/components/ProjectSheets.js +76 -22
  62. package/lib/features/webbuilder/components/ProjectSheets.js.map +1 -1
  63. package/lib/features/webbuilder/components/ProjectsScreen.js +30 -12
  64. package/lib/features/webbuilder/components/ProjectsScreen.js.map +1 -1
  65. package/lib/features/webbuilder/components/PublishSheet.js +2 -2
  66. package/lib/features/webbuilder/components/PublishSheet.js.map +1 -1
  67. package/lib/features/webbuilder/components/SiteUploadSheet.js +17 -2
  68. package/lib/features/webbuilder/components/SiteUploadSheet.js.map +1 -1
  69. package/lib/features/webbuilder/components/SocialExportPicker.js +253 -0
  70. package/lib/features/webbuilder/components/SocialExportPicker.js.map +1 -0
  71. package/lib/features/webbuilder/components/StudioHome.js +300 -185
  72. package/lib/features/webbuilder/components/StudioHome.js.map +1 -1
  73. package/lib/features/webbuilder/components/TemplateCard.js +13 -5
  74. package/lib/features/webbuilder/components/TemplateCard.js.map +1 -1
  75. package/lib/features/webbuilder/connectorTemplates.js +3 -2
  76. package/lib/features/webbuilder/connectorTemplates.js.map +1 -1
  77. package/lib/features/webbuilder/liveSiteDelete.js +58 -0
  78. package/lib/features/webbuilder/liveSiteDelete.js.map +1 -0
  79. package/lib/features/webbuilder/publishTools.js +3 -1
  80. package/lib/features/webbuilder/publishTools.js.map +1 -1
  81. package/lib/features/webbuilder/socialExportFile.js +84 -0
  82. package/lib/features/webbuilder/socialExportFile.js.map +1 -0
  83. package/lib/features/webbuilder/stepLabels.js +7 -7
  84. package/lib/features/webbuilder/stepLabels.js.map +1 -1
  85. package/lib/features/webbuilder/thumbSources.js +17 -3
  86. package/lib/features/webbuilder/thumbSources.js.map +1 -1
  87. package/lib/features/webbuilder/useVoiceTyping.js +169 -0
  88. package/lib/features/webbuilder/useVoiceTyping.js.map +1 -0
  89. package/lib/features/webbuilder/web/chat/connectRequest.js +17 -0
  90. package/lib/features/webbuilder/web/chat/connectRequest.js.map +1 -0
  91. package/lib/features/webbuilder/web/notify/turnDone.js +20 -0
  92. package/lib/features/webbuilder/web/notify/turnDone.js.map +1 -0
  93. package/lib/features/webbuilder/web/project/coverRequest.js +22 -0
  94. package/lib/features/webbuilder/web/project/coverRequest.js.map +1 -0
  95. package/lib/features/webbuilder/web/project/deleteFlow.js +57 -0
  96. package/lib/features/webbuilder/web/project/deleteFlow.js.map +1 -0
  97. package/lib/features/webbuilder/web/publish/siteAddress.js +5 -1
  98. package/lib/features/webbuilder/web/publish/siteAddress.js.map +1 -1
  99. package/lib/features/webbuilder/web/upload/sitePhotos.js +2 -2
  100. package/lib/features/webbuilder/web/upload/sitePhotos.js.map +1 -1
  101. package/lib/features/webbuilder/web/upload/socialExport.js +191 -0
  102. package/lib/features/webbuilder/web/upload/socialExport.js.map +1 -0
  103. package/lib/features/webbuilder/web/upload/zipRandomAccess.js +64 -0
  104. package/lib/features/webbuilder/web/upload/zipRandomAccess.js.map +1 -0
  105. package/lib/features/webbuilder/web/webServices.js +27 -3
  106. package/lib/features/webbuilder/web/webServices.js.map +1 -1
  107. package/lib/hooks/useHeaderProfile.js +25 -0
  108. package/lib/hooks/useHeaderProfile.js.map +1 -0
  109. package/lib/index.js +1 -1
  110. package/lib/index.js.map +1 -1
  111. package/lib/routes.json +21 -29
  112. package/lib/screens/Account/AccountSheets.js +140 -74
  113. package/lib/screens/Account/AccountSheets.js.map +1 -1
  114. package/lib/screens/Account/index.js +3 -3
  115. package/lib/screens/Account/index.js.map +1 -1
  116. package/lib/screens/Apps/index.js +1 -1
  117. package/lib/screens/Apps/index.js.map +1 -1
  118. package/lib/screens/ChatHistory/index.js +1 -1
  119. package/lib/screens/ChatHistory/index.js.map +1 -1
  120. package/lib/screens/ExpensesNative/index.js +3 -3
  121. package/lib/screens/ExpensesNative/index.js.map +1 -1
  122. package/lib/screens/Home/HomeScreen.js +11 -0
  123. package/lib/screens/Home/HomeScreen.js.map +1 -1
  124. package/lib/screens/Home/components/ChatHistoryLanding.js +3 -2
  125. package/lib/screens/Home/components/ChatHistoryLanding.js.map +1 -1
  126. package/lib/screens/WebBuilderNative/index.js +3 -2
  127. package/lib/screens/WebBuilderNative/index.js.map +1 -1
  128. package/lib/screens/WebBuilderNative/useWebBuilderHost.js +2 -2
  129. package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
  130. package/lib/utils/drawerRoutes.js +13 -0
  131. package/lib/utils/drawerRoutes.js.map +1 -0
  132. package/package.json +4 -4
@@ -0,0 +1,55 @@
1
+ const FREE_CREDITS_PHONE_COPY = {
2
+ title: "Verify your phone number",
3
+ subtitle: "Free credits need a verified phone number. Each number can claim them once.",
4
+ workingTitle: "Phone number verified",
5
+ workingText: "Adding your free credits..."
6
+ };
7
+ let view = null;
8
+ let copy = FREE_CREDITS_PHONE_COPY;
9
+ let waiting = null;
10
+ const hosts = /* @__PURE__ */ new Set();
11
+ function show(next) {
12
+ view = next;
13
+ hosts.forEach((listener) => listener(next));
14
+ }
15
+ function settle(outcome) {
16
+ const resolve = waiting;
17
+ waiting = null;
18
+ resolve == null ? void 0 : resolve(outcome);
19
+ }
20
+ const currentPhoneStep = () => view;
21
+ const currentPhoneStepCopy = () => copy;
22
+ function askForVerifiedPhone(askCopy = FREE_CREDITS_PHONE_COPY) {
23
+ if (hosts.size === 0) return Promise.resolve("unavailable");
24
+ settle("closed");
25
+ copy = askCopy;
26
+ return new Promise((resolve) => {
27
+ waiting = resolve;
28
+ show("verify");
29
+ });
30
+ }
31
+ function phoneVerified() {
32
+ show("claiming");
33
+ settle("verified");
34
+ }
35
+ function closePhoneStep() {
36
+ show(null);
37
+ settle("closed");
38
+ }
39
+ function endPhoneStep() {
40
+ if (view === "claiming" || view === "verify") show(null);
41
+ }
42
+ function showPhoneAlreadyClaimed() {
43
+ if (hosts.size > 0) show("already-claimed");
44
+ }
45
+ function subscribePhoneStep(listener) {
46
+ hosts.add(listener);
47
+ listener(view);
48
+ return () => {
49
+ hosts.delete(listener);
50
+ if (hosts.size === 0) {
51
+ view = null;
52
+ settle("closed");
53
+ }
54
+ };
55
+ }export{FREE_CREDITS_PHONE_COPY,askForVerifiedPhone,closePhoneStep,currentPhoneStep,currentPhoneStepCopy,endPhoneStep,phoneVerified,showPhoneAlreadyClaimed,subscribePhoneStep};//# sourceMappingURL=freeCreditsPhoneStep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"freeCreditsPhoneStep.js","sources":["../../../src/features/credits/freeCreditsPhoneStep.ts"],"sourcesContent":["/**\n * The app's phone step: the account gets a verified phone number before something billing holds back\n * for one. First the free-credits claim (2026-11-19: free credits only for a verified phone, once per\n * number), then a promo code at the checkout (Black Friday 2026: a code can need a verified phone, once\n * per number; the billing module asks through the checkout phone step the app registers).\n *\n * Whoever needs it (useFreeCredits on the home and in a chat, a native surface's host chat through\n * useHostFreeCreditsClaim, the plan checkout) asks here; the one sheet that asks the person,\n * FreeCreditsPhoneStepHost, is mounted once for the whole app (as ChatLinkOpenerProvider is), so a\n * surface's remote never bundles the account's GraphQL to draw it. Free of React Native and Apollo.\n *\n * `verify`: the number and its code. `claiming`: the phone is verified and what asked runs again (each\n * ask says in its own words, see PhoneStepCopy). `already-claimed`: this number already got its free\n * credits.\n */\nexport type FreeCreditsPhoneView = 'verify' | 'claiming' | 'already-claimed';\n\n/** How an ask ended: the phone is verified, the person closed the step, or no sheet is mounted to ask with. */\nexport type PhoneStepOutcome = 'verified' | 'closed' | 'unavailable';\n\n/** What the sheet says for one ask: why a verified number is needed, and what runs once it is. */\nexport interface PhoneStepCopy {\n /** The verify view's title. */\n title: string;\n /** Under the title while the number is entered. */\n subtitle: string;\n /** The `claiming` view's title, once the phone is verified. */\n workingTitle: string;\n /** The `claiming` view's line while what asked runs again. */\n workingText: string;\n}\n\n/** The free-credits claim's words: every ask that names none. */\nexport const FREE_CREDITS_PHONE_COPY: PhoneStepCopy = {\n title: 'Verify your phone number',\n subtitle: 'Free credits need a verified phone number. Each number can claim them once.',\n workingTitle: 'Phone number verified',\n workingText: 'Adding your free credits...',\n};\n\ntype Listener = (view: FreeCreditsPhoneView | null) => void;\n\nlet view: FreeCreditsPhoneView | null = null;\nlet copy: PhoneStepCopy = FREE_CREDITS_PHONE_COPY;\nlet waiting: ((outcome: PhoneStepOutcome) => void) | null = null;\nconst hosts = new Set<Listener>();\n\nfunction show(next: FreeCreditsPhoneView | null): void {\n view = next;\n hosts.forEach((listener) => listener(next));\n}\n\nfunction settle(outcome: PhoneStepOutcome): void {\n const resolve = waiting;\n waiting = null;\n resolve?.(outcome);\n}\n\n/** What the sheet shows now; null while no claim needs it. */\nexport const currentPhoneStep = (): FreeCreditsPhoneView | null => view;\n\n/** The words of the ask the sheet shows now (the free-credits claim's until another ask names its own). */\nexport const currentPhoneStepCopy = (): PhoneStepCopy => copy;\n\n/**\n * Ask the person for a verified phone, in `askCopy`'s words. Resolves `verified` once `addPhoneNumber`\n * took the code, and the sheet then says what asked is running (`claiming`) until `endPhoneStep` or\n * `showPhoneAlreadyClaimed`.\n */\nexport function askForVerifiedPhone(askCopy: PhoneStepCopy = FREE_CREDITS_PHONE_COPY): Promise<PhoneStepOutcome> {\n if (hosts.size === 0) return Promise.resolve('unavailable');\n // One ask at a time: an earlier one still open ends as closed.\n settle('closed');\n copy = askCopy;\n return new Promise((resolve) => {\n waiting = resolve;\n show('verify');\n });\n}\n\n/** The sheet: the code checked out and the number is on the account, verified. */\nexport function phoneVerified(): void {\n show('claiming');\n settle('verified');\n}\n\n/** The sheet was closed. A claim waiting on it ends with nothing claimed. */\nexport function closePhoneStep(): void {\n show(null);\n settle('closed');\n}\n\n/** The claim that waited on the phone is done (claimed, or refused for another reason): the sheet closes. */\nexport function endPhoneStep(): void {\n if (view === 'claiming' || view === 'verify') show(null);\n}\n\n/** This number already got its free credits: the sheet says so, with the way on. */\nexport function showPhoneAlreadyClaimed(): void {\n if (hosts.size > 0) show('already-claimed');\n}\n\n/** The sheet's subscription. The last one to go ends any ask still waiting on it. */\nexport function subscribePhoneStep(listener: Listener): () => void {\n hosts.add(listener);\n listener(view);\n return () => {\n hosts.delete(listener);\n if (hosts.size === 0) {\n view = null;\n settle('closed');\n }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AACjB;AAGO,SAAS,YAAqB,GAAA;AACnC,EAAA,IAAI,IAAS,KAAA,UAAA,IAAc,IAAS,KAAA,QAAA,OAAe,IAAI,CAAA;AACzD;AAGO,SAAS,uBAAgC,GAAA;AAC9C,EAAA,IAAI,KAAM,CAAA,IAAA,GAAO,CAAG,EAAA,IAAA,CAAK,iBAAiB,CAAA;AAC5C;AAGO,SAAS,mBAAmB,QAAgC,EAAA;AACjE,EAAA,KAAA,CAAM,IAAI,QAAQ,CAAA;AAClB,EAAA,QAAA,CAAS,IAAI,CAAA;AACb,EAAA,OAAO,MAAM;AACX,IAAA,KAAA,CAAM,OAAO,QAAQ,CAAA;AACrB,IAAI,IAAA,KAAA,CAAM,SAAS,CAAG,EAAA;AACpB,MAAO,IAAA,GAAA,IAAA;AACP,MAAA,MAAA,CAAO,QAAQ,CAAA;AAAA;AACjB,GACF;AACF"}
@@ -1,6 +1,32 @@
1
- import {useApolloClient}from'@apollo/client/index.js';import {useState,useEffect,useCallback}from'react';import {fetchFreeCreditsStatus,FREE_CREDITS_CLAIM_FAILED,claimFreeCredits}from'./freeCredits.js';const claimListeners = /* @__PURE__ */ new Set();
1
+ import {useApolloClient}from'@apollo/client/index.js';import {useState,useEffect,useCallback}from'react';import {fetchFreeCreditsStatus,isPhoneStepClosed,FREE_CREDITS_CLAIM_FAILED,claimFreeCredits,claimRefusal,FreeCreditsClaimError,PHONE_ALREADY_CLAIMED_TEXT}from'./freeCredits.js';import {askForVerifiedPhone,endPhoneStep,showPhoneAlreadyClaimed}from'./freeCreditsPhoneStep.js';const claimListeners = /* @__PURE__ */ new Set();
2
+ function sayIfAlreadyClaimed(err) {
3
+ if (claimRefusal(err) !== "PHONE_ALREADY_CLAIMED") return err;
4
+ showPhoneAlreadyClaimed();
5
+ return new FreeCreditsClaimError(PHONE_ALREADY_CLAIMED_TEXT, "PHONE_ALREADY_CLAIMED");
6
+ }
7
+ async function claimWithPhoneStep(client, orgName) {
8
+ try {
9
+ return await claimFreeCredits(client, orgName);
10
+ } catch (err) {
11
+ if (claimRefusal(err) !== "PHONE_VERIFICATION_REQUIRED") throw sayIfAlreadyClaimed(err);
12
+ const outcome = await askForVerifiedPhone();
13
+ if (outcome === "unavailable") throw err;
14
+ if (outcome === "closed") {
15
+ throw new FreeCreditsClaimError(err.message, "PHONE_VERIFICATION_REQUIRED", true);
16
+ }
17
+ }
18
+ try {
19
+ const next = await claimFreeCredits(client, orgName);
20
+ endPhoneStep();
21
+ return next;
22
+ } catch (err) {
23
+ const failure = sayIfAlreadyClaimed(err);
24
+ if (failure === err) endPhoneStep();
25
+ throw failure;
26
+ }
27
+ }
2
28
  async function claimFreeCreditsForOrg(client, orgName) {
3
- const next = await claimFreeCredits(client, orgName);
29
+ const next = await claimWithPhoneStep(client, orgName);
4
30
  claimListeners.forEach((listener) => listener(orgName, next));
5
31
  return next;
6
32
  }
@@ -35,7 +61,7 @@ function useFreeCredits(orgName) {
35
61
  try {
36
62
  return await claimFreeCreditsForOrg(client, orgName);
37
63
  } catch (err) {
38
- setError(err instanceof Error ? err.message : FREE_CREDITS_CLAIM_FAILED);
64
+ if (!isPhoneStepClosed(err)) setError(err instanceof Error ? err.message : FREE_CREDITS_CLAIM_FAILED);
39
65
  return null;
40
66
  } finally {
41
67
  setClaiming(false);
@@ -1 +1 @@
1
- {"version":3,"file":"useFreeCredits.js","sources":["../../../src/features/credits/useFreeCredits.ts"],"sourcesContent":["import { useApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useState } from 'react';\nimport {\n claimFreeCredits,\n fetchFreeCreditsStatus,\n FREE_CREDITS_CLAIM_FAILED,\n type FreeCreditsStatus,\n} from './freeCredits';\n\nexport interface FreeCredits {\n /** Null until read, and when it cannot be read. */\n status: FreeCreditsStatus | null;\n claiming: boolean;\n /** The last claim's failure, in the server's words. */\n error: string | null;\n /** Claim the offer; resolves to the new status, or null when it failed (see `error`). */\n claim: () => Promise<FreeCreditsStatus | null>;\n}\n\ntype ClaimListener = (orgName: string, status: FreeCreditsStatus) => void;\n\n/** A claim in one surface updates the others (the web uses a `window` event for this). */\nconst claimListeners = new Set<ClaimListener>();\n\n/**\n * Claim the org's free credits through the offer, and tell every mounted useFreeCredits of\n * that org, so a card elsewhere (the home screen's) stops offering them. Throws with the\n * server's reason when refused.\n */\nexport async function claimFreeCreditsForOrg(\n client: Parameters<typeof claimFreeCredits>[0],\n orgName: string,\n): Promise<FreeCreditsStatus> {\n const next = await claimFreeCredits(client, orgName);\n claimListeners.forEach((listener) => listener(orgName, next));\n return next;\n}\n\n/** The org's free-tier offer for one surface. Idle while `orgName` is empty. */\nexport function useFreeCredits(orgName?: string | null): FreeCredits {\n const client = useApolloClient();\n const [status, setStatus] = useState<FreeCreditsStatus | null>(null);\n const [claiming, setClaiming] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (!orgName) return undefined;\n let live = true;\n void fetchFreeCreditsStatus(client, orgName).then((next) => {\n // A read that started before a claim must not take the claim back.\n if (live) setStatus((current) => (current?.unlocked ? current : next));\n });\n return () => {\n live = false;\n };\n }, [client, orgName]);\n\n useEffect(() => {\n const onClaimed: ClaimListener = (claimedOrg, next) => {\n if (claimedOrg === orgName) setStatus(next);\n };\n claimListeners.add(onClaimed);\n return () => {\n claimListeners.delete(onClaimed);\n };\n }, [orgName]);\n\n const claim = useCallback(async () => {\n if (!orgName) return null;\n setClaiming(true);\n setError(null);\n try {\n return await claimFreeCreditsForOrg(client, orgName);\n } catch (err) {\n setError(err instanceof Error ? err.message : FREE_CREDITS_CLAIM_FAILED);\n return null;\n } finally {\n setClaiming(false);\n }\n }, [client, orgName]);\n\n return { status, claiming, error, claim };\n}\n"],"names":[],"mappings":"0MAeA,MAAM,cAAA,uBAAqB,GAAmB,EAAA;AAOxB,eAAA,sBAAA,CAAuB,QAAgD,OAA6C,EAAA;AACxI,EAAA,MAAM,IAAO,GAAA,MAAM,gBAAiB,CAAA,MAAA,EAAQ,OAAO,CAAA;AACnD,EAAA,cAAA,CAA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AY,YAAY;AACpC,IAAI,IAAA,CAAC,SAAgB,OAAA,IAAA;AACrB,IAAA,WAAA,CAAY,IAAI,CAAA;AAChB,IAAA,QAAA,CAAS,IAAI,CAAA;AACb,IAAI,IAAA;AACF,MAAO,OAAA,MAAM,sBAAuB,CAAA,MAAA,EAAQ,OAAO,CAAA;AAAA,aAC5C,GAAK,EAAA;AACZ,MAAA,QAAA,CAAS,GAAe,YAAA,KAAA,GAAQ,GAAI,CAAA,OAAA,GAAU,yBAAyB,CAAA;AACvE,MAAO,OAAA,IAAA;AAAA,KACP,SAAA;AACA,MAAA,WAAA,CAAY,KAAK,CAAA;AAAA;AACnB,GACC,EAAA,CAAC,MAAQ,EAAA,OAAO,CAAC,CAAA;AACpB,EAAO,OAAA;AAAA,IACL,MAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACF;AACF"}
1
+ {"version":3,"file":"useFreeCredits.js","sources":["../../../src/features/credits/useFreeCredits.ts"],"sourcesContent":["import { useApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useState } from 'react';\nimport {\n claimFreeCredits,\n claimRefusal,\n fetchFreeCreditsStatus,\n FREE_CREDITS_CLAIM_FAILED,\n FreeCreditsClaimError,\n isPhoneStepClosed,\n PHONE_ALREADY_CLAIMED_TEXT,\n type FreeCreditsStatus,\n} from './freeCredits';\nimport { askForVerifiedPhone, endPhoneStep, showPhoneAlreadyClaimed } from './freeCreditsPhoneStep';\n\nexport interface FreeCredits {\n /** Null until read, and when it cannot be read. */\n status: FreeCreditsStatus | null;\n claiming: boolean;\n /** The last claim's failure, in the server's words. */\n error: string | null;\n /**\n * Claim the offer; resolves to the new status, or null when it failed (see `error`) or the phone step\n * was closed. When billing first wants a verified phone, it waits on the phone step and claims again\n * once the phone is verified, so one tap ends with the credits.\n */\n claim: () => Promise<FreeCreditsStatus | null>;\n}\n\ntype ClaimListener = (orgName: string, status: FreeCreditsStatus) => void;\n\n/** A claim in one surface updates the others (the web uses a `window` event for this). */\nconst claimListeners = new Set<ClaimListener>();\n\n/** A phone that already claimed: the sheet says so with the way on, and the claim fails with the same words. */\nfunction sayIfAlreadyClaimed(err: unknown): unknown {\n if (claimRefusal(err) !== 'PHONE_ALREADY_CLAIMED') return err;\n showPhoneAlreadyClaimed();\n return new FreeCreditsClaimError(PHONE_ALREADY_CLAIMED_TEXT, 'PHONE_ALREADY_CLAIMED');\n}\n\n/**\n * The claim, with billing's phone rule (2026-11-19): refused for an unverified phone, it asks for one\n * (freeCreditsPhoneStep) and, once the phone is verified, claims again by itself, once. A phone that\n * already claimed is told so and never claimed for again.\n */\nasync function claimWithPhoneStep(\n client: Parameters<typeof claimFreeCredits>[0],\n orgName: string,\n): Promise<FreeCreditsStatus> {\n try {\n return await claimFreeCredits(client, orgName);\n } catch (err) {\n if (claimRefusal(err) !== 'PHONE_VERIFICATION_REQUIRED') throw sayIfAlreadyClaimed(err);\n const outcome = await askForVerifiedPhone();\n // No sheet to ask with: the server's own words say what to do.\n if (outcome === 'unavailable') throw err;\n if (outcome === 'closed') {\n throw new FreeCreditsClaimError((err as Error).message, 'PHONE_VERIFICATION_REQUIRED', true);\n }\n }\n try {\n // Once: a second refusal is shown as it is, never another round of codes.\n const next = await claimFreeCredits(client, orgName);\n endPhoneStep();\n return next;\n } catch (err) {\n const failure = sayIfAlreadyClaimed(err);\n // The sheet says an already-claimed number itself; for anything else it closes.\n if (failure === err) endPhoneStep();\n throw failure;\n }\n}\n\n/**\n * Claim the org's free credits through the offer (with the phone step when billing wants a verified\n * phone first), and tell every mounted useFreeCredits of that org, so a card elsewhere (the home\n * screen's) stops offering them. Throws with the server's reason when refused.\n */\nexport async function claimFreeCreditsForOrg(\n client: Parameters<typeof claimFreeCredits>[0],\n orgName: string,\n): Promise<FreeCreditsStatus> {\n const next = await claimWithPhoneStep(client, orgName);\n claimListeners.forEach((listener) => listener(orgName, next));\n return next;\n}\n\n/** The org's free-tier offer for one surface. Idle while `orgName` is empty. */\nexport function useFreeCredits(orgName?: string | null): FreeCredits {\n const client = useApolloClient();\n const [status, setStatus] = useState<FreeCreditsStatus | null>(null);\n const [claiming, setClaiming] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (!orgName) return undefined;\n let live = true;\n void fetchFreeCreditsStatus(client, orgName).then((next) => {\n // A read that started before a claim must not take the claim back.\n if (live) setStatus((current) => (current?.unlocked ? current : next));\n });\n return () => {\n live = false;\n };\n }, [client, orgName]);\n\n useEffect(() => {\n const onClaimed: ClaimListener = (claimedOrg, next) => {\n if (claimedOrg === orgName) setStatus(next);\n };\n claimListeners.add(onClaimed);\n return () => {\n claimListeners.delete(onClaimed);\n };\n }, [orgName]);\n\n const claim = useCallback(async () => {\n if (!orgName) return null;\n setClaiming(true);\n setError(null);\n try {\n return await claimFreeCreditsForOrg(client, orgName);\n } catch (err) {\n // Closing the phone step is the person's choice, not a failure to report.\n if (!isPhoneStepClosed(err)) setError(err instanceof Error ? err.message : FREE_CREDITS_CLAIM_FAILED);\n return null;\n } finally {\n setClaiming(false);\n }\n }, [client, orgName]);\n\n return { status, claiming, error, claim };\n}\n"],"names":[],"mappings":"2XAoBA,MAAM,cAAA,uBAAqB,GAAmB,EAAA;AAG9C,SAAS,oBAAoB,GAAuB,EAAA;AAClD,EAAA,IAAI,YAAa,CAAA,GAAG,CAAM,KAAA,uBAAA,EAAgC,OAAA,GAAA;AAC1D,EAAwB,uBAAA,EAAA;AACxB,EAAO,OAAA,IAAI,qBAAsB,CAAA,0BAAA,EAA4B,uBAAuB,CAAA;AACtF;AAOA,eAAe,kBAAA,CAAmB,QAAgD,OAA6C,EAAA;AAC7H,EAAI,IAAA;AACF,IAAO,OAAA,MAAM,gBAAiB,CAAA,MAAA,EAAQ,OAAO,CAAA;AAAA,WACtC,GAAK,EAAA;AACZ,IAAA,IAAI,aAAa,GAAG,CAAA,KAAM,6BAA+B,EAAA,MAAM,oBAAoB,GAAG,CAAA;AACtF,IAAM,MAAA,OAAA,GAAU,M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1,4 +1,4 @@
1
- import {CommonActions}from'@react-navigation/native';import*as WebBrowser from'expo-web-browser';import {Linking}from'react-native';import {nativeTwinForSurface}from'../apps/nativeSurfaceTwin.js';import {designOpeningFromUrl}from'../design/surface/designLinks.js';import {computerParamsFromUrl}from'../computer/handoff.js';var __defProp = Object.defineProperty;
1
+ import {CommonActions}from'@react-navigation/native';import*as WebBrowser from'expo-web-browser';import {Linking}from'react-native';import {nativeTwinForSurface}from'../apps/nativeSurfaceTwin.js';import {designOpeningFromUrl}from'../design/surface/designLinks.js';import {computerParamsFromUrl}from'../computer/handoff.js';import {navigateAction}from'../../utils/drawerRoutes.js';var __defProp = Object.defineProperty;
2
2
  var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -40,11 +40,8 @@ function openSurfaceInApp(navigation, target) {
40
40
  }
41
41
  const twin = nativeTwinForSurface(target.surface);
42
42
  if (twin) {
43
- navigation.dispatch(CommonActions.navigate({
44
- name: twin.screen,
45
- params: {
46
- appTitle: twin.title
47
- }
43
+ navigation.dispatch(navigateAction(twin.screen, {
44
+ appTitle: twin.title
48
45
  }));
49
46
  return;
50
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"openInApp.js","sources":["../../../src/features/links/openInApp.ts"],"sourcesContent":["/**\n * Where a tapped link opens on the phone.\n *\n * A Yantra surface page opens on the app's native screen when it has one\n * (nativeSurfaceTwin), else in the app's own surface screen (WebBuilder),\n * which hands the page this device's sign-in - so a bounty link opens the\n * bounty in Freelance, signed in, ready to apply. Any other web page opens in\n * an in-app browser sheet, so reading a link never drops the person out of\n * Yantra. WHICH links are surface pages is the messenger gateway's call\n * (`Query.gatewayLinkPreview` -> `open`), not decided here.\n *\n * Shared by the messenger's host seam (portable-devices `useChatLinkSeam`) and\n * the assistant chat, so a link behaves the same wherever it was tapped.\n */\nimport { CommonActions, type NavigationProp, type ParamListBase } from '@react-navigation/native';\nimport * as WebBrowser from 'expo-web-browser';\nimport { Linking } from 'react-native';\nimport { nativeTwinForSurface } from '../apps/nativeSurfaceTwin';\nimport { designOpeningFromUrl, type DesignOpening } from '../design/surface/designLinks';\nimport { computerParamsFromUrl } from '../computer/handoff';\n\nexport interface InAppSurfaceTarget {\n surface: string;\n url: string;\n}\n\n/** `freelance` -> `Freelance`, `job-search` -> `Job Search`: the surface screen's header. */\nexport function surfaceTitle(slug: string): string {\n return slug\n .split(/[-_]+/)\n .filter(Boolean)\n .map((word) => word[0].toUpperCase() + word.slice(1))\n .join(' ');\n}\n\n/**\n * Open a surface page in the app's surface screen - the same navigation the\n * Apps catalog uses to open a surface tile, with the link's page as its URL.\n */\nexport function openSurfaceInApp(\n navigation: Pick<NavigationProp<ParamListBase>, 'dispatch'>,\n target: InAppSurfaceTarget,\n): void {\n // The Design surface has a native screen: its links open there (on the template\n // gallery when they ask for design templates), never the web surface in a WebView.\n const design =\n target.surface === 'design' || target.surface === 'design-native'\n ? (designOpeningFromUrl(target.url) ?? { templates: false })\n : designOpeningFromUrl(target.url);\n if (design) {\n openDesignNative(navigation, design);\n return;\n }\n // The Computer has a native screen: its links open there, a handoff link\n // (`mode=handoff&reason=…`) on the handoff with its reason - never the web\n // surface in a WebView.\n if (/^computer(?:-surface|-native)?$/i.test(target.surface.trim())) {\n navigation.dispatch(\n CommonActions.navigate({\n name: 'MainStack.ComputerNative',\n params: { appTitle: 'Computer', ...computerParamsFromUrl(target.url) },\n }),\n );\n return;\n }\n // Apps with a native screen (Shop, Travel, Job Search, ...) open it, as their Apps tile does.\n const twin = nativeTwinForSurface(target.surface);\n if (twin) {\n navigation.dispatch(CommonActions.navigate({ name: twin.screen, params: { appTitle: twin.title } }));\n return;\n }\n navigation.dispatch(\n CommonActions.navigate({\n name: 'MainStack.WebBuilder',\n params: { url: target.url, appTitle: surfaceTitle(target.surface) },\n }),\n );\n}\n\n/** Native Design, optionally on its template gallery with a search. */\nexport function openDesignNative(\n navigation: Pick<NavigationProp<ParamListBase>, 'dispatch'>,\n opening: DesignOpening,\n): void {\n navigation.dispatch(\n CommonActions.navigate({\n name: 'MainStack.DesignNative',\n params: {\n appTitle: 'Design',\n // A fresh value each time, so a second card re-opens the gallery on the reused screen.\n ...(opening.templates ? { templates: Date.now(), templatesQuery: opening.templatesQuery ?? '' } : {}),\n // Stamped for the same reason: a second link re-opens the work.\n ...(opening.studio ? { studio: { ...opening.studio, at: Date.now() } } : {}),\n },\n }),\n );\n}\n\n/** Open a web page in an in-app browser sheet; anything that is not a web page goes to the OS. */\nexport async function openWebPageInApp(url: string): Promise<void> {\n try {\n if (/^https?:\\/\\//i.test(url)) {\n await WebBrowser.openBrowserAsync(url, {\n presentationStyle: WebBrowser.WebBrowserPresentationStyle.PAGE_SHEET,\n dismissButtonStyle: 'close',\n });\n return;\n }\n await Linking.openURL(url);\n } catch {\n // A link that cannot be opened must not take the screen down with it.\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA0BO,SAAS,aAAa,IAAsB,EAAA;AACjD,EAAO,OAAA,IAAA,CAAK,MAAM,OAAO,CAAA,CAAE,OAAO,OAAO,CAAA,CAAE,IAAI,CAAQ,IAAA,KAAA,IAAA,CAAK,CAAC,CAAE,CAAA,WAAA,KAAgB,IAAK,CAAA,KAAA,CAAM,CAAC,CAAC,CAAA,CAAE,KAAK,GAAG,CAAA;AACxG;AAMgB,SAAA,gBAAA,CAAiB,YAA6D,MAAkC,EAAA;AAlChI,EAAA,IAAA,EAAA;AAqCE,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,OAAA,KAAY,QAAY,IAAA,MAAA,CAAO,OAAY,KAAA,eAAA,GAAA,CAAkB,EAAqB,GAAA,oBAAA,CAAA,MAAA,CAAO,GAAG,CAAA,KAA/B,IAAoC,GAAA,EAAA,GAAA;AAAA,IACrH,SAAW,EAAA;AAAA,GACb,GAAI,oBAAqB,CAAA,MAAA,CAAO,GAAG,CAAA;AACnC,EAAA,IAA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AAAA,MACpB,cAAA,EAAA,CAAgB,EAAQ,GAAA,OAAA,CAAA,cAAA,KAAR,IAA0B,GAAA,EAAA,GAAA;AAAA,KACxC,GAAA,EAEA,CAAA,EAAA,OAAA,CAAQ,MAAS,GAAA;AAAA,MACnB,MAAA,EAAQ,aACH,CAAA,cAAA,CAAA,EAAA,EAAA,OAAA,CAAQ,MADL,CAAA,EAAA;AAAA,QAEN,EAAA,EAAI,KAAK,GAAI;AAAA,OACf;AAAA,QACE,EAAC;AAAA,GAER,CAAC,CAAA;AACJ;AAGA,eAAsB,iBAAiB,GAA4B,EAAA;AACjE,EAAI,IAAA;AACF,IAAI,IAAA,eAAA,CAAgB,IAAK,CAAA,GAAG,CAAG,EAAA;AAC7B,MAAM,MAAA,UAAA,CAAW,iBAAiB,GAAK,EAAA;AAAA,QACrC,iBAAA,EAAmB,WAAW,2BAA4B,CAAA,UAAA;AAAA,QAC1D,kBAAoB,EAAA;AAAA,OACrB,CAAA;AACD,MAAA;AAAA;AAEF,IAAM,MAAA,OAAA,CAAQ,QAAQ,GAAG,CAAA;AAAA,GACnB,CAAA,OAAA,CAAA,EAAA;AAAA;AAGV"}
1
+ {"version":3,"file":"openInApp.js","sources":["../../../src/features/links/openInApp.ts"],"sourcesContent":["/**\n * Where a tapped link opens on the phone.\n *\n * A Yantra surface page opens on the app's native screen when it has one\n * (nativeSurfaceTwin), else in the app's own surface screen (WebBuilder),\n * which hands the page this device's sign-in - so a bounty link opens the\n * bounty in Freelance, signed in, ready to apply. Any other web page opens in\n * an in-app browser sheet, so reading a link never drops the person out of\n * Yantra. WHICH links are surface pages is the messenger gateway's call\n * (`Query.gatewayLinkPreview` -> `open`), not decided here.\n *\n * Shared by the messenger's host seam (portable-devices `useChatLinkSeam`) and\n * the assistant chat, so a link behaves the same wherever it was tapped.\n */\nimport { CommonActions, type NavigationProp, type ParamListBase } from '@react-navigation/native';\nimport * as WebBrowser from 'expo-web-browser';\nimport { Linking } from 'react-native';\nimport { nativeTwinForSurface } from '../apps/nativeSurfaceTwin';\nimport { designOpeningFromUrl, type DesignOpening } from '../design/surface/designLinks';\nimport { computerParamsFromUrl } from '../computer/handoff';\nimport { navigateAction } from '../../utils/drawerRoutes';\n\nexport interface InAppSurfaceTarget {\n surface: string;\n url: string;\n}\n\n/** `freelance` -> `Freelance`, `job-search` -> `Job Search`: the surface screen's header. */\nexport function surfaceTitle(slug: string): string {\n return slug\n .split(/[-_]+/)\n .filter(Boolean)\n .map((word) => word[0].toUpperCase() + word.slice(1))\n .join(' ');\n}\n\n/**\n * Open a surface page in the app's surface screen - the same navigation the\n * Apps catalog uses to open a surface tile, with the link's page as its URL.\n */\nexport function openSurfaceInApp(\n navigation: Pick<NavigationProp<ParamListBase>, 'dispatch'>,\n target: InAppSurfaceTarget,\n): void {\n // The Design surface has a native screen: its links open there (on the template\n // gallery when they ask for design templates), never the web surface in a WebView.\n const design =\n target.surface === 'design' || target.surface === 'design-native'\n ? (designOpeningFromUrl(target.url) ?? { templates: false })\n : designOpeningFromUrl(target.url);\n if (design) {\n openDesignNative(navigation, design);\n return;\n }\n // The Computer has a native screen: its links open there, a handoff link\n // (`mode=handoff&reason=…`) on the handoff with its reason - never the web\n // surface in a WebView.\n if (/^computer(?:-surface|-native)?$/i.test(target.surface.trim())) {\n navigation.dispatch(\n CommonActions.navigate({\n name: 'MainStack.ComputerNative',\n params: { appTitle: 'Computer', ...computerParamsFromUrl(target.url) },\n }),\n );\n return;\n }\n // Apps with a native screen (Shop, Travel, Job Search, ...) open it, as their Apps tile does.\n const twin = nativeTwinForSurface(target.surface);\n if (twin) {\n navigation.dispatch(navigateAction(twin.screen, { appTitle: twin.title }));\n return;\n }\n navigation.dispatch(\n CommonActions.navigate({\n name: 'MainStack.WebBuilder',\n params: { url: target.url, appTitle: surfaceTitle(target.surface) },\n }),\n );\n}\n\n/** Native Design, optionally on its template gallery with a search. */\nexport function openDesignNative(\n navigation: Pick<NavigationProp<ParamListBase>, 'dispatch'>,\n opening: DesignOpening,\n): void {\n navigation.dispatch(\n CommonActions.navigate({\n name: 'MainStack.DesignNative',\n params: {\n appTitle: 'Design',\n // A fresh value each time, so a second card re-opens the gallery on the reused screen.\n ...(opening.templates ? { templates: Date.now(), templatesQuery: opening.templatesQuery ?? '' } : {}),\n // Stamped for the same reason: a second link re-opens the work.\n ...(opening.studio ? { studio: { ...opening.studio, at: Date.now() } } : {}),\n },\n }),\n );\n}\n\n/** Open a web page in an in-app browser sheet; anything that is not a web page goes to the OS. */\nexport async function openWebPageInApp(url: string): Promise<void> {\n try {\n if (/^https?:\\/\\//i.test(url)) {\n await WebBrowser.openBrowserAsync(url, {\n presentationStyle: WebBrowser.WebBrowserPresentationStyle.PAGE_SHEET,\n dismissButtonStyle: 'close',\n });\n return;\n }\n await Linking.openURL(url);\n } catch {\n // A link that cannot be opened must not take the screen down with it.\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA2BO,SAAS,aAAa,IAAsB,EAAA;AACjD,EAAO,OAAA,IAAA,CAAK,MAAM,OAAO,CAAA,CAAE,OAAO,OAAO,CAAA,CAAE,IAAI,CAAQ,IAAA,KAAA,IAAA,CAAK,CAAC,CAAE,CAAA,WAAA,KAAgB,IAAK,CAAA,KAAA,CAAM,CAAC,CAAC,CAAA,CAAE,KAAK,GAAG,CAAA;AACxG;AAMgB,SAAA,gBAAA,CAAiB,YAA6D,MAAkC,EAAA;AAnChI,EAAA,IAAA,EAAA;AAsCE,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,OAAA,KAAY,QAAY,IAAA,MAAA,CAAO,OAAY,KAAA,eAAA,GAAA,CAAkB,EAAqB,GAAA,oBAAA,CAAA,MAAA,CAAO,GAAG,CAAA,KAA/B,IAAoC,GAAA,EAAA,GAAA;AAAA,IACrH,SAAW,EAAA;AAAA,GACb,GAAI,oBAAqB,CAAA,MAAA,CAAO,GAAG,CAAA;AACnC,EAAA,IAAI,MAAQ,EAAA;AACV,IAAA,gBAAA,CAAiB,YAAY,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AA;AAAA,KACxC,GAAA,EAEA,CAAA,EAAA,OAAA,CAAQ,MAAS,GAAA;AAAA,MACnB,MAAA,EAAQ,aACH,CAAA,cAAA,CAAA,EAAA,EAAA,OAAA,CAAQ,MADL,CAAA,EAAA;AAAA,QAEN,EAAA,EAAI,KAAK,GAAI;AAAA,OACf;AAAA,QACE,EAAC;AAAA,GAER,CAAC,CAAA;AACJ;AAGA,eAAsB,iBAAiB,GAA4B,EAAA;AACjE,EAAI,IAAA;AACF,IAAI,IAAA,eAAA,CAAgB,IAAK,CAAA,GAAG,CAAG,EAAA;AAC7B,MAAM,MAAA,UAAA,CAAW,iBAAiB,GAAK,EAAA;AAAA,QACrC,iBAAA,EAAmB,WAAW,2BAA4B,CAAA,UAAA;AAAA,QAC1D,kBAAoB,EAAA;AAAA,OACrB,CAAA;AACD,MAAA;AAAA;AAEF,IAAM,MAAA,OAAA,CAAQ,QAAQ,GAAG,CAAA;AAAA,GACnB,CAAA,OAAA,CAAA,EAAA;AAAA;AAGV"}
@@ -1,4 +1,4 @@
1
- import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useMemo,useState,useCallback,useRef,useEffect}from'react';import {StyleSheet,Alert,Linking,Keyboard,BackHandler,View,Text,Share,Clipboard}from'react-native';import {MaterialCommunityIcons}from'@expo/vector-icons';import {GestureHandlerRootView}from'react-native-gesture-handler';import {useSafeInsets}from'../canvas/withRemoteSafeArea.js';import {useAppTheme}from'../../theme/AppThemeProvider.js';import {Tap,DIM}from'../inbox/components/Tap.js';import {isBareSeed,studioTurnText,siteScoreTurn}from'./studioCatalog.js';import {brandKitNote,findDesires,importBrandKit}from'../design/surface/brandKit.js';import {useBrandKitInUse}from'../design/surface/useBrandKitInUse.js';import {BrandSheet}from'../design/surface/BrandSheet.js';import {moveLegacyBrandKit}from'./brandKitMove.js';import {titleFromPrompt,displayHost}from'./buildFragments.js';import {parseToolActivity}from'../chat/toolActivity.js';import {friendlySteps,firstContentLanded}from'./stepLabels.js';import {restoreTurnNote}from'./webbuilderPrompts.js';import {webbuilderTheme}from'./webbuilderTheme.js';import {CodeView}from'./components/CodeView.js';import {ProjectChat}from'./components/ProjectChat.js';import {ViewportToggle,PreviewScreen,ViewPicker}from'./components/PreviewScreen.js';import {PublishSheet}from'./components/PublishSheet.js';import {BOTTOM_TABS_SPACE,BottomTabs}from'./components/BottomTabs.js';import {SiteScoreSheet}from'./components/SiteScoreSheet.js';import {ProjectsScreen}from'./components/ProjectsScreen.js';import {TemplatesSheet}from'./components/TemplatesSheet.js';import {StudioHome}from'./components/StudioHome.js';import {VersionsSheet}from'./components/VersionsSheet.js';import {IconButton,Sheet,Toast}from'./components/ui.js';import {exportMessage,exportTurn}from'./exportCode.js';import {ownCloudflareTurn,projectNameOfLiveUrl,plainActionError}from'./publishTools.js';import {SecretsSheet}from'./components/SecretsSheet.js';import {CloudSheet}from'./components/CloudSheet.js';import {MAX_IMAGE_EDIT_BYTES,imageMimeFor}from'./web/code/imageEdit.js';import {useSiteCopyProgress,SiteCopyCard}from'./components/SiteCopyProgress.js';import {heldCopyLine,copyLine}from'./web/chat/siteCopy.js';import {publishDeployCheck}from'./web/publish/siteInsights.js';import {DraftBanner,DraftsSheet}from'./components/DraftsSheet.js';import {draftBuild,createDrafts}from'./drafts.js';import {draftTurnNote}from'./web/project/drafts.js';import {notReadyHint,projectReadiness}from'./readiness.js';import {SiteStatusSheet}from'./components/SiteStatusSheet.js';import {useRetention,RetentionBanner}from'./components/RetentionBanner.js';import {useGithubAutoSync}from'./useGithubAutoSync.js';import {githubSyncStatus,repoNameOf,githubSettingsPatch}from'./web/github/githubSync.js';import {syncChip,canRunSync}from'./web/github/autoSync.js';import {normalizeGithubRepoUrl}from'./web/project/serverSettings.js';import {ShareSheet}from'./components/ShareSheet.js';import {approvalsSettingsUrl}from'./approvalsLink.js';import {NotesSheet}from'./components/NotesSheet.js';import {projectShareLink}from'./web/sharing/shareLink.js';import {ignoresPatch}from'./web/publish/review/ignores.js';import {publishRequestComment}from'./web/publish/publishRequest.js';import {roleCan}from'./web/sharing/roles.js';import {remixSnapshotParams,snapshotIdFromResult,remixSecretsCheck,buildRemixUrl}from'./web/sharing/share.js';import {OutOfCreditsCard,CreditsSheet}from'./components/Credits.js';import {billingPageUrl}from'./creditsLinks.js';import {useWebBuilderCredits}from'./useWebBuilderCredits.js';import {OUT_OF_CREDITS_TITLE,outOfCreditsText,chipLabel}from'./web/credits/credits.js';import {IntegrationsPanel}from'./components/IntegrationsPanel.js';import {createWebServices}from'./web/webServices.js';import {websiteImportBrief}from'./web/import/websiteImport.js';import {siteForLink}from'./web/upload/sitePhotos.js';import {SiteUploadSheet}from'./components/SiteUploadSheet.js';import {GithubConnectSheet}from'./components/GithubConnectSheet.js';import {needsGithubConnection}from'./web/github/githubConnect.js';import {useUploadCard}from'./uploadCard.js';import {setupPhase}from'./web/preview/setupPhase.js';import {ProjectMenuSheet,ProjectSettingsSheet,GithubPushSheet,IntegrationsSheet,ImportProjectSheet}from'./components/ProjectSheets.js';import {isUserOwnedRepo,CODEZEN_NEEDS_GITHUB,codezenRepoHandoff,codezenRepoFragment,demoVideoSource,webbuilderDemoHandoff,encodeCodezenHandoff}from'./codezenHandoff.js';import {PreviewAccessProvider,openPreviewInBrowser}from'./usePreviewAccess.js';import {probePreviewPrivacy}from'./previewProbe.js';import {siteShareTarget,PRIVATE_SHARE_TITLE,privateShareMessage}from'./shareLink.js';var __defProp = Object.defineProperty;
1
+ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useMemo,useState,useCallback,useRef,useEffect}from'react';import {StyleSheet,Alert,Linking,Keyboard,BackHandler,View,Text,Share,Clipboard}from'react-native';import {MaterialCommunityIcons}from'@expo/vector-icons';import {GestureHandlerRootView}from'react-native-gesture-handler';import {useSafeInsets}from'../canvas/withRemoteSafeArea.js';import {useAppTheme}from'../../theme/AppThemeProvider.js';import {Tap,DIM}from'../inbox/components/Tap.js';import {isBareSeed,studioTurnText,siteScoreTurn}from'./studioCatalog.js';import {brandKitNote,findDesires,importBrandKit}from'../design/surface/brandKit.js';import {useBrandKitInUse}from'../design/surface/useBrandKitInUse.js';import {BrandSheet}from'../design/surface/BrandSheet.js';import {moveLegacyBrandKit}from'./brandKitMove.js';import {titleFromPrompt,displayHost}from'./buildFragments.js';import {parseToolActivity}from'../chat/toolActivity.js';import {friendlySteps,firstContentLanded}from'./stepLabels.js';import {restoreTurnNote}from'./webbuilderPrompts.js';import {webbuilderTheme}from'./webbuilderTheme.js';import {CodeView}from'./components/CodeView.js';import {ProjectChat}from'./components/ProjectChat.js';import {ViewportToggle,PreviewScreen,ViewPicker}from'./components/PreviewScreen.js';import {PublishSheet}from'./components/PublishSheet.js';import {BOTTOM_TABS_SPACE,BottomTabs}from'./components/BottomTabs.js';import {SiteScoreSheet}from'./components/SiteScoreSheet.js';import {ProjectsScreen}from'./components/ProjectsScreen.js';import {TemplatesSheet}from'./components/TemplatesSheet.js';import {StudioHome}from'./components/StudioHome.js';import {VersionsSheet}from'./components/VersionsSheet.js';import {IconButton,Sheet,Toast}from'./components/ui.js';import {exportMessage,exportTurn}from'./exportCode.js';import {ownCloudflareTurn,projectNameOfLiveUrl,plainActionError}from'./publishTools.js';import {SecretsSheet}from'./components/SecretsSheet.js';import {CloudSheet}from'./components/CloudSheet.js';import {MAX_IMAGE_EDIT_BYTES,imageMimeFor}from'./web/code/imageEdit.js';import {useSiteCopyProgress,SiteCopyCard}from'./components/SiteCopyProgress.js';import {heldCopyLine,copyLine}from'./web/chat/siteCopy.js';import {publishDeployCheck}from'./web/publish/siteInsights.js';import {DraftBanner,DraftsSheet}from'./components/DraftsSheet.js';import {draftBuild,createDrafts}from'./drafts.js';import {draftTurnNote}from'./web/project/drafts.js';import {notReadyHint,projectReadiness}from'./readiness.js';import {SiteStatusSheet}from'./components/SiteStatusSheet.js';import {useRetention,RetentionBanner}from'./components/RetentionBanner.js';import {useGithubAutoSync}from'./useGithubAutoSync.js';import {githubSyncStatus,repoNameOf,githubSettingsPatch}from'./web/github/githubSync.js';import {syncChip,canRunSync}from'./web/github/autoSync.js';import {normalizeGithubRepoUrl}from'./web/project/serverSettings.js';import {ShareSheet}from'./components/ShareSheet.js';import {approvalsSettingsUrl}from'./approvalsLink.js';import {NotesSheet}from'./components/NotesSheet.js';import {projectShareLink}from'./web/sharing/shareLink.js';import {ignoresPatch}from'./web/publish/review/ignores.js';import {publishRequestComment}from'./web/publish/publishRequest.js';import {roleCan}from'./web/sharing/roles.js';import {remixSnapshotParams,snapshotIdFromResult,remixSecretsCheck,buildRemixUrl}from'./web/sharing/share.js';import {OutOfCreditsCard,CreditsSheet}from'./components/Credits.js';import {billingPageUrl}from'./creditsLinks.js';import {useWebBuilderCredits}from'./useWebBuilderCredits.js';import {OUT_OF_CREDITS_TITLE,outOfCreditsText,chipLabel}from'./web/credits/credits.js';import {IntegrationsPanel}from'./components/IntegrationsPanel.js';import {createWebServices}from'./web/webServices.js';import {longTurn,turnDoneText}from'./web/notify/turnDone.js';import {liveSiteDeleteTools}from'./liveSiteDelete.js';import {CdecliConnectionContext}from'../../contexts/cdecliConnection.js';import {websiteImportBrief}from'./web/import/websiteImport.js';import {siteForLink}from'./web/upload/sitePhotos.js';import {AppPhoneSheet}from'./components/AppPhoneSheet.js';import {SiteUploadSheet}from'./components/SiteUploadSheet.js';import {GithubConnectSheet}from'./components/GithubConnectSheet.js';import {needsGithubConnection}from'./web/github/githubConnect.js';import {useUploadCard}from'./uploadCard.js';import {setupPhase}from'./web/preview/setupPhase.js';import {ProjectMenuSheet,ProjectSettingsSheet,GithubPushSheet,IntegrationsSheet,ImportProjectSheet}from'./components/ProjectSheets.js';import {isUserOwnedRepo,CODEZEN_NEEDS_GITHUB,codezenRepoHandoff,codezenRepoFragment,demoVideoSource,webbuilderDemoHandoff,encodeCodezenHandoff}from'./codezenHandoff.js';import {PreviewAccessProvider,openPreviewInBrowser}from'./usePreviewAccess.js';import {probePreviewPrivacy}from'./previewProbe.js';import {siteShareTarget,PRIVATE_SHARE_TITLE,privateShareMessage}from'./shareLink.js';var __defProp = Object.defineProperty;
2
2
  var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -65,9 +65,10 @@ function WebBuilderExperience({
65
65
  initialAgentSeed = null,
66
66
  uploadLink = null,
67
67
  onUploadLinkDone,
68
- previewAccess
68
+ previewAccess,
69
+ agentConnection = null
69
70
  }) {
70
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S;
71
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T;
71
72
  const appTheme = useAppTheme();
72
73
  const isDark = hostIsDark != null ? hostIsDark : appTheme.isDark;
73
74
  const theme = useMemo(() => webbuilderTheme(isDark), [isDark]);
@@ -212,6 +213,44 @@ ${draftTurnNote(openDraft, openDraft.sandboxId)}` : text, [openDraft]);
212
213
  }, action ? TOAST_ACTION_MS : TOAST_MS);
213
214
  }, []);
214
215
  useEffect(() => () => toastTimer.current ? clearTimeout(toastTimer.current) : void 0, []);
216
+ const aiTurnBusy = Boolean(hostChat == null ? void 0 : hostChat.busy);
217
+ const turnStarted = useRef(null);
218
+ const turnNotice = useRef({
219
+ title: siteTitle,
220
+ messages: hostChat == null ? void 0 : hostChat.messages
221
+ });
222
+ turnNotice.current = {
223
+ title: siteTitle,
224
+ messages: hostChat == null ? void 0 : hostChat.messages
225
+ };
226
+ useEffect(() => {
227
+ var _a2, _b2;
228
+ if (aiTurnBusy) {
229
+ if (!turnStarted.current) turnStarted.current = {
230
+ at: Date.now(),
231
+ channel: activeChannelId
232
+ };
233
+ return;
234
+ }
235
+ const started = turnStarted.current;
236
+ turnStarted.current = null;
237
+ if (!started || started.channel !== activeChannelId || !longTurn(started.at, Date.now())) return;
238
+ const reply = (_b2 = [...(_a2 = turnNotice.current.messages) != null ? _a2 : []].reverse().find((m) => m.role === "assistant")) == null ? void 0 : _b2.content;
239
+ const {
240
+ title,
241
+ body
242
+ } = turnDoneText(turnNotice.current.title, reply);
243
+ showToast(`${title}. ${body}`);
244
+ }, [aiTurnBusy]);
245
+ const [appPhoneOpen, setAppPhoneOpen] = useState(false);
246
+ const runOnSandbox = useMemo(
247
+ () => (publishTools == null ? void 0 : publishTools.run) && (build == null ? void 0 : build.sandboxId) ? (action, params, timeoutMs) => publishTools.run(build, action, __spreadValues({
248
+ sandbox_id: build.sandboxId
249
+ }, params), timeoutMs) : void 0,
250
+ // eslint-disable-next-line react-hooks/exhaustive-deps
251
+ [publishTools, build == null ? void 0 : build.key, build == null ? void 0 : build.sandboxId]
252
+ );
253
+ useEffect(() => setAppPhoneOpen(false), [activeChannelId]);
215
254
  const [mode, setMode] = useState("chat");
216
255
  const [viewport, setViewport] = useState("phone");
217
256
  useEffect(() => setMode("chat"), [activeChannelId]);
@@ -294,22 +333,7 @@ ${draftTurnNote(openDraft, openDraft.sandboxId)}` : text, [openDraft]);
294
333
  kind: "gone"
295
334
  };
296
335
  const activeProjectCover = (_l = (_k = projects.find((p) => p.channelId === activeChannelId)) == null ? void 0 : _k.coverUrl) != null ? _l : null;
297
- const coverWanted = Boolean((publishTools == null ? void 0 : publishTools.run) && activeChannelId && (build == null ? void 0 : build.sandboxId) && !build.coverUrl && !activeProjectCover && !building && !(hostChat == null ? void 0 : hostChat.busy) && !previewTrouble && !openDraft);
298
- useEffect(() => {
299
- if (!coverWanted || !build || !activeChannelId || coverAsked.has(activeChannelId)) return void 0;
300
- const channel = activeChannelId;
301
- const target = build;
302
- const timer = setTimeout(() => {
303
- coverAsked.add(channel);
304
- const builder = /next/i.test(target.templateId || "") ? "next" : "vite";
305
- publishTools == null ? void 0 : publishTools.run(target, "WEBBUILDER_FINISH", {
306
- sandbox_id: target.sandboxId,
307
- builder,
308
- workDir: "/home/yantra/repo"
309
- }, 3 * 60 * 1e3).catch(() => null);
310
- }, COVER_WARMUP_MS);
311
- return () => clearTimeout(timer);
312
- }, [coverWanted, build == null ? void 0 : build.key, activeChannelId]);
336
+ const coverWanted = Boolean(activeChannelId && (build == null ? void 0 : build.sandboxId) && !build.coverUrl && !activeProjectCover && !building && !(hostChat == null ? void 0 : hostChat.busy) && !previewTrouble && !openDraft);
313
337
  const wakePreview = useCallback((asked = false) => {
314
338
  if (!build || waking) return;
315
339
  if (openDraft) {
@@ -566,6 +590,41 @@ ${restoreTurnNote({
566
590
  appUrl: projectTools.appUrl,
567
591
  agentUrl: projectTools.agentUrl
568
592
  }) : null, [projectTools]);
593
+ useEffect(() => {
594
+ if (!coverWanted || !(build == null ? void 0 : build.sandboxId) || !activeChannelId || coverAsked.has(activeChannelId)) return void 0;
595
+ if (!webServices && !(publishTools == null ? void 0 : publishTools.run)) return void 0;
596
+ const channel = activeChannelId;
597
+ const target = build;
598
+ const timer = setTimeout(() => {
599
+ coverAsked.add(channel);
600
+ if (webServices) {
601
+ webServices.requestCover(channel, String(target.sandboxId)).catch(() => false);
602
+ return;
603
+ }
604
+ const builder = /next/i.test(target.templateId || "") ? "next" : "vite";
605
+ publishTools == null ? void 0 : publishTools.run(target, "WEBBUILDER_FINISH", {
606
+ sandbox_id: target.sandboxId,
607
+ builder,
608
+ workDir: "/home/yantra/repo"
609
+ }, 3 * 60 * 1e3).catch(() => null);
610
+ }, COVER_WARMUP_MS);
611
+ return () => clearTimeout(timer);
612
+ }, [coverWanted, build == null ? void 0 : build.key, activeChannelId, webServices]);
613
+ const siteDelete = useMemo(() => {
614
+ if (!webServices || !(publishTools == null ? void 0 : publishTools.run) || !activeChannelId) return null;
615
+ const runner = publishTools.run;
616
+ const target = build != null ? build : {
617
+ key: activeChannelId
618
+ };
619
+ return liveSiteDeleteTools({
620
+ services: webServices,
621
+ channelId: activeChannelId,
622
+ known: {
623
+ liveUrl: (project == null ? void 0 : project.liveUrl) || (build == null ? void 0 : build.liveUrl) || null
624
+ },
625
+ run: (action, params, timeoutMs) => runner(target, action, params, timeoutMs)
626
+ });
627
+ }, [webServices, publishTools, activeChannelId, build, project == null ? void 0 : project.liveUrl]);
569
628
  const githubSync = useGithubAutoSync({
570
629
  services: webServices,
571
630
  run: publishTools == null ? void 0 : publishTools.run,
@@ -1238,7 +1297,7 @@ ${secrets.note}` : ""}`, [{
1238
1297
  }];
1239
1298
  };
1240
1299
  const openMore = () => setProjectMenuOpen(true);
1241
- return /* @__PURE__ */ jsx(PreviewAccessProvider, { access: previewAccess, channelId: activeChannelId, children: /* @__PURE__ */ jsxs(GestureHandlerRootView, { style: [styles.fill, {
1300
+ return /* @__PURE__ */ jsx(CdecliConnectionContext.Provider, { value: agentConnection, children: /* @__PURE__ */ jsx(PreviewAccessProvider, { access: previewAccess, channelId: activeChannelId, children: /* @__PURE__ */ jsxs(GestureHandlerRootView, { style: [styles.fill, {
1242
1301
  backgroundColor: theme.screen
1243
1302
  }], children: [
1244
1303
  activeChannelId ? /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -1285,7 +1344,7 @@ ${secrets.note}` : ""}`, [{
1285
1344
  mode === "preview" ? /* @__PURE__ */ jsx(PreviewScreen, { build, building, loading: buildsLoading, previewNonce, onReload: () => setPreviewNonce((n) => n + 1), onWake: () => wakePreview(), waking, trouble: previewTrouble, onRetry: () => wakePreview(true), onRestore: restoreFromSavedCopy, onAskAiRestore: hostChat ? askAiToRestore : void 0, agentBusy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), steps: liveSteps, onPublish: openPublish, publishLabel, error: (_I = hostChat == null ? void 0 : hostChat.error) != null ? _I : null, theme, bottomInset: insets.bottom, viewport, unpublished: Boolean(build == null ? void 0 : build.sandboxId) && !(build == null ? void 0 : build.liveUrl), readSourceFile: code && build ? (path) => code.readFile(build, path, false).then((r) => {
1286
1345
  var _a2;
1287
1346
  return r.ok ? (_a2 = r.content) != null ? _a2 : null : null;
1288
- }) : void 0, onShowCode: canShowCode ? () => setMode("code") : void 0, buildingCover, setupNotice }) : null,
1347
+ }) : void 0, onShowCode: canShowCode ? () => setMode("code") : void 0, buildingCover, setupNotice, onOpenApp: () => setAppPhoneOpen(true) }) : null,
1289
1348
  mode === "code" ? /* @__PURE__ */ jsxs(View, { style: [styles.fill, {
1290
1349
  backgroundColor: theme.card,
1291
1350
  paddingBottom: insets.bottom
@@ -1316,7 +1375,7 @@ ${req.note}`), req.attachments, build);
1316
1375
  homeTab === "create" ? /* @__PURE__ */ jsx(View, { style: [styles.header, styles.headerBare, {
1317
1376
  paddingTop: insets.top + 4,
1318
1377
  borderBottomColor: "transparent"
1319
- }], children: /* @__PURE__ */ jsx(IconButton, { icon: "arrow-left", label: "Leave Web Builder", onPress: back, theme, testID: "webbuilder-back" }) }) : null,
1378
+ }], children: /* @__PURE__ */ jsx(IconButton, { icon: "chevron-left", label: "Leave Web Builder", onPress: back, theme, testID: "webbuilder-back" }) }) : null,
1320
1379
  /* @__PURE__ */ jsx(View, { style: styles.fill, children: homeTab === "create" ? /* @__PURE__ */ jsx(StudioHome, { draft, onDraft: setDraft, template, onClearTemplate: () => setTemplate(null), onBrowseTemplates: () => setTemplatesOpen(true), templates, onUseTemplate: (t, brief) => {
1321
1380
  pickTemplate(t);
1322
1381
  if (brief) setDraft(brief);
@@ -1335,7 +1394,7 @@ ${req.note}`), req.attachments, build);
1335
1394
  /* @__PURE__ */ jsx(BrandSheet, { visible: brandOpen, kits: brandKits.kits, active: brandKits.active, off: brandKits.off, loading: Boolean(brandTools) && brandKits.loading, error: brandTools ? brandKits.error : "Sign in to use your brand kits.", onClose: () => setBrandOpen(false), onPick: brandKits.pick, onOff: brandKits.setOff, onSave: brandKits.save, onDelete: brandKits.remove, onImport: (brandTools == null ? void 0 : brandTools.completeJson) ? (site) => importBrandKit(brandTools.completeJson, site) : void 0, onFindDesires: (brandTools == null ? void 0 : brandTools.completeJson) ? (d) => findDesires(brandTools.completeJson, d) : void 0 }),
1336
1395
  /* @__PURE__ */ jsx(ProjectMenuSheet, { visible: projectMenuOpen, title: siteTitle || "Project", sections: projectMenuOpen ? projectMenu() : [], onClose: () => setProjectMenuOpen(false), theme }),
1337
1396
  projectTools ? /* @__PURE__ */ jsxs(Fragment, { children: [
1338
- /* @__PURE__ */ jsx(ProjectSettingsSheet, { visible: settingsMode !== null, mode: settingsMode != null ? settingsMode : "settings", channelId: activeChannelId, title: siteTitle || "New app", tools: projectTools, aiBusy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), onSaved: () => showToast("Saved"), onDeleted: () => {
1397
+ /* @__PURE__ */ jsx(ProjectSettingsSheet, { visible: settingsMode !== null, mode: settingsMode != null ? settingsMode : "settings", channelId: activeChannelId, title: siteTitle || "New app", tools: projectTools, aiBusy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), findSite: siteDelete == null ? void 0 : siteDelete.findSite, unpublishSite: siteDelete == null ? void 0 : siteDelete.unpublishSite, onSaved: () => showToast("Saved"), onDeleted: () => {
1339
1398
  showToast("Project deleted");
1340
1399
  onCloseProject();
1341
1400
  setHomeTab("projects");
@@ -1400,10 +1459,11 @@ ${req.note}`), req.attachments, build);
1400
1459
  return true;
1401
1460
  }, onClose: () => setCloudOpen(false), theme }) : null,
1402
1461
  webServices ? /* @__PURE__ */ jsx(SecretsSheet, { visible: secretsOpen, channelId: activeChannelId, build, secrets: webServices.secrets, runAction: publishTools == null ? void 0 : publishTools.run, aiBusy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), onClose: () => setSecretsOpen(false), theme }) : null,
1462
+ /* @__PURE__ */ jsx(AppPhoneSheet, { visible: appPhoneOpen, previewUrl: (_O = build == null ? void 0 : build.previewUrl) != null ? _O : null, run: runOnSandbox, onClose: () => setAppPhoneOpen(false), theme }),
1403
1463
  /* @__PURE__ */ jsx(SiteUploadSheet, { visible: Boolean(uploadLink), onClose: () => {
1404
1464
  setUploadPicked(null);
1405
1465
  onUploadLinkDone == null ? void 0 : onUploadLinkDone();
1406
- }, linkState: uploadSite.state, site: uploadSite.site, choices: uploadSite.choices, onPickSite: (p) => setUploadPicked(p), ready: Boolean(uploadSite.site && activeChannelId === uploadSite.site.channelId && hostChat && build), busy: Boolean(hostChat == null ? void 0 : hostChat.busy) || Boolean(building), lastReply: uploadLastReply, messageCount: (_P = (_O = hostChat == null ? void 0 : hostChat.messages) == null ? void 0 : _O.length) != null ? _P : 0, messages: uploadLink ? hostChat == null ? void 0 : hostChat.messages : void 0, failed: Boolean(hostChat == null ? void 0 : hostChat.error), card: (uploadLink == null ? void 0 : uploadLink.card) ? uploadCard : null, previewUrl: uploadSite.site && build && activeChannelId === uploadSite.site.channelId ? build.previewUrl : null, onPublishNow: onPublish && build && roleCan(projectRole, "publish") ? async (target) => {
1466
+ }, linkState: uploadSite.state, site: uploadSite.site, choices: uploadSite.choices, onPickSite: (p) => setUploadPicked(p), ready: Boolean(uploadSite.site && activeChannelId === uploadSite.site.channelId && hostChat && build), busy: Boolean(hostChat == null ? void 0 : hostChat.busy) || Boolean(building), lastReply: uploadLastReply, messageCount: (_Q = (_P = hostChat == null ? void 0 : hostChat.messages) == null ? void 0 : _P.length) != null ? _Q : 0, messages: uploadLink ? hostChat == null ? void 0 : hostChat.messages : void 0, renderConnectorCard: hostChat == null ? void 0 : hostChat.renderConnectorCard, failed: Boolean(hostChat == null ? void 0 : hostChat.error), card: (uploadLink == null ? void 0 : uploadLink.card) ? uploadCard : null, previewUrl: uploadSite.site && build && activeChannelId === uploadSite.site.channelId ? build.previewUrl : null, onPublishNow: onPublish && build && roleCan(projectRole, "publish") ? async (target) => {
1407
1467
  if ((hostChat == null ? void 0 : hostChat.busy) || building) {
1408
1468
  return {
1409
1469
  ok: false,
@@ -1457,7 +1517,7 @@ ${req.note}`), req.attachments, build);
1457
1517
  /* @__PURE__ */ jsx(PublishSheet, { visible: publishOpen, build, publishing, onPublish: onPublish ? publish : void 0, onClose: () => setPublishOpen(false), theme, liveUrl: live, aiBusy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), tools: publishTools, onDownloadCode: (build == null ? void 0 : build.sandboxId) && !building ? downloadCode : void 0, onExport: hostChat && !building ? exportTo : void 0, onOwnCloudflare: hostChat && !building ? () => askAgent(ownCloudflareTurn(siteTitle || (build == null ? void 0 : build.title) || "")) : void 0, onFixWithAi: hostChat ? (text) => askAgent(text) : void 0, onUnpublished: () => showToast("The site is offline now."), onSiteStatus: (publishTools == null ? void 0 : publishTools.run) && live ? () => {
1458
1518
  setPublishOpen(false);
1459
1519
  setTimeout(() => setSiteStatusOpen(true), 300);
1460
- } : void 0, progressText: publishing ? (_Q = building == null ? void 0 : building.statusText) != null ? _Q : null : null, reviewIgnores, appUrl: projectTools == null ? void 0 : projectTools.appUrl, askToPublish: projectRole === "viewer" && (projectTools == null ? void 0 : projectTools.graphql) && activeChannelId ? async (note) => {
1520
+ } : void 0, progressText: publishing ? (_R = building == null ? void 0 : building.statusText) != null ? _R : null : null, reviewIgnores, appUrl: projectTools == null ? void 0 : projectTools.appUrl, askToPublish: projectRole === "viewer" && (projectTools == null ? void 0 : projectTools.graphql) && activeChannelId ? async (note) => {
1461
1521
  var _a2, _b2, _c2;
1462
1522
  const r = await projectTools.graphql.mutate(ADD_COMMENT_MUTATION, {
1463
1523
  channelId: activeChannelId,
@@ -1493,15 +1553,15 @@ ${req.note}`), req.attachments, build);
1493
1553
  setSelectedKey(picked.key === (latest == null ? void 0 : latest.key) ? null : picked.key);
1494
1554
  setVersionsOpen(false);
1495
1555
  }, onClose: () => setVersionsOpen(false), theme }),
1496
- /* @__PURE__ */ jsx(Sheet, { visible: menu !== null, title: (_R = menu == null ? void 0 : menu.title) != null ? _R : "", onClose: () => setMenu(null), theme, children: /* @__PURE__ */ jsx(View, { style: [styles.menuList, {
1556
+ /* @__PURE__ */ jsx(Sheet, { visible: menu !== null, title: (_S = menu == null ? void 0 : menu.title) != null ? _S : "", onClose: () => setMenu(null), theme, children: /* @__PURE__ */ jsx(View, { style: [styles.menuList, {
1497
1557
  paddingBottom: insets.bottom + 8
1498
- }], children: ((_S = menu == null ? void 0 : menu.actions) != null ? _S : []).map((action) => /* @__PURE__ */ jsx(Tap, { onPress: () => chooseMenu(action), accessibilityRole: "button", style: [styles.menuRow, {
1558
+ }], children: ((_T = menu == null ? void 0 : menu.actions) != null ? _T : []).map((action) => /* @__PURE__ */ jsx(Tap, { onPress: () => chooseMenu(action), accessibilityRole: "button", style: [styles.menuRow, {
1499
1559
  borderBottomColor: theme.border
1500
1560
  }], pressedStyle: DIM, children: /* @__PURE__ */ jsx(Text, { style: [styles.menuLabel, {
1501
1561
  color: action.destructive ? theme.crit : theme.ink
1502
1562
  }], children: action.label }) }, action.label)) }) }),
1503
1563
  /* @__PURE__ */ jsx(Toast, { message: toast, action: toastAction, theme, bottom: insets.bottom + 80 })
1504
- ] }) });
1564
+ ] }) }) });
1505
1565
  }
1506
1566
  const styles = StyleSheet.create({
1507
1567
  codeBar: {