{
  "version": 3,
  "sources": ["/cdn/shop/t/1064/assets/dtf-ai-page.js?auto=format%2Ccompress"],
  "sourcesContent": ["/* dtf-ai-page.js\n   Standalone-page glue for /pages/ai-image-creator.\n\n   Two jobs:\n     1. Strip out the legacy figure-click-to-upload behavior. On a product\n        page, clicking a result figure downloads the image into the upload\n        pipeline. On a standalone page that pipeline doesn't exist, so a\n        stray click would just fail silently. We open the image in a new\n        tab as a sane fallback.\n     2. Cross-page Order-as-DTF. dtf-ai-history.js dispatches\n        `md-picker:use-designs` when the user multi-selects history tiles\n        and clicks the black bar. There's no upload bridge listening on\n        this page, so we intercept the event, stash the payload in\n        sessionStorage, and navigate to /products/dtf-transfers, where\n        product-page-popups(-multiupload).liquid rehydrates the stash and\n        re-dispatches the event into the real upload pipeline. */\n(function () {\n  'use strict';\n\n  if (window.__dtfAiPageInit) return;\n  window.__dtfAiPageInit = true;\n\n  var STASH_KEY = 'dtf:pending-ai-uploads:v1';\n  var TARGET_URL = '/products/dtf-transfers';\n\n  function isStandalonePage() {\n    /* Detect by presence of the host element so we don't accidentally\n       hijack md-picker:use-designs on a normal product page that\n       somehow loaded this script (defensive). */\n    return !!document.querySelector('[data-dtf-ai-page]');\n  }\n\n  /* ---- 1. Capture md-picker:use-designs and hand off to product page ---- */\n  function onUseDesigns(e) {\n    if (!isStandalonePage()) return;\n    var items = (e && e.detail && e.detail.items) || [];\n    if (!items.length) return;\n\n    /* Stop the event so dtf-ai-history.js's closeAiModalIfOpen path is\n       the only side-effect; nothing else listens here, but other\n       listeners may be added later. */\n    if (typeof e.stopImmediatePropagation === 'function') {\n      e.stopImmediatePropagation();\n    }\n\n    try {\n      sessionStorage.setItem(STASH_KEY, JSON.stringify({\n        items: items,\n        ts: Date.now()\n      }));\n    } catch (err) { /* sessionStorage may be disabled \u2014 fall through */ }\n\n    /* Visual hint while we navigate so the user knows something is\n       happening on slow connections. */\n    showHandoffToast(items.length);\n\n    /* Defer the navigation a tick so the toast paints. */\n    setTimeout(function () {\n      window.location.assign(TARGET_URL);\n    }, 250);\n  }\n\n  function showHandoffToast(count) {\n    var t = document.createElement('div');\n    t.style.cssText = [\n      'position:fixed',\n      'left:50%',\n      'bottom:32px',\n      'transform:translateX(-50%)',\n      'background:#0f172a',\n      'color:#fff',\n      'font:600 14px/1.2 \"DM Sans\",system-ui,sans-serif',\n      'padding:14px 22px',\n      'border-radius:999px',\n      'box-shadow:0 12px 32px rgba(15,23,42,0.25)',\n      'z-index:99999',\n      'pointer-events:none'\n    ].join(';');\n    t.textContent = 'Sending ' + count + ' design' + (count === 1 ? '' : 's') +\n      ' to your DTF order\u2026';\n    document.body.appendChild(t);\n  }\n\n  document.addEventListener('md-picker:use-designs', onUseDesigns, true);\n\n  /* ---- 2. Open clicked figures in a new tab (no local upload pipeline) ---- */\n  /* The native generative-ai-image-modal.js binds figure clicks inside\n     #generative-ai-images to a download-and-add-to-upload handler. On a\n     standalone page that handler will fail because there's no upload\n     pipeline. Pre-empt it: capture-phase click on .dtfut__ai-chat-results\n     figures opens the original asset URL in a new tab instead. We don't\n     touch the history tiles \u2014 those still go through reuseItem which\n     dispatches a hidden figure click into the legacy flow, which on a\n     page with no upload pipeline will no-op. The selection-bar Order-as-DTF\n     path is the recommended way to use a history image off this page. */\n  document.addEventListener('click', function (e) {\n    if (!isStandalonePage()) return;\n    var fig = e.target && e.target.closest && e.target.closest('.dtfut__ai-chat-results figure');\n    if (!fig) return;\n    var url = fig.dataset && fig.dataset.url;\n    if (!url) return;\n    e.preventDefault();\n    e.stopPropagation();\n    window.open(url, '_blank', 'noopener');\n  }, true);\n})();\n"],
  "mappings": "CAgBC,UAAY,CACX,aAEA,GAAI,OAAO,gBAAiB,OAC5B,OAAO,gBAAkB,GAEzB,IAAI,UAAY,4BACZ,WAAa,0BAEjB,SAAS,kBAAmB,CAI1B,MAAO,CAAC,CAAC,SAAS,cAAc,oBAAoB,CACtD,CAGA,SAAS,aAAa,EAAG,CACvB,GAAK,iBAAiB,EACtB,KAAI,M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