import { r as registerInstance, d as createEvent, B as Build, h } from './index-26447f8a.js';
import { l as logic } from './getHandlebarsHelpers-0376b57c.js';
import { t as toastController } from './overlays-a3190093.js';
import { r as renderHandlebars } from './renderHandlebars-329aa13a.js';
import { s as state } from './store-838a3050.js';
import { g as getEventTypeOptions } from './getEventTypeOptions-3c1ed245.js';
import './_commonjsHelpers-7c4ea794.js';
import './index-e6b3332e.js';
import './ionic-global-b53b5faa.js';
import './helpers-06537f39.js';
import './index-9ae23364.js';
import './index-b0d3ac50.js';
import './localforage-c63d55c8.js';

const testLocation = {
  id: "kQs2TZlebsel1c5yQnWM",
  type: "corporate",
  name: "St. Louis",
  email: "stlouis@thefloodteam.com",
  photo: null,
  phone: "+3143103064",
  website: "floodteam-stl.com",
  isSearchable: true,
  dba: null,
  taxId: null,
  googleTagManagerId: "GTM-KXPR3MB",
  bannerPhoto: null,
  teamPhoto: null,
  address: {
    placeId: "ChIJl_9c8QnL2IcRzQVyRwJc_vw",
    lat: 38.611455,
    lng: -90.35094409999999,
    full: "8816 Manchester Rd Suite 197, St. Louis, MO 63144, USA",
    street: "8816 Manchester Road",
    unit: null,
    city: "St. Louis",
    state: "MO",
    zip: "63144",
    country: "US",
  },
  owner: {
    id: "KMyRIGHaMFbG6j5x5VONEoulKUH3",
    firstName: "Tony",
    lastName: "Tumminia",
    email: "tony@thefloodteam.com",
  },
  defaultPayModel: null,
  tags: null,
};

const testJob = {
  amountDeducted: 0,
  payModel: null,
  dateOfLoss: null,
  claimNumber: null,
  tags: null,
  services: [
    {
      quantity: 1,
      total: 1722.6,
      service: {
        id: "41HOaW9BlezSbfa46iGp",
        name: "Add for personal protective equipment - Heavy duty",
      },
      updatedAt: null,
      price: 39.15,
      id: "41HOaW9BlezSbfa46iGp",
      createdAt: "063782484305.223000000",
      amount: 44,
    },
    {
      id: "EPWAnGfBK8hqMbhS0B4a",
      createdAt: "063782368455.255000000",
      amount: 300,
      service: {
        name: "Eye protection - plastic goggles - Disposable",
        id: "EPWAnGfBK8hqMbhS0B4a",
      },
      quantity: 1,
      total: 3657,
      updatedAt: null,
      price: 12.19,
    },
  ],
  phone: "+13143133351",
  location: testLocation,
  customer: {
    lastName: null,
    firstName: null,
    email: "popcorn245@gmail.com",
    id: "iIrpecGWykUX151deLwu",
    phone: "+13143133351",
  },
  appointment: null,
  users: [
    {
      photo: null,
      firstName: "Bobby",
      id: "bumAIXVSbIR0SX9C8wISPkdLkQX2",
      email: "bobby@madnesslabs.net",
      lastName: "Johnson",
    },
    {
      email: "popcorn245@gmail.com",
      id: "iIrpecGWykUX151deLwu",
      firstName: null,
      lastName: null,
      photo: null,
    },
    {
      email: "bobby+wee@madnesslabs.net",
      firstName: "Bobby",
      id: "MidF454eQSP3TL3niRPShq3wSBL2",
      lastName: "Johnson",
      photo: null,
    },
    {
      photo: null,
      firstName: "Bobby",
      id: "qkaFKrgKsBYlQnS4oPDJ0MgLAQo2",
      lastName: "Johnson",
      email: "bobby@madnesslabs.net",
    },
    {
      lastName: "Tumminia",
      email: "tony@thefloodteam.com",
      id: "KMyRIGHaMFbG6j5x5VONEoulKUH3",
      photo: "/assets/svg/ft-person-suit.svg",
      firstName: "Tony",
    },
  ],
  category: null,
  matterportModelId: null,
  title: "Hank Hill",
  address: {
    country: null,
    street: "1551 Misty River Drive",
    lng: -90.7405867,
    placeId: "Ei0xNTUxIE1pc3R5IFJpdmVyIERyLCBTdCBQZXRlcnMsIE1PIDYzMzY2LCBVU0EiURJPCjQKMgkBzGZSONvehxGmUDLrqiQnixoeCxDuwe6hARoUChIJPy6SlBXP3ocRrjiLiYIvTBQMEI8MKhQKEgmZaO4yONvehxH5uYtwpj9cuA",
    zip: "63366",
    full: "1551 Misty River Dr, St Peters, MO 63366, USA",
    city: "St. Peters",
    state: "MO",
    unit: null,
    lat: 38.8795583,
  },
  readings: [],
  picture: null,
  sites: [
    {
      inventories: [],
      wallType: "Drywall",
      class: 3,
      updatedAt: "1647834619094",
      areaTotalSqft: 100,
      dots: [
        {
          id: "1Nb5r6M8QQGcaLNVVYuS",
          material: "Drywall",
          createdAt: "1646929502638",
          dryStandard: 44,
          placement: "Wall",
          evaporationPotentialGoal: 34,
          updatedAt: null,
          meter: "Hydrometer",
        },
      ],
      areas: [
        {
          cuft: 1000,
          lnft: null,
          height: 10,
          length: 10,
          sqft: 100,
          width: 10,
        },
      ],
      id: "mogIRfif4X30DbkGfbuI",
      affectedAreaTotalCuft: 216,
      affectedAreaTotalSqft: 36,
      floorType: "Carpet",
      photos: [
        {
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-10T02%3A24%3A59.812Z.jpeg?alt=media&token=14453c53-1f94-4081-ac51-14aa4fbcfc2d",
          default: false,
          id: "517U0dY443amXHRAFFWb",
        },
        {
          default: false,
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-10T03%3A00%3A38.510Z.jpg?alt=media&token=61669406-a5f1-499a-be2e-8bfc072505fe",
          id: "GlIyh1na6qYsGMmJwkAi",
        },
        {
          id: "KUxBXfZKPV6pt8Ua9Pms",
          default: false,
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-10T02%3A01%3A56.277Z.jpg?alt=media&token=4f793469-8c66-438a-adf4-edcb2e3aa11f",
        },
        {
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-08T20%3A31%3A56.651Z.jpg?alt=media&token=9324e318-2028-45db-a435-062712d251f0",
          id: "L0Shb7MJkDsLHgDiipl1",
          default: false,
        },
        {
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-08T20%3A32%3A04.320Z.jpg?alt=media&token=2937d752-bc4a-4f64-9881-cb3b9636c144",
          default: false,
          id: "PfgfUDePfObxWyE6zMJZ",
        },
        {
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-08T20%3A31%3A58.606Z.jpg?alt=media&token=4f4cc0d4-f8ba-4401-af6f-9fb8a0f43f73",
          default: false,
          id: "PjcpLjdfcfaiD3UAuS97",
        },
        {
          default: false,
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-08T20%3A31%3A53.002Z.jpg?alt=media&token=9606c270-b2f9-4387-84b3-55ce220b2a2a",
          id: "TGsAO5GPns6ZZWNWXspp",
        },
        {
          default: false,
          id: "btQ49oPRHrode2LIKVyt",
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-08T20%3A32%3A02.136Z.jpg?alt=media&token=1a84354c-5365-4c3f-a5c5-4b6d9f5f4bef",
        },
        {
          default: false,
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-08T20%3A31%3A54.937Z.jpg?alt=media&token=34a94ee3-e916-4216-a35e-003d6ffd7bab",
          id: "c29N12xu8UHWA7Agv5ZD",
        },
        {
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-08T20%3A31%3A51.175Z.jpg?alt=media&token=7420cd87-0e16-46d1-80bf-7a81b5d8f750",
          default: false,
          id: "c3qngzeV6FIbsMq5qIMV",
        },
        {
          id: "iT0MCUm6BtgIpFJroWHb",
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-08T20%3A32%3A00.400Z.jpg?alt=media&token=745d2299-3297-459b-aacf-d4b1df05207b",
          default: false,
        },
      ],
      name: "Basement",
      createdAt: "1646771410574",
      level: 1,
      job: {
        id: "29bfgrXpkMHzMeDFuc51",
        title: "Hank Hill",
      },
      areaTotalCuft: 1000,
      ceilingType: "Dropped",
      affectedAreas: [],
      chamber: 0,
      services: [
        {
          createdAt: "063782368428.316000000",
          quantity: 1,
          updatedAt: null,
          service: {
            id: "IVEX8speHgq4n8Qij5LV",
            name: "Water extraction from carpeted floor",
          },
          price: 0.49,
          amount: 300,
          total: 147,
          id: "IVEX8speHgq4n8Qij5LV",
        },
        {
          amount: 1,
          service: {
            name: "Apply bio cleaning agent (spore-based) to {V} - after hrs",
            id: "iJBeo2jA3Rj6o5WibZqf",
          },
          quantity: 1,
          id: "iJBeo2jA3Rj6o5WibZqf",
          total: 0.36,
          price: 0.36,
          updatedAt: null,
          createdAt: "063783944331.347000000",
        },
        {
          total: 216,
          updatedAt: null,
          amount: 300,
          createdAt: "063782368435.819000000",
          quantity: 1,
          service: {
            name: "Water extraction from carpeted floor- after hours",
            id: "rEwgLDYXoWIiOaMictXn",
          },
          price: 0.72,
          id: "rEwgLDYXoWIiOaMictXn",
        },
      ],
    },
    {
      class: 3,
      createdAt: "1647832151323",
      affectedAreaTotalSqft: 100,
      name: "Dining Room",
      id: "vaeksmKOIkn73chyqr8V",
      wallType: "Test",
      inventories: [],
      floorType: "Test",
      affectedAreaTotalCuft: 1000,
      job: {
        id: "29bfgrXpkMHzMeDFuc51",
        title: "Hank Hill",
      },
      areaTotalCuft: 1000,
      photos: [
        {
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-21T03%3A09%3A20.569Z.jpg?alt=media&token=4338727f-eec6-42d2-84e5-87ffe4183510",
          default: false,
          id: "Aswvia4ZL6vaEvPhoLsG",
        },
        {
          id: "D4Y37t3T2Yeh71prGaRe",
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-21T03%3A09%3A17.396Z.jpg?alt=media&token=bf9fd12c-2c7f-448e-9e50-4dd82cc6b003",
          default: false,
        },
        {
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-21T03%3A09%3A22.912Z.jpg?alt=media&token=e6ea57a9-6e00-4bf1-a3f9-18df62e331fd",
          id: "mhUu7ZdanPQWtCOEUb62",
          default: false,
        },
      ],
      services: [
        {
          id: "iJBeo2jA3Rj6o5WibZqf",
          price: 0.36,
          updatedAt: null,
          quantity: 1,
          amount: 1,
          total: 0.36,
          service: {
            name: "Apply bio cleaning agent (spore-based) to {V} - after hrs",
            id: "iJBeo2jA3Rj6o5WibZqf",
          },
          createdAt: "063783944333.281000000",
        },
        {
          amount: 5,
          id: "rEwgLDYXoWIiOaMictXn",
          createdAt: "063783432011.476000000",
          updatedAt: null,
          service: {
            id: "rEwgLDYXoWIiOaMictXn",
            name: "Water extraction from carpeted floor- after hours",
          },
          total: 72,
          quantity: 20,
          price: 0.72,
        },
      ],
      level: 1,
      ceilingType: "Test",
      dots: [],
      affectedAreas: [
        {
          cuft: 1000,
          lnft: null,
          length: 10,
          width: 10,
          height: 10,
          sqft: 100,
        },
      ],
      areas: [
        {
          length: 10,
          lnft: null,
          sqft: 100,
          cuft: 1000,
          width: 10,
          height: 10,
        },
      ],
      chamber: 0,
      updatedAt: "1647832197021",
      areaTotalSqft: 100,
    },
    {
      affectedAreas: null,
      inventories: [],
      name: "wee",
      services: [
        {
          id: "iJBeo2jA3Rj6o5WibZqf",
          service: {
            id: "iJBeo2jA3Rj6o5WibZqf",
            name: "Apply bio cleaning agent (spore-based) to {V} - after hrs",
          },
          amount: 1,
          updatedAt: null,
          price: 0.36,
          quantity: 1,
          createdAt: "063783944335.412000000",
          total: 0.36,
        },
      ],
      job: {
        id: "29bfgrXpkMHzMeDFuc51",
        title: "Hank Hill",
      },
      affectedAreaTotalSqft: null,
      class: 3,
      areaTotalSqft: null,
      areaTotalCuft: null,
      ceilingType: null,
      level: 1,
      chamber: 2,
      wallType: null,
      affectedAreaTotalCuft: null,
      photos: [
        {
          id: "SQDO7o6fUskTN0yS0Gyy",
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-21T03%3A53%3A30.926Z.jpg?alt=media&token=68e86c88-be8d-41bf-87f8-7e661d1bccf4",
          default: false,
        },
        {
          id: "pwFMU6zWuBIitQuQ7Rtq",
          default: false,
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-21T03%3A53%3A33.236Z.jpg?alt=media&token=149b9a87-2899-4ed5-97ed-b873bd03275f",
        },
        {
          url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/jobs%2F29bfgrXpkMHzMeDFuc51%2Fphotos2022-03-21T03%3A53%3A28.226Z.jpg?alt=media&token=650e84bf-f467-4d54-80ba-2b6d7380d0a1",
          id: "zrMOUp9BfVlC1Jw9msrH",
          default: false,
        },
      ],
      dots: [],
      floorType: null,
      id: "xWvXfIr8WACBWiqBbOHJ",
      updatedAt: "1647834825011",
      areas: null,
      createdAt: "1647834686573",
    },
  ],
  amountOwed: 5815.679999999999,
  cause: null,
  type: null,
  isFranchise: false,
  efileCount: null,
  amountBilled: 5815.679999999999,
  referral: {
    firstName: "Bobby",
    email: "bobby@madnesslabs.net",
    id: "bumAIXVSbIR0SX9C8wISPkdLkQX2",
    lastName: "Johnson",
  },
  status: "book",
  efiles: [
    {
      tags: null,
      id: "bhxCX8JwjuVcm5G1EEFR",
      name: "Photos Pdf",
      type: null,
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Photos%20Pdf-2022-04-14T21%3A25%3A56.373Z.pdf?alt=media&token=5d822ff8-c644-4aa4-b284-31603fe4b040",
    },
    {
      tags: null,
      name: "Certificate of Completion",
      id: "rqnaWUOzqaixSD9rYolH",
      type: null,
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Certificate%20of%20Completion-2022-04-14T21%3A22%3A47.243Z.pdf?alt=media&token=d8767f5c-cd6f-4f18-8340-ae8cd139361e",
    },
    {
      tags: null,
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Certificate%20of%20Completion-2022-04-14T20%3A23%3A00.360Z.pdf?alt=media&token=12c691c7-8462-44e5-a21a-a60e440543d8",
      id: "Xpy432Db4NQ9Jupbgcjl",
      type: null,
      name: "Certificate of Completion",
    },
    {
      tags: null,
      type: null,
      id: "CXpCY2yPQvNyZ6cLPqnT",
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Invoice%20PDF.pdf?alt=media&token=aa561e49-eb36-4b78-bdf4-438ce93e7e70",
      name: "Invoice PDF",
    },
    {
      type: null,
      id: "zkvUMCMx1dvDmed78Th3",
      name: "Photos Pdf",
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Photos%20Pdf.pdf?alt=media&token=8871beae-f917-46dc-b837-cfbb3be5bc4c",
      tags: null,
    },
    {
      id: "iNJCLdd5VQZIQj2CkqOF",
      type: null,
      name: "Invoice PDF",
      tags: null,
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Invoice%20PDF.pdf?alt=media&token=035021ac-cfbb-431a-9e32-dadb5e5d65eb",
    },
    {
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Photos%20Pdf.pdf?alt=media&token=345693c5-e51d-41c3-ad42-c3dc6bc69265",
      type: null,
      name: "Photos Pdf",
      tags: null,
      id: "wHZsyVITA18Bt4HAKWlx",
    },
    {
      tags: null,
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Invoice%20PDF.pdf?alt=media&token=27cb4f20-dc8f-46d8-8bca-b973d4e76eb6",
      id: "VjIMEAbmuBEq6MJnxnIh",
      type: null,
      name: "Invoice PDF",
    },
    {
      tags: null,
      type: null,
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Readings%20PDF.pdf?alt=media&token=ff6bcd49-10b6-4202-95df-963414d735ff",
      name: "Readings PDF",
      id: "V23j7hlWTwzxtagWRgem",
    },
    {
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Service%20Agreement.pdf?alt=media&token=65805ed0-826b-449e-bedf-6a592df55629",
      id: "O04GZzMce7LUhjLuhpnx",
      tags: null,
      type: null,
      name: "Service Agreement",
    },
    {
      id: "XsfC5WDldsnmyUmOe79F",
      tags: null,
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Direct%20Pay.pdf?alt=media&token=47a787dc-0636-4f1e-8145-3ffd788a1bb3",
      type: null,
      name: "Direct Pay",
    },
    {
      name: "Direct Pay",
      id: "DFg1TLhxODWzjwo6X51r",
      tags: null,
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Direct%20Pay.pdf?alt=media&token=841d3455-89da-40a1-9e10-d94cab98024d",
      type: null,
    },
    {
      name: "Invoice PDF",
      type: null,
      id: "qc10vNYAfxA3L530CUwm",
      tags: null,
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Invoice%20PDF.pdf?alt=media&token=40ab3d86-f370-44f7-94e7-92532c930fed",
    },
    {
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/2022-03-08T20%3A53%3A57.213Z.csv?alt=media&token=ad783185-63e5-4e61-aa1e-72e55dd17d8d",
      type: "upload",
      id: "Y1oLuUPlvYrJM8tdOp4o",
      tags: [],
      name: "Jobs.csv",
    },
    {
      type: null,
      id: "yBkhGwQOsjZXAMmZKym6",
      name: "Readings PDF",
      tags: null,
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Readings%20PDF.pdf?alt=media&token=094e7f77-1a0c-4492-b469-93709e0a9598",
    },
    {
      name: "Photos Pdf",
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Photos%20Pdf.pdf?alt=media&token=c10ce0d7-9048-453f-8f2e-b2ee31a3fd57",
      tags: null,
      id: "V6khavStLBbTzZNUoQvY",
      type: null,
    },
    {
      tags: null,
      type: null,
      id: "pw1yMP2jAEZpDqHcNdoc",
      name: "Invoice PDF",
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Invoice%20PDF.pdf?alt=media&token=0af615ba-427d-47f7-beb9-af053edfa2ae",
    },
    {
      name: "Photos Pdf",
      type: null,
      url: "https://firebasestorage.googleapis.com/v0/b/the-flood-team.appspot.com/o/Photos%20Pdf.pdf?alt=media&token=12d67419-9079-4e0b-8ce6-f0b7292b466f",
      id: "GovF5kYcMtGJRQ0jf4vr",
      tags: null,
    },
  ],
  id: "29bfgrXpkMHzMeDFuc51",
};

const testUser = {
  id: "qkaFKrgKsBYlQnS4oPDJ0MgLAQo2",
  online: null,
  firstName: "Bobby",
  lastName: "Johnson",
  isSetup: null,
  email: "bobby@madnesslabs.net",
  phone: "13143133351",
  active: null,
  photo: null,
  tags: null,
  trade: null,
  role: "referral",
  isOnboarded: null,
  isFranchise: null,
  isFranchiseOwner: null,
  birthday: null,
  slackHandle: null,
  rating: null,
  location: {
    id: "kQs2TZlebsel1c5yQnWM",
    name: "St. Louis",
    type: "corporate",
    defaultPayModel: null,
  },
  company: null,
  referredBy: null,
  friends: [],
  address: null,
  billingAddress: null,
};

function getNotionDatabaseOptions() {
  return [
    {
      label: "FT Roadmap",
      value: "{{config.notion.db.roadmap}}",
    },
    {
      label: "Events",
      value: "{{config.notion.db.events}}",
    },
    {
      label: "Companies",
      value: "{{config.notion.db.companies}}",
    },
    {
      label: "Locations",
      value: "{{config.notion.db.locations}}",
    },
    {
      label: "Team",
      value: "{{config.notion.db.team}}",
    },
    {
      label: "Income",
      value: "{{config.notion.db.income}}",
    },
    {
      label: "Expenses",
      value: "{{config.notion.db.expenses}}",
    },
    {
      label: "Bills",
      value: "{{config.notion.db.bills}}",
    },
    {
      label: "Domains",
      value: "{{config.notion.db.domains}}",
    },
    {
      label: "Endpoints",
      value: "{{config.notion.db.endpoints}}",
    },
    {
      label: "Materials",
      value: "{{config.notion.db.meterials}}",
    },
    {
      label: "Data Models",
      value: "{{config.notion.db.date_models}}",
    },
    {
      label: "Pay Models",
      value: "{{config.notion.db.pay_models}}",
    },
    {
      label: "Roles",
      value: "{{config.notion.db.roles}}",
    },
    {
      label: "Services",
      value: "{{config.notion.db.services}}",
    },
    {
      label: "Equipment",
      value: "{{config.notion.db.equipment}}",
    },
    {
      label: "Call Logs",
      value: "{{config.notion.db.call_logs}}",
    },
    {
      label: "Vehicle",
      value: "{{config.notion.db.vehicle}}",
    },
    {
      label: "Jobs",
      value: "{{config.notion.db.jobs}}",
    },
    {
      label: "Objectives and Key Results",
      value: "{{config.notion.db.objectives_and_key_results}}",
    },
    {
      label: "Ratings",
      value: "{{config.notion.db.ratings}}",
    },
    {
      label: "Users",
      value: "{{config.notion.db.users}}",
    },
    {
      label: "Units",
      value: "{{config.notion.db.units}}",
    },
    {
      label: "Templates",
      value: "{{config.notion.db.templates}}",
    },
    {
      label: "Personas",
      value: "{{config.notion.db.personas}}",
    },
    {
      label: "Flows",
      value: "{{config.notion.db.flows}}",
    },
  ];
}

const appTriggerCss = "app-trigger fireenjin-json-editor{display:block;position:static}";

const appTrigger = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.fireenjinFetch = createEvent(this, "fireenjinFetch", 7);
    this.fireenjinSubmit = createEvent(this, "fireenjinSubmit", 7);
    this.fireenjinTrigger = createEvent(this, "fireenjinTrigger", 7);
    this.seedData = {
      addJob: testJob,
      editJob: testJob,
      addLocation: testLocation,
      editLocation: testLocation,
      addUser: testUser,
      editUser: testUser,
      signContract: {
        job: testJob,
        url: "https://firebasestorage.googleapis.com/v0/b/ftms-ca85b.appspot.com/o/A%20New%20Job%20added%20(customer%20alert).png.png?alt=media&token=a64c1904-cebb-429e-bbfd-5351d301eaea",
        efile: {
          id: "test",
        },
      },
      addLog: {
        id: "test-log",
      },
      addNote: {
        id: "test-note",
      },
      editNote: {
        id: "test-note",
      },
      addPayable: {
        id: "addPayable-test",
      },
      editPayable: {
        id: "payable-test",
      },
      addPayment: {
        id: "payment-test",
      },
      editPayment: {
        id: "payment-test",
      },
    };
    this.payloadKey = {
      addJob: "job",
      editJob: "job",
      addLocation: "location",
      editLocation: "location",
      addUser: "user",
      editUser: "user",
      addLog: "log",
      addNote: "note",
      editNote: "note",
      addPayable: "payable",
      editPayable: "payable",
      addPayment: "payment",
      editPayment: "payment",
    };
    this.sampleOutput = {};
    this.defaultAlertPayload = {
      types: ["email"],
      emails: [],
      userIds: [],
      payload: {},
      options: {},
      sendAt: null,
      templateId: null,
      tags: [],
    };
    this.defaultTotallerPayload = {
      totallerId: null,
      before: null,
      after: null,
      extras: {},
      mergeData: {},
      dryRun: false,
    };
    this.defaultNotionPayload = {
      pageId: "{{data.notionId}}",
      docPath: null,
      databaseId: null,
    };
    this.triggerId = undefined;
    this.trigger = {};
    this.triggerWillFire = false;
    this.currentTab = "settings";
    this.showAdvanced = false;
    this.payload = undefined;
  }
  ionChange(event) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
    console.log("ionInput:", event);
    if (((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.name) && !event.target.name.startsWith("ion-"))
      this.setByPath(this.trigger, event.target.name, event.detail.value);
    if (((_b = event === null || event === void 0 ? void 0 : event.target) === null || _b === void 0 ? void 0 : _b.name) === "type" && !((_c = this.trigger) === null || _c === void 0 ? void 0 : _c.sampleData)) {
      if ((_d = this.seedData) === null || _d === void 0 ? void 0 : _d[(_e = event.detail) === null || _e === void 0 ? void 0 : _e.value])
        this.trigger.sampleData = (_f = this.seedData) === null || _f === void 0 ? void 0 : _f[(_g = event.detail) === null || _g === void 0 ? void 0 : _g.value];
      const alertPayload = {
        ...this.payload,
        types: [...(((_j = (_h = this.trigger) === null || _h === void 0 ? void 0 : _h.payload) === null || _j === void 0 ? void 0 : _j.types) || [])],
        emails: [...(((_l = (_k = this.trigger) === null || _k === void 0 ? void 0 : _k.payload) === null || _l === void 0 ? void 0 : _l.emails) || [])],
        userIds: [...(((_o = (_m = this.trigger) === null || _m === void 0 ? void 0 : _m.payload) === null || _o === void 0 ? void 0 : _o.userIds) || [])],
        templateId: ((_q = (_p = this.trigger) === null || _p === void 0 ? void 0 : _p.payload) === null || _q === void 0 ? void 0 : _q.templateId) || null,
        payload: this.payloadKey[(_r = this.trigger) === null || _r === void 0 ? void 0 : _r.type]
          ? {
            [this.payloadKey[(_s = this.trigger) === null || _s === void 0 ? void 0 : _s.type]]: "@data",
          }
          : {
            "...": "@data",
          },
        options: ((_u = (_t = this.trigger) === null || _t === void 0 ? void 0 : _t.payload) === null || _u === void 0 ? void 0 : _u.options) || {},
        sendAt: ((_w = (_v = this.trigger) === null || _v === void 0 ? void 0 : _v.payload) === null || _w === void 0 ? void 0 : _w.sendAt) || null,
        tags: ((_y = (_x = this.trigger) === null || _x === void 0 ? void 0 : _x.payload) === null || _y === void 0 ? void 0 : _y.tags) || [],
      };
      this.payload =
        ((_z = this.trigger) === null || _z === void 0 ? void 0 : _z.type) === "time"
          ? {
            action: "alert",
            queries: [
              {
                collection: "jobs",
                aliasAs: "job",
                filter: {
                  whereIn: {
                    status: [
                      "book",
                      "evaluate",
                      "claim",
                      "mitigate",
                      "monitor",
                      "review",
                    ],
                  },
                },
              },
            ],
            payload: alertPayload,
          }
          : alertPayload;
    }
    else if (event.target.name === "payload") {
      this.generateSampleOutput();
    }
    else if (event.target.name === "sampleData") {
      this.generateSampleOutput();
      this.triggerWillFire = this.checkIfTriggerFires(this.trigger.when);
    }
  }
  onChange(event) {
    setTimeout(() => {
      var _a, _b, _c, _d, _e, _f;
      console.log("ionChange:", event);
      if (((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.name) === "action") {
        this.showAdvanced = ((_b = event === null || event === void 0 ? void 0 : event.target) === null || _b === void 0 ? void 0 : _b.value) !== "alert";
        this.trigger = { ...this.trigger, action: (_c = event === null || event === void 0 ? void 0 : event.target) === null || _c === void 0 ? void 0 : _c.value };
        this.payload =
          ((_d = this.trigger) === null || _d === void 0 ? void 0 : _d.payload) ||
            (((_e = this.trigger) === null || _e === void 0 ? void 0 : _e.action) === "totaller"
              ? this.defaultTotallerPayload
              : ((_f = this.trigger) === null || _f === void 0 ? void 0 : _f.action) === "notion"
                ? this.defaultNotionPayload
                : this.defaultAlertPayload);
      }
    }, 1000);
  }
  async onCodeChange(event) {
    if (event.target.name === "payload") {
      this.payload = JSON.parse(event.target.value);
      this.trigger = { ...this.trigger, payload: this.payload };
      this.generateSampleOutput();
    }
    else if (event.target.name === "sampleData") {
      this.trigger.sampleData = JSON.parse(event.target.value);
      this.generateSampleOutput();
      this.triggerWillFire = this.checkIfTriggerFires(this.trigger.when);
    }
    else if (event.target.name === "when") {
      this.trigger.when = event.target.value;
      this.triggerWillFire = this.checkIfTriggerFires(this.trigger.when);
    }
    else if (event.target.name === "batch.when") {
      this.trigger.batch.when = event.target.value;
    }
    else if (event.target.name === "batch.transformer") {
      this.trigger.batch.transformer = event.target.value;
    }
  }
  onSuccess(event) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
    if (((_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) === "findTrigger") {
      this.trigger = ((_c = (_b = event === null || event === void 0 ? void 0 : event.detail) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.trigger) || null;
      this.payload =
        ((_d = this.trigger) === null || _d === void 0 ? void 0 : _d.payload) ||
          (((_e = this.trigger) === null || _e === void 0 ? void 0 : _e.action) === "totaller"
            ? this.defaultTotallerPayload
            : ((_f = this.trigger) === null || _f === void 0 ? void 0 : _f.action) === "notion"
              ? this.defaultNotionPayload
              : this.defaultAlertPayload);
    }
    else if (((_g = event === null || event === void 0 ? void 0 : event.detail) === null || _g === void 0 ? void 0 : _g.endpoint) === "addTrigger" &&
      this.triggerId === "new") {
      const routerEl = document.querySelector("ion-router");
      this.triggerId = ((_k = (_j = (_h = event === null || event === void 0 ? void 0 : event.detail) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j.addTemplate) === null || _k === void 0 ? void 0 : _k.id) || "new";
      if (routerEl)
        routerEl.push(`/triggers/${this.triggerId}`);
    }
  }
  setByPath(obj, path, value) {
    const pList = path.split(".");
    const len = pList.length;
    for (let i = 0; i < len - 1; i++) {
      const elem = pList[i];
      if (!obj[elem])
        obj[elem] = {};
      obj = obj[elem];
    }
    obj[pList[len - 1]] = value;
  }
  checkIfTriggerFires(when) {
    return !!logic.apply(typeof when === "string" ? JSON.parse(when) : when, {
      data: this.trigger.sampleData,
    });
  }
  generateSampleOutput() {
    var _a, _b, _c;
    let output = renderHandlebars(JSON.stringify(((_a = this.trigger) === null || _a === void 0 ? void 0 : _a.payload) || {}), {
      data: ((_b = this.trigger) === null || _b === void 0 ? void 0 : _b.sampleData) || {},
    });
    output = output.replace('"@data"', JSON.stringify(((_c = this.trigger) === null || _c === void 0 ? void 0 : _c.sampleData) || {}));
    this.jsonViewerEl.innerHTML = output;
    this.sampleOutput = JSON.parse(output);
    return output;
  }
  async save() {
    this.formEl.submit();
    (await toastController.create({
      message: "Trigger saved successfully!",
      duration: 2000,
    })).present();
  }
  async componentDidLoad() {
    if (!(Build === null || Build === void 0 ? void 0 : Build.isBrowser))
      return;
    this.fireenjinTrigger.emit({
      name: "subscribe",
      payload: {
        collection: "triggers",
        id: this.triggerId,
        callback: () => {
          this.formEl.fetchData();
        },
      },
    });
  }
  disconnectedCallback() {
    this.fireenjinTrigger.emit({
      name: "unsubscribe",
      payload: {
        collection: "triggers",
        id: this.triggerId,
      },
    });
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40;
    return [
      h("ion-content", { class: "ion-padding" }, h("fireenjin-form", { ref: (el) => (this.formEl = el), fetch: this.triggerId === "new" ? null : "findTrigger", "fetch-key": "trigger", endpoint: this.triggerId === "new" ? "addTrigger" : "editTrigger", documentId: this.triggerId === "new" ? null : this.triggerId, beforeSubmit: async (data) => ({
          ...data,
          payload: this.payload,
        }), formData: this.trigger, filterData: "name,type,when,action,payload,sampleData,active,batch", hideControls: true }, h("ion-card", { style: {
          overflow: "visible",
        } }, h("fireenjin-input-logic", { variables: {
          "job.title": {
            label: "Job Title",
            value: null,
          },
          "job.status": {
            label: "Job Status",
            options: [
              {
                label: "Started",
                value: "started",
              },
            ],
          },
        } }), h("ion-segment", { onIonChange: (event) => { var _a; return (this.currentTab = ((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value) || "settings"); }, style: { "--background": "rgba(0,0,0,0.2)" }, color: "primary", scrollable: true, value: this.currentTab }, h("ion-segment-button", { value: "settings", layout: "icon-start" }, h("ion-label", null, "Settings"), h("ion-icon", { name: "settings" })), h("ion-segment-button", { value: "action", layout: "icon-start" }, h("ion-label", null, "Action"), h("ion-icon", { name: "flash" })), h("ion-segment-button", { value: "test", layout: "icon-start" }, h("ion-label", null, "Test"), h("ion-icon", { name: "flashlight" }))), h("ion-card-content", { style: {
          opacity: this.currentTab === "settings" ? "1" : "0",
          height: this.currentTab === "settings" ? "auto" : "0",
          padding: this.currentTab === "settings" ? "1rem 2rem" : "0",
        } }, h("ion-grid", null, h("ion-row", null, h("ion-col", { size: "10" }, h("fireenjin-input", { "data-fill": true, labelPosition: "stacked", type: "text", name: "name", label: "Name", required: true })), h("ion-col", { size: "2" }, h("fireenjin-toggle", { value: (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.active, color: "primary", lines: "none", label: "Active", labelPosition: "stacked", name: "active" })))), h("fireenjin-select", { labelPosition: "stacked", "data-fill": true, name: "type", label: "Type", options: getEventTypeOptions(), required: true }), h("ion-item", { class: "json-editor-field", style: { zIndex: "3" } }, h("ion-label", null, h("h2", null, "When is this triggered?"), h("fireenjin-code-editor", { autoExpand: true, value: ((_b = this.trigger) === null || _b === void 0 ? void 0 : _b.when) || "{}", language: "json", name: "when" }))), h("ion-grid", null, h("ion-row", null, h("ion-col", { size: "10", class: "ion-align-self-center" }, h("h1", { style: {
          color: "var(--ion-text-color)",
          display: "block",
        } }, "Trigger Batching")), h("ion-col", { size: "2" }, h("fireenjin-toggle", { value: (_d = (_c = this.trigger) === null || _c === void 0 ? void 0 : _c.batch) === null || _d === void 0 ? void 0 : _d.active, color: "primary", lines: "none", label: "Active", labelPosition: "stacked", name: "batch.active" }))), h("ion-row", { style: {
          display: ((_f = (_e = this.trigger) === null || _e === void 0 ? void 0 : _e.batch) === null || _f === void 0 ? void 0 : _f.active) ? "block" : "none",
        } }, h("ion-col", null, h("fireenjin-input", { label: "Frequency", labelPosition: "stacked", name: "batch.frequency", type: "number", min: "5", max: "30" }), h("ion-item", { class: "json-editor-field", style: {
          zIndex: "3",
        } }, h("ion-label", null, h("h2", null, "When is this batched?"), h("fireenjin-code-editor", { autoExpand: true, value: ((_h = (_g = this.trigger) === null || _g === void 0 ? void 0 : _g.batch) === null || _h === void 0 ? void 0 : _h.when) || "{}", language: "json", name: "batch.when" }))), h("ion-item", { class: "json-editor-field" }, h("ion-label", null, h("h2", null, "Do we need to transform the template data?"), h("fireenjin-code-editor", { autoExpand: true, value: ((_k = (_j = this.trigger) === null || _j === void 0 ? void 0 : _j.batch) === null || _k === void 0 ? void 0 : _k.transformer) || "{}", language: "json", name: "batch.transformer" }))))))), h("ion-card-content", { style: {
          opacity: this.currentTab === "action" ? "1" : "0",
          height: this.currentTab === "action" ? "auto" : "0",
          padding: this.currentTab === "action" ? "1rem 2rem" : "0",
        } }, h("ion-grid", null, h("ion-row", null, h("ion-col", { size: "12", sizeMd: ((_l = this.trigger) === null || _l === void 0 ? void 0 : _l.action) === "alert" ? "7" : "12" }, h("fireenjin-select", { name: "action", label: "Action", labelPosition: "stacked", placeholder: "Select an Action", value: (_m = this.trigger) === null || _m === void 0 ? void 0 : _m.action, options: [
          {
            label: "Send Alert",
            value: "alert",
          },
          {
            label: "Run Totaller",
            value: "totaller",
          },
          {
            label: "Sync to Notion",
            value: "notion",
          },
        ], interface: "action-sheet" }), ((_o = this.trigger) === null || _o === void 0 ? void 0 : _o.action) === "notion" && [
        h("fireenjin-select", { name: "payload.databaseId", label: "Notion Page", labelPosition: "stacked", placeholder: "Select a Page", value: (_q = (_p = this.trigger) === null || _p === void 0 ? void 0 : _p.payload) === null || _q === void 0 ? void 0 : _q.databaseId, options: getNotionDatabaseOptions(), interface: "action-sheet" }),
        h("fireenjin-input", { name: "payload.docPath", label: "Firestore Document Path", labelPosition: "stacked", value: (_s = (_r = this.trigger) === null || _r === void 0 ? void 0 : _r.payload) === null || _s === void 0 ? void 0 : _s.docPath, placeholder: "/jobs/{{data.id}}" }),
      ], ((_t = this.trigger) === null || _t === void 0 ? void 0 : _t.action) === "alert" && (h("fireenjin-select", { "data-fill": true, multiple: true, name: "payload.types", label: "Types of Alerts", value: ((_v = (_u = this.trigger) === null || _u === void 0 ? void 0 : _u.payload) === null || _v === void 0 ? void 0 : _v.types) || ["email"], options: [
          "email",
          "feed",
          "text",
          "push",
          "call",
          "slack",
        ].map((value) => ({
          label: value,
          value,
        })) })), ((_w = this.trigger) === null || _w === void 0 ? void 0 : _w.action) === "alert" && (h("fireenjin-select", { name: "payload.templateId", label: "Template", labelPosition: "stacked", placeholder: "Select Message Template", value: ((_y = (_x = this.trigger) === null || _x === void 0 ? void 0 : _x.payload) === null || _y === void 0 ? void 0 : _y.templateId) || null, options: (state.templates || [])
          .filter((template) => !(template === null || template === void 0 ? void 0 : template.partial))
          .map((template) => ({
          label: template === null || template === void 0 ? void 0 : template.subject,
          value: template === null || template === void 0 ? void 0 : template.id,
        })), interface: "action-sheet" }))), ((_z = this.trigger) === null || _z === void 0 ? void 0 : _z.action) === "alert" && (h("ion-col", { size: "12", sizeMd: ((_0 = this.trigger) === null || _0 === void 0 ? void 0 : _0.action) === "alert" ? "5" : "12", style: { overflow: "auto" } }, h("floodteam-template", { id: "email-preview", allowFullscreen: true, zoom: 0.5, rawHtml: ((_1 = (state.templates || []).find((template) => { var _a, _b; return (template === null || template === void 0 ? void 0 : template.id) === ((_b = (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.templateId); })) === null || _1 === void 0 ? void 0 : _1.html) || "", data: this.sampleOutput.payload || {} })))), h("ion-row", null, h("ion-col", null, ((_2 = this.trigger) === null || _2 === void 0 ? void 0 : _2.action) === "alert" && (h("fireenjin-select-tags", { name: "payload.emails", label: "Email Addresses", options: (((_4 = (_3 = this.trigger) === null || _3 === void 0 ? void 0 : _3.payload) === null || _4 === void 0 ? void 0 : _4.emails) || []).map((email) => ({
          label: email,
          value: email,
        })), value: ((_6 = (_5 = this.trigger) === null || _5 === void 0 ? void 0 : _5.payload) === null || _6 === void 0 ? void 0 : _6.emails) || [], allowAdding: true })), ((_7 = this.trigger) === null || _7 === void 0 ? void 0 : _7.action) === "alert" && (h("fireenjin-select-tags", { name: "payload.options.email.cc", label: "Email CCs", options: (((_11 = (_10 = (_9 = (_8 = this.trigger) === null || _8 === void 0 ? void 0 : _8.payload) === null || _9 === void 0 ? void 0 : _9.options) === null || _10 === void 0 ? void 0 : _10.email) === null || _11 === void 0 ? void 0 : _11.cc) || []).map((email) => ({
          label: email,
          value: email,
        })), value: ((_15 = (_14 = (_13 = (_12 = this.trigger) === null || _12 === void 0 ? void 0 : _12.payload) === null || _13 === void 0 ? void 0 : _13.options) === null || _14 === void 0 ? void 0 : _14.email) === null || _15 === void 0 ? void 0 : _15.cc) || [], allowAdding: true })), ((_16 = this.trigger) === null || _16 === void 0 ? void 0 : _16.action) === "alert" && (h("fireenjin-select-tags", { name: "payload.options.email.bcc", label: "Email BCCs", options: (((_20 = (_19 = (_18 = (_17 = this.trigger) === null || _17 === void 0 ? void 0 : _17.payload) === null || _18 === void 0 ? void 0 : _18.options) === null || _19 === void 0 ? void 0 : _19.email) === null || _20 === void 0 ? void 0 : _20.bcc) || []).map((email) => ({
          label: email,
          value: email,
        })), value: ((_24 = (_23 = (_22 = (_21 = this.trigger) === null || _21 === void 0 ? void 0 : _21.payload) === null || _22 === void 0 ? void 0 : _22.options) === null || _23 === void 0 ? void 0 : _23.email) === null || _24 === void 0 ? void 0 : _24.bcc) || [], allowAdding: true })), ((_25 = this.trigger) === null || _25 === void 0 ? void 0 : _25.action) === "alert" && (h("fireenjin-select-tags", { name: "payload.userIds", label: "User IDs", options: (((_27 = (_26 = this.trigger) === null || _26 === void 0 ? void 0 : _26.payload) === null || _27 === void 0 ? void 0 : _27.userIds) || []).map((userId) => ({
          label: userId,
          value: userId,
        })), value: ((_29 = (_28 = this.trigger) === null || _28 === void 0 ? void 0 : _28.payload) === null || _29 === void 0 ? void 0 : _29.userIds) || [], allowAdding: true })), ((_30 = this.trigger) === null || _30 === void 0 ? void 0 : _30.action) === "alert" && (h("fireenjin-select-tags", { name: "payload.locationIds", label: "Locations", options: [
          ...(((_32 = (_31 = this.trigger) === null || _31 === void 0 ? void 0 : _31.payload) === null || _32 === void 0 ? void 0 : _32.locationIds) || [])
            .filter((locationId) => {
            var _a, _b;
            return !((_b = (_a = state === null || state === void 0 ? void 0 : state.locations) === null || _a === void 0 ? void 0 : _a.find) === null || _b === void 0 ? void 0 : _b.call(_a, (location) => (location === null || location === void 0 ? void 0 : location.id) === locationId));
          })
            .map((locationId) => ({
            id: locationId,
            name: locationId,
          })),
          ...((state === null || state === void 0 ? void 0 : state.locations) || []),
        ].map(({ id, name }) => ({
          label: name,
          value: id,
        })), value: ((_34 = (_33 = this.trigger) === null || _33 === void 0 ? void 0 : _33.payload) === null || _34 === void 0 ? void 0 : _34.locationIds) || [], allowAdding: true }))))), h("ion-item", { href: "#", detail: true, detailIcon: this.showAdvanced ? "chevron-up" : "chevron-down", onClick: () => (this.showAdvanced = !this.showAdvanced) }, h("ion-label", null, "Advanced")), h("ion-item", { style: {
          opacity: this.showAdvanced ? "1" : "0",
          height: this.showAdvanced ? "auto" : "0",
          overflow: "visible",
        }, class: "json-editor-field" }, h("ion-label", { class: "ion-text-wrap" }, h("h2", null, "What payload is passed to the action?"), h("fireenjin-code-editor", { ref: (el) => (this.payloadEl = el), autoExpand: true, value: JSON.stringify(((_35 = this.trigger) === null || _35 === void 0 ? void 0 : _35.payload) ||
          (((_36 = this.trigger) === null || _36 === void 0 ? void 0 : _36.action) === "totaller"
            ? this.defaultTotallerPayload
            : ((_37 = this.trigger) === null || _37 === void 0 ? void 0 : _37.action) === "notion"
              ? {}
              : this.defaultAlertPayload), null, 4), language: "json", name: "payload" })))), h("ion-card-content", { style: {
          opacity: this.currentTab === "test" ? "1" : "0",
          height: this.currentTab === "test" ? "auto" : "0",
          padding: this.currentTab === "test" ? "1rem 2rem" : "0",
        } }, h("ion-grid", null, h("ion-row", null, h("ion-col", { size: "12", sizeMd: "6" }, h("fireenjin-code-editor", { ref: (el) => (this.sampleDataEl = el), autoExpand: true, value: JSON.stringify(((_38 = this.trigger) === null || _38 === void 0 ? void 0 : _38.sampleData) || {}, null, 4), language: "json", name: "sampleData" })), h("ion-col", { size: "12", sizeMd: "6" }, h("fireenjin-json-viewer", { ref: (el) => (this.jsonViewerEl = el), watcher: true }))))))), h("br", null), h("br", null), h("br", null), h("br", null), h("br", null), h("br", null), h("br", null), h("br", null)),
      h("floodteam-navigation-footer", null, h("floodteam-title-bar", { back: "/triggers" }, h("ion-breadcrumbs", null, h("ion-breadcrumb", { href: "/triggers" }, h("ion-icon", { class: "ft-icon-style", slot: "start", name: "flash" }), "Triggers"), h("ion-breadcrumb", { onClick: () => {
          var _a;
          return this.fireenjinTrigger.emit({
            name: "pin",
            payload: {
              icon: "flash",
              href: `/triggers/${this.triggerId}`,
              name: ((_a = this.trigger) === null || _a === void 0 ? void 0 : _a.name) || "Add a Trigger",
            },
          });
        } }, h("ion-icon", { color: ((_39 = ((state === null || state === void 0 ? void 0 : state.pins) || [])
          .map((pin) => pin === null || pin === void 0 ? void 0 : pin.href)) === null || _39 === void 0 ? void 0 : _39.includes(`/triggers/${this.triggerId}`))
          ? "primary"
          : null, slot: "start", name: "pin" }), (this.triggerId === "new" && "Add a Trigger") ||
        ((_40 = this.trigger) === null || _40 === void 0 ? void 0 : _40.name) ||
        "Edit Trigger")), h("ion-buttons", { slot: "end" }, h("ion-button", { color: this.triggerWillFire ? "warning" : "medium", fill: this.triggerWillFire ? "solid" : "outline", disabled: !this.triggerWillFire, onClick: () => this.fireenjinSubmit.emit({
          endpoint: "addAlert",
          data: JSON.parse(this.generateSampleOutput()),
        }) }, "Fire"), h("ion-button", { fill: "solid", color: "primary", onClick: () => this.save() }, "Save")))),
      ,
    ];
  }
};
appTrigger.style = appTriggerCss;

export { appTrigger as app_trigger };
