(this.webpackJsonpNextApp=this.webpackJsonpNextApp||[]).push([[0],{1006:function(e,t){},107:function(e,t,n){"use strict";t.a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"name",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"asc";return e.sort((function(e,a){var r,c,i=(null===(r=e[t])||void 0===r?void 0:r.toString().toLowerCase())||"",o=(null===(c=a[t])||void 0===c?void 0:c.toString().toLowerCase())||"";if(!i)return 1;if(!o)return-1;var s=i.localeCompare(o);return"asc"===n?s:-s}))}},1259:function(e,t){},1283:function(e,t,n){},13:function(e,t,n){"use strict";n.r(t);var a=n(31),r=n.n(a);t.default=function(e){if(!r.a.isCancel(e)&&"AbortError"!==e.name)throw e;console.log(e.message)}},1356:function(e,t,n){},1438:function(e,t,n){},1463:function(e,t){},1465:function(e,t,n){},1466:function(e,t,n){},1467:function(e,t,n){},1470:function(e,t,n){},1471:function(e,t,n){},1472:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/alfalfa.7db083bd.svg"},1473:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/almonds.de691138.svg"},1474:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/apples.db5096fe.svg"},1475:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/apricots.442b68ec.svg"},1476:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/artichokeGlobe.856ee9cf.svg"},1477:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/asparagus.42faad35.svg"},1478:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/barley.46b814b8.svg"},1479:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/broadBeans.6583546e.svg"},1480:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/beetroot.913885e3.svg"},1481:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/blackberries.c7d26a29.svg"},1482:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/brusselSprouts.bfc21232.svg"},1483:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/cabbage.b5e8d068.svg"},1484:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/canola.1700a9de.svg"},1485:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/carrots.3c68d3c4.svg"},1486:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/cauliflower.d506cfd5.svg"},1487:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/celery.142666a6.svg"},1488:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/cherries.3a13cf27.svg"},1489:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/chickpeas.1deb0381.svg"},1490:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/chives.f9767145.svg"},1491:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/clover.1db6fcb4.svg"},1492:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/coffee.0b4b8d2b.svg"},1493:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/coriander.46cd4f93.svg"},1494:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/cotton.eb8e726b.svg"},1495:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/cucumber.26498f98.svg"},1496:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/dillLeaf.5e944405.svg"},1497:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/endive.ef098cca.svg"},1498:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/forageCorn.0c7c7cc8.svg"},1499:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/garlic.1c4fdb11.svg"},1500:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/grassesSeed.44dd6b7a.svg"},1501:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/hazelnuts.58e8891c.svg"},1502:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/hops.d8be9731.svg"},1503:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/leeks.c3dcdb07.svg"},1504:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/lettuces.bffa5592.svg"},1505:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/millet.81b7c182.svg"},1506:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/mushrooms.efc7b915.svg"},1507:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/oats.75e13b88.svg"},1508:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/oilseedRape.1700a9de.svg"},1509:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/onions.6b7dec65.svg"},1510:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/parsnips.696ef4e4.svg"},1511:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/peanuts.a1b21f55.svg"},1512:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/pears.c07290f8.svg"},1513:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/peas.f27fb9e4.svg"},1514:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/pecans.b340c854.svg"},1515:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/peppers.8561291c.svg"},1516:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/pistachios.46898a01.svg"},1517:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/plums.0beb9da0.svg"},1518:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/pomeFruits.db5096fe.svg"},1519:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/potato.4994e6be.svg"},1520:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/pumpkins.ac87086a.svg"},1521:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/radicchio.adc5eef2.svg"},1522:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/raspberries.45e77140.svg"},1523:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/rhubarb.6e798d13.svg"},1524:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/rice.536bd8e8.svg"},1525:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/rye.46b814b8.svg"},1526:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/soybeans.6583546e.svg"},1527:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/spinach.13c1594c.svg"},1528:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/squash.e78ba34d.svg"},1529:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/strawberries.ca59534d.svg"},1530:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/sugarBeet.55156b04.svg"},1531:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/sugarcane.3621413b.svg"},1532:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/sunflower.6cc6c9eb.svg"},1533:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/sweetPotato.af7baf43.svg"},1534:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/tobacco.5aaf9199.svg"},1535:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/tomatoes.52bf56ef.svg"},1536:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/treeNuts.58e8891c.svg"},1537:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/triticale.46b814b8.svg"},1538:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/vetch.c35fc4fb.svg"},1539:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/walnuts.8aacdf18.svg"},1540:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/watermelon.28b15a96.svg"},1541:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/wheat.60c49277.svg"},1542:function(e,t,n){},1543:function(e,t,n){},1544:function(e,t,n){},1545:function(e,t,n){},1546:function(e,t,n){},1547:function(e,t,n){},1548:function(e,t,n){},1549:function(e,t,n){},1550:function(e,t,n){},1551:function(e,t,n){},1552:function(e,t,n){},1553:function(e,t,n){},1554:function(e,t,n){},1555:function(e,t,n){},1556:function(e,t,n){},1557:function(e,t,n){},1558:function(e,t,n){},1559:function(e,t,n){},1560:function(e,t,n){},1561:function(e,t,n){},1643:function(e,t,n){},1679:function(e,t,n){},1680:function(e,t,n){},1681:function(e,t,n){},1682:function(e,t,n){},1683:function(e,t,n){},1684:function(e,t,n){},1685:function(e,t,n){},1686:function(e,t,n){},1687:function(e,t,n){},1688:function(e,t,n){},1689:function(e,t,n){},1690:function(e,t,n){},1691:function(e,t,n){},1692:function(e,t,n){},1693:function(e,t,n){},1694:function(e,t,n){},1696:function(e,t,n){},1697:function(e,t,n){},20:function(e,t,n){"use strict";n.d(t,"g",(function(){return r})),n.d(t,"a",(function(){return c})),n.d(t,"c",(function(){return i})),n.d(t,"b",(function(){return o})),n.d(t,"e",(function(){return s})),n.d(t,"d",(function(){return l})),n.d(t,"f",(function(){return u}));var a={"acre inch":"ac in",acre:"ac",bushel:"bu","british ton":"brit. ton",centimeter:"cm",centiliter:"cL",cubic:"cu","cubic centimeter":"cu cm","cubic foot":"cu ft","cubic inch":"cu in","cubic meter":"cu m","cubic yard":"cu yd","cwt (hundredweight)":"cwt",day:"d",dozen:"doz","fluid ounce":"fl oz",foot:"ft",gallon:"gal",grain:"gr",gram:"g",gross:"gro",hectare:"ha",hour:"h",inch:"in",kilogram:"kg",kiloliter:"kl",kilometer:"km",liter:"L","long ton":"Brit. ton",meter:"m","metric ton":"m ton",micrometer:"\u03bcm",mile:"mi","miles per hour":"mph",milligram:"mg",milliliter:"mL",millimeter:"mm",ounce:"dry oz",pint:"pt",pound:"lbs",lb:"lbs",quart:"qt",second:"s",square:"sq","square kilometer":"sq km","square yard":"sq yd","short ton":"tn",ton:"ton",yard:"yd",year:"y"},r=function(e){var t,n;return null!==(t=null!==(n=a[null===e||void 0===e?void 0:e.toLowerCase()])&&void 0!==n?n:e)&&void 0!==t?t:""},c={GALLON:"gallon",FLUID_OUNCE:"fl oz",QUART:"quart",LITER:"liter",ML:"ml",BUSHEL:"bushel",PINT:"pint",ACRE_INCH:"acre-inch",CENTILITER:"centiliter",SHORT_TON:"short ton",TON:"ton",METRIC_TON:"metric ton",POUND:"lb",OUNCE:"ounce",KILOGRAM:"kg",MILLIGRAM:"mg",GRAM:"g",SQUARE_METER:"square meter",ACRE:"acre",HECTARE:"hectare",INCH:"inch",HOUR:"hour",DAY:"day",MINUTE:"minute",BAG:"bag",SEED:"seed",CWT:"cwt",UNIT:"unit",PACKAGE:"package",EACH:"each",KERNEL:"kernel"},i=[c.SHORT_TON,c.TON,c.METRIC_TON,c.OUNCE,c.POUND,c.KILOGRAM,c.MILLIGRAM,c.GRAM],o=[].concat(i,["pound","gram","kilogram","long ton"]),s=[c.ACRE,c.ACRE_INCH,c.CENTILITER,c.FLUID_OUNCE,c.GALLON,c.LITER,c.ML,c.PINT,c.QUART],l=[].concat(s,["acre inch","cubic inch","cubic foot","cubic meter","cubic yard","fluid ounce","milliliter"]),d={lb:1,ounce:1/16,g:1/453.592,cwt:100,kg:1/.453592,"metric ton":2204.62,ton:2e3},u=function(e,t,n){return e*d[t]/d[n]}},25:function(e,t,n){"use strict";n.d(t,"g",(function(){return a})),n.d(t,"f",(function(){return r})),n.d(t,"k",(function(){return c})),n.d(t,"l",(function(){return i})),n.d(t,"d",(function(){return o})),n.d(t,"e",(function(){return s})),n.d(t,"c",(function(){return l})),n.d(t,"i",(function(){return d})),n.d(t,"j",(function(){return u})),n.d(t,"h",(function(){return b})),n.d(t,"b",(function(){return j})),n.d(t,"a",(function(){return p}));var a="http://localhost:3000",r="/inviteservice",c="/permissionservice",i=void 0!==Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).JEST_WORKER_ID||!1,o=(i||"https://".concat("staging.accounts.cropwise.com","/v2"),i?"":"".concat("https://api-qa.financials.cropwise.com","/api")),s=i?"":"".concat("https://api-v2-qa.financials.cropwise.com"),l=i?"":"".concat("https://api-qa.financials.cropwise.com","/masterdata/api/v1"),d=i?"":"https://masterlist-proxy-api-staging.landdb.com/api",u="",b=(i||Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).REACT_APP_PERMISSIONSERVICE_API_URL,i?"":"https://".concat("staging.accounts.cropwise.com","/v2")),j=i?"":"https://".concat("api.staging.base.cropwise.com","/v2"),p="".concat("https://ag.us.clearapis.com","/v1.1")},27:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/fallow.cee3ad7e.svg"},2747:function(e,t,n){"use strict";n.r(t);var a=n(1),r=n.n(a),c=n(44),i=n.n(c),o=n(2842),s=n(831),l=n(385),d=n.n(l),u=n(25),b=n(3),j=n(22),p=n(101),f=n(42),m=n(2),v=(n(904),n(14)),O=n(18),h=n.p+"static/media/NotoSans-LightItalic.ce1e88fe.ttf",x=n.p+"static/media/NotoSans-Regular.eae34fa8.ttf",g=n.p+"static/media/NotoSans-Medium.a4c42b7a.ttf",C=n.p+"static/media/NotoSans-SemiBold.99df72e2.ttf",y=n(0),P=O.StyleSheet.create({container:{display:"flex",flexDirection:"row",alignItems:"center",backgroundColor:"#F3F4F6",width:"100%",padding:"6px 9px"},text:{fontFamily:"Noto Sans",fontSize:9,fontWeight:"medium"}}),A=function(e){var t=e.items;return Object(y.jsx)(O.View,{style:P.container,children:t.map((function(e){return Object(y.jsx)(O.Text,{style:[P.text,{width:"".concat(e.width,"%"),textAlign:e.alignment}],children:e.label},e.label)}))})};A.defaultProps={items:[]};var S=A,T=O.StyleSheet.create({container:{display:"flex",flexDirection:"row",alignItems:"center",width:"100%",padding:"6px 9px"},text:{fontFamily:"Noto Sans",fontSize:9}}),N=function(e){var t=e.items,n=e.showBorder;return Object(y.jsx)(O.View,{style:[T.container,{borderBottom:n?"1px solid #DFE2E7":"none"}],children:t.map((function(e,t){var n={width:"100%"};return Object(y.jsxs)(O.View,{style:{width:e.styles.width},wrap:!1,children:[Object(y.jsx)(O.Text,{style:[T.text,e.styles,n],children:e.label},"".concat(e.label,"-").concat(t)),e.subtexts.map((function(e){return Object(y.jsx)(O.Text,{style:[e.styles,n],children:e.label})}))]})}))})};N.defaultProps={showBorder:!1};var E=N,w=O.StyleSheet.create({tableTitle:{fontFamily:"Noto Sans",fontWeight:"medium",fontSize:12,marginBottom:12},tableContainer:{border:"1px solid #DFE2E7",borderTop:"1.5px solid #DFE2E7",borderRadius:2},tableHeaderContainer:{width:"100%",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"}}),_=function(e){var t=e.title,n=e.headerItems,a=e.bodyItems,r=e.titleRight;return Object(y.jsxs)(O.View,{children:[Object(y.jsxs)(O.View,{style:w.tableHeaderContainer,children:[t&&Object(y.jsx)(O.Text,{style:w.tableTitle,children:t}),r&&Object(y.jsx)(O.Text,{style:w.tableTitle,children:r})]}),Object(y.jsxs)(O.View,{style:w.tableContainer,children:[Object(y.jsx)(S,{items:n}),a.map((function(e,n){return Object(y.jsx)(E,{items:e,showBorder:n+1<a.length},"".concat(n,"-").concat(t))}))]})]})};_.defaultProps={title:null,headerItems:[],bodyItems:[],titleRight:null};var R=_,I=n(4),D={ready:{english:"Ready",LATAMSpanish:"Listo"},task:{english:"Task",LATAMSpanish:"Tarea"}},k={taskDetails:{english:"Task Details",LATAMSpanish:"Detalles de la tarea"},startTime:{english:"Start Time:",LATAMSpanish:"Hora de inicio:"},finishTime:{english:"Finish Time:",LATAMSpanish:"Hora de finalizaci\xf3n:"},authorizedBy:{english:"Authorized By",LATAMSpanish:"Autorizado por"},authorizedOn:{english:"Authorized On",LATAMSpanish:"Autorizado el"},timingEvent:{english:"Timing Event",LATAMSpanish:"Sincronizaci\xf3n del evento"}},L={applicators:{english:"Applicators",LATAMSpanish:"Aplicadores"},nameCompany:{english:"Name/Company",LATAMSpanish:"Nombre/compa\xf1\xeda"},licenseNo:{english:"License No",LATAMSpanish:"N.\xb0 de licencia"}},F={environmentalStartingConditions:{english:"Environmental Starting Conditions",LATAMSpanish:"Condiciones ambientales de inicio"},skyCondition:{english:"Sky Condition:",LATAMSpanish:"Condici\xf3n del cielo:"},windSpeed:{english:"Wind Speed:",LATAMSpanish:"Velocidad del viento:"},windDirection:{english:"Wind Direction:",LATAMSpanish:"Direcci\xf3n del viento:"},soilCondition:{english:"Soil Condition:",LATAMSpanish:"Condici\xf3n del suelo:"},temperature:{english:"Temperature:",LATAMSpanish:"Temperatura:"},humidity:{english:"Humidity:",LATAMSpanish:"Humedad:"}},M={tankInfo:{english:"Tank Information",LATAMSpanish:"Informaci\xf3n del tanque"},tankSize:{english:"Tank Size",LATAMSpanish:"Tama\xf1o del tanque"},carrierArea:{english:"Carrier/Area",LATAMSpanish:"Transporte/\xe1rea"},totalCarrier:{english:"Total Carrier",LATAMSpanish:"Total de transporte"},tankCount:{english:"Tank Count",LATAMSpanish:"Cantidad de tanques"}},V={products:{english:"Products",LATAMSpanish:"Productos"},nameActive:{english:"Name/Active",LATAMSpanish:"Nombre/activo"},reg:{english:"Reg #",LATAMSpanish:"N.\xb0 de reg."},pest:{english:"Pest",LATAMSpanish:"Peste"},rei:{english:"REI",LATAMSpanish:"IER"},phi:{english:"PHI",LATAMSpanish:"PHI"},appMethod:{english:"App Method",LATAMSpanish:"M\xe9todo de aplicaci\xf3n"},appArea:{english:"App Area",LATAMSpanish:"\xc1rea de aplicaci\xf3n"},rateAC:{english:"Rate a/c.",LATAMSpanish:"Tasa aplic./cult."},total:{english:"Total",LATAMSpanish:"Total"}},B={fields:{english:"Fields",LATAMSpanish:"Campos"},area:{english:"Area",LATAMSpanish:"\xc1rea"},farm:{english:"Farms",LATAMSpanish:"Granjos"},field:{english:"Field",LATAMSpanish:"Campo"},cropZone:{english:"Crop Zone",LATAMSpanish:"Zone de Cultivo"},crop:{english:"Crop",LATAMSpanish:"Cultivo"},centerLatLong:{english:"Center Lat/Long",LATAMSpanish:"Lat./long. del centro"},appArea:{english:"App Area",LATAMSpanish:"\xc1rea de aplicaci\xf3n"}},U={notes:{english:"Notes",LATAMSpanish:"Notas"}},z={workerProtection:{english:"Worker Protection",LATAMSpanish:"Protecci\xf3n del trabajador"}},Z={signature:{english:"Signature",LATAMSpanish:"Firma"},date:{english:"Date",LATAMSpanish:"Fecha"}},Y=n(10),H=n(6),G=n.n(H),W=n(30),q=n(31),J=n.n(q),K=n(69),Q=function(e){return Math.round(100*(e+Number.EPSILON))/100},X=function(e,t){var n,a=e.totalProductValue,r=e.totalProductCost,c=e.specificCostUnit,i=e.productRateUnit,o=e.productRateValue,s=e.specificCostValue,l=t*e.coveragePercent/100,d=e.applicationCount;if(i===c)r=(a=o*l*d)*s;else{var u=Object(K.getConvertUnitFromTo)(Number.parseFloat(o),e.productRateUnit,e.specificCostUnit,e);n=u.Value,r=(a=Math.round(1e3*(n+Number.EPSILON))/1e3*l*d)*s}return Object(I.a)(Object(I.a)({},e),{},{areaValue:l,totalProductCost:Q(r),totalProductValue:a})},$=function(e){return{productId:(null===e||void 0===e?void 0:e.productId)||"",productName:(null===e||void 0===e?void 0:e.productName)||"",manufacturerName:(null===e||void 0===e?void 0:e.manufacturerName)||"",areaUnit:"acre",averagePriceAtTimeOfCreation:(null===e||void 0===e?void 0:e.specificCostValue)||0,averagePriceUnitAtTimeOfCreation:(null===e||void 0===e?void 0:e.specificCostUnit)||"gallon",totalProductValue:(null===e||void 0===e?void 0:e.totalProductValue)||0,totalProductUnit:(null===e||void 0===e?void 0:e.totalProductUnit)||"gallon",ratePerAreaValue:(null===e||void 0===e?void 0:e.productRateValue)||0,ratePerAreaUnit:(null===e||void 0===e?void 0:e.productRateUnit)||"gallon",ratePerTankValue:0,ratePerTankUnit:(null===e||void 0===e?void 0:e.productRateUnit)||"gallon",totalCostAtTimeOfCreation:(null===e||void 0===e?void 0:e.totalProductCost)||0,coveragePercent:100*Number.parseFloat(e.coveragePercent)||100,appliedAreaValue:(null===e||void 0===e?void 0:e.areaValue)||0,appliedAreaUnit:(null===e||void 0===e?void 0:e.areaUnit)||"acre",applicationMethod:"",targetPest:{},specificCostPerUnit:(null===e||void 0===e?void 0:e.specificCostValue)||0,specificCostUnit:(null===e||void 0===e?void 0:e.specificCostUnit)||"a",shareOwnerInformation:{percentGrowerResponsibility:100,totalFromGrowerInventoryQuantity:100,totalFromGrowerInventoryUnit:(null===e||void 0===e?void 0:e.totalProductUnit)||"gallon"},productDensity:(null===e||void 0===e?void 0:e.productDensity)||0,custom:(null===e||void 0===e?void 0:e.custom)||!1,customProductValue:0,customProductUnit:"",hasCost:!1,customRateType:"",associatedProduct:!1}},ee=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;if(null==e)return null;var a={currency:{style:"currency",currency:"USD"},percent:{style:"percent",minimumFractionDigits:n,maximumFractionDigits:n},fixed:{minimumFractionDigits:n,maximumFractionDigits:n}},r=new Intl.NumberFormat("en-US",a[t]);return Number.isFinite(e)?r.format(e):r.format(0)},te=n(26),ne=n(9),ae=n.n(ne);var re,ce=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Request Cancelled",a=!0,r=e.finally((function(){return a=!1}));return{promise:r,cancel:function(){return a&&t(n)}}},ie=n(262),oe=n.n(ie),se=function(e){return oe.a.stringify(e,{encodeValuesOnly:!0})},le=n(539),de=n.n(le),ue=n(263),be=n.n(ue),je=n(434),pe=de.a.createInstance({driver:[de.a.LOCALSTORAGE],name:"cwf-cache"}),fe=null!==(re=null===je.setupCache||void 0===je.setupCache?void 0:Object(je.setupCache)({maxAge:12e4,store:pe,exclude:{query:!1,methods:["put","patch","delete"],filter:function(e){return!e.headers["Local-Cache"]}},invalidate:function(e,t){var n=t.method.toLowerCase();("get"!==n&&"post"!==n||"post"===n&&!t.headers["Fetch-By-Post"])&&e.store.clear()},key:function(e){return"".concat(e.url,":").concat(e.method,":").concat(be.a.stringify(e.params),":").concat(JSON.stringify(e.data),":").concat(e.headers["cwf-context"])}}))&&void 0!==re?re:{},me={instances:{default:{api:J.a.create({adapter:fe.adapter})}},interceptors:{request:{config:{withCredentials:!1}}}},ve=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Object(I.a)({},e),a=["_id","createdAt","createdBy","updatedBy","updatedAt","active"];return t||a.push("version"),a.forEach((function(e){delete n[e]})),n},Oe=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Array.isArray(e)?e.map((function(e){return ve(e,t)})):"object"===typeof e?ve(e,t):e},he=Object(ne.runInContext)();he.mixin({appendUrlResourceName:function(e,t,n){return n?e:"".concat(e,"/").concat(t)},appendUrlAction:function(e,t){return t?"".concat(e,"/").concat(t):e},appendUrlId:function(e,t){return t?"".concat(e,"/").concat(t):e}});var xe=function(e,t,n,a){return function(r){return he.chain(e).appendUrlResourceName(t,n).appendUrlAction(a).appendUrlId(r).value()}},ge=function(e,t){return e.reduce((function(e,t){return function(e,t,n){return"".concat(e,"/").concat(t,"/").concat(n())}(e,t.resource,t.idCallback)}),t)},Ce=function(e,t){var n=[].concat(Object(v.a)(e.parentResources||[]),Object(v.a)(t.parentResources||[])).map((function(e){return Object(ne.isString)(e)?{resource:e}:e})),a=t.action||e.action;return{parentResources:n,action:a,suppressResourceName:!!a||t.suppressResourceName||e.suppressResourceName}},ye=function e(t,n){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},c=Ce(a,r),i=c.parentResources,o=c.action,s=c.suppressResourceName,l=ge(i,n),d=xe(l,t,s,o);return d.createUrlBuilder=e(t,n,{parentResources:i,action:o,suppressResourceName:s}),d}},Pe=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=n.parentResources,r=n.action,c=n.suppressResourceName;return ye(e,t,{parentResources:a,action:r,suppressResourceName:c})()},Ae=n(13),Se=n(2793),Te=n(189),Ne={keys:{user_id:"user_id"}},Ee={epic:{Authentication:{signIn:"sign in"},Organization:{id:"organizations",accessOrg:"access organization",switchingOrgs:"switching orgs",orgLoadingCount:"orgs loading count",paginatedProperties:"paginated properties"},Properties:{id:"properties",accessProps:"access properties",editFieldName:"edit field name",addCropZone:"add crop zone",createField:"create field",createProperty:"create property",archiveFarm:"archive farm",unarchiveFarm:"unarchive farm",archiveField:"archive field",unarchiveField:"unarchive field",filters:{toggleArchivedProperties:"show archived properties"},viewCostAnalysis:"view cost analysis"},ProductList:{editCustomProductCart:"edit custom product cart",resetToListPrice:"reset to list price",saveReiPhi:"save rei phi",viewInvoice:"view invoice",viewProductDetails:"view product details",accessPPL:"access product list"},PropertiesV2:{id:"propertiesV2",accessPropertiesV2:"access propertiesV2"},CropSeason:{id:"crop seasons",accessCS:"access crop season"},Plans:{id:"plans",accessPlan:"access plans",deletePlan:"delete plan",createPlan:"create plan"},Recommendations:{id:"recommendations",accessRecommendations:"access recommendations",createRecommendations:"create recommendation",deleteRecommendations:"delete recommendation"},Tasks:{id:"tasks",accessTasks:"access tasks",accessTasksSuccess:"access tasks success",cancelTask:"cancel task",cancelTaskSuccess:"cancel task success",viewTask:"view task",viewTaskSuccess:"view task success",selectDetailsTab:"select details tab",selectDetailsTabSuccess:"select details tab success",createTask:"create task",createTaskSuccess:"create task success",selectPropertiesTab:"select properties tab",selectPropertiesTabSuccess:"select properties tab success",selectProductTab:"select product tab",selectProductTabSuccess:"select product tab success",addProduct:"add product",addProductSuccess:"add product success",saveProduct:"save product",saveProductSuccess:"save product success",cancelProduct:"cancel product",cancelProductSuccess:"cancel product success",selectWeatherTab:"selected weather tab",selectWeatherTabSuccess:"selected weather tab success",saveTask:"save task",saveTaskSuccess:"save task success",duplicateTask:"duplicate task",duplicateTaskSuccess:"duplicate task success",editTask:"edit task",editTaskSuccess:"edit task success",updateTask:"update task",updateTaskSuccess:"update task success",saveTaskFromRec:"save task from rec",saveTaskFromRecSuccess:"save task from rec success",deleteTask:"delete task",deleteTaskSuccess:"delete task success",pages:{fromTaskLanding:"top right button",fromPlan:"converted from plan",fromRec:"converted from rec",fromInvoice:"converted from invoice",fromEmptyState:"converted from empty state"}},Invoices:{id:"invoices",accessInvoice:"access invoices"},People:{id:"people",accessPeople:"access people",deletePerson:"delete person",editPerson:"edit person",createPerson:"create person"},Companies:{id:"companies",accessCompanies:"access companies",deleteCompany:"delete company",createCompany:"create company",editCompany:"edit company"},Equipment:{id:"equipment",accessEquipment:"access equipment",createEquipment:"create equipment",deleteEquipment:"delete equipment"},Reports:{id:"reports",accessReports:"access report",reportSuccess:"report success",reportFailed:"report failed"},YieldV2:{saleLocations:{createSaleLocation:"create sale location",editSaleLocation:"edit sale location",deleteSaleLocation:"delete sale location"},storageLocations:{goToLoads:"select go to loads button",delete:"delete storage location",editStorageLocation:"edit storage location",createStorageLocation:"create storage location",saveStorageLocation:"save storage location",createCompany:"create company"},addYield:{createYield:"create yield",selectTemplate:"select template",saveLoads:"save loads",createNewSourceStorage:"create new storage",saveProperties:"save properties",selectUOM:"select UOM"},loads:{selectCrop:"select crop",deleteYield:"delete yield load",editYield:"edit yield"}},Integrations:{JohnDeere:{operationsMatched:"operations matched",operationsUnmatched:"operations unmatched",numberOfOperationAvailable:"number of operations available",cropZoneMatchFailure:"crop zone match failure",cropZoneMatchSuccess:"crop zone match success",selectCropZone:"select crop zone"},importRecommendationSelected:"import recommendation selected",importRecommendationSearched:"import recommendation searched",importRecommendationPropertiesMatch:"import recommendation properties match",importRecommendationTriggered:"import recommendation triggered",importRecommendationProductsMatch:"import recommendation products match",submissionStarted:"submission started",submissionTaskClick:"submission task click",submissionTaskRedirect:"submission task redirect",submissionCredentialsFilled:"submission credentials filled",submissionOrganizationFilled:"submission organization filled",submissionSeasonSelected:"submission season selected",submissionPropertiesSelected:"submission properties selected",submissionProductsSelected:"submission products selected",submissionProductsMatched:"submission products matched",submissionFieldsFilledRegulatoryData:"submission fields filled regulatory data",submissionApplicatorDetailsFilled:"submission applicator details filled",submissionRegulatoryDataReview:"submission regulatory data review",submissionPropertiesMatched:"submission properties matched",submissionCropZoneRemoved:"submission crop zone removed",submissionRunning:"submission running",submissionCompleted:"submission completed",submissionCanceled:"submission canceled",submissionEditClick:"submission edit click",submissionRetryClick:"submission retry click"}}},we=r.a.createContext();Te.a.getInstance().init("e1cc15ce421fdc13c7194b57e60ba78e");function _e(e){function t(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Te.a.getInstance().logEvent(e,t)}return Object(y.jsx)(we.Provider,{value:{amplitude:Te.a,events:Ee,properties:Ne,setUserId:function(e){Te.a.setUserId(e)},sendEventToAmplitude:t,sendToAmplitudeIdentify:function(e,t){var n=(new Te.a.Identify).setOnce(e,t.email);Te.a.getInstance().identify(n)},filterNavItems:function(e){switch(e){case Ee.epic.Organization.id:return Ee.epic.Organization.accessOrg;case Ee.epic.PropertiesV2.id:return Ee.epic.PropertiesV2.accessPropertiesV2;case Ee.epic.Properties.id:return Ee.epic.Properties.accessProps;case Ee.epic.CropSeason.id:return Ee.epic.CropSeason.accessCS;case Ee.epic.Plans.id:return Ee.epic.Plans.accessPlan;case Ee.epic.Recommendations.id:return Ee.epic.Recommendations.accessRecommendations;case Ee.epic.Tasks.id:return Ee.epic.Tasks.accessTasks;case Ee.epic.Invoices.id:return Ee.epic.Invoices.accessInvoice;case Ee.epic.People.id:return Ee.epic.People.accessPeople;case Ee.epic.Companies.id:return Ee.epic.Companies.accessCompanies;case Ee.epic.Equipment.id:return Ee.epic.Equipment.accessEquipment;case Ee.epic.Reports.id:return Ee.epic.Reports.accessReports;case Ee.epic.ProductList.id:return Ee.epic.ProductList.accessPPL;default:return e}},updateIdentify:function(e,n){var a=(new Te.a.Identify).set("organization_name",e).set("organization_id",n);Te.a.getInstance().identify(a),t(Ee.epic.Organization.switchingOrgs)}},children:e.children})}var Re={"Content-Type":"application/x-www-form-urlencoded",authorization:"Basic ".concat("ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6")},Ie="https://".concat("staging.accounts.cropwise.com"),De=J.a.create({baseURL:Ie,headers:{"Cache-Control":"no-cache"}}),ke=new(n(778).CookieStorage),Le=function(){return!!localStorage.getItem("tokens")},Fe=function(e){return localStorage.setItem("tokens",e)},Me=function(){window.indexedDB.deleteDatabase("cwf-cache"),localStorage.clear()},Ve=function(){return JSON.parse(localStorage.getItem("tokens")||"{}").access_token},Be="https://".concat("staging.accounts.cropwise.com","\n/oauth/authorize\n?response_type=code\n&client_id=").concat("ddcd4fe8157148fc90b0fe95753f2bd0","\n&redirect_uri=").concat(window.location.origin,"/authenticate"),Ue=Object(a.createContext)(),ze=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={headers:Re},t.code){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,De.post("oauth/token",be.a.stringify(t),n).catch(Ae.default);case 5:a=e.sent,r=a.data,Fe(JSON.stringify(r));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function Ze(){var e="https://".concat("staging.accounts.cropwise.com","/exit?continue=").concat(window.location.origin);Me(),window.location.href=e}function Ye(e,t,n){return He.apply(this,arguments)}function He(){return(He=Object(Y.a)(G.a.mark((function e(t,n,a){var r,c,i;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(Ve())}},c={role_context:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",workspace_id:n,org_id:t},i={updates:[{operation:"add",roles:[Object(I.a)({role_id:"CWFAdminView"},c),Object(I.a)({role_id:"CWFAdminEdit"},c),Object(I.a)({role_id:"CWFFinancialEdit"},c),Object(I.a)({role_id:"CWFFinancialView"},c)]}]},e.abrupt("return",J.a.post("https://".concat("api.staging.base.cropwise.com","/v2/accounts/").concat(a,"/roles/updates"),i,r));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ge=function(e){var t=e.children,n=Object(a.useContext)(we),r=n.properties,c=n.sendToAmplitudeIdentify,i=function(){var e=Object(a.useContext)(we),t=Object(a.useState)(null),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useCallback)((function(){Le()&&De.get("/v2/accounts/me",{headers:{common:{Authorization:"Bearer ".concat(Ve())}},useCache:!1}).then((function(t){if(t.error)throw t.error;c(t.data);var n=t.data,a=n.id,r=n.email,i=n.name;e.setUserId(t.data.id),d.a.identify(t.data.id,{id:a,email:r,name:i}),Se.b({email:r})})).catch((function(e){var t,n;"invalid_token"===(null===(t=e.response)||void 0===t||null===(n=t.data)||void 0===n?void 0:n.error)&&Se.b(null),Ze()}))}),[e]);return{user:r,logout:Ze,performLogin:ze,fetchUserProfile:i}}();return i.user&&c(r.keys.user_id,i.user),Object(y.jsx)(Ue.Provider,{value:i,children:t})};function We(){return Object(a.useContext)(Ue)}Ge.defaultProps={children:Object(y.jsx)(y.Fragment,{})};var qe,Je=function(e,t){var n;null!==t&&void 0!==t&&null!==(n=t.headers)&&void 0!==n&&n.Authorization||Object(ne.set)(e,"request.config.headers.Authorization","Bearer ".concat(Ve()))},Ke=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0,a=e.request.contextCallback?e.request.contextCallback():"";return t.find((function(e){return e.test(n)}))?null:a},Qe=function(e,t,n){var a=Ke(e,t,n.url);return a?{"cwf-context":a}:void 0},Xe=function(e,t,n){var a,r,c=Object(I.a)(Object(I.a)(Object(I.a)({},null!==(a=null===e||void 0===e?void 0:e.headers)&&void 0!==a?a:{}),null!==(r=null===t||void 0===t?void 0:t.headers)&&void 0!==r?r:{}),n);return Object(I.a)(Object(I.a)(Object(I.a)({},e),t),{},{headers:c})},$e=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=e.interceptors,c=e.instances[t];Object(ne.isNil)(c.interceptors)&&(c.interceptors={request:c.api.interceptors.request.use((function(e){Je(r,e);var t=Qe(r,n,e);return Xe(e,r.request.config,a?void 0:t)}),(function(e){return Promise.reject(e)}))})},et=n(7),tt={str:function(e,t){return e.toLowerCase()===t.toLowerCase()},num:function(e,t){return e===t||Math.floor(e)===t},date:function(e,t){return(Object(ne.isDate)(e)?e.toDateString():e)===(Object(ne.isDate)(t)?t.toDateString():t)},matches:function(e,t){return t(e)}},nt=function(e,t){return e.reverse().reduce((function(e,t){var n=t.field,a=t.dir;return e.sort(function(e,t){return function(n,a){return n[e]===a[e]?0:("asc"===t?function(e){return e}:function(e){return!e})(n[e]<a[e])?-1:1}}(n,a))}),t)},at={onResponse:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=e.filter((function(e){return n.reduce((function(t,n){var a=n.field,r=n.value,c=n.type;return Object(ne.isNil)(r)?t:t&&tt[c](e[a],r)}),!0)}));return nt(t,a)}},rt={onRequest:function(e,t){var n=t.sorts,a=void 0===n?[]:n,r=t.filters,c=void 0===r?[]:r;return Object(I.a)(Object(I.a)({},e),{},{params:Object(I.a)(Object(I.a)({},e.params),c.reduce((function(e,t){var n=t.field,a=t.value;return Object(ne.isNil)(a)||Object(ne.set)(e,n,"like(%".concat(a,"%)")),e}),{sort:a.map((function(e){var t=e.field,n=e.dir;return"".concat(n,"(").concat(t,")")}))}))})}},ct=function(e,t){return t?t.filters.reduce((function(e,t){var n=t.field,a=t.value,r=t.type;return Object(ne.isNil)(a)?e:"matches"===r?Object(I.a)(Object(I.a)({},e),{},{filterClause:function(t){var r=t&&t[n]&&a(t[n]);return e.filterClause?function(t){return r&&e.filterClause(t)}:r}}):Object(I.a)(Object(I.a)({},e),{},{whereClause:Object(I.a)(Object(I.a)({},e.whereClause),{},Object(et.a)({},n,a))})}),{whereClause:e}):e},it="CLIENT_SIDE_MODEL",ot="PROXY_SEARCH_MODEL",st=(qe={},Object(et.a)(qe,it,at),Object(et.a)(qe,"VNEXT_CLASSIC_MODEL",rt),Object(et.a)(qe,ot,{onRequest:function(e){return e}}),qe),lt=n(779),dt=n(780),ut=n.n(dt),bt=(Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).REACT_APP_DISABLED_FEATURES||"").split(",").reduce((function(e,t){return Object(ne.set)(e,t,"disabled")}),{}),jt=Object(ne.merge)(ut.a,bt),pt=function(){return jt},ft="caching",mt=pt(),vt=function(e){return"disabled"===Object(ne.get)(mt,ft)||"disabled"===Object(ne.get)(mt,"".concat(ft,".").concat(e))},Ot=function(e,t){return t?{clearTableOnChange:e}:{table:vt(e)?null:e}},ht={organizations:Ot("organization"),organization:Ot("organization",!0),cropseasons:Ot("cropseason"),cropseason:Ot("cropseason",!0)},xt=["data"],gt=new lt.a("cwf-cache");gt.version(1.1).stores({organization:"id,name",cropseason:"id,name"});var Ct={organization:9e5,cropseason:9e5},yt=function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=a?e[0]:e;return Object(I.a)(Object(I.a)({data:r},t),{},{source:n})},Pt=function(e,t){return e&&t?e[t]:e},At={},St=function(e,t,n){return e.then((function(e){var a=e.data,r=Object(te.a)(e,xt),c=Pt(a,t);return yt(c,r,n)}))},Tt=function(e,t){return At[e]&&St(At[e],t)},Nt=function(){localStorage.removeItem("selectedOrganizationId"),localStorage.removeItem("selectedCropSeasons"),window.location.replace("/")},Et=function(e,t,n){var a;return((a=At[e])?St(a,t,"lastFetch"):null)||(At[e]=n(),At[e].then((function(){Object(ne.delay)((function(){At[e]=null}),1e3)})).catch((function(t){var n;At[e]=null,401!==(null===(n=t.response)||void 0===n?void 0:n.status)||e.includes("api/v1/base/organization")||Nt()})),At[e])},wt=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,c=arguments.length>4?arguments[4]:void 0,i="{organization_id: ",o=Ke(me.interceptors,n,a),s=null===o||void 0===o?void 0:o.replace(i,"").substr(0,o.length-i.length-1),l="organization"===e?"id":"organizationId",d=Object(I.a)(Object(I.a)({},r||{}),s?Object(et.a)({},l,s):{}),u=ct(d,c),b=u.whereClause,j=u.filterClause;return s||r||null!==c&&void 0!==c&&null!==(t=c.filters)&&void 0!==t&&t.length?{whereClause:b,filterClause:j}:{}},_t=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.length){e.next=6;break}return e.next=3,gt[n].count();case 3:if(0!==e.sent){e.next=6;break}return e.abrupt("return",null);case 6:if(a=Date.now(),!t.find((function(e){var t=e.cacheTimestamp?e.cacheTimestamp.getTime():a;return a-t>Ct[n]}))){e.next=11;break}return gt[n].clear(),e.abrupt("return",null);case 11:return e.abrupt("return",t);case 12:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),Rt=function(e){return ht[e]||{}},It=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,r,c,i,o,s,l,d,u,b,j,p,f,m,v,O;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n.url,r=n.cwfContextRegExpExclusions,c=n.parentResourceIds,i=n.query,o=n.containerName,!(s=Tt(a,o))){e.next=4;break}return e.abrupt("return",s);case 4:if(l=Rt(t),d=l.table,u=t===d,gt[d]){e.next=8;break}return e.abrupt("return",null);case 8:return b=wt(d,r,a,c,i),j=b.whereClause,p=b.filterClause,f=j&&Object.keys(j).length?gt[d].where(j):gt[d],m=p?f.filter(p):f,e.next=13,m.toArray();case 13:return v=e.sent,e.next=16,_t(v,d);case 16:return O=e.sent,e.abrupt("return",O?yt(O,null,"cache",u):null);case 18:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),Dt=function(e,t,n){var a=n.url,r=n.cwfContextRegExpExclusions,c=n.parentResourceIds;if(t){var i=Rt(e).table;if(gt[i]){var o=wt(i,r,a,c).whereClause;gt[i].bulkAdd(Object(ne.flatten)(t).map((function(e){return Object(I.a)(Object(I.a)(Object(I.a)({},e),o),{},{cacheTimestamp:new Date})})))}}},kt=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=Rt(t),r=a.table,gt[r]){e.next=3;break}return e.abrupt("return",null);case 3:return e.next=5,gt[r].get(n);case 5:return c=e.sent,e.abrupt("return",{data:c});case 7:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),Lt=function(e,t,n){var a=n.url,r=n.cwfContextRegExpExclusions,c=n.parentResourceIds,i=Rt(e).table;if(gt[i]){var o=wt(i,r,a,c).whereClause;gt[i].add(Object(I.a)(Object(I.a)(Object(I.a)({},t),o),{},{cacheTimestamp:new Date}))}},Ft=function(e,t){var n=Rt(e).clearTableOnChange;n&&t.then((function(){gt[n].clear()}))},Mt=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:gt.tables.forEach((function(e){e.clear()}));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Vt=["data"],Bt=["data","source"],Ut=function e(t,n,a,r){return{updateRequestInterceptor:function(e,t){Object.assign(me.interceptors.request.config,e),t&&(me.interceptors.request.contextCallback=t)},createChildApi:function(r){var c=a.createUrlBuilder(r);return e(t,n,c)},fetch:function(e,c,i,o){var s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],l=a(e||null),d=e?kt(t,e):It(t,{url:l,cwfContextRegExpExclusions:r,containerName:o}),u=q.CancelToken.source(),b=u.token,j=u.cancel,p=d.then((function(a){var d;if(!s&&a)return a;var u=Object(I.a)(Object(I.a)({},i),{},{headers:Object(I.a)(Object(I.a)({},null===i||void 0===i?void 0:i.headers),{},{"Local-Cache":!(null===i||void 0===i||null===(d=i.headers)||void 0===d||!d["Local-Cache"])}),params:c,cancelToken:b,paramsSerializer:se});return Et(l,o,(function(){return me.instances[n].api.get(l,u)})).then((function(n){var a=n.data,c=Object(te.a)(n,Vt),i=Pt(a,o);return Object(ne.defer)((function(){s||(e?Lt(t,i,{url:l,cwfContextRegExpExclusions:r}):Dt(t,i,{url:l,cwfContextRegExpExclusions:r}))})),yt(i,c,"api")}))}));return ce(p,j,"Cancelled ".concat(t," fetch"))},find:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},c=arguments.length>1?arguments[1]:void 0,i=c.serverSearchModel,o=void 0===i?null:i,s=c.containerName,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},d=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u=a(null),b=It(t,{url:u,cwfContextRegExpExclusions:r,query:e,containerName:s}),j=q.CancelToken.source(),p=j.token,f=j.cancel,m=b.then((function(a){if(a)return a;var c=Object(I.a)(Object(I.a)({},d),{},{params:Object(I.a)({},l),paramsSerializer:se,cancelToken:p}),i=o&&st[o].onRequest?st[o].onRequest(c,e):c;return Et(u,s,(function(){return me.instances[n].api.get(u,i)})).then((function(n){var a=n.data,c=n.source,i=Object(te.a)(n,Bt),l="lastFetch"===c?a:Pt(a,s);Object(ne.defer)((function(){"lastFetch"!==c&&Dt(t,l,{url:u,cwfContextRegExpExclusions:r})}));var d=o&&st[o].onResponse?st[o].onResponse(l,e.sorts,e.filters):l;return yt(d,i,"api")}))}));return ce(m,f,"Cancelled ".concat(t," find"))},post:function(e,r){var c=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=a(null),o=Oe(e),s=q.CancelToken.source(),l=s.token,d=s.cancel,u=me.instances[n].api.post(i,o,Object(I.a)(Object(I.a)({cancelToken:l},r),{},{headers:Object(I.a)(Object(I.a)({},null===r||void 0===r?void 0:r.headers),{},{"Local-Cache":c})})).catch((function(e){var t;if(401!==(null===(t=e.response)||void 0===t?void 0:t.status))throw e;Nt()}));return Ft(t,u),ce(u,d,"Cancelled ".concat(t," create"))},create:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.post(e,t,n)},fetchByPost:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return this.post(e,{params:Object(I.a)(Object(I.a)({},t),{},{include_dangling_fields:a}),headers:{"Fetch-By-Post":!0}},n)},update:function(e,r,c){var i;i=a(e||null);var o=Oe(r,!0),s=q.CancelToken.source(),l=s.token,d=s.cancel,u=me.instances[n].api.put(i,o,{cancelToken:l,headers:Object(I.a)({},null===c||void 0===c?void 0:c.headers)}).catch((function(e){if(401!==e.response.status)throw e;Nt()}));return Ft(t,u),ce(u,d,"Cancelled ".concat(t," update"))},delete:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=a(e),i=q.CancelToken.source(),o=i.token,s=i.cancel,l=me.instances[n].api.delete(c,Object(I.a)({cancelToken:o},r)).catch((function(e){var t;if(401!==(null===(t=e.response)||void 0===t?void 0:t.status))throw e;Nt()}));return Ft(t,l),ce(l,s,"Cancelled ".concat(t," delete"))},patch:function(e,r,c){var i=a(e),o=Oe(r,!0),s=q.CancelToken.source(),l=s.token,d=s.cancel,u=Object(I.a)(Object(I.a)({},c),{},{cancelToken:l}),b=me.instances[n].api.patch(i,o,u);return ce(b,d,"Cancelled ".concat(t," patch"))}}},zt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=n.parentResources,r=n.action,c=n.suppressResourceName,i=n.cwfContextRegExpExclusions,o=n.customCwfContext,s=void 0!==o&&o,l=Pe(e,t,{parentResources:a,action:r,suppressResourceName:c}),d=null!==i&&void 0!==i&&i.length?e:"default";"default"!==d&&(me.instances[d]={api:Object(q.create)({adapter:fe.adapter}),cwfContextRegExpExclusions:i}),$e(me,d,i,s);var u=Ut(e,d,l,i);return u.updateRequestInterceptor({}),u},Zt=(zt("mock",u.g,{parentResources:[{resource:"organizations",idCallback:function(){return"9a1a1673-6926-41fa-9d71-a5aad6f67cb6"}}]}),zt("crops",u.h,{cwfContextRegExpExclusions:[/\/crops/]}),zt("products",u.i)),Yt=zt("product","".concat(u.c)),Ht=zt("products","".concat(u.c)),Gt=zt("flags","".concat(u.c)),Wt=zt("flag","".concat(u.c)),qt=(zt("cost-per-acres",u.j),zt("dashboards",u.j),zt("imagery",u.j),zt("organizations","".concat(u.d,"/v1/base"),{cwfContextRegExpExclusions:[/\/organizations/]})),Jt=zt("organization","".concat(u.d,"/v1/base")),Kt=zt("organization/land-management-enabled","".concat(u.d,"/v1/base")),Qt=(zt("properties","".concat(u.d,"/v1/base")),zt("properties","".concat(u.d,"/v2/base")),zt("properties","".concat(u.d,"/v3/base"))),Xt=zt("properties","".concat(u.d,"/v4/base")),$t=(zt("dashboardWeather",u.j),zt("cropseason","".concat(u.d,"/v2/base"))),en=zt("cropseasons","".concat(u.d,"/v2/base")),tn=zt("recommendation","".concat(u.d,"/v1")),nn=zt("recommendations","".concat(u.d,"/v1")),an=(zt("recommendations/search","".concat(u.d,"/v1")),zt("products","".concat(u.i))),rn=zt("integrations/submission","".concat(u.e),{cwfContextRegExpExclusions:[/organizations/g],customCwfContext:!0}),cn=zt("integrations/simplot/match","".concat(u.e),{cwfContextRegExpExclusions:[/organizations/g],customCwfContext:!0}),on=zt("integrations/simplot/cropzones","".concat(u.e),{cwfContextRegExpExclusions:[/organizations/g],customCwfContext:!0}),sn=zt("integrations/agrian/fields","".concat(u.e),{cwfContextRegExpExclusions:[/organizations/g],customCwfContext:!0}),ln=zt("integrations/agrian/match","".concat(u.e),{cwfContextRegExpExclusions:[/organizations/g],customCwfContext:!0}),dn=zt("integrations","".concat(u.e),{cwfContextRegExpExclusions:[/organizations/g],customCwfContext:!0}),un=zt("integrations/agrian","".concat(u.e),{cwfContextRegExpExclusions:[/organizations/g],customCwfContext:!0}),bn=zt("integrations/calag","".concat(u.e),{cwfContextRegExpExclusions:[/organizations/g],customCwfContext:!0}),jn=zt("documents","".concat(u.i)),pn=zt("farm","".concat(u.d,"/v1/base")),fn=zt("farms","".concat(u.d,"/v1/base")),mn=zt("field","".concat(u.d,"/v1/base")),vn=zt("field","".concat(u.d,"/v2/base")),On=zt("cropzone","".concat(u.d,"/v1/base")),hn=zt("cropzone","".concat(u.d,"/v2/base")),xn=(zt("cropzone","".concat(u.d,"/v3/base")),zt("tasks","".concat(u.d,"/v1/base"))),gn=zt("task","".concat(u.d,"/v1/base")),Cn=zt("products-per-season","".concat(u.d,"/v1/base/tasks")),yn=zt("plans","".concat(u.d,"/v1")),Pn=zt("plan","".concat(u.d,"/v1")),An=zt("johnDeere","".concat(u.d,"/v1/integration")),Sn=zt("company","".concat(u.d,"/v1/base")),Tn=zt("invoices","".concat(u.d,"/v1")),Nn=zt("invoice","".concat(u.d,"/v1")),En=(zt("companies","".concat(u.d,"/v1/base")),zt("equipment","".concat(u.d,"/v1/base"))),wn=zt("weather","".concat(u.a,"/").concat("historical/hourly")),_n=zt("mcCain","".concat(u.d,"/v1/integration")),Rn=(zt("inventory","".concat(u.d,"/v1/inventory")),zt("products","".concat(u.d,"/v1/inventory"))),In=zt("product","".concat(u.d,"/v1/inventory")),Dn=zt("products-prices","".concat(u.d,"/v1/inventory")),kn=zt("reports","".concat(u.d,"/v1/base")),Ln=(zt("yields","".concat(u.d,"/v2/base")),zt("reportInGroup","".concat(u.d,"/v1/integration/powerBi"))),Fn=(zt("reiphis","".concat(u.i)),zt("reiphi","".concat(u.d,"/v1/base"))),Mn="".concat(u.d,"/v2/yield"),Vn=zt("list",Mn,{cwfContextRegExpExclusions:[/organizations/g,/yield/g],customCwfContext:!0}),Bn=zt("dashboard","".concat(u.d,"/v2/yield"),{cwfContextRegExpExclusions:[/organizations/g,/yield/g],customCwfContext:!0}),Un=zt("yield","".concat(u.d,"/v2"),{cwfContextRegExpExclusions:[/organizations/g,/yield/g],customCwfContext:!0}),zn=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.parentResources,a=t.action,r=t.urlVersion,c=void 0===r?"":r;return zt(e,"".concat(u.d).concat(c),{parentResources:n,action:a})},Zn="".concat(u.a,"/").concat("historical/hourly"),Yn=("".concat(u.a,"/").concat("forecast/hourly"),function(e,t){return e.createChildApi({action:t})}),Hn=zt("unmappedCropZoneCount","".concat(u.d,"/v1/integration/johnDeere"),{}),Gn=zt("properties","".concat(u.d,"/v1/integration/johnDeere/"),{}),Wn=zt("matchCropzones","".concat(u.d,"/v1/integration/johnDeere"),{}),qn=zt("operations","".concat(u.d,"/v1/integration/johnDeere"),{}),Jn=zt("missing-pw-summary","".concat(u.d,"/v1/integration/johnDeere/operations"),{}),Kn=zt("cropzones","".concat(u.d,"/v1/base"),{}),Qn=n(87),Xn=n.n(Qn),$n=function(e,t,n){var a=Object(W.bbox)(t);return new Promise((function(r,c){e.on("load",(function(){try{e.addSource("geojson",{type:"geojson",data:t}),e.addLayer({id:"geojson",type:"fill",source:"geojson",paint:{"fill-color":"#31B4F2","fill-opacity":.37}}),e.addLayer({id:"outline",type:"line",source:"geojson",paint:{"line-color":"#31B4F2","line-width":1}}),e.fitBounds(a,{padding:20}),e.once("render",(function(){e.once("idle",(function(){r(e.getCanvas().toDataURL("image/png")),Object.defineProperty(window,"devicePixelRatio",{get:function(){return n}})}))}))}catch(i){c(i)}})),e.on("error",c)}))},ea=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Xn.a.accessToken="pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",n=window.devicePixelRatio,Object.defineProperty(window,"devicePixelRatio",{get:function(){return 1.5625}}),a=document.createElement("div"),"mapbox://styles/mapbox/satellite-streets-v11","\n    z-index: 100;\n    visibility: hidden;\n    position: absolute;\n    top: 0;\n    height: 198px;\n    width: 270px;\n  ",(r=new Xn.a.Map({container:a,style:"mapbox://styles/mapbox/satellite-streets-v11",fadeDuration:0,interactive:!1,preserveDrawingBuffer:!0})).getContainer().style.cssText="\n    z-index: 100;\n    visibility: hidden;\n    position: absolute;\n    top: 0;\n    height: 198px;\n    width: 270px;\n  ",e.abrupt("return",$n(r,t,n));case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ta=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==t&&void 0!==t&&t.length){e.next=2;break}return e.abrupt("return","");case 2:return n=Object(W.featureCollection)(t),e.next=5,ea(n);case 5:return a=e.sent,e.abrupt("return",a);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),na=function(e){return{type:"Feature",properties:{stroke:"#31B4F2","stroke-width":1,fill:"#31B4F2","fill-opacity":.37},geometry:e}},aa=function(e){return null==e||""===e?"-":e},ra=function(e){return null==e?"-":ee(e,"fixed")},ca=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,i,o,s,l,d,b,j,p,f,m,v,O;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=On.fetch(t),a=n.promise,e.next=3,a.catch((function(){return{data:{}}}));case 3:return r=e.sent,c=r.data,i=mn.fetch(c.fieldId),o=i.promise,e.next=8,o.catch((function(){return{data:{}}}));case 8:return s=e.sent,l=s.data,d=pn.fetch(l.propertyId),b=d.promise,e.next=13,b.catch((function(){return{data:{}}}));case 13:return j=e.sent,p=j.data,f="".concat(u.h,"/crops/").concat(c.cropId,"?location=@CWF"),e.next=18,J.a.get(f,{headers:{common:{Authorization:"Bearer ".concat(Ve())}}}).catch((function(){return{data:{}}}));case 18:return m=e.sent,v=m.data,O=c.geometry?Object(W.centroid)(c.geometry):{},e.abrupt("return",{cropZone:c,field:l,farm:p,crop:v,centroId:O});case 22:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ia=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,i,o,s,l,d,u,b,j,p,f;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=Zt.fetch(t),r=a.promise,e.next=3,r.catch((function(){return{data:{}}}));case 3:return c=e.sent,i=c.data,o=Zt.fetch("".concat(t,"/activeIngredients")),s=o.promise,e.next=8,s.catch((function(){return{data:[]}}));case 8:return l=e.sent,d=l.data,u={productName:i.name,key:i.id,signalword:aa(i.signalword),rup:aa(null===(n=i.restricteduse)||void 0===n?void 0:n.toString()),ppe:aa(i.ppe),ppereentry:aa(i.ppereentry)},b=Fn.fetch(t),j=b.promise,e.next=14,j.catch((function(){return{data:[]}}));case 14:return p=e.sent,f=p.data,e.abrupt("return",{masterProduct:i,activeIngredients:d,reiphisData:f,workerProtection:u});case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),oa=O.StyleSheet.create({headerContainer:{marginTop:18},header:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",fontSize:12,paddingHorizontal:10},titleContainer:{display:"flex",flexDirection:"row",alignItems:"center",marginBottom:9},title:{marginRight:10,fontSize:12,fontWeight:"semibold",fontFamily:"Noto Sans"},text:{marginBottom:6,fontSize:10,fontFamily:"Noto Sans"},status:{borderRadius:4,color:"white",paddingVertical:2,paddingHorizontal:13,textAlign:"center",margin:0,fontSize:8,fontFamily:"Noto Sans"},logo:{width:"auto",height:45,position:"relative",right:-18},divider:{borderTop:"1 solid #A3A9B9",marginTop:6,marginBottom:21}}),sa={ready:{color:"#E99921",label:"Ready"},inprogress:{color:"#5FD2C8",label:"In Progress"},complete:{color:"#0071CD",label:"Complete"}},la=function(e){var t=e.title,n=e.status,a=e.organization,r=e.type,c=e.cropSeasons,i=e.cropName,o=e.exportLanguage,s=void 0===o?"english":o;return Object(y.jsxs)(O.View,{fixed:!0,style:oa.headerContainer,children:[Object(y.jsxs)(O.View,{style:oa.header,children:[Object(y.jsxs)(O.View,{children:[Object(y.jsxs)(O.View,{style:oa.titleContainer,children:[Object(y.jsx)(O.Text,{style:oa.title,children:aa(t)}),n&&Object(y.jsx)(O.Text,{style:Object(I.a)(Object(I.a)({},oa.status),{},{backgroundColor:sa[n].color}),children:"Ready"===sa[n].label?D.ready[s]:sa[n].label})]}),Object(y.jsxs)(O.Text,{style:oa.text,children:[a," | ",r]}),Object(y.jsx)(O.Text,{style:oa.text,children:function(){var e=[];return null!==c&&void 0!==c&&c.length&&e.push(c.join(", ")),i&&e.push(i),e.join(" | ")}()})]}),Object(y.jsx)(O.Image,{style:oa.logo,src:"/Cropwise Product Logo.png"})]}),Object(y.jsx)(O.View,{style:oa.divider})]})};la.defaultProps={status:null,cropSeasons:[],cropName:null};var da=la,ua={pages:{english:"Page",LATAMSpanish:"P\xe1gina"},copyright:{english:"\xa9 Copyright of Syngenta",LATAMSpanish:"\xa9 Derechos de autor de Syngenta"},generated:{english:"generated",LATAMSpanish:"generado"}},ba=O.StyleSheet.create({footer:{width:"100%",position:"absolute",bottom:0,left:30,paddingRight:15,paddingBottom:15,display:"flex",flexDirection:"row",justifyContent:"space-between"},pageNumber:{fontSize:10,marginTop:12,fontFamily:"Noto Sans",fontWeight:"medium"},footerLogo:{width:90},copyrightContainer:{paddingTop:12,paddingBottom:10,display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"center",height:"100%"},copyright:{fontSize:10,fontFamily:"Noto Sans"}}),ja=function(e){var t=e.exportLanguage,n=e.year,a=e.fullDate,r="english"===t?ua.pages.english:ua.pages.LATAMSpanish;return Object(y.jsxs)(O.View,{fixed:!0,style:ba.footer,children:[Object(y.jsx)(O.Text,{style:ba.pageNumber,render:function(e){var t=e.pageNumber;return"".concat(r," ").concat(t)}}),Object(y.jsxs)(O.View,{style:ba.copyrightContainer,children:[Object(y.jsxs)(O.Text,{style:[ba.copyright,{fontWeight:"medium"}],children:[ua.copyright[t]," ",n]}),Object(y.jsxs)(O.Text,{style:ba.copyright,children:[ua.generated[t]," ",a[t]]})]}),Object(y.jsx)(O.Image,{src:"/pdf-footer-logo.png",style:ba.footerLogo})]})},pa=O.StyleSheet.create({title:{fontFamily:"Noto Sans",fontWeight:"medium",fontSize:12,marginBottom:12},notes:{fontFamily:"Noto Sans",fontSize:9}}),fa=function(e){var t=e.notes,n=e.exportLanguage,a=void 0===n?"english":n;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(O.Text,{style:pa.title,children:U.notes[a]}),Object(y.jsx)(O.Text,{style:pa.notes,children:t})]})};fa.defaultProps={notes:""};var ma=fa,va=n(20),Oa=O.StyleSheet.create({title:{fontFamily:"Noto Sans",fontWeight:"medium",fontSize:12,marginBottom:12,marginTop:3},row:{display:"flex",flexDirection:"row",justifyContent:"space-between",marginBottom:20},fieldContainer:{width:"25%"},fieldText:{fontFamily:"Noto Sans",fontSize:9},fieldTitle:{color:"#363948",lineHeight:2},fieldValue:{color:"#14151C",fontWeight:"medium"}}),ha=function(e){var t=e.exportLanguage,n=e.tankInformation;return Object(y.jsxs)(O.View,{children:[Object(y.jsx)(O.Text,{style:Oa.title,children:M.tankInfo[t]}),Object(y.jsxs)(O.View,{style:Oa.row,children:[Object(y.jsxs)(O.View,{style:Oa.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[Oa.fieldText,Oa.fieldTitle],children:M.tankSize[t]}),Object(y.jsx)(O.Text,{style:[Oa.fieldText,Oa.fieldValue],children:"".concat(ra(n.tankSizeValue)," ").concat(Object(va.g)(n.tankSizeUnit))})]}),Object(y.jsxs)(O.View,{style:Oa.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[Oa.fieldText,Oa.fieldTitle],children:M.carrierArea[t]}),Object(y.jsx)(O.Text,{style:[Oa.fieldText,Oa.fieldValue],children:"".concat(ra(n.carrierPerAreaValue)," ").concat(Object(va.g)(n.carrierPerAreaUnit))})]}),Object(y.jsxs)(O.View,{style:Oa.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[Oa.fieldText,Oa.fieldTitle],children:M.totalCarrier[t]}),Object(y.jsx)(O.Text,{style:[Oa.fieldText,Oa.fieldValue],children:"".concat(ra(n.totalCarrierValue)," ").concat(Object(va.g)(n.totalCarrierUnit))})]}),Object(y.jsxs)(O.View,{style:Oa.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[Oa.fieldText,Oa.fieldTitle],children:M.tankCount[t]}),Object(y.jsx)(O.Text,{style:[Oa.fieldText,Oa.fieldValue],children:ra(n.tankCount)})]})]})]})};ha.defaultProps={tankInformation:{}};var xa=ha,ga=O.StyleSheet.create({signatureContainer:{display:"flex",justifyContent:"space-between",flexDirection:"row"},downLine:{borderBottom:"1px solid #00004B",width:"40%",paddingBottom:4},text:{fontSize:10,fontFamily:"Noto Sans",fontWeight:"medium"}}),Ca=function(e){var t=e.exportLanguage,n=void 0===t?"english":t;return Object(y.jsxs)(O.View,{style:ga.signatureContainer,children:[Object(y.jsx)(O.View,{style:ga.downLine,children:Object(y.jsx)(O.Text,{style:ga.text,children:Z.signature[n]})}),Object(y.jsx)(O.View,{style:ga.downLine,children:Object(y.jsxs)(O.Text,{style:ga.text,children:[" ",Z.date[n]]})})]})},ya=n(2843),Pa=O.StyleSheet.create({title:{fontFamily:"Noto Sans",fontWeight:"medium",fontSize:12,marginBottom:12},row:{display:"flex",flexDirection:"row",justifyContent:"space-between",marginBottom:20},fieldContainer:{width:"50%"},fieldText:{fontFamily:"Noto Sans",fontSize:9},fieldTitle:{color:"#363948",lineHeight:2},fieldValue:{color:"#14151C",fontWeight:"medium"}}),Aa=function(e,t){return e.licenseNumber?e.expiresDateEpoch?"".concat(e.licenseNumber," - ").concat("english"===t?Object(ya.a)(e.expiresDateEpoch,"MM/dd/yyyy"):Object(ya.a)(e.expiresDateEpoch,"dd/MM/yyyy")):e.licenseNumber:"-"},Sa=function(e){var t=e.applicators,n=e.exportLanguage,a=void 0===n?"english":n;return t.length>0?Object(y.jsxs)(O.View,{children:[Object(y.jsx)(O.Text,{style:Pa.title,children:L.applicators[a]}),t.map((function(e){var t;return Object(y.jsxs)(O.View,{style:Pa.row,children:[Object(y.jsxs)(O.View,{style:Pa.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[Pa.fieldText,Pa.fieldTitle],children:L.nameCompany[a]}),Object(y.jsxs)(O.Text,{style:[Pa.fieldText,Pa.fieldValue],children:[e.personName," / ",null!==(t=e.companyName)&&void 0!==t?t:"-"]})]}),Object(y.jsxs)(O.View,{style:Pa.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[Pa.fieldText,Pa.fieldTitle],children:L.licenseNo[a]}),Object(y.jsx)(O.Text,{style:[Pa.fieldText,Pa.fieldValue],children:Aa(e,a)})]})]},e.licenseNumber)}))]}):null};Sa.defaultProps={applicators:[]};var Ta=Sa;O.Font.register({family:"Noto Sans",fonts:[{src:h,fontStyle:"italic",fontWeight:"light"},{src:x},{src:g},{src:C}]});var Na=O.StyleSheet.create({body:{paddingHorizontal:20,paddingBottom:85},overallView:{paddingHorizontal:10},viewContainer:{marginBottom:27}}),Ea=function(e){var t=e.children,n=e.headerTitle,a=e.orgName,r=e.cropName,c=e.cropSeasons,i=e.generatedYear,o=e.generatedFullDate,s=e.status,l=e.type,d=e.exportLanguage;return Object(y.jsx)(O.Document,{children:Object(y.jsxs)(O.Page,{style:Na.body,children:[Object(y.jsx)(da,{type:l,title:n,organization:a,cropName:r,cropSeasons:c,status:s,exportLanguage:d}),Object(y.jsx)(O.View,{style:Na.overallView,children:t}),Object(y.jsx)(ja,{exportLanguage:d,year:i,fullDate:o})]})})};Ea.defaultProps={cropName:null,cropSeasons:[],status:null,exportLanguage:"english"};var wa=Ea,_a=O.StyleSheet.create({taskDetailsContainer:{display:"flex",flexDirection:"row",justifyContent:"space-between"},taskDetails:{width:"50%"},imageContainer:{width:270,height:198},row:{display:"flex",flexDirection:"row",justifyContent:"space-between",marginBottom:20},fieldContainer:{width:"50%"},fieldText:{fontFamily:"Noto Sans",fontSize:9},fieldTitle:{color:"#363948",lineHeight:2},fieldValue:{color:"#14151C",fontWeight:"medium"}}),Ra=function(e){var t=e.rec;return Object(y.jsxs)(O.View,{style:_a.taskDetailsContainer,children:[Object(y.jsxs)(O.View,{style:_a.taskDetails,children:[Object(y.jsxs)(O.View,{children:[Object(y.jsxs)(O.View,{style:_a.row,children:[Object(y.jsxs)(O.View,{style:_a.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[_a.fieldText,_a.fieldTitle],children:"Proposed Date"}),Object(y.jsx)(O.Text,{style:[_a.fieldText,_a.fieldValue],children:aa(t.proposedDate)})]}),Object(y.jsxs)(O.View,{style:_a.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[_a.fieldText,_a.fieldTitle],children:"Authorized By"}),Object(y.jsx)(O.Text,{style:[_a.fieldText,_a.fieldValue],children:aa(t.authorisedByName)})]})]}),Object(y.jsxs)(O.View,{style:_a.row,children:[Object(y.jsxs)(O.View,{style:_a.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[_a.fieldText,_a.fieldTitle],children:"Authorized On"}),Object(y.jsx)(O.Text,{style:[_a.fieldText,_a.fieldValue],children:aa(t.authorisedOn)})]}),Object(y.jsxs)(O.View,{style:_a.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[_a.fieldText,_a.fieldTitle],children:"Expiration Date"}),Object(y.jsx)(O.Text,{style:[_a.fieldText,_a.fieldValue],children:aa(t.expirationDate)})]})]}),Object(y.jsx)(O.View,{style:_a.row,children:Object(y.jsxs)(O.View,{style:_a.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[_a.fieldText,_a.fieldTitle],children:"Timing Event"}),Object(y.jsx)(O.Text,{style:[_a.fieldText,_a.fieldValue],children:aa(t.timingEvent)})]})})]}),Object(y.jsx)(Ta,{applicators:t.applicators})]}),t.mapImage?Object(y.jsx)(O.View,{style:_a.imageContainer,children:Object(y.jsx)(O.Image,{src:t.mapImage})}):null]})},Ia=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return{label:e,styles:t,subtexts:n}},Da=function(e){return e.reduce((function(e,t){return e+t.areaValue}),0)},ka=[{label:"Name/Active",width:19},{label:"Area Applied",width:14},{label:"% Area",width:11},{label:"EPA Number",width:13},{label:"REI(h)",width:8},{label:"PHI(d)",width:8},{label:"Rate/Area",width:15},{label:"Total",width:12}],La=18,Fa=[{label:"Farm",width:La},{label:"Field",width:La},{label:"Crop Zone",width:La},{label:"Crop",width:La},{label:"Center Lat/Long",width:19},{label:"Rec. Area",width:9}],Ma=O.StyleSheet.create({viewContainer:{marginBottom:27}}),Va=function(e){var t=e.rec;return t?Object(y.jsxs)(wa,{headerTitle:t.title,type:"Recommendation",orgName:t.organizationName,cropSeasons:t.cropSeasons,generatedYear:t.year,generatedFullDate:t.fullDate,children:[Object(y.jsxs)(O.View,{style:Ma.viewContainer,children:[Object(y.jsx)(Ra,{rec:t}),Object(y.jsx)(xa,{tankInformation:t.tankInformation})]}),Object(y.jsx)(O.View,{style:Ma.viewContainer,wrap:!1,children:Object(y.jsx)(R,{title:"Products",headerItems:ka,bodyItems:t.recommendationProductEntries})}),Object(y.jsx)(O.View,{style:Ma.viewContainer,wrap:!1,children:Object(y.jsx)(R,{title:"Fields",headerItems:Fa,bodyItems:t.cropZones,titleRight:"Area: ".concat(ra(t.totalFieldsArea)," ac.")})}),Object(y.jsx)(O.View,{style:Ma.viewContainer,wrap:!1,children:Object(y.jsx)(ma,{notes:aa(t.notes)})}),Object(y.jsx)(O.View,{style:Ma.viewContainer,wrap:!1,children:Object(y.jsx)(Ca,{})})]}):null};Va.defaultProps={rec:null};var Ba,Ua,za=Va,Za={id:"3c013cb7-027c-4bda-82de-f57919e4faa5",title:"test-rec",number:"",tankInformation:{tankCount:0,tankValueTypeEntered:"CarrierPerArea",tankSizeUnit:"gallon",tankSizeValue:0,carrierPerAreaUnit:"gallon",carrierPerAreaValue:0,totalCarrierUnit:"gallon",totalCarrierValue:0},cropZones:[],recommendationProductEntries:[{productId:"72972c93-4224-4db4-86ba-3e36d2a215b1",productName:"Gramoxone SL",manufacturerName:"Syngenta",trackingId:"b354a936-e481-4cf2-996d-a6b0d0f21ae5",productRatePerAreaValue:0,productRatePerAreaUnit:"gallon",areaUnit:"acre",productRatePerTankValue:0,productRatePerTankUnit:"gallon",totalProductValue:0,totalProductUnit:"gallon",coveragePercent:1,productAppliedAreaValue:0,productAppliedAreaUnit:"acre",productDensity:1,applicationMethod:"",custom:!1},{productId:"d8794335-c41a-413b-85bf-de5b3300e565",productName:"GA-06 (32,500 seed bag)",manufacturerName:"Public",trackingId:"3e268c2b-ccae-41e9-ab7b-dc93b8b90942",productRatePerAreaValue:2,productRatePerAreaUnit:"bag",areaUnit:"acre",productRatePerTankValue:0,productRatePerTankUnit:"bag",totalProductValue:0,totalProductUnit:"bag",coveragePercent:1,productAppliedAreaValue:0,productAppliedAreaUnit:"acre",productDensity:32500,applicationMethod:"",custom:!1}],documentDescriptors:[],applicators:[{applicatorId:"cc185946-a7d7-4039-ad03-6f3c0eef7b1b",companyName:"",personName:"",personId:"529396fb-9fd9-4e64-a486-d624289447aa",companyId:"f4b27737-44e6-486a-9999-75b2d8141718"}],cropSeasonIds:["ee492fb8-b04c-43c5-80df-feb89e3eedf8"],flagIds:["31bc24d8-7a2f-44ef-9ab6-383844e80120"],unknownCropZones:[],unknownApplicators:[],unknownAuthorizations:[],unknownRecommendationProducts:[],proposedDate:"11/30/2022",proposedDateEpoch:1669788e6,expirationDate:"12/26/2022",expirationDateEpoch:1672070079385,createdOn:"2022-11-25T15:55:00",timingEvent:"",organizationId:"72dd40be-405d-4b68-897d-1a6141c98fb0",authorisedOn:"11/25/2022",authorisedOnEpoch:1669391679385,authorisedByName:"Andrew Gullixson",authorisedById:"1cb5efcd-42eb-4239-8bfc-a8dd871dbfbb",type:"LANDDB",applicationStrategy:"ByRatePerArea",coveragePercent:100},Ya=function(){var e=Object(a.useState)(!0),t=Object(b.a)(e,2),n=t[0],r=t[1];return Object(a.useEffect)((function(){setTimeout((function(){r(!1)}),2e3)}),[]),n?Object(y.jsx)(y.Fragment,{children:"Loading"}):Object(y.jsx)("div",{style:{width:"100%",height:"100vh"},children:Object(y.jsx)(O.PDFViewer,{width:"100%",height:"100%",children:Object(y.jsx)(za,{rec:Za})})})},Ha=n.p+"static/media/login-background.d3e1647f.svg",Ga=n.p+"static/media/cropwise-financials-logo.3997d3c9.svg",Wa=n.p+"static/media/warning.f5dd6113.svg",qa={background:"#FFF3DD",border:"1px solid #F0C355",padding:"12px 16px 12px 16px",bottom:"-11rem"},Ja=function(e){var t=e.featureFlagText;return Object(y.jsxs)("div",{className:"absolute rounded flex",style:qa,children:[Object(y.jsx)("div",{className:"w-22 mr-4",children:Object(y.jsx)("img",{src:Wa,alt:"CropWise Warning Icon"})}),Object(y.jsxs)("div",{children:[Object(y.jsx)("h2",{className:"text-neutral-1000 text-base font-bold",children:"Undergoing Maintenance"}),Object(y.jsxs)("p",{className:"text-sm",children:["Cropwise Financials is temporarily unavailable due to planned maintenance. We expect to be back today around"," ",Object(y.jsx)("span",{className:"font-bold",children:t}),". Thank you for your patience."]})]})]})},Ka=function(){var e=Object(a.useState)(),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useContext)(we),i=c.events,o=c.sendEventToAmplitude,s=Object(f.useFlags)().feLandManagementUndergoingMaintenanceMessaging;return Object(y.jsxs)("div",{children:[n&&Object(y.jsx)(p.b,{push:!0,to:"".concat(n)}),Object(y.jsx)("div",{children:Object(y.jsx)("img",{src:Ha,alt:"",className:"fixed right-0 object-cover w-1/2 h-screen inset"})}),Object(y.jsx)("div",{className:"w-1/2 h-screen",children:Object(y.jsx)("div",{className:"flex justify-center items-center h-screen",children:Object(y.jsxs)("div",{className:"relative flex flex-col items-center justify-center pl-6 md:items-start",children:[Object(y.jsx)("img",{src:Ga,alt:"CropWise Logo",className:"block mb-12 md:inline"}),Object(y.jsx)("div",{className:"flex w-full justify-center",children:Object(y.jsxs)("div",{className:"flex flex-wrap",children:[Object(y.jsx)(m.Button,{type:"primary",disabled:""!==s,onClick:function(){o(i.epic.Authentication.signIn),r("/login")},children:"Sign In"}),Object(y.jsx)("div",{className:"ml-4",children:Object(y.jsx)(m.Button,{type:"primary",disabled:""!==s,onClick:function(){return window.location.href="https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl"},children:"Sign Up"})})]})}),s&&""!==s&&Object(y.jsx)(Ja,{featureFlagText:s})]})})})]})},Qa=function(){var e=Object(p.h)(),t=Object(a.useState)(),n=Object(b.a)(t,2),r=n[0],c=n[1],i=We(),o=i.fetchUserProfile,s=i.user;Object(a.useEffect)((function(){var e=location.search.replace("?",""),t=be.a.parse(e);t.state?c(t):c({code:t.code,state:null})}),[]),Object(a.useEffect)((function(){if(r)if(r.code&&!r.state)sessionStorage.getItem("cod".concat(r.code))||d(r.code);else if(r.code&&"L2FwcC93b3Jrc3BhY2Vz"===r.state){if(!sessionStorage.getItem("cod".concat(r.code)))return void d(r.code);e.push("/app")}else Le()?o():window.location.href=Be}),[r]);var l=function(){var t=Object(Y.a)(G.a.mark((function t(){return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("L2FwcC93b3Jrc3BhY2Vz"!==(null===r||void 0===r?void 0:r.state)){t.next=13;break}return c(void 0),t.prev=2,t.next=5,Ye(s.auto_created_org_id,s.default_workspace_id,s.id);case 5:e.push("/app"),t.next=11;break;case 8:t.prev=8,t.t0=t.catch(2),e.push("/app");case 11:t.next=14;break;case 13:e.push("/app");case 14:case"end":return t.stop()}}),t,null,[[2,8]])})));return function(){return t.apply(this,arguments)}}();Object(a.useEffect)((function(){void 0!==r&&s&&l()}),[s,r]);var d=function(e){var t={grant_type:"authorization_code",client_id:"ddcd4fe8157148fc90b0fe95753f2bd0",redirect_uri:"".concat(location.origin,"/authenticate"),code:e};sessionStorage.setItem("cod".concat(e),"Y"),ze(t).then((function(){o()}))};return Object(y.jsx)("div",{className:"m-auto h-screen w-full",children:Object(y.jsx)(m.Spinner,{})})},Xa="Admin",$a="Full control",er="View Only",tr=(Ba={},Object(et.a)(Ba,Xa,1),Object(et.a)(Ba,$a,2),Object(et.a)(Ba,er,3),Ba),nr="WRITE",ar="READ",rr=(Ua={},Object(et.a)(Ua,nr,1),Object(et.a)(Ua,ar,2),Ua),cr=function(e,t){return!(!e||!tr[e])&&(!t||tr[e]<=tr[t])},ir=function(e,t){return!t||!!e&&rr[e]<=rr[t]},or=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.role,n=e.financialAccess,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=a.minAllowedRole,c=a.minFinancialAccess;return t===Xa||cr(t,r)&&ir(n,c)},sr="SET_ERROR",lr="SET_ORGANIZATION",dr="SET_PERMISSION",ur="LOGOUT_USER",br="BACKGROUND_COLOR",jr="SET_ORGANIZATIONS",pr="ORG_LOADING",fr="SELECT_PROPERTY",mr="EXPAND_PROPERTIES",vr="COLLAPSE_PROPERTY",Or="SET_SEASONS",hr="DELETE_SEASON",xr="SELECTED_FIELD_ROW_ID",gr="IS_MASS_ASSIGNER_ACTIVE",Cr="IS_EXPORT_PDF_MAPS_ACTIVE",yr="DISMISS_EXPORT_PDF_MAPS_ALERT",Pr="FIELDS_TO_MASSIVE_ASSIGN",Ar="MASSIVE_CHANGE_SUMMARY",Sr="RESET_MASS_ASSIGNER",Tr="IS_FARM_EDITED",Nr="MASS_ASSIGNER_SUCCESS_COUNTER",Er="MASS_ASSIGNER_REJECTIONS",wr="IS_GLOBAL_CROPSEASON_LOADING",_r="SEARCH_TEXT_VALUE_FFT",Rr="IS_FIELD_IMPORT_SUCCESSFUL",Ir="IMPORTED_FIELDS",Dr="UPLOADED_FILES",kr="SET_LOAD_PROPERTIES",Lr="IS_FULL_SCREEN_NEEDED",Fr="SET_LOAD_COSTS",Mr="SET_CROP_ZONE_MATCHER_TYPE",Vr="SET_SHOW_TOAST_CROP_ZONE_MATCHER",Br="SET_SELECTED_PRODUCT",Ur="SET_SHOW_TOAST_REMOVE_PRODUCT",zr="SET_TOAST_TYPE",Zr="SET_TOAST_MESSAGE",Yr="SET_REMOVE_PRODUCT_FAILURE",Hr="SET_CROP_ZONE_MATCHER_INFO",Gr="SET_SIDEBAR_STATUS",Wr="SET_SHOW_TOAST_SALE_LOCATION",qr="SET_SORT_RULES",Jr="SET_SELECTED_LOCATION",Kr="SET_SHOW_TOAST_CHANGES_SAVED",Qr="SET_TASK_CREATION_FROM",Xr=new Event("cwf-expired"),$r=function(e,t){switch(t.type){case"SET_TOOLBAR":return Object(I.a)(Object(I.a)({},e),{},{toolbarComponents:t.payload});case sr:return Object(I.a)(Object(I.a)({},e),{},{error:t.payload});case jr:return Object(I.a)(Object(I.a)({},e),{},{organizations:t.payload});case lr:return t.payload.id!==e.organization.id&&Mt(),Object(I.a)(Object(I.a)({},e),{},{organization:t.payload});case dr:return Object(I.a)(Object(I.a)({},e),{},{permission:t.payload});case ur:return window.dispatchEvent(Xr),Object(I.a)(Object(I.a)({},e),{},{permission:null});case br:return Object(I.a)(Object(I.a)({},e),{},{backgroundColor:t.payload});case"SET_ORGANIZATION_PERMISSIONS":return Object(I.a)(Object(I.a)({},e),{},{organizationPermissions:t.payload});case"SET_USER_ENVIRONMENT":return Object(I.a)(Object(I.a)({},e),{},{organization:t.organization,permission:t.permission,organizationPermissions:t.organizationPermissions});case"SET_SELECTED_CONTEXT":return Object(I.a)(Object(I.a)({},e),{},{selectedContext:t.payload});case"SET_CONVERT_PLAN":return Object(I.a)(Object(I.a)({},e),{},{planToConvert:t.payload});case"SWITCH_WEATHER_TOGGLE":return Object(I.a)(Object(I.a)({},e),{},{weatherAutomaticToggle:!e.weatherAutomaticToggle});case"RESET_PROPERTY_NAME":return Object(I.a)(Object(I.a)({},e),{},{shouldResetPropertyName:!e.shouldResetPropertyName});case"SELECT_MEMBER":return Object(I.a)(Object(I.a)({},e),{},{loggedInUserOrgPermission:t.payload});case pr:return Object(I.a)(Object(I.a)({},e),{},{loadingOrg:t.payload});case fr:return Object(I.a)(Object(I.a)({},e),{},{selectedProperty:t.payload});case mr:return Object(I.a)(Object(I.a)({},e),{},{expandedPropertyIds:[].concat(Object(v.a)(e.expandedPropertyIds),[t.payload])});case vr:return Object(I.a)(Object(I.a)({},e),{},{expandedPropertyIds:e.expandedPropertyIds.filter((function(e){return e!==t.payload}))});case Or:return Object(I.a)(Object(I.a)({},e),{},{cropSeasons:t.payload});case hr:return Object(I.a)(Object(I.a)({},e),{},{cropSeasons:e.cropSeasons.filter((function(e){return e.id!==t.payload}))});case"DELETE_YIELD":return Object(I.a)(Object(I.a)({},e),{},{yieldEntryId:t.payload});case xr:return Object(I.a)(Object(I.a)({},e),{},{selectedFieldRowId:t.payload});case"IS_ENABLE_INFO_TAB_EDIT":return Object(I.a)(Object(I.a)({},e),{},{isEnableInfoTabEdit:t.payload});case gr:return Object(I.a)(Object(I.a)({},e),{},{isMassAssignerActive:t.payload});case Cr:return Object(I.a)(Object(I.a)({},e),{},{isExportPDFMapsActive:t.payload});case yr:return Object(I.a)(Object(I.a)({},e),{},{isExportPDFMapsAlertDismissed:!0});case Pr:return Object(I.a)(Object(I.a)({},e),{},{fieldsToMassiveAssign:Object(ne.uniqBy)(t.payload,"id")});case Ar:return Object(I.a)(Object(I.a)({},e),{},{massiveChangeSummary:t.payload});case Sr:return Object(I.a)(Object(I.a)({},e),{},{isMassAssignerActive:t.payload||!1,isExportPDFMapsActive:t.payload||!1,massiveChangeSummary:{},fieldsToMassiveAssign:[]});case Tr:return Object(I.a)(Object(I.a)({},e),{},{isFarmEdited:t.payload});case"UPDATE_CROP_NAME":return Object(I.a)(Object(I.a)({},e),{},{updateCropName:t.payload});case Nr:return Object(I.a)(Object(I.a)({},e),{},{massAssignerSuccessCounter:t.payload});case Er:return Object(I.a)(Object(I.a)({},e),{},{massAssignerRejections:t.payload});case wr:return Object(I.a)(Object(I.a)({},e),{},{isGlobalCropSeasonLoading:t.payload});case _r:return Object(I.a)(Object(I.a)({},e),{},{searchTextValueFFT:t.payload});case Rr:return Object(I.a)(Object(I.a)({},e),{},{isFieldImportedSuccessful:t.payload});case Ir:return Object(I.a)(Object(I.a)({},e),{},{importedFields:t.payload});case Dr:return Object(I.a)(Object(I.a)({},e),{},{uploadedFiles:t.payload});case kr:return Object(I.a)(Object(I.a)({},e),{},{loadingProperties:t.payload,selectedProperty:{},loadTimestamp:(new Date).valueOf()});case Lr:return Object(I.a)(Object(I.a)({},e),{},{isFullScreenNeeded:t.payload});case Fr:return Object(I.a)(Object(I.a)({},e),{},{loadingCosts:t.payload});case"SELECTED_YIELD_COMMODITY":return Object(I.a)(Object(I.a)({},e),{},{selectedYieldCommodity:t.payload});case"SET_DISABLE_INITIAL_ZOOM":return Object(I.a)(Object(I.a)({},e),{},{zoomInitialMap:t.payload});case Mr:return Object(I.a)(Object(I.a)({},e),{},{cropZoneMatcherType:t.payload});case Ur:return Object(I.a)(Object(I.a)({},e),{},{showToastRemoveProduct:t.payload});case Br:return Object(I.a)(Object(I.a)({},e),{},{selectedProduct:t.payload});case zr:return Object(I.a)(Object(I.a)({},e),{},{toastType:t.payload});case Zr:return Object(I.a)(Object(I.a)({},e),{},{toastMessage:t.payload});case Yr:return Object(I.a)(Object(I.a)({},e),{},{removeProductFailure:t.payload});case Vr:return Object(I.a)(Object(I.a)({},e),{},{showToastCropZoneMatcher:t.payload});case Hr:return Object(I.a)(Object(I.a)({},e),{},{additionalInformationToastCropZoneMatcher:t.payload});case"SET_PROPERTY_FILTERS":return Object(I.a)(Object(I.a)({},e),{},{propertyFilters:Object(I.a)(Object(I.a)({},e.propertyFilters),t.payload)});case Gr:return Object(I.a)(Object(I.a)({},e),{},{isSidebarOpen:t.payload});case Wr:return Object(I.a)(Object(I.a)({},e),{},{showToastSaleLocation:t.payload});case qr:return Object(I.a)(Object(I.a)({},e),{},{sortRules:t.payload});case Jr:return Object(I.a)(Object(I.a)({},e),{},{selectedLocation:t.payload});case Kr:return Object(I.a)(Object(I.a)({},e),{},{showToastChangesSaved:t.payload});case Qr:return Object(I.a)(Object(I.a)({},e),{},{taskCreationFrom:t.payload});default:return e}},ec={toolbarComponents:null,error:null,organizations:null,organization:{id:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",name:"Test Org"},permission:[],backgroundColor:"#F3F4F6",organizationPermissions:[],selectedContext:null,planToConvert:{},weatherAutomaticToggle:!0,shouldResetPropertyName:!1,loggedInUserOrgPermission:{role:"View Only",financialAccess:void 0},loadingOrg:!0,selectedProperty:{},expandedPropertyIds:[],cropSeasons:[],selectedFieldRowId:{},isEnableInfoTabEdit:!1,isMassAssignerActive:!1,isExportPDFMapsActive:!1,isExportPDFMapsAlertDismissed:!1,fieldsToMassiveAssign:[],massiveChangeSummary:{},isFarmEdited:!1,updateCropName:{cropName:"",cropId:"",shouldUpdate:!1},massAssignerSuccessCounter:{},massAssignerRejections:[],isGlobalCropSeasonLoading:!1,searchTextValueFFT:"",isFieldImportedSuccessful:!1,importedFields:[],loadingProperties:!0,loadTimestamp:(new Date).valueOf(),isFullScreenNeeded:!1,uploadedFiles:[],loadingCosts:!0,selectedYieldCommodity:{id:"",name:""},zoomInitialMap:!1,cropZoneMatcherType:"null",selectedProduct:void 0,showToastCropZoneMatcher:!1,showToastPropertyRemove:!1,showToastRemoveProduct:!1,showToastChangesSaved:!1,toastType:"null",toastMessage:"null",removeProductFailure:!1,additionalInformationToastCropZoneMatcher:{cropZoneName:"",operationMapped:"",totalOperationMapped:""},propertyFilters:{showArchivedProperties:!1,showFarmWithIds:[]},isSidebarOpen:!0,showToastSaleLocation:!1,sortRules:void 0,selectedLocation:void 0,taskCreationFrom:void 0},tc=function(e){var t=e.children,n=Object(a.useReducer)($r,Object(I.a)({},ec)),r=Object(b.a)(n,2),c=r[0],i=r[1];return Object(y.jsx)(ac.Provider,{value:[c,i],children:t})};tc.defaultProps={children:null};var nc,ac=Object(a.createContext)(ec),rc=tc,cc=n(57),ic=n.n(cc),oc=Symbol("SERVER_ERROR"),sc=Symbol("CLIENT_ERROR"),lc=(nc={400:"Bad Request"},Object(et.a)(nc,401,"Unauthorized"),Object(et.a)(nc,402,"Payment Required"),Object(et.a)(nc,403,"Forbidden"),Object(et.a)(nc,404,"Not Found"),Object(et.a)(nc,405,"Method Not Allowed"),Object(et.a)(nc,406,"Not Acceptable"),Object(et.a)(nc,407,"Proxy Authentication Required"),Object(et.a)(nc,408,"Request Timeout"),Object(et.a)(nc,409,"Conflict"),Object(et.a)(nc,410,"Gone"),Object(et.a)(nc,411,"Length Required"),Object(et.a)(nc,412,"(Precondition Failed) - Another user has edited this record, please refresh your page."),Object(et.a)(nc,413,"Payload Too Large"),Object(et.a)(nc,414,"URI Too Long"),Object(et.a)(nc,415,"Unsupported Media Type"),Object(et.a)(nc,416,"Range Not Satisfiable"),Object(et.a)(nc,417,"Expectation Failed"),Object(et.a)(nc,418,"I'm a Teapot"),Object(et.a)(nc,419,"Page Expired"),Object(et.a)(nc,421,"Misdirected Request"),Object(et.a)(nc,422,"Unprocessable Entity"),Object(et.a)(nc,423,"Locked"),Object(et.a)(nc,424,"Failed Dependency"),Object(et.a)(nc,425,"Too Early"),Object(et.a)(nc,426,"Upgrade Required"),Object(et.a)(nc,428,"Precondition Required"),Object(et.a)(nc,429,"Too Many Requests"),Object(et.a)(nc,431,"Request Header Fields Too Large"),Object(et.a)(nc,451,"Unavailable For Legal Reasons"),Object(et.a)(nc,498,"Invalid Token"),Object(et.a)(nc,499,"Token Required"),Object(et.a)(nc,500,"Internal Server Error"),Object(et.a)(nc,501,"Not Implemented"),Object(et.a)(nc,502,"Bad Gateway"),Object(et.a)(nc,503,"Service Unavailable"),Object(et.a)(nc,504,"Gateway Timeout"),Object(et.a)(nc,505,"HTTP Version Not Supported"),Object(et.a)(nc,506,"Variant Also Negotiates"),Object(et.a)(nc,507,"Insufficient Storage"),Object(et.a)(nc,508,"Loop Detected"),Object(et.a)(nc,510,"Not Extended"),Object(et.a)(nc,511,"Network Authentication Required"),nc),dc=function(e,t){var n=e.showTryAgain||!1,a=t.response&&t.response.data&&t.response.data.message||t.message,r=t.response&&t.response.status||500;return{id:Object(cc.generate)(),type:oc,showTryAgain:n,message:a,displayMessage:a||e.displayMessage||lc[r]||"Unrecognized Server Error",status:r}},uc=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var a,r;401===(null===(a=n.response)||void 0===a?void 0:a.status)?e({type:ur}):404===(null===(r=n.response)||void 0===r?void 0:r.status)&&t.noErrorOn404||e({type:sr,payload:dc(t,n)})}},bc=function(e){return function(t){e({type:sr,payload:{id:Object(cc.generate)(),type:sc,message:t}})}},jc=function(e,t,n){e({type:t,payload:n})},pc=zt(),fc=function(e,t){var n;return u.l?[{scope:"WRITE",name:"APPS"},{scope:"READ",name:"ORG"}]:null===t||void 0===t||null===(n=t.find((function(t){return(null===e||void 0===e?void 0:e.id)===(null===t||void 0===t?void 0:t.id)})))||void 0===n?void 0:n.permissions},mc=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,r,c,i,o=arguments;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=o.length>2&&void 0!==o[2]&&o[2],jc(t,wr,!0),null===JSON.parse(localStorage.getItem("selectedCropSeasons"))&&localStorage.setItem("selectedCropSeasons",JSON.stringify([])),r=(new Date).getTime(),c=en.createChildApi({action:a?"cropseasons/condensed":"cropseasons"}).fetch(void 0,{pageNo:0,size:1e3},void 0,a?void 0:"results",!0),i=c.promise,e.next=7,i.then((function(e){var a=e.data;if(a){var c={active:[],upcoming:[],past:[]};a.forEach((function(e){r>e.startDateEpoch?r>e.endDateEpoch?c.past.push(e.id):c.active.push(e.id):c.upcoming.push(e.id)})),JSON.parse(localStorage.getItem("selectedCropSeasons")).length?null!==n&&localStorage.setItem("selectedCropSeasons",JSON.stringify([n].flat())):c.active.length?localStorage.setItem("selectedCropSeasons",JSON.stringify(c.active)):c.past.length?localStorage.setItem("selectedCropSeasons",JSON.stringify([c.past[0]])):c.upcoming.length&&localStorage.setItem("selectedCropSeasons",JSON.stringify([c.upcoming[0]])),jc(t,Or,a)}})).catch(Ae.default).catch((function(e){uc(t)(e)})).finally((function(){return jc(t,wr,!1)}));case 7:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),vc=function(e,t,n){var a=fc(t,n.authorities);jc(e,lr,t),jc(e,dr,a),jc(e,fr,{}),localStorage.setItem("PROPERTY_VIEW_v2","map"),pc.updateRequestInterceptor({},(function(){return"{organization_id: ".concat(t.id,"}")})),localStorage.setItem("selectedOrganizationId",t.id)},Oc=function(){var e=We().user,t=Object(a.useContext)(ac),n=Object(b.a)(t,2)[1],r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(),l=Object(b.a)(s,2),d=l[0],j=l[1],p=Object(a.useState)(),f=Object(b.a)(p,2),m=f[0],v=f[1],O=Object(a.useCallback)(Object(Y.a)(G.a.mark((function t(){var a,r;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n({type:"ORG_LOADING",payload:!0}),a=Jt.fetch(null,{includeProperties:!0}),r=a.promise,o(!1),t.next=5,r.then((function(t){var a,r=t.data,c=null===r||void 0===r||null===(a=r.members)||void 0===a?void 0:a.filter((function(t){return t.email===e.email}))[0];n({type:"SELECT_MEMBER",payload:c}),n({type:"ORG_LOADING",payload:!1})})).catch(Ae.default).catch((function(e){n({type:"ORG_LOADING",payload:!1}),o(!0),uc(n)(e)}));case 5:case"end":return t.stop()}}),t)}))),[n,e.email]);return{setOrganization:Object(a.useCallback)((function(t){vc(n,t,e),O()}),[n,O,e]),organizationPermissionError:i,getOrgByIdV1:Object(a.useCallback)((function(e){return j(!1),J.a.get("".concat(u.d,"/v1/base/organization?includeProperties=true"),{headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(Ve()),"cwf-context":JSON.stringify({organization_id:e})}}).then((function(e){var t=e.data;v(t||null)})).catch(Ae.default).catch(uc(n)).finally((function(){return j(!0)}))}),[]),loadedOrgByIdV1:d,orgByIdV1:m}},hc=n.p+"static/media/cropwise-financials-icon.ed734f3c.svg",xc=n.p+"static/media/cropwise-financials-text.3efd656b.svg",gc=n.p+"static/media/syngenta-digital.0e8260dd.svg",Cc={welcome:"/app/welcome",organizations:"/app/organizations",properties:"/app/property-landing",cropSeasons:"/app/crop-seasons",plans:"/app/plans",recommendations:"/app/recommendations",tasks:"/app/tasks",invoices:"/app/invoices",inventory:"/app/inventory",products:"/app/products",people:"/app/people",companies:"/app/companies",equipment:"/app/equipment",integrations:"/app/integrations",reports:"/app/reports",yield:"/app/yieldV1",yieldV2:"/app/yieldV2",integrationCropZoneMatcher:"/app/integrations/crop-zone-matcher"},yc=function(e,t,n){var a=null===t||void 0===t?void 0:t.includes(n);return e||a},Pc=n.p+"static/media/expand_less.3b4a157e.svg",Ac=n.p+"static/media/expand_more.d97ac396.svg",Sc=function(e){var t,n=e.item,a=e.pathname;return a.includes(null===n||void 0===n?void 0:n.path)||(null===n||void 0===n||null===(t=n.subRoutes)||void 0===t?void 0:t.some((function(e){return a.includes(null===e||void 0===e?void 0:e.path)})))},Tc=function(e){var t,n,r,c=e.item,i=e.isOpened,o=Object(a.useState)(!0),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(!1),f=Object(b.a)(u,2),v=f[0],O=f[1],h=Object(a.useContext)(we),x=Object(p.i)();Object(a.useEffect)((function(){i?O(!1):d(!0)}),[i]);var g=Sc({item:c,pathname:x.pathname}),C=function(e){var t=e.route,n=e.pathname;return Object(y.jsx)(m.NavItem,{disabled:t.disabled,icon:t.icon,active:Sc({item:t,pathname:n}),open:!0,as:Object(y.jsx)(j.c,{onClick:function(){return h.sendEventToAmplitude(h.filterNavItems(t.key))},to:t.path,sensitive:!0,secure:!0,exact:!0},t.key),children:Object(y.jsx)(y.Fragment,{children:Object(ne.startCase)(t.id)})},t.key)};return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("button",{type:"button",className:"focus:outline-none relative gr-flex gr-flex-row gr-items-center  gr-w-64 gr-leading-5 gr-py-1 gr-relative gr-transition gr-items-center gr-duration-200 gr-group gr-mb-1 gr-text-neutral-500 hover:gr-bg-neutral-1000 hover:gr-text-white cursor-pointer ".concat(g?"text-white":""),onClick:function(){return i?d(!l):O(!v)},onBlur:function(e){e.currentTarget.contains(e.relatedTarget)||O(!1)},children:[v&&Object(y.jsx)("div",{className:"absolute w-full z-50",style:{left:"68px",backgroundColor:"#232630"},children:null===c||void 0===c||null===(t=c.subRoutes)||void 0===t?void 0:t.map((function(e){return C({route:e,pathname:x.pathname})}))}),Object(y.jsxs)("div",{className:"gr-h-8 gr-items-center gr-justify-center gr-flex gr-w-16",children:[Object(y.jsx)("span",{className:"gr-bg-inherit gr-h-8 gr-absolute gr-rounded-r gr-w-1 gr-flex-1 gr-left-0"}),c.icon]}),Object(y.jsx)("div",{className:"flex-1 text-left",children:Object(y.jsx)("span",{className:"gr-opacity-100 gr-transition gr-ease-in gr-duration-200 gr-text-sm gr-min-w-full ".concat(g?"text-white":""),children:Object(ne.startCase)(c.id)})}),Object(y.jsx)("div",{className:"gr-h-8 gr-items-center gr-justify-center gr-flex gr-w-16",children:(null===c||void 0===c||null===(n=c.subRoutes)||void 0===n?void 0:n.length)>0&&(l?Object(y.jsx)("img",{src:Ac,className:"gr-text-neutral-500 hover:gr-text-white",alt:"expand-more-icon"}):Object(y.jsx)("img",{src:Pc,className:"gr-text-neutral-500 hover:gr-text-white",alt:"expand-less-icon"}))})]}),Object(y.jsx)("div",{children:!l&&(null===c||void 0===c||null===(r=c.subRoutes)||void 0===r?void 0:r.map((function(e){return C({route:e,pathname:x.pathname})})))})]})},Nc=Object(f.withLDConsumer)()((function(e){var t=e.routes,n=Object(f.useFlags)(),r=n.feReportsModuleEnableModule,c=n.feYieldModuleEnableModule,i=n.beJohnDeereEnabledForAll,o=n.beJohnDeereEnabledPerOrg,s=n.feInventoryModuleEnableModule,l=n.beProductPriceListEnabled,d=n.beProductPriceListEnableByOrgId,u=n.feProductPriceList,v=n.feYieldV2ModuleEnableModule,O=n.beYieldEnableByOrgId,h=Object(p.i)(),x=Object(a.useContext)(we),g=Object(a.useState)(t),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useContext)(ac),T=Object(b.a)(S,2),N=T[0],E=N.organization,w=N.loggedInUserOrgPermission,_=N.loadingOrg,R=T[1],I=Object(a.useState)(!0),D=Object(b.a)(I,2),k=D[0],L=D[1],F=u&&(l||(null===d||void 0===d?void 0:d.includes(null===E||void 0===E?void 0:E.id))),M=yc(v,O,null===E||void 0===E?void 0:E.id);Object(a.useEffect)((function(){A(t.filter((function(e){return"leftNav"===e.nav&&("inventory"===e.id?s:"products"===e.id?F:"reports"===e.id?r:"yield"===e.id&&"yield-v1"===e.key?c:"yield"===e.id&&"yieldV2"===e.key?M:"View Only"!==(null===w||void 0===w?void 0:w.role)||"organization"!==e.id)})))}),[i,o,E,c,w,r,s,F,v,k]);return Object(y.jsx)("div",{"data-testid":"nav-lg ",children:Object(y.jsx)(m.Navbar,{pathToBrandIcon:hc,pathToBrandText:xc,brandFooter:gc,setIsOpened:function(e){return L(!e)},onClick:function(e){R({type:Gr,payload:!e})},children:!_&&P.map((function(e){return null!==e&&void 0!==e&&e.subRoutes?Object(y.jsx)(Tc,{item:e,isOpened:k},e.key):Object(y.jsx)(m.NavItem,{disabled:e.disabled,icon:e.icon,active:h.pathname.includes(e.path)||h.pathname.includes(Cc.organizations)&&"organization"===e.id,as:Object(y.jsx)(j.c,{onClick:function(){return x.sendEventToAmplitude(x.filterNavItems(e.key))},to:"organizations"===e.key?"".concat(Cc.organizations,"/").concat(E.id):e.path,exact:!0},e.key),children:Object(y.jsx)(y.Fragment,{children:Object(ne.startCase)(e.id)})},e.key)}))})})})),Ec=n(15),wc=n.n(Ec),_c=(wc.a.string,wc.a.oneOf([oc,sc]),wc.a.bool,wc.a.string,wc.a.string,wc.a.number,function(e){var t=e.error,n=e.onReset;return Object(y.jsxs)("div",{"data-testid":"try-again-message",className:"flex flex-col items-center justify-center h-64 bg-white rounded shadow-md radius",role:"alert",children:[Object(y.jsxs)("div",{className:"text-xs text-gray-500",children:["Error code: ",t.status]}),Object(y.jsx)("div",{className:"px-4 text-xl leading-6 text-center text-gray-800",children:"Uh oh, there was an issue."}),Object(y.jsxs)("div",{className:"px-4 mt-2 text-base leading-5 text-center text-gray-700",children:["Something happened while trying to","Unknown"===t.status?" process":" load"," your data."]}),Object(y.jsx)("div",{className:"px-4 mb-10 text-base leading-5 text-center text-gray-700",children:"Try again and if the problem persists, please reach out to Support."}),Object(y.jsxs)("div",{className:"flex justify-center w-full",children:[Object(y.jsx)("div",{className:"mx-4",children:Object(y.jsx)("a",{href:"https://www.syngentadigital.com/us-en",type:"button",target:"_blank",rel:"noopener noreferrer",children:Object(y.jsx)(m.Button,{type:"primary",ghost:!0,children:Object(y.jsx)("div",{className:"block px-4 font-normal text-center w-36",children:"Contact Support"})})})}),Object(y.jsx)("div",{className:"mx-4",children:Object(y.jsx)(m.Button,{onClick:n,type:"primary",children:Object(y.jsx)("div",{className:"block px-4 font-normal text-center w-36",children:"Try again"})})})]})]})});_c.defaultProps={error:void 0};var Rc=_c,Ic=function(e){var t,n=e.error,a=e.onReset;return t=n.message&&n.message.includes("Mirage:")||n.type===sc?n.message:n.type===oc?"".concat(n.status,": ").concat(n.displayMessage):null,Object(y.jsx)(y.Fragment,{children:t?Object(y.jsx)("div",{className:"z-1010",children:Object(y.jsx)(m.Toast,{icon:"error",onClose:a,children:t})}):null})};Ic.defaultProps={error:void 0};var Dc=Ic,kc=n(41),Lc=n(36),Fc=n(112),Mc=n(113),Vc=function(e){Object(Fc.a)(n,e);var t=Object(Mc.a)(n);function n(e){var a;return Object(kc.a)(this,n),(a=t.call(this,e)).logger=console,a.state={hasError:!1,errorMessage:"",errorStack:"",componentStack:""},a}return Object(Lc.a)(n,[{key:"componentDidCatch",value:function(e,t){this.logger.error("error boundary:",e,t),this.setState({errorMessage:e.message,errorStack:e.stack,componentStack:t.componentStack})}},{key:"render",value:function(){var e=this.state,t=e.hasError,n=e.errorMessage,a=e.errorStack,r=e.componentStack,c=this.props.children;return t?["development","mirage-development"].includes("qa")?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("h1",{className:"my-4 h1",children:"An error has occurred."}),Object(y.jsx)("pre",{children:n}),Object(y.jsx)("h2",{className:"my-4 h2",children:"Error Stack"}),Object(y.jsx)("pre",{children:a}),Object(y.jsx)("h2",{className:"my-4 h2",children:"Component Stack"}),Object(y.jsx)("pre",{children:r})]}):Object(y.jsx)(Rc,{error:{status:"Unknown"},onReset:function(){window.location="/app"}}):c}}],[{key:"getDerivedStateFromError",value:function(e){return{hasError:!!e}}}]),n}(a.Component);Vc.defaultProps={children:null};var Bc=Vc,Uc=function(e){var t=e.children,n=e.history,r=Object(a.useContext)(ac),c=Object(b.a)(r,2),i=c[0].error,o=c[1],s=Object(a.useRef)(),l=Object(a.useCallback)((function(){return o({type:sr,payload:null})}),[o]);return Object(a.useEffect)((function(){return s.current=n.listen((function(){return l()})),function(){s.current&&s.current()}}),[n,l]),i&&i.showTryAgain?Object(y.jsx)(Rc,{error:i,onReset:l}):Object(y.jsxs)(y.Fragment,{children:[i&&Object(y.jsx)(Dc,{error:i,onReset:l}),Object(y.jsx)(Bc,{children:t})]})};Uc.defaultProps={children:void 0,history:void 0};var zc=Object(p.l)(Uc),Zc=function(e,t,n,a){var r=function(e,t){if(u.l)return{currentOrganization:{id:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",name:"Test Org"},currentOrganizationPermissions:[]};var n=null,a=null,r=e?e.authorities:null,c=localStorage.getItem("selectedOrganizationId");if(null!==t&&void 0!==t&&t.length){var i=t.find((function(e){return e.id===c}));i?a=fc(n=i,r):c=null}if(e&&!c&&null!==t&&void 0!==t&&t.length){var o=t[0];localStorage.setItem("selectedOrganizationId",o.id),a=fc(n=o,r)}return{currentOrganization:n,currentOrganizationPermissions:a}}(e,t),c=r.currentOrganization;vc(n,c,e),a(!0)},Yc=function(e){var t=Array.from(e);return t.length>1?t[t.length-2]:void 0},Hc=n(2794),Gc=function(e){var t=e.size,n=e.height,a=void 0===n?30:n,r=e.width,c=void 0===r?30:r;return Object(y.jsx)("svg",{viewBox:"0 0 ".concat(t," ").concat(t),width:"".concat(c),height:"".concat(a),fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"success-icon",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0Zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8Zm-2-5.83 6.59-6.59L16 7l-8 8-4-4 1.41-1.41L8 12.17Z",fill:"#19A04B",transform:"translate(2, 2)"})})};Gc.defaultProps={size:24,height:30,width:30};var Wc=Gc,qc=function(e){var t=e.size;return Object(y.jsx)("svg",{viewBox:"0 0 ".concat(t," ").concat(t),width:30,height:30,fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"warning-icon",children:Object(y.jsx)("path",{width:30,height:30,d:"M11 3.99 18.53 17H3.47L11 3.99ZM11 0 0 19h22L11 0Zm1 14h-2v2h2v-2Zm0-6h-2v4h2V8Z",fill:"#ECC94B"})})};qc.defaultProps={size:27};var Jc=qc,Kc=(n(1283),function(e){var t=e.type,n=e.title,r=e.onClose,c=e.open,i=e.timeout,o=e.children,s=e.isBold,l=e.customStyle,d=Object(a.useState)(c),u=Object(b.a)(d,2),j=u[0],p=u[1];Object(a.useEffect)((function(){p(c)}),[c]),Object(a.useEffect)((function(){var e;return j&&i>=0&&(e=setTimeout((function(){p(!1),r()}),i)),function(){e&&clearTimeout(e)}}),[j,i,r]);var f={success:Object(y.jsx)(Wc,{width:24,height:24}),warning:Object(y.jsx)(Jc,{}),info:Object(y.jsx)(m.Icon,{icon:"error",color:"#0092E4",size:24}),error:Object(y.jsx)(m.Icon,{icon:"error",color:"#CF3537",size:24})};return Object(y.jsx)("div",{className:" toast fixed transition-all duration-500 ease-in top-21 ".concat(j&&"show-toast"," py-4 px-6 bg-white rounded border-l-4 flex ").concat(o?"w-2/6":"w-1/4"),style:Object(I.a)({zIndex:2e3,borderColor:{success:"#19A04B",warning:"#ECC94B",info:"#0092E4",error:"#CF3537"}[t],boxShadow:"0 2px 3px 3px rgba(0, 0, 0, 0.2)"},l),"data-testid":"toast-alert",children:Object(y.jsxs)("div",{className:"w-full flex",children:[Object(y.jsx)("div",{className:"mr-3",children:f[t]}),Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsxs)("div",{className:"flex justify-between font-body items-center",children:[Object(y.jsx)("h4",{className:"text-base capitalize-first ".concat(s?"font-semibold":""),children:n}),Object(y.jsx)(m.Button,{ariaLabel:"alert-close",type:"text",onClick:r,icon:Object(y.jsx)(Hc.a,{}),size:"small"})]}),o&&Object(y.jsx)("div",{className:"mt-2",children:o})]})]})})});Kc.defaultProps={type:"success",open:!1,timeout:5e3,onClose:function(){},title:"",isBold:!1,children:null,customStyle:{}};var Qc=Kc,Xc=n(11),$c=function(){return Object(y.jsx)("div",{"data-testid":"support-button",className:"flex flex-col mt-2",children:Object(y.jsx)(Xc.Button,{style:{alignSelf:"end"},type:Xc.ButtonType.primary,onClick:function(){window.open("https://www.syngentadigital.com/us-en#support","_blank","noopener")},children:"Contact Support"})})},ei=function(){var e=[],t=[],n=function(){t.forEach((function(t){return t(e)}))},a=function(t){var a=t.title,r=t.type,c=void 0===r?"info":r,i=t.content,o=void 0===i?"":i,s=t.timeout,l=void 0===s?5e3:s,d=t.supportButton,u=void 0!==d&&d,b=t.actionButton,j=void 0===b?void 0:b,p=t.actionButtonLabel,f=void 0===p?null:p;if(!function(t){var n=t.title,a=t.type;return e.some((function(e){return e.title===n&&e.type===a}))}({title:a,type:c})){var m=Date.now();return e=[].concat(Object(v.a)(e),[{id:m,title:a,type:c,content:o,timeout:l,supportButton:u,actionButton:j,actionButtonLabel:f}]),n(),m}};return{subscribe:function(e){return t.push(e),function(){t=t.filter((function(t){return t!==e}))}},addToast:a,removeToast:function(t){e=e.filter((function(e){return e.id!==t})),n()},success:function(e,t){return a(Object(I.a)(Object(I.a)({title:e},t),{},{type:"success"}))},error:function(e,t){return a(Object(I.a)(Object(I.a)({title:e},t),{},{type:"error"}))},warn:function(e,t){return a(Object(I.a)(Object(I.a)({title:e},t),{},{type:"warning"}))},info:function(e,t){return a(Object(I.a)(Object(I.a)({title:e},t),{},{type:"info"}))}}}(),ti=function(e){var t=e.label,n=e.action;return Object(y.jsx)("div",{"data-testid":"toast-action-button",className:"flex flex-col mt-2",children:Object(y.jsx)(Xc.Button,{style:{alignSelf:"end"},type:Xc.ButtonType.primary,onClick:n,children:t})})},ni=function(){return{success:ei.success,error:ei.error,warn:ei.warn,info:ei.info}},ai=function(){var e=Object(a.useState)([]),t=Object(b.a)(e,2),n=t[0],r=t[1];Object(a.useEffect)((function(){var e=ei.subscribe(r);return function(){return e()}}),[]);var c=function(e){ei.removeToast(e)};return Object(y.jsx)(y.Fragment,{children:n.map((function(e){var t=e.id,n=e.title,a=e.type,r=e.content,i=e.supportButton,o=e.timeout,s=e.actionButton,l=e.actionButtonLabel;return Object(y.jsx)(Qc,{open:!0,isBold:!0,type:a,title:n,timeout:o,onClose:function(){return c(t)},children:r||i||s?Object(y.jsxs)("div",{className:"whitespace-pre-line",children:[r,i&&Object(y.jsx)($c,{}),s&&Object(y.jsx)(ti,{action:function(){c(t),s()},label:null!==l&&void 0!==l?l:"View"})]}):null},t)}))})},ri=function(e,t){return null!==e&&void 0!==e&&e.length?e.slice().sort((function(e,n){return e[t].toLowerCase().localeCompare(n[t].toLowerCase())})):[]},ci=function(){var e=Object(a.useState)(),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(),d=Object(b.a)(l,2),j=d[0],p=d[1],f=Object(a.useState)(!1),m=Object(b.a)(f,2),v=m[0],O=m[1],h=Object(a.useContext)(ac),x=Object(b.a)(h,2),g=x[0].organizations,C=x[1],y=function(e,t){var n=e.name.toUpperCase(),a=t.name.toUpperCase();return n<a?-1:n>a?1:0},P=Object(a.useCallback)((function(e){return s(!1),qt.find({filters:[{field:"name",value:function(t){return!e||t.toLowerCase().includes(e.toLowerCase())},type:"matches"}]},{serverSearchModel:it,containerName:"results"}).promise.then((function(e){var t=e.data,n=(null===t||void 0===t?void 0:t.filter((function(e){var t;return!(200!==(null===(t=e.properties)||void 0===t?void 0:t.status))})))||[];n.sort(y),r(n),C({type:"SET_ORGANIZATIONS",payload:n}),s(!0)})).catch(Ae.default).catch((function(){uc(C),s(!0)}))}),[C]);return{organizations:g,getDefaultOrg:Object(a.useCallback)((function(e,t){return O(!1),J.a.get("".concat(u.d,"/v1/base/organizations"),{params:{pageNo:e,size:t},headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(Ve())}}).then((function(e){var t=e.data;if(t.results.length){var n=t.results.map((function(e){return{id:e.id,name:e.name,properties:e.properties}}));p(ri(n,"name"))}else p(null)})).catch(Ae.default).catch(uc(C)).finally((function(){return O(!0)}))}),[]),loadedDefaultOrg:v,defaultOrg:j,loaded:o,findOrganization:P,filteredOrganizations:n||g}},ii=n.p+"static/media/spinner_modal.eabb2737.svg",oi=function(e){var t=e.open,n=e.message,a=e.opaque;return Object(y.jsx)(Xc.Modal,{centered:!0,className:a?"opacity-75\t":"",closable:!1,"data-testid":"spinner-modal",footer:null,maskClosable:!1,open:t,children:Object(y.jsxs)("div",{className:"py-8 flex flex-col justify-center items-center",children:[Object(y.jsx)("img",{src:ii,alt:"spinner",className:"animate-spin m-auto mb-40px"}),Object(y.jsx)("div",{className:"font-semibold",children:n})]})})};oi.defaultProps={open:!1,message:"Loading",opaque:!1};var si=oi,li=function(e){var t,n=e.route,a=e.shouldRenderInRoutes,r=e.isLoading,c=/\/app\/organizations\//.test(t=n)?n.split("/").slice(0,3).join("/"):t;return a.includes(c)&&Object(y.jsx)(si,{open:r,message:"Loading Organization"})},di=n(47),ui=n(40),bi=function(){return{createChatWidget:function(){if(!document.getElementById("ze-snippet")){var e=document.createElement("script");e.src="https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",e.id="ze-snippet",document.getElementById("cwf-body").appendChild(e)}},destroyChatWidget:function(){var e=document.getElementById("ze-snippet");e&&e.remove()},openChatWidget:function(){window.zE&&window.zE("messenger","open")},getUnreadChatMessages:function(e){window.zE&&window.zE("messenger:on","unreadMessages",e)}}},ji=function(){var e=We(),t=e.user,n=e.logout,r=bi().destroyChatWidget,c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(y.jsx)("button",{type:"button",className:"flex items-center justify-center w-10 h-10 bg-gray-400 rounded-full cursor-pointer hover:opacity-75","data-testid":"profile-trigger",onClick:function(){return s(!0)},children:Object(y.jsx)(ui.a,{icon:di.w,size:"lg",className:"text-white"})});return Object(y.jsx)(m.Popup,{trigger:l,position:"bottom",align:"right",open:o,children:Object(y.jsxs)("div",{"data-testid":"profile-popup",className:"-m-2 text-left ",style:{minWidth:"170px"},children:[Object(y.jsxs)("div",{className:"px-3 py-3 border-b border-gray-300",children:[Object(y.jsx)("div",{className:"text-lg font-light text-gray-800",children:t&&"".concat(t.email)}),Object(y.jsx)("div",{className:"text-xs leading-none text-gray-600",children:t&&t.name})]}),Object(y.jsxs)("ul",{className:"font-normal text-gray-700 ",children:[Object(y.jsx)("li",{className:"cursor-pointer hover:bg-gray-200 hover:bg-text-800",children:Object(y.jsx)("h2",{className:"block py-2 pl-2 cursor-not-allowed",children:"Profile"})}),Object(y.jsx)("li",{className:"cursor-pointer hover:bg-gray-200 hover:bg-text-800",children:Object(y.jsx)("button",{onClick:function(){r(),n()},"data-testid":"logout-btn",type:"button",className:"w-full py-2 pl-2 text-left focus:outline-none",children:"Logout"})})]})]})})},pi=function(e){return window.open(e,"_blank")},fi=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,1)[0],n=Object(a.useContext)(ac),r=Object(b.a)(n,1)[0].organization,c=Object(f.useFlags)(),i=c.releaseFeSubmitFeedbackByOrgs,o=c.releaseFeSubmitFeedback,s=Object(y.jsx)("div",{className:"relative",children:Object(y.jsx)("button",{"data-testid":"help-button",type:"button",className:"flex justify-center items-center p-2 text-gray-100 rounded-full bg-gray-400 hover:bg-gray-500 hover:text-gray-200 focus:outline-none focus:shadow-outline focus:text-gray-500",children:Object(y.jsx)("svg",{fill:"currentColor",viewBox:"0 0 9 14",className:"w-4 h-4",children:Object(y.jsx)("path",{d:"M2.94512 11.0506V14H5.81707V11.0506H2.94512ZM0 4.73051H2.68902C2.68902 4.38577 2.72561 4.06657 2.79878 3.77291C2.87195 3.46648 2.98171 3.20474 3.12805 2.98769C3.28659 2.75786 3.48171 2.57911 3.71341 2.45144C3.95732 2.31099 4.2439 2.24077 4.57317 2.24077C5.06098 2.24077 5.43902 2.38121 5.70732 2.66211C5.9878 2.943 6.12805 3.37711 6.12805 3.96443C6.14024 4.30917 6.07927 4.59644 5.94512 4.82626C5.82317 5.05609 5.65854 5.26676 5.45122 5.45828C5.2439 5.6498 5.01829 5.84131 4.77439 6.03283C4.53049 6.22435 4.29878 6.45417 4.07927 6.7223C3.85976 6.97766 3.66463 7.29047 3.4939 7.66074C3.33537 8.03101 3.2378 8.49065 3.20122 9.03967V9.9015H5.67073V9.17373C5.71951 8.7907 5.83537 8.4715 6.01829 8.21614C6.21341 7.96078 6.43293 7.73735 6.67683 7.54583C6.92073 7.34154 7.17683 7.14364 7.44512 6.95212C7.72561 6.74783 7.97561 6.50524 8.19512 6.22435C8.42683 5.94346 8.61585 5.60511 8.76219 5.2093C8.92073 4.8135 9 4.30917 9 3.69631C9 3.32604 8.92073 2.93023 8.76219 2.50889C8.61585 2.07478 8.36585 1.67259 8.01219 1.30232C7.65854 0.932056 7.18902 0.625627 6.60366 0.383037C6.03049 0.127679 5.31098 0 4.44512 0C3.77439 0 3.16463 0.121295 2.61585 0.363885C2.07927 0.593707 1.61585 0.919289 1.22561 1.34063C0.847561 1.76197 0.54878 2.25992 0.329268 2.83447C0.121951 3.40903 0.0121951 4.04104 0 4.73051Z"})})})});return Object(y.jsx)(m.Popup,{trigger:s,position:"bottom",align:"right",open:t,children:Object(y.jsx)("div",{"data-testid":"help-popup",className:"text-left -mx-2 whitespace-no-wrap",children:Object(y.jsxs)(m.List,{children:[Object(y.jsx)(m.List.Item,{id:"support",selectable:!0,selectAction:function(){return pi("https://www.syngentadigital.com/us")},children:"Support"}),Object(y.jsx)(m.List.Item,{id:"training",selectable:!0,selectAction:function(){return pi("https://agconnections.zendesk.com/hc/en-us")},children:"Help Center"}),Object(y.jsx)(m.List.Item,{id:"productRequest",selectable:!0,selectAction:function(){return pi("https://www.syngentadigital.com/us/product-request-form")},children:Object(y.jsx)("span",{children:"Product Request"})}),Object(y.jsx)(m.List.Item,{id:"eula",selectable:!0,selectAction:function(){return pi("https://login.landdb.com/eula")},children:"EULA"}),yc(o,i,r.id)&&Object(y.jsx)(m.List.Item,{id:"chat",selectable:!0,children:Object(y.jsx)("p",{className:"relative",children:"Submit Feedback"})})]})})})},mi=function(e){var t=e.size,n=void 0===t?20:t,a=e.color,r=void 0===a?"#C17E19":a;return Object(y.jsx)("svg",{width:1.1*n,height:n,viewBox:"0 0 22 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"exclamation-triangle",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 19.5L11 0.5L0 19.5H22ZM10 16.5V14.5H12V16.5H10ZM10 12.5H12V8.5H10V12.5Z",fill:r})})};mi.defaultProps={color:"#C17E19",size:20};var vi=Object(a.memo)(mi),Oi=function(){return Object(y.jsx)("svg",{width:"22",height:"20",viewBox:"0 0 22 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"exclamation-triangle-outline",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 19.5L11 0.5L22 19.5H0ZM18.5297 17.4983L10.9997 4.48828L3.46973 17.4983H18.5297ZM10 14.5V16.5H12V14.5H10ZM10 8.5H12V12.5H10V8.5Z",fill:"#E99921"})})},hi=function(e){var t=e.open,n=e.handleClose,a=e.message;return Object(y.jsx)(m.SimpleModal,{onCancel:n,close:n,open:t,type:"buttonless",children:Object(y.jsxs)("div",{className:"pr-12 grid grid-cols-12",children:[Object(y.jsx)("div",{className:"col-span-1",children:Object(y.jsx)("div",{className:"mt-2 mr-4",children:Object(y.jsx)(Oi,{})})}),Object(y.jsxs)("div",{className:"col-span-11",children:[Object(y.jsx)("h2",{className:"text-lg mb-4 mt-2",children:Object(y.jsx)("b",{children:"Upcoming Maintenance"})}),Object(y.jsxs)("span",{className:"text-base",children:["Cropwise Financials will be offline for planned maintenance from"," ",Object(y.jsx)("b",{children:a})," The tool will be inaccessible during this time frame and we apologize for any inconvenience this may cause."]}),Object(y.jsx)(m.Button,{style:{marginLeft:"auto",backgroundColor:"#14803C",color:"white",padding:"20px 15px"},onClick:n,children:"OK"})]})]})})};hi.defaultProps={open:!1,handleClose:function(){}};var xi=hi,gi=function(e){var t=e.message,n=Object(a.useState)(!1),r=Object(b.a)(n,2),c=r[0],i=r[1];return Object(y.jsxs)("div",{className:"w-82 flex p-1 mr-2 rounded border border-golden bg-cream",children:[Object(y.jsx)(xi,{open:c,handleClose:function(){i(!1)},message:t}),Object(y.jsx)("div",{className:"my-auto mx-1",children:Object(y.jsx)(vi,{})}),Object(y.jsx)("b",{className:"my-auto mr-2",children:"Upcoming Maintenance"}),Object(y.jsx)(m.Button,{onClick:function(){i(!0)},style:{border:"1px solid #C2C7D0",borderRadius:"4px",padding:"2px 8px"},children:"Learn More"})]})},Ci=function(){return Object(y.jsx)("div",{className:"mr-6 flex flex-wrap",children:Object(y.jsx)("div",{id:"cwf-breadcrumb-portal",className:"flex items-center"})})},yi=function(){var e=Object(f.useFlags)().feLandManagementUpcomingMaintenanceMessaging;return Object(y.jsx)("div",{className:"flex flex-shrink-0 px-4 bg-white border-b border-neutral-20",children:Object(y.jsxs)("div",{className:"flex justify-between w-full py-3px ml-0 flex-shrink-1",children:[Object(y.jsx)("div",{className:"flex w-5/6",children:Object(y.jsx)(Ci,{})}),Object(y.jsxs)("div",{className:"flex items-center ml-4 md:ml-6",children:[""!==e&&Object(y.jsx)(gi,{message:e}),Object(y.jsx)(fi,{}),Object(y.jsx)("div",{className:"ml-3 ",children:Object(y.jsx)(ji,{})})]})]})})},Pi=["property-landing","reports","crop-zone-matcher","products","storage-locations","sale-locations","loads","yieldV2/create","yieldV2/commodity-summary"],Ai=["".concat(Cc.yieldV2,"/storage-locations"),"".concat(Cc.yieldV2,"/sale-locations"),"".concat(Cc.yieldV2,"/loads"),"".concat(Cc.yieldV2,"/commodity-summary")],Si=["/app/welcome"],Ti=function(e){var t=e.routes,n=e.children,r=Object(a.useContext)(ac),c=Object(b.a)(r,2),i=c[0],o=i.organization,s=i.isFullScreenNeeded,l=i.loadingOrg,d=c[1],u=We().user,j=ni(),O=ci(),h=O.getDefaultOrg,x=O.loadedDefaultOrg,g=O.defaultOrg,C=Oc(),P=C.setOrganization,A=C.organizationPermissionError,S=C.getOrgByIdV1,T=C.loadedOrgByIdV1,N=C.orgByIdV1,E=Object(a.useState)(!1),w=Object(b.a)(E,2),_=w[0],R=w[1],I=Object(p.h)(),D=Object(p.i)(),k=Object(f.useFlags)().releaseFe50Orgs,L=!u,F=x||T,M=Object(a.useRef)(new Set),V=Object(a.useRef)(""),B=function(){I.replace(Cc.welcome),R(!0),M.current=new Set,V.current=""};return Object(a.useEffect)((function(){if(k){var e=localStorage.getItem("selectedOrganizationId");e?S(e):h(0,1)}else h(0,50)}),[]),Object(a.useEffect)((function(){var e=A;if(!k&&e&&(j.error("Unable to load organization data",{supportButton:!0,content:"An error prevented us from loading your list of organization's. Please try again."}),B()),k&&e){if(M.current.size<=1)return j.error("Unable to load organization data",{supportButton:!0,content:"An error prevented us from loading your list of organization's. Please try again."}),void B();var t=Yc(M.current);if(V.current===t)return j.error("Unable to load organization data",{supportButton:!0,content:"An error prevented us from loading any of your organization's. Please try logging in again."}),void B();j.error("Unable to load organization data",{supportButton:!0,content:"An error prevented us from loading your organization ".concat(o.name,". Please try again.")}),V.current=t,S(t)}}),[A]),Object(a.useEffect)((function(){var e;F&&(L&&D.pathname!==Cc.welcome?B():N||g?Zc(u,(e=N,g||(e?[e]:[])),d,R):B())}),[F]),Object(a.useEffect)((function(){var e=D.pathname.split("/"),t=Pi.some((function(t){return t.includes("/")?D.pathname.includes(t):e.includes(t)}));d({type:Lr,payload:t})}),[D.pathname,d]),Object(a.useEffect)((function(){"9a1a1673-6926-41fa-9d71-a5aad6f67cb6"!==o.id&&(M.current.add(o.id),P(o))}),[o]),Object(y.jsxs)("div",{className:"flex h-screen bg-[#F8F9FA]",children:[Object(y.jsx)(Nc,{routes:t}),Object(y.jsx)("div",{className:"flex flex-col flex-1 w-0",children:_?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(yi,{}),Object(y.jsx)("main",{className:"relative overflow-auto flex flex-1 focus:outline-none bg-app-background",style:{height:"calc(100% - 64px)"},children:Object(y.jsxs)("div",{className:"w-full flex flex-col flex-1 ".concat(!s&&"p-4"," mx-auto"),children:[Object(y.jsx)(zc,{children:n}),k&&Object(y.jsx)(li,{route:D.pathname,shouldRenderInRoutes:[].concat(Object(v.a)(Object.values(Cc)),Ai).filter((function(e){return!Si.includes(e)})),isLoading:l})]})})]}):Object(y.jsx)(m.Spinner,{})})]})};Ti.defaultProps={children:null};var Ni=Ti,Ei=function(e){var t=e.resourceName,n=e.btnText,a=e.btnLink;return Object(y.jsxs)("div",{className:"flex flex-col items-center justify-center h-64 bg-white rounded shadow-md radius",children:[Object(y.jsx)("div",{className:"text-xs text-gray-500",children:"Error code: 404"}),Object(y.jsx)("div",{className:"px-4 text-xl leading-6 text-center text-gray-800",children:t?"".concat(t," not found"):"Page not found"}),Object(y.jsx)("div",{className:"px-4 mt-2 mb-10 text-base leading-5 text-center text-gray-700",children:"We couldn't find what you're looking for."}),Object(y.jsx)("div",{className:"flex justify-center w-full",children:Object(y.jsx)("div",{className:"mx-4",children:Object(y.jsx)(j.b,{to:a||"/app",children:Object(y.jsx)(m.Button,{children:n||"View Dashboard"})})})})]})};Ei.defaultProps={btnLink:null,btnText:null,resourceName:null};var wi=Ei,_i=function(e){var t=Object(a.useRef)();Object(a.useEffect)((function(){if(Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).JEST_WORKER_ID)return function(){};var n=document.getElementById(e),a=t.current;return n.appendChild(a),function(){a.remove()}}),[e]);return t.current||(t.current=document.createElement("div")),t.current},Ri=function(){return Object(y.jsxs)("svg",{width:"43",height:"40",viewBox:"0 0 43 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("path",{d:"M42.0206 20C42.0206 30.7434 32.799 39.5 21.3636 39.5C9.92814 39.5 0.706543 30.7434 0.706543 20C0.706543 9.25657 9.92814 0.5 21.3636 0.5C32.799 0.5 42.0206 9.25657 42.0206 20Z",fill:"#F5F8FC",stroke:"#E8EAED"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.3456 7.72476L33.3552 17.2147C33.8556 17.6142 33.8556 18.2136 33.5554 18.6132C33.2551 19.1126 32.5546 19.1126 32.1542 18.813L20.7451 9.82253L9.33595 18.813C8.93563 19.1126 8.23507 19.0128 7.93483 18.6132C7.63459 18.2136 7.73467 17.5143 8.13499 17.2147L20.1446 7.72476C20.4448 7.42508 20.9453 7.42508 21.3456 7.72476ZM28.7515 19.5122C28.7515 18.9129 29.1518 18.5133 29.7523 18.5133C30.3528 18.5133 30.7531 18.9129 30.7531 19.5122V30.0011C30.7531 30.6004 30.3528 31 29.7523 31H11.7379C11.1374 31 10.7371 30.6004 10.7371 30.0011V19.5122C10.7371 18.9129 11.1374 18.5133 11.7379 18.5133C12.3383 18.5133 12.7387 18.9129 12.7387 19.5122V29.0021H19.7443V24.0074C17.1422 23.9076 14.8403 22.8087 14.7403 20.0117V18.4134V17.5144H15.9412C16.054 17.5144 16.1677 17.5139 16.282 17.5135C17.8917 17.5073 19.6237 17.5006 20.7451 18.7131C21.946 17.3146 23.8476 17.4145 25.5489 17.5144H26.7499V18.4134V20.0117C26.6498 22.7088 24.348 23.9076 21.7459 24.0074V29.0021H28.7515V19.5122ZM16.7419 19.5122C16.7419 21.61 17.9428 22.0096 19.7443 22.0096V20.5112C19.2814 19.4947 18.1335 19.504 17.251 19.5111C17.1795 19.5117 17.1097 19.5122 17.0421 19.5122H16.7419ZM24.7483 19.5122H24.448C24.3718 19.5122 24.2944 19.5116 24.2163 19.5111C23.2684 19.504 22.2082 19.496 21.7459 20.5112V22.0096C23.5473 22.0096 24.7483 21.61 24.7483 19.5122Z",fill:"#8CC3A3"})]})},Ii=n(2799),Di=n.p+"static/media/chevron_down.5c57ddad.svg",ki=function(e){var t=e.title,n=e.value,a=e.isLast,r=e.to,c=e.onClick,i=e.onKeyDown,o=e.disabled,s=Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"".concat(o?"text-neutral-50":"text-gray-600"," text-sm"),children:t}),Object(y.jsx)("div",{className:"".concat(o?"text-neutral-50":"text-gray-900"," font-medium text-lg max-w-xs truncate"),children:n})]}),l=Object(ne.lowerCase)(n),d=l?l.replace(/\s+/g,"-"):"";return Object(y.jsxs)("div",{className:"px-3 flex items-center rounded py-1 ".concat(r||!o?"hover:bg-gray-300":"bg-neutral-100"),children:[Object(y.jsx)("div",{id:d,"data-testid":d,className:"flex flex-col ".concat(a?"":"mr-6"),children:r?Object(y.jsx)(j.c,{to:r,children:s}):c&&!o?Object(y.jsxs)("div",{"data-testid":"breadcrumb-item",role:"button",tabIndex:0,onClick:c,onKeyDown:i,children:[Object(y.jsx)("div",{className:"text-gray-600 text-sm",children:t}),Object(y.jsx)("div",{className:"text-gray-900 font-medium text-lg max-w-xs truncate",children:n})]}):s}),a?null:Object(y.jsx)("div",{className:"text-gray-600",children:Object(y.jsx)("img",{src:Di,alt:"expand collapse accordion"})})]})};ki.defaultProps={title:null,value:null,isLast:!1,to:null,onClick:function(){},onKeyDown:function(){},disabled:!1};var Li=ki,Fi=n.p+"static/media/search.7c350dfd.svg",Mi=function(e){var t=e.name,n=e.onSelect,a=e.isActive;return Object(y.jsx)("li",{"data-testid":"breadcrumb-dropdown-item",className:"hover:bg-gray-200 cursor-pointer hover:bg-text-800 pb-1 pl-2 pt-1 ".concat(a?"bg-info-light-blue":""),children:Object(y.jsxs)("div",{className:"flex justify-start p-1",role:"button",tabIndex:0,onClick:n,onKeyDown:function(e){return"Enter"===e.nativeEvent.key&&n()},children:[Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"24",viewBox:"0 0 25 24",fill:"none",className:"flex-shrink-0",children:Object(y.jsx)("path",{d:"M8.8273 15.8769L4.6573 11.7069L3.2373 13.1169L8.8273 18.7069L20.8273 6.70687L19.4173 5.29688L8.8273 15.8769Z",fill:a?"#0071CD":"bg-text-800"})}),Object(y.jsx)("div",{className:"leading-5 ml-2 text-sm font-normal truncate text-neutral-1000",children:t})]})})};Mi.defaultProps={isActive:!1};var Vi=Mi,Bi=function(e){var t=e.dropDownFooter,n=e.dropDownItemProps,r=e.getData,c=e.organizations,i=e.isLast,o=e.onSelect,s=e.searchPlaceholder,l=e.title,d=e.value,u=e.loadedOrgs,j=Object(a.useContext)(we),p=j.sendEventToAmplitude,v=j.events,O=Object(a.useContext)(ac),h=Object(b.a)(O,1)[0].isSidebarOpen,x=Object(a.useState)(!1),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)([]),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(!1),w=Object(b.a)(E,2),_=w[0],R=w[1],I=Object(a.useState)(null),D=Object(b.a)(I,2),k=D[0],L=D[1],F=Object(f.useFlags)().releaseFe50Orgs;Object(a.useEffect)((function(){C&&r(0,F?1e3:50)}),[C]),Object(a.useEffect)((function(){!function(e,t,n,a,r,c){r(!1),e&&t&&n&&(c(n.filter((function(e){return!a||e.name.toLowerCase().includes(a.toLowerCase())}))),r(!0))}(C,u,c,k,R,N)}),[C,u,c,k]),Object(a.useEffect)((function(){C&&null!==c&&void 0!==c&&c.length&&p(v.epic.Organization.orgLoadingCount,{orgsLoading:c.length})}),[c,C]);var M=function(){P(!1),L(null)},V=function(e){o(e),M()},B=Object(y.jsx)("div",{"data-testid":"nav-menu-head",className:"flex items-center flex-shrink-0 focus:border-none text-white",role:"button",tabIndex:0,onClick:function(){P(!C),L(null)},onKeyDown:function(e){return"Enter"===e.nativeEvent.key&&P(!C)&&L(null)},children:Object(y.jsx)("div",{children:Object(y.jsx)(Li,{title:l,value:d,isLast:i})})});return Object(y.jsx)(m.Popup,{trigger:B,position:"bottom",align:"left",hasOffset:!0,open:C,onClose:M,footer:t&&[Object(y.jsx)("div",{className:"w-full text-left bg-white rounded-b px-1 pt-2 pb-1 border-t border-neutral-200",children:t({onClick:function(){M()}})},Object(cc.generate)())],children:Object(y.jsxs)("div",{"data-testid":"breadcrumb-popup",className:"h-490px w-max text-left mt-2",children:[Object(y.jsx)("span",{className:"text-sm font-semibold",children:"Organizations"}),Object(y.jsx)("div",{className:"relative w-full text-gray-400 focus-within:text-gray-600 mr-4 my-2",children:Object(y.jsx)(Xc.Input,{"data-testid":"search-input",style:{marginTop:"8px"},suffix:Object(y.jsx)("img",{alt:"Search icon",src:Fi}),allowClear:!0,type:"default",autoComplete:"off",placeholder:s,onChange:function(e){L(e.target.value)},value:k})}),Object(y.jsx)("ul",{className:"font-normal text-gray-700 h-420px overflow-y-scroll -mx-2 border-t min-w-430px w-max",style:{maxWidth:"calc(100vw - ".concat(h?"400px":"200px",")")},children:_?T.map((function(e){return Object(y.jsx)(Vi,{onSelect:function(){return V(e)},name:n.name(e),isActive:n.isActive(e)},Object(cc.generate)())})):Object(y.jsx)("li",{className:"w-full min-w-430px h-full flex flex-col items-center justify-center",children:Object(y.jsxs)("div",{style:{marginTop:"-60px"},children:[Object(y.jsx)(m.Spinner,{size:"lg"}),Object(y.jsx)("span",{className:"font-semibold text-xs",children:"Loading your list of organizations"})]})})})]})})};Bi.defaultProps={dropDownFooter:void 0,searchPlaceholder:"Search",isLast:!1};var Ui=Bi,zi=function(e,t){var n=Object(a.useState)(e),r=Object(b.a)(n,2),c=r[0],i=r[1];return Object(a.useEffect)((function(){var n=setTimeout((function(){i(e)}),t);return function(){clearTimeout(n)}}),[e,t]),c},Zi=n(12),Yi=["componentName","GrowUIFormControl","name","id"],Hi=["target"],Gi=["control","name","id"],Wi=function(e){return Object(ne.kebabCase)(e)},qi={Checkbox:m.Checkbox,DatePicker:m.DatePicker,Input:m.Input,NumberInput:m.NumberInput,Search:m.Search,Select:m.Select,TextArea:m.TextArea,RadioButtonGroup:m.RadioButtonGroup,RadioButton:m.RadioButtonGroup.RadioButton,ColorSelect:m.ColorSelect},Ji=function(e){var t=e.componentName,n=e.GrowUIFormControl,a=e.name,r=e.id,c=Object(te.a)(e,Yi),i=Object(Zi.f)(a),o=Object(b.a)(i,3),s=o[0],l=s.value,d=s.onBlur,u=s.onChange,j=o[1],p=j.error,f=j.touched,m=o[2],v=m.setValue,O=m.setTouched,h=Object(Zi.h)(),x=h.setFieldValue,g=h.setFieldTouched,C=h.submitCount,P=h.values,A=null;c.imask&&(A={onBlur:function(e){O(!0),v(e.target.value)},onChange:function(){}});var S={onBlur:function(e){O(!0),v(e.target.value)}},T={onBlur:void 0,onChange:function(e,t){var n;if(null!==(n=e.target.value)&&void 0!==n&&n.includes(JSON.stringify(P[a]))||g(a,!0),!t&&e){var r=e.target.value.length?JSON.parse(e.target.value):{};x(a,r.key),c.onSelect&&c.onSelect(r)}else u({target:{value:t}}),x(a,t),c.onSelect&&c.onSelect(t)}},N={onBlur:void 0,onChange:function(e){var t;null!==e&&void 0!==e&&null!==(t=e.target)&&void 0!==t&&t.value||v(null)},selectedValue:l,onSelect:function(e){g(a,!0),x(a,e.key)}},E={dates:Array.isArray(l)?l:[l],onChange:function(e){var t=e.target,n=Object(te.a)(e,Hi);u({target:{value:c.isRangePicker?t.value:t.value[0],name:n.name}})}},w={onChange:function(e){v(e)}},_=Object(I.a)(Object(I.a)(Object(I.a)(Object(I.a)(Object(I.a)(Object(I.a)(Object(I.a)(Object(I.a)(Object(I.a)(Object(I.a)({id:r||Wi(a),name:a,value:l},(f||C)&&p?{error:!0}:{error:!1}),(f||C)&&{errorMessage:p}),{},{onBlur:d,onChange:u},"Input"===t?A:{}),"NumberInput"===t?A:{}),"Select"===t||"ColorSelect"===t?T:{}),"Search"===t?N:{}),"DatePicker"===t?E:{}),"RadioButtonGroup"===t?w:{}),"TextArea"===t?S:{}),c);return Object(y.jsx)(n,Object(I.a)({},_))};Ji.defaultProps={id:null};var Ki=function(e){var t=e.control,n=e.name,a=e.id,r=Object(te.a)(e,Gi),c=Object.entries(qi).find((function(e){return Object(b.a)(e,2)[1]===t}))||[null,null],i=Object(b.a)(c,1)[0];if(!i)throw new Error("GrowUIFormField requires a GrowUI Form Control. [Checkbox, DatePicker, Input, Search, Select, TextArea, RadioButton or RadioButtonGroup ]");return Object(y.jsx)(Ji,Object(I.a)({GrowUIFormControl:t,componentName:i,name:n,id:a},r))};Ki.defaultProps={id:null};var Qi=Ki,Xi=function(e){var t=e.open,n=e.onClose,r=e.onSuccess,c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(null),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useContext)(ac),f=Object(b.a)(p,2)[1],v=function(){var e=Object(Y.a)(G.a.mark((function e(t){var a,c,i,o,l;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new Date(t.date[0]).getTime(),c=new Date(t.date[1]).getTime(),i={name:t.name,startDateEpoch:a,endDateEpoch:c},s(!0),o=$t.create(i),l=o.promise,e.next=7,l.then((function(e){var t=e.data;r(t),s(!1),mc(f,[t.id]),n()})).catch(Ae.default).catch((function(e){var t,n,a,r;(s(!1),null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.displayErrorMessage)?"ESEA017"===(null===(a=e.response)||void 0===a||null===(r=a.data)||void 0===r?void 0:r.code)?j("Field Name : Crop Zone Name already exists in a Crop Season within the selected dates. Please remove selection in order to save this Crop Season."):j(e.response.data.displayErrorMessage):uc(f)(e)}));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(y.jsx)(Zi.e,{initialValues:{name:"",date:null},onSubmit:function(e){v(e)},children:function(e){var a=e.values,r=e.handleSubmit;return Object(y.jsxs)(m.SimpleModal,{open:t,close:n,confirmLabel:"Save",isSaving:o,onConfirm:function(){return r(a)},children:[u&&Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){return j("")},children:u}),Object(y.jsx)("h1",{className:"text-xl font-bold",children:"Create New Crop Season"}),Object(y.jsx)("div",{className:"mt-10 py-2",children:Object(y.jsxs)("div",{className:"grid mb-4 mr-12",children:[Object(y.jsx)(m.Form.Field,{className:"my-2 mb-6",children:Object(y.jsx)(Qi,{control:m.Input,label:"Crop Season Name *",name:"name"})}),Object(y.jsx)("div",{children:"\xa0"}),Object(y.jsx)(m.Form.Field,{className:"my-2",children:Object(y.jsx)(Qi,{label:"Target Dates *",control:m.DatePicker,name:"date",isRangePicker:!0,"data-testid":"cropSeasonDates"})})]})})]})}})};Xi.defaultProps={onSuccess:function(){}};var $i=Xi,eo=function(e){var t=e.getData,n=e.isLast,r=e.onSelect,c=e.searchPlaceholder,i=e.title,o=e.disabled,s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useContext)(ac),p=Object(b.a)(j,2),O=p[0],h=O.organization,x=O.cropSeasons,g=p[1],C=Object(a.useState)({active:[],upcoming:[],past:[]}),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(!1),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)(),R=Object(b.a)(_,2),I=R[0],D=R[1],k=Object(a.useState)(),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Object(a.useState)("New Crop Season"),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=Object(a.useState)(null),H=Object(b.a)(Z,2),W=H[0],q=H[1],J=zi(W,300),K=Object(a.useState)(!1),Q=Object(b.a)(K,2),X=Q[0],$=Q[1],ee=Object(f.useFlags)(),te=ee.releaseFeCondensedCropSeasons,ae=ee.releaseFeCondensedCropSeasonsByOrg;Object(a.useEffect)((function(){if(d){var e,n=t(),a=(new Date).getTime(),r={active:[],upcoming:[],past:[]};n.filter((function(e){return!J||e.name.toLowerCase().includes(J.toLowerCase())})).forEach((function(e){a>e.startDateEpoch?a>e.endDateEpoch?r.past.push(e):r.active.push(e):r.upcoming.push(e)}));var c=Object(ne.cloneDeep)(r.past),i=Object(ne.orderBy)(c,[function(e){return e.name.toLowerCase()}],"asc");r.past=i;var o=JSON.parse(localStorage.getItem("selectedCropSeasons"))||[];S(r),w(!0);var s=x.filter((function(e){return o.includes(e.id)&&e.active})).map((function(e){return e.id})),l=s.length?null:"88888888-8888-8888-8888-888888888888";D((null===(e=x.find((function(e){return o.includes(e.id)&&!e.active})))||void 0===e?void 0:e.id)||l),M(s)}}),[J,d,x,t]),Object(a.useEffect)((function(){var e=JSON.parse(localStorage.getItem("selectedCropSeasons"))||[],t=e.length&&"88888888-8888-8888-8888-888888888888"!==e[0]?null===x||void 0===x?void 0:x.filter((function(t){return e.includes(t.id)})).reduce((function(e,t){return e+(e.length?" | ":"")+t.name}),""):"New Crop Season";z(t)}),[x]);var re=function(){u(!1),q(null)},ce=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=yc(te,ae,null===h||void 0===h?void 0:h.id),e.next=3,mc(g,t.id,n);case 3:r(t.id);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ie=Object(y.jsx)("div",{"data-testid":"nav-menu-head",className:"flex items-center  flex-shrink-0 focus:border-none text-white\n    ".concat(o?"pointer-events-none":""),role:"button",tabIndex:0,onClick:function(){o||(u((function(e){return!e})),q(null))},onKeyDown:function(e){o||"Enter"===e.nativeEvent.key&&(u((function(e){return!e})),q(null))},disabled:o,children:Object(y.jsx)(Li,{title:i,value:U,isLast:n,disabled:o})});return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(m.Popup,{trigger:ie,position:"bottom",align:"left",hasOffset:!0,open:d,onClose:re,footer:[Object(y.jsx)("div",{className:"w-full text-left rounded-b bg-white py-2 px-4 border-t border-neutral-200",children:Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsx)(m.Button,{ghost:!0,"data-testid":"add-crop-season-button",onClick:function(e){e.stopPropagation(),re(),$(!0)},children:"+ New Season"}),Object(y.jsxs)("div",{className:"flex justify-end",children:[Object(y.jsx)("div",{className:"mr-2",children:Object(y.jsx)(m.Button,{ghost:!0,"data-testid":"cancel-button",onClick:function(e){e.stopPropagation(),re()},children:"Cancel"})}),Object(y.jsx)(m.Button,{ghost:!0,type:"primary","data-testid":"apply-button",onClick:function(e){e.stopPropagation(),g({type:Sr}),function(){var e=null!==F&&void 0!==F&&F.length?F:[I];e[0]&&r(e),re()}()},children:"Apply"})]})]})},Object(cc.generate)())],children:Object(y.jsxs)("div",{"data-testid":"breadcrumb-popup",className:"w-92 h-382px overflow-auto text-left",children:[Object(y.jsxs)("div",{className:"relative w-full text-gray-400 focus-within:text-gray-600 mr-4 mb-2",children:[Object(y.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pointer-events-none",children:Object(y.jsx)("div",{className:"mr-1.5 h-5 w-5 pl-2 text-gray-400",children:Object(y.jsx)(ui.a,{icon:di.m,size:"1x"})})}),Object(y.jsx)("input",{className:"border block w-full h-full pl-8 pr-3 py-2 rounded-md text-gray-600 placeholder-gray-500 focus:outline-none focus:placeholder-gray-400 sm:text-sm",autoComplete:"off",type:"text",name:"search_breadcrumb",placeholder:c,onChange:function(e){q(e.target.value)}})]}),E&&!o?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"font-medium mb-2 ml-2",children:"Crop Seasons"}),Object(y.jsx)("ul",{className:"mb-2 ml-2",children:Object(y.jsx)(m.Radio,{label:"View Unassigned Fields",value:"88888888-8888-8888-8888-888888888888",checked:"88888888-8888-8888-8888-888888888888"===I,onChange:function(e){F&&M([]),D(e.target.value)}})}),Object(y.jsx)("div",{className:"font-normal text-sm mb-2 ml-2 text-neutral-600",children:"Active Seasons"}),Object(y.jsx)("ul",{className:"mb-2  ml-2",children:0===A.active.length?Object(y.jsx)("div",{className:"font-normal text-sm ml-4",children:"No Active Seasons"}):A.active.map((function(e){return Object(y.jsx)(m.Checkbox,{label:e.name,value:e.id,checked:null===F||void 0===F?void 0:F.includes(e.id),onChange:function(e){I&&D(null),e.target.checked?M([].concat(Object(v.a)(F),[e.target.value])):F&&M(F.filter((function(t){return t!==e.target.value})))}},e.id)}))}),Object(y.jsx)("div",{className:"font-normal text-sm ml-2 mb-2 text-neutral-600",children:"Upcoming Seasons"}),Object(y.jsx)("ul",{className:"mb-2 ml-2",children:0===A.upcoming.length?Object(y.jsx)("div",{className:"font-normal text-sm ml-4",children:"No Upcoming Seasons"}):A.upcoming.map((function(e){return Object(y.jsx)(m.Radio,{label:e.name,value:e.id,checked:I===e.id,onChange:function(e){F&&M([]),D(e.target.value)}},e.id)}))}),Object(y.jsx)("div",{className:"font-normal text-sm ml-2 mb-2 text-neutral-600",children:"Past Seasons"}),Object(y.jsx)("ul",{className:"mb-2 ml-2",children:0===A.past.length?Object(y.jsx)("div",{className:"font-normal text-sm ml-4",children:"No Past Seasons"}):A.past.map((function(e){return Object(y.jsx)(m.Radio,{label:e.name,value:e.id,checked:I===e.id,onChange:function(e){F&&M([]),D(e.target.value)}},e.id)}))})]}):Object(y.jsx)(m.Spinner,{})]})}),Object(y.jsx)($i,{open:X,onClose:function(){return $(!1)},onSuccess:ce})]})};eo.defaultProps={searchPlaceholder:"Search",isLast:!1,disabled:!1};var to=eo,no=document.getElementById("cwf-modal-root"),ao=function(e){return Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).JEST_WORKER_ID?Object(y.jsx)(m.SimpleModal,Object(I.a)({},e)):i.a.createPortal(Object(y.jsx)(m.SimpleModal,Object(I.a)({},e)),no)},ro=function(e){var t=e.error,n=e.consoleMessage,r=e.toastMessage,c=Object(a.useContext)(ac),i=Object(b.a)(c,2)[1];return Object(a.useEffect)((function(){t&&r&&bc(i)(r)}),[i,t,r]),Object(y.jsx)("div",{className:"flex flex-col align-center justify-center mx-4",role:"alert",children:Object(y.jsx)("div",{title:n||t||"",className:"gr-text-red-600 text-sm whitespace-no-wrap truncate ".concat(t?"visible":"invisible"),children:n||t||"&nbsp;"})})};ro.defaultProps={error:!1,consoleMessage:null,toastMessage:null};var co=ro,io=function(e){var t=e.open,n=e.handleCancel,r=Object(a.useState)(),c=Object(b.a)(r,1)[0],i=Object(a.useState)(!1),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useContext)(ac),u=Object(b.a)(d,2)[1],j=We().fetchUserProfile,f=Object(p.h)(),v=We().user,O=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:l(!0),Jt.updateRequestInterceptor({},(function(){return""})),n=Jt.create(t),n.promise.then((function(e){var t=e.data;return j(),t})).then((function(e){localStorage.setItem("selectedCropSeasons",JSON.stringify([])),vc(u,{name:e.name,id:e.id},v),f.go("".concat(Cc.organizations,"/").concat(e.id))})).catch(Ae.default).catch((function(e){l(!1),uc(u)(e)}));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(y.jsx)("div",{"data-testid":"create-organiaztion-modal",children:Object(y.jsx)(Zi.e,{initialValues:{name:"",languageCountry:"en-US",timeZone:"GMT",areaUnit:"acres"},validate:function(e){var t={};return(!e.name.length>0||/^\s+$/.test(e.name))&&(t.name="Required"),t},onSubmit:O,children:function(e){var a=e.errors,r=e.handleSubmit;return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(ao,{cancelLabel:"Cancel",onConfirm:r,confirmLabel:"Save",open:t,close:n,title:"Create new organization",isSaving:s,children:Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"pr-6 mt-12",children:Object(y.jsx)(Qi,{autoFocus:!0,control:m.Input,label:"Name",name:"name",errors:a.name})}),Object(y.jsx)("div",{className:"flex justify-end pb-4 mr-5",children:Object(y.jsx)(co,{error:c,consoleMessage:c})})]})})})}})})};io.defaultProps={open:!1};var oo=io,so=function(e){var t,n,r=e.children,c=e.hideOrganizationDropdown,o=e.hideCropSeasonDropdown,s=e.onOrganizationSelect,l=e.onCropSeasonSelect,d=e.disabled,u=e.disabledCropSeasons,j=Object(a.useState)(null),p=Object(b.a)(j,2),m=p[0],v=p[1],O=_i("cwf-breadcrumb-portal"),h=Object(a.useState)(!1),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useContext)(we).updateIdentify,A=Object(a.useContext)(ac),S=Object(b.a)(A,2),T=S[0],N=T.organization,E=T.organizations,w=T.cropSeasons,_=S[1],R=ci(),I=R.getDefaultOrg,D=R.loadedDefaultOrg,k=R.defaultOrg,L=Object(f.useFlags)(),F=L.releaseFeCondensedCropSeasons,M=L.releaseFeCondensedCropSeasonsByOrg,V=yc(F,M,null===N||void 0===N?void 0:N.id),B={name:function(e){return e.name},isActive:function(e){return N&&N.id===e.id}},U=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,mc(_,null,V);case 2:case"end":return e.stop()}}),e)}))),[_,V]),z=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(localStorage.setItem("selectedCropSeasons",JSON.stringify([])),jc(_,lr,t),o){e.next=5;break}return e.next=5,U();case 5:s(t),_({type:Sr}),P(null===t||void 0===t?void 0:t.name,null===t||void 0===t?void 0:t.id);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Z=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,mc(_,t,V);case 2:l();case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();Object(a.useEffect)((function(){o||U()}),[o]),Object(a.useEffect)((function(){v(N)}),[N]),Object(a.useEffect)((function(){k&&jc(_,jr,k)}),[k]);var H=Object(y.jsx)(y.Fragment,{children:Object(y.jsx)("div",{className:"flex w-full",children:r})});return Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).JEST_WORKER_ID?H:i.a.createPortal(Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(oo,{open:g,handleCancel:function(){return C(!1)}}),Object(y.jsxs)("div",{className:"flex w-full mr-6 gap-2",children:[c?null:Object(y.jsxs)("div",{id:"breadcrumb-organization","data-testid":"breadcrumb-organization",className:"flex items-center",children:[Object(y.jsx)("div",{className:"mr-2",children:Object(y.jsx)(Ri,{})}),d?Object(y.jsx)("div",{"data-testid":"nav-menu-head",className:"flex items-center flex-shrink-0 focus:border-none text-white",children:Object(y.jsx)("div",{children:Object(y.jsx)(Li,{title:"Organization",value:null!==(n=null===m||void 0===m?void 0:m.name)&&void 0!==n?n:"New Organization",isLast:!r,disabled:!0})})}):Object(y.jsx)(Ui,{dropDownItemProps:B,getData:I,organizations:E,onSelect:z,searchPlaceholder:"Search Organizations",title:"Organization",value:null!==(t=null===m||void 0===m?void 0:m.name)&&void 0!==t?t:"New Organization",disabled:!0,dropDownFooter:function(e){return Object(y.jsx)("button",{"data-testid":"add-organization-button",type:"button",onClick:function(t){t.stopPropagation(),C(!0),e.onClick(t)},children:Object(y.jsx)("div",{className:"text-cucumber-green-700  text-sm font-normal hover:text-cucumber-green-500",children:Object(y.jsxs)("div",{className:"w-auto flex flex-row items-center",children:[Object(y.jsx)(Ii.a,{style:{width:"30%"}}),Object(y.jsx)("p",{style:{whiteSpace:"nowrap"},children:"Create Organization"})]})})})},isLast:!r,loadedOrgs:D})]}),o?null:Object(y.jsx)("div",{id:"breadcrumb-cropseason","data-testid":"breadcrumb-cropseason",className:"flex items-center",children:Object(y.jsx)(to,{getData:function(){return w},onSelect:Z,searchPlaceholder:"Search Crop Seasons",title:"Crop Season",disabled:u})}),null!==r&&void 0!==r?r:H]})]}),O)};so.Item=Li,so.DropDown=Ui,so.defaultProps={children:null,hideOrganizationDropdown:!1,hideCropSeasonDropdown:!0,onOrganizationSelect:function(){},onCropSeasonSelect:function(){},disabled:!1,disabledCropSeasons:!1};var lo=so,uo=function(e){var t=e.redirect,n=Object(a.useState)(!0),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useContext)(ac),s=Object(b.a)(o,1)[0],l=s.loadingOrg,d=s.loggedInUserOrgPermission;Object(a.useEffect)((function(){i(l||void 0===(null===d||void 0===d?void 0:d.email))}),[l,d]);return Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"people",children:[Object(y.jsx)(lo,{onOrganizationSelect:function(){window.location.reload()}}),c?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(y.Fragment,{children:t?Object(y.jsx)(p.b,{push:!0,to:{pathname:t}}):Object(y.jsxs)("div",{className:"flex flex-col items-center justify-center h-64 bg-white rounded shadow-md radius","data-testid":"forbidden-testid",children:[Object(y.jsx)("div",{className:"text-xs text-gray-500",children:"Error code: 403"}),Object(y.jsx)("div",{className:"px-4 text-xl leading-6 text-center text-gray-800",children:"Forbidden"}),Object(y.jsx)("div",{className:"px-4 mt-2 mb-10 text-base leading-5 text-center text-gray-700",children:"You are not authorized to view this page"})]})})]})};uo.defaultProps={redirect:""};var bo=uo,jo=["component","minPermissions"],po=function(e){var t=e.routes,n=Object(f.useFlags)(),r=n.feIntegrationsModuleEnableJohnDeer,c=n.feIntegrationsModuleEnableMcCain,i=n.feIntegrationsModuleEnableMcCainPerOrg,o=n.feReportsModuleEnableModule,s=n.feYieldModuleEnableModule,l=n.beJohnDeereEnabledForAll,d=n.beJohnDeereEnabledPerOrg,u=n.beProductPriceListEnabled,j=n.beProductPriceListEnableByOrgId,m=n.feYieldV2ModuleEnableModule,v=n.beYieldEnableByOrgId,O=Object(a.useContext)(ac),h=Object(b.a)(O,1)[0],x=h.loadingOrg,g=h.loggedInUserOrgPermission,C=h.organization,P=We().user,A=Object(a.useState)(!1),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(t),w=Object(b.a)(E,2),_=w[0],R=w[1];return Object(a.useEffect)((function(){var e=new Map([["mcCain",c||(null===i||void 0===i?void 0:i.includes(null===C||void 0===C?void 0:C.id))],["reports",o],["yield",s],["yieldV2",yc(m,v,null===C||void 0===C?void 0:C.id)],["products",u||(null===j||void 0===j?void 0:j.includes(null===C||void 0===C?void 0:C.id))]]),n=t.filter((function(t){var n=t.key;return!e.has(n)||e.get(n)})).map((function(e){var t=e.component,n=e.minPermissions,a=Object(te.a)(e,jo);return Object(I.a)(Object(I.a)({},a),{},{component:or(g,n)?t:bo})}));R(n)}),[t,g,x,r,c,i,o,s,l,d,u,j,C,m,v]),Object(a.useEffect)((function(){var e=function(){};if(window.addEventListener("cwf-expired",e,!1),P)try{var t=localStorage.getItem("selectedOrganizationId");window.pendo.initialize({visitor:{id:P.id,language:"en_US"},account:{id:t}}),N(!0)}catch(n){console.log(n)}return function(){window.removeEventListener("cwf-expired",e)}}),[P]),Object(y.jsx)(y.Fragment,{children:T?Object(y.jsx)(Ni,{routes:t,children:Object(y.jsxs)(p.e,{children:[_.map((function(e){var t=e.key,n=e.component,a=e.path,r=e.exact,c=e.redirect;return Object(y.jsx)(p.c,{path:a,exact:r,children:n?Object(y.jsx)(n,{redirect:c}):null},t)})),Object(y.jsx)(p.c,{path:"*",render:wi},"404")]})}):null})};function fo(){var e=window;return{width:e.innerWidth,height:e.innerHeight}}function mo(){var e=Object(a.useState)(fo()),t=Object(b.a)(e,2),n=t[0],r=t[1];return Object(a.useEffect)((function(){function e(){r(fo())}return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),n}var vo=function(e){var t=e.onFilterChange,n=e.filterItems,a=e.filterPlaceholder,r=e.selectedItems;return Object(y.jsx)("div",{"data-testid":"cropseasonselect",children:Object(y.jsx)("div",{className:"w-68 mr-4",children:n?Object(y.jsx)(m.Select,{multiple:!0,value:r,items:n,placeholder:a,onChange:t}):Object(y.jsx)(m.Select,{value:r,multiple:!0,items:n,placeholder:a,onChange:t})})})};vo.defaultProps={onFilterChange:function(){},filterItems:null,filterPlaceholder:"Filters",selectedItems:""};var Oo=vo,ho=function(e){return(e&&e.target||{}).value},xo=function(e){var t=ho(e)||"{}",n=JSON.parse(t);return n?n.key:null},go=function(e,t){return function(n){return e(n,t(n))}},Co=function(e){var t=e.taskTypes,n=e.onChangeTaskType,a=go(n,xo);return Object(y.jsx)("div",{"data-testid":"tasktypeselect",children:Object(y.jsx)("div",{className:"relative w-32 text-gray-400 focus-within:text-gray-600 mr-4",children:Object(y.jsx)(m.Select,{placeholder:"Task Type",items:t,onChange:a})})})};Co.defaultProps={onChangeTaskType:function(){}};var yo=Co,Po=function(e){var t=e.onDateRangeChange;return Object(y.jsx)("div",{"data-testid":"daterangepicker",children:Object(y.jsx)("div",{className:"relative w-64 text-gray-400 focus-within:text-gray-600 mr-4",children:Object(y.jsx)(m.DatePicker,{onChange:t,isRangePicker:!0})})})};Po.defaultProps={onDateRangeChange:function(){}};var Ao=Po,So=function(e){var t=e.searchValue,n=e.onChange,a=e.onFilterChange,r=e.onChangeTaskType,c=e.onChangeProductType,i=e.placeholder,o=e.id,s=e.filterPlaceholder,l=e.filterItems,d=e.selectedItems,u=e.selectedProductTypes,b=e.name,j=e.showSearch,p=e.showDateRange,f=e.showCropSeason,m=e.showTaskType,v=e.showProductType,O=e.onDateRangeChange,h=mo().width,x=[{key:"productTypes",value:"Product Types",nestedItems:[{key:"cropProtection",value:"Crop Protection"},{key:"fertilizer",value:"Fertilizer"},{key:"seed",value:"Seed"},{key:"service",value:"Service"}]}];return Object(y.jsxs)("div",{className:"flex items-center justify-between flex-1 md:ml-0",children:[j?Object(y.jsxs)("div",{children:[Object(y.jsx)("label",{htmlFor:o,className:"sr-only",children:"Search"}),Object(y.jsx)(Xc.Input,{value:null!==t&&void 0!==t?t:void 0,"data-testid":"search-input",style:{margin:0},prefix:Object(y.jsx)("img",{alt:"Search icon",src:Fi}),allowClear:!0,type:"default",id:o,name:b,placeholder:h<=386?"Search...":i,onChange:n})]}):"",Object(y.jsxs)("div",{className:"flex items-center",children:[p?Object(y.jsx)(Ao,{onDateRangeChange:O}):null,f?Object(y.jsx)(Oo,{onFilterChange:a,filterItems:l,filterPlaceholder:s,selectedItems:d}):null,m?Object(y.jsx)(yo,{taskTypes:[{key:"none",value:"none"},{key:"planting",value:"Planting"},{key:"workOrder",value:"Work Order"}],onChangeTaskType:r}):null,v?Object(y.jsx)(Oo,{filterItems:x,onFilterChange:c,selectedItems:u}):null]})]})};So.defaultProps={searchValue:null,placeholder:"Search...",id:"search",filterPlaceholder:"Filters",filterItems:null,selectedItems:[],selectedProductTypes:[],name:"search",showDateRange:!0,showCropSeason:!0,showSearch:!0,showTaskType:!1,showProductType:!1,onFilterChange:function(){},onChangeTaskType:function(){},onChangeProductType:function(){},onDateRangeChange:function(){}};var To=So,No=n(94),Eo=n.n(No),wo=50,_o=function(e,t,n,a,r,c,i,o){var s={sorts:e.map((function(e){return Object(et.a)({},e,t)})),filters:[]};return a&&s.filters.push(Object(et.a)({},n,a)),r&&"none"!==r&&s.filters.push({"cropSeason.cropSeasonLabel":r}),o&&"none"!==o&&s.filters.push({flag:o}),i&&"none"!==i&&s.filters.push({taskType:i}),c&&"none"!==c&&s.filters.push({productType:c}),s},Ro=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,c=Object(a.useState)("comfortable"),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)("asc"),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(!1),f=Object(b.a)(p,2),m=f[0],v=f[1],O=Object(a.useState)(null),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)(null),y=Object(b.a)(C,2),P=y[0],A=y[1],S=Object(a.useState)(null),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)(null),_=Object(b.a)(w,2),R=_[0],I=_[1],D=Object(a.useState)(null),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)(!1),V=Object(b.a)(M,2),B=V[0],U=V[1],z=Object(a.useContext)(ac),Z=Object(b.a)(z,2),H=Z[1],W=Object(a.useState)([]),q=Object(b.a)(W,2),J=q[0],K=q[1],Q=Object(a.useState)(!1),X=Object(b.a)(Q,2),$=X[0],ee=X[1],te=Object(a.useState)(0),ne=Object(b.a)(te,2),ae=ne[0],re=ne[1],ce=Object(a.useRef)(zn(e,{urlVersion:"/v1/base"})),ie=Object(a.useRef)(t),oe=zi(x,300);return Object(a.useEffect)((function(){var e=function(){var e=Object(Y.a)(G.a.mark((function e(a,c){var i,o,s,l,d;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(ce.current){e.next=2;break}return e.abrupt("return",!0);case 2:return i=_o(ie.current,a,n,c,P,N,R,L),o={pageNo:r,size:wo},e.next=6,ce.current.find(i,ot,o);case 6:return s=e.sent,l=s.promise,d=s.cancel,l.then((function(e){var n=e.data;if(n&&re(n.totalElements),"company.name"===t[0]&&(null===x||void 0===x?void 0:x.length)>0){var a=[];n.results.forEach((function(e){e.name.includes(x)&&a.push(e)})),K(a)}else K(n.results)})).catch(Ae.default).catch(uc(H,{showTryAgain:!0})).finally((function(){c&&v(!0),U(!0)})),e.abrupt("return",(function(){d()}));case 11:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();U(!1),ee(!1),oe?e(u,oe):e(u)}),[oe,u,e,n,P,N,R,L,H,$]),{view:o,setView:s,sort:u,setSort:j,isSearch:m,setSearchText:g,setCropSeason:A,setLabel:F,setTaskType:I,productType:N,setProductType:E,loaded:B,items:J,setItems:K,setReload:ee,totalItems:ae}},Io=n(2841),Do="update_internal",ko="update_external",Lo=function(e,t){return e===t},Fo={internalChanges:void 0,externalChanges:void 0,value:void 0,comparator:Lo},Mo=function(e,t,n){var a=Object(ne.isFunction)(t)?t(e):t;return n(e,a)?e:a},Vo=function(e,t){var n=t.type,a=t.payload;if(n===Do){var r=Mo(e.value,a,e.comparator);return{comparator:e.comparator,externalChanges:void 0,internalChanges:r,value:r}}if(n===ko){var c=Mo(e.value,a,e.comparator);return{comparator:e.comparator,internalChanges:void 0,externalChanges:c,value:c}}return e},Bo=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,t=arguments.length>1?arguments[1]:void 0,n=Object(I.a)(Object(I.a)({},Fo),{},{value:e,comparator:t||Lo}),r=Object(a.useReducer)(Vo,n,(function(){return n})),c=Object(b.a)(r,2),i=c[0],o=i.value,s=i.internalChanges,l=i.externalChanges,d=c[1],u=Object(a.useCallback)((function(e){d({type:Do,payload:e})}),[]),j=Object(a.useCallback)((function(e){d({type:ko,payload:e})}),[]);return[o,u,j,s,l]},Uo=function(e){var t=e.id,n=e.name,r=e.onChange,c=e.defaultChecked,i=e.color,o=e.big,s=Bo(c),l=Object(b.a)(s,3),d=l[0],u=l[1],j=l[2];Object(a.useEffect)((function(){j(c)}),[c,j]);var p=i.includes("#")&&d?{backgroundColor:i}:{};return Object(y.jsx)("div",{"data-testid":"toggle-button",children:Object(y.jsx)("div",{className:"flex",children:Object(y.jsx)("label",{htmlFor:n,className:"flex cursor-pointer",children:Object(y.jsxs)("div",{className:"relative",children:[Object(y.jsx)("input",{"data-testid":"toggle-button-input",name:n,id:t,type:"checkbox",className:"hidden",onChange:function(e){u(e.target.checked),r(e)},checked:d}),Object(y.jsx)("div",{style:Object(I.a)({height:o?"24px":"16px"},p),className:"".concat(o?"w-12":"w-8"," bg-gray-400 rounded-full shadow-inner relative ").concat(d?"bg-".concat(i):"bg-gray-400"),children:Object(y.jsx)("div",{style:{height:o?"21px":"14px",width:o?"21px":"14px",left:d?o?"25px":"16px":"0px",margin:"1px"},className:"absolute ".concat(o?"w-8 h-8":"w-4 h-4"," ")+"bg-white rounded-full shadow inset-y-0 transition-all duration-300"})})]})})})})};Uo.defaultProps={defaultChecked:!1,id:"toggle-".concat(Object(cc.generate)()),name:"toggle-".concat(Object(cc.generate)()),onChange:void 0,color:"cucumber-green-500",big:!1};var zo=Uo,Zo={paginationTableStyles:{border:0,color:"#696F88",padding:"0px"},paginationButtonStyles:{border:"1px solid",borderRadius:"4px",padding:"1px"}},Yo=function(){return Object(y.jsx)("span",{})},Ho=function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:wo,c=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]?arguments[6]:void 0,o=a,s=e>r;return Object(y.jsxs)("table",{className:"w-full ".concat(i&&"flex flex-row justify-between items-center"),children:[i&&Object(y.jsx)("div",{className:"float-left",children:Object(y.jsx)("thead",{children:Object(y.jsxs)("tr",{className:"flex flex-row items-center",children:[Object(y.jsx)(zo,{color:"#0071CD",name:"View planting data",big:!0,defaultChecked:c,onChange:function(e){return i(e.currentTarget.checked)}},"enabled"),Object(y.jsx)("span",{className:"inline-block pl-2 -mt-2px text-sm",children:"View planting data"})]})})}),Object(y.jsx)("div",{className:"float-right",children:Object(y.jsx)("thead",{children:Object(y.jsxs)("tr",{children:[o?Object(y.jsx)("th",{className:"font-normal",children:Object(y.jsx)(o,{})}):null,Object(y.jsx)("th",{children:Object(y.jsx)(Io.a,{count:e,rowsPerPageOptions:[],rowsPerPage:r,page:t,style:Zo.paginationTableStyles,backIconButtonProps:{style:Object(I.a)(Object(I.a)({},Zo.paginationButtonStyles),{},{marginRight:"8px"})},nextIconButtonProps:{style:Object(I.a)({},Zo.paginationButtonStyles)},onPageChange:function(e,t){n(t)},ActionsComponent:s?void 0:Yo})})]})})})]})},Go=[{field:"name",title:"Company Name",sortable:!0},{field:"city",title:"City",sortable:!0},{field:"state",title:"State",sortable:!0},{field:"",title:"",sortable:!1}];var Wo=function(e){var t=e.onAction,n=e.options,r=Object(a.useState)([]),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useContext)(ac),l=Object(b.a)(s,1)[0].loggedInUserOrgPermission,d=l.role,u=l.financialAccess;return Object(a.useEffect)((function(){var e=n.filter((function(e){var t=e.minAllowedRole,n=e.minFinancialAccess;return or({role:d,financialAccess:u},{minAllowedRole:t,minFinancialAccess:n})}));o(e)}),[n,d,u]),Object(y.jsx)(y.Fragment,{children:i.length>0&&Object(y.jsx)(m.ContextMenu,{onSelect:t,children:i.map((function(e){var t=e.value,n=e.className,a=e.text,r=e.label;return Object(y.jsx)(m.ContextMenu.Option,{value:t,label:r,children:Object(y.jsx)("span",{className:n,children:a})},t)}))})})},qo=function(e,t){return[].concat(Object(v.a)(e),[t])},Jo=function(e,t){return e.filter((function(e){return e.value!==t}))},Ko=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return{value:"view",text:"View",label:t,minAllowedRole:e}},Qo=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{value:"edit",text:"Edit",minAllowedRole:e}},Xo=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{value:"exportPdfEnglish",text:"Export PDF (English)",minAllowedRole:e}},$o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{value:"shareOrPrint",text:"Share or Print",minAllowedRole:e}},es=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{value:"tag",text:"Tag",minAllowedRole:e}},ts=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{value:"duplicate",text:"Duplicate",minAllowedRole:e}},ns=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{value:"convertTask",text:"Create Task",minAllowedRole:e}},as=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{value:"convertToRec",text:"Convert to Recommendation",minAllowedRole:e}},rs=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=e.charAt(0).toUpperCase()+e.slice(1);return{value:e,text:n,className:"text-red-500",minAllowedRole:t}},cs=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{value:"createTask",text:"Create Task From Invoice",minAllowedRole:e}},is=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{value:"editBoundary",text:"Edit Boundary",minAllowedRole:e}},os=[Ko(er),Qo($a),rs("delete",$a)],ss=[Qo($a),rs("delete",$a)],ls=[Ko(er),Qo($a),es($a),ts($a),ns($a),as($a),$o(er),rs("delete",$a)],ds=[Qo(),rs("remove")],us=[Ko(er),Qo($a),es($a),ts($a),$o(er),ns($a),rs("delete",$a)],bs=[Ko(er),Qo($a),es($a),ts($a),Xo(er),rs("delete",$a)],js=[Ko(er),Qo($a),es($a),ts($a),rs("delete",$a)],ps=[Qo($a),es($a),ts($a),Xo(er),rs("delete",$a)],fs=[Qo($a),es($a),ts($a),Xo(er),rs("delete",$a)],ms=[Ko(er),Qo($a),es($a),ts($a),Xo(er),function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{value:"exportPdfSpanish",text:"Export PDF (Spanish)",minAllowedRole:e}}(er),rs("delete",$a)],vs=[Ko(er),Xo(er),Qo($a),es($a),ts($a),rs("delete",$a)],Os=[Ko(er),Qo($a),es($a),cs($a),$o($a),rs("delete",$a)],hs=[Ko(er),Qo($a),rs("delete",$a)],xs=[Qo($a),rs("delete",$a)],gs=[Ko(er),Qo($a),rs("delete",$a)],Cs=[Qo($a),rs("delete",$a)],ys=[Ko(er),Qo($a),rs("delete",$a)],Ps=[Qo($a),rs("delete",$a)],As=[Qo(),rs("remove",$a)],Ss=(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:""}($a),ts($a),Qo($a),Ko($a),rs("delete",$a),is(),cs(),rs("delete"),function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:""}(),is(),cs(),rs("delete"),Ko($a),rs("delete"),[Qo($a),es($a),ts($a),ns($a),as($a),$o(er),rs("delete",$a)]),Ts=[Qo($a),es($a),$o(er),ns($a),rs("delete",$a)],Ns=[Qo($a),es($a),cs($a),$o($a),rs("delete",$a)],Es=function(e){var t=e.company,n=e.onAction,a=null===t||void 0===t?void 0:t.address,r=function(e){return n(e,t)};return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{onClick:function(){return r("view")},children:Object(y.jsx)("span",{className:"font-bold",children:null!==t&&void 0!==t&&t.name?t.name:t.legalName})}),Object(y.jsx)(m.Table.Cell,{children:null===a||void 0===a?void 0:a.city}),Object(y.jsx)(m.Table.Cell,{children:null===a||void 0===a?void 0:a.state}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{"data-testid":"company-table-options-menu",className:"absolute right-0 flex-none w-10 mr-2",children:Object(y.jsx)(Wo,{onAction:r,options:gs})})})]})};Es.defaultProps={companyAdress:{}};var ws=Es,_s="asc",Rs=function(e){return e?(t=e)?t===_s?"desc":null:_s:_s;var t},Is=function(e,t,n){return e===t?n:null},Ds=function(e){var t=e.sortBy,n=e.sortDir,r=e.simpleSortMode,c=e.onSort,i=e.tableColumns,o=Object(a.useCallback)((function(e){return Is(e,t,n)}),[t,n]),s=function(e){return function(){if(c)if(r)c(e,t!==e||"asc"===n?"desc":"asc");else{var a=Is(e,t,n);c(e,Rs(a))}}};return Object(y.jsx)(m.Table.Header,{children:i.map((function(e){var t=e.field,n=e.title,a=e.width,r=e.sortable,c=e.position;return Object(y.jsx)(m.Table.Cell,{width:a,sortable:r,sort:o(t),onClick:r&&s(t),className:"".concat(r?"":"pointer-events-none"),backGround:"right"===c?"number-content":"",children:n},t||Object(cc.generate)())}))})};Ds.defaultProps={sortBy:null,sortDir:null,onSort:null,simpleSortMode:!1};var ks=Ds,Ls=function(e){var t=e.placeholderWidth,n=e.placeholderHeight;return n||t?Object(y.jsx)("div",{"data-testid":"permissions-placeholder",style:{width:t,height:n},children:"\xa0"}):null};Ls.defaultProps={placeholderWidth:0,placeholderHeight:0};var Fs=function(e,t){var n=t.visibleRoles,a=t.enabledRoles,r=t.placeholderWidth,c=t.placeholderHeight;return function(t){return Object(y.jsx)(ac.Consumer,{children:function(i){var o=Object(b.a)(i,1)[0].permission;if(!o)return Object(y.jsx)(Ls,{placeholderWidth:r,placeholderHeight:c});var s=!n||n.map(ne.toLower).includes(Object(ne.toLower)(o.role)),l=!a||a.map(ne.toLower).includes(Object(ne.toLower)(o.role));return s?Object(y.jsx)(e,Object(I.a)(Object(I.a)({},t),{},{disabled:!l})):Object(y.jsx)(Ls,{placeholderWidth:r,placeholderHeight:c})}})}},Ms=["editRoles"],Vs=function(e){var t=e.image,n=e.placeholderImage,a=e.columnTwo,r=e.columnThree,c=e.subIcon,i=e.isComfortable,o=e.header,s=e.detail,l=e.routeTo,d=e.handleClick,u=e.EditIcon,b=e.EditLink;return Object(y.jsx)("div",{children:Object(y.jsx)(b,{to:l||"",className:"block hover:bg-gray-100 focus:outline-none focus:bg-gray-100 transition duration-150 ease-in-out",onClick:l||d?d:function(e){return e.preventDefault()},children:Object(y.jsxs)("div",{"data-testid":"landing-list-item",className:"flex items-center p-2",children:[Object(y.jsxs)("div",{className:"min-w-0 flex-1 flex items-center",children:[Object(y.jsx)("div",{className:"flex-shrink-0",children:t?Object(y.jsx)("img",{className:"".concat(i?"h-12 w-12":"h-8 w-8"," rounded-full"),src:t,alt:""}):Object(y.jsx)("div",{className:"text-gray-400",children:n})}),Object(y.jsxs)("div",{className:"min-w-0 flex-1 px-2 md:grid md:grid-cols-3 md:gap-4",children:[Object(y.jsxs)("div",{className:s?"":"flex items-center",children:[Object(y.jsx)("div",{className:"leading-5 font-medium ".concat(i?"text-base":"text-sm"," text-gray-800 truncate"),children:o}),s&&Object(y.jsxs)("div",{className:"".concat(i?"text-sm mt-2":"text-xs"," flex items-center leading-5 text-gray-500"),children:[c&&Object(y.jsx)("div",{className:"mr-1 h-5 w-5 text-gray-400",children:c}),Object(y.jsx)("span",{className:"truncate",children:s})]})]}),Object(y.jsx)("div",{className:"flex items-center",children:a}),Object(y.jsx)("div",{className:"flex items-center",children:r})]})]}),Object(y.jsx)("div",{children:Object(y.jsx)("div",{className:"h-5 w-5 text-gray-400",children:Object(y.jsx)(u,{"data-testid":"landing-list-item-edit-icon",icon:di.f,size:"1x"})})})]})})},ic.a.generate())},Bs={image:void 0,placeholderImage:di.x,columnTwo:null,columnThree:null,subIcon:null,isComfortable:!0,header:"",detail:"",routeTo:null,handleClick:null,EditIcon:ui.a,EditLink:j.c};Vs.defaultProps=Bs;var Us=Vs,zs=function(e){var t=e.to,n=e.className,a=e.onClick,r=e.disabled,c=e.children;return r?c:Object(y.jsx)(j.c,{to:t,className:n,onClick:a,children:c})},Zs=function(e){var t=e.editRoles,n=Object(te.a)(e,Ms),a=Fs(ui.a,{visibleRoles:t}),r=Fs(zs,{enabledRoles:t});return Object(y.jsx)(Vs,Object(I.a)(Object(I.a)({},n),{},{EditIcon:a,EditLink:r}))};Zs.defaultProps=Object(I.a)(Object(I.a)({},Bs),{},{editRoles:null});var Ys=n(325),Hs=n.n(Ys),Gs=function(e){var t=e.listType,n=e.isSearch,a=e.routePath,r=e.messageHeader,c=e.message,i=e.buttonText;return n?Object(y.jsxs)("div",{className:"flex flex-col items-center justify-center h-64 bg-white rounded shadow-md radius",children:[Object(y.jsx)("div",{className:"px-4 mb-10 text-xl leading-6 text-center text-gray-800",children:"Sorry, no results were found."}),Object(y.jsx)(j.c,{to:a,children:Object(y.jsx)(m.Button,{icon:Object(y.jsx)(Hs.a,{}),type:"primary",children:"Back to list"})})]}):Object(y.jsxs)("div",{className:"flex flex-col items-center justify-center h-64 bg-white rounded shadow-md radius",children:[Object(y.jsx)("div",{className:"px-4 text-xl leading-6 text-center text-gray-800",children:r||"This organization doesn\u2019t have ".concat(t.toLowerCase()," yet.")}),Object(y.jsx)("div",{className:"px-4 mt-2 mb-10 text-base leading-5 text-center text-gray-700",children:c||"Add some to include them in tasks and reports."}),a&&Object(y.jsx)(j.c,{to:a,children:Object(y.jsx)(m.Button,{icon:Object(y.jsx)(Hs.a,{}),type:"primary",iconRight:!0,children:i||"Start here "})})]})};Gs.defaultProps={listType:"Items",isSearch:!1,routePath:"",messageHeader:null,message:null,buttonText:null};var Ws=Gs,qs=function(e){var t=e.children;return Object(y.jsx)("ul",{"data-testid":"landing-list",children:t.length?r.a.Children.map(t,(function(e,t){return Object(y.jsx)("li",{className:"bg-white border-b border-gray-200 ",children:Object(y.jsx)("div",{id:"landing-list-item-".concat(t),children:e})},ic.a.generate())})):Object(y.jsx)("li",{className:"bg-white shadow overflow-hidden sm:rounded-t-md sm:rounded-b-md",children:t},ic.a.generate())})};qs.LandingListItem=Us,qs.ProtectedLandingListItem=Zs,qs.LandingEmpty=Ws;var Js=qs,Ks=function(e){var t=e.listType,n=e.searchFilterApplied,a=e.routePath,r=e.message,c=e.messageHeader;return e.hasRouting?Object(y.jsx)(Js.LandingEmpty,{listType:t,isSearch:n,routePath:n?a:"".concat(a,"/create"),message:r,messageHeader:c}):Object(y.jsx)(Js.LandingEmpty,{listType:t,isSearch:n,message:r,messageHeader:c})};Ks.defaultProps={hasRouting:!0,listType:null};var Qs={children:null,hasRouting:!0,isLoading:!1,loadingMessage:"",isEmpty:!1,emptyState:null,items:null,tableColumns:Object(y.jsx)(y.Fragment,{}),listType:null,message:"",messageHeader:"",routePath:"",searchFilterApplied:!1,onSort:function(){},sortBy:"",sortDir:"",simpleSortMode:!1,wrapperClassName:""},Xs=function(e){var t=function(t){var n=t.children,a=t.hasRouting,r=t.isLoading,c=t.loadingMessage,i=t.isEmpty,o=t.emptyState,s=t.items,l=t.tableColumns,d=t.listType,u=t.onSort,b=t.sortBy,j=t.sortDir,p=t.simpleSortMode,f=t.message,m=t.messageHeader,v=t.routePath,O=t.searchFilterApplied,h=t.wrapperClassName;return(s?s.length||r:!i)?Object(y.jsx)(e,{items:s,tableColumns:l,onSort:u,sortBy:b,sortDir:j,isLoading:r,simpleSortMode:p,wrapperClassName:h,loadingMessage:c,children:n}):null!==o&&void 0!==o?o:function(e,t,n){var a=n.routePath,r=n.message,c=n.messageHeader,i=n.hasRouting;return Object(y.jsx)(Ks,{searchFilterApplied:t,listType:e,routePath:a,message:r,messageHeader:c,hasRouting:i})}(d,O,{routePath:v,message:f,messageHeader:m,hasRouting:a})};return t.defaultProps=Qs,t},$s=["id","$nestedItems"],el=Object(a.createContext)({items:[],tableColumns:[]}),tl=function(e,t,n,a,r){var c=e.id,i=e.$nestedItems,o={totalVisibleDescendants:0},s=function(e,t){return Object(I.a)(Object(I.a)({},e),{},{$isParent:!0,$numOfChildren:e.$nestedItems.length,$depth:t})}(e,r),l=[];if(t[c]&&t[c].$isOpen){var d=a(i,t,n,{$parentId:c},r+1),u=Object(b.a)(d,2),j=u[0],p=u[1].totalVisibleDescendants;l=j,o.totalVisibleDescendants=p}return t[c]&&(s.$isOpen=t[c].$isOpen),s.$totalVisibleDescendants=o.totalVisibleDescendants,[[s].concat(Object(v.a)(l)),o]},nl=function e(t,n,a){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},c=r.$parentId,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=[],s={totalVisibleDescendants:0};return i<a&&t&&t.length&&t.forEach((function(t){var r=t.id,l=t.$nestedItems,d=Object(te.a)(t,$s);if(l){var u=tl(t,n,a,e,i),j=Object(b.a)(u,2),p=j[0],f=j[1];o=[].concat(Object(v.a)(o),Object(v.a)(p)),s.totalVisibleDescendants+=f.totalVisibleDescendants}else{var m=Object(I.a)(Object(I.a)({},d),{},{id:r,$depth:i});c&&(m.$parentId=c),o.push(m)}s.totalVisibleDescendants+=1})),0===i?o:[o,s]},al=function e(t,n){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=new Map;return t&&t.length&&a<n&&t.forEach((function(t){var c=t.$nestedItems,i=t.id;if(c){var o=[i,{id:i,$nestedItems:c,$isOpen:!1}],s=e(c,n,a+1);r=new Map([].concat(Object(v.a)(r),[o],Object(v.a)(s)))}})),0===a?Object(ne.fromPairs)(Array.from(r)):r},rl=function(e){var t=e.items,n=e.children,r=e.isLoading,c=e.loadingMessage,i=e.maxDepth,o=e.tableColumns,s=e.onSort,l=e.sortBy,d=e.sortDir,u=e.simpleSortMode,j=e.wrapperClassName,p=Object(a.useState)({}),f=Object(b.a)(p,2),v=f[0],O=f[1],h=Object(a.useState)([]),x=Object(b.a)(h,2),g=x[0],C=x[1];Object(a.useEffect)((function(){O(al(t,i))}),[t,i]),Object(a.useEffect)((function(){C(nl(t,v,i))}),[t,v,i]);return Object(y.jsx)("div",{className:"h-full ".concat(j),"data-testid":"landing-table",children:Object(y.jsxs)(el.Provider,{value:{rows:g,toggleRow:function(e){var t=v[e];t&&O(Object(I.a)(Object(I.a)({},v),{},Object(et.a)({},e,Object(I.a)(Object(I.a)({},t),{},{$isOpen:!t.$isOpen}))))}},children:[Object(y.jsxs)(m.Table,{children:[Object(y.jsx)(ks,{tableColumns:o,onSort:s,sortBy:l,sortDir:d,simpleSortMode:u}),Object(y.jsx)(el.Consumer,{children:n})]}),r&&Object(y.jsxs)("div",{className:"w-full h-full flex flex-col items-center justify-center left-0 top-0 absolute",children:[Object(y.jsx)(m.Spinner,{size:"lg"}),Object(y.jsx)("span",{className:"font-semibold text-base",children:c})]})]})})};var cl,il=wc.a.shape({id:wc.a.string.isRequired,$nestedItems:wc.a.arrayOf((cl=function(){return il},function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return cl().apply(this,t)}))});rl.defaultProps={children:null,items:[],isLoading:!1,loadingMessage:"",maxDepth:3,tableColumns:[],onSort:function(){},sortBy:"",sortDir:"",simpleSortMode:!1,wrapperClassName:""};var ol=Xs(rl),sl=function(e){var t=e.className,n=e.children,a="bg-neutral-100"===t?t:"bg-white";return Object(y.jsx)("div",{className:"".concat(t," w-full p-6 mt-4 ").concat(a," border rounded"),children:n})};sl.defaultProps={className:""};var ll=sl,dl=n.p+"static/media/clipboardIcon.5ab6b392.png",ul=function(e){var t=e.open,n=e.onClick,a=e.memberRole;return Object(y.jsx)(y.Fragment,{children:t&&Object(y.jsx)("div",{"data-testid":"property-overlay-modal",className:"p-10 bg-white border rounded-none sm:rounded border-neutral",children:Object(y.jsxs)("div",{className:"flex flex-col justify-center",children:[Object(y.jsx)("div",{className:"self-center",children:Object(y.jsx)("img",{width:"356",height:"318",src:dl,alt:""})}),Object(y.jsx)("div",{className:"self-center mb-3",children:Object(y.jsx)("p",{children:"We were unable to find any companies under this organization."})}),Object(y.jsx)("div",{className:"self-center",children:"View Only"!==a?Object(y.jsx)(m.Button,{icon:Object(y.jsx)(Eo.a,{}),iconLeft:!0,onClick:n,id:"overlay-create-property-btn",type:"primary",children:"Create Company"}):Object(y.jsx)(y.Fragment,{})})]})})})};ul.defaultProps={open:!1,onClick:function(){}};var bl=ul,jl=function(e){var t=e.open,n=e.close,r=e.companyName,c=e.companyId,i=Object(p.h)(),o=Object(a.useState)(!1),s=Object(b.a)(o,2),l=s[0],d=s[1],u=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d(!0),t=Sn.delete(c),n=t.promise,e.next=4,n.then((function(){i.push({pathname:Cc.companies,selectedView:"comfortable"}),window.location.reload(!1)})).catch(Ae.default).catch((function(){i.go({pathname:Cc.companies,selectedView:"comfortable"})}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)(m.SimpleModal,{open:t,title:'Delete "'+r+'"',close:n,cancelLabel:"Cancel",confirmLabel:"Delete",onCancel:function(){n()},type:"error",onConfirm:function(){return u()},isSaving:l,children:Object(y.jsx)("div",{className:"pr-6",children:"You are about to permanently delete this Company. This cannot be undone. Are you sure you want to proceed?"})})};jl.defaultProps={companyName:"",companyId:""};var pl=Object(p.l)(jl),fl=function(e){var t=e.companies,n=e.memberRole,r=e.totalCompanies,c=e.companyPageNumber,i=e.handlePageChange,o=Object(a.useState)(),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(),j=Object(b.a)(u,2),f=j[0],m=j[1],v=Object(a.useState)(t),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(null),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(p.h)(),_=Object(a.useContext)(we),R=function(e){w.push({pathname:"".concat(Cc.companies,"/").concat(e,"/view")})},I=function(e){w.push({pathname:"".concat(Cc.companies,"/").concat(e)})},D=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=n.id,r=n.name,{view:function(){_.sendEventToAmplitude(_.events.epic.Companies.editCompany),R(a)},edit:function(){I(a)},delete:function(){_.sendEventToAmplitude(_.events.epic.Companies.deleteCompany),A(!0),E({id:a,name:r})}}[t]();case 3:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){x(t)}),[t]),Object(y.jsxs)(y.Fragment,{children:[null,t.length?Object(y.jsxs)(ll,{children:[Ho(r,c,i),Object(y.jsx)(pl,{open:P,close:function(){return A(!1)},companyName:null===N||void 0===N?void 0:N.name,companyId:null===N||void 0===N?void 0:N.id}),Object(y.jsx)(ol,{listType:"Companies",routePath:Cc.companies,items:h,tableColumns:Go,onSort:function(e,t){d(e),m(t),x(function(e,t,n){if(!n)return e;var a=e.map((function(e){return Object(ne.cloneDeep)(e)}));switch(t){case"name":return Object(ne.orderBy)(a,[function(e){return e.name}],n);case"city":return Object(ne.orderBy)(a,[function(e){var t;return null===e||void 0===e||null===(t=e.address)||void 0===t?void 0:t.city}],n);case"state":return Object(ne.orderBy)(a,[function(e){var t;return null===e||void 0===e||null===(t=e.address)||void 0===t?void 0:t.state}],n);default:return a}}(h,e,t))},sortBy:l,sortDir:f,children:function(e){return e.rows.map((function(e){return Object(y.jsx)(ws,{onAction:D,company:e},e.id)}))}}),Ho(r,c,i),Object(y.jsx)("div",{className:"mb-12",children:" "})]}):Object(y.jsx)(bl,{open:0===(null===t||void 0===t?void 0:t.length),onClick:function(){return w.push("".concat(Cc.companies,"/company"))},memberRole:n})]})},ml=function(e){var t=e.view,n=e.changeView,a=e.sort,r=e.changeSort;return Object(y.jsx)("div",{"data-testid":"toolbar-container",children:Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)(m.RadioButtonGroup,{selected:t,onChange:function(e){n(e)},children:[Object(y.jsx)(m.RadioButtonGroup.RadioButton,{name:"comfortableView",value:"comfortable",children:Object(y.jsx)(ui.a,{fixedWidth:!0,icon:di.s})}),Object(y.jsx)(m.RadioButtonGroup.RadioButton,{name:"compactView",value:"compact",children:Object(y.jsx)(ui.a,{fixedWidth:!0,size:"sm",icon:di.k})})]}),Object(y.jsx)("div",{className:"flex ml-4",children:Object(y.jsxs)(m.RadioButtonGroup,{selected:a,onChange:function(e){r(e)},children:[Object(y.jsx)(m.RadioButtonGroup.RadioButton,{name:"ascSort",value:"asc",children:Object(y.jsx)(ui.a,{fixedWidth:!0,icon:di.p,size:"lg"})}),Object(y.jsx)(m.RadioButtonGroup.RadioButton,{name:"descSort",value:"desc",children:Object(y.jsx)(ui.a,{fixedWidth:!0,icon:di.o,size:"lg"})})]})})]})})};ml.defaultProps={changeView:function(){},changeSort:function(){}};var vl=ml,Ol=function(e,t){if(t){var n=t.match(/[^ ]+/g),a=[],r=e.filter((function(e){return function(e,t){var n=function(t){var n,a;return"address"in e&&"city"in e.address&&"state"in e.address&&((null===(n=e.address)||void 0===n?void 0:n.city.toLowerCase().includes(t.toLowerCase()))||(null===(a=e.address)||void 0===a?void 0:a.state.toLowerCase().includes(t.toLowerCase())))||e.name.toLowerCase().includes(t.toLowerCase())};return t.length,t.find(n)}(e,n)}));return r&&r.forEach((function(e){a.push(e)})),a}return e},hl=function(){var e=Object(a.useState)(0),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Ro("worker/companies",["company.name","company.legalName"],"company.name",n),i=c.view,o=c.setView,s=c.sort,l=c.setSort,d=c.isSearch,u=c.loaded,j=c.setReload,f=c.items,v=c.totalItems,O=Object(a.useContext)(ac),h=Object(b.a)(O,2),x=h[0],g=x.loggedInUserOrgPermission,C=x.loadingOrg,P=h[1],A=Object(a.useState)(!1),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(!1),w=Object(b.a)(E,2),_=w[0],R=w[1],I=Object(a.useState)([]),D=Object(b.a)(I,2),k=D[0],L=D[1],F=Object(a.useState)(null),M=Object(b.a)(F,2),V=M[0],B=M[1],U=zi(V,300);Object(a.useEffect)((function(){return L(Ol(f,U||null)),P({type:"SET_TOOLBAR",payload:Object(y.jsx)(vl,{view:i,changeView:function(e){return o(e)},sort:s,changeSort:function(e){return l(e)}})}),function(){P({type:"SET_TOOLBAR",payload:null})}}),[i,o,s,l,P,U,f]),Object(a.useEffect)((function(){Object(ne.isEmpty)(g)?N(!1):N(!0)}),[g]);var z=Object(a.useCallback)((function(){return"View Only"!==(null===g||void 0===g?void 0:g.role)}),[null===g||void 0===g?void 0:g.role]);return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"companies",children:[Object(y.jsx)(lo,{onOrganizationSelect:function(){r(0),j(!0)},hideCropSeasonDropdown:!0,children:Object(y.jsx)(lo.Item,{title:"Company",value:"All Companies",isLast:!0})}),_&&Object(y.jsx)(p.b,{push:!0,to:{pathname:"".concat(Cc.companies,"/company")}}),!C&&u&&T?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex justify-between flex-1 mb-3",children:[Object(y.jsx)(To,{name:"search_companies",id:"companies-search-input",selectedItems:[{}],showLabels:!1,showDateRange:!1,showCropSeason:!1,onChange:function(e){B(e.target.value)},placeholder:"Search Companies"}),Object(y.jsx)("div",{className:"h-8",children:z()?Object(y.jsx)(m.Button,{id:"add-company-button","data-testid":"add_company",type:"primary",icon:Object(y.jsx)(Eo.a,{}),onClick:function(e){e.stopPropagation(),R(!0)},children:(null===f||void 0===f?void 0:f.length)<1?"Create Company":"Add Company"}):Object(y.jsx)(y.Fragment,{})})]}),Object(y.jsx)(fl,{view:i,companies:k,isSearch:d,memberRole:null===g||void 0===g?void 0:g.role,totalCompanies:v,companyPageNumber:n,handlePageChange:function(e){r(e),j(!0)}})]}):Object(y.jsx)(m.Spinner,{})]})})},xl=function(e){var t=Object(a.useState)(zn(e,{urlVersion:"/v1/base"}));return Object(b.a)(t,1)[0]},gl=function(e){var t=e.label,n=e.children;return Object(y.jsx)(m.Form.Field,{children:Object(y.jsxs)("div",{className:"flex flex-col sm:flex-row",children:[Object(y.jsx)("div",{className:"w-1/2",children:Object(y.jsx)("div",{className:"block text-sm font-medium leading-5 text-gray-700 sm:mt-px sm:pt-2 mb-2 sm:mb-0",children:t})}),Object(y.jsx)("div",{className:"w-full md:w-1/2",children:n})]})})};gl.defaultProps={label:""};var Cl=function(e){var t=e.children;return Object(y.jsx)(m.Form,{children:Object(y.jsx)("div",{"data-testid":"edit-screen",className:"p-5",children:r.a.Children.map(t,(function(e,n){return Object(y.jsxs)("div",{children:[e,n===t.length-1?null:Object(y.jsx)("div",{className:"border-t border-gray-200"})]})}))})})};Cl.EditScreenField=gl;var yl=Cl,Pl=function(){return Object(y.jsx)(m.Form.Field,{label:"Name *",children:Object(y.jsx)(Qi,{control:m.Input,id:"name",name:"name"})})},Al=function(){return Object(y.jsx)(m.Form.Field,{label:"Phone Number",children:Object(y.jsx)(Qi,{control:m.Input,id:"phone",name:"phone"})})},Sl=function(){return Object(y.jsx)(m.Form.Field,{label:"Email Address",children:Object(y.jsx)(Qi,{control:m.Input,id:"email",name:"email"})})},Tl=function(){return Object(y.jsx)(m.Form.Field,{label:"City",children:Object(y.jsx)(Qi,{control:m.Input,id:"city",name:"address.city"})})},Nl=Object.entries({AL:"Alabama",AK:"Alaska",AS:"American Samoa",AZ:"Arizona",AR:"Arkansas",CA:"California",CO:"Colorado",CT:"Connecticut",DE:"Delaware",DC:"District Of Columbia",FM:"Federated States Of Micronesia",FL:"Florida",GA:"Georgia",GU:"Guam",HI:"Hawaii",ID:"Idaho",IL:"Illinois",IN:"Indiana",IA:"Iowa",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",ME:"Maine",MH:"Marshall Islands",MD:"Maryland",MA:"Massachusetts",MI:"Michigan",MN:"Minnesota",MS:"Mississippi",MO:"Missouri",MT:"Montana",NE:"Nebraska",NV:"Nevada",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NY:"New York",NC:"North Carolina",ND:"North Dakota",MP:"Northern Mariana Islands",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PW:"Palau",PA:"Pennsylvania",PR:"Puerto Rico",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VT:"Vermont",VI:"Virgin Islands",VA:"Virginia",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming"}).map((function(e){var t=Object(b.a)(e,2);return{key:t[0],value:t[1]}})),El=function(){return Object(y.jsx)(m.Form.Field,{label:"State",children:Object(y.jsx)(Qi,{control:m.Select,id:"state",name:"address.state",items:Nl})})},wl=function(){return Object(y.jsx)(m.Form.Field,{label:"Zip Code",children:Object(y.jsx)(Qi,{control:m.Input,id:"zipCode",name:"address.zipCode"})})},_l=function(){return Object(y.jsx)(m.Form.Field,{label:"Address Line 1",children:Object(y.jsx)(Qi,{control:m.Input,id:"line1",name:"address.line1"})})},Rl=function(){return Object(y.jsx)(m.Form.Field,{label:"Address Line 2",children:Object(y.jsx)(Qi,{control:m.Input,id:"line2",name:"address.line2"})})},Il=function(){return Object(y.jsx)(m.Form.Field,{label:"Legal Name",children:Object(y.jsx)(Qi,{control:m.Input,id:"legalName",name:"legalName"})})},Dl=function(){return Object(y.jsx)(m.Form.Field,{children:Object(y.jsx)(Qi,{control:m.TextArea,id:"notes",name:"notes",style:{height:"200px"},editable:!1})})},kl=function(){var e,t,n,r,c,i=Object(a.useState)(""),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(p.j)().id,u=Object(p.h)(),j="company"===d,f=Object(a.useState)({}),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)(!0),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useContext)(ac),S=Object(b.a)(A,2)[1],T=xl("worker"),N=xl("company"),E=Object(a.useContext)(we);Object(a.useEffect)((function(){P(!0),T.fetch(d).promise.then((function(e){var t=e.data;t&&h(t),P(!1)})).catch(Ae.default).catch((function(){P(!1)}))}),[T,d]);var w={id:(null===O||void 0===O?void 0:O.id)||"",name:(null===O||void 0===O?void 0:O.name)||"",legalName:O.legalName||"",notes:(null===O||void 0===O?void 0:O.notes)||"",address:{line1:(null===O||void 0===O||null===(e=O.address)||void 0===e?void 0:e.line1)||"",line2:(null===O||void 0===O||null===(t=O.address)||void 0===t?void 0:t.line2)||"",city:(null===O||void 0===O||null===(n=O.address)||void 0===n?void 0:n.city)||"",state:(null===O||void 0===O||null===(r=O.address)||void 0===r?void 0:r.state)||"",zipCode:(null===O||void 0===O||null===(c=O.address)||void 0===c?void 0:c.zipCode)||""},phone:(null===O||void 0===O?void 0:O.phone)||"",email:(null===O||void 0===O?void 0:O.email)||""},_=function(e){var t={};return e.name&&!/^\s+$/.test(e.name)||(t.name="Required"),t},R=function(e){return N.create(e).promise.then((function(){u.push(Cc.companies)})).catch(Ae.default).catch((function(e){var t,n;null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.displayErrorMessage?l(e.response.data.displayErrorMessage):uc(S)(e)})),function(){S({type:"SET_TOOLBAR",payload:null})}},I=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:j?R(t):(n=t,N.update(n.id,n).promise.then((function(){u.push(Cc.companies)})).catch(Ae.default).catch(uc(S)));case 1:case"end":return e.stop()}var n}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(y.jsxs)("div",{className:"w-full h-full",children:[Object(y.jsxs)(lo,{disabled:!0,children:[Object(y.jsx)(lo.Item,{title:"Company",value:"All Companies",to:Cc.companies}),Object(y.jsx)(lo.Item,{title:"Company",value:j?"Create Company":"Edit Company",isLast:!0})]}),Object(y.jsxs)(y.Fragment,{children:[s&&Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){return l("")},children:s}),C?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(Zi.e,{initialValues:w,validate:_,onSubmit:function(e){E.sendEventToAmplitude(E.events.epic.Companies.createCompany),I(e)},children:function(e){var t=e.handleSubmit;return Object(y.jsxs)("div",{className:"mb-10",children:[Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{className:"w-full flex mr-4",children:Object(y.jsx)("div",{className:"text-3xl my-6",children:j?"Create Company":"Edit Company"})}),Object(y.jsx)("div",{className:"flex",children:Object(y.jsx)("div",{className:"w-1/2 flex mr-4",children:Object(y.jsxs)("div",{className:"flex mx-2",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:function(){return u.push(Cc.companies)},children:"Cancel"}),Object(y.jsx)("div",{className:"ml-2",children:Object(y.jsx)(m.Button,{id:"save-and-quit-button",type:"primary",onClick:t,children:"Save"})})]})})})]}),Object(y.jsx)(ll,{children:Object(y.jsx)(yl,{onSubmit:t,children:Object(y.jsxs)(m.Column,{width:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold mt-10",children:"Basic Info"}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{className:"w-1/2 flex-grow mr-4",children:Object(y.jsx)(Pl,{})}),Object(y.jsx)("div",{className:"w-1/2 flex-grow mr-4",children:Object(y.jsx)(Il,{})})]}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{className:"w-1/2 flex-grow mr-4",children:Object(y.jsx)(Sl,{})}),Object(y.jsx)("div",{className:"w-1/2 flex-grow mr-4",children:Object(y.jsx)(Al,{})})]}),Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold mt-10",children:"Address Info"}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{className:"w-1/2 flex-grow mr-4",children:Object(y.jsx)(_l,{})}),Object(y.jsx)("div",{className:"w-1/2 flex-grow mr-4",children:Object(y.jsx)(Rl,{})})]}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{className:"w-1/2 flex-grow mr-4",children:Object(y.jsx)(Tl,{})}),Object(y.jsx)("div",{className:"w-1/4 flex-grow mr-2",children:Object(y.jsx)(El,{})}),Object(y.jsx)("div",{className:"w-1/4 flex-grow mr-4",children:Object(y.jsx)(wl,{})})]}),Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold mt-10",children:"Notes"}),Object(y.jsx)("div",{className:"flex items-center",children:Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(Dl,{})})})]})})})]})}})})]})]})},Ll=function(e){var t=e.className,n=e.testId,a=e.header,r=e.data,c="";return void 0===e.text&&(c="text-2xl"),Object(y.jsxs)("div",{"data-testid":n,className:t,children:[Object(y.jsx)("div",{className:"text-gray-600",children:a}),Object(y.jsx)("div",{className:c,children:r})]})};Ll.defaultProps={className:"",header:"",data:"",testId:"",text:""};var Fl=Ll,Ml=function(){var e=Object(p.j)().id,t=Object(a.useState)({}),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)(!0),o=Object(b.a)(i,2),s=o[0],l=o[1],d=xl("worker"),u=Object(a.useState)(!1),j=Object(b.a)(u,2),f=j[0],v=j[1],O=function(){v(!1)},h=Object(a.useContext)(ac),x=Object(b.a)(h,1)[0].loggedInUserOrgPermission,g=(null===x||void 0===x?void 0:x.role)!==er?Jo(Cs,"shareOrPrint"):Cs;Object(a.useEffect)((function(){l(!0),d.fetch(e).promise.then((function(e){var t=e.data;t&&c(t),l(!1)})).catch(Ae.default).catch((function(){l(!1)}))}),[d,e]);var C=Object(p.h)();return Object(y.jsxs)("div",{className:"w-full h-full",children:[Object(y.jsxs)(lo,{disabled:!0,children:[Object(y.jsx)(lo.Item,{title:"Company",value:"All Companies",to:Cc.companies}),Object(y.jsx)(lo.Item,{title:"Company",value:null===r||void 0===r?void 0:r.name,isLast:!0})]}),s?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{children:[Object(y.jsx)(pl,{open:f,close:O,companyName:null===r||void 0===r?void 0:r.name,companyId:null===r||void 0===r?void 0:r.id}),Object(y.jsxs)("div",{className:"mb-10",children:[Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{className:"w-full flex mr-4",children:Object(y.jsx)("div",{className:"text-3xl font-med my-6",children:"View Company"})}),Object(y.jsx)("div",{className:"flex",children:Object(y.jsx)("div",{className:"w-1/2 flex mr-4",children:Object(y.jsx)("div",{className:"flex mx-2",children:Object(y.jsx)(Wo,{onAction:function(e){switch(e){case"edit":C.push({pathname:"".concat(Cc.companies,"/").concat(r.id)});break;case"delete":v(!0)}},options:g})})})})]}),Object(y.jsx)(ll,{children:Object(y.jsx)("div",{className:"py-5",children:Object(y.jsxs)("div",{className:"bg-white w-full p-6",children:[Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold ",children:"Basic Info"}),Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsx)(Fl,{data:r.name,header:"Name *",className:"w-1/3",text:"text-lg"}),Object(y.jsx)(Fl,{data:r.legalName,header:"Legal Name",className:"w-1/3",text:"text-lg"})]}),Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsx)(Fl,{data:r.email,header:"Email Address",className:"w-1/3",text:"text-lg"}),Object(y.jsx)(Fl,{data:r.phone,header:"Phone Number",className:"w-1/3",text:"text-lg"})]})]}),Object(y.jsx)("div",{className:"w-full border-b py-5"}),Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold mt-10",children:"Address Info"}),Object(y.jsx)("div",{className:"flex py-5",children:Object(y.jsxs)("div",{children:[Object(y.jsx)(Fl,{data:null===r||void 0===r?void 0:r.address.line1,text:"text-lg"}),Object(y.jsx)(Fl,{data:null===r||void 0===r?void 0:r.address.line2,text:"text-lg"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)(Fl,{data:null===r||void 0===r?void 0:r.address.city,className:"mr-2",text:"text-lg"}),Object(y.jsx)(Fl,{data:null===r||void 0===r?void 0:r.address.state,className:"mr-2",text:"text-lg"}),Object(y.jsx)(Fl,{data:null===r||void 0===r?void 0:r.address.zipCode,text:"text-lg"})]})]})})]}),Object(y.jsx)("div",{className:"w-full border-b py-5"}),Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold mt-10",children:"Notes"}),Object(y.jsx)("div",{className:"flex py-5",children:Object(y.jsx)(Fl,{data:null===r||void 0===r?void 0:r.notes,text:"text-lg"})})]})]})})})]})]})]})},Vl=n(2802),Bl=n(2803),Ul=n(2804),zl={prefix:"fas",iconName:"reports",icon:[20,20,[],"","M2.02539 12.0008C2.02539 17.1908 5.97539 21.4508 11.0254 21.9508V14.8208C9.86539 14.4008 9.02539 13.3008 9.02539 12.0008C9.02539 10.7008 9.86539 9.60078 11.0254 9.18078V2.05078C5.97539 2.55078 2.02539 6.81078 2.02539 12.0008ZM21.9754 11.0008H14.8454C14.5354 10.1508 13.8754 9.49078 13.0254 9.18078V2.05078C17.7454 2.52078 21.5054 6.28078 21.9754 11.0008ZM19.4454 8.99813C18.6254 6.99813 17.0254 5.39812 15.0254 4.57812V8.00813C15.3954 8.28813 15.7354 8.62813 16.0154 8.99813H19.4454ZM13.0254 21.95V14.82C13.8754 14.51 14.5354 13.85 14.8454 13H21.9754C21.5054 17.72 17.7454 21.48 13.0254 21.95Z"]},Zl={prefix:"fas",iconName:"people",icon:[14,12,[],"","M3.81017 4.80005C3.14753 4.80005 2.51204 4.5472 2.04348 4.09711C1.57493 3.64703 1.3117 3.03659 1.3117 2.40007C1.3117 1.76356 1.57493 1.15311 2.04348 0.703027C2.51204 0.252943 3.14753 8.82112e-05 3.81017 8.82112e-05C4.4728 8.82112e-05 5.1083 0.252943 5.57685 0.703027C6.04541 1.15311 6.30864 1.76356 6.30864 2.40007C6.30864 3.03659 6.04541 3.64703 5.57685 4.09711C5.1083 4.5472 4.4728 4.80005 3.81017 4.80005ZM3.81017 5.40005C5.1531 5.40005 6.43356 5.64005 7.62034 6.05404L6.93326 9.60002H6.15248L5.68402 12H1.93631L1.46785 9.60002H0.687079L0 6.05404C1.22092 5.62529 2.51022 5.40398 3.81017 5.40005ZM9.00074 5.50205C9.82524 5.61005 10.6185 5.79005 11.3743 6.05404L10.681 9.60002H9.90019L9.43173 12H6.95824L7.18935 10.8H7.97012L9.00074 5.50205ZM7.55787 8.82112e-05C7.92349 -0.00292286 8.28535 0.0711868 8.61789 0.217187C8.95044 0.363186 9.24557 0.577518 9.48246 0.845053C9.71935 1.11259 9.89223 1.42681 9.98888 1.76553C10.0855 2.10426 10.1036 2.45924 10.0419 2.80541C9.98009 3.15158 9.83998 3.48051 9.63142 3.76899C9.42285 4.05746 9.15091 4.29845 8.8348 4.47494C8.51868 4.65143 8.16609 4.75912 7.80191 4.79042C7.43773 4.82171 7.07084 4.77585 6.72713 4.65605C7.26682 4.01848 7.56144 3.22181 7.56144 2.40007C7.56144 1.57833 7.26682 0.781664 6.72713 0.144087C6.99572 0.0600878 7.2643 8.82112e-05 7.55787 8.82112e-05Z"]},Yl={prefix:"fas",iconName:"recommendations",icon:[14,12,[],"","M7.49779 12.8439C7.4067 12.6676 7.24798 12.6498 7.18375 12.6498C7.11953 12.6498 6.96081 12.6673 6.87435 12.8341L6.63751 13.2909C6.44081 13.6714 5.86462 13.6294 5.72721 13.2286L5.20752 11.7258L4.87989 12.6751C4.69802 13.2009 4.18883 13.5544 3.61387 13.5544H3.23128C2.95831 13.5544 2.73722 13.3412 2.73722 13.078C2.73722 12.8147 2.95831 12.6015 3.23128 12.6015H3.61387C3.76301 12.6015 3.89517 12.5098 3.94242 12.3735L4.5041 10.7465C4.606 10.4544 4.88823 10.2579 5.20752 10.2579C5.5268 10.2579 5.80903 10.4541 5.91062 10.7465L6.33922 11.9864C6.94908 11.5043 8.00852 11.6975 8.37721 12.408C8.43558 12.5205 8.54674 12.5852 8.66624 12.5944V10.1492L12.6187 6.36496V4.97888H8.4189C8.0113 4.97888 7.67781 4.6573 7.67781 4.26426V0.214722H1.50207C1.09139 0.214722 0.760986 0.533325 0.760986 0.929346V14.7454C0.760986 15.1414 1.09139 15.46 1.50207 15.46H11.8773C12.288 15.46 12.6184 15.1414 12.6184 14.7454V13.5544L8.66593 13.5511C8.16817 13.5419 7.72166 13.2748 7.49779 12.8439ZM12.6184 3.84442C12.6184 3.65683 12.5412 3.47519 12.4023 3.3412L9.37923 0.423154C9.24027 0.289162 9.05191 0.214722 8.85429 0.214722H8.66593V4.02605H12.6184V3.84442ZM9.65405 10.5458V12.6015H11.7844L16.7768 7.7546L14.6808 5.73341L9.65405 10.5458ZM18.3168 5.19714L17.3327 4.24818C17.0257 3.95221 16.5276 3.95221 16.2207 4.24818L15.3793 5.05958L17.4753 7.08077L18.3168 6.26937C18.624 5.9734 18.624 5.49311 18.3168 5.19714Z"]},Hl={prefix:"fax",iconName:"yieldNav",icon:[12,17,[],"","M17.29 4.29L15 2H21V8L18.71 5.71L12.41 12L8.41 8L2.41 14L1 12.59L8.41 5.17L12.41 9.17L17.29 4.29ZM18.5782 22C18.3809 22 18.0521 21.9824 17.9494 21.9503L17.9462 21.9487C17.7248 21.8893 17.5772 21.7032 17.5772 21.4867C17.5772 21.4482 17.5821 21.4065 17.5917 21.3728L17.6109 21.2958L17.5355 21.2749C17.1971 21.1835 16.8891 20.999 16.6196 20.7247C16.2025 20.298 15.8849 19.6772 15.6491 18.8286C15.2304 17.3592 14.9545 16.8555 14.5807 16.2572C14.4556 16.0582 14.3513 15.9091 14.2679 15.7904L14.2671 15.7893C14.0784 15.519 14 15.4067 14 15.1936C14 15.0268 14.069 14.8696 14.1957 14.7509C14.3288 14.6257 14.5165 14.5568 14.7235 14.5568C14.916 14.5568 15.309 14.6177 15.8335 14.7878L15.933 14.8198L15.9394 14.7156C16.0244 13.2045 16.3212 11.7928 16.7736 10.7405C17.0094 10.1903 17.2805 9.76197 17.5772 9.46681C17.8868 9.15721 18.2205 9 18.5686 9C18.9167 9 19.2504 9.15721 19.56 9.46681C19.8567 9.76197 20.1262 10.1919 20.3636 10.7405C20.816 11.7928 21.1128 13.2061 21.1978 14.7204L21.2042 14.8247L21.3037 14.791C21.748 14.6434 22.125 14.5648 22.3977 14.5648C22.6463 14.5648 22.8485 14.6289 22.9848 14.7493C23.1051 14.8551 23.1693 15.0011 23.1693 15.1695C23.1693 15.3769 23.0662 15.5239 22.8807 15.7888L22.8773 15.7936L22.8642 15.8123L22.8641 15.8124C22.7719 15.9436 22.6595 16.1035 22.534 16.3101C21.9533 17.2389 21.7528 17.9287 21.4994 18.8013L21.4881 18.8382C21.2267 19.7446 20.9171 20.3525 20.5128 20.7504C20.2514 21.0054 19.961 21.1739 19.6225 21.2653L19.5487 21.2846L19.5648 21.3599C19.5744 21.4017 19.5792 21.4434 19.5792 21.4819C19.5792 21.7097 19.4348 21.8957 19.2103 21.9551L19.2071 21.9567C19.1268 21.9807 18.7707 22 18.5782 22ZM15.4742 15.8497C16.0389 16.7817 16.3164 17.5501 16.6051 18.5623C16.9548 19.7991 17.4265 20.4007 18.0473 20.4007C18.275 20.4007 18.8076 20.3108 18.8076 19.4863C18.8076 18.9762 18.5654 18.0907 17.8836 17.2742C17.4778 16.7865 16.7463 16.124 15.5672 15.731L15.3603 15.662L15.4742 15.8497ZM21.5619 15.7326C20.3989 16.1064 19.5985 16.7416 19.1317 17.2068L19.0867 17.2517L19.1188 17.3063C19.6145 18.1212 19.8471 19.0323 19.7765 19.8729L19.7541 20.1376L19.9193 19.929C20.1551 19.6323 20.354 19.1863 20.5273 18.5639C20.7743 17.6945 21.0294 16.8892 21.6534 15.8513L21.7641 15.6684L21.5619 15.7326ZM17.0703 13.4339C16.9885 14.0033 16.9404 14.6017 16.9308 15.208L16.9292 15.2562L16.9725 15.2786C17.5596 15.5962 18.0489 15.9684 18.429 16.3855L18.4852 16.4464L18.5445 16.3887C18.9456 16.0021 19.5022 15.6187 20.1535 15.2786L20.1968 15.2562V15.208C20.1968 14.9963 20.1872 14.7621 20.1695 14.5118L20.1647 14.4381H19.3482V13.6199H20.0765L20.0637 13.5285C20.0268 13.2558 19.9835 12.9895 19.9337 12.7377L19.9209 12.6719H19.0434V11.8538H19.7236L19.6931 11.7511C19.5407 11.2314 19.361 10.7966 19.1734 10.4919C18.9696 10.1598 18.7627 9.99297 18.5622 9.99297C18.3488 9.99297 18.1227 10.1903 17.9093 10.5624L17.8403 10.6827H18.498V11.3886H17.5468L17.5275 11.4431C17.4281 11.7287 17.3366 12.0671 17.2516 12.4473L17.2307 12.5452H18.097V13.3633H17.08L17.0703 13.4339ZM17.5821 15.1615V14.3434H18.6264V15.1615H17.5821ZM9.538 21.9617C9.61698 21.9864 9.86994 22 10.0217 22C10.1698 22 10.4437 21.9852 10.5054 21.9667L10.5079 21.9655C10.6806 21.9198 10.7917 21.7767 10.7917 21.6014C10.7917 21.5718 10.788 21.5397 10.7806 21.5077L10.7683 21.4497L10.825 21.4348C11.0854 21.3645 11.3087 21.2349 11.5099 21.0387C11.8208 20.7327 12.059 20.2651 12.2601 19.5679L12.2688 19.5395C12.4637 18.8682 12.618 18.3376 13.0647 17.6231C13.1612 17.4642 13.2476 17.3412 13.3186 17.2402L13.3287 17.2258L13.3313 17.2222C13.474 17.0184 13.5533 16.9053 13.5533 16.7458C13.5533 16.6162 13.5039 16.5039 13.4114 16.4225C13.3065 16.33 13.151 16.2806 12.9598 16.2806C12.75 16.2806 12.46 16.3411 12.1182 16.4546L12.0417 16.4805L12.0368 16.4003C11.9714 15.2354 11.7431 14.1483 11.3951 13.3388C11.2125 12.9168 11.0052 12.5861 10.7769 12.3591C10.5387 12.1209 10.2821 12 10.0143 12C9.74654 12 9.48988 12.1209 9.25173 12.3591C9.02344 12.5861 8.8149 12.9156 8.63351 13.3388C8.28554 14.1483 8.05725 15.2342 7.99185 16.3966L7.98692 16.4768L7.91041 16.4521C7.50691 16.3213 7.20459 16.2744 7.05651 16.2744C6.89733 16.2744 6.75296 16.3275 6.65054 16.4237C6.55306 16.5151 6.5 16.636 6.5 16.7643C6.5 16.9282 6.5603 17.0146 6.70549 17.2225L6.70607 17.2233C6.77024 17.3147 6.85044 17.4294 6.94669 17.5824C7.2342 18.0427 7.44644 18.4302 7.76851 19.5605C7.9499 20.2132 8.19422 20.6908 8.51505 21.019C8.72236 21.23 8.95928 21.3719 9.21964 21.4423L9.27764 21.4583L9.26283 21.5175C9.25543 21.5434 9.25173 21.5755 9.25173 21.6051C9.25173 21.7717 9.36525 21.9149 9.53553 21.9605L9.538 21.9617ZM8.50395 19.3556C8.28183 18.577 8.06836 17.9859 7.63401 17.269L7.5464 17.1246L7.70558 17.1777C8.61253 17.48 9.17522 17.9896 9.48741 18.3648C10.0118 18.9928 10.1982 19.674 10.1982 20.0664C10.1982 20.7006 9.7885 20.7697 9.61327 20.7697C9.13573 20.7697 8.77295 20.307 8.50395 19.3556ZM10.4474 18.3129C10.8065 17.9551 11.4223 17.4664 12.3169 17.1789L12.4724 17.1296L12.3872 17.2702C11.9072 18.0686 11.711 18.6881 11.521 19.3569C11.3877 19.8356 11.2347 20.1787 11.0533 20.407L10.9262 20.5674L10.9435 20.3638C10.9978 19.7172 10.8189 19.0163 10.4376 18.3894L10.4129 18.3475L10.4474 18.3129ZM8.75444 16.7754C8.76184 16.309 8.79886 15.8487 8.86179 15.4107L8.8692 15.3564H9.65153V14.727H8.98519L9.00123 14.6518C9.06663 14.3593 9.13697 14.099 9.21347 13.8793L9.22828 13.8374H9.96002V13.2944H9.45409L9.50715 13.2019C9.67127 12.9156 9.84526 12.7638 10.0094 12.7638C10.1636 12.7638 10.3228 12.8922 10.4795 13.1476C10.6239 13.382 10.7621 13.7164 10.8793 14.1162L10.9028 14.1952H10.3796V14.8245H11.0545L11.0644 14.8751C11.1027 15.0689 11.136 15.2737 11.1644 15.4835L11.1742 15.5538H10.614V16.1831H11.2421L11.2458 16.2399C11.2594 16.4324 11.2668 16.6125 11.2668 16.7754V16.8124L11.2335 16.8297C10.7325 17.0913 10.3043 17.3862 9.9958 17.6836L9.95014 17.728L9.90696 17.6811C9.61451 17.3603 9.23815 17.074 8.78652 16.8297L8.75321 16.8124L8.75444 16.7754ZM9.25543 16.1103V16.7396H10.0587V16.1103H9.25543ZM3.1266 21.9732C3.18188 21.9905 3.35896 22 3.4652 22C3.56885 22 3.76061 21.9896 3.8038 21.9767L3.80553 21.9758C3.92645 21.9439 4.00419 21.8437 4.00419 21.721C4.00419 21.7003 4.0016 21.6778 3.99642 21.6554L3.98778 21.6148L4.02751 21.6044C4.20977 21.5552 4.36611 21.4645 4.50691 21.3271C4.72458 21.1129 4.89128 20.7855 5.03208 20.2975L5.03813 20.2776C5.1746 19.8077 5.28257 19.4363 5.59526 18.9362C5.66284 18.8249 5.72334 18.7389 5.77301 18.6682L5.77303 18.6681L5.7801 18.6581L5.7819 18.6555C5.88183 18.5129 5.93731 18.4337 5.93731 18.3221C5.93731 18.2314 5.90276 18.1528 5.83798 18.0958C5.76456 18.031 5.65572 17.9964 5.52184 17.9964C5.375 17.9964 5.17201 18.0387 4.93275 18.1182L4.87919 18.1364L4.87574 18.0802C4.82996 17.2648 4.67016 16.5038 4.42658 15.9372C4.29874 15.6418 4.15362 15.4103 3.99383 15.2514C3.82712 15.0846 3.64746 15 3.46002 15C3.27258 15 3.09292 15.0846 2.92621 15.2514C2.76641 15.4103 2.62043 15.6409 2.49346 15.9372C2.24988 16.5038 2.09008 17.2639 2.0443 18.0776L2.04084 18.1338L1.98729 18.1165C1.70484 18.0249 1.49321 17.9921 1.38956 17.9921C1.27813 17.9921 1.17707 18.0292 1.10538 18.0966C1.03714 18.1605 1 18.2452 1 18.335C1 18.4497 1.04221 18.5102 1.14384 18.6558L1.14425 18.6563C1.18917 18.7203 1.24531 18.8006 1.31268 18.9077C1.51394 19.2299 1.66251 19.5011 1.88796 20.2923C2.01493 20.7493 2.18596 21.0835 2.41054 21.3133C2.55565 21.461 2.72149 21.5603 2.90375 21.6096L2.94435 21.6208L2.93398 21.6623C2.9288 21.6804 2.92621 21.7029 2.92621 21.7236C2.92621 21.8402 3.00567 21.9404 3.12487 21.9724L3.1266 21.9732ZM2.40276 20.1489C2.24728 19.6039 2.09785 19.1902 1.7938 18.6883L1.73248 18.5872L1.8439 18.6244C2.47877 18.836 2.87265 19.1927 3.09119 19.4553C3.45829 19.895 3.58872 20.3718 3.58872 20.6465C3.58872 21.0904 3.30195 21.1388 3.17929 21.1388C2.84501 21.1388 2.59106 20.8149 2.40276 20.1489ZM3.7632 19.4191C4.01456 19.1686 4.44558 18.8265 5.07181 18.6252L5.18065 18.5907L5.12105 18.6892C4.78504 19.248 4.6477 19.6816 4.51468 20.1498C4.42139 20.4849 4.31429 20.7251 4.18731 20.8849L4.09834 20.9972L4.11044 20.8546C4.14844 20.402 4.0232 19.9114 3.75629 19.4726L3.73902 19.4432L3.7632 19.4191ZM2.57811 18.3428C2.58329 18.0163 2.6092 17.6941 2.65326 17.3875L2.65844 17.3495H3.20607V16.9089H2.73963L2.75086 16.8562C2.79664 16.6515 2.84588 16.4693 2.89943 16.3155L2.9098 16.2862H3.42201V15.9061H3.06787L3.10501 15.8413C3.21989 15.6409 3.34168 15.5347 3.45656 15.5347C3.56453 15.5347 3.67596 15.6245 3.78566 15.8033C3.88672 15.9674 3.98346 16.2015 4.06552 16.4814L4.08193 16.5366H3.71569V16.9772H4.18818L4.19509 17.0126C4.22186 17.1482 4.24518 17.2916 4.26505 17.4384L4.27196 17.4877H3.87981V17.9282H4.31947L4.32206 17.9679C4.33156 18.1027 4.33674 18.2288 4.33674 18.3428V18.3687L4.31342 18.3808C3.96273 18.5639 3.663 18.7704 3.44706 18.9785L3.4151 19.0096L3.38487 18.9768C3.18016 18.7522 2.91671 18.5518 2.60057 18.3808L2.57724 18.3687L2.57811 18.3428ZM2.9288 17.8772V18.3177H3.49111V17.8772H2.9288Z"]};n(236).b.add({prefix:"fas",iconName:"jug",icon:[17,10,[],"","M6.46303 1.41505L5.54665 0.353487C3.7006 0.285438 0.108121 1.25582 0.506548 5.68173C0.283429 5.87772 0.121402 6.03559 0.068278 6.09003C-0.0114074 9.10461 -0.0871085 15.3624 0.24757 16.277C0.454752 16.9466 1.52918 17.0323 2.04049 16.9915C2.04049 16.9915 8.08994 16.8622 8.51493 16.8486C8.93992 16.835 9.7899 16.4706 9.7899 16.046C9.7899 15.9656 9.80188 15.6982 9.82012 15.2911C9.89825 13.5471 10.0913 9.23933 9.94927 6.09003C9.93457 5.76404 9.92088 5.41778 9.90704 5.0679C9.84765 3.56642 9.78563 1.99833 9.63053 1.68045C9.59068 1.59879 9.39147 1.4763 9.39147 1.4763C9.39147 1.4763 9.44327 1.12108 9.49108 1.08842C9.53889 1.05575 9.41803 0.448756 9.35163 0.14934C8.78719 0.0132421 7.44715 -0.152798 6.60248 0.271829C6.57061 0.892437 6.54936 1.11564 6.54272 1.14966C6.56264 1.18369 6.60248 1.2844 6.60248 1.41505H6.46303ZM5.54665 1.96626C5.42712 1.63963 5.01675 1.08434 4.33145 1.47631C4.17208 1.27216 3.4828 1.45181 3.27562 1.84377C3.2557 1.84377 2.55845 1.84377 2.37916 2.5787C2.37729 2.58062 2.37068 2.58488 2.36024 2.59159C2.25958 2.65639 1.80331 2.9501 1.82136 3.57903C1.50262 4.19147 1.30341 5.04889 2.23971 5.04889C2.93031 4.99445 4.55855 4.30171 5.54665 1.96626Z"]},zl,Zl,Yl,Hl);var Gl=Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.y}),Wl=(ui.a,di.g,ui.a,di.j,Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.n})),ql=(ui.a,di.q,Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.v})),Jl=Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.i}),Kl=Object(y.jsx)(Vl.a,{}),Ql=Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:Zl}),Xl=Object(y.jsx)(Bl.a,{}),$l=Object(y.jsx)(Ul.a,{}),ed=Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:Yl}),td=Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:zl}),nd=Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.r}),ad=Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:Hl}),rd=Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:{prefix:"fas",iconName:"products",icon:[10,17,[],"","M6.46303 1.41505L5.54665 0.353487C3.7006 0.285438 0.108121 1.25582 0.506548 5.68173C0.283429 5.87772 0.121402 6.03559 0.068278 6.09003C-0.0114074 9.10461 -0.0871085 15.3624 0.24757 16.277C0.454752 16.9466 1.52918 17.0323 2.04049 16.9915C2.04049 16.9915 8.08994 16.8622 8.51493 16.8486C8.93992 16.835 9.7899 16.4706 9.7899 16.046C9.7899 15.9656 9.80188 15.6982 9.82012 15.2911C9.89825 13.5471 10.0913 9.23933 9.94927 6.09003C9.93457 5.76404 9.92088 5.41778 9.90704 5.0679C9.84765 3.56642 9.78563 1.99833 9.63053 1.68045C9.59068 1.59879 9.39147 1.4763 9.39147 1.4763C9.39147 1.4763 9.44327 1.12108 9.49108 1.08842C9.53889 1.05575 9.41803 0.448756 9.35163 0.14934C8.78719 0.0132421 7.44715 -0.152798 6.60248 0.271829C6.57061 0.892437 6.54936 1.11564 6.54272 1.14966C6.56264 1.18369 6.60248 1.2844 6.60248 1.41505H6.46303ZM5.54665 1.96626C5.42712 1.63963 5.01675 1.08434 4.33145 1.47631C4.17208 1.27216 3.4828 1.45181 3.27562 1.84377C3.2557 1.84377 2.55845 1.84377 2.37916 2.5787C2.37729 2.58062 2.37068 2.58488 2.36024 2.59159C2.25958 2.65639 1.80331 2.9501 1.82136 3.57903C1.50262 4.19147 1.30341 5.04889 2.23971 5.04889C2.93031 4.99445 4.55855 4.30171 5.54665 1.96626Z"]}}),cd=Object(y.jsx)(ui.a,{size:"lg",fill:"none",fillRule:"evenodd",xmlns:"http://www.w3.org/2000/svg",clipRule:"evenodd",icon:{prefix:"fab",iconName:"farm-storage",icon:[24,24,[],"","M1 11.4L12 3L23 11.4L21.79 12.98L20 11.62V21H4V11.62L2.21 12.99L1 11.4ZM18 19H17V15H15V11H9V15H7V19H6V10.1L12 5.52L18 10.1V19ZM9 17V19H11V17H9ZM13 17V19H15V17H13ZM13 15V13H11V15H13Z"]}}),id=Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:{prefix:"fas",iconName:"integrations",icon:[20,20,[],"","M11.4107 5.54475C11.4103 4.89543 10.887 4.35266 10.2376 4.35266C9.58813 4.35266 9.05844 4.89543 9.05803 5.54475L7.78947 5.68421L6.68339 5.55022C6.6838 3.60157 8.2888 2 10.2376 2C12.1863 2 13.7695 3.60157 13.7699 5.55022L12.5263 5.68421L11.4107 5.54475Z M10.2365 18.4691C10.8859 18.4691 11.4124 18.9953 11.4129 19.6446L12.5873 19.802L13.7815 19.6662C13.7811 17.7175 12.1853 16.1164 10.2365 16.1164C8.28778 16.1164 6.69673 17.7175 6.69632 19.6662L7.78947 19.8947L9.0602 19.6446C9.06061 18.9953 9.58711 18.4691 10.2365 18.4691Z M18.4691 17.2934V19.6662C18.4691 20.9655 17.4158 22.0188 16.1164 22.0188H12.5873V22.0031H7.88196V22.0188H4.35317C3.05383 22.0188 2.00051 20.9655 2.00051 19.6662L2 11.4201L2.00051 11.4165V7.90288C2.00051 6.60354 3.05383 5.55022 4.35317 5.55022H6.68339L9.05803 5.54475V7.89669H11.4107V5.54475L13.7699 5.55022H16.1164C17.4158 5.55022 18.4691 6.60354 18.4691 7.90288V10.2354H18.471C20.42 10.2354 22 11.8154 22 13.7644C22 15.7134 20.42 17.2934 18.471 17.2934H18.4691ZM17.2925 14.9407H18.471C19.1207 14.9407 19.6473 14.414 19.6473 13.7644C19.6473 13.1147 19.1207 12.588 18.471 12.588H18.4693V12.599H16.1164L16.1164 7.90288H4.35317V10.2354C6.30217 10.2354 7.88245 11.8154 7.88245 13.7644C7.88245 15.7134 6.30247 17.2934 4.35346 17.2934L4.35317 19.6662L9.05803 19.6505V22.0024H11.4107V19.6505H12.5873L16.1164 19.6662L16.1164 14.9517H17.2925V14.9407ZM4.35314 16.1218V16.1175H2.00051V16.1218H4.35314ZM4.35346 14.9407C5.00313 14.9407 5.52979 14.414 5.52979 13.7644C5.52979 13.1147 5.00313 12.588 4.35347 12.588L2.00051 12.5875V14.9402L4.35346 14.9407Z"]}}),od=(ui.a,ui.a,Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.a})),sd=Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.b}),ld=[{id:"companies",key:"companies",path:Cc.companies,exact:!0,secure:!0,disabled:!1,icon:Gl,nav:"leftNav",component:hl},{id:"companyEntry",key:"companyEntry",path:"".concat(Cc.companies,"/:id"),exact:!0,secure:!0,component:kl,minPermissions:{minAllowedRole:$a}},{id:"companyView",key:"companyView",path:"".concat(Cc.companies,"/:id/view"),exact:!0,secure:!0,component:Ml,minPermissions:{minAllowedRole:er}}],dd=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{searchTerm:null,useFullResponse:!1},t=e.searchTerm,n=e.useFullResponse,r=Object(a.useContext)(ac),c=Object(b.a)(r,2),i=c[0],o=i.organization,s=i.cropSeasons,l=i.isGlobalCropSeasonLoading,d=c[1],u=Object(f.useFlags)(),j=u.releaseFeCondensedCropSeasons,p=u.releaseFeCondensedCropSeasonsByOrg,m=yc(j,p,null===o||void 0===o?void 0:o.id),v=Object(a.useState)(),O=Object(b.a)(v,2),h=O[0],x=O[1],g=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=!n&&m,e.next=3,mc(d,null,t);case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),C=function(){g()},y=Object(a.useCallback)((function(e){var t=s?s.filter((function(t){return!e||t.name.toLowerCase().includes(e.toLowerCase())})):[];t&&x(Object(ne.orderBy)(t,[function(e){var t=e.name;return null===t||void 0===t?void 0:t.toLowerCase()}],"asc"))}),[s]);return Object(a.useEffect)((function(){l||g()}),[]),Object(a.useEffect)((function(){t?y(t):y()}),[t,y]),{cropSeasons:h,findCropSeason:y,loaded:!l,reloadCropSeasons:C}},ud="PLANS_VIEW_v1",bd="CROPSEASON_VIEW_v1",jd="DEFAULT_ORG_v1",pd="INVENTORY_VIEW_v1",fd="TASKS_VIEW_v1",md="RECOMMENDATIONS_VIEW_v1",vd="INVOICES_VIEW_v1",Od="PROPERTY_VIEW_v2",hd="SUBMISSION_TASK_REDIRECT",xd="SUBMISSION_EDIT_REDIRECT",gd=function(e){return e&&"null"!==e?function(e){return e&&"{"===e.substr(0,1)?JSON.parse(e):e}(e):null},Cd=function(e){return Object(ne.isNil)(e)?null:function(e){return Object(ne.isString)(e)?e:JSON.stringify(e)}(e)},yd=function(e){return function(t){return localStorage.setItem(e,Cd(t)),t}},Pd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return function(){return localStorage.hasOwnProperty(e)&&gd(localStorage.getItem(e))||t}},Ad=function(e){return function(){return localStorage.hasOwnProperty(e)&&localStorage.removeItem(e)}},Sd=function(e,t){return{save:yd(e),get:Pd(e,t),remove:Ad(e)}},Td=n(789),Nd=n.n(Td),Ed=function(){return Object(y.jsxs)("svg",{className:"m-auto fill-current",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("path",{d:"M1.25 0C0.559644 0 0 0.559644 0 1.25V5C0 5.69036 0.559644 6.25 1.25 6.25H5C5.69036 6.25 6.25 5.69036 6.25 5V1.25C6.25 0.559644 5.69036 0 5 0H1.25Z"}),Object(y.jsx)("path",{d:"M1.25 8.75C0.559644 8.75 0 9.30964 0 10V13.75C0 14.4404 0.559644 15 1.25 15H5C5.69036 15 6.25 14.4404 6.25 13.75V10C6.25 9.30964 5.69036 8.75 5 8.75H1.25Z"}),Object(y.jsx)("path",{d:"M8.75 1.25C8.75 0.559644 9.30964 0 10 0H13.75C14.4404 0 15 0.559644 15 1.25V5C15 5.69036 14.4404 6.25 13.75 6.25H10C9.30964 6.25 8.75 5.69036 8.75 5V1.25Z"}),Object(y.jsx)("path",{d:"M10 8.75C9.30964 8.75 8.75 9.30964 8.75 10V13.75C8.75 14.4404 9.30964 15 10 15H13.75C14.4404 15 15 14.4404 15 13.75V10C15 9.30964 14.4404 8.75 13.75 8.75H10Z"})]})},wd=function(e){var t=e.view,n=e.changeView,a=e.testId;return Object(y.jsx)("div",{"data-testid":a,children:Object(y.jsxs)(m.RadioButtonGroup,{selected:t,onChange:n,children:[Object(y.jsx)(m.RadioButtonGroup.RadioButton,{name:"tileView",value:"tile",children:Object(y.jsx)("div",{children:Object(y.jsx)(Ed,{})})}),Object(y.jsx)(m.RadioButtonGroup.RadioButton,{name:"listView",value:"list",children:Object(y.jsx)("div",{children:Object(y.jsx)(Nd.a,{})})})]})})};wd.defaultProps={testId:"landing-list-view-toggle"};var _d,Rd=wd,Id=["title","titleId"];function Dd(){return Dd=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Dd.apply(this,arguments)}function kd(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Ld(e,t){var n=e.title,r=e.titleId,c=kd(e,Id);return a.createElement("svg",Dd({width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,_d||(_d=a.createElement("path",{d:"M4.0978 1.59541C4.03326 1.43566 3.94541 1.28635 3.83711 1.15235C4.81748 0.60016 5.92367 0.310059 7.04885 0.310059C8.17404 0.310059 9.28023 0.60016 10.2606 1.15235C10.1522 1.28634 10.0643 1.43565 9.99962 1.59541C9.09929 1.08677 8.08278 0.819474 7.04871 0.819474C6.01464 0.819474 4.99812 1.08677 4.0978 1.59541ZM12.7275 10.0416C13.2799 9.06129 13.5701 7.95509 13.5701 6.82986C13.5701 5.70464 13.2799 4.59844 12.7275 3.61812C12.5937 3.72646 12.4445 3.81432 12.2848 3.87881C12.7935 4.77943 13.0608 5.79623 13.0608 6.8306C13.0608 7.86496 12.7935 8.88176 12.2848 9.78238C12.4445 9.84687 12.5937 9.93473 12.7275 10.0431V10.0416ZM7.04871 12.8432C6.01419 12.8445 4.99707 12.5771 4.09692 12.0672C4.03245 12.2269 3.94459 12.3762 3.83623 12.51C4.81655 13.0624 5.92276 13.3526 7.04798 13.3526C8.1732 13.3526 9.27941 13.0624 10.2597 12.51C10.1513 12.3761 10.0634 12.2269 9.99874 12.0672C9.09913 12.5768 8.08264 12.8442 7.04871 12.8432ZM1.36988 3.61958C0.81769 4.59995 0.527588 5.70614 0.527588 6.83133C0.527588 7.95651 0.81769 9.0627 1.36988 10.0431C1.50375 9.93473 1.65297 9.84687 1.81265 9.78238C1.30393 8.88176 1.03661 7.86496 1.03661 6.8306C1.03661 5.79623 1.30393 4.77943 1.81265 3.87881C1.65306 3.81477 1.50384 3.72741 1.36988 3.61958ZM12.5156 10.52C12.7511 10.7561 12.8833 11.0758 12.8833 11.4092C12.8833 11.7426 12.7511 12.0624 12.5156 12.2984C12.2928 12.5244 11.9926 12.6577 11.6755 12.6714C11.3584 12.6852 11.0478 12.5785 10.8061 12.3727C10.5645 12.1669 10.4097 11.8773 10.3728 11.562C10.3359 11.2468 10.4196 10.9292 10.6072 10.6732L9.38588 9.45213C8.743 10.0268 7.91096 10.3444 7.04871 10.3444C6.18645 10.3444 5.35442 10.0268 4.71154 9.45213L3.49049 10.6732C3.67548 10.9292 3.75725 11.2456 3.71953 11.5592C3.68181 11.8728 3.52737 12.1607 3.28695 12.3656C3.04653 12.5705 2.73776 12.6773 2.42213 12.6648C2.10649 12.6523 1.80714 12.5214 1.58366 12.2982C1.36018 12.0749 1.22897 11.7757 1.21616 11.4601C1.20334 11.1445 1.30985 10.8356 1.5145 10.595C1.71914 10.3543 2.00689 10.1996 2.32048 10.1616C2.63406 10.1235 2.95047 10.205 3.20671 10.3897L4.42805 9.16835C3.85343 8.52547 3.53578 7.69343 3.53578 6.83118C3.53578 5.96892 3.85343 5.13689 4.42805 4.49401L3.20671 3.27296C2.95047 3.45768 2.63406 3.53913 2.32048 3.50109C2.00689 3.46305 1.71914 3.30831 1.5145 3.06767C1.30985 2.82704 1.20334 2.51817 1.21616 2.20255C1.22897 1.88692 1.36018 1.5877 1.58366 1.36446C1.80714 1.14121 2.10649 1.01031 2.42213 0.997817C2.73776 0.985326 3.04653 1.09216 3.28695 1.29705C3.52737 1.50194 3.68181 1.78985 3.71953 2.10348C3.75725 2.4171 3.67548 2.73342 3.49049 2.98948L4.71154 4.21052C5.34744 3.64208 6.16871 3.32487 7.02161 3.31825C7.87452 3.31164 8.70061 3.61607 9.34526 4.17457L10.5757 2.94418C10.4047 2.68422 10.3363 2.37008 10.3836 2.06257C10.4309 1.75505 10.5906 1.47602 10.8318 1.27947C11.073 1.08293 11.3785 0.98284 11.6892 0.998582C12 1.01432 12.2938 1.14478 12.5139 1.36469C12.734 1.58461 12.8647 1.87835 12.8807 2.18907C12.8967 2.49979 12.7968 2.8054 12.6005 3.04675C12.4041 3.28811 12.1252 3.44804 11.8178 3.4956C11.5103 3.54317 11.1961 3.47498 10.936 3.30423L9.70561 4.53492C10.264 5.17959 10.5683 6.00563 10.5617 6.85847C10.555 7.71131 10.2378 8.5325 9.66937 9.16835L10.891 10.3897C11.1333 10.2154 11.4297 10.1328 11.7272 10.1567C12.0248 10.1806 12.3042 10.3093 12.5156 10.52ZM10.879 2.25328C10.879 2.42616 10.9389 2.59369 11.0486 2.72733C11.1582 2.86098 11.3108 2.95248 11.4804 2.98624C11.6499 3.01999 11.8259 2.99393 11.9784 2.91247C12.1309 2.83102 12.2504 2.69922 12.3166 2.53953C12.3828 2.37983 12.3916 2.20212 12.3415 2.03667C12.2914 1.87122 12.1855 1.72827 12.0418 1.63216C11.8981 1.53605 11.7255 1.49273 11.5535 1.50959C11.3814 1.52644 11.2205 1.60242 11.0982 1.72459C11.0285 1.7938 10.9731 1.87617 10.9355 1.96693C10.8978 2.05768 10.8785 2.15502 10.8787 2.25328H10.879ZM3.00009 2.78227C3.10478 2.67765 3.17609 2.54434 3.20501 2.3992C3.23392 2.25405 3.21914 2.10359 3.16253 1.96684C3.10592 1.8301 3.01002 1.71321 2.88697 1.63098C2.76392 1.54874 2.61925 1.50485 2.47125 1.50485C2.32325 1.50485 2.17858 1.54874 2.05553 1.63098C1.93248 1.71321 1.83658 1.8301 1.77997 1.96684C1.72336 2.10359 1.70858 2.25405 1.73749 2.3992C1.76641 2.54434 1.83772 2.67765 1.94241 2.78227C2.01154 2.85228 2.09389 2.90786 2.18467 2.9458C2.27545 2.98374 2.37286 3.00328 2.47125 3.00328C2.56964 3.00328 2.66705 2.98374 2.75783 2.9458C2.84861 2.90786 2.93096 2.85228 3.00009 2.78227ZM3.21899 11.4094C3.21898 11.2363 3.15898 11.0687 3.0492 10.9349C2.93942 10.8011 2.78666 10.7096 2.61695 10.6759C2.44724 10.6421 2.27107 10.6683 2.11848 10.7498C1.96588 10.8314 1.8463 10.9634 1.78011 11.1233C1.71391 11.2832 1.7052 11.461 1.75546 11.6266C1.80572 11.7922 1.91184 11.9352 2.05574 12.0313C2.19963 12.1274 2.3724 12.1706 2.54459 12.1536C2.71679 12.1366 2.87777 12.0604 3.00009 11.9381C3.06964 11.8687 3.12478 11.7863 3.1623 11.6956C3.19982 11.6048 3.21899 11.5076 3.21869 11.4094H3.21899ZM10.0525 6.83118C10.0525 6.2371 9.87624 5.65637 9.54614 5.16243C9.21604 4.6685 8.74689 4.28354 8.19801 4.05623C7.64913 3.82893 7.04518 3.76948 6.46252 3.88542C5.87985 4.00135 5.34465 4.28746 4.92459 4.70756C4.50453 5.12766 4.21848 5.66289 4.1026 6.24557C3.98672 6.82824 4.04622 7.43219 4.27358 7.98105C4.50094 8.5299 4.88595 8.99902 5.37991 9.32907C5.87388 9.65912 6.45462 9.83528 7.04871 9.83528C7.84516 9.83443 8.60874 9.51764 9.17188 8.95444C9.73503 8.39124 10.0517 7.62763 10.0525 6.83118ZM12.1568 10.8804C12.0522 10.7758 11.9189 10.7046 11.7738 10.6757C11.6288 10.6469 11.4784 10.6617 11.3417 10.7183C11.2051 10.7749 11.0883 10.8707 11.0061 10.9937C10.9239 11.1167 10.88 11.2613 10.88 11.4092C10.88 11.5571 10.9239 11.7017 11.0061 11.8247C11.0883 11.9477 11.2051 12.0436 11.3417 12.1002C11.4784 12.1568 11.6288 12.1716 11.7738 12.1427C11.9189 12.1139 12.0522 12.0427 12.1568 11.9381C12.2264 11.8687 12.2816 11.7863 12.3193 11.6955C12.357 11.6047 12.3763 11.5074 12.3762 11.4091C12.3761 11.3108 12.3565 11.2136 12.3187 11.1229C12.2808 11.0322 12.2254 10.9499 12.1556 10.8807L12.1568 10.8804ZM8.35129 5.14808L9.02202 5.05602L8.69469 5.6493C8.55646 5.91729 8.47579 6.21978 8.39747 6.59153L8.38403 6.65203C8.34808 6.81189 8.31096 6.9776 8.26128 7.14506C8.21159 7.31252 8.13619 7.53201 7.9962 7.73425C7.98393 7.75237 7.97224 7.76728 7.96259 7.77926L7.95412 7.79036C7.94097 7.80848 7.92752 7.82602 7.91349 7.84355L7.90706 7.85145C7.89771 7.86284 7.88865 7.87395 7.87784 7.88505C7.64023 8.15978 7.31232 8.33016 6.8754 8.40527C6.62368 8.44581 6.37007 8.47351 6.11554 8.48827C5.99074 8.49733 5.86361 8.50639 5.8037 8.5175L5.48835 8.58209L5.40798 8.26996C5.40594 8.26236 5.40418 8.25447 5.40243 8.24657L5.40009 8.23664C5.34944 8.04501 5.31483 7.8495 5.29663 7.65213C5.27735 7.43291 5.28955 7.21206 5.33287 6.9963C5.40039 6.6456 5.59415 6.30863 5.8791 6.04793C6.36103 5.59932 7.14515 5.31291 8.35129 5.14808ZM8.11603 5.6984C7.1925 5.85095 6.5887 6.083 6.22864 6.42114L6.22601 6.42348C6.02699 6.59985 5.88991 6.83549 5.83497 7.09567V7.10035C5.80087 7.26846 5.79103 7.4406 5.80574 7.6115C5.81753 7.74173 5.83813 7.87101 5.86741 7.99845C5.93141 7.99231 6.00272 7.98705 6.0793 7.98179C6.28066 7.96718 6.52995 7.94935 6.78977 7.90464C7.10599 7.85028 7.33629 7.73513 7.49352 7.55247L7.49615 7.54954L7.51193 7.53084L7.51603 7.52558C7.52509 7.51418 7.53385 7.50278 7.54233 7.4908L7.54437 7.48817L7.56308 7.46391C7.56682 7.45952 7.57033 7.45493 7.5736 7.45018L7.57594 7.44725C7.67531 7.30346 7.73317 7.13366 7.77233 7.00156C7.81705 6.85047 7.85212 6.69382 7.88631 6.54185L7.89888 6.48632C7.96113 6.1926 8.02514 5.93658 8.11603 5.6984Z",fill:"#73DC78"})))}var Fd=a.forwardRef(Ld);n.p;function Md(e){var t=e.buttonText,n=e.onClick,a=e.subtitle,r=e.setPermission,c=e.imageToUse,i=e.children,o=e.text,s=e.importButtonName,l=e.onImportClick,d=Object(f.useFlags)().feTasksModuleConnectsImport;return Object(y.jsx)("div",{"data-testid":"property-overlay-modal",className:"mt-4 p-10 bg-white border rounded-none sm:rounded border-neutral",children:Object(y.jsxs)("div",{className:"flex flex-col justify-center",children:[Object(y.jsx)("div",{className:"self-center","data-testid":"empty-state-image",children:Object(y.jsx)("img",{width:"356",height:"318",src:"documentation"===c?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOsAAAChCAYAAAAmyUjfAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAlKSURBVHgB7d1LbFxXHcfx/8y4kDT1K6ASxw6aKayqIlk8JKqqkqtUVaELpxLiJaFMF1l0lUqIvb1ALFjYsGDDIs2mAlFEjAhpDcgWJWqQQDGiqhSJZu4gN1YjgselxgntzOWe67n2veMZe2Y8M5nzP9+PZM0ruZEy+vm8/udcEQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgC5KiWMKhcKIyJER6YJcbswToEucCWuhcHtSMuW54OmUdE8p+C99Wcpbs7lcriRABzkR1mpQr0vvLOc+PfaUAB2UFhdkyr+S3poqrK6dFaCD1Id1e4wqWem1Sle723DQgKi3/2TSq7+4Kr97fUXef/+/0kmbm/fOiDyXFfGDsat/UeTKJQEOQf2YtVBYy0pGCvU++953L4Rh7Q1/RuS3swK0yYGWtb75uV8ngjo19TnJZh+WTlpZKQQ/N6uvUjPZbL60tPSDBUHLWBZzOKy/jAX1woWXJJ9/WrphZuYVmZ19JXx+4sTx+aCVnxe0rPDPNfMQLIvJrKvBdWM2uI7V1TvhYz5/umtBNWZmvh222sa1azc6PjZ2TD74ZbcUDm0c5GxYI9PTj0u3nT17euf5YjCZhUPJVtLll8RBzod1ZOSYdNuZM4/v/DuLi72szdApncpMi4OcHbP2kgnq5OQjsrz8d/nzmzfkW1//oaB9wbJYsBz33NL2slgqWBK7fFEcQFh7xHSFTVjNmNWMXXEoZu18qrryaNazg27x5lMiy6rrsQlrj5iuMDpnY2NT5ucXxPNum5eTIg+aceyMKEZYe8R0hbs56+yi6ekvy/PPf7+6lp06L8rD6vwEE+yVzX5K5ubORS+DrvGzWVGMsMJq0Rq2C9R2g8OF8wE5Kz67X6CDyrBWi/eXgqBmBVBCZTe4kq7kRQgqdGHMClhCZTfYr6S9oBtclylKWHx9t+RvYeFasFb3nkCFbPDjiVIqN5//o7CWz2TkQu37Zg/rj4IfqPayyOUXRCGds8GZSqm2h3/tzRs7QT1/flpGR7tfwI/eMhVNpdJmXuQrfxO5om7fsMqwZspBWDPJsK6u/it8NKdBzM+fE+hz/frNcFgTdBi7coj7/aZ0gmnAq31nYuKT4WO1lhQKmXphzZyZDR4aelDgCl/l7hulYb2758saGj668zwY1wj02Z3VTxFWWxx0n5lS6QOBauuikOZucCKw0Zg1/ICWVaXd+Yj0hijkTFgTHxBWWMipcsOJU58IHwmrPskqtI88UUhzWL1GH2xsMGaFfZxqWYcGWb7RKrl+/ponCqkNq+9XirXvDVbXWimMgI2calmHh2lZtYpVL3milN6Wtc7C+G7LypY4bdbX9c9DKG5ZdZacoT5aVoul67SsExMs3WjlwneqNqzlSoqiCCf5KquXDLeKImhZ1YoV8ausCzbUhjWzTxULhfya0bLa54G93eBoTystqz6xtXO1E4t6w/phhrBCFScL+bVYuHNZ1j863BCtE9foB7FfwJ4opTasudyYt9/nthdG/Oz2q/JG6U/yk3d/2nbYOnGNfuHCPIRbhfxKzmEyIfvLf/4aPjchaydsnbhGP9ltWdOeKKU9rF78RTysthbzRyE7kj4i+RPfkdGB0ZbD1olr9BuKIhSyuXWNh+zFk+fksWOPyovj51oKWyeu0W+SQb3HbLCVUn7DUw6LRbvGrLUhG//4yfD940HImg1bJ67Rj5Lj1QxhtZKv40jKd7Zu7owvP3v0kZ2QRZoJW6Ogxq9hWlnD/N23Nt8WWyRb1ruE1U57W9bx8e1TDm0a43wmCOg3Hv5a+NyEyASv1n6BPSioxuL6H+SNjavh82dGT8uTw0+ILZLf5TJhtZHvNy49s21C4kuDX9gJrAles4FtNqiL//59+NwE9ZnjT4ulVG+LdG6CaeKUfS1rpJ3AuhDU2Jo5YbWVv081i62L6K0G1pEWtUr3gQM678+6j6Gho2I7E1jj57HChm9WAxyJArtV3lIf1GIxWjPXeY+biOqw+pW0J5nke0NKTjhsNrBifmroa1Hd4GxRhIaKl2a6xLU0BtWFIn5DdVjrbUCPusFaCr9rA7tw5zcN/+wfS1d3gvrkyBNqWlRXDhNwrmXV6J2tQvhoJpO++NDnG/65xx56NJx0Mt764G0VW+OM9fWoZfWLopjysA54te9Et37Ucip/M+uoEdvLChuJHUOqGoX8FmslqBGtgd2me+lGeVjvNizkN2zegN5sZVKrpYk2ip1sSFhtlcvlVH55rZQQtlKaqKCFVXsMqeFCNzgR2GjMGn5g4fJNq7W+hvbA7s4/pNUeQ2o4F9bEB5aFtZ2i/HaK//WMYXVxcukmOuXQprC2u3um3d06tgQ2Oe/Q+GB3DVwIq9fog40NOxbTD9p8buxXmdRsYG3dfO4KJ1vWoUG7lm8O2nzeTAnhQYG1dfN5cr38NU8UUx9W36/sqWoZtLCYv1HYWqn17cQ1cP84t0XOGB62szCidqfNrf+tya17t8L3mg1ZJ67RT1y4iXJEf8ta50vcbVntK4qIt47thqwT1+gX6+vu3BGQQn4LxcPWbsg6cY1+4FLLqr4bnK5TgqbhpsombCc/NtZUPXA3r3G/uXRHQPUta7mSUlMUUasTIbM5qEl6b6Ic0d8NzlQatqy230kOiSJ+9WVX6sOaKVdU78RAhJbVfg+kuAO6YrG1cvW/lPWH9cMMYYUKThfyGwTWbq6cbGioD2suN+bt97krJ+Np5dL352Yhv6JzmFy327KmPVHOlbB68RfxsGo55dBVFEU4gNbVfsmg3mM2WIWU3/CUw2KRwghbJcerGcKqgq/7iEpXJVvWu4RVh70t6/i4vTdVxrbkd7dMWDWo+NLwHiiEVQUnek5OhDVdSc1LzYzwxClaVtvFNmI4EVYnjnWpFkbkCoV3z1TSMmneKxbemw4eJimK0ED3PW4iTp3BlMuNXwoeLm2/+upIME08KbBWsRitkbsxgejkgWlV4Re8slKQfuP7vuBghYJby24pcdaz2WBt7nrwZGRk5JiYH9ilWn1mfrO9IHL5oijncFgNE9iBuWC+uB+6wzSnLUt5wXf3Y5ErlwQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH83+5btVVg1zZUQAAAABJRU5ErkJggg==":dl,alt:c})}),Object(y.jsxs)("div",{className:"self-center mb-3","data-testid":"empty-state-subtitle",children:[Object(y.jsx)("p",{children:a}),Object(y.jsx)("p",{children:o})]}),Object(y.jsxs)("div",{className:"flex self-center","data-testid":"empty-state-button",children:[s&&d&&Object(y.jsx)("div",{className:"mr-2",children:Object(y.jsx)(m.Button,{icon:Object(y.jsx)(Fd,{className:"mr-1"}),iconLeft:!0,onClick:l,id:"overlay-create-property-btn",type:"outline",style:{height:"2.5rem",paddingRight:"1rem",paddingLeft:"1.13rem"},children:s})}),r()?Object(y.jsx)(m.Button,{icon:Object(y.jsx)(Eo.a,{style:{height:"0.8em"}}),iconLeft:!0,onClick:n,id:"overlay-create-property-btn",type:"primary",style:{height:"2.5rem",paddingRight:"1rem"},children:t}):Object(y.jsx)(y.Fragment,{})]}),i]})})}Md.defaultProps={onClick:function(){},setPermission:function(){return!0},children:Object(y.jsx)(y.Fragment,{}),imageToUse:"",text:"",importButtonName:null,onImportClick:function(){}};var Vd=Md,Bd=function(e,t){if(t){var n=t.match(/[^ ]+/g),a=[],r=e.filter((function(e){return function(e,t){return t.length,e.name.toLowerCase().includes(t[0].toLowerCase())}(e,n)}));return r&&r.forEach((function(e){a.push(e)})),a}return e},Ud=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e?t.filter((function(t){return e.includes(t.id)})).length:1},zd=function(e){return e?Object(ya.a)(e,"MMM d, yyyy"):null},Zd=function(e){var t=new Date(e);return null===t||void 0===t?void 0:t.toLocaleString("en-US",{month:"short",day:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0}).replace(/(\d{2}:\d{2})\s?(AM|PM)/,"$1$2").replace(/(\d{4}),/,"$1")},Yd=function(e){var t=new Date(e);return null===t||void 0===t?void 0:t.toLocaleString("en-US",{month:"short",day:"2-digit",year:"numeric"}).replace(/(\d{4}),/,"$1")},Hd=function(e){var t=e.children,n=e.testId;return Object(y.jsxs)("div",{"data-testid":n,className:"text-lg font-semibold text-charcoal text-opacity-90 mt-6",children:[t,Object(y.jsx)("hr",{className:"border-charcoal border-opacity-50"})]})};Hd.defaultProps={children:null,testId:"tile-list-group-heading"};var Gd=Hd,Wd=function(e){var t=e.children,n=e.title,a=e.totalItems,r=e.testId;return Object(y.jsxs)("div",{"data-testid":"".concat(r,"-group-container"),id:"".concat(r,"-group"),children:[Object(y.jsxs)(Gd,{testId:"".concat(r,"-group-title"),children:[n," (",a,")"]}),Object(y.jsx)("div",{"data-testid":"".concat(r,"-group-body"),className:"flex flex-wrap",children:t})]})};Wd.defaultProps={children:null,title:"",totalItems:0,testId:"default"};var qd,Jd,Kd,Qd,Xd=Wd,$d=n(333),eu=function(e){var t=e.colorPickerValue,n=e.setColorPickerValue,a=e.handleColorPickerToggle,r=t?{color:"rgba(".concat(t.r,",\n        ").concat(t.g,",\n        ").concat(t.b,",\n        ").concat(t.a,")")}:{};return Object(y.jsxs)("div",{className:"flex flex-col p-2",children:[Object(y.jsx)("div",{className:"text-sm text-gray-600",children:"Color Picker"}),t?Object(y.jsxs)("div",{className:"flex text-lg",style:r,children:[Object(y.jsx)("div",{children:"".concat(t.r,", ")}),Object(y.jsx)("div",{children:"".concat(t.g,", ")}),Object(y.jsx)("div",{children:"".concat(t.b,", ")}),Object(y.jsx)("div",{children:"".concat(t.a)})]}):null,Object(y.jsx)("div",{className:"mt-4",children:Object(y.jsx)(m.ColorPicker,{color:t,onChange:function(e){return n(e.rgb)}})}),Object(y.jsx)("div",{className:"mt-4",children:Object(y.jsx)(m.Input,{id:"label-name-input",label:"Label Name",maxLength:"20"})}),Object(y.jsxs)("div",{id:"cancel-color-picker-button",className:"flex justify-center my-3",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:a,children:"Cancel"}),Object(y.jsx)("div",{id:"save-from-color-picker-button",className:"ml-2",children:Object(y.jsx)(m.Button,{type:"primary",children:"Save"})})]})]})},tu=function(e){var t=e.handleColorPickerChange,n=e.colorDisplayValue,a=e.colorDisplayColors,r=e.handleCustomColorChange,c=e.customColorValue,i=e.customColors,o=e.handleColorSelectorToggle,s=e.handleColorPickerToggle;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"text-sm text-gray-600",children:"Color Picker"}),Object(y.jsx)(m.ColorPallet,{onChange:t,name:"color-picker-pallet",value:n,colors:a}),Object(y.jsx)("div",{className:"text-sm text-gray-600 mt-6",children:"Custom Colors"}),Object(y.jsx)(m.ColorPallet,{onChange:r,name:"custom-color-pallet",value:c,colors:i}),Object(y.jsx)("button",{id:"more-colors-button",type:"button",className:"text-gray-600 text-xs flex self-center",onClick:s,children:"More Colors >"}),Object(y.jsx)("div",{className:"mt-6",children:Object(y.jsx)(m.Input,{id:"color-display-label-name-input",label:"Label Name",maxLength:"20"})}),Object(y.jsxs)("div",{className:"flex justify-center my-3",children:[Object(y.jsx)(m.Button,{id:"color-display-cancel-button",type:"outline",onClick:o,children:"Cancel"}),Object(y.jsx)("div",{id:"color-display-save-button",className:"ml-2",children:Object(y.jsx)(m.Button,{type:"primary",children:"Save"})})]})]})},nu=function(e){var t=e.handleColorSelectorToggle,n=Object(a.useState)(),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(!1),s=Object(b.a)(o,2),l=s[0],d=s[1],u=function(){d((function(e){return!e}))},j=Object(a.useState)(),p=Object(b.a)(j,2),f=p[0],m=p[1],v=Object(a.useState)(),O=Object(b.a)(v,2),h=O[0],x=O[1];return Object(y.jsx)("div",{className:"flex flex-col p-2",children:l?Object(y.jsx)(eu,{colorPickerValue:h,setColorPickerValue:x,handleColorPickerToggle:u}):Object(y.jsx)(tu,{handleColorPickerChange:function(e){i(e.target.value)},colorPickerValue:c,colorDisplayColors:["rgb(209 82 105)","rgb(50 27 183)","rgb(50 27 183 / 0.7)"],handleCustomColorChange:function(e){m(e.target.value)},customColorValue:f,customColors:["rgb(209 82 105)","rgb(50 27 183)","rgb(50 27 183 / 0.7)"],handleColorSelectorToggle:t,handleColorPickerToggle:u})})},au=function(){return Object(y.jsx)("svg",{width:"13",height:"14",viewBox:"0 0 13 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M6.0529 13.0292C2.70916 13.0292 0 10.1134 0 6.51459C0 2.9158 2.70916 0 6.0529 0C9.39664 0 12.1058 2.9158 12.1058 6.51459C12.1058 10.1134 9.39664 13.0292 6.0529 13.0292ZM9.56749 5.77907C9.56749 5.6057 9.43569 5.46385 9.27461 5.46385H7.02918V3.04715C7.02918 2.87377 6.89738 2.73192 6.73629 2.73192H5.36951C5.20842 2.73192 5.07663 2.87377 5.07663 3.04715V5.46385H2.8312C2.67011 5.46385 2.53831 5.6057 2.53831 5.77907V7.25011C2.53831 7.42348 2.67011 7.56533 2.8312 7.56533H5.07663V9.98203C5.07663 10.1554 5.20842 10.2973 5.36951 10.2973H6.73629C6.89738 10.2973 7.02918 10.1554 7.02918 9.98203V7.56533H9.27461C9.43569 7.56533 9.56749 7.42348 9.56749 7.25011V5.77907Z",fill:"#718096"})})},ru=function(){var e=Object(a.useState)([]),t=Object(b.a)(e,2),n=t[0],r=t[1],c=function(e){r((function(t){var a=Object(ne.cloneDeep)(t);if(a.includes(e)){var r=n.indexOf(e);a.splice(r,1)}else a.push(e);return a}))};return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"mb-1",children:Object(y.jsx)(m.Tag,{onClick:function(){return c("critical")},selected:n.includes("critical"),color:"#C23234",children:"Critical"})}),Object(y.jsx)("div",{className:"mb-1",children:Object(y.jsx)(m.Tag,{onClick:function(){return c("high-priority")},selected:n.includes("high-priority"),color:"#D95032",children:"|> High Priority |>"})}),Object(y.jsx)("div",{className:"mb-1",children:Object(y.jsx)(m.Tag,{onClick:function(){return c("normal-priority")},selected:n.includes("normal-priority"),color:"#E99921",children:String.raw(qd||(qd=Object($d.a)(["/ Normal Priority"],["/\\ Normal Priority"])))})}),Object(y.jsx)("div",{className:"mb-1",children:Object(y.jsx)(m.Tag,{onClick:function(){return c("low-priority")},selected:n.includes("low-priority"),color:"#9664F0",children:String.raw(Jd||(Jd=Object($d.a)(["/ Low Priority"],["\\/ Low Priority"])))})}),Object(y.jsx)("div",{className:"mb-1",children:Object(y.jsx)(m.Tag,{onClick:function(){return c("rectangle-7")},selected:n.includes("rectangle-7"),color:"#46A79F",children:String.raw(Kd||(Kd=Object($d.a)(["* Rectangle 7"])))})}),Object(y.jsx)("div",{className:"mb-1",children:Object(y.jsx)(m.Tag,{onClick:function(){return c("to-do")},selected:n.includes("to-do"),color:"#0078CD",children:String.raw(Qd||(Qd=Object($d.a)(["[ ] To Do"])))})})]})},cu=function(e){var t=e.handleColorSelectorToggle;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{id:"tags-display",className:"p-2 mb-4",children:Object(y.jsx)(ru,{})}),Object(y.jsxs)("button",{id:"add-flag-button",type:"button",className:"border-t border-gray-400 py-2 flex justify-center items-center",onClick:t,children:[Object(y.jsx)(au,{}),Object(y.jsx)("div",{className:"ml-1 text-gray-600 text-sm",children:"Add New Label"})]})]})},iu=function(e){var t=e.className,n=e.handleFlagSelectorClose,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useRef)(),l=function(){o((function(e){return!e}))};function d(e){s.current&&s.current.contains(e.target)||n()}return Object(a.useEffect)((function(){return document.addEventListener("mousedown",d),function(){document.removeEventListener("mousedown",d)}})),Object(y.jsx)("div",{id:"flag-selector",ref:s,className:"absolute z-10 flex flex-col w-64 m-4 bg-white shadow border rounded border-gray-400 ".concat(t," text-left"),children:i?Object(y.jsx)(nu,{handleColorSelectorToggle:l}):Object(y.jsx)(cu,{handleColorSelectorToggle:l})})};iu.defaultProps={className:""};var ou=iu,su=function(e){var t=e.title,n=e.subtitle,a=e.onAction,r=e.testId,c=e.children,i=e.menuItems,o=e.flagSelectorVisible,s=e.handleFlagSelectorClose,l=e.linkTo,d=e.className,u=e.titleColor,b=e.contextMenuHide,p=e.runningProcesses;return Object(y.jsx)("div",{"data-testid":"".concat(r,"-card"),className:"w-full pr-8 mt-6 mb-2 lg:w-1/4 md:w-1/2",children:Object(y.jsx)(ll,{className:"".concat(d),children:Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex justify-between w-full",children:[Object(y.jsxs)("div",{className:"w-5/6",children:[Object(y.jsx)("div",{"data-testid":"".concat(r,"-card-name"),className:"font-semibold truncate text-syngenta-navy",style:{color:u},children:Object(y.jsx)(j.b,{to:l,children:t||"unnamed"})}),Object(y.jsx)("div",{"data-testid":"".concat(r,"-card-crop"),className:"text-sm text-neutral-300",children:n})]}),Object(y.jsxs)("div",{"data-testid":"".concat(r,"-card-options-menu"),className:"h-8",children:[b?Object(y.jsx)(m.Button,{type:"link-default",onClick:a,children:"View"}):p?Object(y.jsx)(m.Spinner,{size:"sm"}):Object(y.jsx)(Wo,{onAction:a,options:i}),o?Object(y.jsx)(ou,{className:"-ml-64",handleFlagSelectorClose:s}):null]})]}),c]})})})};su.defaultProps={title:"",subtitle:"",onAction:function(){},testId:"default",children:null,menuItems:[],flagSelectorVisible:!1,handleFlagSelectorClose:function(){},linkTo:"/",className:"",titleColor:"",contextMenuHide:!1,runningProcesses:!1};var lu=su,du=function(e){var t=e.id,n=e.title,a=e.value,r=e.testId,c=e.hideValue;return Object(y.jsxs)("div",{"data-testid":"".concat(r,"-card-detail"),className:"w-1/2 my-2 text-neutral-300",children:[Object(y.jsx)("div",{className:"font-bold text-xxs",children:n}),Object(y.jsx)("div",{id:t,className:"truncate",children:c?"":a})]})};du.defaultProps={testId:Object(cc.generate)(),hideValue:!1};var uu=du,bu=["children","className"],ju=r.a.forwardRef((function(e,t){var n=e.children,a=e.className,r=Object(te.a)(e,bu);return Object(y.jsx)("div",Object(I.a)(Object(I.a)({"data-testid":"clickable-div",className:"outline-none ".concat(a),role:"button",tabIndex:0,ref:t},r),{},{children:n}))}));ju.propTypes={onClick:wc.a.func.isRequired,onKeyDown:wc.a.func,onBlur:wc.a.func,onMouseEnter:wc.a.func,onMouseLeave:wc.a.func,children:wc.a.node.isRequired,className:wc.a.string},ju.defaultProps={onKeyDown:ne.noop,onBlur:ne.noop,onMouseEnter:ne.noop,onMouseLeave:ne.noop,className:""};var pu=ju,fu=function(e){var t=e.position,n=e.ariaLabel,r=e.top,c=e.delay,i=e.msg,o=e.component,s=Object(a.useState)(null),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(!1),p=Object(b.a)(j,2),f=p[0],v=p[1];return Object(y.jsxs)(pu,{onMouseEnter:function(){return u(setTimeout((function(){return v(!0)}),c))},onMouseLeave:function(){return clearTimeout(d)||v(!1)},className:"gr-text-left",children:[Object(y.jsx)("div",{className:"relative","aria-label":n,children:Object(y.jsx)("div",{className:"absolute",style:{top:r},children:Object(y.jsx)(m.Popup,{position:t,open:f,hasArrow:!0,trigger:Object(y.jsx)("div",{}),children:Object(y.jsx)("div",{className:"whitespace-no-wrap",children:i})})})}),Object(y.jsx)("div",{children:o})]})},mu=function(e){var t=e.cropSeasons,n=e.handleAction,a=e.seasonPageNumber,r=e.handlePageChange,c=e.cropSeasonsLength,i=function(e){return e.crops?e.crops.map((function(t,n){return n!==e.crops.length-1?"".concat(t.name,", "):"".concat(t.name)})):"No Crop"};return Object(y.jsx)(y.Fragment,{children:t&&c?Object(y.jsxs)("div",{"data-testid":"crop-seasons-tile-board",children:[Ho(c||0,a,r),Object(y.jsx)("div",{className:"pb-1",children:" "}),function(){var e=t.filter((function(e){return e.active})).length;return Object(y.jsx)(Xd,{title:"Active Seasons",totalItems:e,testId:"crop-season-active",children:t.map((function(e){var t;return e.active&&Object(y.jsx)(lu,{linkTo:"".concat(Cc.cropSeasons,"/").concat(e.id,"/view"),testId:"crop-season",title:e.name,subtitle:Object(y.jsx)(fu,{position:"right",ariaLabel:"Crops List",delay:1e3,top:"0",msg:Object(y.jsx)("div",{className:"w-96",children:i(e)}),component:Object(y.jsx)("div",{className:"truncate",children:i(e)})}),onAction:function(t){n(t,e)},menuItems:os,children:Object(y.jsxs)("div",{"data-testid":"crop-season-card-details",className:"flex flex-wrap w-full",children:[Object(y.jsx)(uu,{id:"crop-season-total-area",title:"Total Area",value:(null===(t=e.totalArea)||void 0===t?void 0:t.totalArea)||"0",testId:"crop-season"}),Object(y.jsx)(uu,{id:"crop-season-created",title:"Created",value:zd(e.createdDateEpoch),testId:"crop-season"}),Object(y.jsx)(uu,{id:"crop-season-start",title:"Start Date",value:zd(e.startDateEpoch),testId:"crop-season"}),Object(y.jsx)(uu,{id:"crop-season-end",title:"End Date",value:zd(e.endDateEpoch),testId:"crop-season"})]})},e.id)}))})}(),function(){var e=t.filter((function(e){return!1===e.active})).length;return Object(y.jsx)(Xd,{title:"Inactive Seasons",totalItems:e,testId:"crop-season-inactive",children:t.map((function(e){var t;return!1===e.active&&Object(y.jsx)(lu,{linkTo:"".concat(Cc.cropSeasons,"/").concat(e.id,"/view"),testId:"crop-season",title:e.name,className:"bg-neutral-100",titleColor:"#696F88",subtitle:Object(y.jsx)(fu,{position:"right",ariaLabel:"Crops List",delay:1e3,top:"0",msg:Object(y.jsx)("div",{className:"w-96",children:i(e)}),component:Object(y.jsx)("div",{className:"truncate",children:i(e)})}),onAction:function(t){n(t,e)},menuItems:os,children:Object(y.jsxs)("div",{"data-testid":"crop-season-card-details",className:"flex flex-wrap w-full",children:[Object(y.jsx)(uu,{id:"crop-season-total-area",title:"Total Area",value:(null===(t=e.totalArea)||void 0===t?void 0:t.totalArea)||"0",testId:"crop-season"}),Object(y.jsx)(uu,{id:"crop-season-created",title:"Created",value:zd(e.createdDateEpoch),testId:"crop-season"}),Object(y.jsx)(uu,{id:"crop-season-start",title:"Start Date",value:zd(e.startDateEpoch),testId:"crop-season"}),Object(y.jsx)(uu,{id:"crop-season-end",title:"End Date",value:zd(e.endDateEpoch),testId:"crop-season"})]})},e.id)}))})}(),Ho(c||0,a,r)]}):Object(y.jsx)(Js.LandingEmpty,{listType:"any crop seasons",routePath:"".concat(Cc.cropSeasons,"/create")})})};mu.defaultProps={cropSeasons:[],handleAction:function(){}};var vu=mu,Ou=function(e){var t=e.children,n=e.roundedTo,a=e.units;return Object(y.jsxs)(y.Fragment,{children:[Number(t).toFixed(n),a&&" ".concat(a)]})};Ou.defaultProps={roundedTo:2,units:null},Ou.propTypes={children:wc.a.number.isRequired,roundedTo:wc.a.number,units:wc.a.string};var hu=Ou,xu=(n(1356),function(e){var t,n=e.cropSeason,a=e.onAction,r=e.selectedMember,c=e.financialAccess,i=function(e){return e.crops?e.crops.map((function(t,n){return n!==e.crops.length-1?"".concat(t.name,", "):"".concat(t.name)})):"No Crop"};return Object(y.jsxs)(m.Table.Row,{id:"".concat(n.active?"":"bg-neutral-100"),children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("span",{className:"text-sm font-bold",style:{color:n.active?"":"#696F88"},children:Object(y.jsx)(j.b,{to:"".concat(Cc.cropSeasons,"/").concat(n.id,"/view"),children:n.name})})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("span",{style:{color:n.active?"":"#696F88"},children:n.active?"Active":"Inactive"})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(fu,{position:"right",ariaLabel:"Crops List",delay:1e3,top:"0",msg:Object(y.jsx)("div",{className:"w-96",children:i(n)}),component:Object(y.jsx)("div",{className:"truncate w-60",style:{color:n.active?"":"#696F88"},children:i(n)})})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("span",{style:{color:n.active?"":"#696F88"},children:Object(y.jsx)(hu,{children:(null===(t=n.totalArea)||void 0===t?void 0:t.totalArea)||"0"})})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("span",{style:{color:n.active?"":"#696F88"},children:zd(n.startDateEpoch)})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("span",{style:{color:n.active?"":"#696F88"},children:zd(n.endDateEpoch)})}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)("div",{className:"mr-8",style:{color:n.active?"":"#696F88"},children:zd(n.createdDateEpoch)}),Object(y.jsx)("div",{"data-testid":"crop-season-table-options-menu",className:"absolute right-0 flex-none w-10",children:Object(y.jsx)(Wo,{onAction:function(e){return a(e,n)},options:os,userPermissions:{role:null===r||void 0===r?void 0:r.role,financialAccess:c}})})]})]})});xu.defaultProps={selectedMember:{}};var gu=xu,Cu=[{field:"name",title:"Season",sortable:!0},{field:"active",title:"Season status",sortable:!0},{field:"crop",title:"Crop",sortable:!0},{field:"totalArea",title:"Total Area",sortable:!0},{field:"startDate",title:"Start Date",sortable:!0},{field:"endDate",title:"End Date",sortable:!0},{field:"createdAt",title:"Created",sortable:!0}],yu=function(e){var t=e.cropSeasons,n=e.allCropSeasons,r=e.tableSort,c=e.handleAction,i=e.selectedMember,o=e.financialAccess,s=e.seasonPageNumber,l=e.handlePageChange,d=e.cropSeasonsLength,u=Object(a.useState)(),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useState)(),v=Object(b.a)(m,2),O=v[0],h=v[1];return Object(y.jsx)("div",{className:"mx-2 my-4 min-w-content","data-testid":"cropSeasons-table",style:{minWidth:"min-content"},children:Object(y.jsxs)(ll,{children:[Ho(d||0,s,l),Object(y.jsx)(ol,{listType:"Crop Seasons",routePath:Cc.cropSeasons,items:t,tableColumns:Cu,onSort:function(e,t){f(e),h(t),r(function(e,t,n){if(!n)return e;var a=Object(ne.cloneDeep)(e);switch(t){case"name":return Object(ne.orderBy)(a,[function(e){return e.name.toLowerCase()}],n);case"active":return Object(ne.orderBy)(a,[function(e){return e.active}],n);case"crop":return Object(ne.orderBy)(a,[function(e){var t;return null===(t=e.crops)||void 0===t?void 0:t.map((function(e){return e.name}))}],n);case"totalArea":return Object(ne.orderBy)(a,[function(e){var t;return null===(t=e.totalArea)||void 0===t?void 0:t.totalArea}],n);case"startDate":return Object(ne.orderBy)(a,[function(e){return e.startDateEpoch}],n);case"endDate":return Object(ne.orderBy)(a,[function(e){return e.endDateEpoch}],n);case"createdAt":return Object(ne.orderBy)(a,[function(e){return e.createdDateEpoch}],n);default:return a}}(n,e,t))},sortBy:p,sortDir:O,children:function(e){return e.rows.map((function(e){return Object(y.jsx)(gu,{cropSeason:e,onAction:c,selectedMember:i,financialAccess:o},e.id)}))}}),Object(y.jsx)("div",{className:"pb-12",children:Ho(d||0,s,l)})]})})};yu.defaultProps={cropSeasons:[],handleAction:function(){},selectedMember:{}};var Pu=yu,Au=function(e){var t=Object(a.useState)(zn(e,{urlVersion:"/v1"}));return Object(b.a)(t,1)[0]},Su=function(){var e=Au("plans"),t=Object(a.useContext)(ac),n=Object(b.a)(t,2)[1],r=Object(a.useState)({}),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(!0),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useCallback)((function(){var t=e.fetch(),a=t.promise,r=t.cancel;return a.then((function(e){var t=e.data;o(t.results)})).catch(Ae.default).catch((function(e){uc(n)(e)})).finally((function(){return u(!1)})),r}),[n,e]);Object(a.useEffect)((function(){var e=j();return function(){e()}}),[j]);var p=Object(a.useCallback)((function(t){return e.delete(t._id).promise.then(j)}),[e,j]);return{plans:i,loading:d,loadPlans:j,deletePlan:p}},Tu=function(e){var t=e.open,n=e.close,r=e.seasonName,c=e.seasonId,i=Object(a.useContext)(ac),o=Object(b.a)(i,2)[1],s=Object(p.h)(),l=Object(a.useState)(null),d=Object(b.a)(l,2),u=d[0],j=d[1],f=Object(a.useState)(!0),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)(!1),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Su(),S=function(){var e;return null===A||void 0===A||null===(e=A.plans)||void 0===e?void 0:e.some((function(e){return e.cropSeasonIds.includes(c)}))},T=function(e){j(e),h(!0)},N=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(P(!0),!S()){e.next=6;break}P(!1),T(" This crop season has a plan attached thus it can not be deleted."),e.next=9;break;case 6:return t=$t.delete(c),a=t.promise,e.next=9,a.then((function(){o({type:hr,payload:c}),n(!0),s.push(Cc.cropSeasons)})).catch(Ae.default).catch((function(e){"Request failed with status code 403"===e.message?T(" This crop season has a task attached thus it can not be deleted."):T(e.message)})).finally((function(){return P(!1)}));case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),E=function(){h(!1),n()};return Object(y.jsxs)(ao,{open:t,title:r&&"Delete this Crop Season?",close:E,cancelLabel:"Cancel",confirmLabel:"Delete",onCancel:function(){return E()},type:"error",onConfirm:function(){return N()},isSaving:C,children:[Object(y.jsxs)("div",{testId:"crop-seasons-deleteModal",className:"pr-6",children:["Delete the crop season ",r,"?"]}),O?Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){h(!1)},children:u}):null]})};Tu.defaultProps={seasonId:"",seasonName:""};var Nu=Object(p.l)(Tu),Eu=Sd(bd,"tile"),wu=function(e,t){var n=t*wo,a=wo+n;return e.slice(n,a)},_u=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2),n=t[0],r=n.loggedInUserOrgPermission,c=n.loadingOrg,i=n.isGlobalCropSeasonLoading,o=t[1],s=Eu.get(),l=Object(a.useState)(null),d=Object(b.a)(l,2),u=d[0],j=d[1],f=zi(u,300),v=dd({useFullResponse:!0}),O=v.cropSeasons,h=v.findCropSeason,x=v.reloadCropSeasons,g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(null),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)(!1),_=Object(b.a)(w,2),R=_[0],I=_[1],D=Object(a.useState)(s),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(p.h)(),V=Object(a.useState)(O),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=Object(a.useState)(!1),Y=Object(b.a)(Z,2),H=Y[0],G=Y[1],W=Object(a.useState)(),q=Object(b.a)(W,2),J=q[0],K=q[1],Q=Object(a.useState)(0),X=Object(b.a)(Q,2),$=X[0],ee=X[1],te=Object(a.useState)(O),ae=Object(b.a)(te,2),re=ae[0],ce=ae[1];Object(a.useEffect)((function(){G(!Object(ne.isEmpty)(r))}),[r]),Object(a.useEffect)((function(){"Full control"!==(null===r||void 0===r?void 0:r.role)&&"View Only"!==(null===r||void 0===r?void 0:r.role)||Object.prototype.hasOwnProperty.call(r,"financialAccess")?K(null===r||void 0===r?void 0:r.financialAccess):K("none")}),[r]),Object(a.useEffect)((function(){var e="tile"===L?function(e){return Object(ne.orderBy)(e,"active","desc")}(O):re||O;if(f){var t=Bd(e,f);z(wu(t,$))}else if(e){var n=Bd(e,null);z(wu(n,$))}}),[O,f,$,L,re]);Object(a.useEffect)((function(){return"tile"===L&&o({type:br,payload:"#F5F8FC"}),function(){o({type:br,payload:null})}}),[L,o]);Object(a.useEffect)((function(){R&&(x(),h(),I(!1))}),[R]);var ie=function(e,t){var n=t.id,a=t.name;({view:function(){M.push("".concat(Cc.cropSeasons,"/").concat(n,"/view"))},edit:function(){M.push("".concat(Cc.cropSeasons,"/").concat(n))},delete:function(){A(!0),E({id:n,name:a}),I(!1)}})[e]()},oe=function(e){ee(e)},se=cr(null===r||void 0===r?void 0:r.role,"Full control");return Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"cropSeasons",children:[Object(y.jsx)(lo,{onOrganizationSelect:function(){I(!0),ee(0),j(null)},hideCropSeasonDropdown:!0,children:Object(y.jsx)(lo.Item,{title:"Crop Seasons",value:"All Crop Seasons",isLast:!0})}),c||!H||i?Object(y.jsx)(m.Spinner,{ariaLabel:"spinner"}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex items-center justify-between",children:[Object(y.jsx)(To,{id:"crop-season-search-input",filterItems:[{key:"Seasons",value:"Seasons"},{key:"Farms",value:"Farms"},{key:"Crops",value:"Crops"},{key:"Flags",value:"Flags"}],selectedItems:[],name:"search_crop_seasons",placeholder:"Search Crop Seasons",onChange:function(e){j(e.target.value),ee(0)},onFilterChange:ne.noop,onChangeLabel:ne.noop,onChangeProductType:ne.noop,onChangeTaskType:ne.noop,onDateRangeChange:function(e){var t=e.target.value;2===t.length?z(function(e,t){return e.filter((function(e){return t[0].getTime()<=e.createdDateEpoch&&t[1].getTime()>=e.createdDateEpoch}))}(O,t)):z(O)},showCropSeason:!1}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)(Rd,{testId:"crop-seasons-view-toggle",view:L,changeView:function(e){F(e),Eu.save(e)}}),se&&Object(y.jsx)("div",{className:"pl-2 whitespace-no-wrap",children:Object(y.jsx)(m.Button,{type:"primary",id:"add-crop-season-button",onClick:function(e){e.stopPropagation(),M.push("".concat(Cc.cropSeasons,"/create"))},icon:Object(y.jsx)(Eo.a,{}),children:"Create Season"})})]})]}),U&&O.length>0?Object(y.jsx)("div",{children:"tile"===L?Object(y.jsx)(vu,{cropSeasons:U,handleAction:ie,seasonPageNumber:$,handlePageChange:oe,cropSeasonsLength:O.length}):Object(y.jsx)(Pu,{cropSeasons:U,allCropSeasons:O,tableSort:function(e){ce(e),z(wu(e,$))},handleAction:ie,selectedMember:r,financialAccess:J,seasonPageNumber:$,handlePageChange:oe,cropSeasonsLength:O.length})}):Object(y.jsx)(Vd,{className:"w-1",buttonText:"Create Season",onClick:function(){return M.push("".concat(Cc.cropSeasons,"/create"))},subtitle:"We were unable to find any crop seasons under this organization.",setPermission:function(){return se}}),Object(y.jsx)(Nu,{open:P,close:function(e){e&&h(),A(!1)},seasonName:null===N||void 0===N?void 0:N.name,seasonId:null===N||void 0===N?void 0:N.id})]})]})},Ru=n(107),Iu=function(e){var t=Object(a.useState)(),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)(!0),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useContext)(ac),j=Object(b.a)(d,2)[1],p=e?"".concat(u.b,"/crops/").concat(e,"?location=@CWF"):"".concat(u.b,"/crops?location=@CWF");return Object(a.useEffect)((function(){J.a.get(p,{headers:{common:{Authorization:"Bearer ".concat(Ve())}}}).then((function(t){c(e?t.data:Object(Ru.a)(t.data.content)),l(!1)})).catch(Ae.default).catch(uc(j))}),[j,p,e]),{crops:r,loading:s}};Iu.defaultProps={id:null},Iu.propTypes={id:wc.a.string};var Du=Iu,ku=function(e){var t=e.error,n=e.onReset,a=e.children;return Object(y.jsx)(y.Fragment,{children:t?Object(y.jsx)(Rc,{error:t,onReset:n}):a})};ku.defaultProps={error:null,onReset:function(){}};var Lu=ku,Fu=n(16),Mu=Fu.e().shape({date:Fu.a().of(Fu.c()).nullable().required(),name:Fu.f().trim().required("Required")}),Vu=n(31).default,Bu=n(13).default,Uu=function(){var e=Object(Y.a)(G.a.mark((function e(t,n,a,r,c,i){var o;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=Vu.get("".concat(u.d,"/v2/base/cropseason/").concat(t),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:a}),Authorization:"Bearer ".concat(n)}}),e.next=3,o.then((function(e){var t=e.data,n=t;n.date=[new Date(t.startDate),new Date(t.endDate)];var a=[];t.cropZones.forEach((function(e){return a.push(e.cropzoneId)})),n.cropZones=a,n.propertiesGroupBy="property",r(n)})).catch(Bu).catch((function(e){r({}),c(e.response)})).finally((function(){return i(!0)}));case 3:case"end":return e.stop()}}),e)})));return function(t,n,a,r,c,i){return e.apply(this,arguments)}}(),zu=Uu,Zu=n(534),Yu=n.n(Zu),Hu=n(55),Gu=n(437),Wu=n(2844),qu=n(791),Ju=n(179),Ku=n(293),Qu=n(334),Xu={onSetup:function(e){var t=this,n={initiallySelectedFeatureIds:e.featureIds||[]};return this.setSelected(n.initiallySelectedFeatureIds.filter((function(e){return void 0!==t.getFeature(e)}))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),n},fireActionable:function(){var e=this,t=this.getSelected(),n=t.filter((function(t){return e.isInstanceOf("MultiFeature",t)})),a=!1;if(t.length>1){a=!0;var r=t[0].type.replace("Multi","");t.forEach((function(e){e.type.replace("Multi","")!==r&&(a=!1)}))}var c=n.length>0,i=t.length>0;this.setActionableState({combineFeatures:a,uncombineFeatures:c,trash:i})},getUniqueIds:function(e){return e.length?e.map((function(e){return e.properties.id})).filter((function(e){return void 0!==e})).reduce((function(e,t){return e.add(t),e}),new qu.a).values():[]},stopExtendedInteractions:function(){this.map.dragPan.enable()},onStop:function(){Qu.a.enable(this)},onMouseMove:function(e){return this.stopExtendedInteractions(e),!0},onMouseOut:function(){return!0},onMapSelect:function(e,t){return Ku.d(t)?this.clickAnywhere(e,t):Ku.b(t)?this.clickOnFeature(e,t):null},onTap:function(e,t){return this.onMapSelect(e,t)},onClick:function(e,t){return this.onMapSelect(e,t)},clickAnywhere:function(e){var t=this,n=this.getSelectedIds();n.length&&(this.clearSelectedFeatures(),n.forEach((function(e){return t.doRender(e)}))),Qu.a.enable(this),this.stopExtendedInteractions(e)},startOnActiveFeature:function(e,t){this.stopExtendedInteractions(e),this.doRender(t.featureTarget.properties.id)},clickOnFeature:function(e,t){var n=this;Qu.a.disable(this),this.stopExtendedInteractions(e);var a=Ku.c(t),r=this.getSelectedIds(),c=t.featureTarget.properties.id,i=this.isSelected(c);i&&a?(this.deselect(c),1===r.length&&Qu.a.enable(this)):!i&&a?this.select(c):i||a||(r.forEach((function(e){return n.doRender(e)})),this.setSelected(c)),this.doRender(c)},onMouseDown:function(e,t){return Ku.a(t)&&this.startOnActiveFeature(e,t)},onTouchStart:function(e,t){return Ku.a(t)&&this.startOnActiveFeature(e,t)},onMouseUp:function(e){this.stopExtendedInteractions(e)},toDisplayFeatures:function(e,t,n){t.properties.active=this.isSelected(t.properties.id)?Ju.a.ACTIVE:Ju.a.INACTIVE,n(t),this.fireActionable()}},$u=Xu,eb=n(90),tb=n(792),nb=n.n(tb),ab=(n(1408),n(793)),rb=n.n(ab),cb=(n(1437),n(1438),function(e){var t=e.open,n=e.itemType,a=e.onCancel,r=e.onDelete,c=e.type,i="Location?"===n,o="Delete ".concat(n).concat("Load"===n?"?":""),s=i?"Are you sure you want to delete this location":"Are you sure you want to delete this ".concat(n.toLowerCase(),"? All of the data\n  associated with this ").concat(n.toLowerCase()," will be lost.");return Object(y.jsx)(ao,{open:t,title:o,close:a,cancelLabel:"Cancel",confirmLabel:"Delete",onCancel:a,type:c,onConfirm:r,children:Object(y.jsx)("div",{className:"pr-6",children:s})})});cb.defaultProps={open:!1,itemType:"Item",type:"confirmation"};var ib=cb,ob="#fff",sb="#31B4F2",lb=[-98.5795,39.8283],db=[16],ub=[4],bb={speed:1.8,maxDuration:1},jb="create",pb="update",fb="delete",mb=8,vb=46,Ob=27,hb="field",xb="import_feature",gb="add_feature",Cb="remove_feature",yb="field",Pb="cropZone",Ab="lastCoordinatesStored",Sb="map",Tb="info",Nb="costAnalysis",Eb=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],paint:{"fill-color":sb,"fill-outline-color":ob,"fill-opacity":.3}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","active","true"],["==","$type","Polygon"]],paint:{"fill-color":sb,"fill-outline-color":sb,"fill-opacity":.3}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":sb}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":ob,"line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","active","true"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":sb,"line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-line-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","LineString"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":ob,"line-width":2}},{id:"gl-draw-line-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":sb,"line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-polygon-and-line-vertex-stroke-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":sb}},{id:"gl-draw-point-point-stroke-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-opacity":1,"circle-color":"#fff"}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":ob}},{id:"gl-draw-point-stroke-active",type:"circle",filter:["all",["==","$type","Point"],["==","active","true"],["!=","meta","midpoint"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":5,"circle-color":sb}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","mode","static"],["==","$type","Polygon"]],paint:{"fill-color":"#404040","fill-outline-color":"#404040","fill-opacity":.3}},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","mode","static"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","mode","static"],["==","$type","LineString"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","mode","static"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#404040"}}],wb=function(e){var t=e.target.getBoundingClientRect();return[e.clientX-t.left,e.clientY-t.top/2]},_b=function(e,t){var n=e.project(t),a=e.queryRenderedFeatures(n),r=Object(ne.uniqBy)(a,"properties.grisId");return Object(b.a)(r,1)[0]},Rb=n(794),Ib={drawDistance:null,drawArea:null,coordinates:null,feature:null},Db=Object(Rb.a)((function(){return Object(a.useState)(Ib)})),kb=Db.Provider,Lb=Db.useTracked,Fb=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"simple_select",t=Lb(),n=Object(b.a)(t,2),r=n[1],c=Object(a.useCallback)((function(e){r((function(t){return Object(I.a)(Object(I.a)({},t),{},{drawDistance:e})}))}),[r]),i=Object(a.useCallback)((function(e){r((function(t){return Object(I.a)(Object(I.a)({},t),{},{drawArea:e})}))}),[r]),o=Object(a.useCallback)((function(e){r((function(t){return Object(I.a)(Object(I.a)({},t),{},{coordinates:e})}))}),[r]),s=function(e,t){var n=t.current.draw.getAll(),a=n.features.length-1,r=n.features[a].geometry.coordinates[0].length-3,c=n.features[a].geometry.coordinates[0][r];if(c){var i=e.lngLat.wrap(),o=[];o[0]=i.lng,o[1]=i.lat;var s=Object(W.distance)(Object(W.point)(c),Object(W.point)(o),{units:"kilometers"});return Object(W.convertLength)(s,"kilometers","feet").toFixed(2)}return null},l=function(e,t){var n=t.current.draw.getAll(),a=n.features.length-1;if(!n.features[a].geometry.coordinates[0][0])return null;var r=Object(W.center)(n.features[a]).geometry.coordinates;if(r){var c=e.lngLat.wrap(),i=[];i[0]=c.lng,i[1]=c.lat;var o=Object(W.distance)(Object(W.point)(r),Object(W.point)(i),{units:"kilometers"});return Object(W.convertLength)(o,"kilometers","feet").toFixed(2)}return null},d=function(e,t){var n,a=null===(n=t.current)||void 0===n?void 0:n.draw.getMode(),r="draw_polygon"===a||"drag_circle"===a&&e.lngLat,o=t.current.draw.getAll(),d=o.features.length-1;if(r){if("draw_polygon"===a){var u=s(e,t);u&&c(u)}if("drag_circle"===a){var b=l(e,t);b&&c(b)}}if("simple_select"!==a&&e.lngLat&&o.features[d].geometry.coordinates[0].length>3){var j=Object(W.coordAll)(o.features[d].geometry),p=Object(W.polygon)([j]),f=Object(W.area)(p),m=Object(W.convertArea)(f,"meters","acres").toFixed(2);i(m)}},u=function(e){c(null),i(null);var t=wb(e.originalEvent);o(t)};return Object(a.useEffect)((function(){"draw_polygon"!==e&&"drag_circle"!==e&&(c(null),i(null))}),[e,c,i,o]),{onMapMouseMoved:d,onMapMouseDown:u}},Mb=function(e,t,n,a){return{onDrawChanged:function(r,c){c===fb?a(!0):c===jb?function(t){n(t[0],(function(t){e([t])}))}(r):c===pb&&function(e){var n=e[0].id;t(n,e)}(r)}}},Vb=function(e){var t=e.position,n=e.ariaLabel,a=e.msg,r=e.showPopup;return Object(y.jsx)("div",{className:"inherit bg-black",children:Object(y.jsx)("div",{className:"absolute",style:{left:"50%",top:"50%"},children:Object(y.jsx)(m.Popup,{ariaLabel:n,position:t,align:"center",open:r,containerClasses:"bg-black",trigger:Object(y.jsx)("div",{}),children:Object(y.jsx)("div",{className:"bg-black text-white whitespace-no-wrap -m-3 p-3 text-xl rounded",children:a})})})})},Bb=function(e){return e.split(",").reverse().join()},Ub=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return Object.entries(e).find((function(e){var n=Object(b.a)(e,1)[0];return t.find((function(e){return n.toLowerCase().includes(e)&&!n.toLowerCase().includes("_id")}))}))||[]},zb=function(e,t,n){return function(e,t){return Object.entries(Object(ne.groupBy)(e,t))}(e,t).flatMap((function(e){var a,r=Object(b.a)(e,2),c=r[0],i=r[1];if(!n)return i.map((a=t,function(e){return{name:e[a],type:a,features:[e.feature]}}));var o=function(e,t){return{items:t(e)}}(i,n);return function(e,t,n){return Object(I.a)({name:"undefined"===e?void 0:e,type:t,features:n.items.flatMap((function(e){return e.features}))},n)}(c,t,o)}))},Zb=function(e){return Object(ne.last)(Ub(e.properties,["farm"]))},Yb=function(e){return Object(ne.last)(Ub(e.properties,["field","ldblabel"]))},Hb=function(e){return Object(ne.last)(Ub(e.properties,["crop"]))},Gb=function(e){var t=function(e){var t=Array.isArray(e)?null===e||void 0===e?void 0:e.flatMap((function(e){return e.features})):null===e||void 0===e?void 0:e.features,n=null===t||void 0===t?void 0:t.map((function(e){return{farm:Zb(e),field:Yb(e),cropZone:Hb(e),feature:e}}));return zb(n,"farm",(function(e){return zb(e,"field",(function(e){return zb(e,"cropZone")}))}))}(e);return null===t||void 0===t?void 0:t.flatMap((function(e){return e.items.map((function(t){return Object(I.a)(Object(I.a)({},t),{},{farmName:e.name})}))}))},Wb=function(e){return function(t){return t.index===e}},qb=function(e,t,n){var a=e.find(Wb(t)),r=e.find((function(e){var t=e.index,a=e.event;return t===n&&a}));return!!r&&!(null===a||void 0===a||!a.checked)!==!(null===r||void 0===r||!r.checked)},Jb=function(e,t,n){var a=e.find(Wb(t));return{index:n,checked:null===a||void 0===a?void 0:a.checked}},Kb="kilometers",Qb=.001,Xb=function(e,t){return("Polygon"===t.type||"MultiPolygon"===t.type)&&"LineString"===e.type},$b=function(e,t){return Object(W.lineIntersect)(t,e).features.length>0},ej=function(e,t){var n=Object(W.getCoords)(e);return!Object(W.booleanWithin)(Object(Hu.point)(n[0]),t)&&!Object(W.booleanWithin)(Object(Hu.point)(n[n.length-1]),t)},tj=function(e,t,n){var a=Object(W.lineIntersect)(t,e);return n&&0===a.features.length||!n&&a.features.length>0},nj=function(e,t){for(var n=[],a=0;a<e.coordinates.length;a+=1)n.push(e.coordinates[a]);for(var r=t.geometry.coordinates.length-1;r>=0;r-=1)n.push(t.geometry.coordinates[r]);n.push(e.coordinates[0]);var c=Object(Hu.lineString)(n);return Object(W.lineToPolygon)(c)},aj=function(e,t){var n,a,r,c,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],s=[],l=[],d=null;if(!Xb(t,e)||!$b(t,e)||!ej(t,e))return d;l[0]=Object(W.lineOffset)(t,Qb,{units:Kb}),l[1]=Object(W.lineOffset)(t,-.001,{units:Kb});for(var u=0;u<=1;u+=1){n=(u+1)%2,a=nj(t,l[u]),r=Object(W.difference)(e,a),o=[];for(var b=0;b<r.geometry.coordinates.length;b+=1)c=Object(Hu.polygon)(r.geometry.coordinates[b]),tj(l[n],c,i)&&o.push(c.geometry.coordinates);o.forEach((function(e){s.push(Object(Hu.polygon)(e))}))}return s.length>0&&(d=Object(Hu.featureCollection)(s)),d},rj="FeatureCollection",cj="Feature",ij=function(e){return e&&e.type===rj},oj=function(e){return e&&e.type===cj},sj=function(e){if(!e||0===e.length)return[];var t=Object(ne.flatten)(e),n=t.filter(ij),a=t.filter(oj),r=a.length?[Object(Hu.featureCollection)(a)]:[];return[].concat(Object(v.a)(n),r)},lj=function(e){return e&&0!==e.length?Object(ne.flatten)(e).reduce((function(e,t){return ij(t)?e.concat(t.features):(oj(t)&&e.push(Object(W.clone)(t)),e)}),[]):[]},dj=function(e){var t=e.draw.getSelectedIds();return t&&0!==t.length?(e.draw.delete(t),t):null},uj=function(e){var t=e.draw.getSelectedIds(),n=function(e){var t=Object(b.a)(e,2),n=t[0],a=t[1];return n&&a?Object(W.booleanContains)(n,a)?{containerFeature:n,containedFeature:a}:Object(W.booleanContains)(a,n)?{containerFeature:a,containedFeature:n}:{}:{}}(t.map((function(t){return e.draw.get(t)}))),a=n.containerFeature,r=n.containedFeature;if(a&&r){var c=function(e,t){var n=t.geometry.coordinates[0],a=Object(Hu.feature)(e.geometry);return a.geometry.coordinates.push(n),a}(a,r),i=e.draw.delete(t).add(c),o=Object(b.a)(i,1)[0];return c.id=o,{added:c,deleted:t}}return null},bj=function(e,t,n){var a=e.draw.get(t),r=[a.id,n.id],c=function(e,t){var n=[];if(Object(W.lineOverlap)(t,e)){var a=aj(e.geometry,t.geometry,!0);if(a)for(var r=0;r<a.features.length;r+=1)n[n.length-2]&&0===r&&n.splice(n.length-2,1),n.push(a.features[r])}var c=Object(Hu.featureCollection)(n);return c.features.length?c:null}(a,n);return e.draw.delete(c?r:n.id),{added:c,deleted:r}},jj=function e(t,n){var a=Object(W.clone)(t);return n&&n._id&&(ij(a)?a.features=a.features.map((function(t){return e(t,n)})):oj(a)&&function(e,t){var n;if(Object(ne.get)(e,"properties.parentId")!==t)if(null!==e&&void 0!==e&&null!==(n=e.properties)&&void 0!==n&&n.parentId||Object(ne.set)(e,"properties.parentId",t),e.id){var a=Object(ne.last)(e.id.split("/"));Object(ne.set)(e,"properties.internalId",a)}else Object(ne.set)(e,"properties.internalId",Object(cc.generate)()),Object(ne.set)(e,"id","".concat(e.properties.parentId,"/").concat(e.properties.internalId));else e.id||Object(ne.set)(e,"id","".concat(e.properties.parentId,"/").concat(e.properties.internalId))}(a,n._id)),a},pj=function(e){return null!==e&&void 0!==e&&e.features?e.features.filter((function(e){return!e.properties||!1!==e.properties.includeOnMaps})):[]},fj=function(e){if(!e||0===e.length)return[];var t=function(e){var t=e.reduce((function(e,t){return t.fieldBoundedArea&&e.push(pj(t.fieldBoundedArea)),e}),[]);return Object(ne.flatten)(t)}(e),n=function(e){return e&&0!==e.length?e.reduce((function(e,t){return t.areas?e.concat(t.areas.filter((function(e){return!1!==e.includeOnMaps}))):e}),[]):[]}(e);return n.reduce((function(e,t){if(t.boundedArea&&t.boundedArea.length){var n=t.boundedArea;return e.concat(n.map((function(e){return jj(e,t)})))}return e}),t)},mj=function(e){try{for(var t=e.features.filter((function(e){return"Polygon"===e.geometry.type||"MultiPolygon"===e.geometry.type})),n=[],a=0;a<t.length;a+=1)n.push(Object(W.centroid)(t[a].geometry));var r=Object(Hu.featureCollection)(n);return Object(W.center)(r)}catch(c){return[]}},vj=function(e,t){try{var n=e.features.filter((function(e){return"Polygon"===e.geometry.type||"MultiPolygon"===e.geometry.type})),a=n;1===t.length&&(a=n.filter((function(e){return e.properties.propertyId===t[0].id})));for(var r=[],c=0;c<a.length;c+=1)r.push(Object(W.centroid)(a[c].geometry));var i=Object(Hu.featureCollection)(r);return Object(W.center)(i)}catch(o){return[]}},Oj=function(e){return mj(Object(Hu.featureCollection)(e)).geometry.coordinates},hj={},xj=Object(a.createContext)(hj),gj=function(e){var t=e.onDelete,n=e.setMode,r=Object(a.useContext)(eb.MapContext);return Object(a.useEffect)((function(){var e,a=(e={},Object(et.a)(e,mb,(function(){return t()})),Object(et.a)(e,vb,(function(){return t()})),Object(et.a)(e,Ob,(function(){return n("simple_select")})),e),c=function(e){var t=a[e.which];t&&t()};return r&&r.getCanvas()&&r.getCanvas().addEventListener("keydown",c),function(){r&&r.getCanvas()&&r.getCanvas().removeEventListener("keydown",c)}}),[r,t,n]),null};gj.propTypes={onDelete:wc.a.func.isRequired,setMode:wc.a.func.isRequired};var Cj=gj,yj=n(795),Pj=n.n(yj),Aj=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ne.intersection;if(!e&&!t)return!0;if(!e||!t)return!1;if(0===e.length&&0===t.length)return!0;if(e.length!==t.length)return!1;var a=n(e,t);return a.length===e.length},Sj=function(e,t){return e&&t?e.length===t.length&&e.reduce((function(e,n,a){return e&&Object(W.booleanEqual)(n,t[a])&&function(e,t){var n,a;return(null===e||void 0===e||null===(n=e.properties)||void 0===n?void 0:n.$layer)===(null===t||void 0===t||null===(a=t.properties)||void 0===a?void 0:a.$layer)}(n,t[a])}),!0):!e&&!t},Tj=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return Object(W.convertArea)(Object(W.area)(Object(W.featureCollection)(e)),"meters","acres")},Nj=function(e){var t=Object(W.multiPolygon)(e.map(W.getCoords));return Object(W.getGeom)(t)},Ej=function(e){return"MultiPolygon"===e.geometry.type?Object(I.a)(Object(I.a)({},e),{},{geometry:{type:"Polygon",coordinates:Object(ne.flatten)(e.geometry.coordinates)}}):e},wj=function(e,t){var n;return null===e||void 0===e||null===(n=e.features)||void 0===n?void 0:n.find((function(e){return e.properties.id===t.id}))},_j=function(e,t,n){if(!n&&e)return null;var a=Object(W.bbox)(t);return Object(ne.intersection)(e,a).length===(null===a||void 0===a?void 0:a.length)?null:a},Rj=function(e){var t=document.getElementById("map-wrapper-container"),n=t.clientWidth,a=t.clientHeight;return Pj.a.viewport(e,[n-240,a],void 0,void 0,void 0,!0).zoom},Ij=function(e){var t=e.map((function(e){return Object(W.polygon)(e)})),n=W.union.apply(void 0,Object(v.a)(t));return"MultiPolygon"===n.geometry.type?n.geometry.coordinates:[n.geometry.coordinates]},Dj="selected",kj="custom",Lj=["all",["==",["get","$landType"],"field"],[">",["length",["get","cropzones"]],0]],Fj=["==",["get","$layer"],Dj],Mj=["==",["get","$layer"],kj],Vj=function(e,t,n,a){return e.map((function(e,r){if(!t[r]||Object(ne.isEmpty)(t[r]))return null;var c=t[r],i=c.fillColor,o=c.fillOutlineColor,s=c.fillAntialias,l=Object(Hu.featureCollection)(e),d=a?{"fill-color":["case",Lj,"rgba(20, 21, 28, 0.3)",i],"fill-antialias":s||!0}:{"fill-color":i,"fill-outline-color":o},u=a?{"line-color":["case",Lj,"#14151C",o],"line-width":2}:{};return Object(y.jsx)(eb.GeoJSONLayer,{data:l,fillOnClick:n,fillPaint:Object(I.a)(Object(I.a)({},d),{},{"fill-antialias":s||!0}),linePaint:u,fillSortKey:["get","sortKey"]},Object(cc.generate)())}))},Bj=function(e){var t=e.geoJSON,n=e.onClickShape;return Object(y.jsx)(eb.GeoJSONLayer,{fillOnClick:n,data:t,fillPaint:{"fill-color":"rgba(49, 180, 242, 0.4)","fill-outline-color":"rgba(49, 180, 242, 1)","fill-antialias":!0}})},Uj=function(e){var t=e.geoJSON,n=e.onClickShape,a=e.labelKey;return e.isGeoJSONLabelEnabled?Object(y.jsx)("div",{"data-testid":"geojson-layer-with-labels",children:Object(y.jsx)(eb.GeoJSONLayer,{fillOnClick:n,data:t,fillPaint:{"fill-color":["case",Mj,"transparent",Fj,"rgba(49, 180, 242, 0.05)","rgba(255, 255, 255, 0.3)"],"fill-antialias":!0},linePaint:{"line-color":["case",Mj,"transparent","#FFFFFF"],"line-width":2},symbolLayout:{"text-field":["get",a],"text-anchor":"center","text-justify":"auto","text-variable-anchor":["left"],"text-radial-offset":0,"text-size":20,"text-font":["Open Sans Semibold","Arial Unicode MS Bold"],"symbol-z-order":"source","text-allow-overlap":!1},symbolPaint:{"text-color":"white"}})}):Object(y.jsx)("div",{"data-testid":"geojson-layer",children:Object(y.jsx)(eb.GeoJSONLayer,{fillOnClick:n,data:t,fillPaint:{"fill-color":["case",Fj,"rgba(49, 180, 242, 0.05)","rgba(255, 255, 255, 0.15)"],"fill-antialias":!0},linePaint:{"line-color":"rgba(255, 255, 255, 1)","line-width":3}})})},zj=function(e){var t=e.geoJSON,n=e.customStyles,r=e.visible,c=e.setZoom,i=e.activeObjectType,o=e.isGeoJSONLabelEnabled,s=Object(p.i)().pathname,l=Object(a.useContext)(ac),d=Object(b.a)(l,1)[0],u=d.selectedProperty,j=d.loadingProperties,f=d.loadTimestamp,m=d.isExportPDFMapsActive,O=d.fieldsToMassiveAssign,h=Object(a.useState)(),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useState)(!1),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)(!1),E=Object(b.a)(N,2),w=E[0],_=E[1],R=m,D=Object(a.useRef)(!0),k=Object(a.useMemo)((function(){var e;return Object(Hu.featureCollection)((null===t||void 0===t||null===(e=t.features)||void 0===e?void 0:e.filter((function(e){return e.properties.$layer===Dj})))||[])}),[t]),L=Object(a.useMemo)((function(){if(!R)return t;var e=t.features.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{properties:Object(I.a)(Object(I.a)({},e.properties),{},{$layer:Object.keys(null!==n&&void 0!==n?n:{}).includes(e.properties.$layer)?kj:e.properties.$layer})})}));return Object(Hu.featureCollection)(e)}),[t,n,R]),F=Object(a.useMemo)((function(){return Object.keys(null!==n&&void 0!==n?n:{}).map((function(e){return(L.features||[]).filter((function(t){var n=t.properties;return n.$layer===e||n.$layer===kj}))}))}),[L,n]),M=Object(a.useContext)(eb.MapContext);!S&&M&&!M.isMoving()&&M.isStyleLoaded()&&T(!0),Object(a.useEffect)((function(){null!==u&&void 0!==u&&u.id&&(D.current=!0)}),[u]),Object(a.useEffect)((function(){var e=Object(ne.flatMap)(O.map((function(e){var t,n=null===e||void 0===e||null===(t=e.cropzones)||void 0===t?void 0:t.map((function(e){return e.id}));return null!==n&&void 0!==n&&n.length?[e.id].concat(Object(v.a)(n)):[e.id]}))),n=null===L||void 0===L?void 0:L.features.filter((function(t){var n,a;return R?e.includes(null===t||void 0===t||null===(n=t.properties)||void 0===n?void 0:n.id):"focused"===(null===t||void 0===t||null===(a=t.properties)||void 0===a?void 0:a.$layer)})),a=n.length?Object(Hu.featureCollection)(n):t,r=_j(g,a,n.length);if(a&&r&&S&&!w){if(r.find((function(e){return e===1/0||e===-1/0})))return;setTimeout((function(){var e=r.slice(0,2),t=r.slice(-2),n=Object(W.points)([e,t]),a=Object(W.center)(n);localStorage.setItem(Ab,JSON.stringify(a.geometry.coordinates)),M.fitBounds(r,{padding:160,animate:D.current}),C(r)}),1),_(!0)}}),[g,t,M,w,S,R,O,null===L||void 0===L?void 0:L.features]),Object(a.useEffect)((function(){j&&C(void 0)}),[j,f]),Object(a.useEffect)((function(){var e=!0,t=Object(ne.debounce)((function(){e&&(c((function(){return[M.getZoom()]})),_(!1))}),300);return M&&("/app/property"===s||w)&&M.on("moveend",t),function(){e=!1,M&&M.off("moveend",t),t.cancel()}}),[w,M,c,s]);var V="field"===i||"cropzone"===i?"fieldAndCropZoneLabel":"defaultLabel";return t&&r?Object(y.jsx)(xj.Consumer,{children:function(e){var t=e.onClickShape;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Bj,{onClickShape:t,geoJSON:k}),Object(y.jsx)(Uj,{onClickShape:t,geoJSON:L,labelKey:V,isGeoJSONLabelEnabled:o}),n&&Vj(F,Object.values(n),t,R)]})}}):null};zj.defaultProps={geoJSON:null,customStyles:null,visible:!1,setZoom:function(){}};var Zj=zj,Yj=["type","properties","id","layer","source","sourceLayer","state"],Hj={CLU:{providerName:"Common Land Unit (CLU)",cropSeason:"Summer",cropYear:2008},SATELLITE:{providerName:"Cropio"}},Gj=function(e){return function(t){return e.properties.grisId===t.properties.grisId}},Wj={},qj=function(e){return Object(ne.isNil)(e.id)?"".concat(e.xMin,"-").concat(e.yMin,"-").concat(e.xMax,"-").concat(e.yMax):e.id},Jj=function(e){var t,n=e.setZoom,r=e.geoJSONCollection,c=e.type,i=e.onChange,o=e.onDelete,s=Object(a.useState)(null!==(t=null===r||void 0===r?void 0:r.features)&&void 0!==t?t:[]),l=Object(b.a)(s,1)[0],d=Object(a.useState)(Object(W.featureCollection)([])),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(Object(W.featureCollection)([])),m=Object(b.a)(f,2),v=m[0],O=m[1],h=Object(a.useContext)(xj).addNewMapFeatures,x=Object(a.useContext)(eb.MapContext),g=Lb(),C=Object(b.a)(g,2)[1],P=Object(a.useState)([]),A=Object(b.a)(P,2)[1];Object(a.useEffect)((function(){x&&(x.getZoom()<12.25&&n([12.25]))}),[x,n]),Object(a.useEffect)((function(){var e=!0,t=function(){if(e&&x){var t=function(e){var t=e.getCenter(),n=t.lng,a=t.lat;return["".concat(n,"-").concat(a),Object(W.circle)([n,a],1)]}(x);(function(e,t){var n=Object(b.a)(e,2),a=n[0],r=n[1];if(Wj[a])return Promise.resolve({});var c={type:"MultiPolygon",coordinates:[r.geometry.coordinates]},i=J.a.post("https://gris.syngentadigitalapps.com/fbm/v1/boundaries?authkey=6c66fce4-f0b0-4f63-9eb5-e71eceaa93dd",Object(I.a)(Object(I.a)({},t),{},{inputGeometry:c}));return Wj[a]=i,i.then((function(){Wj[a]=null})),i})(t,c).then((function(e){var t;null!==(t=e.data)&&void 0!==t&&t.data&&p((function(t){var n=function(e,t,n){var a=e.features.map((function(e){return e.properties.grisId})),r=t.map((function(e){return e.id})).concat(a);return e.features.concat(n.filter((function(e){return!r.includes(qj(e))})).map((function(e){return Object(W.feature)(e.boundaryData,{grisId:qj(e),crops:""})})))}(t,l,e.data.data);return Object(W.featureCollection)(n)}))})).catch((function(){}))}};return x&&(x.on("moveend",t),t()),function(){e=!1,x&&x.off("moveend",t)}}),[x,l,c]);var S=function(){C((function(e){return Object(I.a)(Object(I.a)({},e),{},{coordinates:null,feature:null})}))};return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(eb.GeoJSONLayer,{data:j,fillPaint:{"fill-color":"rgba(0, 113, 205, 0.7)","fill-outline-color":"rgba(130, 207, 255, 1)","fill-antialias":!0},fillOnClick:function(e){var t=_b(x,e.lngLat),n=v.features,a=[t].map((function(e){var t={};return Yj.forEach((function(n){t[n]=e[n]})),t})),r=null===j||void 0===j?void 0:j.features.filter((function(e){var t,n,r;return(null===e||void 0===e||null===(t=e.properties)||void 0===t?void 0:t.grisId)===(null===(n=a[0])||void 0===n||null===(r=n.properties)||void 0===r?void 0:r.grisId)})).pop();a[0].geometry=null===r||void 0===r?void 0:r.geometry;var c=Object(W.featureCollection)([]);null!==n&&void 0!==n&&n.find(Gj(t))?(o(),c.features=n.filter(Object(ne.negate)(Gj(t)))):c.features=null===n||void 0===n?void 0:n.concat(a),(null===c||void 0===c?void 0:c.features.length)>0?O(c):O(Object(W.featureCollection)([])),function(e){S();var t=e.features.map((function(e){var t=Object(W.feature)(e.geometry,{internalId:e.properties.grisId});return t.id=e.properties.grisId,{feature:t}}));A(t),h(gb,t),i(t)}(c)},fillOnMouseMove:function(e){var t=_b(x,null===e||void 0===e?void 0:e.lngLat);C((function(n){var a,r,c;if((null===n||void 0===n||null===(a=n.feature)||void 0===a||null===(r=a.properties)||void 0===r?void 0:r.grisId)===(null===t||void 0===t||null===(c=t.properties)||void 0===c?void 0:c.grisId))return n;var i=wb(e.originalEvent);return Object(I.a)(Object(I.a)({},n),{},{coordinates:i,feature:t})}))},fillOnMouseLeave:S}),v&&Object(y.jsx)(eb.GeoJSONLayer,{data:v,fillPaint:{"fill-color":"rgba(25, 160, 75, 0.7)","fill-outline-color":"rgba(195, 234, 209, 1)","fill-antialias":!0}})]})};Jj.defaultProps={setZoom:ne.noop,geoJSONCollection:null,type:{},onChange:function(){},onDelete:function(){}};var Kj=Jj,Qj=function(e,t,n){var r=n.position,c=void 0===r?"left":r,i=n.delay,o=void 0===i?2e3:i,s=n.ariaLabel,l=n.top;return function(n){var r=Object(a.useState)(null),i=Object(b.a)(r,2),d=i[0],u=i[1],j=Object(a.useState)(!1),p=Object(b.a)(j,2),f=p[0],v=p[1];return Object(y.jsxs)(pu,{onMouseEnter:function(){return u(setTimeout((function(){return v(!0)}),o))},onMouseLeave:function(){return clearTimeout(d)||v(!1)},children:[Object(y.jsx)("div",{className:"relative","aria-label":s,children:Object(y.jsx)("div",{className:"absolute",style:{top:l},children:Object(y.jsx)(m.Popup,{position:c,open:f,hasArrow:!0,trigger:Object(y.jsx)("div",{}),children:Object(y.jsx)("div",{className:"whitespace-no-wrap",children:t})})})}),Object(y.jsx)(e,Object(I.a)({},n))]})}},Xj=function(e){var t=e.onClick,n=e.children,a=e.selected,r=e.disabled,c=e.className,i=a?"bg-gray-700":"",o=r?"text-gray-500 cursor-not-allowed":"";return Object(y.jsx)("button",{type:"button",className:"flex justify-center items-center m-3 w-8 h-8 bg-white shadow-lg rounded-full ".concat(i," ").concat(o," ").concat(c),onClick:t,disabled:r,children:n})};Xj.defaultProps={onClick:function(){},selected:!1,disabled:!1,className:""};var $j=Xj,ep=function(e){var t=e.message,n=e.hotkey;return Object(y.jsxs)("div",{className:"flex flex-no-wrap",children:[Object(y.jsx)("div",{className:"text-gray-700",children:t}),"\xa0",Object(y.jsxs)("div",{className:"text-gray-300",children:["(",n,")"]})]})},tp="#696F88",np="#FFFFFF",ap="#A0AEC0",rp=function(e){var t,n=e.selected;return t=e.disabled?ap:n?np:tp,Object(y.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M13.7143 11.4286C13.7018 11.4286 13.6904 11.4321 13.6779 11.4321L12.2779 9.09929C12.4589 8.77179 12.5714 8.40071 12.5714 8C12.5714 7.59929 12.4593 7.22821 12.2779 6.90071L13.6779 4.56786C13.6904 4.56821 13.7018 4.57143 13.7143 4.57143C14.9768 4.57143 16 3.54821 16 2.28571C16 1.02321 14.9768 0 13.7143 0C12.8704 0 12.1414 0.4625 11.7457 1.14286H4.25429C3.85857 0.4625 3.12964 0 2.28571 0C1.02321 0 0 1.02321 0 2.28571C0 3.12964 0.4625 3.85857 1.14286 4.25429V11.7454C0.4625 12.1414 0 12.8704 0 13.7143C0 14.9768 1.02321 16 2.28571 16C3.12964 16 3.85857 15.5375 4.25429 14.8571H11.7454C12.1414 15.5375 12.87 16 13.7139 16C14.9764 16 15.9996 14.9768 15.9996 13.7143C16 12.4518 14.9768 11.4286 13.7143 11.4286ZM3.42857 11.7457V4.25429C3.77084 4.05541 4.05541 3.77084 4.25429 3.42857H11.6957L10.3221 5.71786C10.3096 5.7175 10.2982 5.71429 10.2857 5.71429C9.02321 5.71429 8 6.7375 8 8C8 9.2625 9.02321 10.2857 10.2857 10.2857C10.2982 10.2857 10.3096 10.2821 10.3221 10.2821L11.6957 12.5714H4.25429C4.05551 12.2291 3.77091 11.9445 3.42857 11.7457ZM9.71429 8C9.71429 7.685 9.97071 7.42857 10.2857 7.42857C10.6007 7.42857 10.8571 7.685 10.8571 8C10.8571 8.315 10.6007 8.57143 10.2857 8.57143C9.97071 8.57143 9.71429 8.315 9.71429 8ZM14.2857 2.28571C14.2857 2.60071 14.0293 2.85714 13.7143 2.85714C13.3993 2.85714 13.1429 2.60071 13.1429 2.28571C13.1429 1.97071 13.3993 1.71429 13.7143 1.71429C14.0293 1.71429 14.2857 1.97071 14.2857 2.28571ZM2.28571 1.71429C2.60071 1.71429 2.85714 1.97071 2.85714 2.28571C2.85714 2.60071 2.60071 2.85714 2.28571 2.85714C1.97071 2.85714 1.71429 2.60071 1.71429 2.28571C1.71429 1.97071 1.97071 1.71429 2.28571 1.71429ZM1.71429 13.7143C1.71429 13.3993 1.97071 13.1429 2.28571 13.1429C2.60071 13.1429 2.85714 13.3993 2.85714 13.7143C2.85714 14.0293 2.60071 14.2857 2.28571 14.2857C1.97071 14.2857 1.71429 14.0293 1.71429 13.7143ZM13.7143 14.2857C13.3993 14.2857 13.1429 14.0293 13.1429 13.7143C13.1429 13.3993 13.3993 13.1429 13.7143 13.1429C14.0293 13.1429 14.2857 13.3993 14.2857 13.7143C14.2857 14.0293 14.0293 14.2857 13.7143 14.2857Z",fill:t})})};rp.defaultProps={selected:!1,disabled:!1};var cp=function(e){var t,n=e.selected;return t=e.disabled?ap:n?np:tp,Object(y.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.10982 14.5703C3.87823 13.9188 2.11839 12.1612 1.46371 9.93099C0.62033 9.70227 0 8.93139 0 8.01562C0 7.10343 0.615494 6.335 1.45384 6.10296C2.10056 3.85661 3.86691 2.08448 6.10982 1.42966C6.34983 0.603685 7.11223 0 8.01562 0C8.91542 0 9.67534 0.598878 9.91853 1.41978C12.1964 2.07189 13.9882 3.87482 14.6246 6.15928C15.3737 6.443 15.9062 7.16712 15.9062 8.01562C15.9062 8.86784 15.369 9.59457 14.6148 9.87567C13.9699 12.1436 12.1848 13.9314 9.91853 14.5802C9.67534 15.4011 8.91542 16 8.01562 16C7.11223 16 6.34983 15.3963 6.10982 14.5703ZM8.01562 2.5C8.3004 2.5 8.53125 2.26915 8.53125 1.98438C8.53125 1.6996 8.3004 1.46875 8.01562 1.46875C7.73085 1.46875 7.5 1.6996 7.5 1.98438C7.5 2.26915 7.73085 2.5 8.01562 2.5ZM8.01562 3.96875C8.74222 3.96875 9.37761 3.57824 9.72335 2.99564C11.2596 3.51489 12.479 4.72167 13.0156 6.24982C12.3754 6.57905 11.9375 7.2462 11.9375 8.01562C11.9375 8.7813 12.3712 9.44569 13.0062 9.77659C12.465 11.2922 11.2507 12.4881 9.72335 13.0044C9.37761 12.4218 8.74222 12.0312 8.01562 12.0312C7.29272 12.0312 6.6601 12.4178 6.31319 12.9955C4.77322 12.466 3.55513 11.2444 3.03035 9.70227C3.59369 9.35217 3.96875 8.7277 3.96875 8.01562C3.96875 7.29988 3.58982 6.67265 3.02162 6.32359C3.54154 4.76923 4.76462 3.53697 6.31319 3.0045C6.6601 3.58219 7.29272 3.96875 8.01562 3.96875ZM13.9219 8.53125C14.2066 8.53125 14.4375 8.3004 14.4375 8.01562C14.4375 7.73085 14.2066 7.5 13.9219 7.5C13.6371 7.5 13.4062 7.73085 13.4062 8.01562C13.4062 8.3004 13.6371 8.53125 13.9219 8.53125ZM2.5 8.01562C2.5 8.3004 2.26915 8.53125 1.98438 8.53125C1.6996 8.53125 1.46875 8.3004 1.46875 8.01562C1.46875 7.73085 1.6996 7.5 1.98438 7.5C2.26915 7.5 2.5 7.73085 2.5 8.01562ZM8.53125 14.0156C8.53125 14.3004 8.3004 14.5312 8.01562 14.5312C7.73085 14.5312 7.5 14.3004 7.5 14.0156C7.5 13.7309 7.73085 13.5 8.01562 13.5C8.3004 13.5 8.53125 13.7309 8.53125 14.0156Z",fill:t})})};cp.defaultProps={selected:!1,disabled:!1};var ip=function(e){var t=e.modes,n=e.modeSelected,a=e.mode,r=e.icon,c=e.overlay,i=a===t[1];return Object(y.jsx)($j,{onClick:function(){return n(i?t[0]:t[1])},selected:i,disabled:!!c,children:Object(y.jsx)(r,{selected:i,disabled:!!c})})};ip.defaultProps={overlay:null};var op=Qj((function(e){var t=e.modeSelected,n=e.mode,a=e.overlay;return Object(y.jsx)(ip,{overlay:a,modes:["simple_select","draw_polygon"],modeSelected:t,mode:n,icon:rp})}),Object(y.jsx)(ep,{message:"Draw Polygon",hotkey:"p"}),{position:"left",ariaLabel:"Draw Polygon (p)",top:"-0.25rem"}),sp=Qj((function(e){var t=e.modeSelected,n=e.mode,a=e.overlay;return Object(y.jsx)(ip,{overlay:a,modes:["simple_select","drag_circle"],modeSelected:t,mode:n,icon:cp})}),Object(y.jsx)(ep,{message:"Draw Circle",hotkey:"c"}),{position:"left",ariaLabel:"Draw Circle (c)",top:"-0.25rem"}),lp=function(e){var t=e.mode,n=e.modeSelected,a=e.overlay;return Object(y.jsxs)("div",{className:"flex flex-col","data-testid":"draw-mode-buttons",children:[Object(y.jsx)(op,{mode:t,modeSelected:n,overlay:a}),Object(y.jsx)(sp,{mode:t,modeSelected:n,overlay:a})]})};lp.defaultProps={overlay:null};var dp=lp,up="#696F88",bp="#A0AEC0",jp=function(e){var t=e.disabled?bp:up;return Object(y.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.42668 5.09333C6.58001 4.76 6.66668 4.39333 6.66668 4C6.66668 2.52667 5.47334 1.33333 4.00001 1.33333C2.52668 1.33333 1.33334 2.52667 1.33334 4C1.33334 5.47333 2.52668 6.66667 4.00001 6.66667C4.39334 6.66667 4.76001 6.58 5.09334 6.42667L6.66668 8L5.09334 9.57333C4.76001 9.42 4.39334 9.33333 4.00001 9.33333C2.52668 9.33333 1.33334 10.5267 1.33334 12C1.33334 13.4733 2.52668 14.6667 4.00001 14.6667C5.47334 14.6667 6.66668 13.4733 6.66668 12C6.66668 11.6067 6.58001 11.24 6.42668 10.9067L8.00001 9.33333L12.6667 14H14.6667V13.3333L6.42668 5.09333ZM4.00001 5.33333C3.26668 5.33333 2.66668 4.74 2.66668 4C2.66668 3.26 3.26668 2.66667 4.00001 2.66667C4.73334 2.66667 5.33334 3.26 5.33334 4C5.33334 4.74 4.73334 5.33333 4.00001 5.33333ZM2.66668 12C2.66668 12.74 3.26668 13.3333 4.00001 13.3333C4.73334 13.3333 5.33334 12.74 5.33334 12C5.33334 11.26 4.73334 10.6667 4.00001 10.6667C3.26668 10.6667 2.66668 11.26 2.66668 12ZM8.00001 8.33333C7.81334 8.33333 7.66668 8.18667 7.66668 8C7.66668 7.81333 7.81334 7.66667 8.00001 7.66667C8.18668 7.66667 8.33334 7.81333 8.33334 8C8.33334 8.18667 8.18668 8.33333 8.00001 8.33333ZM8.66668 6L12.6667 2H14.6667V2.66667L10 7.33333L8.66668 6Z",fill:t})})},pp=function(e){var t=e.disabled?bp:up;return Object(y.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("path",{d:"M6.67621 8.09302C6.37981 8.09302 6.13953 8.33386 6.13953 8.63094V9.32255C6.13953 9.61963 6.37981 9.86047 6.67621 9.86047H12.5796C12.876 9.86047 13.1163 9.61963 13.1163 9.32255V8.63094C13.1163 8.33386 12.876 8.09302 12.5796 8.09302H6.67621Z",fill:t}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.1628 0H2.5L0 15.1628H6.28849C5.99103 15.0005 5.70687 14.8168 5.43807 14.6139C6.60772 15.4847 8.05764 16 9.62791 16C10.8322 16 11.9657 15.6969 12.9563 15.1628H15.1628V13.3006C16.0953 12.1085 16.6512 10.6075 16.6512 8.97674C16.6512 7.34594 16.0953 5.84496 15.1628 4.65291V0ZM9.62791 14.5116C12.6847 14.5116 15.1628 12.0336 15.1628 8.97674C15.1628 5.91991 12.6847 3.44186 9.62791 3.44186C6.57108 3.44186 4.09302 5.91991 4.09302 8.97674C4.09302 12.0336 6.57108 14.5116 9.62791 14.5116Z",fill:t})]})},fp=function(e){var t=e.disabled?bp:up;return Object(y.jsx)("svg",{width:"17",height:"16",viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.66671 2H6.33337L5.66671 2.66667H3.33337V4H12.6667V2.66667H10.3334L9.66671 2ZM10.6667 6V12.6667H5.33337V6H10.6667ZM4.00004 4.66667H12V12.6667C12 13.4 11.4 14 10.6667 14H5.33337C4.60004 14 4.00004 13.4 4.00004 12.6667V4.66667Z",fill:t})})},mp=function(e){var t=e.disabled?bp:up;return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"21",width:"21",viewBox:"0 0 51 51",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M23.45 27.8q.45.45 1.05.45.6 0 1.05-.45l9.35-9.35q.4-.4.4-.975t-.4-1.025q-.45-.45-1.075-.45t-1.075.45l-8.2 8.25-3.85-3.85q-.4-.4-1-.4t-1.05.45q-.45.45-.45 1.05 0 .6.45 1.05ZM13 38q-1.2 0-2.1-.9-.9-.9-.9-2.1V7q0-1.2.9-2.1.9-.9 2.1-.9h28q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h28V7H13v28Zm-6 9q-1.2 0-2.1-.9Q4 42.2 4 41V11.5q0-.65.425-1.075Q4.85 10 5.5 10q.65 0 1.075.425Q7 10.85 7 11.5V41h29.5q.65 0 1.075.425Q38 41.85 38 42.5q0 .65-.425 1.075Q37.15 44 36.5 44Zm6-37v28V7Z",fill:t})})},vp=Qj((function(e){var t=e.onSplit,n=e.splitDisabled,a=e.showSplitToolPopup;return Object(y.jsx)(pu,{"data-testid":"split-button-container",onMouseEnter:function(){return a(!1)},onMouseLeave:function(){return a(!0)},className:"w-12",children:Object(y.jsx)($j,{onClick:t,disabled:n,children:Object(y.jsx)(jp,{disabled:n})})})}),Object(y.jsx)(ep,{message:"Split Tool",hotkey:"x"}),{position:"left",ariaLabel:"Split Tool (s)",top:"-0.25rem"}),Op=Qj((function(e){var t=e.onSubtract,n=e.subtractDisabled;return Object(y.jsx)("div",{"data-testid":"subtract-button-container",children:Object(y.jsx)($j,{onClick:t,disabled:n,children:Object(y.jsx)(pp,{disabled:n})})})}),Object(y.jsx)(ep,{message:"Subtract Selection",hotkey:"s"}),{position:"left",ariaLabel:"Subtract Selection (s)",top:"-0.25rem"}),hp=Qj((function(e){var t=e.onDelete,n=e.selectedShapeIds;return Object(y.jsx)("div",{"data-testid":"delete-button-container",children:Object(y.jsx)($j,{onClick:t,disabled:!n||0===n.length,children:Object(y.jsx)(fp,{disabled:!n||0===n.length})})})}),Object(y.jsx)(ep,{message:"Delete Shape",hotkey:"Del"}),{position:"left",ariaLabel:"Delete Shape (Del)",top:"-0.25rem"}),xp=Qj((function(e){var t=e.disabled,n=e.selectAllShapes;return Object(y.jsx)("div",{"data-testid":"multiselect-button-container",children:Object(y.jsx)($j,{onClick:n,disabled:t,children:Object(y.jsx)(mp,{disabled:t})})})}),Object(y.jsx)(ep,{message:"Select All",hotkey:"a"}),{position:"left",ariaLabel:"Select All (A)",top:"-0.25rem"}),gp=function(e){var t=e.onDelete,n=e.onSubtract,r=e.onSplit,c=e.features,i=e.setSelectedShapeIds,o=e.showSplitToolPopup,s=Object(a.useContext)(xj).selectedShapeIds,l=1!==(null===s||void 0===s?void 0:s.length),d=2!==(null===s||void 0===s?void 0:s.length),u=ae.a.uniqBy(c.filter((function(e){return"selected"===e.properties.$layer})),"id").length<=1;return Object(y.jsxs)("div",{"data-testid":"edit-buttons",className:"flex flex-col",children:[Object(y.jsx)(vp,{onSplit:r,splitDisabled:l,showSplitToolPopup:o}),Object(y.jsx)(Op,{onSubtract:n,subtractDisabled:d}),Object(y.jsx)(hp,{onDelete:t,selectedShapeIds:s}),Object(y.jsx)(xp,{disabled:u,selectAllShapes:function(){var e=c.filter((function(e){return"selected"===e.properties.$layer})).map((function(e){return e.id}));i(e)}})]})};gp.defaultProps={features:[]};var Cp=gp,yp=function(e){var t=e.buttonClassName,n=e.onClick,a=e.children,r=e.className,c=t||"w-6 h-6";return Object(y.jsx)("div",{className:r,children:Object(y.jsx)("button",{type:"button",className:"flex justify-center items-center bg-white shadow-lg ".concat(c),onClick:n,children:a})})};yp.defaultProps={buttonClassName:null,className:""};var Pp=yp,Ap=function(){return Object(y.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M9.66659 5.66659H5.66659V9.66659H4.33325V5.66659H0.333252V4.33325H4.33325V0.333252H5.66659V4.33325H9.66659V5.66659Z",fill:"#696F88"})})},Sp=function(){return Object(y.jsx)("svg",{width:"10",height:"2",viewBox:"0 0 10 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M9.66659 1.66659H0.333252V0.333252H9.66659V1.66659Z",fill:"#696F88"})})},Tp=function(e){var t=e.setZoom;return Object(y.jsxs)("div",{"data-testid":"zoom-buttons",children:[Object(y.jsx)(Pp,{className:"m-5 mb-0",onClick:function(){return t((function(e){var t=Object(b.a)(e,1)[0];return[t+1>=20?20:t+1]}))},children:Object(y.jsx)(Ap,{})}),Object(y.jsx)(Pp,{className:"m-5 mt-0",onClick:function(){return t((function(e){var t=Object(b.a)(e,1)[0];return[t-1<=1?1:t-1]}))},children:Object(y.jsx)(Sp,{})})]})};Tp.defaultProps={setZoom:function(){}};var Np=Tp,Ep=function(e){var t=e.setZoom;return Object(y.jsx)("div",{className:"absolute flex flex-col z-10 right-0 bottom-0",children:Object(y.jsx)(Np,{setZoom:t})})},wp=function(e){var t=e.value,n=e.onToggle;return Object(y.jsxs)(Pp,{buttonClassName:"h-6 px-2 text-xs font-medium",onClick:function(){},children:[Object(y.jsx)("div",{className:"mr-2",children:"CLU"}),t?Object(y.jsx)("button",{"data-testid":"clu-done-button",className:"text-sm pl-1 pr-1",type:"button",onClick:n,style:{backgroundColor:"#19A04B",color:"white",paddingBottom:"0.13rem"},children:"Done"}):Object(y.jsx)(zo,{id:"map-clu-toggle",name:"map-clu-toggle",defaultChecked:t,onChange:n,color:"#0071CD"})]})},_p=function(e){var t=e.value,n=e.onToggle;return Object(y.jsxs)(Pp,{onClick:function(){},buttonClassName:"h-6 px-2 text-xs font-medium",children:[Object(y.jsx)("div",{className:"mr-2",children:"SAT"}),t?Object(y.jsx)("button",{"data-testid":"sat-done-button",className:"text-sm pl-1 pr-1",type:"button",onClick:n,style:{backgroundColor:"#19A04B",color:"white",paddingBottom:"0.13rem"},children:"Done"}):Object(y.jsx)(zo,{id:"map-satellite-toggle",name:"map-satellite-toggle",defaultChecked:t,onChange:n,color:"#0071CD"})]})},Rp=n(796),Ip=n(2805),Dp=n(412),kp=n.n(Dp),Lp=Object.freeze({READY:Symbol("ready"),ERROR:Symbol("error"),UPLOADING:Symbol("uploading")}),Fp=function(){return Object(y.jsxs)("div",{className:"flex flex-col m-auto items-center content-center",children:[Object(y.jsx)("div",{className:"absolute left-auto top-auto flex flex-row items-center content-center justify-end text-xs font-medium",style:{width:98,height:113},children:"Uploading..."}),Object(y.jsxs)("svg",{width:"98",height:"113",viewBox:"0 0 98 113",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("mask",{id:"path-1-inside-1",fill:"white",children:Object(y.jsx)("path",{d:"M96.1173 91.3662C97.276 92.387 97.3927 94.1592 96.3154 95.2655C89.5838 102.178 81.1676 107.246 71.8744 109.956C61.685 112.928 50.8608 112.943 40.6633 109.999C30.4658 107.055 21.315 101.274 14.2771 93.3285C7.23919 85.3835 2.60413 75.6019 0.912022 65.1237C-0.780085 54.6456 0.540449 43.9023 4.71974 34.1458C8.89903 24.3893 15.765 16.0214 24.5174 10.0172C33.2699 4.0131 43.5485 0.619962 54.1554 0.23323C63.8293 -0.119485 73.4129 2.04183 81.9782 6.48418C83.349 7.19512 83.7961 8.91399 83.0176 10.2476C82.2391 11.5811 80.5302 12.0237 79.1555 11.3203C71.5088 7.40797 62.9737 5.50731 54.3591 5.82141C44.8114 6.16952 35.5592 9.22384 27.6807 14.6284C19.8022 20.033 13.6219 27.5653 9.85989 36.3476C6.09792 45.1298 4.90925 54.8004 6.43239 64.2323C7.95553 73.6641 12.1278 82.469 18.4629 89.6207C24.798 96.7723 33.0351 101.976 42.2143 104.626C51.3935 107.276 61.1368 107.263 70.3088 104.588C78.5844 102.175 86.0874 97.6841 92.1139 91.5637C93.1973 90.4634 94.9587 90.3455 96.1173 91.3662Z"})}),Object(y.jsx)("path",{d:"M96.1173 91.3662C97.276 92.387 97.3927 94.1592 96.3154 95.2655C89.5838 102.178 81.1676 107.246 71.8744 109.956C61.685 112.928 50.8608 112.943 40.6633 109.999C30.4658 107.055 21.315 101.274 14.2771 93.3285C7.23919 85.3835 2.60413 75.6019 0.912022 65.1237C-0.780085 54.6456 0.540449 43.9023 4.71974 34.1458C8.89903 24.3893 15.765 16.0214 24.5174 10.0172C33.2699 4.0131 43.5485 0.619962 54.1554 0.23323C63.8293 -0.119485 73.4129 2.04183 81.9782 6.48418C83.349 7.19512 83.7961 8.91399 83.0176 10.2476C82.2391 11.5811 80.5302 12.0237 79.1555 11.3203C71.5088 7.40797 62.9737 5.50731 54.3591 5.82141C44.8114 6.16952 35.5592 9.22384 27.6807 14.6284C19.8022 20.033 13.6219 27.5653 9.85989 36.3476C6.09792 45.1298 4.90925 54.8004 6.43239 64.2323C7.95553 73.6641 12.1278 82.469 18.4629 89.6207C24.798 96.7723 33.0351 101.976 42.2143 104.626C51.3935 107.276 61.1368 107.263 70.3088 104.588C78.5844 102.175 86.0874 97.6841 92.1139 91.5637C93.1973 90.4634 94.9587 90.3455 96.1173 91.3662Z",fill:"#4A5568",stroke:"#787D96",strokeWidth:"14",strokeLinejoin:"round",mask:"url(#path-1-inside-1)"})]})]})},Mp=function(e){var t=e.title,n=e.multiple,a=e.subtitle,r=e.fileTypes,c=e.onFileInput,i=e.children,o=e.className;return Object(y.jsxs)("form",{className:"w-full",children:[Object(y.jsx)("input",{type:"file","data-testid":"file-input-select",className:"cursor-pointer absolute block opacity-0 top-0 bottom-0 left-0 right-0",accept:r.join(", "),onChange:c,multiple:n}),Object(y.jsxs)("div",{className:"mt-6 flex flex-col items-center content-center",children:[Object(y.jsx)(Ip.a,{fontSize:"large",style:{color:"#0071CD"}}),Object(y.jsx)("div",{className:"text-base font-normal text-neutral-1000 m-1",children:t}),Object(y.jsx)("div",{className:"text-sm mb-8 ".concat(o),children:a||r.join(", ")}),i]})]})};Mp.defaultProps={title:"",subtitle:"",fileTypes:[],multiple:!1,children:null};var Vp=function(e){var t=e.title,n=e.subtitle,r=e.fileTypes,c=e.onSelect,i=e.children,o=e.multiple,s=Object(a.useState)(Lp.READY),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useRef)(),p=function(e,t){var n=Array.from(e);if(r&&!n.reduce((function(e,t){return e&&function(e,t){return!!e.find((function(e){return Object(ne.endsWith)(t.name,e)}))}(r,t)}),!0))return t.preventDefault(),void u(Lp.ERROR);u(Lp.UPLOADING);var a=c(n,t);a?a.then((function(){return u(Lp.READY)})):u(Lp.READY)},f=d===Lp.ERROR?"text-red-600 font-medium":"text-gray-600";return Object(y.jsx)("div",{"data-testid":"file-input",className:"file-drop h-auto w-auto bg-neutral-100 rounded-lg p-1 mb-2",children:Object(y.jsx)("div",{className:"h-full w-auto relative border rounded-lg border-dashed border-neutral-300",children:Object(y.jsxs)("div",{ref:function(e){return j.current=e},className:"file-drop-target w-auto h-full flex",children:[d!==Lp.UPLOADING&&Object(y.jsxs)(Mp,{title:t,subtitle:n,fileTypes:r,onFileInput:function(e){var t=e.target.files;return p(t,e)},className:f,frameRef:j.current,multiple:o,children:[i,Object(y.jsx)(Rp.FileDrop,{multiple:o,frame:j.current,onFrameDrop:function(e){var t=e.dataTransfer.files;p(t,e)},onDrop:p})]}),d===Lp.UPLOADING&&Object(y.jsx)(Fp,{})]})})})};Vp.defaultProps={title:"",subtitle:"",fileTypes:[],children:null,multiple:!1};var Bp=Vp,Up=n(2806),zp=n(2807),Zp=n(444),Yp=function(e){return e.map((function(e){return function(e){return!Object(W.booleanClockwise)(e)}(e)?Object(v.a)(e).reverse():e}))},Hp=function(e){return function(e){var t;if("MultiPolygon"===e.type){var n=Object(b.a)(e.coordinates,1);t=Object(b.a)(n[0],1)[0]}else t=Object(b.a)(e.coordinates,1)[0];return Object(W.booleanClockwise)(t)}(e)&&0===e.coordinates.length?e:(t=e,Object(I.a)(Object(I.a)({},t),{},{coordinates:Yp(t.coordinates)}));var t},Gp=function(e,t,n){var a=n.border,r=n.color,c=n.extent,i={type:"FeatureCollection",features:e.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{geometry:Hp(e.geometry)})}))},o=mj(i),s=Zp.a().center(o.geometry.coordinates).fitExtent(c,i),l=Zp.b().projection(s),d=Zp.c(t).select("g").selectAll("path").data(i.features);d.enter().append("path").merge(d).attr("d",l).attr("stroke",null!==a&&void 0!==a?a:r).attr("fill",r),d.exit().remove()},Wp="#C2C7D0",qp=function(){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("path",{d:"M6.47059 0C2.89698 0 0 2.89698 0 6.47059V18.92L7.93419 0H6.47059Z",fill:Wp}),Object(y.jsx)("path",{d:"M9.12645 0L0 25.4206V37.5294C0 40.6324 2.1842 43.2252 5.099 43.8543L14.7045 0H9.12645Z",fill:Wp}),Object(y.jsx)("path",{d:"M15.8963 0L8.58659 44H20.3672L21.4034 0H15.8963Z",fill:Wp}),Object(y.jsx)("path",{d:"M22.5957 0L23.646 44H35.4551L28.0176 0H22.5957Z",fill:Wp}),Object(y.jsx)("path",{d:"M29.196 0L38.6971 43.8949C41.6984 43.3479 43.9773 40.7304 43.9998 37.5765V25.8606L34.6747 0H29.196Z",fill:Wp}),Object(y.jsx)("path",{d:"M35.8672 0L44 19.4733V6.47059C44 2.89698 41.103 0 37.5294 0H35.8672Z",fill:Wp})]})},Jp=function(e){var t=e.id,n=e.features,r=e.border,c=e.color,i=e.width,o=e.height,s=e.className,l=Object(a.useRef)(),d=(n||[]).filter((function(e){return!!e&&Object.keys(e).length}));return Object(a.useEffect)((function(){l.current&&d.length>0&&Gp(d,l.current,{border:r,color:c,extent:[[4,4],[30,30]]})}),[d,r,c]),Object(y.jsxs)("svg",{"data-testid":"field-shapes-icon",id:t,ref:function(e){return l.current=e},width:i,height:o,viewBox:"0 0 34 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,children:[Object(y.jsx)("g",{className:n.length?"":"hidden"}),0===n.length&&Object(y.jsx)(qp,{})]})};Jp.defaultProps={features:[],border:void 0,color:Wp,width:34,height:34,className:""};var Kp=Jp,Qp=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return null!==t&&void 0!==t&&t.length?t.flatMap((function(t,a){var r,c=Object(I.a)(Object(I.a)({},t),{},{$depth:n,$acres:Tj(t.features),parentReference:0===n?0:a+1});return null!==(r=t.items)&&void 0!==r&&r.length?[c].concat(e(t.items,n+1)):c})):[]},Xp=function(e){var t=e.name,n=e.farmName,a=e.features,r=e.index;return Object(y.jsxs)("div",{className:"ml-2 flex",children:[Object(y.jsx)(Kp,{id:"import-field-icon-".concat(r),features:a,color:"#696F88"}),Object(y.jsxs)("div",{className:"flex flex-col justify-center ml-2",children:[Object(y.jsx)("div",{className:"text-neutral-1000",children:t||"Field info not available"}),n&&Object(y.jsx)("div",{style:{color:"#707374"},children:n})]})]})},$p=function(e){var t=e.name,n=e.features,a=e.index;return Object(y.jsxs)("div",{className:"ml-2 flex",children:[Object(y.jsx)(Kp,{id:"import-crop-zone-icon-".concat(a),features:n,color:"#CBCDD5"}),Object(y.jsx)("div",{className:"flex flex-col justify-center ml-2 text-neutral-1000",children:t||"Crop zone info not available"})]})},ef=function(e){var t=e.geoJson,n=e.fileName,r=e.onSelect,c=e.onCancel,i=Object(a.useState)(),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)([]),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useRef)(Gb(t));Object(a.useEffect)((function(){p(Qp(f.current))}),[]),Object(a.useEffect)((function(){if(s){var e=j.map((function(e,t){return[t,e.parentReference?t-e.parentReference:null]})).filter((function(e){var t=Object(b.a)(e,2)[1];return!Object(ne.isNil)(t)}));l((function(t){var n=function(e,t){if(!t.find((function(e){return e.event})))return[];var n=e.filter((function(e){var n=Object(b.a)(e,2),a=n[0],r=n[1];return qb(t,r,a)})).map((function(e){var n=Object(b.a)(e,2),a=n[0],r=n[1];return Jb(t,a,r)})),a=e.filter((function(e){var n=Object(b.a)(e,2),a=n[0],r=n[1];return qb(t,a,r)})).map((function(e){var n=Object(b.a)(e,2),a=n[0],r=n[1];return Jb(t,r,a)}));return n.concat(a)}(e,t);return n.length&&t?t.map((function(e){return{index:e.index,checked:e.checked}})).filter((function(e){var t=e.index;return!n.find(Wb(t))})).concat(n):t}))}}),[j,s]),Object(a.useEffect)((function(){if(!Object(ne.isNil)(s)){var e=s.filter((function(e){return e.checked})).map((function(e){var t=e.index;return j[t]})).filter((function(e){return"cropZone"===e.type})).flatMap((function(e){return e.features}));r(e)}}),[r,j,s]);var v=function(e){var t=e.map((function(e,t){return[e.parentReference?t-e.parentReference:t,t,e]})),n=Object(ne.groupBy)(t,(function(e){return Object(b.a)(e,1)[0]}));return Object.values(n)}(j);return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex items-center justify-between",style:{backgroundColor:"#EAF6FF",color:"#0071CD"},children:[Object(y.jsxs)("div",{children:[Object(y.jsx)(Up.a,{fontSize:"small",className:"text-neutral-600",style:{height:16}}),n]}),Object(y.jsx)("button",{type:"button",onClick:c,children:Object(y.jsx)(zp.a,{fontSize:"small",className:"mx-2 text-neutral-600",style:{height:12}})})]}),Object(y.jsx)("div",{className:"overflow-auto my-8",style:{maxHeight:"36rem"},children:Object(y.jsx)(m.Table,{selectable:!1,onSelect:ne.noop,children:v.map((function(e){return Object(y.jsx)(m.Table.RowGroup,{children:e.map((function(e){var t=Object(b.a)(e,3),n=t[0],a=t[1],r=t[2],c=r.name,i=r.farmName,o=r.type,d=r.features,u=r.$depth,j=r.$acres;return Object(y.jsx)(m.Table.Row,{children:Object(y.jsxs)("div",{className:"flex flex-1 justify-between items-center p-2 text-gray-600 hover:bg-gray-100 focus:outline-none","data-testid":"land-selector-row-item",children:[Object(y.jsxs)("div",{className:"flex flex-1 items-center ml-2",children:[Array.from({length:u},(function(e,t){return Object(y.jsx)("div",{className:"mx-2"},"tab-".concat(t))})),Object(y.jsx)(m.Checkbox,{checked:!(null===s||void 0===s||!s.find((function(e){var t=e.index,n=e.checked;return t===a&&n}))),onChange:function(e){return t=a,n=e,void l((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.find(Wb(t))?e.map((function(e){var a=e.index,r=e.checked,c=e.event;return{index:a,event:a===t?n:c,checked:a===t?!r:r}})):e.concat([{index:t,event:n,checked:!0}])}));var t,n}}),"field"===o&&Object(y.jsx)(Xp,{name:c,farmName:i,features:d,index:a}),"cropZone"===o&&Object(y.jsx)($p,{name:c,features:d,index:a})]}),Object(y.jsx)("div",{className:"flex flex-col justify-center",children:Object(y.jsx)(hu,{units:"ac.",children:j})})]})},"".concat(o).concat(c).concat(n).concat(a))}))})}))})})]})};ef.defaultProps={geoJson:null};var tf=ef,nf=function(){return Object(y.jsx)("svg",{width:"12",height:"14",viewBox:"0 0 12 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.25 0.625H3.75V5.125H0.75L6 10.375L11.25 5.125H8.25V0.625ZM6.74997 2.125V6.625H7.62747L5.99997 8.2525L4.37247 6.625H5.24997V2.125H6.74997ZM0.75 13.375V11.875H11.25V13.375H0.75Z",fill:"#696F88"})})},af=function(e){var t=e.onClick;return Object(y.jsxs)(Pp,{buttonClassName:"h-6 px-2 text-xs font-medium",onClick:t,children:[Object(y.jsx)("div",{className:"px-1",style:{margin:"0.125rem"},children:"Import"}),Object(y.jsx)(nf,{})]})},rf=function(e){var t=e.onSelect;return Object(y.jsx)("div",{className:"h-64 mb-24",children:Object(y.jsx)(Bp,{title:"Click or drag file to this area to upload",subtitle:"Upload a .zip that contains .shp, .shx, and .dbf",fileTypes:[".zip"],onSelect:t})})},cf=function(e){var t=e.page,n=e.geoJson,a=e.fileName,r=e.onFileSelect,c=e.onClose,i=e.onPropertySelect,o=e.onBack;return Object(y.jsx)(y.Fragment,{children:[Object(y.jsx)(rf,{onSelect:r}),Object(y.jsx)(tf,{geoJson:n,fileName:a,onClose:c,onSelect:i,onCancel:o})][t]})};cf.defaultProps={fileName:""};var of=function(){var e=Object(a.useState)(),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(0),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)([]),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useContext)(ac),f=Object(b.a)(p,2)[1],v=Object(a.useState)(!1),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useContext)(xj).addNewMapFeatures,C=function(){x(!1),s(0)},P=Object(a.useCallback)((function(e){j(e)}),[]),A=null!==n&&void 0!==n&&n.length?n[0].fileName:null===n||void 0===n?void 0:n.fileName;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(af,{onClick:function(){r(null),x(!0)}}),Object(y.jsx)(ao,{title:"Import and Select a Boundary",open:h,type:"buttonless",close:C,children:Object(y.jsxs)("div",{className:"mr-12",children:[Object(y.jsx)(cf,{onClose:C,onFileSelect:function(e,t){t.preventDefault(),e&&e.length>0&&function(e){return Promise.all(e.map((function(e){return e.arrayBuffer()}))).then((function(e){return e.map(kp.a)})).then((function(e){return Promise.all(e)}))}(e).then((function(e){r(e[0]),s(o+1)})).catch((function(){bc(f)("The file you selected is invalid.")}))},onPropertySelect:P,geoJson:n,fileName:A,page:o,onBack:function(){return s(0)}}),Object(y.jsx)("div",{className:"flex justify-end",children:Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsx)("div",{className:"px-1",children:Object(y.jsx)(m.Button,{id:"import-property-cancel-button",type:"outline",onClick:C,children:"Cancel"})}),Object(y.jsx)("div",{className:"px-1",children:Object(y.jsx)(m.Button,{id:"import-property-button",type:"primary",disabled:!(null!==u&&void 0!==u&&u.length),onClick:function(){C(),g(xb,u.map((function(e){var t=Object(W.feature)(e.geometry,{farmName:Zb(e),fieldName:Yb(e),cropZoneName:Hb(e)});return t.id=t.id||Object(Wu.a)(),{feature:t}})))},children:"Import"})})]})})]})})]})},sf="simple_select",lf=function(e){var t=e.overlay,n=e.setOverlay,a=e.modeSelected;return Object(y.jsxs)("div",{className:"flex items-center space-x-3",children:[Object(y.jsx)(wp,{value:"CLU"===t,onToggle:function(e){var t=e.target.checked;n(t?"CLU":null),a(sf)}}),Object(y.jsx)(_p,{value:"SAT"===t,onToggle:function(e){var t=e.target.checked;n(t?"SAT":null),a(sf)}}),Object(y.jsx)(of,{})]})};lf.defaultProps={overlay:null};var df=lf,uf=function(e){var t=e.mode,n=e.modeSelected,a=e.onDelete,r=e.onSubtract,c=e.onSplit,i=e.setZoom,o=e.overlay,s=e.setOverlay,l=e.features,d=e.setSelectedShapeIds,u=e.showSplitToolPopup,b=Object(p.i)();return Object(y.jsxs)("div",{"data-testid":"draw-tools",children:[(b.pathname.match("".concat(Cc.properties,"/create"))||b.pathname.match("".concat(Cc.properties,"/edit")))&&Object(y.jsxs)("div",{"data-testid":"map-tools",children:[Object(y.jsx)("div",{className:"absolute z-1 top-0 left-0 m-5",children:Object(y.jsx)(df,{overlay:o,setOverlay:s,modeSelected:n})}),Object(y.jsx)("div",{className:"absolute z-1 bottom-0 top-0 right-0 m-5",children:Object(y.jsxs)("div",{className:"right-0",children:[Object(y.jsx)(dp,{mode:t,modeSelected:n,overlay:o}),Object(y.jsx)(Cp,{onDelete:a,onSubtract:r,onSplit:c,features:l,setSelectedShapeIds:d,showSplitToolPopup:u})]})})]}),Object(y.jsx)(Ep,{setZoom:i})]})};uf.defaultProps={setZoom:function(){},overlay:null,features:[]};var bf=uf,jf=function(e){var t,n=Array.isArray(null===e||void 0===e||null===(t=e[0])||void 0===t?void 0:t[0])?e.flat():e;if(!((null===n||void 0===n?void 0:n.length)>0))return!1;var a=n.length,r=0,c=0;null===n||void 0===n||n.forEach((function(e){var t=e[0],n=e[1];r+=t,c+=n})),r/=a,c/=a;var i=[];return isNaN(r)||isNaN(c)?"NONE":(i.push(r,c),i)},pf=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Untitled";return[jf(e.flat()),t]},ff=function(e){var t,n=e.geoCollection,a=e.activeObjectType,r=function(e){var t=[],n=[];return(null===e||void 0===e?void 0:e.features).forEach((function(e){var a,r,c=Boolean(null===e||void 0===e||null===(a=e.properties)||void 0===a?void 0:a.archived);if(void 0===(null===e||void 0===e||null===(r=e.properties)||void 0===r?void 0:r.crop)){var i,o,s,l=pf(null===e||void 0===e||null===(i=e.geometry)||void 0===i?void 0:i.coordinates,null!==(o=null===e||void 0===e||null===(s=e.properties)||void 0===s?void 0:s.name)&&void 0!==o?o:"Untitled-Field");t.push({coordinates:l[0],name:l[1],isArchived:c})}else{var d,u,b,j,p=pf(null===e||void 0===e||null===(d=e.geometry)||void 0===d?void 0:d.coordinates,null!==(u=null===e||void 0===e||null===(b=e.properties)||void 0===b?void 0:b.name)&&void 0!==u?u:"Untitled-Cropzone");n.push({coordinates:p[0],name:p[1],parentFieldId:null===e||void 0===e||null===(j=e.properties)||void 0===j?void 0:j.$parentFieldId})}})),{fieldPoints:t,cropZonePoints:n,archivedPoints:{}}}(n),c=[];if(c="field"===a||"cropzone"===a?r.cropZonePoints:r.fieldPoints,(null===n||void 0===n||null===(t=n.features)||void 0===t?void 0:t.length)>0){var i=[];if("farm"===a||""===a)i=c;else{var o=new Map;c.forEach((function(e){var t="".concat(e.parentFieldId,"-").concat(e.coordinates[0],"-").concat(e.coordinates[1]),n=o.get(t);n?o.set(t,Object(I.a)(Object(I.a)({},n),{},{cropZoneNames:[].concat(Object(v.a)(n.cropZoneNames),[e.name])})):o.set(t,Object(I.a)({cropZoneNames:[e.name]},e))})),i=Object(v.a)(o.values())}return i.map((function(e){var t,n;return Object(y.jsx)(eb.Marker,{coordinates:e.coordinates,anchor:"center",style:{pointerEvents:"none"},children:Object(y.jsxs)("div",{"data-tag":"map-marker-children",className:"flex flex-col items-center justify-center",children:[Object(y.jsx)("div",{className:"text-center self-center text-white font-bold text-lg",children:null!==(t=null===e||void 0===e||null===(n=e.cropZoneNames)||void 0===n?void 0:n.map((function(e){return Object(y.jsx)("div",{"data-tag":"map-marker-cropzone",className:"my-1",children:e},ic.a.generate())})))&&void 0!==t?t:Object(y.jsx)("div",{"data-tag":"map-marker-field",children:e.name})},ic.a.generate()),e.isArchived&&Object(y.jsx)("div",{"data-tag":"map-marker-field-archived",className:"text-center self-center w-fit mt-1 text-white rounded-md bg-neutral-80 px-1 py-0.5",children:"ARCHIVED"})]})},ic.a.generate())}))}return null};ff.defaultProps={geoCollection:[],activeObjectType:""};var mf=ff,vf=function(e){var t=e.match(/^[ ]*(?:Lat: )?(-?\d+\.\d*)[, ]+(?:Lng: )?(-?\d+\.\d*)[ ]*$/i);if(!t)return null;function n(e,t){return{center:[e,t],geometry:{type:"Point",coordinates:[e,t]},place_name:"Lat: ".concat(t," Lng: ").concat(e),place_type:["coordinate"],properties:{},type:"Feature"}}var a=Number(t[1]),r=Number(t[2]),c=[];return(a<-90||a>90)&&c.push(n(a,r)),(r<-90||r>90)&&c.push(n(r,a)),0===c.length&&c.push(n(r,a)),c},Of=n.p+"static/media/properties-map-icon.488d6f16.svg",hf=function(e){var t=e.baseText;return Object(y.jsxs)("div",{"data-testid":"empty-summary",children:[Object(y.jsx)("div",{className:"flex justify-center",children:Object(y.jsx)("img",{src:Of,alt:"",style:{width:"65%"}})}),Object(y.jsx)("div",{className:"flex justify-center pb-4",children:Object(y.jsx)("p",{className:"text-sm w-180px text-center",children:t})})]})};hf.defaultProps={baseText:"Select one or more properties from the list to assign a crop"};var xf=hf,gf=function(e){return ae.a.reduce(e,(function(e,t){return e&&e[t.farmName]?(e[t.farmName].push(t),e):e&&!e[t.farmName]?Object(I.a)(Object(I.a)({},e),{},Object(et.a)({},t.farmName,[t])):Object(et.a)({},t.farmName,[t])}),{})},Cf=function(e){var t=e.children,n=e.unit,a=e.roundedTo,r=Intl.NumberFormat("en-US",Object(I.a)({minimumFractionDigits:a,maximumFractionDigits:a},"usCurrency"===n?{style:"currency",currency:"USD"}:{})).format;return Object(y.jsxs)(y.Fragment,{children:[r(t),"bu"===n&&" bu"]})};Cf.propTypes={children:wc.a.oneOfType([wc.a.number,wc.a.string]),unit:wc.a.oneOf(["bu","usCurrency"]),roundedTo:wc.a.number},Cf.defaultProps={unit:null,children:void 0,roundedTo:void 0};var yf=Cf,Pf=function(e){var t=e.extraTagsNames;return Object(y.jsx)("div",{className:"list-none leading-normal",children:null===t||void 0===t?void 0:t.map((function(e){return Object(y.jsx)("li",{children:e},e)}))})},Af=function(e,t){var n=[],a=[],r=0,c=0;return null===e||void 0===e||e.forEach((function(e){var i,o;c+(null===e||void 0===e||null===(i=e.name)||void 0===i?void 0:i.length)+2<t?(c+=(null===e||void 0===e||null===(o=e.name)||void 0===o?void 0:o.length)+2,a.push(e)):(n.push(null===e||void 0===e?void 0:e.name),r+=1)})),{extraTagsCount:r,extraTagsNames:n,tagsToDisplay:a}},Sf=function(e){var t,n=e.displayTagsObject,a=e.isLandingPage,r=e.viewKey,c=localStorage.getItem(r),i=a?"gr-text-neutral-70 px-2 bg-neutral-20 rounded-md text-xs":"w-1/12 text-center gr-text-neutral-80 px-2";return i=!0===a&&"list"===c?"py-1 ".concat(i):i,Object(y.jsxs)("div",{className:"flex flex-nowrap space-x-2",children:[Object(y.jsx)("div",{className:"flex space-x-2 gr-whitespace-nowrap","data-testid":"tag-container",children:null===n||void 0===n||null===(t=n.tagsToDisplay)||void 0===t?void 0:t.map((function(e){return Object(y.jsx)(m.Tag,{color:e.color,children:e.name},e.id)}))}),(null===n||void 0===n?void 0:n.extraTagsCount)>0?Object(y.jsxs)("div",{className:i,children:["+",null===n||void 0===n?void 0:n.extraTagsCount]}):Object(y.jsx)("div",{className:"pb-5"})]})},Tf=function(e){var t=e.setOpenTags,n=e.tags,a=e.displayTagsObject,r=e.viewKey,c=e.disabled,i=e.prompt;return Object(y.jsx)("button",{"data-testid":"tags-btn",type:"button",onClick:function(){return t(!0)},className:"border border-neutral-30 px-2 rounded-md w-full py-1",disabled:c,children:(null===n||void 0===n?void 0:n.length)>0?Object(y.jsx)(Sf,{displayTagsObject:a,isLandingPage:!1,viewKey:r}):Object(y.jsx)("div",{className:"text-neutral-600 text-md text-left px-1",children:i})})};Tf.defaultProps={disabled:!1,prompt:"Add Tags"};var Nf=Tf,Ef=n(2808),wf=n(2809),_f=function(e){var t,n=e.action,a=e.crop,r=e.count,c={Added:{Icon:Object(y.jsx)(Ii.a,{fontSize:"small"}),color:"text-cucumber-green-700"},TagsAdded:{Icon:Object(y.jsx)(Ii.a,{fontSize:"small"}),color:"text-cucumber-green-700"},TagsDeleted:{Icon:Object(y.jsx)(Ef.a,{fontSize:"small"}),color:"text-remove"},Deleted:{Icon:Object(y.jsx)(Ef.a,{fontSize:"small"}),color:"text-remove"},Changed:{Icon:Object(y.jsx)(wf.a,{fontSize:"small"}),color:"text-info-dark-blue"}};return Object(y.jsxs)("p",{className:"text-left font-semibold font-body flex items-center leading-4 ".concat(c[n].color),children:[c[n].Icon,(t=n,"TagsAdded"===t?Object(y.jsx)("span",{className:"pl-1 inline-block",children:"".concat(null===a||void 0===a?void 0:a.name," (tags added)")}):"TagsDeleted"===t?Object(y.jsx)("span",{className:"pl-1 inline-block",children:"".concat(null===a||void 0===a?void 0:a.name," (").concat(r," tags deleted)")}):Object(y.jsx)("span",{className:"pl-1 inline-block",children:"".concat(null===a||void 0===a?void 0:a.name," ").concat(n)}))]})},Rf=function(e){var t,n,r,c=e.massiveChangeSummary,i=e.property,o=e.cropName,s=Object(a.useState)({extraTagsCount:0,extraTagsNames:[],tagsToDisplay:[]}),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)((null===c||void 0===c?void 0:c.flags)||[]),p=Object(b.a)(j,1)[0];return Object(a.useEffect)((function(){u(Af(p,18))}),[p]),"Added"===c.action?Object(y.jsxs)("div",{children:[Object(y.jsx)(_f,{action:null===c||void 0===c?void 0:c.action,crop:null===c||void 0===c?void 0:c.crop,count:null===d||void 0===d||null===(t=d.tagsToDisplay)||void 0===t?void 0:t.length}),Object(y.jsxs)("p",{className:"text-neutral-600 text-xs pl-6 text-left mt-2",children:[Object(y.jsx)(yf,{roundedTo:2,children:null===i||void 0===i?void 0:i.boundaryArea})," ac \u2022 ".concat(null===c||void 0===c||null===(n=c.crop)||void 0===n?void 0:n.name)]})]}):Object(y.jsx)("div",{className:"flex flex-col w-full divide-y divide-gray-400",children:null===(r=i.cropzones)||void 0===r?void 0:r.map((function(e,t){var n;return(!o||o===e.crop.name)&&Object(y.jsxs)("div",{className:"w-full pb-2 ".concat(t>0&&"pt-3"),children:[Object(y.jsx)(_f,{action:c.action,crop:e,count:null===d||void 0===d||null===(n=d.tagsToDisplay)||void 0===n?void 0:n.length}),"Changed"===c.action&&Object(y.jsxs)("p",{className:"text-xs pl-6 text-left mt-2",children:["From ",e.crop.name," to ",c.crop.name]}),Object(y.jsxs)("p",{className:"text-neutral-600 text-xs pl-6 text-left mt-2",children:[Object(y.jsx)(yf,{roundedTo:2,children:e.boundaryArea})," ac \u2022 ".concat("Changed"===c.action?c.crop.name:e.crop.name)]}),("TagsAdded"===c.action||"TagsDeleted"===c.action)&&Object(y.jsx)("div",{className:"pl-6 mt-2 mr-1",children:d.extraTagsNames.length>0?Object(y.jsx)(fu,{position:"bottom",ariaLabel:"Task Tags",top:"1.5rem",msg:Object(y.jsx)(Pf,{extraTagsNames:d.extraTagsNames}),component:Object(y.jsx)(Sf,{displayTagsObject:d,isLandingPage:"view",viewKey:fd})}):Object(y.jsx)(Sf,{displayTagsObject:d,isLandingPage:"view",viewKey:fd})})]})}))})};Rf.defaultProps={massiveChangeSummary:{},property:{},cropName:""};var If=Rf,Df=function(e){var t=e.massiveChangeSummary,n=gf(t.fieldsToMassiveAssign);return Object(y.jsx)(m.Table,{children:Object.entries(n).map((function(e){return Object(y.jsxs)(m.Table.RowGroup,{arrowIcon:!0,children:[Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("p",{className:"font-semibold font-body",children:e[0]})})}),e[1].map((function(e){return Object(y.jsxs)(m.Table.RowGroup,{arrowIcon:!0,children:[Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("p",{className:"font-semibold font-body",children:e.name})})}),Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(If,{massiveChangeSummary:t,property:e},e.id)})})]},e.id)}))]},e[0])}))})};Df.defaultProps={massiveChangeSummary:{}};var kf=Df,Lf=function(e){var t=e.massiveChangeSummary,n=e.mappedFarmView;return Object(y.jsx)(m.Table,{children:Object(y.jsxs)(m.Table.RowGroup,{arrowIcon:!0,children:[Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("p",{className:"font-semibold font-body","data-testid":"view-by-crops",children:t.crop.name})})}),Object.entries(n).map((function(e){return Object(y.jsxs)(m.Table.RowGroup,{arrowIcon:!0,children:[Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("p",{className:"font-semibold font-body",children:e[0]})})}),e[1].map((function(e){return Object(y.jsxs)(m.Table.RowGroup,{arrowIcon:!0,children:[Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("p",{className:"font-semibold font-body",children:e.name})})}),Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(If,{massiveChangeSummary:t,property:e},e.id)})})]},e.id)}))]},e[0])}))]})})};Lf.defaultProps={massiveChangeSummary:{},mappedFarmView:[]};var Ff=Lf,Mf=function(e){var t=e.massiveChangeSummary,n=e.mappedCropView;return Object(y.jsx)(m.Table,{children:Object.entries(n).map((function(e){return Object(y.jsxs)(m.Table.RowGroup,{arrowIcon:!0,children:[Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("p",{className:"font-semibold font-body","data-testid":"view-by-crops",children:e[0]})})}),Object.entries(e[1]).map((function(n){return Object(y.jsxs)(m.Table.RowGroup,{arrowIcon:!0,children:[Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("p",{className:"font-semibold font-body",children:n[0]})})}),n[1].map((function(n){return Object(y.jsxs)(m.Table.RowGroup,{arrowIcon:!0,children:[Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("p",{className:"font-semibold font-body",children:n.name})})}),Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(If,{massiveChangeSummary:t,property:n,cropName:e[0]},n.id)})})]},n.id)}))]},n[0])}))]},e[0])}))})};Mf.defaultProps={massiveChangeSummary:{},mappedCropView:[]};var Vf=Mf,Bf=function(e){var t,n=e.massiveChangeSummary,a=gf(n.fieldsToMassiveAssign),r=(t=n.fieldsToMassiveAssign,ae.a.reduce(t,(function(e,t){return ae.a.reduce(t.cropzones,(function(e,n){if(e&&e[n.crop.name]&&e[n.crop.name][t.farmName])e[n.crop.name][t.farmName].push(t);else{if(!e||!e[n.crop.name]||e[n.crop.name][t.farmName])return e&&!e[n.crop.name]?Object(I.a)(Object(I.a)({},e),{},Object(et.a)({},n.crop.name,Object(et.a)({},t.farmName,[t]))):Object(et.a)({},n.crop.name,Object(et.a)({},t.farmName,[t]));e[n.crop.name]=Object(I.a)(Object(I.a)({},e[n.crop.name]),{},Object(et.a)({},t.farmName,[t]))}return e}),e)}),{}));return"Added"===n.action?Object(y.jsx)(Ff,{mappedFarmView:a,massiveChangeSummary:n}):Object(y.jsx)(Vf,{mappedCropView:r,massiveChangeSummary:n})};Bf.defaultProps={massiveChangeSummary:{}};var Uf=Bf,zf=function(e){var t=e.massiveChangeSummary,n=e.viewBy;return Object(y.jsx)("div",{children:"farm"===n?Object(y.jsx)(kf,{massiveChangeSummary:t}):Object(y.jsx)(Uf,{massiveChangeSummary:t})})};zf.defaultProps={massiveChangeSummary:{}};var Zf=zf,Yf=[{key:"crops",value:"Crops"},{key:"farm",value:"Farm"}],Hf=function(e){var t=e.massiveChangeSummary,n=Object(a.useState)("farm"),r=Object(b.a)(n,2),c=r[0],i=r[1],o=go((function(e,t){i(t)}),xo);return Object(y.jsxs)("div",{"data-testid":"selected-fields-summary",className:"flex flex-col",style:{height:"calc(100% - 1px)"},children:[Object(y.jsxs)("div",{className:"sticky top-9 bg-white z-1 pt-2",children:[Object(y.jsx)("label",{htmlFor:"viewBy",className:"text-neutral-600 text-sm inline-block",children:"View By"}),Object(y.jsx)(m.Select,{name:"viewBy",placeholder:"View By",items:Yf,value:c,onChange:o})]}),Object(y.jsx)("div",{className:"mt-4 overflow-y-auto h-full flex flex-grow",children:Object(y.jsx)(Zf,{massiveChangeSummary:t,viewBy:c})})]})};Hf.defaultProps={massiveChangeSummary:{}};var Gf=Hf,Wf=function(e){var t,n=e.massiveChangeSummary,a=!(null!==(t=n.fieldsToMassiveAssign)&&void 0!==t&&t.length);return Object(y.jsx)("div",{className:"absolute right-0 flex flex-col z-4 h-full",style:{height:"calc(100% - 64px - 164px - 20px)",top:64},children:Object(y.jsxs)("div",{className:"bg-white w-300px m-5 px-5 pb-8 rounded max-h-full flex flex-col",children:[Object(y.jsx)("h4",{className:"font-semibold font-body z-1 sticky top-0 bg-white pt-3",children:"Change Summary"}),a?Object(y.jsx)(xf,{}):Object(y.jsx)(Gf,{massiveChangeSummary:n})]})})};Wf.defaultProps={massiveChangeSummary:{}};var qf=Wf,Jf={propertylanding:{elementsToSum:["mass-assigner-header"],defaultSub:12},integrations:{elementsToSum:["mass-assigner-header","integration-proggress-bar","mccain-footer","integration-property-toolbar"],defaultSum:76}},Kf=function(){return Object(y.jsx)("div",{"data-testid":"printable-area-boundary",className:"absolute left-2 right-2 z-1 m-auto pointer-events-none border-4 border-banner-alert-blue-30",style:{top:"calc(50% + 32px)",width:"calc(100% - 16px)",maxWidth:"calc((100vh - 196px)*647 / 420)",aspectRatio:"647 / 420",transform:"translateY(-50%)"},children:Object(y.jsx)("div",{className:"absolute py-1 px-2 h-7 leading-5 flex items-center justify-center",style:{top:"-28px",left:"-4px",backgroundColor:"#82CFFF",borderRadius:"4px 4px 0 0",fontSize:"12px"},children:"Printable area"})})},Qf=["properties"],Xf="pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",$f=Object(eb.default)({accessToken:Xf,minZoom:1,maxZoom:20}),em=function(e){var t=e.noCard,n=e.children,r=Object(a.useContext)(ac),c=function(e){var t,n,a,r,c=window.location.pathname.split("/").pop(),i=null===(t=Jf[c])||void 0===t||null===(n=t.elementsToSum)||void 0===n?void 0:n.reduce((function(e,t){var n;return e+((null===(n=document.getElementById(t))||void 0===n?void 0:n.clientHeight)||0)}),(null===(a=Jf[c])||void 0===a?void 0:a.defaultSum)||0),o=(null===(r=Jf[c])||void 0===r?void 0:r.defaultSub)||0;return"calc(100vh - ".concat((e?154:64)+(i||o)-o,"px)")}(Object(b.a)(r,1)[0].isMassAssignerActive);return t?Object(y.jsx)("div",{className:"relative w-full",style:{height:c},children:n}):Object(y.jsx)(m.Card,{children:Object(y.jsx)(m.Card.Content,{children:Object(y.jsx)("div",{className:"relative w-full",style:{height:c},children:n})})})},tm=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"selected";return e.map((function(e){var n=e.properties,a=Object(te.a)(e,Qf);return Object(I.a)(Object(I.a)({},a),{},{properties:Object(I.a)(Object(I.a)({},n),{},{$layer:t})})}))},nm=function(e){return["draw_polygon","drag_circle"].includes(e)},am=function(e){return["select_only","simple_select"].includes(e)},rm=function(e){return["focused","selected"].includes(e)},cm=function(e){var t=e.currentCoordinates,n=e.setCurrentCoordinates,r=e.displayOnly,c=e.geoJSONCollection,i=e.customStyles,o=e.handleDrawCreate,s=e.handleDrawUpdate,l=e.handleDrawDelete,d=e.liveUpdate,u=e.mode,j=e.modes,p=e.setMode,m=e.modeReset,v=e.zoom,O=e.setZoom,h=e.stretch,x=e.fieldsLoading,g=e.labelName,C=e.isCreate,P=Object(a.useState)(!1),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)(!1),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(null),D=Object(b.a)(R,2),k=D[0],L=D[1],F=Object(a.useState)(!1),M=Object(b.a)(F,2),V=M[0],B=M[1],U=Object(a.useState)(!1),z=Object(b.a)(U,2),Z=z[0],H=z[1],W=Fb(u),q=W.onMapMouseMoved,J=W.onMapMouseDown,K=!r,Q=new rb.a({accessToken:Xf,collapsed:!0,localGeocoder:vf,placeholder:"ZIP, Address, Lat/Long",mapboxgl:Xn.a}),X=new Qn.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),$=Object(a.useContext)(ac),ee=Object(b.a)($,2),te=ee[0],ae=te.organization,re=te.massiveChangeSummary,ce=te.isMassAssignerActive,ie=te.fieldsToMassiveAssign,oe=te.isExportPDFMapsActive,se=ee[1],le=Object(f.useFlags)(),de=Object(a.useContext)(xj),ue=de.selectedShapeIds,be=de.setSelectedShapeIds,je=de.newFeatures,pe=de.mapChangeEvent,fe=de.archiveMapHistoryFeature,me=Object(a.useRef)(null),ve=Object(a.useRef)(new Event("init ref event")),Oe=Object(a.useRef)(),he=Object(a.useRef)([]),xe=yc(le.releaseFeGeoJsonLayerMapLabel,le.releaseFeGeoJsonLayerMapLabelByOrg,ae.id),ge=sj(c.features),Ce=!r||"select_only"===u,ye=Object(a.useMemo)((function(){return K?(e=c,Object(Hu.featureCollection)(e.features.filter((function(e){var t=e.properties;return"selected"!==(null===t||void 0===t?void 0:t.$layer)||!!t.$noEdit})))):oe?function(e,t){var n=Object(ne.flattenDeep)(e.map((function(e){return e.cropzones.map((function(e){return e.id}))})));return Object(Hu.featureCollection)(t.features.filter((function(e){var t=e.properties;return"cropzone"!==t.$landType||n.includes(t.id)})).map((function(e){return Object(I.a)(Object(I.a)({},e),{},{properties:Object(I.a)(Object(I.a)({},e.properties),{},{$layer:"cropzone"===e.properties.$landType?"focused":e.properties.$layer,sortKey:"cropzone"===e.properties.$landType?n.length-n.indexOf(e.properties.id)+1:0})})})))}(ie,c):Object(Hu.featureCollection)(c.features);var e}),[K,oe,ie,c]);me.current&&Ce&&K&&ge.forEach((function(e){var t=e.features,n=function(e){return e.filter((function(e){var t,n=e.properties;return"selected"===(null===n||void 0===n?void 0:n.$layer)&&!(null!==(t=n.$noEdit)&&void 0!==t&&t)}))}(void 0===t?[]:t).map((function(e){return Object(I.a)({id:e.properties.id,description:e.properties.name},e)}));me.current.draw.add(Object(Hu.featureCollection)(n))}));var Pe=Object(a.useCallback)((function(e){return ye.features.find((function(t){return t.id===e.id}))}),[ye]),Ae=bb,Se=Object(a.useCallback)((function(e,t){e.id&&d&&me.current.draw.delete(e.id);var n=t(e);return d&&me.current.draw.add(e),n}),[d]),Te=Mb(o,s,Se,_).onDrawChanged,Ne=function(){var e=me.current.draw.getMode();"direct_select"===e?me.current.draw.trash():"simple_select"===e&&_(!0)},Ee=function(){var e=dj(me.current);e&&(l(e),be([])),_(!1)},we=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=uj(me.current)){e.next=5;break}bc(se)("You must select a shape completely contained by the other selected shape"),e.next=10;break;case 5:return n=t.added,a=t.deleted,e.next=8,l(a);case 8:be([]),Se(n,(function(e){o([e])}));case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),_e=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=bj(me.current,Oe.current,t),a=n.added,r=n.deleted,a?(l([Oe.current]),he.current=he.current.concat(r),c=tm(a.features),o(c,r)):bc(se)("The split could not be performed as requested."),Oe.current=null,m();case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Re=Object(a.useCallback)((function(e){var t=e.feature;me.current.draw.add(t);var n=tm([t],"focused");o(n)}),[o]),Ie=Object(a.useMemo)((function(){return C&&am(u)&&!k&&!c.features.some((function(e){return rm(e.properties.$layer)}))}),[C,k,u,c.features]),De=Object(a.useMemo)((function(){return c.features.some((function(e){return rm(e.properties.$layer)}))&&1!==ue.length}),[c.features,ue]);Object(a.useEffect)((function(){if(!r&&c.features.length&&me.current){var e=me.current.draw.getAll();c.features.forEach((function(t){var n=(!t.properties||!1!==t.properties.includeOnMaps)&&!he.current.includes(t.id),a=e.features.find((function(e){return e.id===t.id}));!n||a||Pe(t)?!n&&a&&me.current.draw.delete(a.id):me.current.draw.add(t)}))}}),[c,r,Pe]),Object(a.useEffect)((function(){var e;am(u)&&S&&null!==(e=me.current)&&void 0!==e&&e.draw&&me.current.draw.changeMode(u,{featureIds:ue||[]})}),[u,S,ue]),Object(a.useEffect)((function(){var e;!r&&"select_only"!==u&&S&&null!==(e=me.current)&&void 0!==e&&e.draw&&me.current.draw.getMode()!==u&&me.current.draw.changeMode(u)}),[u,S,me,r]),Object(a.useEffect)((function(){pe.timeStamp!==ve.current.timeStamp&&je.length>0&&(ve.current=pe,je.forEach((function(e){if(e.featureType===xb&&(Re(e),fe(e)),e.featureType===gb){var t=tm([e.feature]);o(t),fe(e)}e.featureType===Cb&&(l([e.feature.id]),fe(e))})))}),[pe,je,Re,o,l,fe]);var ke=function(e){be(e.map((function(e){return e.feature.id})))};return Object(y.jsx)(pu,{"data-testid":"land-map",className:h?"flex-grow flex-col flex":"h-full",onMouseEnter:function(){Ie&&B(!0)},onMouseLeave:function(){return B(!1)},children:Object(y.jsxs)(em,{noCard:h,children:[Object(y.jsx)(Vb,{position:"center",ariaLabel:"Click to split",msg:"To use the split tool, please select the shape you want to split on the map, one at a time",showPopup:Z}),V&&Object(y.jsx)(Vb,{position:"center",ariaLabel:"Click to draw",msg:"Click to start drawing a shape",showPopup:V}),ce&&Object(y.jsx)(qf,{massiveChangeSummary:re}),Object(y.jsx)(bf,{modeSelected:p,mode:u,onDelete:Ne,onSubtract:we,onSplit:function(){Oe.current=ue[0],p("draw_line_string")},setCurrentCoordinates:n,setZoom:O,overlay:k,setOverlay:L,features:c.features,setSelectedShapeIds:be,showSplitToolPopup:function(e){H(!(!De||e))}}),oe&&Object(y.jsx)(Kf,{}),Object(y.jsxs)($f,{style:"mapbox://styles/mapbox/satellite-streets-v11",zoom:v,center:t||lb,flyToOptions:Ae,containerStyle:{height:"100%",width:"100%"},onStyleLoad:function(e){e.addControl(Q,"bottom-right"),e.addControl(X,"bottom-right"),T(!0)},onMouseMove:function(e,t){var n;if(!r&&null!==(n=me.current)&&void 0!==n&&n.draw){var a=me.current.draw.getMode();nm(a)&&q(t,me)}},onMouseDown:function(e,t){var n;if(!r&&null!==(n=me.current)&&void 0!==n&&n.draw){var a=me.current.draw.getMode();nm(a)&&J(t)}},onMouseUp:function(){Ie&&p("draw_polygon")},children:[Object(y.jsx)(Zj,{geoJSON:ye,customStyles:i,setZoom:O,visible:r||K,activeObjectType:g,isGeoJSONLabelEnabled:xe},"map-feature-with-label:".concat(xe)),"CLU"===k&&Object(y.jsx)(Kj,{type:Hj.CLU,setZoom:O,geoJSONCollection:c,onChange:ke,onDelete:Ee}),"SAT"===k&&Object(y.jsx)(Kj,{type:Hj.SATELLITE,setZoom:O,geoJSONCollection:c,onChange:ke,overlay:k,onDelete:Ee}),Ce&&Object(y.jsx)(nb.a,{ref:function(e){me.current=e},onDrawCreate:function(e){if("draw_line_string"===me.current.draw.getMode()){var t=Object(b.a)(e.features,1)[0];_e(t)}else{var n=(K?tm(e.features):e.features).map((function(e){if(e.properties.isCircle){var t=e.properties,n=t.$layer,a=t.center;return Object(I.a)(Object(I.a)({},e),{},{properties:{$layer:n,center:a}})}return e}));Te(n,jb)}},onDrawDelete:function(e){Te(e.features,fb)},onDrawUpdate:function(e){Te(e.features,pb)},onDrawSelectionChange:function(){return be(me.current.draw.getSelectedIds())},defaultMode:"simple_select",displayControlsDefault:!1,modes:j,styles:Eb}),!x&&!xe&&Object(y.jsx)(mf,{geoCollection:c,activeObjectType:g}),Object(y.jsx)(Cj,{onDelete:Ne,setMode:p})]}),Object(y.jsx)(ib,{open:w&&!r,itemType:"Shape",onDelete:function(){var e=dj(me.current);e?(l(e),be([])):bc(se)("You must select a shape to delete"),_(!1)},onCancel:function(){return _(!1)}})]})})};cm.defaultProps={currentCoordinates:null,setCurrentCoordinates:function(){},displayOnly:!1,geoJSONCollection:{features:[]},customStyles:null,handleDrawCreate:function(){},handleDrawUpdate:function(){},handleDrawDelete:function(){},liveUpdate:!0,history:null,zoom:db,setZoom:function(){},stretch:!1,labelName:"",isCreate:!1};var im=r.a.memo(Object(p.l)(cm)),om="MAP_HISTORY_SET_NEW_FEATURE",sm="MAP_HISTORY_SET_FEATURE_PROCESSED",lm=function(){return{newFeatures:[],archivedFeatures:[],mapChangeEvent:new Event("init history")}},dm=function(e){var t=e.payload,n=e.mapChangeEvent;return Array.isArray(t)?t.map((function(e){return{feature:e.feature,featureType:e.featureType,featureAttributes:e.featureAttributes,mapChangeEvent:n}})):Object(I.a)(Object(I.a)({},t),{},{mapChangeEvent:n})},um=function(e){return function(t){return t.mapChangeEvent.timeStamp===e.mapChangeEvent.timeStamp}},bm=function(e,t){var n=function(e){var t=e.payload&&e.payload.event?e.payload.event:new Event(e.type);return Object(I.a)(Object(I.a)({},e),{},{mapChangeEvent:t})}(t);switch(t.type){case om:return Object(I.a)(Object(I.a)({},e),{},{newFeatures:e.newFeatures.concat(dm(n)),mapChangeEvent:n.mapChangeEvent});case sm:return Object(I.a)(Object(I.a)({},e),{},{archivedFeatures:[].concat(Object(v.a)(e.archivedFeatures),[e.newFeatures.find(um(n))]),newFeatures:e.newFeatures.filter((function(e){return!um(n)(e)}))});default:return e}},jm=function(){var e=Object(a.useCallback)(Aj,[]),t=Bo([],e),n=Object(b.a)(t,4),r=n[0],c=n[1],i=n[2],o=n[3],s=Object(a.useReducer)(bm,lm(),lm),l=Object(b.a)(s,2),d=l[0],u=d.mapChangeEvent,j=d.newFeatures,p=l[1];return{selectedShapeIds:r,setSelectedShapeIds:c,setSelectedShapesExternally:i,internalShapeSelectionChanges:o,mapChangeEvent:u,newFeatures:j,addNewMapFeature:Object(a.useCallback)((function(e,t,n){p({type:om,payload:{featureType:e,feature:t,featureAttributes:n}})}),[]),addNewMapFeatures:Object(a.useCallback)((function(e,t){p({type:om,payload:t.map((function(t){var n=t.feature,a=t.featureAttributes;return{featureType:e,feature:n,featureAttributes:a}}))})}),[]),archiveMapHistoryFeature:function(e){p({type:sm,payload:{event:e.mapChangeEvent}})}}},pm=function(){var e=Lb(),t=Object(b.a)(e,1)[0],n=t.drawDistance,a=t.drawArea,r=t.coordinates,c=t.feature,i=r||[],o=Object(b.a)(i,2),s=o[0],l=o[1],d=n?{left:"".concat(s+20,"px"),top:"".concat(l-20,"px"),textShadow:"-1px -1px 0 #000,  1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000"}:{},u=a?{left:"".concat(s-20,"px"),top:"".concat(l+20,"px"),textShadow:"-1px -1px 0 #0060A4,  1px -1px 0 #0060A4, -1px 1px 0 #0060A4, 1px 1px 0 #0060A4"}:{},j=c?{left:"".concat(s,"px"),top:"".concat(l,"px"),textShadow:"-1px -1px 0 #0060A4,  1px -1px 0 #0060A4, -1px 1px 0 #0060A4, 1px 1px 0 #0060A4"}:{};return Object(y.jsxs)(y.Fragment,{children:[a&&Object(y.jsxs)("div",{"data-testid":"map-event-display-area",style:u,className:"text-white absolute pointer-events-none z-10",children:[a," acres"]}),n&&Object(y.jsxs)("div",{"data-testid":"map-event-display-distance",style:d,className:"text-white absolute pointer-events-none z-10",children:[n," ft"]}),c&&Object(y.jsxs)("div",{"data-testid":"map-event-display-feature-info",style:j,className:"text-white absolute pointer-events-none z-10",children:[Object(y.jsx)(hu,{units:"acres",children:Tj([c])}),c.properties.crops&&Object(y.jsxs)("div",{children:["(",c.properties.crops,")"]})]})]})},fm=function(e){var t=e.currentCoordinates,n=e.displayOnly,r=e.fields,c=e.geoJSONCollection,i=e.liveUpdate,o=e.onClickShape,s=e.onFeaturesChange,l=e.onSelectFeatures,d=e.parentId,u=e.selectedFeatureIds,j=e.setCurrentCoordinates,f=e.setZoom,m=e.stretch,v=e.zoom,O=e.fieldsLoading,h=e.labelName,x=e.shapeIdSelected,g=e.isCreate,C=e.setNewFieldFeatures,P=e.customStyles,A=jm(),S=A.selectedShapeIds,T=A.setSelectedShapeIds,N=A.setSelectedShapesExternally,E=A.internalShapeSelectionChanges,w=A.mapChangeEvent,_=A.newFeatures,R=A.addNewMapFeature,D=A.addNewMapFeatures,k=A.archiveMapHistoryFeature,L=Object(a.useState)(!1),F=Object(b.a)(L,2),M=F[0],V=F[1],B=Object(a.useContext)(ac),U=Object(b.a)(B,1)[0],z=U.selectedProperty,Z=U.fieldsToMassiveAssign,Y=Object(I.a)(Object(I.a)({},Yu.a.modes),{},{direct_select:Gu.a,simple_select:Gu.c,drag_circle:Gu.b,select_only:$u}),H=l&&n?"select_only":"simple_select",G=Object(a.useCallback)(Sj,[]),W=Bo([],G),q=Object(b.a)(W,4),J=q[0],K=q[1],Q=q[2],X=q[3],$=Object(p.h)().location,ee=Object(a.useState)(H),te=Object(b.a)(ee,2),ae=te[0],re=te[1],ce=Object(a.useState)(hb),ie=Object(b.a)(ce,1)[0],oe=Object(a.useRef)([]);Object(a.useEffect)((function(){var e,t;t=null!==c&&void 0!==c&&null!==(e=c.features)&&void 0!==e&&e.length?pj(c):fj(r),Object(ne.isUndefined)(t)||Q(t)}),[r,c,Q]),Object(a.useEffect)((function(){Object(ne.isUndefined)(X)||s(X)}),[X,s]),Object(a.useEffect)((function(){Object(ne.isUndefined)(u)||N(u)}),[u,N]),Object(a.useEffect)((function(){l&&!Object(ne.isUndefined)(E)&&l(E)}),[E]),Object(a.useEffect)((function(){Array.isArray(x)?T(x):T([x])}),[x,T]);var se=Object(Hu.featureCollection)(J);return Object(y.jsxs)(kb,{children:[Object(y.jsx)(xj.Provider,{value:{addNewMapFeature:R,addNewMapFeatures:D,archiveMapHistoryFeature:k,onClickShape:o,fields:r,mapChangeEvent:w,markerOn:M,newFeatures:_,selectedShapeIds:S,setMarkerOn:V,setSelectedShapeIds:T},children:Object(y.jsx)(im,{currentCoordinates:t,setCurrentCoordinates:j,displayOnly:n,geoJSONCollection:se,customStyles:!Object(ne.isEmpty)(z)||Z.length||P?Object(I.a)({focused:{fillColor:"rgba(49, 180, 242, 0.4)",fillOutlineColor:"rgba(49, 180, 242, 1)",fillAntialias:!0}},P):null,handleDrawCreate:function(e,t){for(var n=0;n<e.length;n+=1)e[n].id||(e[n].id=Object(Wu.a)());var a=t?function(e){var n=e.id;return!t.includes(n)}:function(){return!0};K((function(t){var n=e.map((function(e){return jj(e,{_id:d})}));return t.filter(a).concat(n)}))},handleDrawUpdate:function(e,t){K((function(e){return e.map((function(e){var n=t.find((function(t){return t.id===e.id}));return Object(I.a)(Object(I.a)({},e),{},{geometry:n?n.geometry:e.geometry})}))})),C(t),oe.current=function(e,t){return e.map((function(e){return e===t?"UPDATE:".concat(e):e}))}(oe.current,e)},handleDrawDelete:function(e){c.features.length&&K((function(t){return t.filter((function(t){var n=t.id;return!e.includes(n)}))}))},markerOn:M,mode:ae,modeReset:function(){re(H)},setMode:re,modes:Y,liveUpdate:i,viewContext:ie,zoom:v,setZoom:f,stretch:m,fieldsLoading:O,labelName:null===(null===$||void 0===$?void 0:$.label)||void 0===(null===$||void 0===$?void 0:$.label)?h:null===$||void 0===$?void 0:$.label,isCreate:g})}),Object(y.jsx)(pm,{})]})};fm.defaultProps={currentCoordinates:null,customStyles:!1,displayOnly:!1,fields:[],geoJSONCollection:null,liveUpdate:!0,onClickShape:function(){},onFeaturesChange:function(){},onSelectFeatures:null,parentId:null,selectedFeatureIds:void 0,setCurrentCoordinates:function(){},setZoom:function(){},stretch:!1,zoom:db,shapeIdSelected:null,isCreate:!1,setNewFieldFeatures:function(){},labelName:""};var mm=fm,vm=n(797),Om=[{key:"ByRatePerArea",value:"Rate/Area"},{key:"ByTotalProduct",value:"Total Product"},{key:"ByRatePerTank",value:"Rate/Tank"}],hm="paginatedPropertiesMap",xm="propertiesMap",gm="cropSeasonsMap",Cm={status:"ready",startDate:new Date((new Date).setHours(8,0,0,0)),dueDate:Object(vm.a)((new Date).setHours(8,0,0,0),120),duration:"2",type:"General",timingEvent:"",applicationStrategy:Om[0].key,flags:[],source:[],authorizerId:"",authorizedDate:new Date((new Date).setHours(8,0,0,0)),bufferZone:"",bufferReason:"",totalAreaValue:0,tankInformation:{tankSizeValue:0,tankSizeUnit:"bag",tankCount:0,carrierPerAreaValue:0,carrierPerAreaUnit:"bag",totalCarrierValue:0,totalCarrierUnit:"bag",tankValueTypeEnteredByUser:"CarrierPerArea"},weather:[{date:"",temperature:"",temperatureUnit:"F",humidity:"",skyCondition:"",windSpeed:"",windSpeedUnit:"MPH",windDirection:"",soilMoisture:"unknown",type:"start"},{date:"",temperature:"",temperatureUnit:"F",humidity:"",skyCondition:"",windSpeed:"",windSpeedUnit:"MPH",windDirection:"",soilMoisture:"unknown",type:"end"}],applicators:[{personId:"",companyId:""}],assigneeIds:[{id:""}],notes:"",totalApplied:0,coveragePercent:100,properties:[],products:[],propertiesGroupBy:"property"},ym="88888888-8888-8888-8888-888888888888",Pm="You have unsaved changes. Navigating away will discard changes. Do you want to continue?",Am=function(e){var t=e.title,n=e.onValidationError,r=e.customText,c=e.disabled,i=e.alwaysShow,o=e.isDeleting,s=e.hideInstructions,l=e.cancelLabel,d=e.confirmLabel,u=e.type,j=Object(Zi.h)(),f=j.touched,m=j.isSubmitting,v=j.validateForm,O=Object(a.useState)(!0),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)(!1),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(!1),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)(null),R=Object(b.a)(_,2),I=R[0],D=R[1];Object(a.useEffect)((function(){o&&(S(!1),w(!0))}),[o]),Object(a.useEffect)((function(){var e=function(e){m||c?g(!1):Object(ne.values)(f).some((function(e){return!!e}))?e?(e.preventDefault(),e.returnValue=Pm):g(!0):g(!1)};return window.addEventListener("beforeunload",e),e(),function(){window.removeEventListener("beforeunload",e)}}),[f,m,c]),Object(a.useEffect)((function(){i&&g(!0)}),[i]);var k=Object(a.useCallback)((function(e){return!!E||(S(!0),D(e),!1)}),[E]),L=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,v();case 2:t=e.sent,S(!1),Object.keys(t).length&&n(t);case 5:case"end":return e.stop()}}),e)}))),[S,n]),F=Object(a.useCallback)((function(){S(!1),w(!0)}),[]);return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(p.a,{when:x&&!E,message:k}),E&&I&&Object(y.jsx)(p.b,{to:I}),Object(y.jsx)("div",{"data-testid":"confirm-modal",children:Object(y.jsx)(ao,{open:A,close:L,onConfirm:F,cancelLabel:l,confirmLabel:d,type:u,title:t||"Leaving Form",children:Object(y.jsxs)("div",{className:"pr-6",children:[r||Pm,s?null:Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("br",{}),"(Click ",Object(y.jsx)("span",{className:"font-semibold",children:"Yes"})," to discard changes, ",Object(y.jsx)("span",{className:"font-semibold",children:"No"})," to go back)"]})]})})})]})};Am.defaultProps={customText:null,title:null,onValidationError:function(){},disabled:!1,alwaysShow:!1,isDeleting:!1,hideInstructions:!1,cancelLabel:"No",confirmLabel:"Yes",type:"confirmation"};var Sm=Am,Tm=function(e,t){return e.name.toUpperCase().localeCompare(t.name.toUpperCase())},Nm=function(e){var t=Object(I.a)({},e);return t.properties.length?(t.properties.sort(Tm).forEach((function(e){return e.fields.sort(Tm).forEach((function(e){return e.cropzones.sort(Tm)}))})),t):t};function Em(e){return Object(I.a)(Object(I.a)({},e),{},{features:e.features.flatMap((function(e){var t=e.properties,n=t.archived,a=t.$landType,r=t.name,c=t.cropzones,i=Object(W.centerOfMass)(e).geometry.coordinates,o="";n?o="ARCHIVED":"field"===a&&(o=r||"Untitled-Field");var s="";return s=n?"ARCHIVED":null!==c&&void 0!==c&&c.length?c.map((function(e){return e.name})).join("\n"):r||"Untitled-Field",n?Object(I.a)(Object(I.a)({},e),{},{properties:Object(I.a)(Object(I.a)({},e.properties),{},{defaultLabel:o,fieldAndCropZoneLabel:s})}):[e,{type:"Feature",geometry:{type:"Point",coordinates:i},properties:{defaultLabel:o,fieldAndCropZoneLabel:s}}]}))})}var wm,_m,Rm=["geometry","id"],Im=["geometry","cropzones"],Dm=function(e,t){return void 0!==t&&(0!==Object.keys(t).length||t.constructor!==Object)&&("MultiPolygon"===Object(W.getType)(e)&&"Polygon"===Object(W.getType)(t)?function(e,t){return Object(W.getCoords)(e).find((function(e){return Object(W.booleanEqual)(Object(W.polygon)(e),t)}))}(e,t):Object(W.booleanEqual)(e,t))},km=function(e,t){return(t||[]).filter((function(t){var n=t.geometry;return Dm(e,n)})).map((function(e){return e.id}))},Lm=function(e,t,n){return!!km(e,[{id:n,geometry:t}]).includes(n)},Fm=function(e){return function(t,n){var a=n.geometry,r=n.cropzones,c=void 0===r?[]:r,i=Object(te.a)(n,Im);return[].concat(Object(v.a)(t),Object(v.a)(a?[Object(W.feature)(a,Object(I.a)(Object(I.a)({},i),{},{propertyId:e,cropzones:c,$landType:"field",$includedChildGeometries:km(a,c)}))]:[]),Object(v.a)(c.reduce(function(e,t,n){return function(a,r){var c=r.geometry,i=r.id,o=Object(te.a)(r,Rm);return[].concat(Object(v.a)(a),Object(v.a)(!c||0===Object.keys(c).length&&c.constructor===Object?[]:[Object(W.feature)(c,Object(I.a)(Object(I.a)({},o),{},{id:i,$landType:"cropzone",propertyId:e,$parentFieldId:t,$parentDuplicated:Lm(n,c,i)}))]))}}(e,i.id,a),[])))}},Mm=function(e,t){var n=new Map;return e.forEach((function(e){n.set(e.properties.id,e)})),t.forEach((function(e){n.set(e.properties.id,e)})),Array.from(n.values())},Vm=function(e){return function(t,n){var a,r;return Object(I.a)(Object(I.a)({},t),{},Object(et.a)({},e,(a=t[e],r=n.payload,Object(ne.isFunction)(r)?r(a):r)))}},Bm="PROPERTY_DATA_INIT_RELOAD",Um="PROPERTY_PAGINATED_DATA_INIT_RELOAD",zm="PROPERTY_DATA_LOAD_PROPERTIES",Zm="PROPERTY_DATA_PAGINATED_LOAD_PROPERTIES",Ym="RESET_PRELOADED_PAGES",Hm="PROPERTY_DATA_SET_FIELDS_LOADED",Gm="PROPERTY_DATA_SET_GEOJSON_COLLECTION_FEATURES",Wm="PROPERTY_DATA_CALCULATE_CENTROID",qm="PROPERTY_DATA_RESET_MAP_VIEW",Jm="PROPERTY_DATA_SET_FIELDS",Km="PROPERTY_DATA_SET_MAP_CENTROID",Qm="PROPERTY_DATA_SET_ZOOM",Xm="SET_PROPERTY_COSTS",$m={data:{beforeSearch:null,pagination:{preLoadedPages:[]},properties:[]},loadedBoundedAreaCount:0,zoom:ub,fieldsAndAreasCentroidCoordinates:null,fieldsAndAreasGeoJSONCollection:{type:"FeatureCollection",features:[]},loading:!0,fieldsLoading:!1,shapesLoading:!0,costs:{}},ev=function(){return $m},tv=(wm={},Object(et.a)(wm,Bm,(function(){return Object(I.a)(Object(I.a)({},$m),{},{fieldsLoading:!0})})),Object(et.a)(wm,Um,(function(e){return Object(I.a)(Object(I.a)({},e),{},{isLoadingPaginatedProperties:!0})})),Object(et.a)(wm,Ym,ev),Object(et.a)(wm,zm,(function(e,t){var n=t.payload.properties.filter((function(e){return 200===e.status||null===e.status})),a=n.flatMap((function(e){var t;return null===e||void 0===e||null===(t=e.fields)||void 0===t?void 0:t.reduce(Fm(e.id),[])}));return Object(I.a)(Object(I.a)({},e),{},{data:{properties:n},fieldsAndAreasGeoJSONCollection:Em(Object(W.featureCollection)(a)),loading:!1})})),Object(et.a)(wm,Zm,(function(e,t){var n;if(t.payload.textSearch){var a,r=t.payload.properties.filter((function(e){return 200===e.status||null===e.status})),c=r.flatMap((function(e){var t;return null===e||void 0===e||null===(t=e.fields)||void 0===t?void 0:t.reduce(Fm(e.id),[])})),i=e.beforeSearch?e.beforeSearch:Object(ne.cloneDeep)(e);return Object(I.a)(Object(I.a)({},e),{},{beforeSearch:i,data:{orgId:t.payload.orgId,properties:r,pagination:{referencePage:t.payload.referencePage,totalPages:null===(a=t.payload)||void 0===a?void 0:a.totalPages,preLoadedPages:[t.payload.parentPage]}},fieldsAndAreasGeoJSONCollection:Em(Object(W.featureCollection)(c)),loading:!1})}var o=e.beforeSearch?Object(ne.cloneDeep)(e.beforeSearch):Object(ne.cloneDeep)(e),s=t.payload,l=s.parentPage,d=s.referencePage,u=l-10;u=u<=0?0:u;var b=l+2,j=t.payload.properties.filter((function(e){return 200===e.status||null===e.status})).map((function(e){return Object(I.a)(Object(I.a)({},e),{},{parentPage:l})})),p=new Map;o.data.properties.forEach((function(e){e.parentPage>=u&&e.parentPage<=b&&p.set(e.id,e)})),j.forEach((function(e){p.set(e.id,e)}));var f=Array.from(p.values()),m=f.flatMap((function(e){var t;return null===e||void 0===e||null===(t=e.fields)||void 0===t?void 0:t.reduce(Fm(e.id),[])})),v=o.fieldsAndAreasGeoJSONCollection.features.filter((function(e){return f.some((function(t){return t.id===e.properties.id}))})),O=Mm(v,Object(W.featureCollection)(m).features),h=Array.from(new Set((f||[]).map((function(e){return e.parentPage})).concat(d))).filter((function(e){return void 0!==e})).sort((function(e,t){return e-t}));return Object(I.a)(Object(I.a)({},o),{},{data:{befofeSearch:null,orgId:t.payload.orgId,pagination:{totalPages:(null===(n=t.payload)||void 0===n?void 0:n.totalPages)||o.data.pagination.totalPages,preLoadedPages:h,referencePage:d},properties:f},fieldsAndAreasGeoJSONCollection:Em({type:"FeatureCollection",features:O}),loading:!1})})),Object(et.a)(wm,Hm,(_m=!1,function(e){return Object(I.a)(Object(I.a)({},e),{},{fieldsLoading:_m,isLoadingPaginatedProperties:_m,loading:!1})})),Object(et.a)(wm,Gm,(function(e,t){var n;return Object(I.a)(Object(I.a)({},e),{},{fieldsAndAreasGeoJSONCollection:Em(Object(I.a)(Object(I.a)({},e.fieldsAndAreasGeoJSONCollection),{},{features:null!==(n=t.payload)&&void 0!==n&&n.isEdition?Object(W.featureCollection)(t.payload.value).features:Mm(e.fieldsAndAreasGeoJSONCollection.features,Object(W.featureCollection)(t.payload).features)}))})})),Object(et.a)(wm,Wm,(function(e){var t=Object(W.centroid)(e.fieldsAndAreasGeoJSONCollection);return Object(I.a)(Object(I.a)({},e),{},{loading:!1,fieldsAndAreasCentroidCoordinates:t&&t.geometry?t.geometry.coordinates:void 0})})),Object(et.a)(wm,qm,(function(e){return Object(I.a)(Object(I.a)({},e),{},{zoom:ub,fieldsAndAreasCentroidCoordinates:lb,loading:!!e.shapesLoading&&e.loading})})),Object(et.a)(wm,Jm,Vm("fields")),Object(et.a)(wm,Km,Vm("fieldsAndAreasCentroidCoordinates")),Object(et.a)(wm,Qm,Vm("zoom")),Object(et.a)(wm,"SET_PROPERTY_FARM_DATA",(function(e,t){var n=t.payload.properties.filter((function(e){return 200===e.status})),a=n.flatMap((function(e){var t;return null===e||void 0===e||null===(t=e.fields)||void 0===t?void 0:t.reduce(Fm(e.id),[])})),r=e.data.properties.find((function(e){var t;return e.id===(null===(t=n[0])||void 0===t?void 0:t.id)}));return r&&n[0]?(Object.assign(r,n[0]),Object(I.a)(Object(I.a)({},e),{},{data:{properties:Nm(Object(v.a)(e.data.properties))},fieldsAndAreasGeoJSONCollection:Em({type:"FeatureCollection",features:[].concat(Object(v.a)(e.fieldsAndAreasGeoJSONCollection.features),Object(v.a)(a))})})):Object(I.a)({},e)})),Object(et.a)(wm,Xm,(function(e,t){var n=e.data.properties.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{fields:t.payload.farmId===e.id?e.fields.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{cropzones:e.cropzones.map((function(e){var n;return Object(I.a)(Object(I.a)({},e),{},{costs:null!==(n=t.payload.costs[e.id])&&void 0!==n?n:e.costs})}))})})):e.fields})}));return Object(I.a)(Object(I.a)({},e),{},{data:{properties:Object(v.a)(n)}})})),wm),nv=function(e,t){var n=tv[t.type];return n?n(e,t):e},av=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=Object(a.useContext)(ac),n=Object(b.a)(t,2),r=n[0].propertyFilters,c=n[1],i=r||{},o=i.showArchivedProperties,s=i.showFarmWithIds,l=Object(a.useState)([]),d=Object(b.a)(l,2),u=d[0],j=d[1],p=function(e){return(null===e||void 0===e?void 0:e.filter((function(e){return!e.archived})).map((function(e){var t;return Object(I.a)(Object(I.a)({},e),{},{fields:(null===(t=e.fields)||void 0===t?void 0:t.filter((function(e){return!e.archived})))||[]})})))||[]},f=Object(a.useCallback)((function(t){if(!t)return[];var n,a;return(n=t,a=function(e,t){return e.archived-t.archived},e?n:n.sort(a)).map((function(e){return e.fields?Object(I.a)(Object(I.a)({},e),{},{fields:e.fields.sort((function(e,t){return e.archived-t.archived}))}):e}))}),[e]),m=Object(a.useMemo)((function(){var e;return e=o?f(u):p(u),(null===s||void 0===s?void 0:s.length)>0&&(e=e.filter((function(e){return null===s||void 0===s?void 0:s.includes(e.id)}))),e}),[o,u,s,f]),v=function(e){c({type:"SET_PROPERTY_FILTERS",payload:{showArchivedProperties:e}})},O=function(e){c({type:"SET_PROPERTY_FILTERS",payload:{showFarmWithIds:e}})},h=Object(a.useCallback)((function(e){return o?e:e.features?Object(I.a)(Object(I.a)({},e),{},{features:e.features.filter((function(e){var t;return!(null!==(t=e.properties)&&void 0!==t&&t.archived)}))}):[]}),[o]),x=o||(null===u||void 0===u?void 0:u.length)>0||(null===s||void 0===s?void 0:s.length)>0,g=function(e){var t=e.selectedFarmIds,n=e.showLocalArchivedProperties;return!ae.a.isEqual(ae.a.sortBy(t),ae.a.sortBy(s))||n!==o},C=function(e){var t=e.selectedFarmIds,n=e.showLocalArchivedProperties;O(t),v(n)};return{filteredProperties:m||[],showArchivedProperties:o,setShowArchivedProperties:v,setPropertiesToFilter:j,hasActiveFilters:x,hasFilterChanges:g,runMapFilter:h,applyFilters:C}},rv=function(e){var t,n=e.fetchType,r=e.cropSeasonsId,c=e.isCacheOn,i=void 0!==c&&c,o=e.showDanglingFields,s=void 0!==o&&o,l=Object(f.useFlags)().configureLargeGrowerConditionals,d=Object(a.useRef)(),u=Object(a.useContext)(ac),j=Object(b.a)(u,2)[1],p=Object(a.useReducer)(nv,ev(),ev),m=Object(b.a)(p,2),v=m[0],O=v.data,h=v.beforeSearch,x=v.zoom,g=v.fieldsAndAreasCentroidCoordinates,C=v.fieldsAndAreasGeoJSONCollection,y=v.loading,P=v.fieldsLoading,A=v.costs,S=v.isLoadingPaginatedProperties,T=m[1],N=av().runMapFilter,E=Object(a.useMemo)((function(){return N(C)}),[C,N]),w=Object(a.useCallback)((function(e){J.a.isCancel(e)?Object(Ae.default)(e):uc(j)(e)}),[j]),_=Object(a.useCallback)((function(e,t){return T({type:Gm,payload:t?{isEdition:t,value:e}:e})}),[]),R=Object(a.useCallback)((function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=JSON.parse(localStorage.getItem("selectedCropSeasons"));null===r&&(r=[ym]);var c={seasonIds:r},i=e||c||{};return null!==i&&void 0!==i&&null!==(t=i.seasonIds)&&void 0!==t&&t.length||(i.seasonIds=[ym]),T({type:n?Um:Bm}),a||j({type:kr,payload:!0}),i}),[j]),D=function(e,t){return!!e.orgId&&t.orgId!==e.orgId},k=function(e,t){return 0===e.page&&1===(null===t||void 0===t?void 0:t.totalPage)||e.page>=(null===t||void 0===t?void 0:t.totalPages)},L=function(e,t){var n;return null===t||void 0===t||null===(n=t.preLoadedPages)||void 0===n?void 0:n.includes(e.page)},F=function(e,t,n){T({type:Zm,payload:{properties:[],orgId:n.orgId,referencePage:t.referencePage,parentPage:e.page,totalPages:t.totalPages}}),T({type:Hm})},M=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,o,d,u,b,j,p=arguments;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=p.length>1&&void 0!==p[1]?p[1]:{page:0,textSearch:"",orgId:null},a=null!==n&&void 0!==n&&n.textSearch?200:l.pageSize,!D(n,O)){e.next=7;break}T({type:Ym}),e.next=16;break;case 7:if(!n.textSearch||!k(n,null===O||void 0===O?void 0:O.pagination)){e.next=11;break}return e.abrupt("return");case 11:if(n.textSearch){e.next=16;break}if(c=(null===h||void 0===h||null===(r=h.data)||void 0===r?void 0:r.pagination)||O.pagination,!L(n,c)&&!k(n,c)){e.next=16;break}return F(n,c,O),e.abrupt("return");case 16:return e.prev=16,b=R(t,!0,!n.textSearch),e.next=20,Xt.fetchByPost(Object(I.a)(Object(I.a)({},b),{},{include_extended:!0}),Object(I.a)({pageNo:n.page,size:a},n.textSearch?{name:n.textSearch}:{}),i,s).promise;case 20:null!==(j=e.sent)&&void 0!==j&&null!==(o=j.data)&&void 0!==o&&null!==(d=o.data)&&void 0!==d&&null!==(u=d.properties)&&void 0!==u&&u.length&&T({type:Zm,payload:Object(I.a)(Object(I.a)({},j.data.data),{},{referencePage:n.page,parentPage:n.page,totalPages:j.data.totalPages,textSearch:n.textSearch})}),e.next=27;break;case 24:e.prev=24,e.t0=e.catch(16),w(e.t0);case 27:return e.prev=27,T({type:Hm}),e.finish(27);case 30:case"end":return e.stop()}}),e,null,[[16,24,27,30]])})));return function(t){return e.apply(this,arguments)}}(),[l,O,null===h||void 0===h||null===(t=h.data)||void 0===t?void 0:t.pagination,w,R,i,s,T]),V=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r=R(t),e.next=4,Qt.fetchByPost(Object(I.a)(Object(I.a)({},r),{},{include_extended:!0}),i,s).promise;case 4:null!==(c=e.sent)&&void 0!==c&&null!==(n=c.data)&&void 0!==n&&null!==(a=n.properties)&&void 0!==a&&a.length&&T({type:zm,payload:c.data}),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),w(e.t0);case 11:return e.prev=11,T({type:Hm}),j({type:kr,payload:!1}),e.finish(11);case 15:case"end":return e.stop()}}),e,null,[[0,8,11,15]])})));return function(t){return e.apply(this,arguments)}}(),[j,w,R,i,s]),B=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,c,o;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n=[r].flat(),a={seasonIds:n},c=t||a||{},T({type:Bm}),j({type:kr,payload:!0}),e.next=8,Qt.fetchByPost(Object(I.a)(Object(I.a)({},c),{},{include_extended:!0}),null,i,s).promise;case 8:o=e.sent,T({type:zm,payload:o.data}),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(0),w(e.t0);case 15:return e.prev=15,T({type:Hm}),j({type:kr,payload:!1}),e.finish(15);case 19:case"end":return e.stop()}}),e,null,[[0,12,15,19]])})));return function(t){return e.apply(this,arguments)}}(),[r,j,w,i,s]),U=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,r,c,i,o,s,l,d,u,b;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=pn.createChildApi({action:"farm/".concat(t,"/cost")}),e.prev=1,c=JSON.parse(localStorage.getItem("selectedCropSeasons")),i={seasonIds:c},o=n||i||{},j({type:Fr,payload:!0}),(null===(r=o.seasonIds)||void 0===r?void 0:r.length)>0&&!new Set(o.seasonIds).has(ym)){e.next=9;break}return T({type:Xm,payload:{costs:{},farmId:t}}),e.abrupt("return");case 9:return e.next=11,a.post(o).promise;case 11:s=e.sent,T({type:Xm,payload:{costs:s.data,farmId:t}}),e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(1),"Could not retrieve any task with the specified filters"!==(null===e.t0||void 0===e.t0||null===(l=e.t0.response)||void 0===l||null===(d=l.data)||void 0===d?void 0:d.displayErrorMessage)){e.next=19;break}return e.abrupt("return");case 19:if("Could not convert from CWF season to Base season"!==(null===e.t0||void 0===e.t0||null===(u=e.t0.response)||void 0===u||null===(b=u.data)||void 0===b?void 0:b.displayErrorMessage)){e.next=21;break}return e.abrupt("return");case 21:w(e.t0);case 22:return e.prev=22,j({type:Fr,payload:!1}),e.finish(22);case 25:case"end":return e.stop()}}),e,null,[[1,15,22,25]])})));return function(t,n){return e.apply(this,arguments)}}(),[]),z=Object(a.useCallback)((function(e,t){switch(n){case xm:return V(e);case hm:return M(e,t);case gm:return B(e);default:throw new Error(n)}}),[V,M,B,n]);Object(a.useEffect)((function(){y&&O&&C&&(C.features.length>0?T({type:Wm}):T({type:qm}))}),[O,g,C,y]),Object(a.useMemo)((function(){d.current=Nm(O)}),[O]);var Z=d.current,H=Object(a.useCallback)((function(e){return T({type:Jm,payload:e})}),[]),W=Object(a.useCallback)((function(e){return T({type:Km,payload:e})}),[]),q=Object(a.useCallback)((function(e){return T({type:Qm,payload:e})}),[]);return{pagination:null===O||void 0===O?void 0:O.pagination,fieldsAndAreasCentroidCoordinates:g,fieldsAndAreasGeoJSONCollection:E,setGeoJSONCollectionFeatures:_,getSsurgoInfo:function(){return Promise.resolve({slope:3,soilTexture:"loam",slopeLength:13,hydrologyGroup:"C"})},loading:y,reloadData:z,setFields:H,setFieldsAndAreasCentroidCoordinates:W,setZoom:q,zoom:x,dataSorted:Z,costs:A,fieldsLoading:P,filterFeatureCollectionByParentId:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return e.features?e.features.map((function(e){var a,r,c,i=t||n.length?"default":"focused";return Object(ne.set)(e,"properties.$layer",t===(null===(a=e.properties)||void 0===a?void 0:a.id)||t===(null===(r=e.properties)||void 0===r?void 0:r.propertyId)&&(null===(c=e.properties)||void 0===c||!c.$parentDuplicated)||n.some((function(t){var n;return t.id===(null===(n=e.properties)||void 0===n?void 0:n.id)}))?"focused":i),e})):[]},fetchFarmCosts:U,isLoadingPaginatedProperties:S}},cv=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(e){var n=0;return t.forEach((function(t){n+=Ud(e,t.cropSeasons)})),n}return(null===e||void 0===e)&&t.length>0?1:0},iv=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(e){var n=0;return t.forEach((function(t){n+=cv(e,t.cropzones)})),n}return null===e||void 0===e?1:0},ov=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=function e(t){return t.flatMap((function(t){var n;return(null===(n=t.children)||void 0===n?void 0:n.length)>0?e(t.children):t}))},a=n(e).filter((function(e){return t.includes(e.value)})).map((function(e){return e.farmId}));return Object(v.a)(new Set(a))},sv=function(e){var t=e.properties,n=e.propertiesLoading,r=e.setFieldValue,c=e.values,i=e.setTotalArea,o=e.setGeoJSONCollectionFeatures,s=e.fieldsAndAreasGeoJSONCollection,l=function(e){(function(e){var t=e.map((function(e){return On.fetch(e).promise}));return Promise.all(t).catch(Ae.default).then((function(e){return e.flatMap((function(e){var t=e.data;return{cropId:t.cropId,reportedArea:t.reportedArea,boundaryArea:t.boundaryArea}}))}))})(e).then((function(e){i(e.reduce((function(e,t){var n=t.reportedArea,a=t.boundaryArea;return e+(n||a)}),0))}))},d=function(e){return o(s.features?s.features.map((function(t){return Object(ne.set)(t,"properties.$layer",e),t})):[])},u=function(e,a){var c,i;o((i=e,(c=s).features?c.features.map((function(e){var t,n,a;return Object(ne.set)(e,"properties.$layer",null!==i&&void 0!==i&&i.includes(null===(t=e.properties)||void 0===t?void 0:t.id)||null!==i&&void 0!==i&&i.includes(null===(n=e.properties)||void 0===n?void 0:n.id)&&(null===(a=e.properties)||void 0===a||!a.$parentDuplicated)?"focused":"default"),e})):[]));var u=function(e,n){return t.filter((function(e){var t=e.id;return n.includes(t)})).map((function(t){var n=t.fields.flatMap((function(e){return e.cropzones}));return{farmId:t.id,cropzoneIds:n.filter((function(t){var n=t.id;return e.includes(n)})).map((function(e){return e.id}))}}))}(e,a);l(e),r("properties",u),n||0===t.length||0!==u.length||(d("focused"),d("default"))};return Object(a.useEffect)((function(){c.cropZones&&u(c.cropZones,c.farms)}),[n]),Object(y.jsxs)("div",{"data-testid":"cropseason-sidebar",className:"flex-col items-center justify-center flex-none p-6 bg-white",style:{width:"500px"},children:[Object(y.jsx)(m.Form.Field,{label:"Crop Season Name*",children:Object(y.jsx)(Qi,{control:m.Input,name:"name","data-testid":"cropSeasonName"})}),Object(y.jsx)(m.Form.Field,{label:"Crop Season Dates*",children:Object(y.jsx)(Qi,{control:m.DatePicker,name:"date",isRangePicker:!0,"data-testid":"cropSeasonDate"})}),Object(y.jsx)(m.Form.Field,{label:"Notes",children:Object(y.jsx)(m.TextArea,{name:"values.notes",id:"notes",onChange:function(e){return r("notes",e.target.value)},value:c.notes})})]})};sv.defaultProps={properties:[],propertiesLoading:!0};var lv=sv,dv=n(833),uv=function(e){var t=e.handleSubmit,n=e.loading,a=e.saving,r=e.totalArea,c=Object(Zi.f)("date"),i=Object(b.a)(c,1)[0].value,o=Object(p.h)(),s=2===(null===i||void 0===i?void 0:i.length)?Object(dv.a)(i[1],i[0])+1:0;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Sm,{}),Object(y.jsxs)("div",{"data-testid":"cropseason-topheader",className:"flex items-center justify-between h-20 px-4 border bg-app-background",style:{borderColor:"#E8EAED"},children:[Object(y.jsxs)("div",{className:"flex justify-start",children:[Object(y.jsxs)("div",{className:"mr-12",children:[Object(y.jsx)("div",{className:"text-sm text-gray-600",children:"Duration"}),Object(y.jsxs)("div",{className:"text-2xl text-charcoal",children:[s," Days"]})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-sm text-gray-600",children:"Total Area"}),Object(y.jsxs)("div",{className:"text-2xl text-charcoal",children:[r," Acres"]})]})]}),Object(y.jsxs)("div",{className:"flex space-x-4",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:function(){return o.push(Cc.cropSeasons)},children:Object(y.jsx)("span",{className:"w-16",children:"Cancel"})}),Object(y.jsx)(m.Button,{type:"primary",onClick:t,disabled:a||n,children:Object(y.jsx)("span",{className:"w-16",children:a?"Saving...":"Save"})})]})]})]})};uv.defaultProps={saving:!1,loading:!1,totalArea:"0"};var bv=uv,jv=function(e){var t=e.initialValues,n=e.onSubmit,r=e.schema,c=e.saving,i=e.totalArea,o=e.id,s=e.error,l=e.cropItems,d=e.setTotalArea,u=e.setError,b=e.blankValues,j=rv({fetchType:gm,cropSeasonsId:"create"===o?"88888888-8888-8888-8888-888888888888":o}),p=j.dataSorted,f=j.fieldsAndAreasCentroidCoordinates,v=j.setFieldsAndAreasCentroidCoordinates,O=j.fieldsAndAreasGeoJSONCollection,h=j.fieldsLoading,x=j.loading,g=j.zoom,C=j.setZoom,P=j.setGeoJSONCollectionFeatures,A=j.reloadData;return Object(a.useEffect)((function(){A()}),[]),Object(y.jsx)(Zi.e,{initialValues:t,enableReinitialize:!0,onSubmit:n,validationSchema:r,children:function(e){var t=e.values,n=e.setFieldValue,a=e.handleSubmit;return Object(y.jsxs)("div",{"data-testid":"crop-season-form",className:"flex flex-col flex-1 -mx-4 -mt-3",children:[Object(y.jsx)(bv,{handleSubmit:a,loading:x||!l,saving:c,totalArea:i.toFixed(2),id:o}),s&&Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){return u("")},children:s}),Object(y.jsx)(Sm,{}),Object(y.jsxs)("div",{className:"flex flex-1",children:[Object(y.jsx)(lv,{values:t,properties:null===p||void 0===p?void 0:p.properties,cropItems:l,propertiesLoading:x||!l,setFieldValue:n,setTotalArea:d,fieldsAndAreasGeoJSONCollection:O,setGeoJSONCollectionFeatures:P,groupByDefaultValue:b.propertiesGroupBy}),Object(y.jsx)("div",{className:"relative flex flex-col flex-auto",children:h?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(mm,{properties:null===p||void 0===p?void 0:p.properties,zoom:g,setZoom:C,currentCoordinates:f,setCurrentCoordinates:v,displayOnly:!0,geoJSONCollection:O,liveUpdate:!1,customStyles:{focused:{fillColor:"rgba(0, 255, 0, 0.15)",fillOutlineColor:"rgba(255, 255, 255, 1)",fillAntialias:!0}},labelName:"cropzone"})})]})]})}})},pv={name:"",date:null,crop:"",notes:""},fv=function(){var e=Object(a.useState)(),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(null),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],f=Object(a.useState)(!1),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)(),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(0),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(p.j)().id,w=Object(a.useContext)(ac),_=Object(b.a)(w,2),R=_[0].organization,D=_[1],k=Object(p.h)(),L=Du().crops,F=(null===L||void 0===L?void 0:L.map((function(e){return{key:e.id,value:e.name}})))||[];Object(a.useEffect)((function(){u||("create"===E?(r(Object(I.a)({},pv)),j(!0)):zu(E,Ve(),R.id,r,P,j))}),[u,E]);var M=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,i,o,l,d,u;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=new Date((null===t||void 0===t?void 0:t.date[1])||(null===t||void 0===t?void 0:t.date[0])).getTime(),c=new Date(null===t||void 0===t?void 0:t.date[0]).getTime(),i=Object(I.a)(Object(I.a)({},"create"!==E&&{id:E}),{},{name:t.name,startDateEpoch:c,endDateEpoch:r,crops:null!==(n=null===(a=t.crops)||void 0===a?void 0:a.map((function(e){return e.id})))&&void 0!==n?n:[],properties:t.properties,notes:t.notes}),h(!0),"create"!==E){e.next=10;break}return o=$t.create(i),l=o.promise,e.next=8,l.then((function(){h(!1),k.push(Cc.cropSeasons)})).catch(Ae.default).catch((function(e){var t,n,a,r;(h(!1),null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.displayErrorMessage)?"ESEA017"===(null===(a=e.response)||void 0===a||null===(r=a.data)||void 0===r?void 0:r.code)?s("Field Name : Crop Zone Name already exists in a Crop Season within the selected dates. Please remove selection in order to save this Crop Season."):s(e.response.data.displayErrorMessage):uc(D)(e)}));case 8:e.next=13;break;case 10:return d=$t.update(i.id,i),u=d.promise,e.next=13,u.then((function(){h(!1),k.push(Cc.cropSeasons)})).catch(Ae.default).catch((function(e){var t,n;h(!1),null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.displayErrorMessage?s(e.response.data.displayErrorMessage):uc(D)(e)}));case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(lo,{disabled:!0,children:[Object(y.jsx)(lo.Item,{title:"Crop Seasons",value:"All Crop Seasons",to:Cc.cropSeasons}),Object(y.jsx)(lo.Item,{title:"Crop Season",value:"create"===E?"New Crop Season":"Edit Crop Season",isLast:!0})]}),u&&n?Object(y.jsx)(Lu,{error:C,onReset:function(){k.go(0)},children:Object(y.jsx)(jv,{initialValues:n,onSubmit:M,schema:Mu,saving:O,totalArea:T,id:E,error:o,cropItems:F,setTotalArea:N,setError:s,blankValues:pv})}):Object(y.jsx)(m.Spinner,{})]})};function mv(e,t,n){return vv.apply(this,arguments)}function vv(){return(vv=Object(Y.a)(G.a.mark((function e(t,n,a){var r,c,i,o,s;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===a||void 0===a||!a.coordinates){e.next=2;break}return e.abrupt("return");case 2:if(r=Object(W.feature)(a.geometry),c=Oj([r]).toString(),a.coordinates=c,i=Object(I.a)(Object(I.a)({},a),{},{coordinates:c}),!(o=1===(null===t||void 0===t?void 0:t.length)?t.at(0):null===(s=n.find((function(e){var t;return null===e||void 0===e||null===(t=e.cropZoneIds)||void 0===t?void 0:t.includes(i.id)})))||void 0===s?void 0:s.id)){e.next=10;break}return e.next=10,On.update(i.id,Object(I.a)(Object(I.a)({},i),{},{cropSeasonId:o}));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ov=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Object(a.useState)(),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(!!e),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useState)(!1),v=Object(b.a)(m,2),O=v[0],h=v[1],x=Object(a.useState)(),g=Object(b.a)(x,2),C=g[0],y=g[1],P=Object(a.useState)(db),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)([]),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)([]),D=Object(b.a)(R,2),k=D[0],L=D[1],F=Object(a.useState)([]),M=Object(b.a)(F,2),V=M[0],B=M[1],U=Object(a.useRef)(!1),z=Object(a.useContext)(ac),Z=Object(b.a)(z,2),Y=Z[0].cropSeasons,H=Z[1],G=Object(a.useCallback)((function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e,n=arguments.length>1?arguments[1]:void 0;f(!0);var a=On.fetch(t),r=a.promise,c=a.cancel;return r.then((function(e){var t=e.data,n=JSON.parse(localStorage.getItem("selectedCropSeasons"))||[];n.length>0&&mv(n,Y,t),i(t)})).catch(Ae.default).catch(uc(H,{showTryAgain:!!n})).finally((function(){f(!1)})),{promise:r,cancel:c}}),[H,Y,e]),W=Object(a.useCallback)((function(e){var t=Kn.create(e).promise;return t.catch(Ae.default).catch((function(e){uc(H)(e)})),t}),[H]),q=Object(a.useCallback)((function(e){var t=Kn.update(void 0,e).promise;return t.catch(Ae.default).catch((function(e){uc(H)(e)})),t}),[H]),J=Object(a.useCallback)((function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e,n=On.delete(t),a=n.promise;return a.then((function(e){return e.data})).catch(Ae.default),a}),[e]);Object(a.useEffect)((function(){var t;if(e){var n=G().cancel;return t=n,function(){t&&t()}}return t}),[G,e]),Object(a.useEffect)((function(){c&&!c.boundedArea&&(T(ub),y(lb))}),[c]);var K=Object(a.useCallback)((function(e){var t=On.create(e).promise;return t.then((function(e){var t=e.data;i(t)})).catch(Ae.default).catch(uc(H)),t}),[H]),Q=Object(a.useCallback)((function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,a=On.update(n,t),r=a.promise;return r.then((function(e){var t=e.data;i(Object(I.a)({},t))})).catch(Ae.default).catch(uc(H)),r}),[H,e]),X=Object(a.useCallback)((function(e){if(U.current)return Promise.reject(new Error("Save is already in progress"));d(""),h(!0),U.current=!0;var t=On.update(e.id,e).promise;return t.then((function(e){var t=e.data;return d("success"),i(t),t})).catch((function(){return d("error"),null})).finally((function(){U.current=!1,h(!1)})),t}),[]),$=function(e,n,a){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],c=function(){return Yn(On,n).fetch()},i=function(){return Yn(hn,n).create(a)},o=t?i():c(),s=o.promise;s.then((function(t){var n=t.data;e(n.results)})).catch((function(t){var n;404!==(null===(n=t.response)||void 0===n?void 0:n.status)?(uc(H)(t),Object(Ae.default)(t)):e(r)}))},ee=function(){return{getAppliedProducts:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};$(L,e,t)},getVariety:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};$(B,e,t)},getCrophistory:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};$(_,e,t)}}};return{cropZone:c,cropZoneCentroidCoordinates:C,setCropZoneCentroidCoordinates:y,fetchCropZone:G,loading:p,saving:O,state:l,createCropZone:K,editCropZone:X,updateCropZone:Q,zoom:S,setZoom:T,getCropZoneData:ee,productsServices:k,cropHistory:w,variety:V,deleteCropZone:J,createBulkCropZone:W,updateBulkCropZone:q}},hv={data:null,isLoading:!1,isError:!1,isSuccess:!1},xv=function(e){return Object(I.a)(Object(I.a)({},e),{},{isLoading:!0})},gv=function(e,t){return Object(I.a)(Object(I.a)({},e),{},{data:null,isError:!0,isSuccess:!1,error:t})},Cv=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Object(I.a)(Object(I.a)({},e),{},{isError:!1,isSuccess:!0,error:null,data:t})},yv=function(e){return Object(I.a)(Object(I.a)({},e),{},{isLoading:!1})},Pv=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=Object(a.useState)(hv),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(n),p=Object(b.a)(j,2),f=p[0],m=p[1],v=Object(a.useState)(!1),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(),C=Object(b.a)(g,2),y=C[0],P=C[1],A=Object(a.useState)({type:"FeatureCollection",features:[]}),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(lb),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)(db),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)([]),V=Object(b.a)(M,2),B=V[0],U=V[1],z=Object(a.useState)([]),Z=Object(b.a)(z,2),H=Z[0],q=Z[1],J=Object(a.useState)([]),K=Object(b.a)(J,2),Q=K[0],X=K[1],$=Object(a.useRef)({}),ee=Object(a.useRef)(!1),te=Object(a.useContext)(ac),ne=Object(b.a)(te,2),ae=ne[1],re=Object(a.useCallback)(Object(Y.a)(G.a.mark((function t(){var n,a,r,c,i,o,s,l,d,u,b,j,p,f,v,O,h=arguments;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=h.length>0&&void 0!==h[0]?h[0]:e,a=h.length>1&&void 0!==h[1]&&h[1],r=h.length>2&&void 0!==h[2]&&h[2],P(null),m(!0),c=mn.fetch(n),i=c.promise,o=c.cancel,t.prev=6,t.next=9,i;case 9:if(s=t.sent,l=s.data,d=Object(I.a)(Object(I.a)({},l),{},{coordinates:Bb(l.coordinates||""),cropzones:[]}),!r){t.next=21;break}return u=Xt.createChildApi({action:"properties/fields/".concat(n,"/cropzones")}),b=u.fetchByPost({seasonIds:JSON.parse(localStorage.getItem("selectedCropSeasons"))},null),j=b.promise,t.next=17,j;case 17:p=t.sent,f=p.data,v=void 0===f?[]:f,d.cropzones=v;case 21:$.current=d,P(d),O=[d].reduce(Fm(d.propertyId),[]),N(Em(Object(W.featureCollection)(O))),t.next=31;break;case 27:t.prev=27,t.t0=t.catch(6),Object(Ae.default)(t.t0),uc(ae,{showTryAgain:!!a})(t.t0);case 31:return t.prev=31,m(!1),t.finish(31);case 34:return t.abrupt("return",{promise:i,cancel:o});case 35:case"end":return t.stop()}}),t,null,[[6,27,31,34]])}))),[ae,e]);Object(a.useEffect)((function(){e&&re()}),[e,re]);var ce=Object(a.useCallback)((function(e){var t=mn.create(e).promise;return t.then((function(e){var t=e.data;P(t)})).catch(Ae.default).catch(uc(ae)),t}),[ae]),ie=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){mn.createChildApi({action:"field/".concat(t,"/archive")}).post().promise.then((function(t){var n=t.data;e(n)})).catch((function(e){n(e)}))})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),oe=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o((function(e){return xv(e)})),n=mn.createChildApi({action:"field/".concat(t,"/unarchive")}),a=n.post(),a.promise.then((function(){o((function(e){return Cv(e)}))})).catch(Ae.default).catch((function(e){o((function(t){return gv(t,e)})),uc(ae)})).finally((function(){o((function(e){return yv(e)}))}));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[ae]),se=Object(a.useCallback)((function(e,t){if(ee.current)return Promise.reject(new Error("Save is already in progress"));u(""),x(!0),ee.current=!0;var n=mn.update(e.id||t,e).promise;return n.then((function(e){var t=e.data;return u("success"),P(t),t})).catch(Ae.default).catch(u("error")).catch(uc(ae)).finally((function(){ee.current=!1,x(!1)})),n}),[ae]),le=Object(a.useCallback)((function(e,t){if(!$.current.id&&!t)return Promise.reject(new Error("Save is already in progress"));var n=Object(I.a)(Object(I.a)({},$.current),e);$.current=null;var a=mn.update(n.id||t,n).promise;return a.then((function(e){var t=e.data;P(t),$.current=t})).catch(Ae.default).catch(uc(ae)),a}),[ae]),de=function(e,n,a){(t?Yn(vn,n).create(a):Yn(mn,n).fetch()).promise.then((function(t){var n=t.data;e(n.results)})).catch(Ae.default).catch(uc(ae))},ue=function(){return{getAppliedProducts:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};de(q,e,t)},getVariety:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};de(X,e,t)},getCrophistory:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};de(U,e,t)}}};return{field:y,fieldCentroidCoordinates:_,setFieldCentroidCoordinates:R,fieldGeoJSONCollection:T,loading:f,saving:h,state:d,setField:P,updateField:le,loadField:re,createField:ce,editField:se,archive:i,archiveField:ie,unarchiveField:oe,zoom:L,setZoom:F,getFieldData:ue,productsServices:H,cropHistory:B,variety:Q}},Av=function(e){var t=e.property,n=e.fieldsAndAreasGeoJSONCollection,a=e.fieldsLoading,r=Ov(null===t||void 0===t?void 0:t.cropzoneId).cropZone,c=Pv(null===r||void 0===r?void 0:r.fieldId),i=c.field;return c.loading||a?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{width:"5rem",children:Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(Kp,{id:t.cropzoneId,features:function(){if(n.features.length>0){var e=[];return n.features.forEach((function(n){t.cropzoneId===n.properties.id&&e.push(n)})),e}return""}()})})}),Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsxs)("span",{className:"flex flex-col",children:[Object(y.jsx)("span",{className:"w-64 pb-2 text-sm font-bold text-left truncate","data-testid":"property-name",children:null===i||void 0===i?void 0:i.name}),Object(y.jsx)("span",{className:"w-64 text-sm text-left text-gray-600 truncate","data-testid":"property-manufacturer",children:null===t||void 0===t?void 0:t.name})]})}),Object(y.jsxs)(m.Table.Cell,{children:[t.crop.name,t.crop.name&&t.crop.variety&&Object(y.jsx)(y.Fragment,{children:" - "}),t.crop.variety]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:2,children:t.area})," ",1===t.area?t.areaUnit:"".concat(t.areaUnit,"s")]})]},t.cropzoneId)};Av.defaultProps={fieldsAndAreasGeoJSONCollection:{features:[]},fieldsLoading:!0};var Sv=Av,Tv=function(){var e,t,n=Object(p.j)().id,r=Object(a.useState)(null),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(null),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(!1),f=Object(b.a)(j,2),v=f[0],O=f[1],h=Object(a.useContext)(ac),x=Object(b.a)(h,2)[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(null),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(p.h)(),_=rv({fetchType:xm,isCacheOn:!0}),R=_.fieldsAndAreasGeoJSONCollection,I=_.fieldsLoading,D=_.reloadData,k=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=$t.fetch(n),a=t.promise,O(!1),e.next=4,a.then((function(e){var t,n=e.data,a=null===n||void 0===n||null===(t=n.cropZones)||void 0===t?void 0:t.filter((function(e){return 200===(null===e||void 0===e?void 0:e.status)}));u(a),o(n),O(!0)})).catch(Ae.default).catch((function(e){uc(x)(e)}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){D()}),[]),Object(a.useEffect)((function(){i||k()}),[i]),Object(y.jsx)(y.Fragment,{children:v?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(lo,{disabled:!0,children:[Object(y.jsx)(lo.Item,{title:"Crop Seasons",value:"All Crop Seasons",to:Cc.cropSeasons}),Object(y.jsx)(lo.Item,{title:"Crop Season",value:i.name,isLast:!0})]}),Object(y.jsx)(Nu,{open:P,close:function(){return A(!1)},seasonName:null===N||void 0===N?void 0:N.name,seasonId:null===N||void 0===N?void 0:N.id}),Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsxs)("div",{className:"flex justify-start w-1/2",children:[Object(y.jsx)(Fl,{className:"ml-4 mr-8",header:"Duration",data:"".concat(i?Object(dv.a)(new Date(i.endDate),new Date(i.startDate))+1:0," Days"),testId:"duration"}),Object(y.jsx)(Fl,{className:"ml-8 mr-4",header:"Total Area",data:"".concat(200===i.totalArea.status?i.totalArea.totalArea:0," ac"),testId:"totalArea"})]}),Object(y.jsx)("div",{className:"flex self-center mr-6",children:Object(y.jsx)(Wo,{onAction:function(e){({edit:function(){w.push("".concat(Cc.cropSeasons,"/").concat(n))},delete:function(){A(!0),E({id:n,name:i.name})}})[e]()},options:ss})})]}),Object(y.jsx)("div",{className:"mx-2 my-4 min-w-content","data-testid":"tasks-table",style:{minWidth:"min-content"},children:Object(y.jsx)(ll,{children:Object(y.jsxs)("div",{className:"m-4",children:[Object(y.jsx)("div",{"data-testid":"crop-season-details",children:Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Crop Season Details"})})}),Object(y.jsxs)("div",{children:[Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Crop Season Name",data:i.name,testId:"crop-season-name"})})})}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsx)(m.Column,{width:"w-120",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Start Date",data:zd(i.startDateEpoch),testId:"startDateTime"})})}),Object(y.jsx)(m.Column,{width:"w-56",children:Object(y.jsx)("div",{className:"flex items-center w-full h-full",children:Object(y.jsx)("svg",{width:"53",height:"16",viewBox:"0 0 53 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M52.7071 8.7071C53.0976 8.31658 53.0976 7.68341 52.7071 7.29289L46.3431 0.928928C45.9526 0.538404 45.3195 0.538404 44.9289 0.928928C44.5384 1.31945 44.5384 1.95262 44.9289 2.34314L50.5858 8L44.9289 13.6569C44.5384 14.0474 44.5384 14.6805 44.9289 15.0711C45.3195 15.4616 45.9526 15.4616 46.3431 15.0711L52.7071 8.7071ZM8.74228e-08 9L52 9L52 7L-8.74228e-08 7L8.74228e-08 9Z",fill:"#696F88"})})})}),Object(y.jsx)(m.Column,{width:"w-120",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"End Date",data:zd(i.endDateEpoch),testId:"endDateTime"})})})]}),Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Crops",data:Object(y.jsx)("div",{children:null===(e=i.crops)||void 0===e?void 0:e.map((function(e,t){return t!==i.crops.length-1?"".concat(e.name,", "):"".concat(e.name)}))}),testId:"crop-season-crops"})})})})]}),Object(y.jsx)("hr",{className:"my-6"}),Object(y.jsxs)("div",{"data-testid":"properties-section",className:"mb-6",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Properties"})}),Object(y.jsxs)(m.Table,{children:[Object(y.jsx)(ks,{tableColumns:[{},{field:"cropzones",title:"Cropzones",sortable:!1},{field:"crops",title:"Crops",sortable:!1},{field:"area",title:"Area",sortable:!1}],onSort:ne.noop,sortBy:"",sortDir:""}),d.map((function(e){return Object(y.jsx)(Sv,{property:e,fieldsAndAreasGeoJSONCollection:R,fieldsLoading:I},e.cropzoneId)}))]})]}),Object(y.jsxs)("div",{"data-testid":"notes-section",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Notes"})}),Object(y.jsx)(m.TextArea,{"data-testid":"crop-season-notes",className:"h-64 overscroll-auto",resizeDisabled:!0,disabled:!0,value:null!==(t=i.notes)&&void 0!==t?t:""})]})]})})})]}):Object(y.jsx)(m.Spinner,{})})},Nv=[{id:"crop seasons",key:"crop seasons",path:Cc.cropSeasons,exact:!0,secure:!0,disabled:!1,component:_u,icon:Wl,nav:"leftNav"},{id:"crop season",key:"crop season",path:"".concat(Cc.cropSeasons,"/:id"),exact:!0,secure:!0,disabled:!1,component:fv,minPermissions:{minAllowedRole:$a}},{id:"crop season view",key:"crop season view",path:"".concat(Cc.cropSeasons,"/:id/view"),exact:!0,secure:!0,disabled:!1,component:Tv}],Ev=[{key:"owner",value:"Owner"},{key:"leased",value:"Leased"},{key:"contracted",value:"Contracted"}],wv=[{key:"EARTH_MOVING",value:"Earth Moving"},{key:"FERTILIZER",value:"Fertilizer"},{key:"FORAGE_AND_HAY",value:"Forage and Hay"},{key:"HARVESTING",value:"Harvesting"},{key:"IRRIGATION",value:"Irrigation"},{key:"MANURE",value:"Manure"},{key:"MISC",value:"Miscellaneous"},{key:"PLANTER",value:"Planter"},{key:"SHOP",value:"Shop"},{key:"SPRAYER",value:"Sprayer"},{key:"TILLAGE",value:"Tillage"},{key:"TRACTOR",value:"Tractor"},{key:"TRAILER",value:"Trailer"},{key:"TRUCK",value:"Truck"},{key:"GENERICAL_VEHICLE",value:"Generical Vehicle"}],_v=[{field:"name",title:"Name",sortable:!0},{field:"type",title:"Type",sortable:!0},{field:"currentStatus",title:"Current Status",sortable:!0},{field:"year",title:"Year",sortable:!0},{field:"make",title:"Make",sortable:!0},{field:"model",title:"Model",sortable:!0},{field:"",title:"",sortable:!1}],Rv=function(e){return isNaN(e)?Number(e.replace(/[$,]/g,"")):Number(e)},Iv=function(e,t,n){return{type:e,amount:Rv(t),dateEpoch:new Date(null!==n&&void 0!==n?n:"").valueOf()}},Dv=function(e){var t,n,a,r,c,i,o,s,l={id:"",name:"",make:"",model:"",year:0,type:"",notes:"",licenseNumber:"",serialNumber:"",unitId:"",services:[{productId:"",productName:"",operationCost:null}],valuations:[{type:"",amount:null,dateEpoch:0,date:""}],statusHistory:[{id:"",status:"",date:"",dateEpoch:0,current:!1,active:!1}]},d=[],u=null!==e&&void 0!==e&&e.services?null===e||void 0===e?void 0:e.services.map((function(e){return{productId:e.productId,productName:e.productName,operationCost:Rv(e.operationCost)}})):[];return null!==e&&void 0!==e&&e.purchasePrice&&d.push(Iv("purchase",null===e||void 0===e?void 0:e.purchasePrice,null===e||void 0===e?void 0:e.purchasePriceDate)),null!==e&&void 0!==e&&e.currentValue&&d.push(Iv("current",null===e||void 0===e?void 0:e.currentValue,null===e||void 0===e?void 0:e.currentValueDate)),l.id=e.id,l.name=null===e||void 0===e?void 0:e.name,l.type=null===e||void 0===e?void 0:e.equipmentType,l.model=null!==(t=null===e||void 0===e?void 0:e.model)&&void 0!==t?t:l.model,l.year=null!==(n=null===e||void 0===e?void 0:e.modelYear)&&void 0!==n?n:l.year,l.make=null!==(a=null===e||void 0===e?void 0:e.make)&&void 0!==a?a:l.make,l.notes=null!==(r=null===e||void 0===e?void 0:e.notes)&&void 0!==r?r:l.notes,l.licenseNumber=null!==(c=null===e||void 0===e?void 0:e.licenseNumber)&&void 0!==c?c:l.licenseNumber,l.serialNumber=null!==(i=null===e||void 0===e?void 0:e.serialNumber)&&void 0!==i?i:l.serialNumber,l.unitId=null!==(o=null===e||void 0===e?void 0:e.unitID)&&void 0!==o?o:l.unitId,l.statusHistory=null!==e&&void 0!==e&&e.currentStatus?[{status:null===e||void 0===e?void 0:e.currentStatus,dateEpoch:new Date(null!==(s=null===e||void 0===e?void 0:e.currentStatusDate)&&void 0!==s?s:"").valueOf(),current:!0,active:!0}]:l.statusHistory,l.valuations=d,l.services=u.length>0?u.filter((function(e){return""!==e.productId})):[],l},kv=function(e,t){var n,a=null===e||void 0===e?void 0:e.filter((function(e){return e.type.toLowerCase()===t}));return a?null===(n=a[0])||void 0===n?void 0:n.amount:""},Lv=function(e,t){var n,a,r=null===e||void 0===e?void 0:e.filter((function(e){return e.type.toLowerCase()===t}));return r&&0!==(null===(n=r[0])||void 0===n?void 0:n.dateEpoch)?new Date(null===(a=r[0])||void 0===a?void 0:a.dateEpoch):""},Fv=function(e,t){if(t){var n=t.toLowerCase();return e.filter((function(e){var t,a,r,c,i,o;return(null===e||void 0===e||null===(t=e.name)||void 0===t?void 0:t.toLowerCase().includes(n))||(null===e||void 0===e||null===(a=e.type)||void 0===a?void 0:a.toLowerCase().includes(n))||(null===e||void 0===e||null===(r=e.currentStatus)||void 0===r?void 0:r.toLowerCase().includes(n))||(null===e||void 0===e||null===(c=e.year)||void 0===c?void 0:c.toString().includes(n))||(null===e||void 0===e||null===(i=e.make)||void 0===i?void 0:i.toLowerCase().includes(n))||(null===e||void 0===e||null===(o=e.model)||void 0===o?void 0:o.toLowerCase().includes(n))}))}return e},Mv=function(e){var t=e.equipment,n=e.onAction,a=function(e){return n(e,t)};return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{onClick:function(){return a("view")},children:Object(y.jsx)("span",{className:"font-bold",children:null===t||void 0===t?void 0:t.name})}),Object(y.jsx)(m.Table.Cell,{children:Object(ne.startCase)(Object(ne.camelCase)(null===t||void 0===t?void 0:t.type.split("_")))}),Object(y.jsx)(m.Table.Cell,{children:Object(ne.startCase)(Object(ne.camelCase)(null===t||void 0===t?void 0:t.currentStatus))}),Object(y.jsx)(m.Table.Cell,{children:null===t||void 0===t?void 0:t.year}),Object(y.jsx)(m.Table.Cell,{children:null===t||void 0===t?void 0:t.make}),Object(y.jsx)(m.Table.Cell,{children:null===t||void 0===t?void 0:t.model}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{"data-testid":"equipment-table-options-menu",className:"absolute right-0 flex-none w-10 mr-2",children:Object(y.jsx)(Wo,{onAction:a,options:ys})})})]},t.id)},Vv=function(e){var t=e.open,n=e.close,r=e.equipmentName,c=e.equipmentId,i=e.setItems,o=e.equipments,s=e.label,l=void 0===s?"":s,d=Object(p.h)(),u=Object(a.useState)(!1),j=Object(b.a)(u,2),f=j[0],v=j[1],O=Object(a.useContext)(we),h=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],"view"!==l&&(t=o.filter((function(e){return e.id!==c}))),O.sendEventToAmplitude(O.events.epic.Equipment.deleteEquipment),v(!0),a=En.delete(c),r=a.promise,e.next=7,r.then((function(){"view"===l?d.replace({pathname:Cc.equipment}):i(t),v(!1),n()})).catch(Ae.default);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)(m.SimpleModal,{open:t,title:'Delete "'+r+'"',close:n,cancelLabel:"Cancel",confirmLabel:"Delete",onCancel:function(){n()},type:"error",onConfirm:function(){return h()},isSaving:f,children:Object(y.jsx)("div",{className:"pr-6",children:"You are about to permanently delete this equipment item. This cannot be undone. Are you sure you want to proceed?"})})};Vv.defaultProps={equipmentName:"",equipments:[{}],setItems:function(){},equipmentId:"",label:""};var Bv=Object(p.l)(Vv),Uv=function(e){var t=e.equipments,n=e.isSearch,r=e.totalEquipments,c=e.equipmentPageNumber,i=e.handlePageChange,o=e.setItems,s=Object(a.useState)(),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(),f=Object(b.a)(j,2),m=f[0],v=f[1],O=Object(a.useState)(t),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)(),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(p.h)(),R=Object(a.useState)(!1),I=Object(b.a)(R,2),D=I[0],k=I[1];Object(a.useEffect)((function(){g(t)}),[t]);var L=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=n.id,r=n.name,e.t0=t,e.next="view"===e.t0?4:"edit"===e.t0?6:"delete"===e.t0?8:12;break;case 4:return _.push({pathname:"".concat(Cc.equipment,"/").concat(a,"/view"),itemId:a}),e.abrupt("break",13);case 6:return _.push("".concat(Cc.equipment,"/").concat(a)),e.abrupt("break",13);case 8:return S(a),w(r),k(!0),e.abrupt("break",13);case 12:return e.abrupt("break",13);case 13:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();return Object(y.jsxs)("div",{"data-testid":"equipment-list",children:[Object(y.jsx)(Bv,{open:D,close:function(){k(!1)},equipmentName:E,equipmentId:A,setItems:o,equipments:t}),false,t.length>0?Object(y.jsxs)(ll,{children:[Ho(r,c,i),Object(y.jsx)(ol,{listType:"Equipment",routePath:Cc.equipment,items:x,tableColumns:_v,onSort:function(e,t){u(e),v(t),g(function(e,t,n){return Object(ne.orderBy)(e,t,n)}(x,e,t))},sortBy:d,sortDir:m,children:function(e){return e.rows.map((function(e){return Object(y.jsx)(Mv,{onAction:L,equipment:e},e.id)}))}}),Ho(r,c,i),Object(y.jsx)("div",{className:"mb-12",children:" "})]}):Object(y.jsx)(Js.LandingEmpty,{listType:"Equipments",isSearch:n,routePath:n?Cc.equipment:"".concat(Cc.equipment,"/item")})]})};Uv.defaultProps={equipments:[],isSearch:"false"};var zv=Uv,Zv=function(e){var t=e.view,n=e.changeView,a=e.sort,r=e.changeSort;return Object(y.jsx)("div",{"data-testid":"toolbar-container",children:Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)(m.RadioButtonGroup,{selected:t,onChange:function(e){n(e)},children:[Object(y.jsx)(m.RadioButtonGroup.RadioButton,{name:"comfortableView",value:"comfortable",children:Object(y.jsx)(ui.a,{fixedWidth:!0,icon:di.s})}),Object(y.jsx)(m.RadioButtonGroup.RadioButton,{name:"compactView",value:"compact",children:Object(y.jsx)(ui.a,{fixedWidth:!0,icon:di.k})})]}),Object(y.jsx)("div",{className:"flex ml-4",children:Object(y.jsxs)(m.RadioButtonGroup,{selected:a,onChange:function(e){r(e)},children:[Object(y.jsx)(m.RadioButtonGroup.RadioButton,{name:"ascSort",value:"asc",children:Object(y.jsx)(ui.a,{fixedWidth:!0,icon:di.p,size:"lg"})}),Object(y.jsx)(m.RadioButtonGroup.RadioButton,{name:"descSort",value:"desc",children:Object(y.jsx)(ui.a,{fixedWidth:!0,icon:di.o,size:"lg"})})]})})]})})};Zv.defaultProps={changeView:function(){},changeSort:function(){}};var Yv=Zv,Hv=function(){var e,t,n=Object(a.useState)(0),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Ro("equipments",["name","equipmentType"],"name",c),s=o.view,l=o.setView,d=o.sort,u=o.setSort,j=o.isSearch,f=o.loaded,v=o.items,O=o.totalItems,h=o.setReload,x=o.setItems,g=Object(a.useContext)(ac),C=Object(b.a)(g,2),P=C[0],A=P.loggedInUserOrgPermission,S=P.loadingOrg,T=C[1],N=Object(a.useState)(),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(!1),I=Object(b.a)(R,2),D=I[0],k=I[1],L=Object(a.useState)(null),F=Object(b.a)(L,2),M=F[0],V=F[1],B=Object(a.useState)([]),U=Object(b.a)(B,2),z=U[0],Z=U[1],Y=zi(M,300),H=Object(p.h)(),G=Object(a.useState)(!1),W=Object(b.a)(G,2),q=W[0],J=W[1],K=function(){i(0),h(!0)},Q=Object(a.useCallback)((function(){return or({role:null===A||void 0===A?void 0:A.role,financialAccess:null===A||void 0===A?void 0:A.financialAccess},{minAllowedRole:$a,minFinancialAccess:nr})}),[null===A||void 0===A?void 0:A.financialAccess,null===A||void 0===A?void 0:A.role]);Object(a.useEffect)((function(){return Z(Fv(v,Y||null)),T({type:"SET_TOOLBAR",payload:Object(y.jsx)(Yv,{view:s,changeView:function(e){return l(e)},sort:d,changeSort:function(e){return u(e)}})}),function(){T({type:"SET_TOOLBAR",payload:null})}}),[s,l,d,u,T,v,Y]),Object(a.useEffect)((function(){Object(ne.isEmpty)(A)?J(!1):J(!0)}),[A]),Object(a.useEffect)((function(){"View Only"!==(null===A||void 0===A?void 0:A.role)&&"Full control"!==(null===A||void 0===A?void 0:A.role)||Object.prototype.hasOwnProperty.call(A,"financialAccess")?_(null===A||void 0===A?void 0:A.financialAccess):_("none")}),[A]);var X,$={},ee="";(null===(e=location)||void 0===e||null===(t=e.selectedView)||void 0===t?void 0:t.length)>0&&(ee=null===(X=location)||void 0===X?void 0:X.selectedView,v.forEach((function(e){var t;e.id===(null===(t=location)||void 0===t?void 0:t.itemId)&&($=e)})));var te=function(e){i(e),h(!0)};return Object(y.jsxs)(y.Fragment,{children:[function(){var e;return"view"===ee||"edit"===ee||"create"===ee?Object(y.jsxs)(lo,{disabled:!0,hideCropSeasonDropdown:!0,children:[Object(y.jsx)(lo.Item,{title:"Equipment",value:"All Equipment",to:Cc.equipment}),Object(y.jsx)(lo.Item,{title:"Equipment",value:null===(e=$)||void 0===e?void 0:e.name,isLast:!0})]}):Object(y.jsx)(lo,{onOrganizationSelect:K,hideCropSeasonDropdown:!0,children:Object(y.jsx)(lo.Item,{title:"Equipment",value:"All Equipment",isLast:!0})})}(),D&&Object(y.jsx)(p.b,{push:!0,to:{pathname:"".concat(Cc.equipment,"/item")}}),Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"equipment",children:[Object(y.jsx)("div",{className:"mb-3",children:Object(y.jsxs)("div",{className:"flex justify-between flex-1",children:[Object(y.jsx)(To,{id:"search-equipment-input",name:"search_equipment",showLabels:!1,filterItems:[],selectedItems:[],onChange:function(e){V(e.target.value)},onFilterChange:ne.noop,onChangeProductType:ne.noop,onChangeTaskType:ne.noop,placeholder:"Search Equipment",showDateRange:!1,showCropSeason:!1,onDateRangeChange:function(){}}),Object(y.jsx)("div",{className:"h-8",children:Q()&&q&&Object(y.jsx)(m.Button,{type:"primary",id:"add-equipment-button",onClick:function(e){e.stopPropagation(),k(!0)},icon:Object(y.jsx)(Eo.a,{}),children:"Add Equipment"})})]})}),f&&!S&&q?Object(y.jsx)(y.Fragment,{children:z&&z.length?Object(y.jsx)(zv,{view:s,equipments:z,isSearch:j,memberRole:null===A||void 0===A?void 0:A.role,memberFinancialAccess:w,totalEquipments:O,equipmentPageNumber:c,handlePageChange:te,setItems:x}):Object(y.jsx)(Vd,{buttonText:"Add Equipment",onClick:function(){return H.push("".concat(Cc.equipment,"/item"))},subtitle:"We were unable to find any equipment under this organization.",setPermission:Q})}):Object(y.jsx)(m.Spinner,{})]})]})},Gv=function(e,t){var n=function(n){var r,c=Object(a.useState)(null),i=Object(b.a)(c,2),o=i[0],s=i[1];return o?function(e,t){var n=t.resourceName,a=t.btnText,r=t.btnLink;return 404===e?Object(y.jsx)(wi,{resourceName:n,btnText:a,btnLink:r}):null}(null===o||void 0===o||null===(r=o.response)||void 0===r?void 0:r.status,t):Object(y.jsx)(Wv.Provider,{value:{ajaxError:o,setAjaxError:s},children:Object(y.jsx)(e,Object(I.a)({},n))})};return n.defaultProps={error:null},n},Wv=r.a.createContext(),qv=function(e){var t=e.isCreateScreen,n=e.redirectPath,a=e.openModal,r=e.setRedirect;return Object(y.jsx)("div",{children:Object(y.jsx)(m.Button,{type:"primary",ghost:!0,"data-testid":t?"cancelButton":"deleteButton",onClick:t?function(){r(n)}:a,children:t?"Cancel":"Delete"})})};qv.defaultProps={isCreateScreen:!1,redirectPath:""};var Jv=qv,Kv=n(2801),Qv=function(e,t,n,a,r){var c=t.update(e.id,e),i=c.promise,o=c.cancel;return i.then((function(){n(!1),a()})).catch(Ae.default).catch(uc(r)).finally((function(){return n(!1)})),function(){r({type:"SET_TOOLBAR",payload:null}),o()}},Xv=function(e,t,n,a,r){var c=t.create(e),i=c.promise,o=c.cancel;return i.then((function(){n(!1),a()})).catch(Ae.default).catch(uc(r)).finally((function(){return n(!1)})),function(){r({type:"SET_TOOLBAR",payload:null}),o()}},$v=function(e){var t=Object(a.useState)("item"===e),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)(!r),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useContext)(ac);return{isCreateScreen:r,setIsCreateScreen:c,loading:s,setLoading:l,dispatch:Object(b.a)(d,2)[1]}},eO=function(){return Object(y.jsx)("div",{"data-testid":"equipment-item-name",children:Object(y.jsx)(m.Form.Field,{label:"Name *",children:Object(y.jsx)(Qi,{control:m.Input,id:"name",name:"name"})})})},tO=function(){return Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{"data-testid":"equipment-item-current-status",className:"w-1/2 mr-8",children:Object(y.jsx)(m.Form.Field,{label:"Current Status *",children:Object(y.jsx)(Qi,{id:"currentStatus",name:"currentStatus",control:m.Select,items:Ev})})}),Object(y.jsx)("div",{className:"w-1/2",children:Object(y.jsx)(m.Form.Field,{label:"Current Status Date",children:Object(y.jsx)(Qi,{id:"currentStatusDate",name:"currentStatusDate",control:m.DatePicker,dateFormat:"M d, Y"})})})]})},nO=function(){return Object(y.jsx)(m.Form.Field,{label:"Type *",children:Object(y.jsx)(Qi,{id:"equipmentType",name:"equipmentType",control:m.Select,items:wv})})},aO=function(){return Object(y.jsxs)("div",{className:"block","data-testid":"equipment-item-details-section",children:[Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Basic Info"}),Object(y.jsxs)("div",{className:"flex w-full",children:[Object(y.jsx)("div",{className:"w-full mr-16",children:Object(y.jsx)(eO,{})}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(nO,{})})]}),Object(y.jsxs)("div",{className:"flex w-full",children:[Object(y.jsxs)("div",{className:"flex w-1/2 mr-16",children:[Object(y.jsx)("div",{className:"w-1/2 mr-8",children:Object(y.jsx)(m.Form.Field,{label:"Year",children:Object(y.jsx)(Qi,{id:"modelYear",name:"modelYear",control:m.Input})})}),Object(y.jsx)("div",{className:"w-1/2",children:Object(y.jsx)(m.Form.Field,{label:"Make",children:Object(y.jsx)(Qi,{control:m.Input,id:"make",name:"make"})})})]}),Object(y.jsx)("div",{className:"w-1/2",children:Object(y.jsx)(m.Form.Field,{label:"Model",children:Object(y.jsx)(Qi,{control:m.Input,id:"model",name:"model"})})})]}),Object(y.jsxs)("div",{className:"flex w-full",children:[Object(y.jsx)("div",{className:"w-1/2 mr-16",children:Object(y.jsx)(tO,{})}),Object(y.jsx)("div",{className:"w-1/2",children:Object(y.jsx)(m.Form.Field,{label:"Unit ID",children:Object(y.jsx)(Qi,{control:m.Input,id:"unitID",name:"unitID"})})})]}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"block w-1/2 mr-16",children:Object(y.jsx)(m.Form.Field,{label:"Serial Number",children:Object(y.jsx)(Qi,{control:m.Input,id:"serialNumber",name:"serialNumber"})})}),Object(y.jsx)("div",{className:"block w-1/2",children:Object(y.jsx)(m.Form.Field,{label:"License Number",children:Object(y.jsx)(Qi,{control:m.Input,id:"licenseNumber",name:"licenseNumber"})})})]})]})},rO=Object(a.forwardRef)((function(e,t){var n=e.memberRole,a=e.memberFinancialAccess,r=Object(Zi.h)().values,c=Object(p.j)().id,i=function(){return"item"!==c&&"Full control"===n&&("none"===a||"READ"===a)};return Object(y.jsxs)("div",{ref:t,className:"mt-4","data-testid":"equipment-item-price-and-status-section",children:[Object(y.jsx)("div",{className:"text-2xl font-bold mb-4",children:"History Info"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"w-1/2 mr-16",children:[Object(y.jsx)("div",{className:"text-xl font-semibold",children:"Purchase History"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"w-1/2 mr-8",children:Object(y.jsx)(m.Form.Field,{label:"Purchase Price",children:Object(y.jsx)(Qi,{control:m.Input,id:"purchasePrice",name:"purchasePrice",value:"item"!==c&&"Full control"===n&&"none"===a?"":null===r||void 0===r?void 0:r.purchasePrice,imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],thousandsSeparator:","}}},disabled:i()})})}),Object(y.jsx)("div",{className:"w-1/2",children:Object(y.jsx)(m.Form.Field,{label:"Purchase Date",children:Object(y.jsx)(Qi,{control:m.DatePicker,id:"purchasePriceDate",name:"purchasePriceDate",dateFormat:"M d, Y"})})})]})]}),Object(y.jsxs)("div",{className:"w-1/2",children:[Object(y.jsx)("div",{className:"text-xl font-semibold",children:"Current Value"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"w-1/2 mr-8",children:Object(y.jsx)(m.Form.Field,{label:"Current Value",children:Object(y.jsx)(Qi,{control:m.Input,id:"currentValue",name:"currentValue",value:"item"!==c&&"Full control"===n&&"none"===a?"":null===r||void 0===r?void 0:r.currentValue,imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],thousandsSeparator:","}}},disabled:i()})})}),Object(y.jsx)("div",{className:"w-1/2",children:Object(y.jsx)(m.Form.Field,{label:"Current Value Date",children:Object(y.jsx)(Qi,{control:m.DatePicker,id:"currentValueDate",name:"currentValueDate",dateFormat:"M d, Y"})})})]})]})]})]})})),cO=(Fu.a().of(Fu.e().shape({amount:Fu.d(),date:Fu.c()})),Fu.a().nullable().of(Fu.e().shape({status:Fu.f().required(),date:Fu.c(),current:Fu.b(),active:Fu.b()}))),iO=Fu.a().nullable().of(Fu.e().shape({productId:Fu.f().default(""),operationCost:Fu.f().default(null).defined()})),oO=Fu.a().nullable().of(Fu.e().shape({purchasePrice:Fu.d().nullable(),purchaseDate:Fu.c().nullable(),currentValue:Fu.d().nullable(),currentValueDate:Fu.c().nullable()})),sO=Fu.e().shape({currentStatus:Fu.f().default("").required("Current Status is a required field"),currentStatusDate:Fu.c().nullable(),equipmentType:Fu.f().default("").required("Type is a required field"),licenseNumber:Fu.f().default(""),make:Fu.f().default(""),manufacturedYear:Fu.d().default(null).defined(),model:Fu.f().default(""),modelYear:Fu.d().default(null).defined(),name:Fu.f().default("").trim().required("Name is a rquired field"),purchasePrice:Fu.f().default(null).defined(),purchasePriceDate:Fu.c().default(null).defined(),currentValue:Fu.f().default(null).defined(),currentValueDate:Fu.c().default(null).defined(),notes:Fu.f().default(""),serialNumber:Fu.f().default(""),unitID:Fu.f().default(""),statusHistory:cO,services:iO,history:oO}),lO=Gv((function(){var e=Object(p.j)().id,t=We().user,n=Object(a.useState)(null),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)({id:"",currentStatus:"",currentStatusDate:"",equipmentType:"",licenseNumber:"",make:"",manufacturedYear:"",model:"",modelYear:"",name:"",purchasePrice:"",purchasePriceDate:"",currentValue:"",currentValueDate:"",notes:"",serialNumber:"",unitID:"",services:[{productId:"",operationCost:"",productName:""}],history:{purchasePrice:null,purchaseDate:"",currentValue:null,currentValueDate:""}}),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(!1),j=Object(b.a)(u,2),f=j[0],v=j[1],O=Object(a.useState)(!1),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useRef)(null),P=xl("equipment"),A=function(){return v(!0)},S=Object(a.useContext)(we),T=Object(a.useContext)(Wv).setAjaxError,N=Object(a.useState)(null),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(),I=Object(b.a)(R,2),D=I[0],k=I[1],L=$v(e),F=L.loading,M=L.setLoading,V=L.isCreateScreen,B=L.dispatch,U=function(){d(null),i(Cc.equipment)},z=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Jt.fetch(),a=n.promise,e.next=3,a.then((function(e){var n,a=e.data,r=null===a||void 0===a||null===(n=a.members)||void 0===n?void 0:n.filter((function(e){return e.email===t.email}))[0];_(r)})).catch(Ae.default).catch((function(e){uc(B)(e)}));case 3:case"end":return e.stop()}}),e)}))),[B,t.email]);Object(a.useEffect)((function(){w||z(),"Full control"!==(null===w||void 0===w?void 0:w.role)||Object.prototype.hasOwnProperty.call(w,"financialAccess")?k(null===w||void 0===w?void 0:w.financialAccess):k("none")}),[w,z]),Object(a.useEffect)((function(){var t;if(!V){var n=P.fetch(e),a=n.promise,r=n.cancel;return t=r,a.then((function(e){var t=function(e){var t,n,a,r,c,i,o,s,l,d,u,b,j={id:"",currentStatus:"",currentStatusDate:"",equipmentType:"",licenseNumber:"",make:"",manufacturedYear:"",model:"",modelYear:"",name:"",purchasePrice:"",purchasePriceDate:"",currentValue:"",currentValueDate:"",notes:"",serialNumber:"",unitID:"",services:[{productId:"",operationCost:"",productName:""}],history:{purchasePrice:null,purchaseDate:"",currentValue:null,currentValueDate:""}};return j.id=null===e||void 0===e?void 0:e.id,j.name=null===e||void 0===e?void 0:e.name,j.equipmentType=null!==(t=null===e||void 0===e?void 0:e.type)&&void 0!==t?t:"",j.modelYear=0!==(null===e||void 0===e?void 0:e.year)?null===e||void 0===e?void 0:e.year:"",j.make=null!==(n=null===e||void 0===e?void 0:e.make)&&void 0!==n?n:"",j.model=null!==(a=null===e||void 0===e?void 0:e.model)&&void 0!==a?a:"",j.notes=null!==(r=null===e||void 0===e?void 0:e.notes)&&void 0!==r?r:"",j.licenseNumber=null!==(c=null===e||void 0===e?void 0:e.licenseNumber)&&void 0!==c?c:"",j.serialNumber=null!==(i=null===e||void 0===e?void 0:e.serialNumber)&&void 0!==i?i:"",j.unitID=null!==(o=null===e||void 0===e?void 0:e.unitId)&&void 0!==o?o:"",j.currentStatus=null!==(s=null===e||void 0===e||null===(l=e.statusHistory[0])||void 0===l?void 0:l.status.toLowerCase())&&void 0!==s?s:"",j.currentStatusDate=0!==(null===e||void 0===e||null===(d=e.statusHistory[0])||void 0===d?void 0:d.dateEpoch)?new Date(null===e||void 0===e||null===(u=e.statusHistory[0])||void 0===u?void 0:u.dateEpoch):"",j.currentValue=kv(null===e||void 0===e?void 0:e.valuations,"current"),j.currentValueDate=Lv(null===e||void 0===e?void 0:e.valuations,"current"),j.purchasePrice=kv(null===e||void 0===e?void 0:e.valuations,"purchase"),j.purchasePriceDate=Lv(null===e||void 0===e?void 0:e.valuations,"purchase"),j.services=null!==e&&void 0!==e&&e.services?null===(b=null===e||void 0===e?void 0:e.services)||void 0===b?void 0:b.map((function(e){return{productId:e.productId,operationCost:e.operationCost,productName:e.productName}})):j.services,j}(e.data);d(t)})).catch(Ae.default).catch((function(e){uc(B)(e),T(e)})).finally((function(){return M(!1)})),function(){B({type:"SET_TOOLBAR",payload:null}),t()}}return function(){return t&&t()}}),[]);var Z=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Object.assign({},t),e.prev=1,a=Dv(n),r=V?Xv(a,P,g,U,B):Qv(a,P,g,U,B),c=r.promise,e.next=6,c;case 6:e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),uc(B)(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}(),H=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,P.delete(l.id).promise;case 3:i(Cc.equipment),e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),uc(B)(e.t0);case 9:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(){return e.apply(this,arguments)}}();return Object(y.jsxs)("div",{className:"w-full h-full",children:[Object(y.jsxs)(lo,{disabled:!0,children:[Object(y.jsx)(lo.Item,{title:"Equipment",value:"All Equipment",to:Cc.equipment}),Object(y.jsx)(lo.Item,{title:"Equipment",value:V?"New Equipment":"Edit Equipment",isLast:!0})]}),c&&Object(y.jsx)(p.b,{push:!0,to:"".concat(c)}),F?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{"data-testid":"equipment-item",children:[Object(y.jsx)(ib,{open:f,itemType:"Equipment",onCancel:function(){return v(!1)},onDelete:H}),Object(y.jsx)(Zi.e,{initialValues:l,validationSchema:sO,onSubmit:Z,children:function(e){var t=e.submitForm,n=e.errors;return Object(y.jsxs)("div",{className:"mb-10",children:[Object(y.jsx)("div",{className:"flex text-gray-800 pt-4 pb-4",children:Object(y.jsxs)("div",{className:"flex w-full",children:[Object(y.jsx)("div",{className:"text-2xl w-full font-bold",children:V?"Create Equipment":"Edit Equipment"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)(Jv,{isCreateScreen:true,redirectPath:Cc.equipment,openModal:A,setRedirect:i}),Object(y.jsx)("div",{className:"ml-4",children:Object(y.jsx)(m.Button,{type:"primary",onClick:function(){S.sendEventToAmplitude(S.events.epic.Equipment.createEquipment),t()},disabled:Object.keys(n).length>0,loading:x,children:"Save"})})]})]})}),Object(y.jsx)(Kv.a,{children:Object(y.jsxs)(yl,{children:[Object(y.jsx)(aO,{}),Object(y.jsx)(rO,{ref:C,memberRole:null===w||void 0===w?void 0:w.role,memberFinancialAccess:D}),Object(y.jsx)("div",{className:"mt-4 mb-4 text-2xl font-bold",children:"Notes"}),Object(y.jsx)(Qi,{control:m.TextArea,id:"notes",name:"notes",rows:"5"})]})})]})}})]})})]})}),{resourceName:"Equipment Item",btnLink:Cc.equipment,btnText:"View Equipment"}),dO=function(e){var t=e.equipment,n=e.nonFinancialAccess,a=t.valuations,r=a?a.find((function(e){return"PURCHASE"===e.type})):{};return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Purchase Price",className:"w-1/3",text:"text-lg"}),n()?Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:(null===r||void 0===r?void 0:r.amount)||""}):null]}),Object(y.jsx)(Fl,{data:r&&r.dateEpoch&&0!==r.dateEpoch?zd(r.dateEpoch):"--",header:"Purchase Date",className:"w-1/3",text:"text-lg"})]})})},uO=function(e){var t=e.equipment,n=e.nonFinancialAccess,a=t.valuations,r=a?a.find((function(e){return"CURRENT"===e.type})):{};return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Current Value",id:"currentValue",className:"w-1/3",text:"text-lg"}),n()?Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:(null===r||void 0===r?void 0:r.amount)||0}):null]}),Object(y.jsx)(Fl,{data:r&&r.dateEpoch&&0!==r.dateEpoch?zd(r.dateEpoch):"--",header:"Current Value Date",id:"currentValueDate",className:"w-1/3",text:"text-lg"})]})})},bO=function(e){var t,n,a,r,c=e.equipment;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsx)(Fl,{data:(null===c||void 0===c?void 0:c.name)||"--",header:"Name",className:"w-1/3",text:"text-lg"}),Object(y.jsx)(Fl,{data:Object(ne.startCase)(Object(ne.camelCase)(null===c||void 0===c||null===(t=c.type)||void 0===t?void 0:t.split("_")))||"--",header:"Type",className:"w-1/3",text:"text-lg"})]}),Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsx)(Fl,{data:(null===c||void 0===c||null===(n=c.year)||void 0===n?void 0:n.toString())||"--",header:"Year",className:"w-1/3",text:"text-lg"}),Object(y.jsx)(Fl,{data:(null===c||void 0===c?void 0:c.make)||"--",header:"Make",className:"w-1/3",text:"text-lg"}),Object(y.jsx)(Fl,{data:(null===c||void 0===c?void 0:c.model)||"--",header:"Model",className:"w-1/3",text:"text-lg"})]}),Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsx)(Fl,{data:Object(ne.startCase)(Object(ne.camelCase)(null===c||void 0===c||null===(a=c.statusHistory[0])||void 0===a?void 0:a.status))||"--",header:"Current Status",className:"w-1/3",text:"text-lg"}),Object(y.jsx)(Fl,{data:zd(null===c||void 0===c||null===(r=c.statusHistory[0])||void 0===r?void 0:r.dateEpoch)||"--",header:"Current Status Date",className:"w-1/3",text:"text-lg"}),Object(y.jsx)(Fl,{data:(null===c||void 0===c?void 0:c.unitId)||"--",header:"Unit ID",className:"w-1/3",text:"text-lg"})]}),Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsx)(Fl,{data:(null===c||void 0===c?void 0:c.serialNumber)||"--",header:"Serial Number",className:"w-1/3",text:"text-lg"}),Object(y.jsx)(Fl,{data:(null===c||void 0===c?void 0:c.licenseNumber)||"--",header:"License Number",className:"w-1/3",text:"text-lg"})]})]})};dO.defaultProps={equipment:{valuations:{find:function(){}}}},dO.defaultProps={equipment:{valuations:{find:function(){}}}};var jO=function(){var e=Object(a.useState)({}),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(!0),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],f=function(){j(!1)},v=Object(a.useContext)(ac),O=Object(b.a)(v,2)[1],h=Object(p.h)(),x=Object(p.j)().id,g=xl("equipment"),C=Object(a.useState)(),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useContext)(ac),N=Object(b.a)(T,1)[0].loggedInUserOrgPermission,E=(null===N||void 0===N?void 0:N.role)!==er?Jo(Ps,"shareOrPrint"):Ps;Object(a.useEffect)((function(){"View Only"!==(null===N||void 0===N?void 0:N.role)&&"Full control"!==(null===N||void 0===N?void 0:N.role)||Object.prototype.hasOwnProperty.call(N,"financialAccess")?S(null===N||void 0===N?void 0:N.financialAccess):S("none")}),[N]);var w=Object(a.useCallback)((function(){return"View Only"!==(null===N||void 0===N?void 0:N.role)||"none"!==A}),[N.role,A]);Object(a.useEffect)((function(){s(!0),g.fetch(x).promise.then((function(e){var t=e.data;r(t),s(!1)})).catch(Ae.default).catch((function(e){uc(O)(e),s(!1)}))}),[]);return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"equipment-view",children:[Object(y.jsxs)(lo,{disabled:!0,children:[Object(y.jsx)(lo.Item,{title:"Equipment",value:"All Equipment",to:Cc.equipment}),Object(y.jsx)(lo.Item,{title:"Equipment",value:null===n||void 0===n?void 0:n.name,isLast:!0})]}),o?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{children:[Object(y.jsx)(Bv,{open:u,close:f,equipmentName:null===n||void 0===n?void 0:n.name,equipmentId:null===n||void 0===n?void 0:n.id,label:"view"}),Object(y.jsxs)("div",{className:"mb-10","data-testid":"equipment-view-loaded",children:[Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{className:"w-full flex mr-4",children:Object(y.jsx)("div",{className:"text-3xl font-med my-6",children:"View Equipment"})}),Object(y.jsx)("div",{className:"flex",children:Object(y.jsx)("div",{className:"w-1/2 flex mr-4",children:Object(y.jsx)("div",{className:"flex mx-2",children:Object(y.jsx)(Wo,{onAction:function(e){switch(e){case"edit":h.push("".concat(Cc.equipment,"/").concat(x));break;case"delete":j(!0)}},options:E})})})})]}),Object(y.jsxs)(ll,{children:[Object(y.jsxs)("div",{className:"bg-white w-full p-6",children:[Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold ",children:"Basic Info"}),Object(y.jsx)(bO,{equipment:n})]}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]}),Object(y.jsxs)("div",{className:"bg-white w-full p-6",children:[Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold ",children:"History Info"}),Object(y.jsx)("div",{children:Object(y.jsx)("span",{children:Object(y.jsx)("br",{})})}),Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-lg font-bold",children:"Purchase History"}),Object(y.jsx)(dO,{equipment:n,nonFinancialAccess:w}),Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-lg font-bold",children:"Current Value"}),Object(y.jsx)(uO,{equipment:n,nonFinancialAccess:w})]}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]}),Object(y.jsx)("div",{className:"bg-white w-full p-6",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold ",children:"Notes"}),Object(y.jsx)(Fl,{data:(null===n||void 0===n?void 0:n.notes)||"--",text:"text-lg"})]})})]})]})]})]})})},pO=[{id:"equipment",key:"equipment",path:Cc.equipment,exact:!0,secure:!0,disabled:!1,icon:ql,nav:"leftNav",component:Hv},{id:"equipmentEntry",key:"equipmentEntry",path:"".concat(Cc.equipment,"/:id"),exact:!0,secure:!0,component:lO,minPermissions:{minAllowedRole:$a}},{id:"equipmentView",key:"equipmentView",path:"".concat(Cc.equipment,"/:id/view"),exact:!0,secure:!0,component:jO,minPermissions:{minAllowedRole:er}}],fO=(n(1465),n.p+"static/media/coming_soon.11299e40.svg"),mO=function(e){var t=e.size,n=e.color;return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 18 18",fill:"none","data-testid":"equipment-icon",className:"fill-current text-".concat(n),children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.5 6.00219V10.5472C16.965 11.0197 17.25 11.6647 17.25 12.3772C17.25 13.8247 16.0725 15.0022 14.625 15.0022C13.1775 15.0022 12 13.8247 12 12.3772C12 12.2816 12.0127 12.1859 12.0253 12.0903C12.0295 12.0584 12.0337 12.0266 12.0375 11.9947H8.1675C8.1225 12.2047 8.0625 12.4147 7.9875 12.6097L7.3125 12.3097L7.155 12.6547L7.8225 12.9547C7.4325 13.7272 6.795 14.3422 6 14.6872L5.7375 13.9897L5.385 14.1247L5.64 14.8072C5.28 14.9197 4.8975 15.0022 4.5 15.0022C4.02 15.0022 3.555 14.9047 3.1425 14.7397L3.4425 14.0647L3.0975 13.9072L2.7975 14.5747C2.025 14.1847 1.41 13.5472 1.065 12.7522L1.7625 12.4897L1.6275 12.1372L0.945 12.3922C0.8325 12.0322 0.75 11.6497 0.75 11.2522C0.75 10.7722 0.8475 10.3072 1.0125 9.89469L1.6875 10.1947L1.845 9.84969L1.1775 9.54969C1.5675 8.77719 2.205 8.16219 3 7.81719L3.2625 8.51469L3.615 8.37969L3.36 7.69719C3.72 7.58469 4.1025 7.50219 4.5 7.50219C4.98 7.50219 5.445 7.59969 5.8575 7.76469L5.5575 8.43969L5.9025 8.59719L6.2025 7.92969C6.3825 8.02719 6.555 8.13219 6.72 8.25219H8.25C9.075 8.25219 9.75 7.57719 9.75 6.75219V5.03469L8.955 4.23969L7.8975 5.29719L7.365 4.76469L10.0125 2.11719L10.545 2.64969L9.4875 3.70719L10.2825 4.50219H15C15.825 4.50219 16.5 5.17719 16.5 6.00219ZM2.25 11.2522C2.25 12.4972 3.255 13.5022 4.5 13.5022C5.745 13.5022 6.75 12.4972 6.75 11.2522C6.75 10.0072 5.745 9.00219 4.5 9.00219C3.255 9.00219 2.25 10.0072 2.25 11.2522ZM8.055 10.1122C8.0925 10.2397 8.1225 10.3672 8.1525 10.5022H12.795C13.2675 10.0372 13.9125 9.75219 14.625 9.75219C14.724 9.75219 14.823 9.76576 14.9185 9.77885C14.946 9.78261 14.9732 9.78634 15 9.78969V6.00219H11.25V6.75219C11.25 8.40969 9.9075 9.75219 8.25 9.75219H7.935L7.2375 10.0147L7.3725 10.3672L8.055 10.1122ZM13.5 12.3772C13.5 12.9997 14.0025 13.5022 14.625 13.5022C15.2475 13.5022 15.75 12.9997 15.75 12.3772C15.75 11.7547 15.2475 11.2522 14.625 11.2522C14.0025 11.2522 13.5 11.7547 13.5 12.3772ZM6.75 6.75195H3C2.5875 6.75195 2.25 6.41445 2.25 6.00195C2.25 5.58945 2.5875 5.25195 3 5.25195H5.25C6.075 5.25195 6.75 5.92695 6.75 6.75195Z"})})};mO.defaultProps={color:"neutral-600",size:18};var vO=Object(a.memo)(mO),OO=function(e){var t=e.size,n=e.color;return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 32 32","data-testid":"submit-icon",className:"fill-current text-".concat(n),children:Object(y.jsx)("g",{id:"icon (18px)",children:Object(y.jsx)("path",{id:"icon/communication/present_to_all_24px",fillRule:"evenodd",clipRule:"evenodd",d:"M28 3.99951H3.99998C2.51998 3.99951 1.33331 5.18618 1.33331 6.66618V25.3328C1.33331 26.8128 2.51998 27.9995 3.99998 27.9995H28C29.48 27.9995 30.6666 26.8128 30.6666 25.3328V6.66618C30.6666 5.18618 29.48 3.99951 28 3.99951ZM28 25.3595H3.99998V6.63951H28V25.3595ZM10.6666 15.9995H13.3333V21.3328H18.6666V15.9995H21.3333L16 10.6662L10.6666 15.9995Z"})})})};OO.defaultProps={color:"neutral-600",size:32};var hO=Object(a.memo)(OO),xO=function(e){var t=e.size,n=e.color;return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 52 52","data-testid":"checklist-icon",className:"fill-current text-".concat(n),children:Object(y.jsx)("path",{d:"M32.0533 24.6669L27.3333 19.9469L29.2133 18.0669L32.04 20.8936L37.6933 15.2402L39.5733 17.1202L32.0533 24.6669ZM24.6666 19.3336H12.6666V22.0002H24.6666V19.3336ZM38 27.8802L36.12 26.0002L32.6666 29.4536L29.2133 26.0002L27.3333 27.8802L30.7866 31.3336L27.3333 34.7869L29.2133 36.6669L32.6666 33.2136L36.12 36.6669L38 34.7869L34.5466 31.3336L38 27.8802ZM24.6666 30.0002H12.6666V32.6669H24.6666V30.0002Z"})})};xO.defaultProps={color:"neutral-600",size:32};var gO=Object(a.memo)(xO),CO=function(){var e,t,n=Object(a.useContext)(ac),r=Object(b.a)(n,2)[1],c=Object(a.useContext)(we),i=Object(a.useState)(void 0),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)([]),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(!1),m=Object(b.a)(f,2),v=m[0],O=m[1],h=Object(a.useState)(!1),x=Object(b.a)(h,2),g=x[0],C=x[1],y=Object(a.useState)(!1),P=Object(b.a)(y,2),A=P[0],S=P[1],T=Object(a.useState)(!1),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)(!1),R=Object(b.a)(_,2),I=R[0],D=R[1],k=Object(a.useState)([]),L=Object(b.a)(k,2),F=L[0],M=L[1],V=null===ac||void 0===ac||null===(e=ac._currentValue[0])||void 0===e||null===(t=e.organization)||void 0===t?void 0:t.id,B=Object(a.useState)([]),U=Object(b.a)(B,2),z=U[0],Z=U[1],Y=Object(a.useState)(!1),H=Object(b.a)(Y,2),G=H[0],W=H[1];return{isLoadingFields:g,loadUnmappedCropZonesCount:function(e){return O(!0),Hn.fetch(e,void 0,{headers:{"cwf-context":JSON.stringify({organization_id:V})}}).promise.then((function(e){var t=e.data;c.sendEventToAmplitude(c.events.epic.Integrations.JohnDeere.numberOfOperationAvailable,{operations:null===t||void 0===t?void 0:t.unmappedCount}),l(t)})).catch(Ae.default).catch((function(e){uc(r)(e)})).finally((function(){return O(!1)}))},isLoadingCropZoneCount:v,unmappedCropZoneCount:s,unmappedFarms:j,loadUnmappedFarms:function(e){return C(!0),Gn.fetch(void 0,{cropSeasons:e.toString()},{headers:{"cwf-context":JSON.stringify({organization_id:V})}}).promise.then((function(e){p(e.data[0].farms)})).catch(Ae.default).catch((function(e){uc(r)(e)})).finally((function(){return C(!1)}))},setUnmappedCropZoneCount:l,isLoadingMatchOperation:A,loadMatchCropZone:function(e,t,n,a){return S(!0),Wn.post({operationId:e,cropzoneId:t,cropseasonId:n,creationDate:a}).promise.then((function(e){return e.data})).catch(Ae.default).catch((function(e){return uc(r)(e),w(!0),[{status:400,message:"Bad Request"}]})).finally((function(){return S(!1)}))},matchOperationError:E,setMatchOperationError:w,loadMappedOperations:function(){return D(!0),qn.fetch(void 0).promise.then((function(e){var t=e.data.reduce((function(e,t){var n,a=null===t||void 0===t||null===(n=t.fields)||void 0===n?void 0:n[0];return a?(e[a.id]?e[a.id].operations.push(t):e[a.id]={fieldId:a.id,fieldName:a.description,farmName:t.farms[0].description,operations:[t]},e):e}),{});t=Object.values(t).sort((function(e,t){var n=e.fieldName,a=t.fieldName;return n.localeCompare(a)})).sort((function(e,t){var n=e.operations;return t.operations.length-n.length})),M(t)})).catch(Ae.default).catch((function(e){uc(r)(e)})).finally((function(){return D(!1)}))},isLoadingMappedOperations:I,mappedOperations:F,loadProductsMissingWeight:function(){return W(!0),Jn.fetch(void 0).promise.then((function(e){var t=e.data.sort((function(e,t){var n=e.productName.toUpperCase(),a=t.productName.toUpperCase();return n<a?-1:n>a?1:0}));Z(t)})).catch(Ae.default).catch((function(e){uc(r)(e)})).finally((function(){return W(!1)}))},isLoadingWeight:G,productsWithoutWeight:z}},yO=n.p+"static/media/chevron_right_24px.9090d2b0.svg",PO=n.p+"static/media/replace-data.458c149a.svg",AO=n.p+"static/media/Ribbon.0ac3d5cb.svg",SO=n.p+"static/media/McCainLogo.af984f80.png",TO=n.p+"static/media/SimplotLogo.c1836c7d.svg",NO=n.p+"static/media/AgrianLogo.d8aa4dc7.svg",EO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMYAAAAtCAYAAAD1GBQcAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAEudJREFUeNrsnXuUJUV9xz+/qr53ZpaFfYHs8liEFVRQNIAuICKgImdVVNSTI0rQgG9FBT1JlCQmHAMGkxCSCInGZwIRFYMBAkFWER9EBR+oC8uSBfb9msfOnbm3H1W//NF1Z3p67525szuzsnvud06f6equrq6uqt/v9/39qrqvqCo3P/pdiqhEFUZGd/Lo2l+zecdGttS2098YYSCpU8/cUQ6Wq+pxwJEZPkq818zrelRXAz818JiIMNtoiGCAmwe2c3KastUYuuhiT3HSDauIpsrkvCNJEyI4/5CeA95ie+1ZRljsVUm9o+EdDZcx4jLqLiPxbsh5f6+qfs2I3NJt5i72RbQVDAXiNAZ4xeELlnyqJ+p5cWQE5xypS5MkS1ySpcQukThLZSRLbC1Lo2GXzqtl6QWNLLvAqb9S4JOC3Npt6i72ecFQwHvH/AMX/v2i+YdcFhlLksZDjaThkiQ2cRqbOI2lksYSZbGJbCIVE2mvSVxPZk2PsVIzaTSSZc+PXfZN0JsEuQjw3SbvYp8RjGqlBwARIctS0jSV3p45dx9z5LNfmSSNnaONkVEb1yNjrFgTeWMtxhgRMUaM8SJGRMQggoh4K2IMkhkRERHbcOmFeH2BiJwJ9HebvYt9QjC29W8CIHMpc/oOZG7fQSsVPQvYmLlMKpWq8d6pV4+qx6v3qmpU1YMaVUUhP5ZbHO9RoyiAA0ys6QmK/kyQE4D6TFRegLoIsQi225ddzLRgrNu8FlSJ05hnHn7sF+fNXXBW5tINzjtRVREEMVatsRgbSWQznI80spE479R5h/cebytBeCL61GumilPFWfVevUlddjTwHeAlMyEUiQiLvOdw5xjt9mUXMwgDsGn7BtZuepxGUn9zNaq8vRGPbk+zVLIsEfWO3DBoGJDiRQxG5ABj7Dxj7EHW2AOtMXOtsVgTqTGWirHaa6z25Bs9xqoRi6KnA3+0pxVXwBvDO0dqnJimDHZDtV3MtGBsHtrCjtpAbyWq3phmKfVGLUniuk3TxGQuFeedOO9RVQe6EFgIJAgPGJE7RMwDRmzNip1jjZljjfFGrFaMpWoMFTFaMYbIGgVB0WuAg/fEWgwby+I046L6CNu6QtHFbAjGjvowGPv+3qhnYb0xsq0e16NG2pAkjSXJEkmzDO8z771b7L0fVfUfBzlR4DTgNcBpKjwH4SOC9BtkjjGCEaORGCIjRGK0IkbN+CC+co+shTX8Qb3GMpexwxik25ddzLRgjLiMalR5n/eORlKXRlw3cdyQOI0lTRPJskQzly7OXLbaq38hyNXA2lJZG4DrBHO8EfNzQXqNCFZEw0bYNNf5XApUd6fCQzZiaRLznpEaT1rbdby7mB3BaKg7pWLMMUmaJI24YeOkLnFSlyRpSJLGmmbxgjRLB7y6U0X4v3Za3IgBYYtXf6qIbAZ6jIgKghFRI4IRAQGFA4BXTreyuS+h3DjYz3z1DEpXLLqYJcFA5WwU4qzRiJOGhM3EuWBUkjSpuiy9zHs3oN4jEoh+QSiqJkLx1OIREpcmwCUhS9TMbkCF/C+/irOn41fURVBj+fTgAGcnMWtsRJSX00UXM4oIwMMJTh1xmkhkG0ZEcJFXa4yIyHyFp0T5t7FBOrZAMP/fV+lhYGSQLUM7yNQRGYugdwJrFJ4FeGnGtEAFJAzn53ZaUQc0bMTFtZ18eHSYR6IKXZe7i1kVDIUlsUtJssREacMDpuKdWmvViBHgR0UT0dyzxjKn2semwS081b8Br56qreDUN23Co6o8S6GiJdoVSnlZO1qmIYcAKTBa7eGckRqfHRpgrY1IxsxdF13MkmCk3vfFWUacxWKNFRC8eiIbBb9BtpeHrjURkbVsGNjME9vWISJUbYRXLeTSGx261qNOQcJMuMjYvmwuU6XYmJDSCWL4utow1+7sZ4cx7OzOdHexNwQj9i6pu5Q4jY0RCyLeq8e5TIy1gMwfG6gKxhjUKE9uf4p1/Zvoq/YQmQhVLXkFejtw+1S+w6AxYCxVl3Fm3GB5ErMsy6iLkIqw0Hte26hTF2GjsVS6fkUXe8libB12KQdlqRiTiIgY7706G6nxFiOcPuatiwWUpwY2sW24nznVXkRyCyMdzCY0RBgRIRMDuRBycJby1pFhVjTqnJim9KH4ZqSLfCZxo7Wk0BWKLvaeYDj1j9ayjFqWmIoxiJBbDO+w1sZGzDGorgC5ExKGG6MMNWr0VKpM9B10F+EwQCbChkqVYWNYEDdYoEqfyzjMp7wwTbh0tMYJWUq/MWyyFj8x6DWGLn3qYq8KBsp99SxjOEsqFWMSRYz36p11Yr1NjdgeI3KDxx/VSGPqSYOKjXDqSvQpL0wQEmNIxLA+ijBxnXN3DnBqbZgTkgYHek9V4TCfMUeVITE8HKJM0kYouuhirwuGwPdjnw3tzNJ5kTEi+RpyU1Gr1lhrxNSNyFJE7gPOrdhKnHlH+4iS0uMdFuWCwe2c17+VE+t1DlLPgI2IRfAi7DCWbeGarjXo4mknGEbEO+8/P5KlV1SNsQLOi9KrEdZYMWLUiGkIcqYIq4BPiMjXRSWTEuf3ItSs5YNPreHFQ/3MdQ4VYWulykZ+JyHWCrCA8QhwCgx0u36fwEFAH/mbnwYYBYb3HpUCDHJ14rIrhtN8zYVX1dR67RGrkbUYMRhogByNcBPoNYr+VuHzwDeb5aSAVzisUWdBmrK+t2/MZzDjA/UVwMnAoUAv+Vt9jwA/AX4zw894KnBvIf0r4JQprjm3wOgEiIHvznJfLAZeCG2jCw7YCKyaJM/+hn8G3lQQjC8C79qrgiEiO0A/Xs/SvxIRo4rPvBJbR9VbiUSwYlSEBLAKS1V1qVfdrEEwDLCup5fz+rdyXH2E9b19Y2o64Erg/WEQtMP/AtcDN82gxagU0gunyP8q4K4Wx583C0JbxHmh46fCBuDbwKfC/v6MxUz8LsEhpfPvC4LTxJeAr8zEjScwG0GuBv15PUullqVmxKVSyzJTc6nUXCrDLjG1/JwfydJ0xKWMuGzLqMsYdRnDPiNOYs4Z2EZVFT8uEhHwfeCqKYQCYDnw7zPYuFkpPZUp/sM2x98+y4Og09d9DwfeCzwWrO7+jDLlHSylTyNfb9fcZqw9dvlKiCBnqfo19Sw9xKmaqlVNvWkuGc9XxzI+N62qY6N/S6XC8uFBTq6PsqVSpeB/rARe2uL+PwQeDjzyNcCicPzx31FH9AGvb3PubcDHZvHeZXoUA82VAT0tFEof+WvChwLJfioYFwblnYWxWo74rJ0iPXOCAewU5CSFH8cuOyJTL4nJXzIKgiHCRIak5KsCB63llNFhDnUZj0S9mDyU+84WQrEFuAD4UeHY3KAJ/xpY1qJeS4HjgSOCSZWgQdYBPwM2zUB7XED7d0QWh+e4v4Nynh+02SHAE8CtwSIcx/i85Q5g+xSU8mUFy34EcDnwoUKe+cAbgK+1KeP4oEWXhb7eAPwceKBN/kNDmU23cDOwM5w7KjjDjwRXsif0SZGy/jbsvyg8fxT8xh+U7nNc0PDzg8/3323qkwQFEBUCJ817LQGOLOV/ZjjWE9qsWP8yK3lu6FMX2mVVaJu2ggGwXuB5Al933r3Sey+ZGDFG1CAYQcblIrcYTgSTxjwriWkY2xQKAn2aELgKDvETpeM14NrQaX8MHFigPdeVBkQrunRLEKydeyAY7+iAZt0/BTX9atB0RWwMgls09ddP8Uyu1GZPAR8GzgR+r3DupBaCcWxosxWTCN27wqAs4lrgokL6OcA88gDLuYVB/Vg494tC3iHgDOAjLejot4HXhf3Phn4q4oFQfpnm/m2pja4C/iwI+qoWz/WhUv73BAe+iXcGq39sm3ZZG+p292TR0yHgXIN8UGCrV0fmnCQuk3h8I3aO2DlGnCNKU+Y7Rzz+3dpTghYq4sYWQlHE/cCrgUZJw0xl+S4MlqOyB47eywvpx1tQpzdPokwImvHCFscPa8F/p/o8arupnUemyPf8ECRYMYUf91BJ47cq69PA6oJQUIrWUbL4D7fx0c4HPhf8zPe2iRx+tQNGYwvUshMsKux/BviXSYQC4Ohg6TqaVvhH4GhBLhf4qZB/METDN6ZUdbGq0kBZkmUc7hy18fe6X9yivK91+FBpYb83mNWbgA8AFwOXAbe10JQX7aZgvKmU/mVozKIFOgB4bZvr391s1AJ+GyzDjcCTLXyITp+/iDItXV0aOCtLyuEDQcOeAPxnKe8NU9TpdaHtWw1W32bQ3gV8o0W9Lw11Xxmse9LiXounqE/zmm2hjDUt2vuWQF1vDTSuSe2uKAU6rgt9/kbgLwo0ak4nWquJUeDvwnZs/hEEOQ44BvifpgJp7PqF80NblLVuNwbtR4H1wNbS8X9oYZpfBHxhN+5xYil9X/h/d7AURbr1rRbXX15K31PStFcEQesUcwoar5f8ha8/D75GEd8qDb6DS+l/LaTfEPj0YSG9gjx83e7rkN8NmvzBYCEWThIiVvJQ9z0hfUmgYEW8lfEw/HktfIvjCwGHybAR+P3QHp8sHL8hKPIyXt3i+o8U0reGcq4IQtexYBTxWNgmxnyN5eRGnaOcY5O1k9GFbDfu+VDB2TwjmLxlwaTOVIjuVaV0M2T8lZJgvDo4oUVLsqQF3ftgKd07zfosLyiRXlovIft4syMLwYMyhbuwcO0oMNKCet3Xpg5/EvyRTqNqKwvpO1vkKU60rgwWoBjsmO7HMQ4qpRe0yVcrpZcFWndXsBQPBqX7N53y3M7MiQgV53j/SG1s5Iee2NnBw3SCZ4RKX9A0dR06rZ3izBLfvidEjSB/n2RHQXuboK0+V8hf1uI7W4Scp7sczISITDt8Cri6BUcu4i87uM+CSc4tmWadDysIc7VNeVsK4eZGKd90+06mSDfxjRBYKFPSlxYo2veCT7WyUx9jyprFxvLyuM4ZScx6a4u1a/VFkRdN8xaHBKfubSWhWB+k/tEZkO13tDDpvwr3/WkLh36q6FXG7Czb2BAs2am0/i5X2SlthLr4wubC5jvwdfZkoXMnimBvLW15AnjLJGylGmjvvc3o2R5bjEzyqb7XN+pjLxfJrjy9iI+RT91PhhUhOjUczPkzCudWBUf3B+F2H22hDaaDqIXjfXjY2uG0cL7Jt7e30MJzQ2SviekuXHwwKINKeM5GUDST/ZRCOdx5cfATKm2c+2387jAbbxhM1jb/Afw4tMnZgUIuapHvw8Bte2wxaiIckaYsTxO2TbQWBN52dwtt/E9tijuQPOZ9RyECUbYwVwah0VKkYndxfhjE00Ux+vVkgXo1O/2qFlx+OmgurHwY+HWIwEz1+yK/LqXPCoN/Y4ttW6Be89h3YdtErco4PdC8JwO9PDvQ35OYOM/RpHgzsApcDM/LUhY7x0jr3927rMWx95HPel8SokGnB868hjwcuqFg4suFFiM9i8iXkuwJ3l5Kfzn4HOeE7ewwwH7SQhsXNdXtLZzv+wP1+SX55NJ00LMbz/LZUvq9wTd7ZuHY3NCGtwcLdPA+LBhlRfGakpJtPtuHQsDoUsYXkTaC431XC0s6M853FcW0J4yrw+D7Ugs6clqbIovx7O8x8WcD3h049lam+SXDNoGAcijvT2kdUr6BifMyzyGfG/hN4bqLS9ecMUv8vR2+HwTxrYVjl4ft8dDph5Yc7qF9WDAeauFQPxKe9SXks+TXh/ScEDC5LtDUTUFhLC+VcfvMWAwgQ3CT9/SXyRfnbeywyOJv9l1DvhyiiBcEoYjZdSl4ee5kziSRm0+U2mAL7edZWn3t5JrC/rogCK0Wsn2HXZfRyxTRuqW72R1vI5/hLWNZEOYFk9RjSQtq26lFMyVfppVf01uiQeVnPqCUfkYpXbZut7DrxOmzg486rxDxqpTucSZ5ZLEsFF8IkamZsRgd4rbgb1xCPrlzfOiISnBMVwXr8F/kSzvG3JggCNeH6xaRTwLdG2jaceQTPWloiHtK910Xymy+QbumxEnvCNGKCnDzJPXfTh4efUG4lw1ap/gRrB+ST3qeTz6/IuTrgO4Mdb1wEk29qlSXX+xBW787dPJFQXMuDYNQw3OsDjTvtlLg4M5AT9IwNlZPco9twR9swjExPD8YypeS4ilGzG4O1M6H9nyidI+VgfqkoU1+WDofBz/hM+TLeY5kfLHhE4yvp7o2KNdzgpVfGspLwvEHyd+FGRs7oqrMv/Jlu90DQzZiRX2Ezw/2syV84WMaWBg6YCcT10ZNpqUWhE5xPL0ggWo9xK7LOeYGS3JwiQ/fsZfqNifUQYMSytg/sYTmF5cmj7gtCoKRloImQIe/8z3LmO4PVRbfUXi6QcmXZywIA/4XoYOWkc+cl3n9XXuxbqNh29/R6asHO6bKENHFTGI4aK03hq0d3vQ0tHhdlBymLmYOU03iPUj+IYjvdJvq6Y2uxZhZXEw+IXkM+cx4MxqyNlCru9l/X0Pdr/D/AwCJGka6j2PuBwAAAABJRU5ErkJggg==",wO=n.p+"static/media/CropwiseProductLogo.5c82cc95.svg",_O=function(e){switch(e){case"McCain":return SO;case"Simplot":return TO;case"Agrian":return NO;case"CalAgPermits":return EO;case"Connect":return wO;default:return null}},RO={McCain:{imageContainer:"m-auto py-3",image:"m-auto w-1/2"},Simplot:{imageContainer:"m-auto pt-10 pb-8",image:"m-auto w-1/2"},Agrian:{imageContainer:"m-auto pt-10 pb-10",image:"m-auto w-1/2"},CalAgPermits:{imageContainer:"m-auto pt-10 pb-10",image:"m-auto w-1/2"},Connect:{imageContainer:"m-auto pt-8",image:"m-auto"}},IO=function(e){var t=e.title,n=e.description,r=e.integrationType,c=e.isExternalLink,i=e.urlPath,o=e.reloadUnmappedCropZonesCount,s=Object(a.useContext)(ac),l=(Object(b.a)(s,1)[0].organization,Object(p.h)()),d=(window.location,{johnDeere:{url:"https://".concat("uat.","connect.cropwise.com/integrations")}}),u=CO(),f=u.loadUnmappedCropZonesCount,v=u.unmappedCropZoneCount,O=u.isLoadingCropZoneCount,h=Object(a.useState)(null===v||void 0===v?void 0:v.unmappedCount),x=Object(b.a)(h,2),g=x[0],C=x[1];Object(a.useEffect)((function(){return C(void 0),"Connect"===r&&f(),function(){}}),[o]),Object(a.useEffect)((function(){return C(null===v||void 0===v?void 0:v.unmappedCount),function(){}}),[v]);var P=function(){return Object(y.jsxs)("div",{className:"p-4",children:[Object(y.jsx)("h1",{"data-testid":"integrations-card-title-".concat(r),className:"text-base text-neutral-1000",children:t.toLocaleUpperCase()}),Object(y.jsx)("div",{"data-testid":"integrations-card-image-".concat(r),className:RO[r].imageContainer,children:Object(y.jsx)("img",{className:RO[r].image,src:_O(r),alt:""})}),Object(y.jsx)("span",{"data-testid":"integrations-card-subtitle-".concat(r),className:"text-xs text-gray-600 leading-4",children:n})]})};return Object(y.jsx)("div",{"data-testid":"integrations-card",className:"bg-white border rounded shadow-lg",style:{width:"432px",height:"auto"},children:Object(y.jsx)("div",{children:c?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("a",{"data-testid":"anchor-".concat(r),href:d.johnDeere.url,rel:"noreferrer",target:"_blank",children:P()}),"Connect"===r?Object(y.jsx)(y.Fragment,{children:0===g?null:Object(y.jsxs)(pu,{className:"flex w-430px rounded-b-lg bg-neutral-80 pb-4 pt-4",onClick:function(){O||l.push(Cc.integrationCropZoneMatcher)},children:[Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"pt-34px",children:Object(y.jsx)("img",{src:AO,alt:""})}),Object(y.jsx)("div",{className:"text-golden h-4 text-3xl w-51px pt-29px text-center",children:O?Object(y.jsx)(m.Spinner,{size:"sm",color:"white"}):g})]}),Object(y.jsxs)("div",{className:"pt-4",children:[Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"h-8",children:Object(y.jsx)("img",{src:PO,alt:""})}),Object(y.jsx)("div",{className:"text-base text-white",children:"CROPZONE MATCHING REQUIRED"})]}),Object(y.jsxs)("div",{className:"flex text-sm text-white pb-4",children:["Match your machinery integration data from Cropwise Connect to Crop Zones",Object(y.jsx)("div",{className:"pr-23px",children:Object(y.jsx)("img",{src:yO,alt:""})})]})]})]})}):null]}):Object(y.jsx)(j.b,{to:i,children:P()})})})};IO.defaultProps={isExternalLink:!1,urlPath:"",reloadUnmappedCropZonesCount:!0};var DO=IO,kO=function(e){var t=e.children;return Object(y.jsx)("div",{className:"flex flex-row gap-4","data-testid":"integration-gallery-card",children:t})},LO={name:"Simplot",title:"Simplot Integration",description:"The Simplot Integration allows you to share your field information to Simplot at anytime.",integrationType:"Simplot",urlPath:"".concat(Cc.integrations,"/Simplot/landing-page"),launchDarklyFlag:"feIntegrationsModuleEnableSimplot"},FO={name:"Agrian",title:"Agrian Integration",description:"Send application records to your NextGen Agrian account, to share with additional 3rd parties as needed.",integrationType:"Agrian",urlPath:"".concat(Cc.integrations,"/Agrian/landing-page"),launchDarklyFlag:"feIntegrationsModuleEnableAgrian"},MO={name:"Agrian Recommendations",title:"Agrian Integration",description:"Import recommendations from your NextGen Agrian account to CropwiseFinancials, so they can be converted to tasks.",integrationType:"Agrian",urlPath:"".concat(Cc.integrations,"/AgrianRecommendation/landing-page"),launchDarklyFlag:["releaseFeAgrianRecommendationIntegration","releaseFeAgrianRecommendationIntegrationByOrgs"]},VO={name:"CalAgPermits",title:"CalAgPermits Integration",description:"Send application records to your CalAgPermits account, to share with additional 3rd parties as needed.",integrationType:"CalAgPermits",urlPath:"".concat(Cc.integrations,"/CalAgPermits/landing-page"),launchDarklyFlag:["feIntegrationsModuleEnableCalAgPurPerOrg","feIntegrationsModuleEnableCalAgPurGlobal"]},BO={name:"McCain",title:"McCain Foods Inc. Integration",description:"The McCain Foods Inc. Integration allows you to share your field information to McCain Foods at anytime.",integrationType:"McCain",urlPath:"".concat(Cc.integrations,"/McCain"),launchDarklyFlag:["feIntegrationsModuleEnableMcCain","feIntegrationsModuleEnableMcCainPerOrg"]},UO={name:"",title:"",description:"Connect your data for John Deere Operation Center, CNH AFS Connect\u2122, and more, powered by Cropwise Connect.",integrationType:"Connect",launchDarklyFlag:["beJohnDeereEnabledForAll","beJohnDeereEnabledPerOrg"]};function zO(e,t,n){return Array.isArray(t.launchDarklyFlag)?t.launchDarklyFlag.some((function(t){var a=e[t];return Array.isArray(a)?a.includes(n):a})):e[t.launchDarklyFlag]}function ZO(e,t){return[UO].filter((function(n){return zO(e,n,t)}))}var YO=function(e){return"success"===e?"operation(s) mapped. You can adjust crop zones via the associated task.":"operation(s) were unable to be matched, contact support if issue persists."},HO=function(e){return"success"===e?"Data matched to":"Data unable to be matched to"},GO=function(e){var t=e.title,n=e.subtitle,a=e.icon;return Object(y.jsxs)("div",{className:"mt-8 mb-10 flex flex-row w-full justify-start",children:[Object(y.jsx)("div",{children:Object(y.jsx)("div",{className:"bg-green-200 p-2 rounded-full",children:a})}),Object(y.jsxs)("div",{className:"flex flex-col ml-4",children:[Object(y.jsx)("h2",{className:"text-lg font-semibold text-neutral-1000",children:t}),Object(y.jsx)("p",{children:n})]})]})},WO=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2),n=t[0],r=n.cropZoneMatcherType,c=n.showToastCropZoneMatcher,i=n.additionalInformationToastCropZoneMatcher,o=n.organization,s=t[1],l=Object(f.useFlags)(),d=i.operationMapped,u=i.cropZoneName,j=Object(a.useState)(c),p=Object(b.a)(j,2),m=p[0],v=p[1],O=Object(a.useState)(null),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)(null),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(null),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)(!1),R=Object(b.a)(_,2),I=R[0],D=R[1],k=function(){D((function(e){return!e}))};return Object(a.useEffect)((function(){g(ZO(l,null===o||void 0===o?void 0:o.id)),S(function(e,t){return[BO,LO,FO].filter((function(n){return zO(e,n,t)}))}(l,null===o||void 0===o?void 0:o.id)),w(function(e,t){return[VO,MO].filter((function(n){return zO(e,n,t)}))}(l,null===o||void 0===o?void 0:o.id))}),[l,o]),Object(y.jsxs)("div",{"data-testid":"integrations",children:[Object(y.jsx)(lo,{onOrganizationSelect:k,hideCropSeasonDropdown:!0,onCropSeasonSelect:k,children:Object(y.jsx)(lo.Item,{title:"Integrations",value:"All Integrations",isLast:!0})}),Object(y.jsxs)("div",{"data-testid":"integrations-cards-container",className:"my-4 ml-6 font-body",children:[(null===x||void 0===x?void 0:x.length)<=0&&(null===A||void 0===A?void 0:A.length)<=0?Object(y.jsx)("div",{className:"h-screen flex items-center justify-center",children:Object(y.jsxs)("div",{className:"text-center grid grid-rows-3",children:[Object(y.jsx)("div",{className:"row",children:Object(y.jsx)("img",{width:150,src:fO,alt:"empty-state",className:"mx-auto"})}),Object(y.jsxs)("div",{className:"row",children:[Object(y.jsx)("div",{className:"font-bold",children:Object(y.jsx)("span",{children:"Integrations Coming Soon"})}),Object(y.jsx)("div",{className:"w-96 row",children:Object(y.jsx)("span",{children:"We\u2019re hard at work adding Integrations to Cropwise Financials. These will make it easier for you bring in your data and send it out to the partners you work with. Stay tuned!"})})]})]})}):Object(y.jsx)(y.Fragment,{}),(null===A||void 0===A?void 0:A.length)>0&&Object(y.jsx)(GO,{title:"Processor",subtitle:"Selectively send your Task based application records to the various food processing companies that you contract with",icon:Object(y.jsx)(hO,{color:"green-700"})}),Object(y.jsx)(kO,{children:null===A||void 0===A?void 0:A.map((function(e){var t=e.integrationType,n=e.title,a=e.description,r=e.name,c=e.urlPath;return Object(y.jsx)(DO,{title:n,description:a,status:r,integrationType:t,urlPath:c},t)}))}),(null===E||void 0===E?void 0:E.length)>0&&Object(y.jsx)(GO,{title:"Regulatory",subtitle:"Manage records for regulatory purposes",icon:Object(y.jsx)(gO,{color:"green-700"})}),Object(y.jsx)(kO,{children:null===E||void 0===E?void 0:E.map((function(e){var t=e.integrationType,n=e.title,a=e.description,r=e.name,c=e.urlPath;return Object(y.jsx)(DO,{title:n,description:a,status:r,integrationType:t,urlPath:c},t)}))}),(null===x||void 0===x?void 0:x.length)>0&&Object(y.jsx)(GO,{title:"Machinery",subtitle:"Tracking apps for tractors, planters, harvesters and agricultural aircraft",icon:Object(y.jsx)(vO,{color:"green-700",size:32})}),Object(y.jsx)(kO,{children:null===x||void 0===x?void 0:x.map((function(e){var t=e.name,n=e.description,a=e.integrationType;return Object(y.jsx)(DO,{title:t,description:n,integrationType:a,reloadUnmappedCropZonesCount:I,isExternalLink:!0},a)}))})]}),Object(y.jsx)(Qc,{type:r,title:"".concat(HO(r)," ").concat(u),open:m,onClose:function(){v(!1),s({type:Vr,payload:!1})},timeout:5500,children:Object(y.jsx)("p",{className:"text-sm font-body",children:"".concat(d," ").concat(YO(r),".")})})]})},qO="All",JO="McCain",KO="Simplot",QO="Agrian",XO="AgrianRecommendation",$O="CalAgPermits",eh=[{number:1,header:"Sign In",description:"Authenticate with your vendor credentials"},{number:2,header:"Select Organization",description:"Select an organization which you would like to submit Task records"},{number:3,header:"Select Crop Seasons",description:"Select the Crop Seasons with which you would like to submit Task records"},{number:4,header:"Select Properties",description:"Select the Properties with Tasks records you would like to submit"},{number:5,header:"Match Properties",description:"Match the Cropwise Financials properties with the integration vendor"},{number:6,header:"Review and Submit",description:"Review your Task records and then submit the information to the processor"}],th="pending",nh="in_progress",ah="done",rh="error",ch=function(e){for(var t=(new Date).getFullYear(),n=[],a=0;a<e;a++)n.push(String(t+1-a));return n}(8).map((function(e){return{key:e,value:e}})),ih=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useContext)(ac),i=Object(b.a)(c,2)[1];return{createMcCain:Object(a.useCallback)((function(e){return r(!0),_n.create(e).promise.then((function(e){return e})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[i]),isLoading:n}},oh="SET_STEP",sh="SET_PROPERTIES_GROUPED_BY",lh="SET_SELECTED_PROPERTIES",dh="SET_OPEN_SUBMISSION_MODAL",uh="SET_OPEN_RESUBMISSION_MODAL",bh="SET_SUBMISSION_FLOW_ID",jh=function(e,t){switch(t.type){case oh:return Object(I.a)(Object(I.a)({},e),{},{step:t.payload});case sh:return Object(I.a)(Object(I.a)({},e),{},{propertiesGroupedBy:t.payload});case lh:return Object(I.a)(Object(I.a)({},e),{},{selectedProperties:t.payload});case dh:return Object(I.a)(Object(I.a)({},e),{},{openSubmissionModal:t.payload});case uh:return Object(I.a)(Object(I.a)({},e),{},{openResubmissionModal:t.payload});case bh:return Object(I.a)(Object(I.a)({},e),{},{submissionFlowId:t.payload});default:return e}},ph=function e(t){return Array.isArray(t[0])?e(t[0]):[t[0],t[1]]},fh=function e(t){return Array.isArray(t[0])?t.flatMap(e):[t]},mh={integrationStatus:qO,step:0,propertiesGroupedBy:"property",selectedProperties:[],openSubmissionModal:!1,openReSubmissionModal:!1,submissionFlowId:null},vh=Object(a.createContext)(mh),Oh=function(e){var t=e.children,n=We().user,r=Object(a.useReducer)(jh,mh),c=Object(b.a)(r,2),i=c[0],o=c[1],s=ih(),l=s.createMcCain,d=s.isLoading,u=function(e){return fh(e).map((function(e,t){return{longitude:e[0],latitude:e[1],sequenceNumber:t+1}}))},j=function(e,t){var n=0;return e.forEach((function(e){e.cropZoneIds.includes(t)||(n=e.startDateEpoch)})),0===n&&(n=e[0].startDateEpoch),new Date(n).getFullYear()},p=function(e){return{id:null===n||void 0===n?void 0:n.id,fmsVendor:"Agconnections",vendorNumber:e.mccainVendorId,name:null===n||void 0===n?void 0:n.name,country:"United States",growerContinent:"North America",email:null===n||void 0===n?void 0:n.email,farm:e.selectedProperties.map((function(t){return{id:t.id,name:t.name,field:t.fields.map((function(t){var n,a,r=ph(null===(n=t.cropzones[0])||void 0===n?void 0:n.geometry.coordinates),c=Object(b.a)(r,2),i=c[0],o=c[1];return{id:t.id,name:t.name,officialArea:null===(a=t.cropzones[0])||void 0===a?void 0:a.boundaryArea,unitOfMeasure:"acre",soilType:"",longitude:i,latitude:o,cropZone:t.cropzones.map((function(n){return{id:n.id,name:"".concat(t.name," - ").concat(n.name),boundaries:u(n.geometry.coordinates),longitude:i,latitude:o,acreage:n.boundaryArea,unitOfMeasure:"acre",products:n.products,season:j(e.selectedCropSeasons,n.id)}}))}}))}}))}},f=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=p(t),e.next=3,l(n);case 3:201===(null===(a=e.sent)||void 0===a?void 0:a.status)&&o({type:oh,payload:4});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(y.jsx)(vh.Provider,{value:{state:i,dispatch:o,goBack:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;o({type:oh,payload:e||i.step-1})},goForward:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;o({type:oh,payload:e||i.step+1})},updateSelectedProperties:function(e){o({type:lh,payload:e})},updateSubmissionFlowId:function(e){o({type:bh,payload:e})},submitToMcCain:f,isLoading:d,setModalSubmissionState:function(e){o({type:dh,payload:e})},setModalResubmissionState:function(e){o({type:uh,payload:e})}},children:t})};Oh.defaultProps={children:null};var hh=Oh,xh=n(202),gh=n.n(xh),Ch=function(e){var t=e.stepNumber,n=e.caption,r=e.currentStep,c=e.canGoNext,i=e.gotoStep,o=Object(a.useMemo)((function(){return t===r+1&&c}),[t,r,c]),s=r===t?"bg-info-dark-blue text-white":"bg-white text-gray-500",l=r>t?"text-blue-600 border-blue-600":"",d=r===t?"text-lg font-semibold":"text-neutral-60",u=r>=t?"border-info-dark-blue":"border-gray-400",b=r>t||o?"hover:text-info-dark-blue text-neutral-600 cursor-pointer":"";return Object(y.jsxs)(pu,{className:"flex",onClick:r>t||o?function(){return i(t)}:null,children:[Object(y.jsx)("div",{"data-testid":"progress-bar-number",className:"h-auto border rounded-3xl ".concat(t>=r?"":"p-2"," ").concat(s," ").concat(l," ").concat(u," mr-2 flex"),style:t>=r?{padding:"3px 10px"}:{},children:t>=r?t:Object(y.jsx)(gh.a,{style:{fontSize:12,color:"#0071CD"}})}),Object(y.jsx)("div",{"data-testid":"progress-bar-text",className:"flex items-center w-full whitespace-no-wrap  ".concat(b," ").concat(d),children:n})]})},yh=function(e){var t=e.stepArray,n=e.currentStep,r=e.canGoNext,c=e.gotoStep,i=e.style,o=e.className;return Object(y.jsx)("div",{className:"flex w-full px-4 mb-5 mt-5 ".concat(o),id:"integration-proggress-bar",style:i,children:t.length>0&&t.map((function(e,i){return Object(y.jsxs)(a.Fragment,{children:[Object(y.jsx)("div",{className:"w-auto",children:Object(y.jsx)(Ch,{stepNumber:i+1,caption:e.caption,currentStep:n,canGoNext:r,gotoStep:c})}),t.length!==i+1?Object(y.jsx)("div",{className:"h-px w-full my-auto mx-2 bg-gray-500 "}):null]},e.caption)}))})};yh.defaultProps={stepArray:[],currentStep:1,canGoNext:function(){return!1},style:{},className:""};var Ph=yh,Ah=[{caption:"Select Crop Seasons"},{caption:"Select Properties"},{caption:"Review and Submit"}],Sh=function(e){var t=e.size,n=e.color;return Object(y.jsx)("svg",{className:"mt-2px",width:t,height:t,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"map-icon",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.255 2.2725L15.375 2.25C15.585 2.25 15.75 2.415 15.75 2.625V13.965C15.75 14.1375 15.6375 14.2725 15.48 14.325L11.25 15.75L6.75 14.175L2.745 15.7275L2.625 15.75C2.415 15.75 2.25 15.585 2.25 15.375V4.035C2.25 3.8625 2.3625 3.7275 2.52 3.675L6.75 2.25L11.25 3.825L15.255 2.2725ZM10.5 5.15156L7.5 4.10156V12.8466L10.5 13.8966V5.15156ZM3.75 4.845L6 4.0875V12.8625L3.75 13.7325V4.845ZM12 13.9125L14.25 13.155V4.275L12 5.145V13.9125Z",fill:n})})};Sh.defaultProps={color:"#696F88",size:18};var Th=Object(a.memo)(Sh),Nh=function(e){var t=e.size,n=e.color;return Object(y.jsx)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"mt-2px","data-testid":"cost-icon",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 0.5C3.86 0.5 0.5 3.86 0.5 8C0.5 12.14 3.86 15.5 8 15.5C12.14 15.5 15.5 12.14 15.5 8C15.5 3.86 12.14 0.5 8 0.5ZM8 14C4.6925 14 2 11.3075 2 8C2 4.6925 4.6925 2 8 2C11.3075 2 14 4.6925 14 8C14 11.3075 11.3075 14 8 14ZM6.4775 6.1025C6.4775 6.65 6.905 7.0175 8.2325 7.355C9.5525 7.7 10.97 8.27 10.9775 9.92C10.97 11.1275 10.07 11.78 8.93 11.9975V13.25H7.175V11.975C6.05 11.7425 5.105 11.0225 5.03 9.7475H6.32C6.3875 10.4375 6.86 10.9775 8.06 10.9775C9.3425 10.9775 9.635 10.3325 9.635 9.935C9.635 9.395 9.3425 8.8775 7.88 8.5325C6.2525 8.1425 5.135 7.4675 5.135 6.125C5.135 4.9925 6.0425 4.2575 7.175 4.0175V2.75H8.9225V4.0325C10.1375 4.3325 10.7525 5.255 10.79 6.26H9.5075C9.4775 5.525 9.0875 5.03 8.0525 5.03C7.07 5.03 6.4775 5.4725 6.4775 6.1025Z",fill:n})})};Nh.defaultProps={color:"#696F88",size:18};var Eh=Object(a.memo)(Nh),wh=function(e){var t=e.size,n=e.color;return Object(y.jsx)("svg",{className:"mt-2px",width:t,height:t,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"list-icon",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.25 6.75H3.75V5.25H2.25V6.75ZM3.75 9.75H2.25V8.25H3.75V9.75ZM3.75 12.75H2.25V11.25H3.75V12.75ZM15.75 9.75H5.25V8.25H15.75V9.75ZM5.25 12.75H15.75V11.25H5.25V12.75ZM5.25 6.75V5.25H15.75V6.75H5.25Z",fill:n})})};wh.defaultProps={color:"#696F88",size:18};var _h=Object(a.memo)(wh),Rh=(n(1466),function(e){var t=e.showPropertyDetails,n=e.view,r=e.onChangeView,c=e.loading,i=e.buttonText,o=Object(a.useContext)(we),s=Object(a.useContext)(ac),l=Object(b.a)(s,1)[0],d=l.organization,u=l.selectedProperty,j=Object(a.useState)(null),p=Object(b.a)(j,2),v=p[0],O=p[1],h=Object(f.useFlags)(),x=h.releaseCostAnalysisViewEnable,g=h.releaseCostAnalysisViewEnableByOrg,C=yc(x,g,d.id)&&"Farm"!==(null===u||void 0===u?void 0:u.type);if(!t)return Object(y.jsx)("div",{className:"text-white w-full p-2 rounded",style:{backgroundColor:"#0071CD"},children:Object(y.jsxs)("div",{className:"flex h-auto justify-center",children:[Object(y.jsx)(Th,{color:"white"}),Object(y.jsx)("span",{className:"ml-1",children:"Map"})]})});var P=[{name:"mapView",value:Sb,icon:Th,label:"Map"},{name:"infoView",value:Tb,icon:_h,label:i}];return C&&P.push({name:"costAnalysisView",value:Nb,icon:Eh,label:"Cost Analysis"}),Object(y.jsx)(m.RadioButtonGroup,{selected:n,onChange:function(e){if(e===Nb){var t=JSON.parse(localStorage.getItem("selectedCropSeasons"))||[];o.sendEventToAmplitude(o.events.epic.Properties.viewCostAnalysis,{cropSeasonsCount:t.length})}r(e)},className:"flex w-full property-view-mode-button-group",children:P.map((function(e){var t,a=e.name,r=e.value,i=e.icon,o=e.label;return Object(y.jsx)(m.RadioButtonGroup.RadioButton,{name:a,value:r,disabled:c,children:Object(y.jsx)(pu,{className:"absolute",onMouseEnter:function(){return O(r)},onMouseLeave:function(){return O(null)},children:Object(y.jsxs)("div",{className:"flex justify-center",children:[Object(y.jsx)(i,{color:(t=r,n===t?"white":v===t?"#0092E4":"#696F88")}),Object(y.jsx)("span",{className:"ml-1",children:o})]})})},r)}))})});Rh.defaultProps={buttonText:"Details",showPropertyDetails:!0};var Ih=Rh,Dh="field",kh="farm",Lh="crop zone",Fh=function(e){return null===e||void 0===e?void 0:e.flatMap((function(e){var t=e.fields;return null===t||void 0===t?void 0:t.flatMap((function(e){return e.cropzones}))}))},Mh=function(e,t){return null===e||void 0===e?void 0:e.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{selectedCropSeason:t})}))},Vh=function(e,t){return t.reduce((function(t,n){var a=e.features.find((function(e){return e.properties.id===n})),r=e.features.find((function(e){return e.properties.id===a.properties.$parentFieldId})).properties;return a.properties.fieldName=r.name,t.push(a),t}),[])},Bh=function(e){var t=e.color,n=e.width,a=e.height,r=e.widthBox,c=e.heightBox;return Object(y.jsx)("svg",{width:n,height:a,viewBox:"0 0 ".concat(n-r," ").concat(a-c),fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"delete-icon-svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11.375 2.25H7.625L6.875 3H4.25V4.5H14.75V3H12.125L11.375 2.25ZM12.5 6.75V14.25H6.5V6.75H12.5ZM5 5.25H14V14.25C14 15.075 13.325 15.75 12.5 15.75H6.5C5.675 15.75 5 15.075 5 14.25V5.25Z",fill:"".concat(t)})})};Bh.defaultProps={color:"#CF3537",height:"18",width:"19",widthBox:0,heightBox:1};var Uh=Bh,zh=function(){var e=Object(a.useContext)(vh),t=e.state.selectedProperties,n=e.updateSelectedProperties;return Object(y.jsx)("div",{className:"h-full w-3/4","data-testid":"property-list-view",children:Object(y.jsxs)("div",{className:"flex flex-col w-full h-30 font-body",children:[Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{className:"font-body",children:[Object(y.jsxs)(m.Table.Cell,{width:"30%",children:["Fields (",t.length,")"]}),Object(y.jsx)(m.Table.Cell,{children:"Crops"}),Object(y.jsx)(m.Table.Cell,{children:"Area"}),Object(y.jsx)(m.Table.Cell,{})]}),t.map((function(e){var a=[Ej(e)];return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)(Kp,{id:"field-card-icon",features:a}),Object(y.jsxs)("div",{className:"flex flex-col justify-start leading-5 text-left ml-3",children:[Object(y.jsx)("span",{className:"font-bold text-neutral-1000",children:e.properties.fieldName}),Object(y.jsx)("span",{style:{color:"#707374"},children:e.properties.name})]})]})}),Object(y.jsx)(m.Table.Cell,{children:e.properties.crop.name}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:2,children:e.properties.reportedArea||e.properties.boundaryArea})," ","ac"]}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"flex justify-end w-full pr-5",children:Object(y.jsx)(m.Button,{type:"text",icon:Object(y.jsx)(Uh,{color:"#696F88",width:"24",height:"24",widthBox:"5",heightBox:"6"}),onClick:function(){return function(e){var a=t.filter((function(t){return t.properties.id!==e}));n(a)}(e.properties.id)}})})})]},e.properties.id)}))]}),!t.length&&Object(y.jsxs)("div",{className:"flex flex-col items-center self-stretch justify-center h-full py-32 border border-t-0","data-testid":"empty-body-table",children:[Object(y.jsx)("img",{src:Of,alt:"No properties illustration"}),Object(y.jsx)("p",{children:"Select one or more fields from the list to add it to this Plan"})]})]})})},Zh=function(e){var t=0;return e.forEach((function(e){return e.cropzones.length>0&&(t=e.cropzones.reduce((function(e,t){return e+(t.reportedArea||t.boundaryArea)}),0)),t})),"".concat(t.toFixed(2)," ac")},Yh=function(e){return e.reduce((function(e,t){return e+(t.properties.reportedArea||t.properties.boundaryArea)}),0)},Hh=function(e){return Yh(e).toFixed(2)},Gh=function(e){var t=e.property;return Object(y.jsxs)("div",{className:"p-3 border-t-2 first:border-t-0","data-testid":"selected-properties-info",children:[Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsx)("span",{className:"font-bold text-sm",children:t.fieldName}),Object(y.jsxs)("span",{className:"font-bold text-sm",children:[Object(y.jsx)(yf,{roundedTo:2,children:t.reportedArea||t.boundaryArea})," ","ac"]})]}),Object(y.jsx)("div",{children:Object(y.jsx)("span",{className:"text-sm",children:t.name})}),Object(y.jsx)("div",{children:Object(y.jsx)("span",{className:"text-sm text-gray-600",children:t.crop.name})})]})},Wh=function(e){var t=e.geoJSONCollection,n=e.zoom,r=e.setZoom,c=e.fieldsLoading,i=Object(a.useContext)(vh).state.selectedProperties;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"w-2/4 flex h-560px","data-testid":"property-map-view",children:Object(y.jsx)(mm,{fieldsLoading:c,geoJSONCollection:t,zoom:n,setZoom:r,customStyles:i.length>0,stretch:!0})}),Object(y.jsxs)("div",{className:"w-1/4 overflow-y-auto h-560px",children:[Object(y.jsxs)("div",{className:"flex flex-row justify-between pl-8 pb-6 font-semibold",children:[Object(y.jsx)("span",{children:"SELECTED PROPERTIES"}),Object(y.jsxs)("span",{children:[Hh(i)," ac"]})]}),Object(y.jsx)("div",{className:"ml-8 border-2",children:0===i.length?Object(y.jsx)(xf,{baseText:"Select the properties from the left that you would like to submit"}):i.map((function(e){return Object(y.jsx)(Gh,{property:e.properties},e.properties.id)}))})]})]})};Wh.defaultProps={geoJSONCollection:{type:"FeatureCollection",features:[]}};var qh=Wh,Jh=function(e){var t=e.view,n=e.propertyLandingPageData,a=e.fieldsAndAreasGeoJSONCollection,r=e.fieldsLoading,c=e.zoom,i=e.setZoom;return"info"===t?Object(y.jsx)(zh,{}):Object(y.jsx)(qh,{properties:n.properties,geoJSONCollection:a,fieldsLoading:r,zoom:c,setZoom:i})},Kh=Object(a.createContext)(),Qh=function(e){var t=e.children,n=Object(a.useState)(1),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(!1),s=Object(b.a)(o,2),l=s[0],d=s[1],u=function(){return d(!1)},j=function(){return d(!0)},p=4===c,f=function(){i((function(e){return Math.max(0,e-1)}))},m=function(){i((function(e){return e+1}))},v=Object(a.useMemo)((function(){return{state:{step:c,canGoNext:p||l},gotoStep:i,goBack:f,blockStepForward:u,releaseStepForward:j,goForward:m}}),[c,l,p]);return Object(y.jsx)(Kh.Provider,{value:v,children:t})};Qh.defaultProps={children:null};var Xh=Qh,$h=Object(a.createContext)(),ex=function(e){var t=e.children,n=Object(a.useState)(1),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(1),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(!0),j=Object(b.a)(u,2),p=j[0],f=j[1],m=function(){return f(!1)},v=function(){return f(!0)},O=function(){d(c),i((function(e){return Math.max(0,e-1)}))},h=function(){d(c),i((function(e){return e+1}))},x=Object(a.useMemo)((function(){return{state:{step:c,comingFromStep:l,canGoNext:p},gotoStep:i,goBack:O,blockStepForward:m,releaseStepForward:v,goForward:h}}),[c,p]);return Object(y.jsx)($h.Provider,{value:x,children:t})};ex.defaultProps={children:null};var tx=ex,nx=Object(a.createContext)(),ax=function(e){var t=e.children,n="".concat("https://qa.financials.cropwise.com","/app/integrations/Simplot"),r="44ad8ad0-5abc-43e5-be3d-0934f00631be",c=Object(a.useState)(1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=function(){s((function(e){return Math.max(0,e-1)}))},d=function(){s((function(e){return e+1}))},u="https://id.trimble.com/oauth/authorize?scope=Cropwise%20openid&client_id=".concat(r,"&response_type=code&redirect_uri=").concat(n),j=Object(a.useCallback)((function(){window.location.href="https://www.trimbleag.com/ThirdPartyAccess/ThirdPartyAuthorizationRedirect?clientid=".concat(r,"&redirectionUrl=").concat(n)}),[]),p=Object(a.useState)(!1),f=Object(b.a)(p,2),m=f[0],v=f[1],O=function(){return v(!1)},h=function(){return v(!0)};Object(a.useEffect)((function(){4===o&&v(!0)}),[o]);var x=Object(a.useMemo)((function(){return{state:{step:o,canGoNext:m},gotoStep:s,goBack:l,goForward:d,simplotOauthUrl:u,redirectToSimplotAuthorizeOrgUrl:j,blockStepForward:O,releaseStepForward:h}}),[u,j,o,m]);return Object(y.jsx)(nx.Provider,{value:x,children:t})};ax.defaultProps={children:null};var rx=ax,cx=function(e){switch(e){case KO:return nx;case QO:case XO:return Kh;case $O:return $h;default:return null}},ix=function(){var e=Object(p.i)().search;return r.a.useMemo((function(){return new URLSearchParams(e)}),[e])},ox=function(){var e=ix(),t=Object(p.h)(),n=e.get("from"),r=Object(p.j)().id,c="task"===n,i="view"===n,o=Object(a.useCallback)((function(){if(r)return r;if(c){var e=Sd(hd,null).get();return Sd(hd).remove(),c?e:null}var t=Sd(xd,null).get();return Sd(xd).remove(),i?t:null}),[c,i,r]),s=Object(a.useCallback)((function(e,n,a){Sd("selectedCropSeasons").save(JSON.stringify(e.cropSeasonsIds)),Sd(hd).save(n),t.push("".concat(Cc.integrations,"/").concat(a,"?from=task")),t.push("".concat(Cc.tasks,"/").concat(e.taskId,"?submission=").concat(n,"&vendor=").concat(a))}),[]),l=Object(a.useCallback)((function(e,n){Sd(xd).save(e),t.push("".concat(Cc.integrations,"/").concat(n,"?from=view"))}),[]);return Object(a.useMemo)((function(){return{determineSubmissionId:o,comingFromTaskEdition:c,comingFromView:i,redirectToTask:s,redirectToEdit:l,isReadOnly:!!r}}),[r,c,i,o,s,l])},sx=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onMountTriggerEvent,n=void 0===t?void 0:t,r=e.onUnMountTriggerEvent,c=void 0===r?void 0:r,i=Object(a.useContext)(we),o=Object(a.useCallback)((function(e,t){i.sendEventToAmplitude(e,null!==t&&void 0!==t?t:{})}),[i]);return Object(a.useEffect)((function(){return n&&o(n.event,n.data),function(){c&&o(c.event,c.data)}}),[]),{events:Ee,triggerAnalyticsEvent:o}},lx=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onMountTriggerEvent,n=void 0===t?void 0:t,r=e.onUnMountTriggerEvent,c=void 0===r?void 0:r,i=localStorage.getItem("selectedOrganizationId"),o=Object(a.useContext)(vh),s=o.state.submissionFlowId,l=o.updateSubmissionFlowId,d=sx(),u=d.events,b=d.triggerAnalyticsEvent,j=Object(a.useCallback)((function(e){if(e){var t,n,a=e.event,r=e.data;return a===u.epic.Integrations.submissionStarted&&(n=Object(Wu.a)(),l(n)),Object(I.a)({orgId:i,flowId:null!==(t=n)&&void 0!==t?t:s},r)}return{}}),[]),p=Object(a.useCallback)((function(e,t){b(e,j({event:e,data:t}))}),[b,j]);return Object(a.useEffect)((function(){return n&&p(n.event,n.data),function(){c&&p(c.event,c.data)}}),[]),{events:u,triggerAnalyticsEvent:p}},dx=function(e){var t=e.isLastStep,n=e.comingFromView,a=e.integrationType,r=e.nextLabel;return t?"".concat(n?"Resubmit":"Submit"," to ").concat(a):r},ux=(n(1467),function(e){var t=e.nextDisabled,n=e.onNext,r=e.nextLabel,c=e.loading,i=e.setModalSubmissionState,o=e.isLastStep,s=e.integrationType,l=e.isBottomFixed,d=Object(p.h)(),u=lx(),j=u.events,f=u.triggerAnalyticsEvent,v=Object(a.useContext)(cx(s)),O=v.state,h=O.canGoNext,x=O.step,g=v.releaseStepForward,C=v.goBack,P=ox().comingFromView,A=Object(a.useContext)(ac),S=Object(b.a)(A,1)[0].isSidebarOpen,T=function(){f(j.epic.Integrations.submissionCanceled,{vendor:s}),d.replace("".concat(Cc.integrations,"/").concat(s,"/landing-page"))};Object(a.useEffect)((function(){o&&g()}),[o,g]);var N=dx({isLastStep:o,comingFromView:P,integrationType:s,nextLabel:r});return Object(y.jsx)("div",{className:l?"fixed-footer-manipulation z-50 ".concat(S&&"sidebar-opened"):"h-24 w-full","data-testid":"submission-review-footer","data-html2canvas-ignore":!0,children:Object(y.jsxs)("div",{className:"flex flex-row border-t-2 bg-white w-auto justify-between px-4 py-6 h-auto",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:T,children:"Cancel"}),Object(y.jsxs)("div",{className:"flex flex-row gap-6",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:function(){return 1===x?T():C()},icon:Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.e}),children:"Back"}),Object(y.jsx)(m.Button,{type:"primary",disabled:c||!h||t,dataTestId:"footer-next-button",onClick:function(){o?i(!0):n&&!t&&n()},children:N})]})]})})});ux.defaultProps={nextDisabled:!1,nextLabel:"Next",loading:!1,onNext:function(){},setModalSubmissionState:function(){},isLastStep:!1,integrationType:"Integration Label",isBottomFixed:!1};var bx=ux,jx=function(e){var t=e.nextDisabled,n=e.nextLabel,a=e.onNext,r=e.loading,c=e.setModalSubmissionState,i=e.isLastStep;return Object(y.jsx)(bx,{nextDisabled:t,onNext:a,nextLabel:n,loading:r,setModalSubmissionState:c,isLastStep:i,context:$h,integrationType:"CalAgPermits"})};jx.defaultProps={nextDisabled:!1,nextLabel:"Next",loading:!1,onNext:function(){},setModalSubmissionState:function(){},isLastStep:!1};var px=jx,fx=function(e){var t=e.nextDisabled,n=e.onNext,a=e.nextLabel,r=e.setModalSubmissionState,c=e.isLastStep,i=e.integrationType,o=e.isBottomFixed;return Object(y.jsx)(bx,{nextDisabled:t,onNext:n,setModalSubmissionState:r,isLastStep:c,context:Kh,nextLabel:a,integrationType:i,isBottomFixed:o})};fx.defaultProps={nextDisabled:!1,onNext:function(){},setModalSubmissionState:function(){},isLastStep:!1,integrationType:QO,nextLabel:"Next",isBottomFixed:!1};var mx=fx,vx=n(545),Ox=n.n(vx),hx=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useRef)();return{downloadPDF:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"print.pdf",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=document.getElementById(e);a&&(r(!0),Ox()().set({pagebreak:{before:n}}).from(a).save(t).finally((function(){return r(!1)})))},downloading:n,mccainDownloadPDF:function(e,t){var n=document.getElementById(e);n&&(r(!0),Ox()().from(n).set(t).save().finally((function(){return r(!1)})))},downloadPDFV2:function(e,t){if(e&&e!==c.current){c.current=e;var n=document.createElement("a");n.href=c.current,n.download=t,document.body.appendChild(n),n.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window})),document.body.removeChild(n)}},setDownloading:r}},xx=function(){return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"14",viewBox:"0 0 12 14",fill:"none",className:"fill-current w-3 h-3 mr-2",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.25 0.625H3.75V5.125H0.75L6 10.375L11.25 5.125H8.25V0.625ZM6.75006 2.125V6.625H7.62756L6.00006 8.2525L4.37256 6.625H5.25006V2.125H6.75006ZM0.75 13.375V11.875H11.25V13.375H0.75Z",fill:"#14803C"})})},gx={filename:"McCain_Export_".concat((new Date).toJSON().slice(0,10).replace(/-/g,"_")),jsPDF:{unit:"in",format:"a4",orientation:"landscape"}},Cx=function(e){var t=e.MCCAIN_PDF_WRAPPER,n=e.nextButtonDisabled,r=e.onNextValidation,c=e.onNext,i=e.onBack,o=lx(),s=o.events,l=o.triggerAnalyticsEvent,d=Object(Zi.h)().values,u=Object(p.h)(),b=Object(a.useContext)(vh),j=b.goForward,f=b.goBack,v=b.setModalSubmissionState,O=b.state.step,h=hx().mccainDownloadPDF,x=function(){r()&&(c(),j())},g=function(){i(),f()},C=function(){l(s.epic.Integrations.submissionCanceled,{vendor:JO}),u.goBack()};return function(){var e;switch(O){case 1:return Object(y.jsxs)("div",{className:"flex flex-row border-t-2 justify-between pt-4 ","data-testid":"mccain-crop-season-footer",id:"mccain-footer",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:C,children:"Cancel"}),Object(y.jsx)(m.Button,{type:"primary",onClick:function(){l(s.epic.Integrations.submissionSeasonSelected,{vendor:JO}),x()},ghost:!0,disabled:!(null!==d&&void 0!==d&&null!==(e=d.selectedCropSeasons)&&void 0!==e&&e.length)>0||!d.cropSeasonStartDate||!d.cropSeasonEndDate,children:"Next: Select Properties"})]});case 2:return Object(y.jsxs)("div",{className:"flex flex-row border-t-2 bg-white w-auto justify-between px-4 py-6 h-auto","data-testid":"mccain-properties-footer",id:"mccain-footer",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:C,children:"Cancel"}),Object(y.jsxs)("div",{className:"flex flex-row gap-6",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:g,icon:Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.e}),children:"Back"}),Object(y.jsx)(m.Button,{type:"primary",ghost:!0,onClick:function(){l(s.epic.Integrations.submissionPropertiesSelected,{vendor:JO}),x()},disabled:n,children:"Next: Review & Submit"})]})]});case 3:return Object(y.jsx)("div",{className:"w-full h-24 bg-black","data-testid":"mccain-review-footer",id:"mccain-footer","data-html2canvas-ignore":!0,children:Object(y.jsxs)("div",{className:"flex flex-row border-t-2 bg-white w-auto justify-between px-4 py-6 h-auto",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:C,children:"Cancel"}),Object(y.jsxs)("div",{className:"flex flex-row gap-6",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:g,icon:Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.e}),children:"Back"}),Object(y.jsx)(m.Button,{id:"save-button",type:"primary",ghost:!0,icon:Object(y.jsx)(xx,{}),onClick:function(){h(t,gx)},children:"Save as PDF"}),Object(y.jsx)(m.Button,{type:"primary",onClick:function(){v(!0)},children:"Submit to McCain"})]})]})});default:return null}}()};Cx.defaultProps={nextButtonDisabled:!0,onNext:function(){},onBack:function(){},MCCAIN_PDF_WRAPPER:"",onNextValidation:function(){return!0}};var yx=Cx,Px=function(e){var t=e.nextDisabled,n=e.onNext,a=e.setModalSubmissionState,r=e.isLastStep;return Object(y.jsx)(bx,{nextDisabled:t,onNext:n,setModalSubmissionState:a,isLastStep:r,context:nx,integrationType:"Simplot"})};Px.defaultProps={onNext:function(){},setModalSubmissionState:function(){},isLastStep:!1,nextDisabled:!1};var Ax=Px,Sx=function(e){return null===e||void 0===e?void 0:e.map((function(e){return null===e||void 0===e?void 0:e.startDateEpoch})).reduce((function(e,t){return!e||t<e?t:e}),null)},Tx=function(e){return null===e||void 0===e?void 0:e.map((function(e){return null===e||void 0===e?void 0:e.endDateEpoch})).reduce((function(e,t){return!e||t>e?t:e}),null)},Nx="selectedOrganization",Ex="selectedCropSeasons",wx="seasonSingleDateRangeInitial",_x="selectedProperties",Rx="selectedRecommendations",Ix=function(){var e=Object(Zi.h)(),t=e.values,n=e.setFieldValue,r=Object(a.useState)([]),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useContext)(vh),l=s.updateSelectedProperties,d=s.state.selectedProperties,u=rv({fetchType:gm}),j=u.reloadData,p=u.setGeoJSONCollectionFeatures,f=u.filterFeatureCollectionByParentId,m=u.fieldsAndAreasGeoJSONCollection,v=dd().cropSeasons,O=function(e){n(Nx,e)},h=function(e){n(_x,e)},x=function(e){n(wx,e.map((function(e){return"number"===typeof e?new Date(e):function(e){var t=new Date(e);return t.setMinutes(t.getMinutes()+t.getTimezoneOffset())}(e)})))},g=function(e){var t=Sx(e),a=Tx(e);n(Ex,e),n("cropSeasonsMinDate",t),n("cropSeasonsMaxDate",a)},C=function(e){n(Rx,e)},y=function(e){var n,a=null===(n=t.selectedRecommendations)||void 0===n?void 0:n.map((function(t){return Object(I.a)(Object(I.a)({},t),{},{fields:t.fields.map((function(t){return Object(I.a)(Object(I.a)({},t),{},{hide:t.id===e?!t.hide:t.hide})}))})}));C(a)},P=function(e,t,n,a,r){O(e),g(t),h(n),o(a),r&&x(r)};return Object(a.useEffect)((function(){var e,n=t.selectedCropSeasons;null===v||void 0===v||!v.length||null===n||void 0===n||!n.length||null!==n&&void 0!==n&&null!==(e=n[0])&&void 0!==e&&e.startDateEpoch||g(null===v||void 0===v?void 0:v.filter((function(e){return n.find((function(t){return e.id===(null===t||void 0===t?void 0:t.id)}))})))}),[v,t.selectedCropSeasons]),Object(a.useEffect)((function(){var e,n;null!==i&&void 0!==i&&i.length&&null!==(e=t.selectedCropSeasons)&&void 0!==e&&e.length&&j({seasonIds:null===(n=t.selectedCropSeasons)||void 0===n?void 0:n.map((function(e){return null===e||void 0===e?void 0:e.id}))})}),[i,t.selectedCropSeasons]),Object(a.useEffect)((function(){var e;if(null!==i&&void 0!==i&&i.length&&null!==m&&void 0!==m&&null!==(e=m.features)&&void 0!==e&&e.length&&!d.length){p(f(m,void 0,i));var t=Vh(m,i);l(t)}}),[m.features,i,d]),Object(a.useMemo)((function(){return{setSelectedOrganization:O,setSelectedCropSeasons:g,setSelectedProperties:h,setAllDataFromSubmission:P,setSelectedCropSeasonsDateRangeInitial:x,setSelectedRecommendations:C,setFieldHiddenInRecommendations:y,selectedOrganization:t.selectedOrganization,selectedCropSeasons:t.selectedCropSeasons,selectedProperties:t.selectedProperties,selectedRecommendations:t.selectedRecommendations,selectedCropSeasonsDateRange:t.seasonSingleDateRange,selectedCropSeasonsDateRangeInitial:t.seasonSingleDateRangeInitial}}),[t])},Dx=function(e){var t=e.integrationName,n=e.propertyLandingPageData,r=Ix().setSelectedProperties,c=Object(a.useContext)(vh),i=c.state.selectedProperties,o=c.updateSelectedProperties,s=function(){var e=i.reduce((function(e,t){var a=n.properties.find((function(e){return e.id===t.properties.propertyId})),r=a.fields.find((function(e){return e.id===t.properties.$parentFieldId})),c=r.cropzones.find((function(e){return e.id===t.properties.id})),i=e.findIndex((function(e){return e.id===a.id}));if(i>=0){var o=e[i].fields.findIndex((function(e){return e.id===r.id}));o>=0?e[i].fields[o].cropzones.push(c):e[i].fields.push({id:r.id,name:r.name,boundaryArea:r.boundaryArea,geometry:r.geometry,cropzones:[c]})}else e.push({id:a.id,name:a.name,fields:[{id:r.id,name:r.name,geometry:r.geometry,boundaryArea:r.boundaryArea,cropzones:[c]}]});return e}),[]);r(e)},l=function(){o([]),r([])};return function(){switch(t){case JO:return Object(y.jsx)(yx,{nextButtonDisabled:0===i.length,onNext:s,onBack:l});case KO:return Object(y.jsx)(Ax,{isLastStep:!1,nextDisabled:0===i.length,onNext:s,onBack:l});case QO:return Object(y.jsx)(mx,{isLastStep:!1,nextDisabled:0===i.length,onNext:s,onBack:l});case $O:return Object(y.jsx)(px,{isLastStep:!1,nextDisabled:0===i.length,onNext:s,onBack:l});default:return Object(y.jsx)(y.Fragment,{})}}()},kx=n(174),Lx=n.n(kx),Fx=(n(312),n(1470),n(2810)),Mx=n(2811),Vx=n(2812),Bx=n(2813),Ux=n(2814),zx=function(e){var t=e.data,n=e.value,r=e.enableFilter,c=e.onChange,i=e.disabled,o=e.cropZonesChecked,s=e.setCropZonesChecked,l=Object(a.useState)(n),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)([]),f=Object(b.a)(p,2),O=f[0],h=f[1],x=Object(a.useState)(),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)([]),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(T),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)([]),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)(null),V=Object(b.a)(M,2),B=V[0],U=V[1],z=Object(a.useState)([]),Z=Object(b.a)(z,2),Y=Z[0],H=Z[1],G=Object(a.useState)(),W=Object(b.a)(G,2),q=W[0],J=W[1],K=[],Q=[];Object(a.useEffect)((function(){var e;(null===(e=Q=null===t||void 0===t?void 0:t.map((function(e){var t;return Object(I.a)({value:e.id,className:e.archived?"opacity-50":"",label:e.name+(e.archived?" (archived)":""),type:"farm",disabled:0===iv(e.selectedCropSeason,e.fields)},e.fields.length>0?{children:null===(t=e.fields)||void 0===t?void 0:t.map((function(t){var n;return Object(I.a)({className:t.archived&&!e.archived?"opacity-50":"",value:t.id,label:t.name+(t.archived?" (archived)":""),type:"field",disabled:0===cv(e.selectedCropSeason,t.cropzones)},t.cropzones.length>0?{children:null===(n=t.cropzones)||void 0===n?void 0:n.map((function(n){return{value:n.id,className:n.archived&&!t.archived?"opacity-50":"",label:n.name+(n.archived?" (archived)":""),farmId:e.id,type:"cropzone",disabled:0===Ud(e.selectedCropSeason,n.cropSeasons)}}))}:{})}))}:{})})))||void 0===e?void 0:e.length)>0&&(K=function(e,t){var n=Object(v.a)(t);return(null===e||void 0===e?void 0:e.length)>0&&e.forEach((function(e){var t;(null===e||void 0===e||null===(t=e.children)||void 0===t?void 0:t.length)>0&&!1===(null===e||void 0===e?void 0:e.disabled)&&e.children.forEach((function(e){var t;(null===e||void 0===e||null===(t=e.children)||void 0===t?void 0:t.length)>0&&!1===(null===e||void 0===e?void 0:e.disabled)&&e.children.forEach((function(e){!1===(null===e||void 0===e?void 0:e.disabled)&&n.push(e.value)}))}))})),n}(Q,K),F(K),N(Q))}),[t]);var X=function(e){(null===n||void 0===n?void 0:n.length)>0||(null===e||void 0===e?void 0:e.length)>0?((null===e||void 0===e?void 0:e.length)===K.length&&B&&U(!0),(null===e||void 0===e?void 0:e.length)<K.length&&U(null)):U(null)},$=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;X(e),s(e),j(e);var n=ov(T.length?T:Q,e);c(e,n,t)};Object(a.useEffect)((function(){$(o),H(o)}),[o]);var ee=Object(a.useCallback)((function(e,t){var n=(t.children||[]).reduce(ee,[]);return(t.label.toLocaleLowerCase().indexOf(null===C||void 0===C?void 0:C.toLocaleLowerCase())>-1||n.length)&&e.push(Object(I.a)(Object(I.a)({},t),{},{children:n})),e}),[C]);Object(a.useEffect)((function(){if(C){R((function(e){return e.reduce(ee,[])}))}else R(T)}),[C,ee,T]),Object(a.useEffect)((function(){Object(ne.isEqual)(K,o)?U(!0):s(K),$(!0===B?L:!1===B?[]:o)}),[U,B]),Object(a.useEffect)((function(){J(Y.length===L.length&&Y.length>0)}),[L,Y]);return Object(y.jsxs)("div",{className:"filter-container","data-testid":"cropseason-group-by-property",children:[Object(y.jsx)("div",{className:"mt-2",children:Object(y.jsx)(m.Checkbox,{label:"Select All",onChange:function(){U(null===B||!B)},checked:q,color:"#0071cd"})}),r&&Object(y.jsx)("div",{className:"mb-2",children:Object(y.jsx)(m.Input,{className:" filter-text",placeholder:"Search...",type:"text",value:C,onChange:function(e){P(e.target.value)}})}),Object(y.jsx)(Lx.a,{nodes:_,checked:u,showNodeIcon:!1,icons:{halfCheck:Object(y.jsx)(Fx.a,{fontSize:"small"}),uncheck:Object(y.jsx)(Mx.a,{fontSize:"small",className:"text-neutral-600"}),check:Object(y.jsx)(Vx.a,{fontSize:"small"}),expandClose:Object(y.jsx)(Bx.a,{fontSize:"small",className:"text-neutral-600"}),expandOpen:Object(y.jsx)(Ux.a,{fontSize:"small",className:"text-neutral-600"})},expanded:O,onCheck:function(e,t){return $(e,t)},onExpand:function(e){return h(e)},showNodeTitle:!0,optimisticToggle:!1,disabled:i})]})};zx.defaultProps={onChange:function(){},enableFilter:!1,disabled:!1,value:[],cropZonesChecked:[],setCropZonesChecked:function(){}};var Zx=zx,Yx=(n(1471),function(e){var t=e.data,n=e.value,r=e.onChange,c=e.disabled,i=e.cropZonesChecked,o=e.setCropZonesChecked,s=Object(a.useState)(n),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)([]),p=Object(b.a)(j,2),f=p[0],m=p[1],v=Object(a.useState)([]),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)([]),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)([]),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)([]),_=Object(b.a)(w,2),R=_[0],D=_[1],k=function(e,t){var n=1;if(e&&(n=0,null===t||void 0===t||t.children.forEach((function(t){n+=function(e,t){var n=1;if(e&&(n=0,null===t||void 0===t||t.cropzones.forEach((function(t){n+=Ud(e,t.cropSeasons)}))),n>0){var a=R;a.push(t.fieldId),D(a)}return n}(e,t)}))),n>0){var a=N;a.push(t.farmId),E(a)}return n},L=[];Object(a.useEffect)((function(){var e,n=ae.a.flatMap(t,(function(e){var t=e.fields,n=e.id,a=e.name,r=e.selectedCropSeason;return ae.a.map(t,(function(e){return ae.a.map(e.cropzones,(function(t){return{farms:{farmName:a,farmId:n,field:{fieldName:e.name,fieldId:e.id,farmId:n,cropzones:e.cropzones}},crpId:t.crop.id,crpName:t.crop.name,selectedCropSeason:r}}))}))})),a=ae.a.flatMap(n),r=ae.a.chain(ae.a.flatMap(a)).groupBy("crpName").map((function(e,t){return{name:t,crpId:e[0].crpId,children:e.map((function(e){return e.farms})),selectedCropSeason:e[0].selectedCropSeason}})).value(),c=ae.a.map(r,(function(e){return{crpId:e.crpId,crpName:e.name,children:ae()(e.children).groupBy("farmName").map((function(e,t){return{farmName:t,farmId:e[0].farmId,children:ae.a.map(e.map((function(e){return e.field})))}})).value(),selectedCropSeason:e.selectedCropSeason}})),i=ae.a.map(c,(function(e){return{crpId:e.crpId,crpName:e.crpName,children:ae()(e.children).map((function(e){return{farmName:e.farmName,farmId:e.farmId,children:e.children.filter((function(t,n){return e.children.findIndex((function(e){return t.fieldId===e.fieldId}))===n}))}})).value(),selectedCropSeason:e.selectedCropSeason}}));i.forEach((function(e){!function(e,t){var n=1;if(e&&(n=0,null===t||void 0===t||t.children.forEach((function(t){n+=k(e,t)}))),n>0){var a=P;a.push(t.crpId),A(a)}}(e.selectedCropSeason,e)}));var o=function(e){return(null===e||void 0===e?void 0:e.length)>0};(null===(e=L=null===i||void 0===i?void 0:i.map((function(e,t){var n,a;return Object(I.a)({value:e.crpId,label:e.crpName,type:"crop",disabled:e.selectedCropSeason?!P.includes(e.crpId):!o(e.children)},(null===e||void 0===e||null===(n=e.children)||void 0===n?void 0:n.length)>0?{children:null===e||void 0===e||null===(a=e.children)||void 0===a?void 0:a.map((function(n,a){var r,c;return Object(I.a)({value:"".concat(null===n||void 0===n?void 0:n.farmId,"_").concat(t,"_").concat(a),label:n.farmName,farmId:n.farmId,type:"farm",disabled:e.selectedCropSeason?!N.includes(n.farmId):!o(n.children)},(null===n||void 0===n||null===(r=n.children)||void 0===r?void 0:r.length)>0?{children:null===n||void 0===n||null===(c=n.children)||void 0===c?void 0:c.map((function(a){var r,c;return Object(I.a)({value:"".concat(null===a||void 0===a?void 0:a.fieldId,"_").concat(t),label:null===a||void 0===a?void 0:a.fieldName,farmId:n.farmId,type:"field",disabled:e.selectedCropSeason?!R.includes(a.fieldId):!o(null===a||void 0===a?void 0:a.cropzones)},(null===a||void 0===a||null===(r=a.cropzones)||void 0===r?void 0:r.length)>0?{children:null===a||void 0===a||null===(c=a.cropzones)||void 0===c?void 0:c.filter((function(t){return t.crop.id===e.crpId})).map((function(t){return{value:t.id,label:t.name,farmId:n.farmId,type:"cropzone",disabled:0===Ud(e.selectedCropSeason,t.cropSeasons)}}))}:{})}))}:{})}))}:{})})))||void 0===e?void 0:e.length)>0&&x(L)}),[t]),Object(a.useEffect)((function(){}),[h]);var F=function(e){var t=function e(t){return t.flatMap((function(t){var n;return(null===(n=t.children)||void 0===n?void 0:n.length)>0?e(t.children):t}))},n=[];return null===e||void 0===e||e.map((function(e){return(h.length>0?t(h):t(L)).find((function(t){return t.value.split("_").shift()!==e||n.includes(t.farmId)||n.push(t.farmId),!1}))})),n},M=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n,a,c=arguments;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=c.length>0&&void 0!==c[0]?c[0]:[],n=c.length>1?c[1]:void 0,o(t),u(t),a=F(t),r(t,a,n);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){M(i)}),[i]),Object(y.jsx)("div",{className:"filter-container","data-testid":"cropseason-group-by-crop",children:Object(y.jsx)(Lx.a,{nodes:h,checked:d,showNodeIcon:!1,icons:{halfCheck:Object(y.jsx)(Fx.a,{fontSize:"small"}),uncheck:Object(y.jsx)(Mx.a,{fontSize:"small",className:"text-neutral-600"}),check:Object(y.jsx)(Vx.a,{fontSize:"small"}),expandClose:Object(y.jsx)(Bx.a,{fontSize:"small",className:"text-neutral-600"}),expandOpen:Object(y.jsx)(Ux.a,{fontSize:"small",className:"text-neutral-600"})},expanded:f,onCheck:function(e,t){return M(e,t)},onExpand:function(e){return m(e)},showNodeTitle:!0,disabled:c})})});Yx.defaultProps={onChange:function(){},disabled:!1,value:[],setCropZonesChecked:function(){}};var Hx=Yx,Gx=function(e){var t=e.properties,n=e.cropZonesChecked,r=e.setCropZonesChecked,c=e.fieldsAndAreasGeoJSONCollection,i=e.setGeoJSONCollectionFeatures,o=e.filterFeatureCollectionByParentId,s=Object(a.useContext)(vh),l=s.state,d=l.propertiesGroupedBy,u=l.selectedProperties,b=s.updateSelectedProperties,j=function(e){if(c.features&&e.length!==u.length){i(o(c,void 0,e.map((function(e){return{id:e}}))));var t=Vh(c,e);b(t)}};return"property"===d?Object(y.jsx)("div",{className:"pt-2 overflow-auto h-480px",children:Object(y.jsx)(Zx,{data:t,cropZonesChecked:n,setCropZonesChecked:r,onChange:j})}):Object(y.jsx)("div",{className:"pt-4 overflow-auto h-480px",children:Object(y.jsx)(Hx,{data:t,cropZonesChecked:n,setCropZonesChecked:r,onChange:j})})},Wx=function(e){var t=e.integrationName,n=Object(a.useState)("map"),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)([]),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)([]),j=Object(b.a)(u,2),p=j[0],f=j[1],v=Object(a.useContext)(ac)[1],O=Ix().selectedCropSeasons,h=Object(a.useContext)(vh),x=h.state,g=x.propertiesGroupedBy,C=x.selectedProperties,P=h.dispatch,A=rv({fetchType:gm}),S=A.loading,T=A.zoom,N=A.setZoom,E=A.dataSorted,w=A.fieldsAndAreasGeoJSONCollection,_=A.setGeoJSONCollectionFeatures,R=A.fieldsLoading,I=A.filterFeatureCollectionByParentId,D=A.reloadData,k=Object(a.useRef)(O.map((function(e){return e.id})));Object(a.useEffect)((function(){D({seasonIds:k.current})}),[]),Object(a.useEffect)((function(){if(E.properties){var e=Mh(E.properties,k.current);d(e)}}),[E.properties]);return Object(a.useEffect)((function(){return v({type:Pr,payload:C}),_(I(w,void 0,C.map((function(e){return e.properties})))),function(){v({type:Pr,payload:[]})}}),[C]),Object(a.useEffect)((function(){var e=C.map((function(e){return e.properties.id}));f(e)}),[C]),S||R?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{className:"w-full bg-white px-6 rounded-xl","data-testid":"property-integration",children:[Object(y.jsx)("div",{className:"flex flex-row w-full justify-end py-4 mb-2",id:"integration-property-toolbar",children:Object(y.jsxs)("div",{className:"flex flex-row w-full items-center py-4 h-10/100 justify-between mb-2",id:"integration-property-toolbar",children:[Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-xl leading-7 font-semibold text-neutral-1000 mb-2",children:"Select Properties"}),Object(y.jsx)("p",{className:"text-base leading-6 text-neutral-70",children:"Select properties based on your selected crop seasons and time period"})]}),Object(y.jsx)(Ih,{loading:!1,onChangeView:i,view:c,buttonText:"List"})]})}),Object(y.jsxs)("div",{className:"flex flex-row w-full h-auto pb-6",children:[Object(y.jsxs)("div",{className:"h-full w-1/4 pr-5",children:[Object(y.jsx)(m.Select,{items:[{key:"property",value:"Group By Property"},{key:"crop",value:"Group By Crop"}],onChange:function(e){!function(e){var t=JSON.parse(e.target.value);P({type:sh,payload:t.key})}(e)},value:g}),Object(y.jsxs)("div",{className:" mt-6",children:[Object(y.jsx)("div",{children:Object(y.jsx)("h1",{className:"font-semibold",children:"PROPERTIES"})}),Object(y.jsx)("div",{children:Object(y.jsx)(Gx,{properties:l,cropZonesChecked:p,setCropZonesChecked:f,setGeoJSONCollectionFeatures:_,fieldsAndAreasGeoJSONCollection:w,fieldsLoading:R,filterFeatureCollectionByParentId:I})})]})]}),Object(y.jsx)(Jh,{view:c,propertyLandingPageData:E,fieldsAndAreasGeoJSONCollection:w,fieldsLoading:R,zoom:T,setZoom:N})]}),Object(y.jsx)(Dx,{integrationName:t,propertyLandingPageData:E})]})},qx=function(){var e=lx({onMountTriggerEvent:{event:Ee.epic.Integrations.submissionStarted,data:{vendor:JO}}}).triggerAnalyticsEvent,t=Object(Zi.h)().setFieldValue,n=Object(a.useContext)(vh),r=n.state.submissionFlowId,c=n.goForward,i=Object(a.useState)(""),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(!0),u=Object(b.a)(d,2),j=u[0],f=u[1],v=Object(p.h)(),O=Object(a.useCallback)((function(){e(Ee.epic.Integrations.submissionCredentialsFilled,{vendor:JO,flowId:r}),c()}),[r,c]);return Object(a.useEffect)((function(){7===s.length?f((function(e){return!e})):f(!0)}),[s]),Object(y.jsxs)("div",{className:"h-full p-4 bg-white rounded-xl","data-testid":"mccain-authentication",children:[Object(y.jsx)("div",{className:"w-full flex pl-4 mt-2",children:Object(y.jsx)(m.Button,{type:"outline","data-testid":"mccain-authentication-back-button",className:"absolute",onClick:function(){e(Ee.epic.Integrations.submissionCanceled,{vendor:JO,flowId:r}),v.goBack()},children:"< Back"})}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"w-1/2",children:Object(y.jsx)("div",{className:"w-full filler-image-integration h-full"})}),Object(y.jsxs)("div",{className:"w-1/2 py-7 rounded-xl",children:[Object(y.jsxs)("div",{className:"flex flex-row gap-x-3",children:[Object(y.jsx)(Qi,{control:m.Input,name:"mccainVendorId",id:"mccainVendorId",label:"McCain Vendor ID *",placeholder:"Enter Vendor ID Number",onChange:function(e){t("mccainVendorId",e.target.value),l(e.target.value)},imask:{mask:"num",blocks:{num:{mask:Number,scale:0}}}}),Object(y.jsx)(m.Button,{onClick:O,disabled:j,type:"primary",children:"Start New Submission"})]}),Object(y.jsxs)("p",{className:"mt-6 pr-6 font-normal font-body text-sm leading-6 color-600",children:["Please be aware, that you are submitting data to a \u201cthird-party\u201d,\n            McCain Foods. Syngenta Digital IS NOT responsible for the accuracy\n            of the data submitted and encourages users to verify the accuracy of\n            the data using the recipient\u2019s interface. The user is responsible\n            for the contents of data transmitted. Grower acknowledges that any\n            data released to a third party at Grower's request is subject to the\n            terms of the recipient\u2019s privacy policy. Grower assumes all risk for\n            third party use of data.\n            ",Object(y.jsx)("br",{}),Object(y.jsx)("br",{}),"The user shall:",Object(y.jsx)("br",{}),Object(y.jsx)("br",{}),"(a) obtain and pay for all equipment and third-party services (e.g., Internet access, phone service, SMS, user credentials and subscriptions to webservices) required for you to access and use the webservices;",Object(y.jsx)("br",{}),Object(y.jsx)("br",{}),"(b) maintain the security of your user credentials and other confidential information relating to your account; and",Object(y.jsx)("br",{}),Object(y.jsx)("br",{}),"(c) be responsible for all submissions resulting from the use of your webservices account, including potential unauthorized use prior to your notifying Syngenta Digital of such use and Syngenta Digital taking steps to prevent its further occurrence."]})]})]})]})},Jx=n(175),Kx=n.n(Jx),Qx=n(278),Xx=n.n(Qx),$x=n(277),eg=n.n($x),tg=function(e){var t,n,r,c,i,o,s=e.onSelect,l=e.allCropSeasonsData,d=e.csLoaded,u=e.selectedActive,j=e.isRequired,p=Object(Zi.h)().values,f=Object(a.useState)({active:[],upcoming:[],past:[]}),O=Object(b.a)(f,2),h=O[0],x=O[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(!0),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)(p.selectedCropSeasons?null===p||void 0===p||null===(t=p.selectedCropSeasons)||void 0===t?void 0:t.map((function(e){return null!==e&&void 0!==e&&e.active?e.id:null})):[]),_=Object(b.a)(w,2),R=_[0],D=_[1],k=Object(a.useState)(p.selectedCropSeasons&&!1===(null===p||void 0===p||null===(n=p.selectedCropSeasons)||void 0===n||null===(r=n[0])||void 0===r?void 0:r.active)?null===p||void 0===p||null===(c=p.selectedCropSeasons)||void 0===c||null===(i=c[0])||void 0===i?void 0:i.id:null),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Object(a.useState)((null===p||void 0===p?void 0:p.selectedCropSeasons)||[]),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=Object(a.useState)(0),Y=Object(b.a)(Z,2),H=Y[0],G=Y[1];Object(a.useEffect)((function(){if(d&&l.length>0){var e=(new Date).getTime(),t={active:[],upcoming:[],past:[]};l.forEach((function(n){e>n.startDateEpoch?e>n.endDateEpoch?t.past.push(n):t.active.push(n):t.upcoming.push(n)})),x(Object(I.a)({},t))}}),[d,l]),Object(a.useEffect)((function(){s(U)}),[U]),Object(a.useEffect)((function(){var e=[];if(d&&l.length>0&&R.length>0){var t=l.filter((function(e){return R.includes(e.id)}));e.push.apply(e,Object(v.a)(t))}if(d&&l.length>0&&null!==F&&0===e.length){var n=l.find((function(e){return e.id===F}));e.push(n)}N&&e.length&&(s(e),E(!1)),z(e)}),[R,F,l,d]),Object(a.useEffect)((function(){u&&h.active.length&&(z(h.active),D(h.active.map((function(e){return null===e||void 0===e?void 0:e.id}))))}),[h]),Object(a.useEffect)((function(){P||s(U)}),[P]);var W=function(){var e=function(e){var t=[];return e.forEach((function(e){var n=document.createElement("span");n.textContent=null===e||void 0===e?void 0:e.name,n.style.fontFamily="Arial",n.style.fontSize="0.75rem",n.style.padding="6px",document.body.appendChild(n),t.push(n.offsetWidth),document.body.removeChild(n)})),t}(U),t=document.getElementById("dropDown").offsetWidth-200,n=0,a=0;e.every((function(e){return(n+=Number(e))<t?(a+=1,!0):(a-=1,!1)})),G(U.slice(a))};Object(a.useEffect)((function(){W()}),[U]);var q=Object(y.jsx)("div",{"data-testid":"crop-season-trigger-box",className:"w-full",role:"button",tabIndex:0,onClick:function(){A(!P)},onKeyDown:function(e){return"Enter"===e.nativeEvent.key&&A(!P)},children:Object(y.jsxs)("div",{className:"pb-2 w-full",children:[Object(y.jsx)("div",{id:"dropDown",className:"text-neutral-600 text-left mb-1 text-sm","data-testid":"crop-season-heading",children:j?"Crop Season(s)*":"Crop Season(s)"}),Object(y.jsxs)("div",{className:"flex flex-wrap justify-between border border-neutral-30 rounded h-10","data-testid":"crop-season-select",children:[Object(y.jsxs)("div",{className:"flex",children:[d?null===(o=U.slice(H.length))||void 0===o?void 0:o.map((function(e){return Object(y.jsxs)("div",{"data-testid":"crop-season-name",className:"flex flex-no-wrap bg-gray-100 rounded mx-1 my-2 justify-start",children:[Object(y.jsx)("div",{className:"whitespace-nowrap p-1 text-xs text-neutral-600 font-semibold","data-testid":"crop-season-name",children:null===e||void 0===e?void 0:e.name}),Object(y.jsx)("button",{type:"button","data-testid":"remove-crop-season-button",onClick:function(){return t=null===e||void 0===e?void 0:e.id,void(!0===(null===e||void 0===e?void 0:e.active)?D(null===R||void 0===R?void 0:R.filter((function(e){return e!==t}))):M(null));var t},children:Object(y.jsx)(Kx.a,{style:{fontSize:12,marginBottom:"3px",marginRight:"2px",color:"#696F88"}})})]},null===e||void 0===e?void 0:e.id)})):Object(y.jsx)(m.Spinner,{}),H.length>0?Object(y.jsx)("div",{className:"flex flex-no-wrap mx-1 my-2 justify-start",children:Object(y.jsx)("span",{className:"whitespace-nowrap p-1 text-xs text-neutral-600 font-semibold",children:"+ ".concat(H.length," more season(s)")})}):null]}),Object(y.jsx)("div",{className:R.length<1||null===F?"flex justify-end":"",children:P?Object(y.jsx)(eg.a,{style:{color:"#696F88",marginTop:"8px",marginRight:"4px",marginLeft:"6px"}}):Object(y.jsx)(Xx.a,{style:{color:"#696F88",marginTop:"8px",marginRight:"4px",marginLeft:"6px"}})})]})]})});return Object(y.jsx)(m.Popup,{trigger:q,position:"bottom",align:"left",hasOffset:!0,open:P,onClose:function(){return A(!1)},containerClasses:"w-full",children:Object(y.jsx)("div",{"data-testid":"crop-season-popup",className:"w-92 h-full text-left",children:d?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"font-semibold text-sm mb-2 ml-2",children:"Crop Seasons"}),Object(y.jsx)("div",{className:"font-normal text-xs mb-2 ml-2 text-neutral-600",children:"Active Seasons"}),Object(y.jsx)("ul",{className:"mb-2  ml-2",children:0===h.active.length?Object(y.jsx)("div",{className:"font-normal text-sm ml-4",children:"No Active Seasons"}):h.active.map((function(e){return Object(y.jsx)(m.Checkbox,{label:e.name,value:e.id,checked:R.includes(e.id),onChange:function(e){F&&M(null),e.target.checked?D([].concat(Object(v.a)(R),[e.target.value])):D(R.filter((function(t){return t!==e.target.value})))}},e.id)}))}),Object(y.jsx)("div",{className:"font-normal text-xs ml-2 mb-2 text-neutral-600",children:"Upcoming Seasons"}),Object(y.jsx)("ul",{className:"mb-2 ml-2",children:0===h.upcoming.length?Object(y.jsx)("div",{className:"font-normal text-sm ml-4",children:"No Upcoming Seasons"}):h.upcoming.map((function(e){return Object(y.jsx)(m.Radio,{label:null===e||void 0===e?void 0:e.name,value:null===e||void 0===e?void 0:e.id,checked:F===(null===e||void 0===e?void 0:e.id),onChange:function(e){R&&D([]),M(e.target.value)}},null===e||void 0===e?void 0:e.id)}))}),Object(y.jsx)("div",{className:"font-normal text-xs ml-2 mb-2 text-neutral-600",children:"Past Seasons"}),Object(y.jsx)("ul",{className:"mb-2 ml-2",children:0===h.past.length?Object(y.jsx)("div",{className:"font-normal text-sm ml-4",children:"No Past Seasons"}):h.past.map((function(e){return Object(y.jsx)(m.Radio,{label:null===e||void 0===e?void 0:e.name,value:null===e||void 0===e?void 0:e.id,checked:F===(null===e||void 0===e?void 0:e.id),onChange:function(e){R&&D([]),M(e.target.value)}},null===e||void 0===e?void 0:e.id)}))})]}):Object(y.jsx)(m.Spinner,{})})})};tg.defaultProps={allCropSeasonsData:[{}]};var ng=tg,ag=function(e){var t,n,a;return"number"===typeof e?null===(n=new Date(e))||void 0===n||null===(a=n.toISOString().split("T"))||void 0===a?void 0:a[0]:null===e||void 0===e||null===(t=e.toISOString().split("T"))||void 0===t?void 0:t[0]},rg=function(e){var t;return new Date("".concat(null===e||void 0===e||null===(t=e.split("T"))||void 0===t?void 0:t[0],":00:00"))},cg=function(e){if(null===e||void 0===e||!e.length)return{};var t=null===e||void 0===e?void 0:e.map((function(e){return{startDate:rg(null===e||void 0===e?void 0:e.startDate),endDate:rg(null===e||void 0===e?void 0:e.endDate)}})),n=t.sort((function(e,t){return e.startDate.getTime()-t.startDate.getTime()})),a=Object(v.a)(t).sort((function(e,t){return t.endDate.getTime()-e.endDate.getTime()}));return{startDate:Object(b.a)(n,1)[0].startDate,endDate:Object(b.a)(a,1)[0].endDate}},ig=function(e){var t,n,r=e.className,c=e.isRequired,i=Object(Zi.h)(),o=i.values,s=i.setFieldValue,l=Object(a.useMemo)((function(){var e=cg(o.selectedCropSeasons);return{startDate:e.startDate,endDate:e.endDate}}),[o.selectedCropSeasons]),d=l.startDate,u=l.endDate;return Object(a.useEffect)((function(){s("cropSeasonStartDate",d),s("cropSeasonEndDate",u)}),[d,u]),Object(y.jsxs)("div",{className:r,children:[Object(y.jsx)(Qi,{label:c?"Start Date *":"Start Date",name:"cropSeasonStartDate",dates:d,control:m.DatePicker,disabled:!(null!==o&&void 0!==o&&null!==(t=o.selectedCropSeasons)&&void 0!==t&&t.length)}),Object(y.jsx)(Qi,{label:c?"End Date *":"End Date",name:"cropSeasonEndDate",dates:u,control:m.DatePicker,disabled:!(null!==o&&void 0!==o&&null!==(n=o.selectedCropSeasons)&&void 0!==n&&n.length)})]})};ig.defaultProps={className:""};var og=ig,sg=function(){var e=Object(Zi.h)(),t=e.values,n=e.setFieldValue,r=dd(),c=r.cropSeasons,i=r.loaded,o=Object(a.useContext)(ac),s=Object(b.a)(o,2)[1];return Object(y.jsxs)("div",{className:"flex flex-col bg-white top-30 left-26 h-100 w-140 rounded-md mb-20 p-6 shadow-sm","data-testid":"crop-season-mccain",children:[Object(y.jsx)("h1",{className:"mb-6 ml-8 font-body text-base font-normal leading-8 tracking-tight text-left",children:"Add crop seasons for your submission."}),Object(y.jsx)("div",{className:"w-2/3 ml-8",children:Object(y.jsx)(ng,{allCropSeasonsData:c,csLoaded:i,onSelect:function(e){n("selectedCropSeasons",e)},isRequired:!0})}),Object(y.jsx)(og,{className:"flex flex-row my-16 pb-6 gap-20 ml-8",isRequired:!0}),Object(y.jsx)(yx,{onNextValidation:function(){return!(t.cropSeasonStartDate>=t.cropSeasonEndDate)||(bc(s)("Start Date Cannot be Greater than End Date"),!1)}})]})},lg=function(e){var t=e.children;return Object(y.jsx)("div",{className:"w-full h-full align-center","data-testid":"mccain-cropseason-integration",children:Object(y.jsx)("div",{className:"flex w-full justify-center items-center",children:t})})},dg=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=kn.createChildApi({action:"reports/appliedproducts"}),i=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n,a,i,o,s,l=arguments;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=l.length>0&&void 0!==l[0]?l[0]:[],n=l.length>1&&void 0!==l[1]?l[1]:"AVERAGE",a=l.length>2&&void 0!==l[2]?l[2]:"ByFieldId",i={costType:n,reportType:a,seasonsCropZones:t},o=c.create(i),s=o.promise,e.abrupt("return",s.then((function(e){var t=e.data;return r(!0),t})).catch(Ae.default).catch((function(){return r(!0),[]})));case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return{getAppliedProducts:i,loading:n,setLoading:r}},ug=function(e){var t=e.size,n=e.color;return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:1.25*t,viewBox:"0 0 20 20",fill:"none","data-testid":"error-outline-icon",className:"fill-current text-".concat(n),children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.99 0C4.47 0 0 4.48 0 10C0 15.52 4.47 20 9.99 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 9.99 0ZM11 11V5H9V11H11ZM11 15V13H9V15H11ZM2 10C2 14.42 5.58 18 10 18C14.42 18 18 14.42 18 10C18 5.58 14.42 2 10 2C5.58 2 2 5.58 2 10Z"})})};ug.defaultProps={color:"cucumber-green-700",size:20};var bg=Object(a.memo)(ug),jg=function(e){var t=e.handleClose,n=Object(a.useContext)(vh),r=n.submitToMcCain,c=n.isLoading,i=lx(),o=i.events,s=i.triggerAnalyticsEvent,l=Object(Zi.h)().values;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"flex w-1/5 h-8",children:Object(y.jsx)(m.Button,{type:"outline",id:"cancel-button",onClick:function(){t()},children:"Cancel"})}),Object(y.jsxs)("div",{className:"flex flex-row-reverse justify-start w-full",children:[Object(y.jsx)("div",{className:"flex h-8",children:Object(y.jsx)(m.Button,{type:"primary",id:"submit-button",onClick:function(){s(o.epic.Integrations.submissionRunning,{vendor:JO}),r(l)},disabled:c,children:c?Object(y.jsx)(m.Spinner,{size:"xs"}):"Submit to McCain"})}),Object(y.jsx)("div",{className:"flex h-8 px-2",children:Object(y.jsx)(m.Button,{id:"save-button",type:"primary",ghost:!0,icon:Object(y.jsx)(xx,{}),children:"Save as PDF"})})]})]})},pg=function(e){var t=e.open,n=e.setOpenModal;return Object(y.jsx)(ao,{open:t,type:"buttonless",children:Object(y.jsxs)("div",{className:"-ml-6 mr-6 flex flex-row w-full","data-testid":"confirmation-modal",children:[Object(y.jsx)("div",{className:"flex mr-4",children:Object(y.jsx)(bg,{})}),Object(y.jsxs)("div",{className:"flex flex-col w-ful",children:[Object(y.jsx)("div",{className:"flex flex-row justify-items-center pb-4",children:Object(y.jsx)("h3",{className:"font-medium text-lg leading-6 text-gray-900 w-full",children:"Do you want to submit this data?"})}),Object(y.jsxs)("div",{className:"flex flex-col mb-4",children:[Object(y.jsx)("p",{children:"Are you sure you want to submit this data to McCain Foods Inc.?"}),Object(y.jsx)("p",{children:"(You can complete a new submission at any time) "})]}),Object(y.jsx)("div",{className:"mt-5 flex flex-row items-end justify-between w-full",children:Object(y.jsx)(jg,{handleClose:function(){n(!1)}})})]})]})})};pg.defaultProps={open:!0,setOpenModal:function(){}};var fg=pg,mg=function(){return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"19",height:"19",viewBox:"0 0 19 19",fill:"none","data-testid":"pencil-edit-icon",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.659 0C14.409 0 14.149 0.1 13.959 0.29L12.129 2.12L15.879 5.87L17.709 4.04C18.099 3.65 18.099 3.02 17.709 2.63L15.369 0.29C15.169 0.09 14.919 0 14.659 0ZM11.059 6.02L11.979 6.94L2.91902 16H1.99902V15.08L11.059 6.02ZM-0.000976562 14.2514L11.059 3.19141L14.809 6.94141L3.74902 18.0014H-0.000976562V14.2514Z",fill:"#696F88"})})},vg=function(e){var t=e.onClose,n=e.open,r=Object(Zi.h)(),c=r.values,i=r.setFieldValue,o=Object(a.useState)(c.mccainVendorId),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(null),j=Object(b.a)(u,2),p=j[0],f=j[1],v=function(){return f(null)};return Object(y.jsx)("div",{"data-testid":"mccain-vendor-modal",children:Object(y.jsxs)(m.SimpleModal,{onConfirm:function(){7===l.length?(i("mccainVendorId",l),t(),v()):f("Vendor Id must be 7 characters long")},open:n,close:t,confirmLabel:"Save",title:"Edit McCain Vendor ID",children:[p?Object(y.jsx)(m.Toast,{icon:"error",onClose:v,children:p}):null,Object(y.jsx)(m.Input,{className:"w-1/2",type:"text",value:l,onChange:function(e){d(e.target.value)},imask:{mask:"num",blocks:{num:{mask:Number,scale:0}}}})]})})};vg.defaultProps={onClose:function(){},open:!1};var Og=vg,hg=function(){var e=Object(Zi.h)().values,t=Object(a.useState)(!1),n=Object(b.a)(t,2),r=n[0],c=n[1];return Object(y.jsxs)("div",{"data-testid":"top-header",children:[Object(y.jsx)("div",{className:"w-full flex h-10 items-center",children:Object(y.jsx)("p",{className:"font-normal text-sm ",children:"Review the selected data before submitting to McCain."})}),Object(y.jsx)("div",{className:"w-full flex h-20 items-center font-semibold",children:Object(y.jsxs)("p",{className:"text-2xl",children:["McCain Foods Inc. Submission ",e.submitDate.toLocaleDateString()]})}),Object(y.jsx)("div",{className:"w-full h-32",children:Object(y.jsxs)("div",{className:"flex w-full h-full",children:[Object(y.jsxs)("div",{className:"flex h-full",children:[Object(y.jsxs)("div",{className:"h-full",children:[Object(y.jsx)(Og,{open:r,onClose:function(){c(!1)}}),Object(y.jsx)("p",{className:"font-thin text-xs text-gray-600",children:"McCain Vendor ID"}),Object(y.jsxs)("div",{className:"flex w-full items-center",children:[Object(y.jsx)("p",{className:"text-2xl pr-2 flex w-auto overflow-x-auto",children:e.mccainVendorId}),Object(y.jsx)("div",{className:"",children:Object(y.jsx)(m.Button,{type:"text",icon:Object(y.jsx)(mg,{}),onClick:function(){c(!0)}})})]})]}),Object(y.jsxs)("div",{className:"ml-14 h-full",children:[Object(y.jsx)("p",{className:"font-thin text-xs text-gray-600",children:"Crop Season(s) "}),Object(y.jsx)("div",{children:Object(y.jsx)(m.TagCloud,{"data-testid":"crops",children:e.selectedCropSeasons.map((function(e){return Object(y.jsx)(m.Tag,{color:"#696F88",children:e.name},e.id)}))})})]})]}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"flex flex-col ml-14",children:[Object(y.jsx)("p",{className:"font-thin text-xs text-gray-600",children:"Start Date"}),Object(y.jsx)("p",{className:"text-2xl font-normal pr-2",children:null===e||void 0===e?void 0:e.cropSeasonStartDate.toLocaleDateString()})]}),Object(y.jsxs)("div",{className:"flex flex-col ml-12",children:[Object(y.jsx)("p",{className:"font-thin text-xs text-gray-600",children:"End Date"}),Object(y.jsx)("p",{className:"text-2xl font-normal pr-2",children:null===e||void 0===e?void 0:e.cropSeasonEndDate.toLocaleDateString()})]})]})]})})]})},xg=function(e){var t=e.farmName,n=e.farmFields,a=e.isFarmSelected,r=e.handleSelectedFarm;return Object(y.jsx)(pu,{onClick:r,children:Object(y.jsxs)("div",{className:a?"flex flex-col pl-4 mb-10 border-l-8 text-blue-90":"flex flex-col pl-4 mb-10 border-l-8",style:a?{borderColor:"#0092E4"}:{borderColor:"#EAF6FF"},"data-testid":"mccain-farm-selection",children:[Object(y.jsx)("h3",{className:"mb-1 font-semibold",children:t}),Object(y.jsxs)("div",{className:"flex flex-row justify-items-center gap-2",children:[Object(y.jsx)("div",{children:Object(y.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("path",{d:"M6.00711 5.25586C5.45426 5.25586 5.00608 5.70357 5.00608 6.25586V8.25586C5.00608 8.80814 5.45426 9.25586 6.00711 9.25586H8.00915C8.562 9.25586 9.01017 8.80814 9.01017 8.25586V6.25586C9.01017 5.70357 8.562 5.25586 8.00915 5.25586H6.00711Z",fill:a?"#0092E4":"#14151C"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11.0122 1.25586C11.0122 0.703575 11.4604 0.255859 12.0132 0.255859C12.5661 0.255859 13.0143 0.703575 13.0143 1.25586C13.5671 1.25586 14.0153 1.70357 14.0153 2.25586C14.0153 2.80814 13.5671 3.25586 13.0143 3.25586V11.2559C13.5671 11.2559 14.0153 11.7036 14.0153 12.2559C14.0153 12.8081 13.5671 13.2559 13.0143 13.2559C13.0143 13.8081 12.5661 14.2559 12.0132 14.2559C11.4604 14.2559 11.0122 13.8081 11.0122 13.2559H3.00404C3.00404 13.8081 2.55587 14.2559 2.00302 14.2559C1.45017 14.2559 1.002 13.8081 1.002 13.2559C0.44915 13.2559 0.000976562 12.8081 0.000976562 12.2559C0.000976562 11.7036 0.449149 11.2559 1.002 11.2559L1.002 3.25586C0.44915 3.25586 0.000976562 2.80814 0.000976562 2.25586C0.000976562 1.70357 0.449149 1.25586 1.002 1.25586C1.002 0.703575 1.45017 0.255859 2.00302 0.255859C2.55587 0.255859 3.00404 0.703575 3.00404 1.25586L11.0122 1.25586ZM11.0122 11.2559H3.00404V3.25586H11.0122V11.2559Z",fill:a?"#0092E4":"#14151C"})]})}),Object(y.jsx)("span",{className:"font-normal text-xs",children:" fields ".concat(null===n||void 0===n?void 0:n.length," \u2022 ").concat(Zh(n))})]})]})})};xg.defaultProps={handleSelectedFarm:function(){},farmFields:[{}]};var gg=xg,Cg=function(){var e=Object(Zi.h)(),t=e.values,n=e.setFieldValue,a=t.selectedProperties,r=t.selectedFarm,c=(null===a||void 0===a?void 0:a.length)>10?"overflow-y-scroll":"";return Object(y.jsx)("div",{className:"bg-info-light-blue w-48 overflow-auto ".concat(c," max-h-200 h-auto rounded rounded-xl py-4 font-body"),"data-testid":"mccain-summary-farms",children:null===a||void 0===a?void 0:a.map((function(e,t){return Object(y.jsx)(gg,{farmName:e.name,farmFields:e.fields,isFarmSelected:r===t,handleSelectedFarm:function(){return function(e){n("selectedFarm",e)}(t)}},e.id)}))})},yg={Alfalfa:n(1472),Almond:n(1473),Amaranth:n(27),AnnualRyegrass:n(27),Apple:n(1474),Apricot:n(1475),Aquatic:n(27),Artichoke:n(1476),Arugula:n(27),Asparagus:n(1477),Avocado:n(27),BahiaGrass:n(27),Barley:n(1478),Basil:n(27),Bean:n(1479),Beets:n(1480),Bentgrass:n(27),Bermudagrass:n(27),Bittermelon:n(27),Blackberry:n(1481),BluePanicGrass:n(27),Blueberry:n(715),Bluegrass:n(27),Bluestem:n(27),BristleGrass:n(27),Broccoli:n(716),BroccoliRaab:n(716),BrusselsSprout:n(1482),Buckwheat:n(27),Buffelgrass:n(27),BundleflowerGrass:n(27),Cabbage:n(1483),CactusPear:n(27),Canola:n(1484),Cantaloupe:n(27),Carambola:n(27),Carrots:n(1485),Cauliflower:n(1486),Celery:n(1487),Cherry:n(1488),Chervil:n(27),Chestnut:n(27),ChewingFescue:n(27),Chickpea:n(1489),Chicory:n(27),Chives:n(1490),Chrysanthemum:n(27),Cilantro:n(27),Clover:n(1491),Coffee:n(1492),CollardGreens:n(27),Coriander:n(1493),Corn:n(717),Cotton:n(1494),CoverCrop:n(27),Crabgrass:n(27),Cranberry:n(715),Crawfish:n(27),Crenshaw:n(27),CREP:n(27),CRP:n(27),CSP:n(27),Cucumber:n(1495),Currants:n(27),Daffodil:n(27),Daikon:n(27),Dandelion:n(27),Dill:n(1496),Echinacea:n(27),Edamame:n(27),Eggplant:n(27),Endive:n(1497),Escarole:n(27),Fallow:n(27),Fennel:n(27),Fenugreek:n(27),Festulolium:n(27),Filbert:n(27),FineFescue:n(27),Flax:n(27),Flowers:n(27),ForageSorghum:n(1498),Garlic:n(1499),Ginseng:n(27),Gourd:n(27),GrainSorghum:n(27),Grapefruit:n(718),Grapes:n(718),GrassSeedMixed:n(1500),GreenManure:n(27),Guava:n(27),Guayule:n(27),HardSquash:n(27),Hay:n(27),Hazelnut:n(1501),Hemp:n(719),Honeydew:n(27),Hops:n(1502),Horseradish:n(27),Kale:n(27),Kenaf:n(27),Kiwi:n(27),KleinGrass:n(27),Kohlrabi:n(27),Lavender:n(27),Leasedland:n(27),Leek:n(1503),Lemon:n(27),Lemongrass:n(27),Lentil:n(27),Lespedeza:n(27),Lettuce:n(1504),LillyBulb:n(27),LimaBean:n(27),Lime:n(27),Lovegrass:n(27),Lychee:n(27),MacadamiaNut:n(27),Mandarin:n(27),Mango:n(27),Marjoram:n(27),MeadowFescue:n(27),MeadowFoam:n(27),MedicGrass:n(27),Metaleaf:n(27),Millet:n(1505),Mint:n(27),Miscanthus:n(27),Mizuna:n(27),Moqua:n(27),Mushrooms:n(1506),Mustard:n(720),MustardGreens:n(720),MWD:n(27),Nectarine:n(27),NonAg:n(27),NonCrop:n(27),NurseryStock:n(27),Oats:n(1507),OilPalm:n(1508),Okra:n(27),Olive:n(27),Onions:n(1509),Opo:n(27),Orange:n(27),Orchardgrass:n(27),Oregano:n(27),Papaya:n(27),Parsley:n(27),Parsnip:n(1510),PassionFruit:n(27),Pasture:n(27),Peach:n(27),Peanut:n(1511),Pear:n(1512),Peas:n(1513),Pecan:n(1514),Pepper:n(1515),PerennialRyegrass:n(27),Persimmon:n(27),Pistachio:n(1516),Plantain:n(27),Plum:n(1517),Pluot:n(27),Pomegranate:n(1518),Pomelo:n(27),Pond:n(27),Pongamia:n(27),PostHarvest:n(27),Potato:n(1519),PreventedPlanting:n(27),Pumpkin:n(1520),Quinoa:n(27),Radish:n(1521),Rape:n(27),Raspberry:n(1522),Rhubarb:n(1523),Rice:n(1524),Rosemary:n(27),Rutabaga:n(27),Rye:n(1525),Safflower:n(27),Sage:n(27),Sainfoin:n(27),Savory:n(27),SeedProduction:n(27),Sesame:n(27),SetAside:n(27),Sinqua:n(27),Sod:n(27),Sorrel:n(27),Soybeans:n(1526),Spelt:n(27),Spinach:n(1527),SpriteMelon:n(27),Squash:n(1528),Stevia:n(27),Strawberry:n(1529),SudanGrass:n(27),SugarBeets:n(1530),Sugarcane:n(1531),Sunflower:n(1532),SunnHemp:n(719),SweetCorn:n(717),SweetPotato:n(1533),SweetSorghum:n(27),SwissChard:n(27),Switchgrass:n(27),TallFescue:n(27),Tangelo:n(27),Tangerine:n(27),Tarragon:n(27),Teff:n(27),Thyme:n(27),Timothy:n(27),Tobacco:n(1534),Tomatillos:n(27),Tomato:n(1535),Trees:n(1536),Triticale:n(1537),Tulips:n(27),TurnRow:n(27),TurnipGreens:n(721),Turnips:n(721),Undecided:n(27),Vetch:n(1538),Walnut:n(1539),Watercress:n(27),Watermelon:n(1540),Wheat:n(1541),WildlifeRefuge:n(27),WindmillGrass:n(27),WRP:n(27)},Pg=function(e){var t=e.cropObject,n=e.size,a=void 0===n?24:n,r=Object(y.jsx)("div",{children:" "});if(null!==t&&void 0!==t&&t.name){var c=t.name.includes(":")?t.name.split(" ")[0].trim().replace(/\s/g,""):t.name.trim().replace(/\s/g,"");c in yg&&(r=Object(y.jsx)("img",{src:yg[c].default,alt:c,width:a,height:a}))}return r};Pg.defaultProps={size:24,cropObject:{}};var Ag=Pg,Sg=function(e){var t=e.products,n=Object(a.useState)(t),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)("date"),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)("desc"),j=Object(b.a)(u,2),p=j[0],f=j[1],O=Object(a.useCallback)((function(e,n){d(e),f(n),i(Object(v.a)(t).sort((function(t,a){var r,c="asc"===n?t:a,i="asc"===n?a:t;return"productName"===e?null===(r=c.productName)||void 0===r?void 0:r.localeCompare(i.productName):c.appliedDateEpoch-i.appliedDateEpoch})))}),[]);return Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{sort:"date"===l?p:"",sortable:!0,onClick:function(){return O("date","desc"===p?"asc":"desc")},children:"Date"}),Object(y.jsx)(m.Table.Cell,{sort:"productName"===l?p:"",sortable:!0,onClick:function(){return O("productName","desc"===p?"asc":"desc")},children:"Cropwise Product"}),Object(y.jsx)(m.Table.Cell,{children:"Product Type"}),Object(y.jsx)(m.Table.Cell,{children:"Application Method"}),Object(y.jsx)(m.Table.Cell,{children:"Rate (per acre)"}),Object(y.jsx)(m.Table.Cell,{children:"Total Applied"})]}),null===c||void 0===c?void 0:c.map((function(e){var t,n,a,r=null===(t=e.rate)||void 0===t?void 0:t.split(" ").pop();return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:new Date(e.appliedDate).toLocaleDateString()}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex flex-col justify-start text-left",children:[Object(y.jsx)("span",{className:"font-bold mb-1","data-testid":"product-name",children:null!==(n=e.productName)&&void 0!==n?n:e.name}),Object(y.jsx)("span",{className:"text-neutral-600",children:null!==(a=e.manufacturerName)&&void 0!==a?a:e.manufacturer})]})}),Object(y.jsx)(m.Table.Cell,{children:e.type}),Object(y.jsx)(m.Table.Cell,{children:e.applicationMethod}),Object(y.jsx)(m.Table.Cell,{children:e.rate}),Object(y.jsxs)(m.Table.Cell,{children:[e.total.toFixed(2)," ",r]})]},e.id)}))]})};Sg.defaultProps={products:[]};var Tg=Sg,Ng=function(e){var t=e.fields;return Object(y.jsx)(y.Fragment,{children:t.map((function(e,n){var a,r;return(null===e||void 0===e||null===(a=e.cropzones)||void 0===a?void 0:a.reduce((function(e,t){var n;return e+(null===t||void 0===t||null===(n=t.products)||void 0===n?void 0:n.length)}),0))>0&&Object(y.jsxs)("div",{"data-testid":"field-summary-table",className:"w-full ".concat(n===t.length-1?"mb-10":"mb-20"),id:e.fieldId,children:[Object(y.jsx)("div",{className:"w-full text-2xl font-bold",children:null===e||void 0===e?void 0:e.name}),Object(y.jsx)("div",{className:"w-full",children:null===e||void 0===e||null===(r=e.cropzones)||void 0===r?void 0:r.map((function(e){var t,n,a,r;return(null===e||void 0===e||null===(t=e.products)||void 0===t?void 0:t.length)>0&&Object(y.jsxs)("div",{className:"mt-6",children:[Object(y.jsxs)("div",{className:"flex flex-row mb-3 leading-loose items-center",children:[Object(y.jsx)("div",{className:"font-bold mr-4",children:null===e||void 0===e?void 0:e.name}),Object(y.jsxs)("div",{className:"flex flex-row mr-4 items-center",children:[Ag({cropObject:{name:null!==(n=null===e||void 0===e?void 0:e.cropName)&&void 0!==n?n:null===e||void 0===e?void 0:e.name}})," ",null!==(a=null===e||void 0===e?void 0:e.cropName)&&void 0!==a?a:null===e||void 0===e?void 0:e.name]}),Object(y.jsx)("div",{className:"w-auto",children:null===e||void 0===e||null===(r=e.cropSeasons)||void 0===r?void 0:r.map((function(e){var t;return Object(y.jsx)(m.Tag,{color:"#696F88",children:null!==(t=null===e||void 0===e?void 0:e.cropseasonName)&&void 0!==t?t:e.name},e.id)}))})]}),Object(y.jsx)(Tg,{products:null===e||void 0===e?void 0:e.products})]},e.id)}))})]},e.id)}))})};Ng.defaultProps={fields:[]};var Eg=Ng,wg="mccain-pdf-wrapper",_g=function(){var e,t=Object(a.useState)(!0),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(Zi.h)(),o=i.values,s=i.setFieldValue,l=o.selectedProperties,d=o.selectedCropSeasons,u=o.selectedFarm,j=dg().getAppliedProducts,p=Object(a.useContext)(vh),f=p.setModalSubmissionState,O=p.state.openSubmissionModal,h=function(e,t){var n,a;return null!==(n=null===e||void 0===e||null===(a=e.filter)||void 0===a?void 0:a.call(e,(function(e){return t===e.cropZoneId})))&&void 0!==n?n:[]};return Object(a.useEffect)((function(){var e,t=d.map((function(e){return e.id})),n=Fh(l).flatMap((function(e){var t;return{cropZoneId:e.id,seasonsIds:null===(t=e.cropSeasons)||void 0===t?void 0:t.map((function(e){return e.id}))}})),a=null===t||void 0===t||null===(e=t.reduce((function(e,t){var a;return e.push({seasonId:t,cropZoneIds:null===n||void 0===n||null===(a=n.filter((function(e){return e.seasonsIds.includes(t)})))||void 0===a?void 0:a.map((function(e){return e.cropZoneId}))}),e}),[]))||void 0===e?void 0:e.filter((function(e){var t;return null===(t=e.cropZoneIds)||void 0===t?void 0:t.length}));j(a).then((function(e){var t=Object(v.a)(l).map((function(t){return Object(I.a)(Object(I.a)({},t),{},{fields:(n=t.fields,a=e.products,n.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{cropzones:e.cropzones.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{products:h(a,e.id)})})).filter((function(e){return e.products.length}))})})).filter((function(e){return e.cropzones.length})))});var n,a}));s("selectedProperties",t),c(!1)}))}),[d]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"w-full h-full bg-white flex flex-col px-6 py-4 rounded-xl font-body","data-testid":"summary-view",id:wg,children:[Object(y.jsx)("div",{className:"flex flex-col w-full h-48 border-b-2 mb-12",id:"mccain-top-header",children:Object(y.jsx)(hg,{})}),r?Object(y.jsx)("div",{className:"m-auto",children:Object(y.jsx)(m.Spinner,{})}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex flex-row w-full h-full",id:"mccain-summaryview",children:[Object(y.jsx)("div",{className:"w-auto mr-12",children:Object(y.jsx)(Cg,{})}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(Eg,{fields:null===(e=l[u])||void 0===e?void 0:e.fields})})]}),Object(y.jsx)(yx,{MCCAIN_PDF_WRAPPER:wg})]})]}),Object(y.jsx)(fg,{open:O,setOpenModal:f})]})},Rg=n.p+"static/media/mccain-confirmation.e3a8e47f.svg",Ig=function(){lx({onMountTriggerEvent:{event:Ee.epic.Integrations.submissionCompleted,data:{vendor:JO}}});var e=Object(p.h)(),t=Object(Zi.h)().values;return Object(y.jsx)("div",{className:"flex justify-center flex-col h-full",children:Object(y.jsxs)("div",{className:"flex text-center flex-col justify-center ",children:[Object(y.jsx)("div",{className:"flex justify-center",style:{marginBottom:"30px"},children:Object(y.jsx)("img",{src:Rg,alt:"McCain Confirmation",width:"60px",height:"60px"})}),Object(y.jsx)("h1",{className:"text-2xl leading-8 font-semibold",style:{marginBottom:"8px"},children:"Your data has been submitted!"}),Object(y.jsx)("div",{style:{marginBottom:"32px"},children:Object(y.jsxs)("p",{className:"font-normal text-sm",children:["Your submission to McCain vendor ID ",t.mccainVendorId||""," ","has been sent to McCain Foods Inc.",Object(y.jsx)("br",{}),"You can view the submitted properties via the McCain Foods Inc. portal."]})}),Object(y.jsx)("div",{className:"flex justify-center",children:Object(y.jsx)(m.Button,{id:"return-mainpage-button",type:"primary",ghost:!0,onClick:function(){return e.push({pathname:Cc.integrations})},children:"Return to Integrations"})})]})})},Dg={mccain:{0:Object(y.jsx)(qx,{}),1:Object(y.jsx)(lg,{children:Object(y.jsx)(sg,{})}),2:Object(y.jsx)(Wx,{integrationName:JO}),3:Object(y.jsx)(_g,{}),4:Object(y.jsx)(Ig,{})}},kg=function(e){var t=e.integration,n=Object(a.useContext)(vh).state.step;return Dg[t.toLowerCase()][n]};kg.propTypes={integration:wc.a.string.isRequired};var Lg=kg,Fg={selectedProperties:[],submitDate:new Date,selectedFarm:0,selectedCropSeasons:[{}],mccainVendorId:"",cropSeasonStartDate:"",cropSeasonEndDate:""},Mg=function(){var e=function(){return null},t=Object(a.useContext)(vh),n=t.state.step,r=t.goBack;return Object(y.jsx)(Zi.e,{initialValues:Fg,children:function(t){var a=t.values;return Object(y.jsxs)("div",{children:[Object(y.jsx)(lo,{onOrganizationSelect:e,hideCropSeasonDropdown:!0,onCropSeasonSelect:e,disabled:!0,children:Object(y.jsx)(lo.Item,{title:"Integrations",value:"McCain",isLast:!0})}),Object(y.jsxs)("div",{className:"z-50 min-h-50 h-full left-0 right-0 bottom-0 top-18","data-testid":"base-maccain-integration",children:[n>0&&n<4&&Object(y.jsx)(Ph,{stepArray:Ah,currentStep:n,canGoNext:function(){return function(e,t){return 1===t&&e.cropSeason&&e.startDate&&e.endDate}(a,n)},gotoStep:r}),Object(y.jsx)(Lg,{integration:JO})]})]})}})},Vg=function(){return Object(y.jsx)(hh,{children:Object(y.jsx)(Mg,{})})},Bg="SET_SELECTED_CROPYEAR",Ug="SET_UNMATCHED_ENTITIES",zg="SET_VENDOR_PROPERTIES",Zg="SET_MATCHES_SUBMISSION",Yg="SET_OPEN_CONFIRMATION_MODAL",Hg="SET_FARMS_TO_MATCH",Gg=function(e,t){switch(t.type){case zg:return Object(I.a)(Object(I.a)({},e),{},{vendorProperties:t.payload});case Bg:return Object(I.a)(Object(I.a)({},e),{},{selectedCropYear:t.payload});case Ug:return Object(I.a)(Object(I.a)({},e),{},{unmatchedEntities:t.payload});case Zg:return Object(I.a)(Object(I.a)({},e),{},{matches:t.payload});case Yg:return Object(I.a)(Object(I.a)({},e),{},{openConfirmationModal:t.payload});case Hg:return Object(I.a)(Object(I.a)({},e),{},{farmsMatch:t.payload});default:return e}},Wg={simplot:{api:cn,responseTranslator:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"CropZone";return{status:e.status,data:e.data.filter((function(e){return e.type===t})).map((function(e){return{cwfId:e.cwfEntityId,vendorId:e.simplotEntityId,vendorPropertyName:e.simplotEntityDescription}}))}},requestTranslator:function(e){return e.map((function(e){return{cwfEntityId:e.cwfId,simplotEntityId:e.vendorId,simplotEntityDescription:e.vendorPropertyName,type:e.type||"CropZone"}}))}},agrian:{api:ln,responseTranslator:function(e){return{status:e.status,data:e.data.filter((function(e){return"Field"===e.type})).map((function(e){return{cwfId:e.cwfEntityId,vendorId:e.agrianEntityId,type:e.type}}))}},requestTranslator:function(e){return e.map((function(e){return{cwfEntityId:e.cwfId,agrianEntityId:e.vendorId,agrianEntityDescription:e.vendorPropertyName,type:"Field"}}))}},agrianrecommendation:{api:ln,responseTranslator:function(e){return{status:e.status,data:e.data.filter((function(e){return"CropZone"===e.type})).map((function(e){return{cwfId:e.cwfEntityId,vendorId:e.agrianEntityId}}))}},requestTranslator:function(e){return e.map((function(e){return{cwfEntityId:e.cwfId,agrianEntityId:e.vendorId,agrianEntityDescription:e.vendorPropertyName,type:"CropZone"}}))}}},qg=Wg,Jg={simplot:on,agrian:sn,agrianrecommendation:sn},Kg=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useContext)(ac),i=Object(b.a)(c,2)[1],o=localStorage.getItem("selectedOrganizationId"),s=Object(a.useCallback)((function(e){var t=qg[e.toLowerCase()],n=(null===t||void 0===t?void 0:t.api).fetch(null,{types:"Organization"},{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),n.then((function(e){return e.data})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[o]),l=Object(a.useCallback)((function(e){var t=qg[e.toLowerCase()],n=(null===t||void 0===t?void 0:t.api).fetch(null,{types:"Organization,Farm,Field,CropZone"},{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),n.then((function(e){return t.responseTranslator(e)})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[o]),d=Object(a.useCallback)((function(e){var t=qg[e.vendor.toLowerCase()],n=(null===t||void 0===t?void 0:t.api).create(null===t||void 0===t?void 0:t.requestTranslator(e.data),{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),n.then((function(e){return e})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[o]),u=Object(a.useCallback)((function(e){var t=e.vendor,n=e.vendorPropertyId,a=Jg[t.toLowerCase()].fetch("".concat(n,"/geometry"),{},{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),a.then((function(e){return e})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[o]);return{createMatches:d,getOrganizationMatch:s,getPropertiesMatches:l,getVendorProperties:Object(a.useCallback)((function(e){var t=e.vendor,n=e.cropYear,a=Jg[t.toLowerCase()].fetch(null!==n&&void 0!==n?n:"",{},{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),a.then((function(e){return e})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[o]),getVendorPropertyGeometry:u,loading:n,setLoading:r}},Qg={matches:[],farmsMatch:[],vendorProperties:[],openConfirmationModal:!1,errorMessage:"",matchEntityType:"",unmatchedEntities:-1},Xg=Object(a.createContext)(Qg),$g=function(e){var t=e.integrationType,n=e.children,r=e.onCompleteMatch,c=Object(a.useReducer)(Gg,Object(I.a)(Object(I.a)({},Qg),{},{integrationType:t,children:n,matchEntityType:t===QO?"Fields":"Crop Zones",selectedCropYear:t===KO?(new Date).getFullYear():null})),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Kg(),d=l.getPropertiesMatches,u=l.createMatches,j=l.getVendorProperties,p=l.loading,f=function(e){s({type:Hg,payload:e})},m=function(e){s({type:Ug,payload:e})},v=function(e){s({type:Bg,payload:e})},O=function(e){s({type:Zg,payload:e})},h=function(e,t){var n=[].concat(o.matches.filter((function(t){return t.cwfId!==e})));n.push({cwfId:e,vendorId:t}),O(n)},x=function(e,t){var n=[].concat(o.matches),a=n.findIndex((function(e){return e.vendorId===t}));-1!==a&&n.splice(a,1),n.push({cwfId:e,vendorId:t}),O(n)},g=function(){var e=Object(Y.a)(G.a.mark((function e(){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u({vendor:t,data:o.matches.map((function(e){var t;return Object(I.a)(Object(I.a)({},e),{},{vendorPropertyName:null===(t=o.vendorProperties.find((function(t){return t.id===e.vendorId})))||void 0===t?void 0:t.name})}))});case 2:201===(null===(n=e.sent)||void 0===n?void 0:n.status)&&r();case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),C=function(){var e=Object(Y.a)(G.a.mark((function e(){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d(t);case 2:200===(null===(n=e.sent)||void 0===n?void 0:n.status)&&O(n.data);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),P=function(){var e=Object(Y.a)(G.a.mark((function e(){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,j({vendor:t===XO?QO:t,cropYear:o.selectedCropYear});case 2:200===(null===(n=e.sent)||void 0===n?void 0:n.status)&&(a=n.data,s({type:zg,payload:a}));case 4:case"end":return e.stop()}var a}),e)})));return function(){return e.apply(this,arguments)}}(),A=function(e){s({type:Yg,payload:e})},S=function(){switch(o.integrationType){case QO:case XO:return Kh;case KO:return nx;default:return null}},T=Object(a.useMemo)((function(){return{state:o,integrationContext:S(),dispatch:s,updateSelectedCropYear:v,updateUnmatchedEntities:m,addPropertyMatchId:h,addPropertyMatchIdWithVendorIdInControl:x,updateMatches:O,submitMatches:g,fetchMatches:C,fetchVendorProperties:P,updateFarmsMatch:f,isLoading:p,setOpenConfirmationModal:A}}),[o,p]);return Object(y.jsx)(Xg.Provider,{value:T,children:n})};$g.defaultProps={children:null,integrationType:KO,onCompleteMatch:null};var eC=$g,tC=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=ni(),i=Object(a.useContext)(ac),o=Object(b.a)(i,2)[1],s=localStorage.getItem("selectedOrganizationId"),l=Object(a.useCallback)((function(e){var t=e.vendor,n=e.seasonIds,a=e.cropSeasonsDateRange,c=e.cropzoneIds,i=e.submissionId,l={vendor:t,seasonIds:n,cropSeasonsDateRange:a,cropzoneIds:c},d=rn.createChildApi({action:"integrations/submissions"}),u=(i?d.update(i,l,{headers:{"cwf-context":JSON.stringify({organization_id:s})}}):d.create(l,{headers:{"cwf-context":JSON.stringify({organization_id:s})}})).promise;return r(!0),u.then((function(e){return e})).catch(Ae.default).catch(uc(o)).finally((function(){return r(!1)}))}),[s]),d=Object(a.useCallback)((function(e){var t=rn.createChildApi({action:"integrations/submissions"}).fetch(e,{},{headers:{"cwf-context":JSON.stringify({organization_id:s})}}).promise;return r(!0),t.then((function(e){return e})).catch(Ae.default).catch(uc(o)).finally((function(){return r(!1)}))}),[s]),u=Object(a.useCallback)((function(e){var t=e.submissionId,n=e.cropZoneId;return r(!0),rn.createChildApi({action:"integrations/submissions/".concat(t,"/cropzones/").concat(n)}).delete(null,{headers:{"cwf-context":JSON.stringify({organization_id:s})}}).promise.then((function(e){return e})).catch(Ae.default).catch(uc(o)).finally((function(){return r(!1)}))}),[s]),j=Object(a.useCallback)((function(e){var t=e.submissionId,n=e.cropZoneId,a=e.taskId;return r(!0),rn.createChildApi({action:"integrations/submissions/".concat(t,"/cropzones/").concat(n,"/tasks/").concat(a)}).delete(null,{headers:{"cwf-context":JSON.stringify({organization_id:s})}}).promise.then((function(e){return e})).catch(Ae.default).catch(uc(o)).finally((function(){return r(!1)}))}),[s]);return{createSubmission:l,getSubmission:d,getFieldsDetailsBySubmission:Object(a.useCallback)((function(e){return r(!0),rn.createChildApi({action:"integrations/submissions/".concat(e,"/fields/details")}).fetch(null,{},{headers:{"cwf-context":JSON.stringify({organization_id:s})}}).promise.then((function(e){return e})).catch(Ae.default).catch(uc(o)).finally((function(){return r(!1)}))}),[s]),updateFieldsDetailsBySubmission:Object(a.useCallback)((function(e,t){return r(!0),rn.createChildApi({action:"integrations/submissions/".concat(e,"/fields/details")}).update(null,t,{headers:{"cwf-context":JSON.stringify({organization_id:s})}}).promise.then((function(e){return e})).catch(Ae.default).catch(uc(o)).finally((function(){return r(!1)}))}),[s]),deleteSubmissionCropZone:u,deleteTaskFromSubmissionCropZone:j,submit:Object(a.useCallback)((function(e,t,n){var a=rn.createChildApi({action:"integrations/submissions/".concat(e,"/submit/").concat(t.toLowerCase())}).create(null!==n&&void 0!==n?n:null,{headers:{"cwf-context":JSON.stringify({organization_id:s})}}).promise;return r(!0),a.then((function(e){return e})).catch(Ae.default).catch((function(e){var t;if(422!==(null===(t=e.response)||void 0===t?void 0:t.status)){var n,a,r,i,o,s=null===(n=e.response)||void 0===n||null===(a=n.data)||void 0===a||null===(r=a.response)||void 0===r?void 0:r.details,l=null===(i=e.response)||void 0===i||null===(o=i.data)||void 0===o?void 0:o.errorMessage,d=dc({},e);return(null===s||void 0===s?void 0:s.length)>0&&(d={displayMessage:"".concat(l,":\n\n").concat(Object(v.a)(new Set(null===s||void 0===s?void 0:s.map((function(e){return e.errorMessage})))).join("\n\n"))}),c.error("Submission unable to be sent",{content:d.displayMessage,supportButton:!0,timeout:6e4}),null}return e.response})).finally((function(){return r(!1)}))}),[s]),resubmit:Object(a.useCallback)((function(e){var t=rn.createChildApi({action:"integrations/submissions/".concat(e,"/resubmission")}).create(null,{headers:{"cwf-context":JSON.stringify({organization_id:s})}}).promise;return r(!0),t.then((function(e){return e})).catch(Ae.default).catch(uc(o)).finally((function(){return r(!1)}))}),[s]),listSubmissions:Object(a.useCallback)((function(e){var t=rn.createChildApi({action:"integrations/submissions"}).fetch(null,e,{headers:{"cwf-context":JSON.stringify({organization_id:s})}}).promise;return r(!0),t.then((function(e){return e})).catch(Ae.default).catch(uc(o)).finally((function(){return r(!1)}))}),[s]),loading:n,getProducts:Object(a.useCallback)((function(e){var t=rn.createChildApi({action:"integrations/submissions/".concat(e,"/products")}).fetch(null,{},{headers:{"cwf-context":JSON.stringify({organization_id:s})}}).promise;return r(!0),t.then((function(e){return e})).catch(Ae.default).catch(uc(o)).finally((function(){return r(!1)}))}),[s]),getMaterials:Object(a.useCallback)((function(e,t){var n=rn.createChildApi({action:"integrations/".concat(e,"/materials?name=").concat(t)}).fetch(null,{},{headers:{"cwf-context":JSON.stringify({organization_id:s})}}).promise;return r(!0),n.then((function(e){return e})).catch(Ae.default).catch(uc(o)).finally((function(){return r(!1)}))}),[s]),updateProducts:Object(a.useCallback)((function(e,t){var n=rn.createChildApi({action:"integrations/submissions/".concat(e,"/products")}).update(null,{products:t.map((function(e){return{id:e.productId,registrationNumber:e.overrideRegistrationNumber}}))},{headers:{"cwf-context":JSON.stringify({organization_id:s})}}).promise;return r(!0),n.then((function(e){return e})).catch(Ae.default).catch((function(e){var t,n,a,r=null===(t=e.response)||void 0===t||null===(n=t.data)||void 0===n?void 0:n.message;if(422===(null===(a=e.response)||void 0===a?void 0:a.status)&&r)c.error("Products changes unable to be sent",{content:r,supportButton:!0,timeout:6e4});else{var i=dc({},e);c.error("Products changes unable to be sent",{content:i.displayMessage,supportButton:!0,timeout:3e4})}return e})).finally((function(){return r(!1)}))}),[s]),setLoading:r}},nC=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useContext)(ac),i=Object(b.a)(c,2)[1],o=localStorage.getItem("selectedOrganizationId"),s=Object(a.useCallback)((function(e){var t=e.vendor,n=e.matchTypes,a=void 0===n?[]:n,c=dn.createChildApi({action:"integrations/".concat(t,"/match")}).fetch(null,{types:a.join(",")},{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),c.then((function(e){return e})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[o]),l=Object(a.useCallback)((function(e){var t=e.vendor,n=e.products,a=dn.createChildApi({action:"integrations/".concat(t,"/match/products")}).create(n,{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),a.then((function(e){return e})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[o]),d=Object(a.useCallback)((function(e){var t=e.vendor,n=e.products,a=dn.createChildApi({action:"integrations/".concat(t,"/match/products/v2")}).create(n,{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),a.then((function(e){return e})).catch(Ae.default).catch((function(e){return e})).finally((function(){return r(!1)}))}),[o]);return{getMatches:s,createMatches:Object(a.useCallback)((function(e){var t=e.vendor,n=e.matches,a=dn.createChildApi({action:"integrations/".concat(t,"/match/")}).create(n,{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),a.then((function(e){return e})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[o]),createMatchingProducts:l,createMatchingProductsV2:d,loading:n}},aC=function(e){return e?e.flatMap((function(e){var t;return null!==(t=e.fields)&&void 0!==t?t:[]})).flatMap((function(e){var t;return null!==(t=e.cropzones)&&void 0!==t?t:[]})).map((function(e){return e.id})):[]},rC=function(e){return null!==e&&void 0!==e&&e.endsWith("-0")?null===e||void 0===e?void 0:e.slice(0,-2):e},cC=new Map([["Fumigation","F"],["Aerial","A"],["Air Blast","A"],["Ground","G"],["Ground - Banded","G"],["Ground - Broadcast","G"],["Ground - Hooded","G"],["Ground - In Furrow","G"],["Ground - Incorporated","G"],["Ground - Seed Treatment","G"],["Ground - Spot","G"],["Ground - Variable Rate","G"],["Ground - Wipe","G"],["Ground Application","G"]]),iC=function(e){var t;return null!==(t=cC.get(e))&&void 0!==t?t:"O"},oC=function(e,t){var n=e.products.filter((function(e){return iC(e.applicationMethod)===t}));return(null===n||void 0===n?void 0:n.length)>0?Object(I.a)(Object(I.a)({},e),{},{products:n}):null},sC=function(e){return null!==e&&void 0!==e&&e.length?"Fumigation"===e[0].applicationMethod?"Fumigation":Object(v.a)(new Set(e.map((function(e){return e.applicationMethod||"None"})))).join(", "):""},lC=function(e){var t;return null===(t=function(e){var t;return null!==(t=null===e||void 0===e?void 0:e.flatMap((function(e){var t;return null===(t=e.fields)||void 0===t?void 0:t.flatMap((function(e){return e.cropzones}))})))&&void 0!==t?t:[]}(e))||void 0===t?void 0:t.flatMap((function(e){var t;return null===(t=e.tasks)||void 0===t?void 0:t.map((function(t){return Object(I.a)(Object(I.a)({},t),{},{cropZoneId:e.id})}))}))},dC="SET_MATCHES",uC="SET_SUBMISSION_DATA",bC="SET_OPEN_CONFIRMATION_MODAL",jC="SET_OPEN_REMOVE_CROPZONE_MODAL",pC="SET_OPEN_REMOVE_TASK_MODAL",fC="SET_SUBMISSION_DONE",mC="SET_CROPSEASONS",vC="SET_SUBMISSION_FILTER_CROPZONE",OC="SET_SUBMISSION_ID",hC="SET_SELECTED_PRODUCTS",xC="SET_PRODUCTS",gC="SET_FIELDS",CC="SET_OPEN_DRAWER_COUNTIES",yC="SET_READ_ONLY",PC=function(e,t){switch(t.type){case dC:return Object(I.a)(Object(I.a)({},e),{},{matches:t.payload});case hC:return Object(I.a)(Object(I.a)({},e),{},{selectedProducts:t.payload});case xC:return Object(I.a)(Object(I.a)({},e),{},{products:t.payload});case gC:return Object(I.a)(Object(I.a)({},e),{},{fields:t.payload});case uC:return Object(I.a)(Object(I.a)({},e),{},{farms:t.payload.farms,cropSeasons:t.payload.cropSeasons,cropSeasonDateRange:t.payload.cropSeasonDateRange,tasks:t.payload.tasks,extraData:t.payload.extraData,submissionFilterCropZoneIds:t.payload.cropZoneIds,submissionResult:t.payload.submissionResult,loadedSubmission:!0,pastSubmissions:t.payload.pastSubmissions});case bC:return Object(I.a)(Object(I.a)({},e),{},{openConfirmationModal:t.payload});case jC:return Object(I.a)(Object(I.a)({},e),{},{openRemoveCropzoneModal:t.payload.open,cropzoneToRemove:t.payload.cropzone});case pC:return Object(I.a)(Object(I.a)({},e),{},{openRemoveTaskModal:t.payload.open,taskToRemove:t.payload.task});case fC:return Object(I.a)(Object(I.a)({},e),{},{submissionDone:!0,submissionResult:t.payload});case mC:return Object(I.a)(Object(I.a)({},e),{},{cropSeasons:t.payload});case vC:return Object(I.a)(Object(I.a)({},e),{},{submissionFilterCropZoneIds:t.payload});case OC:return Object(I.a)(Object(I.a)({},e),{},{submissionId:t.payload});case CC:return Object(I.a)(Object(I.a)({},e),{},{openDrawerCounties:t.payload});case yC:return Object(I.a)(Object(I.a)({},e),{},{isReadOnly:t.payload});default:return e}},AC={farms:[],cropSeasons:[],selectedProducts:[],products:[],fields:[],tasks:[],extraData:void 0,submissionResult:{},matches:{},selectedFarm:0,submissionFilterCropZoneIds:[],submissionId:null,cropSeasonStartDate:null,cropSeasonEndDate:null,cropSeasonDateRange:null,openConfirmationModal:!1,openRemoveCropzoneModal:!1,openDrawerCounties:!1,cropzoneToRemove:null,setOpenRemoveTaskModal:!1,taskToRemove:null,errorMessage:"",submissionDone:!1,isReadOnly:!1,loadedSubmission:!1,pastSubmissions:[]},SC=Object(a.createContext)(AC),TC=function(e){var t=e.integrationType,n=e.children,r=localStorage.getItem("selectedOrganizationId"),c=Object(a.useContext)(vh).state.submissionFlowId,i=lx(),o=i.events,s=i.triggerAnalyticsEvent,l=ox(),d=l.determineSubmissionId,u=l.isReadOnly,j=l.comingFromView,p=Ix(),f=p.setAllDataFromSubmission,m=p.setSelectedCropSeasonsDateRangeInitial,v=p.selectedCropSeasonsDateRange,O=Object(a.useReducer)(PC,Object(I.a)(Object(I.a)({},AC),{},{integrationType:t,submissionId:d(),isReadOnly:u,resubmitEnabled:u||j,orgId:r})),h=Object(b.a)(O,2),x=h[0],g=h[1],C=tC(),P=C.createSubmission,A=C.getSubmission,S=C.getProducts,T=C.getMaterials,N=C.getFieldsDetailsBySubmission,E=C.updateFieldsDetailsBySubmission,w=C.updateProducts,_=C.deleteSubmissionCropZone,R=C.deleteTaskFromSubmissionCropZone,D=C.submit,k=C.resubmit,L=C.loading,F=nC(),M=F.createMatchingProducts,V=F.getMatches,B=F.loading,U=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=x.farms.flatMap((function(e){return e.fields.flatMap((function(e){return e.cropzones.flatMap((function(e){return e.tasks.flatMap((function(e){return e.products.flatMap((function(e){return Object(I.a)(Object(I.a)({},e),{},{id:e.productId,name:e.productName,type:e.productType,density:e.productDensity})}))}))}))}))})).reduce((function(e,t){return e.find((function(e){return e.productId===t.productId}))||e.push(t),e}),[]),e.abrupt("return",M({vendor:x.integrationType.toLowerCase(),products:t}));case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();Object(a.useEffect)((function(){g({type:yC,payload:u})}),[u]);var z=function(e){g({type:dC,payload:e})},Z=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,V({vendor:x.integrationType,matchTypes:["Organization","CropZone","Field"]});case 2:200===(null===(t=e.sent)||void 0===t?void 0:t.status)&&(a=null===(n=t.data)||void 0===n?void 0:n.reduce((function(e,t){var n,a;"Simplot"===x.integrationType&&(e[t.cwfEntityId]=null!==(a=t.simplotEntityDescription)&&void 0!==a?a:t.simplotEntityId);return"Agrian"===x.integrationType&&(e[t.cwfEntityId]=null!==(n=t.agrianEntityDescription)&&void 0!==n?n:t.agrianEntityId),e}),{}),z(a));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),H=function(e){g({type:gC,payload:e})},W=function(e){g({type:vC,payload:e})},q=function(e){g({type:mC,payload:e})},J=function(e){m(e)},K=function(){var e=Object(Y.a)(G.a.mark((function e(){var n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s(o.epic.Integrations.submissionRunning,{vendor:t,submissionId:x.submissionId,flowId:c}),t===KO){e.next=7;break}return e.next=4,U();case 4:if(201===(null===(n=e.sent)||void 0===n?void 0:n.status)){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,D(x.submissionId,t);case 9:201===(null===(a=e.sent)||void 0===a?void 0:a.status)&&g({type:fC,payload:null===(r=a.data)||void 0===r?void 0:r.response});case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Q=function(){var e=Object(Y.a)(G.a.mark((function e(n){var a,r,i;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s(o.epic.Integrations.submissionRunning,{vendor:t,submissionId:x.submissionId,flowId:c}),e.next=3,D(x.submissionId,t,n);case 3:(a=e.sent)&&(r=a.status,i=a.data,g({type:fC,payload:Object(I.a)({httpStatusCode:r},i)}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),X=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,k(x.submissionId);case 2:if(201===(null===(t=e.sent)||void 0===t?void 0:t.status)){e.next=5;break}return e.abrupt("return",null);case 5:return e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),$=function(){var e=Object(Y.a)(G.a.mark((function e(){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return v&&t===$O&&(n={start:ag(v[0]),end:ag(v[1])}),e.next=3,P({seasonIds:x.cropSeasons.map((function(e){return e.id})),cropSeasonsDateRange:n,cropzoneIds:x.submissionFilterCropZoneIds,vendor:t.toLowerCase(),submissionId:x.submissionId});case 3:201===(null===(a=e.sent)||void 0===a?void 0:a.status)&&(r=a.data.id,g({type:OC,payload:r}));case 5:case"end":return e.stop()}var r}),e)})));return function(){return e.apply(this,arguments)}}(),ee=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n,a,r,c,i,o,s,l,d,u,b;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,A(null===x||void 0===x?void 0:x.submissionId);case 2:200===(null===(t=e.sent)||void 0===t?void 0:t.status)&&null!==t&&void 0!==t&&t.data&&(n=t.data.cwfData,a=n.data,r=n.extraData,a&&(l=a.farms,d=a.cropSeasons,u=a.cropSeasonsEndDate,b=a.cropSeasonsStartDate,g({type:uC,payload:{farms:l,extraData:r,cropSeasons:d,cropSeasonDateRange:b&&u?[b,u]:null,cropZoneIds:aC(l),tasks:lC(l),pastSubmissions:null===t||void 0===t||null===(c=t.data)||void 0===c?void 0:c.pastSubmissions,submissionResult:{status:null===t||void 0===t||null===(i=t.data)||void 0===i?void 0:i.status,errorMessage:null===t||void 0===t||null===(o=t.data)||void 0===o?void 0:o.errorMessage,response:null===t||void 0===t||null===(s=t.data)||void 0===s?void 0:s.response}}})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),te=function(e){g({type:hC,payload:e})},ne=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,S(null===x||void 0===x?void 0:x.submissionId);case 2:200===(null===(t=e.sent)||void 0===t?void 0:t.status)&&(n=t.data,g({type:xC,payload:n}),te(t.data.filter((function(e){return!e.removed&&e.overrideRegistrationNumber})).map((function(e){return Object(I.a)(Object(I.a)({},e),{},{overrideRegistrationNumber:rC(e.overrideRegistrationNumber)})}))));case 4:case"end":return e.stop()}var n}),e)})));return function(){return e.apply(this,arguments)}}(),ae=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w(null===x||void 0===x?void 0:x.submissionId,null===x||void 0===x?void 0:x.selectedProducts);case 2:return t=e.sent,e.abrupt("return",t);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),re=function(){var e=Object(Y.a)(G.a.mark((function e(n){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",T(t,n));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ce=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,N(null===x||void 0===x?void 0:x.submissionId);case 2:return 200===(null===(t=e.sent)||void 0===t?void 0:t.status)&&H(t.data),e.abrupt("return",t);case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ie=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,E(null===x||void 0===x?void 0:x.submissionId,t);case 2:return 200===(null===(n=e.sent)||void 0===n?void 0:n.status)&&H(null===x||void 0===x?void 0:x.fields.map((function(e){var n=t.find((function(t){return t.fieldId===e.fieldId&&t.cropZoneId===e.cropZoneId}));return n||e}))),e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),oe=function(e){g({type:bC,payload:e})},se=function(e,t){g({type:jC,payload:{open:e,cropzone:t}})},le=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(x.cropzoneToRemove){e.next=2;break}return e.abrupt("return");case 2:return t=x.cropzoneToRemove.id,e.next=5,_({submissionId:x.submissionId,cropZoneId:t});case 5:return e.next=7,ee();case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),de=function(e,t){g({type:pC,payload:{open:e,task:t}})},ue=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=x.submissionId,(n=x.taskToRemove)&&t){e.next=3;break}return e.abrupt("return");case 3:return a=n.cropZoneId,r=n.taskId,e.next=6,R({submissionId:t,cropZoneId:a,taskId:r});case 6:return e.next=8,ee();case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),be=function(){f(r,x.cropSeasons,x.farms,x.submissionFilterCropZoneIds,x.cropSeasonDateRange)},je=function(e){g({type:CC,payload:e})},pe=Object(a.useMemo)((function(){return{state:x,dispatch:g,submitIntegration:K,resubmitIntegration:X,startSubmission:$,loadSubmission:ee,resolveMatches:Z,isLoadingProductMatching:B,isLoading:L,setOpenConfirmationModal:oe,setOpenRemoveTaskModal:de,removeTaskFromCropzone:ue,setOpenRemoveCropzoneModal:se,removeCropzone:le,updateSubmissionFilterCropZoneIds:W,updateCropSeasons:q,updateInitialDateRange:J,setFormikDataBySubmission:be,getSubmissionProducts:ne,getVendorMaterials:re,setSubmissionProducts:ae,updateFields:H,getSubmissionFields:ce,setSubmissionFields:ie,setSelectedProducts:te,setOpenDrawerCounties:je,submitIntegrationWithExtraData:Q}}),[x,L,B]);return Object(y.jsx)(SC.Provider,{value:pe,children:n})};TC.defaultProps={children:null,integrationType:KO};var NC=TC,EC=function(){var e=nC(),t=e.createMatchingProductsV2,n=e.getMatches,r=e.loading,c=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t){var a,r,c,i;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=t.vendor,r=t.matchTypes,c=void 0===r?[]:r,i=qg[a.toLowerCase()],e.t0=i,e.next=5,n({vendor:a,matchTypes:c});case 5:return e.t1=e.sent,e.abrupt("return",e.t0.responseTranslator.call(e.t0,e.t1,"Product"));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[]),i=function(e){switch(e.source){case"MATERIAL":return{cwfEntityId:e.cwfId,simplotEntityId:e.vendorId,simplotEntityDescription:e.vendorPropertyName,type:e.type};case"COMMON":return{cwfEntityId:e.cwfId,simplotEntityId:e.vendorId,simplotEntityDescription:e.vendorPropertyName,type:e.type,from:e.simplotProduct.from,stdUnit:e.cwfProduct.stdUnit};default:return Object(I.a)(Object(I.a)({},e.cwfProduct),{},{id:e.cwfProduct.productId,name:e.cwfProduct.productName,type:e.cwfProduct.productType,density:e.cwfProduct.productDensity})}},o=function(e){return{materials:e.filter((function(e){return"MATERIAL"===e.source})).map(i),commonMaterials:e.filter((function(e){return"COMMON"===e.source})).map(i),createCustomMaterials:e.filter((function(e){return"CUSTOM"===e.source})).map(i)}},s=function(){var e=Object(Y.a)(G.a.mark((function e(n){var a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=n.vendor,r=n.matches,e.abrupt("return",t({vendor:a,products:o(r)}));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{getProductMatches:c,createProductMatches:s,loading:r}},wC="SET_MATCHES",_C="SET_FETCHED_MATCHES",RC=function(e,t){switch(t.type){case wC:return Object(I.a)(Object(I.a)({},e),{},{matches:t.payload});case _C:return Object(I.a)(Object(I.a)({},e),{},{matches:t.payload,fetchedMatches:t.payload});default:return e}},IC={matches:[],fetchedMatches:[],errorMessage:"",matchEntityType:""},DC=Object(a.createContext)(IC),kC=function(e){var t=e.integrationType,n=e.children,r=e.onCompleteMatch,c=Object(a.useReducer)(RC,Object(I.a)(Object(I.a)({},IC),{},{integrationType:t,children:n,matchEntityType:["Product"]})),i=Object(b.a)(c,2),o=i[0],s=i[1],l=EC(),d=l.getProductMatches,u=l.createProductMatches,j=l.loading,p=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];s({type:t?_C:wC,payload:e})},f=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==(t=o.matches.filter((function(e){return-1===o.fetchedMatches.findIndex((function(t){return e.cwfId===t.cwfId&&e.vendorId===t.vendorId}))}))).length){e.next=3;break}return e.abrupt("return",r());case 3:return e.next=5,u({vendor:KO,matches:t});case 5:return 201===(null===(n=e.sent)||void 0===n?void 0:n.status)&&r(),e.abrupt("return",n);case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),m=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d({vendor:KO,matchTypes:o.matchEntityType});case 2:200===(null===(t=e.sent)||void 0===t?void 0:t.status)&&p(t.data,!0);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),v=Object(a.useMemo)((function(){return{state:o,integrationContext:KO,dispatch:s,updateMatches:p,submitMatches:f,fetchMatches:m,isLoading:j}}),[o,j]);return Object(y.jsx)(DC.Provider,{value:v,children:n})};kC.defaultProps={children:null,integrationType:KO,onCompleteMatch:null};var LC=kC,FC=function(e){var t=e.progressBarSteps,n=e.selectPropertiesStep,r=e.integrationType,c=e.StepSelector,i=Object(a.useContext)(vh).state.submissionFlowId,o=lx(),s=o.events,l=o.triggerAnalyticsEvent,d=Object(a.useContext)(ac),u=Object(b.a)(d,1)[0].error,j=Object(a.useContext)(cx(r)),p=j.state,f=p.step,v=p.canGoNext,O=j.gotoStep,h=j.goForward,x=Object(a.useContext)(SC),g=x.state,C=g.submissionId,P=g.loadedSubmission,A=g.isReadOnly,S=x.startSubmission,T=x.setFormikDataBySubmission,N=x.loadSubmission,E=Object(a.useState)(!1),w=Object(b.a)(E,2),_=w[0],R=w[1],I=ox(),D=I.comingFromTaskEdition,k=I.comingFromView,L=Object(a.useState)(D),F=Object(b.a)(L,2),M=F[0],V=F[1],B=function(){switch(r){case $O:return 5;case KO:return 7;default:return 6}}();Object(a.useEffect)((function(){_&&!u&&(r===KO?h():O(B))}),[_]);var U=Object(a.useMemo)((function(){return 1===f}),[f]);return Object(a.useEffect)((function(){C&&U&&N()}),[C,U]),Object(a.useEffect)((function(){P&&D&&(l(s.epic.Integrations.submissionTaskRedirect,{vendor:r}),R(!1),S().then((function(){T(),R(!0),V(!1)}))),P&&k&&T()}),[P,D,k]),Object(y.jsx)(y.Fragment,{children:M?Object(y.jsx)("div",{className:"m-auto",children:Object(y.jsx)(m.Spinner,{})}):Object(y.jsxs)("div",{"data-testid":"base-integration",children:[Object(y.jsx)(lo,{hideCropSeasonDropdown:!0,disabled:!0,children:Object(y.jsx)(lo.Item,{title:"Integrations",value:r,isLast:!0})}),Object(y.jsxs)("div",{className:"z-50 min-h-50 h-full left-0 right-0 bottom-0 top-18 flex flex-col items-center ".concat(A&&"mt-5"),children:[!A&&Object(y.jsx)(Ph,{stepArray:t,currentStep:A?B:f,canGoNext:v&&f!==n,gotoStep:O}),Object(y.jsx)(eC,{integrationType:r,onCompleteMatch:function(){l(s.epic.Integrations.submissionPropertiesMatched,{vendor:r,flowId:i}),R(!1),S().then((function(){R(!0)}))},children:Object(y.jsx)(LC,{integrationType:r,onCompleteMatch:function(){l(s.epic.Integrations.ingestionRecommendationProductsMatch,{vendor:XO})},children:Object(y.jsx)(c,{fixedStep:A?B:f})})})]})]})})},MC=function(e){var t=e.className,n=e.isRequired,r=e.isDisabled,c=Object(Zi.h)(),i=c.values,o=c.setFieldValue,s=Object(a.useRef)(null),l=Object(a.useRef)(null),d=Object(a.useMemo)((function(){var e=cg(i.selectedCropSeasons);return{startDate:e.startDate,endDate:e.endDate}}),[i.selectedCropSeasons]),u=d.startDate,b=d.endDate;return Object(a.useEffect)((function(){!s.current&&i.seasonSingleDateRangeInitial?o("seasonSingleDateRange",i.seasonSingleDateRangeInitial):o("seasonSingleDateRange",[u,b]),null!==l.current&&i.selectedCropSeasons!==l.current&&(s.current=!0),i.selectedCropSeasons&&null===l.current&&(l.current=i.selectedCropSeasons)}),[u,b]),Object(y.jsxs)("div",{className:"w-full ".concat(t),children:[Object(y.jsx)("span",{className:"text-sm text-neutral-600",children:"Date Range"}),Object(y.jsx)(Qi,{control:m.DatePicker,id:"seasonSingleDateRange",name:"seasonSingleDateRange",required:n,disabled:r,isRangePicker:!0})]})};MC.defaultProps={className:""};var VC=MC,BC=function(e){var t=e.context,n=e.FooterComponent,r=lx(),c=r.events,i=r.triggerAnalyticsEvent,o=Ix(),s=o.setSelectedCropSeasons,l=o.selectedCropSeasons,d=Object(Zi.h)().values,u=Object(a.useContext)(SC),b=u.updateCropSeasons,j=u.updateInitialDateRange,p=Object(a.useContext)(cx(t)).goForward,f=dd(),v=f.cropSeasons,O=f.loaded;return O?Object(y.jsxs)("div",{className:"flex flex-col bg-white top-30 left-26 w-140 rounded-md mb-20 p-6 shadow-sm","data-testid":"submission-crop-season-selection",children:[Object(y.jsx)("h1",{className:"mb-6 ml-8 font-body text-base font-normal leading-8 tracking-tight text-left",children:"Add crop seasons for your submission."}),Object(y.jsxs)("div",{className:"w-2/3 ml-8 flex-1 h-full",children:[Object(y.jsx)(ng,{selectedActive:!1,allCropSeasonsData:v,csLoaded:O,onSelect:function(e){s(e)},isRequired:!0}),t===$O&&(null===l||void 0===l?void 0:l.length)>0&&Object(y.jsxs)("div",{className:"text-gray-600",children:["Season range:"," ".concat(Yd(d.cropSeasonsMinDate)," - ").concat(Yd(d.cropSeasonsMaxDate))]}),Object(y.jsx)("div",{className:"flex flex-row mt-8 mb-16 pb-6 max-w-80",children:Object(y.jsx)(VC,{isDisabled:t!==$O})})]}),n&&Object(y.jsx)(n,{onNext:function(){b(l),j(d.seasonSingleDateRange),i(c.epic.Integrations.submissionSeasonSelected,{vendor:t}),p()},nextDisabled:!l||0===l.length})]}):Object(y.jsx)("div",{className:"m-auto",children:Object(y.jsx)(m.Spinner,{})})};BC.defaultProps={FooterComponent:null};var UC=BC,zC=function(e){var t=e.size,n=void 0===t?20:t,a=e.color,r=void 0===a?"#CF3537":a;return Object(y.jsx)("svg",{width:n,height:n,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"error-icon",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 1.5C4.86 1.5 1.5 4.86 1.5 9C1.5 13.14 4.86 16.5 9 16.5C13.14 16.5 16.5 13.14 16.5 9C16.5 4.86 13.14 1.5 9 1.5ZM8.25 12.75V11.25H9.75V12.75H8.25ZM8.25 5.25V9.75H9.75V5.25H8.25Z",fill:r})})};zC.defaultProps={color:"#CF3537",size:20};var ZC=Object(a.memo)(zC),YC=n(798),HC=function(e){var t=e.submissionResult;switch(null===t||void 0===t?void 0:t.httpStatusCode){case 207:return Object(y.jsx)(vi,{size:50,color:"#d69e2e"});case 422:return Object(y.jsx)(ZC,{size:50,color:"#CF3537"});default:return Object(y.jsx)(ui.a,{icon:YC.a,size:"4x",className:"text-green-600 mb-5","data-testid":"check-circle"})}};HC.defaultProps={submissionResult:void 0};var GC=HC,WC=function(e){var t=e.disabled;return Object(y.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.1701 6.0687L13.8868 3.78537C13.2699 3.20591 12.3166 3.18083 11.6701 3.72703L4.17009 11.227C3.90073 11.4987 3.73301 11.8547 3.69509 12.2354L3.33676 15.7104C3.31403 15.9575 3.40262 16.2019 3.57843 16.377C3.73569 16.533 3.94859 16.62 4.17009 16.6187H4.24509L7.72009 16.302C8.10076 16.2641 8.45679 16.0964 8.72842 15.827L16.2284 8.32703C16.8345 7.68675 16.8084 6.67684 16.1701 6.0687ZM7.57009 14.6354L5.07009 14.8687L5.29509 12.3687L10.0034 7.7187L12.2534 9.9687L7.57009 14.6354ZM11.1034 6.6187L13.3368 8.85203L15.0034 7.22703L12.7284 4.95203L11.1034 6.6187Z",fill:"#8E9293",opacity:t?"0":"100"})})};WC.defaultProps={disabled:!1};var qC=function(){return Object(y.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{display:"inline-block"},children:[Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 4.91211L18 8.34068V13.0001H16V9.65947L10 7.08804L4 9.65947V13.0001H2V8.34068L10 4.91211Z",fill:"#696F88"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.5 10H13.5V13H11.5V12H8.5V13H6.5V10Z",fill:"#696F88"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18 4.17558V13H16V4H17C16 4 16 3.99902 16 3.99803L16 3.99603L16 3.99194L16.0001 3.9834L16.0006 3.96489C16.001 3.95192 16.0017 3.93768 16.0027 3.92225C16.0048 3.89143 16.0082 3.85564 16.014 3.81561C16.0254 3.73572 16.0459 3.63751 16.0826 3.52752C16.1571 3.30407 16.2957 3.04006 16.5429 2.79289C17.0466 2.28921 17.8459 2 19 2C20.1541 2 20.9534 2.28921 21.4571 2.79289C21.7043 3.04006 21.8429 3.30407 21.9174 3.52752C21.9541 3.63751 21.9746 3.73572 21.986 3.81561C21.9918 3.85564 21.9952 3.89143 21.9973 3.92225C21.9983 3.93768 21.999 3.95192 21.9994 3.96489L21.9999 3.9834L22 3.99194L22 3.99603L22 3.99803C22 3.99902 22 4 21 4H22V13H20V4.17558C19.9688 4.15651 19.9181 4.13095 19.84 4.10493C19.6836 4.0528 19.4197 4 19 4C18.5803 4 18.3164 4.0528 18.16 4.10493C18.0819 4.13095 18.0312 4.15651 18 4.17558Z",fill:"#696F88"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 16H2V14H22V16Z",fill:"#696F88"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 19H2V17H22V19Z",fill:"#696F88"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 22H2V20H22V22Z",fill:"#696F88"})]})},JC=function(){return Object(y.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{display:"inline-block"},children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.313 4.31602L20.083 6.08602L15.103 11.066H13.333V9.29602L18.313 4.31602ZM21.583 3.87602L20.523 2.81602C20.323 2.61602 20.013 2.61602 19.813 2.81602L18.963 3.66602L20.733 5.43602L21.583 4.58602C21.783 4.38602 21.783 4.06602 21.583 3.87602ZM5 3H7V5H16.1667L14.2642 7H7V17L17 17V10.8008L19 9V17H21V19H19V21H17V19L7 19V21H5V19H3V17H5V7H3V5L5 5V3ZM10 9C9.44772 9 9 9.44772 9 10V14C9 14.5523 9.44772 15 10 15H14C14.5523 15 15 14.5523 15 14V12H12V9H10Z",fill:"#696F88"})})},KC=function(){return Object(y.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("path",{d:"M14.0794 5.69593C14.0794 7.73714 11.9674 9.39187 11.9674 9.39187C11.9674 9.39187 9.85547 7.73714 9.85547 5.69593C9.85547 3.65473 11.9674 2 11.9674 2C11.9674 2 14.0794 3.65473 14.0794 5.69593Z",stroke:"#696F88",strokeWidth:"2",strokeLinejoin:"round"}),Object(y.jsx)("path",{d:"M16.6614 11.4107C15.2181 12.8541 12.5546 12.5308 12.5546 12.5308C12.5546 12.5308 12.2313 9.86732 13.6747 8.42397C15.118 6.98061 17.7815 7.30393 17.7815 7.30393C17.7815 7.30393 18.1048 9.96738 16.6614 11.4107Z",stroke:"#696F88",strokeWidth:"2",strokeLinejoin:"round"}),Object(y.jsx)("path",{d:"M16.6614 16.6744C15.2181 18.1178 12.5546 17.7944 12.5546 17.7944C12.5546 17.7944 12.2313 15.131 13.6747 13.6876C15.118 12.2443 17.7815 12.5676 17.7815 12.5676C17.7815 12.5676 18.1048 15.2311 16.6614 16.6744Z",stroke:"#696F88",strokeWidth:"2",strokeLinejoin:"round"}),Object(y.jsx)("path",{d:"M7.33857 11.4107C8.78192 12.8541 11.4454 12.5308 11.4454 12.5308C11.4454 12.5308 11.7687 9.86732 10.3253 8.42397C8.88198 6.98062 6.21853 7.30393 6.21853 7.30393C6.21853 7.30393 5.89522 9.96738 7.33857 11.4107Z",stroke:"#696F88",strokeWidth:"2",strokeLinejoin:"round"}),Object(y.jsx)("path",{d:"M7.33857 16.6744C8.78192 18.1178 11.4454 17.7944 11.4454 17.7944C11.4454 17.7944 11.7687 15.131 10.3253 13.6876C8.88198 12.2443 6.21853 12.5676 6.21853 12.5676C6.21853 12.5676 5.89522 15.2311 7.33857 16.6744Z",stroke:"#696F88",strokeWidth:"2",strokeLinejoin:"round"}),Object(y.jsx)("path",{d:"M11.9678 10.4434L11.9678 22.0592",stroke:"#696F88",strokeWidth:"2",strokeLinecap:"round"})]})},QC=function(e){var t=e.fill;return Object(y.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.75 3.75V14.25H14.25V9H15.75V14.25C15.75 15.075 15.075 15.75 14.25 15.75H3.75C2.9175 15.75 2.25 15.075 2.25 14.25V3.75C2.25 2.925 2.9175 2.25 3.75 2.25H9V3.75H3.75ZM10.5 3.75V2.25H15.75V7.5H14.25V4.8075L6.8775 12.18L5.82 11.1225L13.1925 3.75H10.5Z",fill:t})})};QC.defaultProps={fill:"#696F88"};var XC=QC,$C=function(e){var t,n=e.submissionResult,a=e.integrationType,r=e.comingFromView;switch(null===n||void 0===n?void 0:n.httpStatusCode){case 207:return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("h1",{className:"mt-5 text-2xl leading-8 font-semibold",style:{marginBottom:"8px"},children:"Your data was partially sent due to a vendor integration issue."}),Object(y.jsx)("div",{className:" w-1/2 text-center",style:{marginBottom:"32px"},children:Object(y.jsx)("p",{className:"font-normal text-sm",children:"Your records were successfully created in this submission. However, some errors occurred with certain records. Please review the error reports here for more details."})})]});case 422:return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("h1",{className:"mt-5 text-2xl leading-8 font-semibold",style:{marginBottom:"8px"},children:"Error reported in this submission."}),Object(y.jsx)("div",{className:" w-1/2 text-center",style:{marginBottom:"32px"},children:Object(y.jsxs)("p",{className:"font-normal text-sm",children:["We were unable to send your data due to an integration error with the vendor ",a,". Please verify the errors in submission details."]})})]});default:return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("h1",{className:"text-2xl leading-8 font-semibold",style:{marginBottom:"8px"},children:["Your data has been ",r?"re":"","submitted!"]}),Object(y.jsx)("div",{className:" w-1/2 text-center",style:{marginBottom:"32px"},children:Object(y.jsx)("p",{className:"font-normal text-sm",children:a===$O?Object(y.jsxs)(y.Fragment,{children:["Your pesticide usage reports have been successfully submitted to CalAg. If you need to edit any part of your submission you can do so at the"," ",Object(y.jsx)("a",{target:"_blank",href:null!==(t="https://calagtest.calicosol.com")?t:"https://calagtest.calicosol.com",rel:"noreferrer",className:"text-green-700",children:Object(y.jsxs)("div",{className:"inline-flex gap-1 items-center",children:["CalAg website ",Object(y.jsx)(XC,{fill:"#0C612C"})]})})]}):Object(y.jsxs)(y.Fragment,{children:["Your submission has been sent to ",a,Object(y.jsx)("br",{}),"You can view the submitted properties via the"," ",a,"portal."]})})})]})}};$C.defaultProps={submissionResult:void 0,integrationType:"",comingFromView:""};var ey=$C,ty=function(){var e=Object(a.useContext)(SC).state,t=e.integrationType,n=e.farms,r=e.submissionId,c=e.submissionResult,i=ox().comingFromView,o=Object(p.h)(),s=Object(a.useMemo)((function(){var e=Fh(n);return Object(v.a)(new Map(null===e||void 0===e?void 0:e.flatMap((function(e){var t;return null===(t=e.tasks)||void 0===t?void 0:t.map((function(e){return[e.taskId,e]}))}))).values()).length}),[n]);lx({onMountTriggerEvent:{event:Ee.epic.Integrations.submissionCompleted,data:{vendor:t,tasksLength:s,submissionId:r}}});return Object(y.jsx)("div",{className:"w-full h-full bg-white flex flex-col px-6 py-4 rounded-xl font-body","data-testid":"success-page",children:Object(y.jsx)("div",{className:"flex justify-center  flex-col h-full",children:Object(y.jsxs)("div",{className:"flex text-center items-center flex-col justify-center ",children:[Object(y.jsx)(GC,{submissionResult:c}),Object(y.jsx)(ey,{submissionResult:c,integrationType:t,comingFromView:i}),Object(y.jsxs)("div",{className:"flex justify-center",children:[(207===(null===c||void 0===c?void 0:c.httpStatusCode)||422===(null===c||void 0===c?void 0:c.httpStatusCode))&&Object(y.jsx)("div",{className:"mr-2",children:Object(y.jsx)("a",{href:"".concat(Cc.integrations,"/").concat(t,"/submission/").concat(c.id),rel:"noreferrer",children:Object(y.jsx)(m.Button,{id:"return-viewpage-button",type:"primary",children:"View Submission Details"})})}),Object(y.jsx)(m.Button,{id:"return-mainpage-button",type:207===(null===c||void 0===c?void 0:c.httpStatusCode)||422===(null===c||void 0===c?void 0:c.httpStatusCode)?"outline":"primary",onClick:function(){return o.push("".concat(Cc.integrations,"/").concat(t,"/landing-page"))},children:"Go to Submissions History"})]})]})})})},ny=function(e){var t=e.ReviewComponent,n=e.FooterComponent,r=e.needSolveMatch,c=e.needFields,i=Object(a.useState)(!0),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useContext)(SC),u=d.loadSubmission,j=d.resolveMatches,p=d.getSubmissionFields,f=d.state.submissionDone;return Object(a.useEffect)((function(){function e(){return(e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u();case 2:l(!1);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function t(){return(t=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,j();case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function n(){return(n=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,p();case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}f||(r&&function(){t.apply(this,arguments)}(),c&&function(){n.apply(this,arguments)}(),function(){e.apply(this,arguments)}())}),[]),Object(y.jsx)(y.Fragment,{children:f?Object(y.jsx)(ty,{}):t&&Object(y.jsx)(t,{FooterComponent:n,loading:s})})};ny.defaultProps={FooterComponent:null,needSolveMatch:!0,needFields:!1};var ay=ny,ry=function(e){var t=e.size,n=void 0===t?18:t,a=e.color,r=void 0===a?"#319795":a;return Object(y.jsx)("svg",{width:n,height:n,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"info-icon",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 1.5C4.86 1.5 1.5 4.86 1.5 9C1.5 13.14 4.86 16.5 9 16.5C13.14 16.5 16.5 13.14 16.5 9C16.5 4.86 13.14 1.5 9 1.5ZM8.25 5.25V6.75H9.75V5.25H8.25ZM8.25 8.25V12.75H9.75V8.25H8.25ZM3 9C3 12.3075 5.6925 15 9 15C12.3075 15 15 12.3075 15 9C15 5.6925 12.3075 3 9 3C5.6925 3 3 5.6925 3 9Z",fill:r})})};ry.defaultProps={color:"#319795",size:18};var cy=Object(a.memo)(ry),iy=function(e){var t=e.title,n=e.message,a=e.color,r=e.icon;return Object(y.jsxs)("div",{className:"w-full flex flex-row mb-2 p-4 ".concat(a),children:[r,Object(y.jsxs)("div",{className:"flex flex-col",children:[Object(y.jsx)("p",{className:"text-base",children:t}),Object(y.jsx)("p",{className:"font-normal text-sm text-gray-600 whitespace-pre-line",children:n})]})]})};iy.defaultProps={icon:null};var oy=iy,sy=function(e){var t=e.submissionResult||{},n=t.status,a=t.errorMessage,r=t.response;switch(n){case ah:return Object(y.jsx)(oy,{title:"Submission Successful",message:"This data has already been submitted, you can view submitted information at this screen..",color:"bg-green-200",icon:Object(y.jsx)("div",{className:"mr-3 w-fit h-fit p-1 rounded-full bg-green-600",children:Object(y.jsx)(m.Icon,{size:12,icon:"checkmark",color:"#FFFFFF"})})});case th:return Object(y.jsx)(oy,{title:"Submission Pending",message:"This data were not submitted, you can review included information.",color:"bg-teal-100",icon:Object(y.jsx)("div",{className:"mr-3",children:Object(y.jsx)(cy,{size:24,color:"#319795"})})});case nh:return Object(y.jsx)(oy,{title:"Submission in Progress",message:"We are currently processing your submission. Come back later to view final submission status.",color:"bg-blue-10",icon:Object(y.jsx)("div",{className:"mr-3",children:Object(y.jsx)(cy,{size:24,color:"#0078CD"})})});case rh:return r?Object(y.jsx)(oy,{title:"Product Errors in Submission",message:"This data has already been submitted, however we've identified some errors in the products you submitted. Review submitted information and try again.",color:"bg-yellow-100",icon:Object(y.jsx)("div",{className:"mr-3",children:Object(y.jsx)(vi,{size:20,color:"#d69e2e"})})}):Object(y.jsx)(oy,{title:"Error",message:a,color:"bg-red-100",icon:Object(y.jsx)("div",{className:"mr-3",children:Object(y.jsx)(ZC,{size:24,color:"#CF3537"})})});default:return null}};sy.defaultProps={submissionResult:{}};var ly=sy,dy=function(e){var t=e.subtitle,n=e.integrationType,r=e.submissionResult,c=e.RightComponent,i=r||{},o=i.status,s=i.response,l=lx(),d=l.events,u=l.triggerAnalyticsEvent,j=Object(a.useState)(!1),f=Object(b.a)(j,2),v=f[0],O=f[1],h=Object(a.useState)(!1),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useState)(!1),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(p.h)(),E=Object(a.useContext)(SC),w=E.state,_=w.isReadOnly,R=w.submissionId,I=E.setOpenConfirmationModal,D=E.resubmitIntegration,k=ox().redirectToEdit;Object(a.useEffect)((function(){if(n===$O)return C(o===th),void T(!1);switch(o){case rh:if(s){C(!0),T(!1);break}C(!0),T(!0);break;case ah:case th:C(!0),T(!1);break;default:C(!1),T(!1)}}),[o,s,n]);var L=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(u(d.epic.Integrations.submissionEditClick,{vendor:n,status:o}),o!==th){e.next=3;break}return e.abrupt("return",k(R,n));case 3:return O(!0),e.next=6,D();case 6:if(t=e.sent,O(!1),!t){e.next=11;break}return a=t.data.id,e.abrupt("return",k(a,n));case 11:return e.abrupt("return",null);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)(y.Fragment,{children:_?Object(y.jsxs)("div",{className:"border-b-1 mb-2",children:[Object(y.jsxs)("div",{className:"w-full flex h-10 mb-4 items-center font-semibold justify-between",children:[Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)(m.Button,{"data-testid":"back-button-header",circular:!0,style:{borderRadius:999,marginRight:"0.5rem",height:"2.5rem"},id:"return-history-button",type:"outline",onClick:function(){return N.push("".concat(Cc.integrations,"/").concat(n,"/landing-page"))},children:Object(y.jsx)(m.Icon,{icon:"chevron-left",color:"#718096"})}),Object(y.jsx)("p",{className:"text-2xl ml-4",children:"View Submission"})]}),Object(y.jsxs)("div",{className:"flex flex-row w-2/5 justify-end",children:[S&&Object(y.jsx)(m.Button,{"data-testid":"retry-button-header",id:"redirect-retry-button",type:"outline",style:{height:"2.5rem",marginRight:"0.5rem",flex:1,maxWidth:"250px"},onClick:function(){u(d.epic.Integrations.submissionRetryClick,{vendor:n}),I(!0)},children:"Retry Submission"}),g&&!v&&Object(y.jsx)(m.Button,{"data-testid":"edit-button-header",id:"redirect-retry-button",type:"primary",style:{height:"2.5rem",flex:1,maxWidth:"250px"},onClick:L,children:"".concat(n===$O?"Resume":"Edit and Resubmit")})]})]}),Object(y.jsx)(ly,{submissionResult:r})]}):Object(y.jsxs)("div",{className:"mb-4 flex flex-row justify-between border-b-1",children:[Object(y.jsxs)("div",{className:"flex flex-col",children:[Object(y.jsx)("div",{className:"text-xl leading-7 font-semibold text-neutral-1000 mb-2",children:"Review and Submit"}),Object(y.jsx)("p",{className:"text-sm leading-6 text-neutral-70 font-normal pb-4",children:t})]}),c&&Object(y.jsx)(c,{})]})})};dy.defaultProps={subtitle:"Review selected data before submitting",RightComponent:void 0,integrationType:"",submissionResult:{}};var uy=dy,by=function(){var e=dd().cropSeasons,t=Object(a.useContext)(SC).state,n=t.orgId,r=t.integrationType,c=t.submissionResult,i=t.cropSeasons,o=t.matches,s=Object(a.useState)(),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(),p=Object(b.a)(j,2),f=p[0],v=p[1];Object(a.useEffect)((function(){var t=null===i||void 0===i?void 0:i.map((function(t){var n=null===e||void 0===e?void 0:e.find((function(e){return e.id===t.id}));return Object(I.a)(Object(I.a)({},n),t)}));t.length&&(u(new Date(Sx(t))),v(new Date(Tx(t))))}),[i,e]);var O=null===o||void 0===o?void 0:o[n],h={year:"numeric",month:"short",day:"2-digit"};return Object(y.jsxs)("div",{"data-testid":"top-header",children:[Object(y.jsx)(uy,{integrationType:r,submissionResult:c}),Object(y.jsx)("div",{className:"w-full flex h-15 items-center font-semibold",children:Object(y.jsxs)("p",{className:"text-2xl",children:[r," Submission"," ",(new Date).toLocaleDateString("en-Us",h)]})}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsxs)("div",{className:"flex w-full h-full",style:{justifyContent:"space-between"},children:[Object(y.jsxs)("div",{className:"flex h-full",children:[Object(y.jsxs)("div",{className:"h-full",children:[Object(y.jsxs)("p",{className:"font-thin text-xs text-gray-600",children:[r," Organization"]}),Object(y.jsx)("div",{className:"h-full",children:Object(y.jsx)("div",{className:"w-full items-center",children:Object(y.jsx)("p",{className:"text-2xl pr-2 w-auto overflow-x-auto",children:O})})})]}),Object(y.jsxs)("div",{className:"h-full ml-10",children:[Object(y.jsx)("p",{className:"font-thin text-xs text-gray-600",children:"Crop Season(s) "}),Object(y.jsx)("div",{children:Object(y.jsx)(m.TagCloud,{"data-testid":"crops",children:null===i||void 0===i?void 0:i.map((function(e){return Object(y.jsx)(m.Tag,{color:"#696F88",children:e.name},e.id)}))})})]})]}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"flex flex-col mr-10 ",children:[Object(y.jsx)("p",{className:"font-thin text-xs text-gray-600",children:"Start Date"}),Object(y.jsx)("p",{className:"text-2xl font-normal pr-2",children:null===d||void 0===d?void 0:d.toLocaleDateString("en-Us",h)})]}),Object(y.jsxs)("div",{className:"flex flex-col mr-40",children:[Object(y.jsx)("p",{className:"font-thin text-xs text-gray-600",children:"End Date"}),Object(y.jsx)("p",{className:"text-2xl font-normal pr-2",children:null===f||void 0===f?void 0:f.toLocaleDateString("en-Us",h)})]})]})]})})]})},jy=function(e){var t=e.handleClose,n=Object(a.useContext)(SC),r=n.state.resubmitEnabled,c=n.submitIntegration;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"mr-5",children:Object(y.jsx)(m.Button,{type:"outline",id:"cancel-button",onClick:t,children:"Cancel"})}),Object(y.jsx)("div",{children:Object(y.jsx)(m.Button,{type:"primary",id:"submit-button",onClick:c,children:r?"Resubmit":"Submit"})})]})},py=function(){var e=Object(a.useContext)(SC),t=e.state,n=t.resubmitEnabled,r=t.openConfirmationModal,c=t.integrationType,i=e.isLoading,o=e.isLoadingProductMatching,s=e.setOpenConfirmationModal,l=Object(a.useContext)(ac),d=Object(b.a)(l,1)[0].error,u=function(){s(!1)};return Object(a.useEffect)((function(){d&&u()}),[d]),Object(y.jsx)(ao,{open:r,type:"buttonless",style:{paddingLeft:"2rem"},children:Object(y.jsxs)("div",{className:"flex flex-line w-full mt-2 justify-between","data-testid":"confirmation-modal",children:[o&&Object(y.jsxs)("div",{className:"pr-12 w-full h-40",children:[Object(y.jsxs)("p",{className:"text-center",children:["Matching your products in Cropwise Financials to ",c]}),Object(y.jsx)(m.Spinner,{})]}),i&&Object(y.jsxs)("div",{className:"pr-12 w-full h-40",children:[Object(y.jsx)("p",{className:"text-center",children:n?"Resubmiting":"Generating Final Submission"}),Object(y.jsx)(m.Spinner,{})]}),!i&&!o&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"flex mr-4",children:Object(y.jsx)(bg,{})}),Object(y.jsxs)("div",{className:"flex flex-col pr-10",style:{flexGrow:1},children:[Object(y.jsx)("div",{className:"flex flex-row justify-items-center pb-4",children:Object(y.jsxs)("h3",{className:"font-bold text-lg leading-6 text-gray-900 w-full",children:["Do you want to ",n?"resubmit":"submit"," this data?"]})}),Object(y.jsxs)("div",{className:"flex flex-col mb-4",children:[Object(y.jsxs)("p",{children:["Are you sure you want to"," ",n?"resubmit":"submit"," this data to"," ",c,"?"]}),Object(y.jsx)("p",{children:"(You can complete a new submission at any time) "})]}),Object(y.jsx)("div",{className:"mt-5 flex flex-row items-center justify-end w-full",children:Object(y.jsx)(jy,{handleClose:u})})]})]})]})})},fy=function(){return Object(y.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.5 3.68408L13.5 6.25551V9.75006H12V7.24461L7.5 5.31603L3 7.24461V9.75006H1.5V6.25551L7.5 3.68408Z",fill:"#696F88"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.875 7.5H10.125V9.75H8.625V9H6.375V9.75H4.875V7.5Z",fill:"#696F88"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13.5 3.13169V9.75H12V3H12.75C12 3 12 2.99926 12 2.99852L12 2.99702L12 2.99396L12.0001 2.98755L12.0004 2.97367C12.0007 2.96394 12.0013 2.95326 12.002 2.94169C12.0036 2.91857 12.0062 2.89173 12.0105 2.86171C12.019 2.80179 12.0344 2.72814 12.0619 2.64564C12.1178 2.47805 12.2218 2.28004 12.4072 2.09467C12.7849 1.71691 13.3844 1.5 14.25 1.5C15.1156 1.5 15.7151 1.71691 16.0928 2.09467C16.2782 2.28004 16.3822 2.47805 16.4381 2.64564C16.4656 2.72814 16.481 2.80179 16.4895 2.86171C16.4938 2.89173 16.4964 2.91857 16.498 2.94169C16.4987 2.95326 16.4993 2.96394 16.4996 2.97367L16.4999 2.98755L16.5 2.99396L16.5 2.99702L16.5 2.99852C16.5 2.99926 16.5 3 15.75 3H16.5V9.75H15V3.13169C14.9766 3.11739 14.9386 3.09821 14.88 3.0787C14.7627 3.0396 14.5647 3 14.25 3C13.9353 3 13.7373 3.0396 13.62 3.0787C13.5614 3.09821 13.5234 3.11739 13.5 3.13169Z",fill:"#696F88"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.5 12H1.5V10.5H16.5V12Z",fill:"#696F88"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.5 14.25H1.5V12.75H16.5V14.25Z",fill:"#696F88"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.5 16.5H1.5V15H16.5V16.5Z",fill:"#696F88"})]})},my=function(e){var t=e.farm,n=e.selectFarm,a=e.index;return Object(y.jsxs)(pu,{className:"flex flex-row w-auto p-2 text-xl text-gray-900 hover:bg-info-light-blue hover:text-info-dark-blue",onClick:function(){n(a)},children:[Object(y.jsx)(fy,{color:"#696F88"}),Object(y.jsx)("span",{className:"ml-3",children:t.name})]})},vy=function(e){var t=e.farms,n=e.selectFarm,r=e.onBlur;return Object(a.useEffect)((function(){return document.addEventListener("mousedown",r),function(){return document.removeEventListener("mousedown",r)}}),[]),Object(y.jsx)("div",{"data-testid":"farm-option-list",className:"absolute mt-1 ml-2 w-56 py-2 rounded bg-white shadow z-50",children:t.map((function(e,t){return Object(y.jsx)(my,{selectFarm:n,farm:e,index:t},e.id)}))})},Oy=function(e){var t=e.farms,n=e.farm,r=e.selectFarm,c=e.selectFarmTextSize,i=Object(a.useState)(!1),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useRef)();return Object(y.jsxs)("div",{className:"flex items-center justify-center farm-select",children:[Object(y.jsxs)("div",{className:"flex flex-row items-center text-2xl font-semibold mr-10",children:[Object(y.jsx)(fy,{color:"#363948"}),Object(y.jsx)("span",{style:{color:"#363948"},className:"ml-2 ","data-testid":"farm-name",children:null===n||void 0===n?void 0:n.name})]}),(null===t||void 0===t?void 0:t.length)>1&&Object(y.jsx)("div",{className:"relative flex-1",children:Object(y.jsxs)(pu,{className:"bg-transparent text-info-dark-blue","data-testid":"clickable-div",ref:d,onClick:function(){return l((function(e){return!e}))},children:[Object(y.jsxs)("div",{className:"flex flex-row items-center ".concat(c),children:[Object(y.jsx)("span",{className:"ml-2",children:"Jump to other farms"}),Object(y.jsx)("span",{className:"yield-select-arrow w-8 h-7 selected-icon"})]}),s&&Object(y.jsx)(vy,{"data-testid":"farm-option-list",farms:t,selectFarm:r,onBlur:function(e){d.current.contains(e.target)||l(!1)}})]})})]})};Oy.defaultProps={selectFarmTextSize:"text-xl"};var hy=Oy,xy=function(e){var t=e.farm,n=e.selectFarm,r=Object(a.useContext)(SC).state.farms,c=Object(a.useMemo)((function(){var e;return null===t||void 0===t||null===(e=t.fields)||void 0===e?void 0:e.reduce((function(e,t){var n,a;return e.cropzones+=null===(n=t.cropzones)||void 0===n?void 0:n.length,e.applications+=null===(a=t.cropzones)||void 0===a?void 0:a.reduce((function(e,t){return e+t.tasks.length}),0),e}),{applications:0,cropzones:0})}),[t]);return 0===(null===c||void 0===c?void 0:c.cropzones)?null:Object(y.jsxs)("div",{className:"flex",style:{justifyContent:"space-between"},"data-testid":"submission-summary-farms",children:[Object(y.jsx)(hy,{farm:t,selectFarm:n,farms:r}),Object(y.jsx)("div",{className:"flex",children:Object(y.jsx)("div",{className:"h-full",children:Object(y.jsx)("div",{children:Object(y.jsxs)(m.TagCloud,{children:[Object(y.jsxs)(m.Tag,{color:"#D60469",children:[null===c||void 0===c?void 0:c.cropzones," Crop Zone(s)"]},"cropzones-length"),Object(y.jsxs)(m.Tag,{color:"#2B9C92",children:[null===c||void 0===c?void 0:c.applications," Application(s)"]},"applications-length")]})})})})]})},gy=function(e){var t=e.product,n=Object(y.jsxs)("div",{className:"flex flex-col justify-start text-left w-40","data-testid":"product-name-hover",children:[Object(y.jsx)("span",{className:"mb-1 overflow-hidden truncate",children:t.productName}),Object(y.jsx)("span",{className:"text-xs text-gray-600",children:t.manufacturerName})]});return t.productName.length>24?Object(y.jsx)(m.Popup,{enableHover:!0,position:"top",align:"center",hasArrow:!0,bgColor:"#232630",trigger:n,children:Object(y.jsxs)("div",{className:"gr-w-64 text-xs text-white","data-testid":"product-name-hover-content",children:[t.productName,Object(y.jsx)("br",{}),t.manufacturerName]})}):n},Cy=function(e){var t=e.products,n=e.errors,r=lx(),c=r.events,i=r.triggerAnalyticsEvent,o=ox().redirectToTask,s=Object(a.useContext)(SC).state,l=s.submissionId,d=s.integrationType,u=s.isReadOnly,j=Object(a.useState)({}),p=Object(b.a)(j,2),f=p[0],v=p[1];return Object(a.useEffect)((function(){var e={};n.forEach((function(t){var n=t.taskIds.reduce((function(e,n){return Object(I.a)(Object(I.a)({},e),{},Object(et.a)({},n,t))}),{});e=Object(I.a)(Object(I.a)({},n),e)})),v(e)}),[n]),Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[n&&Object(y.jsx)(m.Table.Cell,{}),Object(y.jsx)(m.Table.Cell,{children:"Date"}),Object(y.jsx)(m.Table.Cell,{children:"Cropwise Product"}),Object(y.jsx)(m.Table.Cell,{children:"Product Type"}),Object(y.jsx)(m.Table.Cell,{children:"Application Method"}),Object(y.jsx)(m.Table.Cell,{children:"Rate (per acre)"}),Object(y.jsx)(m.Table.Cell,{children:"Total Applied"}),!u&&Object(y.jsx)(m.Table.Cell,{})]}),null===t||void 0===t?void 0:t.map((function(e){return Object(y.jsxs)(m.Table.Row,{className:n&&f[e.taskId]?"bg-red-100":"",children:[n&&Object(y.jsx)(m.Table.Cell,{children:f[e.taskId]&&Object(y.jsx)("span",{className:"bg-red-200 text-red-800 rounded-md text-xs p-2 font-semibold","data-testid":"span-error-message",children:f[e.taskId].errorMessage})}),Object(y.jsx)(m.Table.Cell,{children:new Date(e.appliedDate).toLocaleDateString()}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(gy,{product:e})}),Object(y.jsx)(m.Table.Cell,{children:e.productType}),Object(y.jsx)(m.Table.Cell,{children:e.applicationMethod}),Object(y.jsxs)(m.Table.Cell,{children:[e.ratePerArea.toFixed(3)," ",e.ratePerAreaUnit]}),Object(y.jsxs)(m.Table.Cell,{children:[e.quantity.toFixed(3)," ",e.quantityUnit]}),!u&&Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)(m.Button,{type:"button",className:"w-full flex flex-row text-xs",onClick:function(){return function(e){i(c.epic.Integrations.submissionTaskClick,{vendor:d}),o(e,l,d)}(e)},children:[Object(y.jsx)("div",{className:"text-right",children:Object(y.jsx)(mg,{})}),Object(y.jsx)("span",{className:"ml-1",children:"Edit"})]})})]},e.productId)}))]})};Cy.defaultProps={products:[],errors:[]};var yy=Cy,Py=function(){return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"42",height:"14",viewBox:"0 0 42 14",fill:"none",children:Object(y.jsx)("path",{d:"M31.2892 5.34282H0V8.65861H31.2892V13.6323L41.6842 7.00072L31.2892 0.369141V5.34282Z",fill:"#696F88"})})},Ay=function(){return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 1.5C4.86 1.5 1.5 4.86 1.5 9C1.5 13.14 4.86 16.5 9 16.5C13.14 16.5 16.5 13.14 16.5 9C16.5 4.86 13.14 1.5 9 1.5ZM3 9C3 12.3075 5.6925 15 9 15C12.3075 15 15 12.3075 15 9C15 5.6925 12.3075 3 9 3C5.6925 3 3 5.6925 3 9ZM5.25 8.25V9.75H12.75V8.25H5.25Z",fill:"#696F88"})})},Sy=function(e){var t=e.fields,n=Object(a.useContext)(SC),r=n.state,c=r.farms,i=r.matches,o=r.isReadOnly,s=r.integrationType,l=r.submissionResult,d=n.setOpenRemoveCropzoneModal,u=Object(a.useMemo)((function(){return null===c||void 0===c?void 0:c.reduce((function(e,t){return e+t.fields.reduce((function(e,t){return e+t.cropzones.length}),0)}),0)}),[c]),b=Object(a.useMemo)((function(){var e;return null===l||void 0===l||null===(e=l.response)||void 0===e?void 0:e.details.filter((function(e){return e.status===rh})).map((function(e){var t,n,a;return{errorMessage:e.errorMessage,taskIds:null===(t=e.responseData)||void 0===t?void 0:t.taskIds,cropZoneId:null===(n=e.vendorPayload)||void 0===n?void 0:n.cropZoneId,internalRecordId:null===(a=e.responseData)||void 0===a?void 0:a.internalRecordId}}))}),[l]);return Object(y.jsx)(y.Fragment,{children:null===t||void 0===t?void 0:t.map((function(e){var t;return Object(y.jsx)("div",{"data-testid":"field-summary-table",className:"w-full mb-10",id:e.id,children:Object(y.jsx)("div",{className:"w-full",children:null===e||void 0===e||null===(t=e.cropzones)||void 0===t?void 0:t.map((function(t){var n,a,r=(null===t||void 0===t?void 0:t.area)||t.boundaryArea,c=function(e){var t;return null===(t=e.tasks)||void 0===t?void 0:t.flatMap((function(t){return t.products.map((function(n){return Object(I.a)(Object(I.a)({},n),{},{taskId:t.taskId,cropSeasonsIds:(a=e.cropSeasons,null===a||void 0===a?void 0:a.map((function(e){return e.id})))});var a}))}))}(t),l=s===QO?e.id:t.id;return Object(y.jsxs)("div",{className:"mb-10",children:[Object(y.jsxs)("div",{className:"flex flex-row mb-3 leading-loose items-center",children:[Object(y.jsxs)("div",{className:"flex-column",children:[Object(y.jsx)("p",{className:"font-thin text-xs text-gray-600",children:"Cropwise"}),Object(y.jsxs)("div",{className:"font-bold mr-4","data-testid":"cropzone-name",children:[e.name," / ",t.name," - ",null===r||void 0===r?void 0:r.toFixed(2)," ac"]})]}),Object(y.jsx)("div",{className:"mt-6",children:Object(y.jsx)(Py,{})}),Object(y.jsxs)("div",{className:"flex-column",children:[Object(y.jsx)("p",{className:"font-thin text-xs text-gray-600 ml-4 mr-4",children:s}),Object(y.jsx)("div",{className:"font-bold ml-4 mr-4",children:null!==(n=null===i||void 0===i?void 0:i[l])&&void 0!==n?n:"No Matching Found in ".concat(s)})]}),Object(y.jsx)("div",{className:"w-auto mt-6","data-testid":"cropzone-cropseasons-name",children:null===(a=t.cropSeasons)||void 0===a?void 0:a.map((function(e){return Object(y.jsx)(m.Tag,{color:"#696F88",children:e.name},e.id)}))}),Object(y.jsx)("div",{className:"ml-auto flex flex-row items-center",children:!o&&u>1&&Object(y.jsxs)("button",{className:"flex items-center py-1 px-2 text-neutral-600 hover:bg-neutral-100",type:"button",onClick:function(){d(!0,t)},"data-testid":"cropzone-button-remove",children:[Object(y.jsx)(Ay,{}),Object(y.jsx)("span",{className:"ml-1",children:"Remove"})]})})]}),Object(y.jsx)(yy,{products:c,errors:null===b||void 0===b?void 0:b.filter((function(e){return e.internalRecordId===t.id}))})]},t.id)}))})},e.id)}))})};Sy.defaultProps={fields:[]};var Ty=Sy,Ny=function(){var e,t,n=lx(),r=n.events,c=n.triggerAnalyticsEvent,i=Object(a.useContext)(SC),o=i.removeCropzone,s=i.setOpenRemoveCropzoneModal,l=i.state,d=l.openRemoveCropzoneModal,u=l.farms,b=l.integrationType,j=null===(e=u[l.selectedFarm])||void 0===e||null===(t=e.fields)||void 0===t?void 0:t.reduce((function(e,t){return e+t.cropzones.length}),0);return Object(y.jsx)(ao,{open:d,type:"buttonless",style:{paddingLeft:"2rem"},children:Object(y.jsxs)("div",{className:"flex flex-line w-full mt-2 justify-between","data-testid":"remove-cropzone-modal",children:[Object(y.jsx)("div",{className:"flex mr-4",children:Object(y.jsx)(bg,{})}),Object(y.jsxs)("div",{className:"flex flex-col pr-10",style:{flexGrow:1},children:[j>1&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"flex flex-row justify-items-center pb-4",children:Object(y.jsx)("h3",{className:"font-bold text-lg leading-6 text-gray-900 w-full",children:"Remove crop zone?"})}),Object(y.jsx)("div",{className:"flex flex-col mb-4",children:"Are you sure you want to remove the crop zone from this submission?"})]}),1===j&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"flex flex-row justify-items-center pb-4",children:Object(y.jsx)("h3",{className:"font-bold text-lg leading-6 text-gray-900 w-full",children:"Remove property?"})}),Object(y.jsx)("div",{className:"flex flex-col mb-4",children:"This is the only crop zone within this property for submission. Removing it will will remove the entire property from submission."})]}),Object(y.jsxs)("div",{className:"mt-5 flex flex-row items-center justify-end w-full",children:[Object(y.jsx)("div",{className:"mr-5",children:Object(y.jsx)(m.Button,{type:"outline",id:"cancel-button",onClick:function(){s(!1)},children:"Cancel"})}),Object(y.jsx)("div",{children:Object(y.jsx)(m.Button,{type:"primary",id:"submit-button",onClick:function(){o(),c(r.epic.Integrations.submissionCropZoneRemoved,{vendor:b}),s(!1)},children:"Remove"})})]})]})]})})},Ey=function(e){var t=e.FooterComponent,n=e.loading,r=Object(a.useState)([]),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useContext)(SC),l=s.setOpenConfirmationModal,d=s.state,u=d.farms,j=d.isReadOnly;Object(a.useEffect)((function(){o((function(e){return null===u||void 0===u?void 0:u.map((function(t,n){return e[n]||Object(a.createRef)()}))}))}),[u]);var p=function(e){i[e]&&i[e].current.scrollIntoView({behavior:"smooth",block:"center"})};return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"w-full h-full bg-white flex flex-col px-6 py-4 rounded-xl font-body","data-testid":"summary-view",children:[Object(y.jsx)("div",{className:"flex flex-col w-full mb-7",id:"submission-summary-top-header",children:Object(y.jsx)(by,{})}),n?Object(y.jsx)("div",{className:"m-auto",children:Object(y.jsx)(m.Spinner,{})}):Object(y.jsx)(y.Fragment,{children:null!==u&&void 0!==u&&u.length?Object(y.jsxs)(y.Fragment,{children:[null===u||void 0===u?void 0:u.map((function(e,t){var n;return Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"w-full mb-5",ref:function(e){return i[t]?(i[t].current=e,i[t].current):e},children:Object(y.jsx)(xy,{farm:e,selectFarm:p})}),Object(y.jsx)("div",{className:"flex flex-row w-full h-full","data-testid":"submission-summary-view",id:"submission-summary-view",children:Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(Ty,{fields:null===(n=e.fields)||void 0===n?void 0:n.filter((function(e){var t=e.cropzones;return(null===t||void 0===t?void 0:t.length)>0}))})})})]},e.id)})),!j&&t&&Object(y.jsx)(t,{isLastStep:!0,setModalSubmissionState:l})]}):Object(y.jsx)(m.Toast,{isError:!0,icon:"error",children:"No completed tasks found"})})]}),Object(y.jsx)(Ny,{}),Object(y.jsx)(py,{})]})};Ey.defaultProps={FooterComponent:null,loading:!1};var wy=Ey,_y=function(e){var t=e.isLoading,n=e.message,a=e["data-testid"];return Object(y.jsx)(ao,{open:t,type:"buttonless",style:{paddingLeft:"2rem"},children:Object(y.jsx)("div",{className:"flex flex-line w-full mt-2 justify-between","data-testid":a,children:Object(y.jsxs)("div",{className:"pr-12 pb-10 w-full h-40",children:[Object(y.jsx)(m.Spinner,{}),Object(y.jsx)("h3",{className:"font-bold text-lg text-gray-900 text-center",children:n})]})})})};_y.defaultProps={isLoading:!1,message:"Loading...","data-testid":"loading-modal"};var Ry=_y,Iy="https://api-v2-qa.financials.cropwise.com",Dy=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].organization,n=function(e,t){var n=e.name.toUpperCase(),a=t.name.toUpperCase();return n<a?-1:n>a?1:0},r=Object(a.useCallback)((function(){return new Promise((function(e,a){J.a.get("".concat(Iy,"/integrations/simplot/organizations"),{headers:{Authorization:"Bearer ".concat(Ve()),"cwf-context":JSON.stringify({organization_id:t.id})}}).then((function(t){var a=t.data;if(a&&Array.isArray(a)){var r=a.slice(0).sort(n);e(r)}})).catch(Ae.default).catch(a)}))}),[t]);return{saveSimplotOrganization:Object(a.useCallback)((function(e,n){return new Promise((function(a,r){var c;J.a.post("".concat(Iy,"/integrations/simplot/match"),[{cwfEntityId:t.id,simplotEntityDescription:null===(c=n.find((function(t){return t.id===e})))||void 0===c?void 0:c.name,simplotEntityId:e,type:"Organization"}],{headers:{Authorization:"Bearer ".concat(Ve()),"cwf-context":JSON.stringify({organization_id:t.id})}}).then((function(e){a(e)})).catch(Ae.default).catch(r)}))}),[t]),fetchSimplotOrganizations:r}},ky=function(){var e=Object(a.useContext)(vh).state.submissionFlowId,t=Object(a.useContext)(ac),n=Object(b.a)(t,2)[1],r=lx({onMountTriggerEvent:{event:Ee.epic.Integrations.submissionStarted,data:{vendor:KO}}}).triggerAnalyticsEvent,c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],f=Object(a.useState)(!1),m=Object(b.a)(f,2),v=m[0],O=m[1],h=Object(p.i)(),x=Object(a.useContext)(ac),g=Object(b.a)(x,1)[0].organization,C=Object(a.useContext)(nx),P=C.goForward,A=C.simplotOauthUrl,S=C.redirectToSimplotAuthorizeOrgUrl,T=Dy(!0).fetchSimplotOrganizations;return Object(a.useEffect)((function(){function t(){return(t=Object(Y.a)(G.a.mark((function t(){var n;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,j(!0),t.next=4,T();case 4:(null===(n=t.sent)||void 0===n?void 0:n.length)>0&&(r(Ee.epic.Integrations.submissionCredentialsFilled,{vendor:KO,flowId:e}),P()),t.next=13;break;case 8:t.prev=8,t.t0=t.catch(0),j(!1),O(!0),window.location.href=A;case 13:case"end":return t.stop()}}),t,null,[[0,8]])})))).apply(this,arguments)}!new URLSearchParams(h.search).get("code")&&e&&function(){t.apply(this,arguments)}()}),[h.search,e]),Object(a.useEffect)((function(){var t=new URLSearchParams(h.search).get("code");if(t){j(!1),s(!0);fetch("".concat("https://api-v2-qa.financials.cropwise.com","/integrations/simplot/oauth-code"),{method:"POST",headers:{Authorization:"Bearer ".concat(Ve()),"cwf-context":JSON.stringify({organization_id:g.id}),"Content-Type":"application/json"},body:JSON.stringify({code:t})}).then((function(t){if(!t.ok)return s(!1),void uc(n)(t);r(Ee.epic.Integrations.submissionCredentialsFilled,{vendor:KO,flowId:e}),S()}))}}),[h.search]),Object(y.jsx)("div",{className:"flex flex-col w-full items-start",children:Object(y.jsxs)("div",{className:"mt-3 w-full flex gap-5 items-center rounded-lg p-4 shadow-md bg-white",children:[Object(y.jsx)("div",{className:"bg-white rounded-xl border p-6",children:Object(y.jsx)("img",{src:TO,alt:""})}),Object(y.jsxs)("div",{className:"flex flex-col justify-center",children:[Object(y.jsx)("h3",{className:"font-bold text-2xl",children:"Simplot Processor Integration"}),Object(y.jsx)("h2",{children:"By Simplot"})]}),u&&Object(y.jsx)(Ry,{isLoading:!0,message:"Checking if you are already logged in...","data-testid":"spinner-check-logged-in"}),o&&Object(y.jsx)(Ry,{isLoading:o,message:"Redirecting to Authorize your Organizations...","data-testid":"spinner-authorize-orgs"}),v&&Object(y.jsx)(Ry,{isLoading:!0,message:"Redirecting to integration authentication page...","data-testid":"spinner-redirect-integration-login"})]})})},Ly=n(2815),Fy=function(e){var t=e.onSelect,n=e.organizations,r=e.csLoaded,c=e.selectedId,i=e.isRequired,o=e.vendor,s=void 0===o?"":o,l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useMemo)((function(){return c&&n.find((function(e){return e.id===c}))}),[c,n]),f=Object(y.jsx)("button",{"data-testid":"organizations-trigger-box",className:"w-full focus:outline-none",type:"button",tabIndex:0,onClick:function(){j(!u)},onKeyDown:function(e){return"Enter"===e.nativeEvent.key&&j(!u)},children:Object(y.jsxs)("div",{className:"pb-2 w-full",children:[Object(y.jsxs)("div",{id:"dropDown",className:"text-neutral-600 text-left mb-1 text-sm","data-testid":"organizations-heading",children:[s,i?"Organization*":"Organization"]}),Object(y.jsxs)("div",{className:"flex flex-wrap justify-between border border-neutral-30 rounded h-10","data-testid":"organizations-select",children:[Object(y.jsx)("div",{className:"flex",children:r?Object(y.jsx)("div",{"data-testid":"organizations-name",className:"flex flex-no-wrap bg-gray-100 rounded mx-1 my-2 justify-start",children:Object(y.jsx)("div",{className:"whitespace-nowrap p-1 text-xs text-neutral-600 font-semibold","data-testid":"organizations-name",children:(null===p||void 0===p?void 0:p.name)||"Select Organization"})}):Object(y.jsx)(m.Spinner,{})}),Object(y.jsx)("div",{className:"flex justify-end",children:u?Object(y.jsx)(eg.a,{style:{color:"#696F88",marginTop:"8px",marginRight:"4px",marginLeft:"6px"}}):Object(y.jsx)(Xx.a,{style:{color:"#696F88",marginTop:"8px",marginRight:"4px",marginLeft:"6px"}})})]})]})});return Object(y.jsx)(m.Popup,{trigger:f,position:"bottom",align:"left",hasOffset:!0,open:u,onClose:function(){return j(!1)},containerClasses:"w-full",children:Object(y.jsx)("div",{"data-testid":"organizations-popup",className:"w-92 h-full text-left",children:r?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"font-semibold text-sm mb-2 ml-2",children:"Organizations"}),Object(y.jsx)("ul",{className:"mb-2  ml-2",children:0===n.length?Object(y.jsx)("div",{className:"font-normal text-sm ml-4",children:"No Available Organizations"}):n.map((function(e){return Object(y.jsx)(m.Checkbox,{label:e.name,value:e.id,checked:c===e.id,onChange:function(n){j(!1),t(n.target.checked?e.id:null)}},e.id)}))})]}):Object(y.jsx)(m.Spinner,{})})})};Fy.defaultProps={organizations:[],selectedId:null,vendor:""};var My=Fy,Vy=function(){var e=lx(),t=e.events,n=e.triggerAnalyticsEvent,r=Object(a.useState)([]),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useContext)(ac),l=Object(b.a)(s,2)[1],d=Object(a.useContext)(ac),u=Object(b.a)(d,1)[0].organization,j=Object(a.useState)(!0),p=Object(b.a)(j,2),f=p[0],v=p[1],O=Ix(),h=O.selectedOrganization,x=O.setSelectedOrganization,g=Object(a.useContext)(nx),C=g.goForward,P=g.blockStepForward,A=g.releaseStepForward,S=g.redirectToSimplotAuthorizeOrgUrl,T=Object(a.useState)(!1),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Dy(),R=_.fetchSimplotOrganizations,I=_.saveSimplotOrganization,D=Kg().getOrganizationMatch,k=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,I(h,i);case 3:e.sent&&(n(t.epic.Integrations.submissionOrganizationFilled,{vendor:KO}),C()),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),uc(l)(e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){function e(){return(e=Object(Y.a)(G.a.mark((function e(){var t,n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,R();case 3:return n=e.sent,o(n),e.next=7,D(KO);case 7:(a=e.sent)&&(null===(t=a[0])||void 0===t?void 0:t.cwfEntityId)===u.id?(x(a[0].simplotEntityId),A()):P(),v(!0),e.next=16;break;case 12:e.prev=12,e.t0=e.catch(0),uc(l)(e.t0),v(!0);case 16:case"end":return e.stop()}}),e,null,[[0,12]])})))).apply(this,arguments)}P(),v(!1),function(){e.apply(this,arguments)}()}),[]),Object(y.jsxs)("div",{className:"flex flex-col self-center bg-white top-30 left-26 h-100 w-140 rounded-md mb-20 p-6 shadow-sm","data-testid":"simplot-organization-selection",children:[Object(y.jsx)("h1",{className:"mb-6 ml-8 font-body text-base font-normal leading-8 tracking-tight text-left",children:"Select an organization for your submission."}),Object(y.jsxs)("div",{className:"ml-8 flex  h-full flex-line",children:[Object(y.jsx)("div",{className:"w-2/3 ",children:Object(y.jsx)(My,{vendor:"Simplot ",organizations:i,csLoaded:f,selectedId:h,onSelect:function(e){x(e),e&&A()},isRequired:!0})}),Object(y.jsx)("div",{className:"ml-3",style:{marginTop:"1.55rem"},children:Object(y.jsx)(m.Popup,{enableHover:!0,position:"top",align:"center",hasArrow:!0,bgColor:"#232630",trigger:Object(y.jsx)("div",{"data-testid":"button-refresh-simplot-org",children:Object(y.jsx)(m.Button,{type:"overlay",loading:E,disabled:E,style:{width:"2.45rem",height:"2.45rem"},onClick:function(){w(!0),S()},icon:Object(y.jsx)(Ly.a,{})})}),children:Object(y.jsx)("div",{className:"gr-w-64 text-xs text-white",children:"Click here to refresh your Authorized Organizations on Trimble"})})})]}),Object(y.jsx)(Ax,{isLastStep:!1,onNext:k,nextDisabled:!h})]})},By=function(){var e=lx(),t=e.events,n=e.triggerAnalyticsEvent,r=Object(a.useContext)(nx).goForward,c=Object(a.useContext)(SC).updateSubmissionFilterCropZoneIds,i=Object(a.useState)(!0),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Ix().selectedProperties;return Object(a.useEffect)((function(){if(l(!s),d&&!s){var e=aC(d);c(e),n(t.epic.Integrations.submissionPropertiesSelected,{vendor:KO,cropZonesLength:e.length}),r()}}),[d]),Object(y.jsx)(Wx,{integrationName:KO})},Uy=function(){var e=Object(a.useContext)(Xg),t=e.state,n=e.setOpenConfirmationModal,r=Object(a.useContext)(ac),c=Object(b.a)(r,1)[0].error;return Object(a.useEffect)((function(){c&&n(!1)}),[c]),Object(y.jsx)(ao,{open:t.openConfirmationModal,type:"buttonless",style:{paddingLeft:"2rem"},children:Object(y.jsx)("div",{className:"flex flex-line w-full mt-2 justify-between","data-testid":"confirmation-modal",children:Object(y.jsxs)("div",{className:"pr-12 pb-10 w-full h-40",children:[Object(y.jsx)(m.Spinner,{}),Object(y.jsx)("h3",{className:"font-bold text-lg text-gray-900 text-center",children:"Generating Properties Matches"})]})})})},zy=function(e){var t=e.farmFieldTreeData,n=Object(a.useContext)(Xg),r=n.state,c=r.unmatchedEntities,i=r.matchEntityType,o=r.vendorProperties,s=r.matches,l=r.integrationType,d=n.updateUnmatchedEntities,u=n.isLoading,b=function(){var e=s.map((function(e){return e.cwfId})),n=function(){var e=null===t||void 0===t?void 0:t.flatMap((function(e){return e.fields}));return l===QO?null===e||void 0===e?void 0:e.map((function(e){return e.id})):null===e||void 0===e?void 0:e.flatMap((function(e){return e.cropzones})).map((function(e){return e.id}))}();if(n&&0!==n.length){var a=null===n||void 0===n?void 0:n.filter((function(t){return!e.includes(t)})).length;d(a)}};return Object(a.useEffect)((function(){b()}),[s,o]),Object(y.jsxs)("div",{"data-testid":"top-header",children:[Object(y.jsx)("div",{className:"w-full flex h-10 mb-2 items-center font-semibold",children:Object(y.jsxs)("p",{className:"text-xl",children:["Match ",i]})}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsxs)("div",{className:"grid grid-cols-10",children:[Object(y.jsx)("div",{className:"col-span-8 justify-self-start",children:Object(y.jsxs)("p",{className:"font-normal text-sm ",children:["Match selected ",i," within Cropwise Financials with the ones in ",l]})}),u?Object(y.jsx)("div",{className:"col-span-2 justify-self-end",children:Object(y.jsx)(m.Spinner,{size:"sm"})}):Object(y.jsx)("div",{className:"col-span-2 justify-self-end",children:0===c?Object(y.jsx)("div",{"data-testid":"all-matched",children:Object(y.jsxs)(m.Tag,{color:"#DFFBE8",children:[Object(y.jsx)(gh.a,{style:{marginLeft:"7px",fontSize:16,color:"#DFFBE8",backgroundColor:"#0C612C",borderRadius:"50%"}}),Object(y.jsx)("span",{className:"text-base mr-2 ml-2 font-thin text-green-900",children:"All Matched"})]},"unmatched-properties-length")}):Object(y.jsx)("div",{"data-testid":"unmatched-properties",children:Object(y.jsx)(m.Tag,{color:"#FFE4AE",children:Object(y.jsxs)("div",{className:"text-base mr-2 ml-2 text-yellow-700",children:[Object(y.jsx)("span",{className:"font-bold",children:Math.max(c,0)}),Object(y.jsx)("span",{className:"font-thin",children:" Unmatched"})]})},"unmatched-properties-length")})})]})})]})};zy.defaultProps={farmFieldTreeData:[]};var Zy=zy,Yy=n(2816),Hy=n(2817),Gy=n(2818),Wy=function(e){var t=e.area,n=e.unit;return t?Object(y.jsxs)("div",{children:[Object(y.jsx)("span",{className:"text-xs",children:"Size: "}),Object(y.jsxs)("span",{className:"text-xs bold",children:[null===t||void 0===t?void 0:t.toFixed(2)," ",n]})]}):null};Wy.defaultProps={unit:"ac"};var qy=Wy,Jy=Object(eb.default)({accessToken:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",trackResize:!0}),Ky="field-map-preview",Qy="field-map-preview-unavailable",Xy="field-map-preview-loading",$y="flex justify-center items-center h-full bg-gray-200",eP=function(e){var t=e.feature,n=e.area,r=e.className,c=e.fieldColor,i=e.isLoading,o=e.containerStyle,s=Object(a.useMemo)((function(){var e;if(null===t||void 0===t||!t.geometry||i)return{centroId:[0,0],boundingBox:null};var n=mj({features:[t]}),a=Object(W.bbox)(t);return{centroId:(null===n||void 0===n||null===(e=n.geometry)||void 0===e?void 0:e.coordinates)||[0,0],boundingBox:a}}),[t,i]),l=s.centroId,d=s.boundingBox;return i?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{"data-testid":Xy,style:o,className:"".concat(r," ").concat($y),children:Object(y.jsx)(m.Spinner,{})}),Object(y.jsx)(qy,{area:n})]}):null!==t&&void 0!==t&&t.geometry?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Jy,{style:"mapbox://styles/mapbox/satellite-streets-v11",center:l,containerStyle:o,fitBounds:d,fitBoundsOptions:{padding:16},className:r,logoPosition:"none","data-testid":Ky,children:Object(y.jsx)(eb.GeoJSONLayer,{data:t,fillLayout:{visibility:"visible"},fillPaint:{"fill-color":c,"fill-opacity":.4},linePaint:{"line-color":c,"line-width":2}})}),Object(y.jsx)(qy,{area:n})]}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{"data-testid":Qy,style:o,className:"".concat(r," ").concat($y),children:Object(y.jsx)("p",{className:"text-center",children:"Field map preview unavailable."})}),Object(y.jsx)(qy,{area:n})]})};eP.defaultProps={area:null,className:"",containerStyle:{height:"150px",width:"100%"},fieldColor:"#31B4F2",isLoading:!1,feature:null};var tP=eP,nP=function(e){return e.map((function(e){if(function(e){var t=e.properties;return Boolean(t.FarmId&&t.name)}(e))return function(e){var t=e.properties,n=e.geometry;return{name:t.name,farm:t.FarmId,fieldId:t.FieldId,geometry:n}}(e);if(function(e){var t=e.properties;return Boolean(t.FARM_NAME&&t.FIELD_NAME)}(e))return function(e){var t=e.properties,n=e.geometry;return{name:t.FIELD_NAME,farm:t.FARM_NAME,farmId:t.FARM_ID,fieldId:t.FIELD_ID,geometry:n}}(e);if(function(e){var t=e.properties;return Boolean(t.FARM&&t.FIELD)}(e))return function(e){var t=e.properties,n=e.geometry;return{name:t.FIELD,farm:t.FARM,farmId:t.FARM_ID,fieldId:t.FIELD_ID,geometry:n}}(e);if(function(e){var t=e.properties;return Boolean(t.FarmName&&t.FieldName)}(e))return function(e){var t=e.properties,n=e.geometry;return{name:t.FieldName,farm:t.FarmName,geometry:n}}(e);if(function(e){var t=e.properties;return Boolean(t.Bnd_Name&&t.Field)}(e))return function(e){var t=e.properties,n=e.geometry;return{name:t.Field,farm:t.Bnd_Name,geometry:n}}(e);throw new Error("unknown features type")}))},aP=function(e){return Array.isArray(e)?e.flatMap((function(e){return e.features})):e.features},rP=function(e){var t=new Map;return e.forEach((function(e){var n=e.name,a=e.farm,r="".concat(n,"-").concat(a);t.get(r)||t.set(r,e)})),Array.from(t,(function(e){return Object(b.a)(e,2)[1]}))},cP=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.t0=kp.a,e.next=4,t.arrayBuffer();case 4:return e.t1=e.sent,e.next=7,(0,e.t0)(e.t1);case 7:return n=e.sent,a=aP(n),r=nP(a),e.abrupt("return",rP(r));case 13:throw e.prev=13,e.t2=e.catch(0),new Error("Error on file '".concat(t.name,"': ").concat(e.t2.message));case 16:case"end":return e.stop()}}),e,null,[[0,13]])})));return function(t){return e.apply(this,arguments)}}(),iP=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],e.next=3,Promise.all(t.map(function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,cP(t);case 3:return e.abrupt("return",e.sent);case 6:e.prev=6,e.t0=e.catch(0),n.push({file:t.name,message:e.t0.message});case 9:return e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(t){return e.apply(this,arguments)}}()));case 3:return a=e.sent.flat(),e.abrupt("return",{fields:rP(a),errors:n});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),oP=function(e){var t=Object(W.featureCollection)(e);return Object(W.convertArea)(Object(W.area)(t),"meters","acres")},sP=function(e){var t={};return t=Object(W.getCoords)(e).length>1?Object(W.multiPolygon)(Object(W.getCoords)(e)):Object(W.multiPolygon)([e].map(W.getCoords)),Object(W.getGeom)(t)},lP=function(e){return{type:"Feature",geometry:null===e||void 0===e?void 0:e.geometry,properties:{FIELD:null===e||void 0===e?void 0:e.name,FARM:null===e||void 0===e?void 0:e.farm}}},dP="#696F88",uP=function(e){var t=e.color,n=void 0===t?dP:t,a=e.width,r=e.height;return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:r,viewBox:"0 0 122 38",fill:"none",children:Object(y.jsx)("path",{d:"M78.2079 15.875H28.6667V21.125H78.2079V29L94.6667 18.5L78.2079 8V15.875Z",fill:n})})};uP.defaultProps={color:dP,width:"122",height:"38"};var bP=uP,jP=function(e){var t=Object(a.useContext)(Xg).state,n=t.integrationType,r=t.vendorProperties,c=void 0===r?[]:r,i=Kg(),o=i.getVendorPropertyGeometry,s=i.loading,l=Object(a.useState)(null),d=Object(b.a)(l,2),u=d[0],j=d[1];return Object(a.useEffect)((function(){var t=function(){var t=Object(Y.a)(G.a.mark((function t(){var a;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,o({vendor:n===XO?QO:n,vendorPropertyId:e});case 2:200===(null===(a=t.sent)||void 0===a?void 0:a.status)&&j(lP(a.data));case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();t()}),[o,n,e]),{property:Object(a.useMemo)((function(){return c.find((function(t){return t.id===e}))}),[c,e]),feature:u,isLoading:s}},pP=(n(1542),function(e){var t=e.vendorId,n=jP(t),a=n.isLoading,r=n.feature,c=n.property;return Object(y.jsx)(tP,{isLoading:a,className:"rounded-lg cwfi-vendor-property-map",feature:r,area:null===c||void 0===c?void 0:c.area,fieldColor:"#5EBB7F"})}),fP=function(e){var t=e.property,n=e.parentName,r=e.integrationName,c=Object(a.useContext)(Xg),i=c.addPropertyMatchId,o=c.fetchVendorProperties,s=c.fetchMatches,l=c.isLoading,d=c.state,u=d.vendorProperties,j=d.matches,p=Object(a.useState)(0),f=Object(b.a)(p,2),v=f[0],O=f[1],h=Object(a.useState)(null),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useState)(!1),A=Object(b.a)(P,2),S=A[0],T=A[1],N=function(e){return!!v&&e.id===v.id},E=function(e){var t=JSON.parse(e.target.value).key;t!==g&&(T(!1),C(t),i(v.id,t))},w=function(){T((function(e){return!e}))};Object(a.useEffect)((function(){o(),s(),C(null)}),[]),Object(a.useEffect)((function(){var e=j.find((function(e){return t.id===e.cwfId}));e?e&&e.vendorId!==g&&C(e.vendorId):C(null)}),[j,g,null===t||void 0===t?void 0:t.id]);var _=Object(a.useMemo)((function(){return null===u||void 0===u?void 0:u.map((function(e){return{key:e.id,value:r===QO?e.name:"".concat(e.fieldName," - ").concat(e.name)}}))}),[u,r]),R=lP(t);return Object(y.jsxs)("div",{"data-testid":"property-collapse",className:"text-l rounded-lg p-4 shadow-md mt-1 grid-flow-row auto-rows-max max-w-800 mb-5",children:[Object(y.jsxs)(pu,{className:"flex bg-transparent text-info-dark max-w-800",onClick:function(){var e=(null===v||void 0===v?void 0:v.id)===t.id;O(e?null:t)},children:[Object(y.jsx)("div",{className:"w-20","data-testid":"property-match-status",children:g?Object(y.jsx)(m.Tag,{color:"#C3EAD1",children:Object(y.jsx)("span",{className:"justify-self-center w-full text-xs mr-5 text-green-900 ml-2",children:"Matched"})},"matching-state-property"):Object(y.jsx)(m.Tag,{color:"#FFE4AE",children:Object(y.jsx)("span",{className:"justify-self-center w-full text-xs mr-5 text-yellow-700",children:"Unmatched"})},"matching-state-property")}),Object(y.jsxs)("div",{className:"flex justify-start ml-2","data-testid":"property-title",children:[n&&Object(y.jsxs)("span",{children:[n," /"]}),Object(y.jsxs)("span",{className:"font-semibold",children:["\xa0",null===t||void 0===t?void 0:t.name]})]}),Object(y.jsx)("div",{className:"flex justify-end flex-1",children:N(t)?Object(y.jsx)(Yy.a,{fontSize:"small",className:"text-neutral-600"}):Object(y.jsx)(Ux.a,{fontSize:"small",className:"text-neutral-600"})})]}),N(t)&&Object(y.jsx)("div",{className:"justify-self-start pr-15 col-span-w w-full mt-12",children:l?Object(y.jsx)("div",{className:"mb-5",children:Object(y.jsx)(m.Spinner,{})}):Object(y.jsxs)(y.Fragment,{children:[S&&Object(y.jsx)("div",{className:"grid grid-cols-4",children:Object(y.jsxs)("div",{className:"col-span-2 col-start-3",children:[Object(y.jsx)("div",{className:"flex justify-end mb-1 -mt-8",children:Object(y.jsx)(m.Button,{icon:Object(y.jsx)(Hy.a,{}),iconLeft:!0,onClick:w,id:"hide-vendor-property-boundary-btn",size:"small",type:"outline",children:"Hide Boundary"})}),Object(y.jsx)(m.Select,{label:"".concat(r," Fields"),onChange:E,value:g,items:_})]})}),Object(y.jsxs)("div",{className:"grid items-".concat(S?"end grid-cols-3":"center grid-cols-4"),children:[Object(y.jsx)("div",{className:"col-span-1 justify-self-start w-full",children:Object(y.jsx)("div",{className:"mt-2 bg-gray-100 rounded-lg overflow-hidden text-left p-4",children:Object(y.jsx)(tP,{className:"rounded-lg",feature:R,area:(null===t||void 0===t?void 0:t.reportedArea)||(null===t||void 0===t?void 0:t.boundaryArea)},"property-preview-with-vendor=".concat(S))})}),Object(y.jsx)("div",{className:"flex items-center justify-center h-full col-span-1",children:Object(y.jsx)("span",{className:"mb-1",children:Object(y.jsx)(bP,{})})}),Object(y.jsx)("div",{className:"text-sm col-span-".concat(S?"1":"2"),style:{position:"relative"},children:S?Object(y.jsx)("div",{className:"mt-2 bg-gray-100 rounded-lg overflow-hidden text-left p-4",children:Object(y.jsx)(pP,{vendorId:g})}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"flex justify-end mb-1 -mt-8",children:Object(y.jsx)(m.Button,{icon:Object(y.jsx)(Gy.a,{}),iconLeft:!0,onClick:w,id:"display-vendor-property-boundary-btn",size:"small",type:"outline",children:"View Boundary"})}),Object(y.jsx)(m.Select,{label:"".concat(r," Fields"),onChange:E,value:g,items:_})]})})]})]})})]})};fP.defaultProps={property:{},integrationName:"",parentName:""};var mP=fP,vP=n(2819),OP=(n(1543),(new Date).getFullYear()),hP=OP-1,xP=function(e){var t=e.integrationName,n=Object(a.useContext)(Xg),r=n.fetchVendorProperties,c=n.updateSelectedCropYear,i=n.updateMatches,o=n.state.selectedCropYear;return Object(a.useEffect)((function(){r()}),[o]),Object(y.jsxs)("div",{className:"SquareDropdown grid grid-flow-row auto-rows-max",children:[Object(y.jsxs)("div",{className:"justify-self-start",children:[Object(y.jsx)(vP.a,{className:"calendarCropYear"}),Object(y.jsx)("span",{className:"font-bold",children:" Select Crop Year"})]}),Object(y.jsxs)("span",{className:"font-thin mt-1 -mb-3",children:[t," Crop Year"]}),Object(y.jsx)("div",{className:"w-full -mb-2",children:Object(y.jsx)(m.Select,{onChange:function(e){var t=JSON.parse(e.target.value).key;i([]),c(t)},value:o,items:[{key:OP,value:OP},{key:hP,value:hP}]})}),Object(y.jsxs)("div",{className:"justify-self-start w-full warningBox grid grid-cols-5",children:[Object(y.jsx)("div",{className:"col-span-1",children:Object(y.jsx)(Jc,{})}),Object(y.jsx)("div",{className:"col-span-4",children:Object(y.jsx)("span",{className:"text-xs",children:"Changing Crop Year will reset all matched crop zones"})})]})]})};xP.defaultProps={integrationName:""};var gP=xP,CP=function(e){var t=e.farmFieldTreeData,n=e.integrationName,a=n===KO,r=function(e){return n===QO?Object(y.jsx)(y.Fragment,{children:e.fields.map((function(e){return Object(y.jsx)(mP,{property:e,integrationName:n},e.id)}))}):Object(y.jsx)(y.Fragment,{children:e.fields.map((function(e){return e.cropzones.map((function(t){return Object(y.jsx)(mP,{property:t,parentName:e.name,integrationName:n},t.id)}))}))})};return Object(y.jsxs)("div",{className:"grid grid-cols-10 h-full",children:[Object(y.jsx)("div",{className:"col-span-7 mb-5",children:null===t||void 0===t?void 0:t.map((function(e){return e.fields.length>0&&e.fields.some((function(e){return e.cropzones.length>0}))?Object(y.jsxs)("div",{className:"mt-7",children:[Object(y.jsx)("div",{className:"justify-self-start",children:Object(y.jsxs)("div",{className:"flex flex-row items-center text-2xl font-semibold",children:[Object(y.jsx)(qC,{}),Object(y.jsx)("span",{"data-testid":"farm-name",className:"ml-2",children:null===e||void 0===e?void 0:e.name})]})}),Object(y.jsx)("div",{children:r(e)})]},e.id):Object(y.jsx)("div",{},e.id)}))}),a&&Object(y.jsx)("div",{className:"col-span-3 justify-self-end object-cover h-158 w-200",children:Object(y.jsx)(gP,{integrationName:n})})]})};CP.defaultProps={farmFieldTreeData:[],integrationName:""};var yP=CP,PP=function(e){var t=e.setModalSubmissionState,n=Object(p.h)(),r=Object(a.useContext)(Xg),c=r.submitMatches,i=r.integrationContext,o=r.state.unmatchedEntities,s=Object(a.useContext)(i).goBack;return Object(y.jsx)("div",{className:"w-full h-24","data-testid":"properties-match-footer","data-html2canvas-ignore":!0,children:Object(y.jsxs)("div",{className:"flex flex-row border-t-2 bg-white w-auto justify-between px-4 py-6 h-auto",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:function(){n.goBack()},"data-testid":"cancel",children:"Cancel"}),Object(y.jsxs)("div",{className:"flex flex-row gap-6",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:s,"data-testid":"back",icon:Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.e}),children:"Back"}),Object(y.jsx)(m.Button,{type:"primary","data-testid":"submit",disabled:0!==o,onClick:function(){c(),t(!0)},children:"Next: Review and Submit"})]})]})})};PP.defaultProps={setModalSubmissionState:function(){}};var AP=PP,SP=function(e){var t=e.integrationName,n=Ix().selectedProperties,r=Object(a.useContext)(Xg),c=r.state.unmatchedEntities,i=r.setOpenConfirmationModal,o=r.integrationContext,s=Object(a.useContext)(o),l=s.blockStepForward,d=s.releaseStepForward;return Object(a.useEffect)((function(){i(!1)}),[]),Object(a.useEffect)((function(){0===c?d():l()}),[c]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"w-full bg-white flex flex-col px-6 py-4 rounded-xl font-body","data-testid":"properties-match-view",children:[Object(y.jsx)("div",{className:"flex flex-col w-full mb-3",id:"properties-match-top-header",children:Object(y.jsx)(Zy,{farmFieldTreeData:n})}),Object(y.jsx)("div",{className:"w-full mb-5 overflow-y-auto",children:Object(y.jsx)(yP,{farmFieldTreeData:n,integrationName:t})}),Object(y.jsx)(AP,{setModalSubmissionState:i})]}),Object(y.jsx)(Uy,{})]})},TP=function(e){var t=e.title,n=e.description,a=e.unmatchCount,r=e.isMatchCountVisible,c=e.isLoading;return Object(y.jsxs)("div",{"data-testid":"top-header",children:[Object(y.jsx)("div",{className:"w-full flex h-10 mb-2 items-center font-semibold",children:Object(y.jsx)("p",{className:"text-xl",children:t})}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsxs)("div",{className:"grid grid-cols-10",children:[Object(y.jsx)("div",{className:"col-span-8 justify-self-start",children:Object(y.jsx)("p",{className:"font-normal text-sm ",children:n})}),c&&r?Object(y.jsx)("div",{className:"col-span-2 justify-self-end",children:Object(y.jsx)(m.Spinner,{size:"sm"})}):Object(y.jsx)("div",{className:"col-span-2 justify-self-end",children:0===a?Object(y.jsx)("div",{"data-testid":"all-matched",children:Object(y.jsxs)(m.Tag,{color:"#DFFBE8",children:[Object(y.jsx)(gh.a,{style:{marginLeft:"7px",fontSize:16,color:"#DFFBE8",backgroundColor:"#0C612C",borderRadius:"50%"}}),Object(y.jsx)("span",{className:"text-base mr-2 ml-2 font-thin text-green-900",children:"All Matched"})]},"unmatched-properties-length")}):Object(y.jsx)("div",{"data-testid":"unmatched-properties",children:Object(y.jsx)(m.Tag,{color:"#FFE4AE",children:Object(y.jsxs)("div",{className:"text-base mr-2 ml-2 text-yellow-700",children:[Object(y.jsx)("span",{className:"font-bold","data-testid":"unmatched-properties-count",children:Math.max(a,0)}),Object(y.jsx)("span",{className:"font-thin",children:" Unmatched"})]})},"unmatched-properties-length")})})]})})]})};TP.defaultProps={isLoading:!1,unmatchCount:0,isMatchCountVisible:!1};var NP=TP,EP=n.p+"static/media/chevron_up.1ac36251.svg",wP=function(e){var t=e.size,n=void 0===t?18:t,a=e.color,r=void 0===a?"#696F88":a;return Object(y.jsx)("svg",{width:n,height:n,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"search-icon",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11.2239 10.6904H11.8164L15.5589 14.4404L14.4414 15.5579L10.6914 11.8154V11.2229L10.4889 11.0129C9.63391 11.7479 8.52391 12.1904 7.31641 12.1904C4.62391 12.1904 2.44141 10.0079 2.44141 7.31543C2.44141 4.62293 4.62391 2.44043 7.31641 2.44043C10.0089 2.44043 12.1914 4.62293 12.1914 7.31543C12.1914 8.52293 11.7489 9.63293 11.0139 10.4879L11.2239 10.6904ZM3.94141 7.31543C3.94141 9.18293 5.44891 10.6904 7.31641 10.6904C9.18391 10.6904 10.6914 9.18293 10.6914 7.31543C10.6914 5.44793 9.18391 3.94043 7.31641 3.94043C5.44891 3.94043 3.94141 5.44793 3.94141 7.31543Z",fill:r})})};wP.defaultProps={color:"#696F88",size:18};var _P=Object(a.memo)(wP),RP=(n(1544),function(){return Object(y.jsx)("div",{className:"flex justify-center items-center",children:Object(y.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-500"})})}),IP=function(e){var t=e.valueRenderer,n=e.onChange,r=e.onFilter,c=e.isServerSideFilter,i=e.value,o=e.items,s=e.ItemComponent,l=e.bottomButtonText,d=e.onBottomButtonClick,u=e.bottomButtonTextColor,j=e.id,p=e.rightOffset,f=e.heightClass,O=e.mainClass,h=e.isInvalid,x=e.isLoading,g=e.mergeSearchInputWithValue,C=e.searchPlaceholderText,P=e.itemOptionClassName,A=Object(a.useState)(!1),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(void 0),w=Object(b.a)(E,2),_=w[0],R=w[1],D=zi(_,300),k=Object(a.useState)(o),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Object(a.useRef)(null),B=Object(a.useRef)(null),U=function(){N(!T)};Object(a.useEffect)((function(){o&&o.length>0&&M(o)}),[o]),Object(a.useEffect)((function(){var e=function(e){V.current&&!V.current.contains(e.target)&&(N(!1),R(void 0))};return document.addEventListener("click",e),function(){document.removeEventListener("click",e)}}),[]),Object(a.useEffect)((function(){if(r&&"function"===typeof r&&void 0!==D){if(c)return r("empty",D);var e=Object(v.a)(o).reduce((function(e,t){if(!t.items&&r(t,D))return e.concat([t]);if(t.items){var n=t.items.filter((function(e){return r(e,D)}));return 0===n.length?e:e.concat([Object(I.a)(Object(I.a)({},t),{},{items:n})])}return e}),[]);return M(Object(v.a)(e))}}),[D,r]);var z=function(e){R(e)},Z=function(e){return JSON.stringify(e)===JSON.stringify(i)?"bg-selectedBlue":"hover:bg-neutral-100"},Y=i?t(i):void 0,H=function e(t){var a=t.value;return null!==t&&void 0!==t&&t.onItemClick?Object(y.jsx)(pu,{className:"h-8 gr-whitespace-nowrap",onClick:function(){N(!1),R(""),t.onItemClick()},children:s?Object(y.jsx)(s,{item:t}):t.value},t.key||JSON.stringify(t.value)):a?Object(y.jsx)(pu,{className:"".concat(Z(a)," ").concat(s?"":"h-6"," ").concat(P),onClick:function(){N(!1),R(void 0),n(a)},children:s?Object(y.jsx)(s,{item:t}):Object(y.jsx)(y.Fragment,{children:t.label})},t.key||JSON.stringify(a)):t.items?Object(y.jsxs)(y.Fragment,{children:[s?Object(y.jsx)(s,{item:t}):t.label,t.items.map((function(t){return e(t)}))]}):Object(y.jsx)(s,{item:t})||Object(y.jsx)(y.Fragment,{children:t.label})};return Object(y.jsxs)("div",{className:"w-full mt-1 ".concat(O),ref:V,id:j,"data-testid":"items-drop-down-field",children:[g?Object(y.jsx)("div",{className:"flex flex-row",children:Object(y.jsx)("div",{style:{whiteSpace:"nowrap"},className:"flex-1 overflow-x-hidden whitespace-nowrap",children:Object(y.jsx)(Xc.Input,{id:"label-search-input","data-testid":"merged-input-items-dropdown",placeholder:C,maxLength:"20",autoComplete:"off",onChange:function(e){return t=e.target.value,R(t),void z(t);var t},onFocus:function(){T||U()},value:void 0!==_&&null!==_?_:i?t(i):"",prefix:Object(y.jsx)(_P,{}),ref:B,suffix:x?Object(y.jsx)(RP,{}):T?Object(y.jsx)("img",{className:"mr-1",src:EP,alt:"Sort Icon"}):Object(y.jsx)("img",{className:"mr-1",src:Di,alt:"Sort Icon"})})})}):Object(y.jsx)(m.Button,{onClick:U,style:{width:"100%"},type:"outline",ghost:!h,danger:h,disabled:x,dataTestId:j,children:Object(y.jsxs)("div",{className:"flex flex-row w-full relative",children:[Object(y.jsx)("div",{style:{whiteSpace:"nowrap"},className:"flex-1 overflow-x-hidden whitespace-nowrap",children:Y}),x?Object(y.jsx)(RP,{}):Object(y.jsx)("img",{className:"mr-1",src:Di,alt:"Sort Icon"})]})}),T&&Object(y.jsxs)("div",{className:"absolute bg-white z-50 mt-2 shadow-card rounded",style:{width:"calc(".concat(V.current.clientWidth,"px - ").concat(p,"px)")},"data-testid":"items-drop-down-options",children:[!g&&r&&"function"===typeof r&&Object(y.jsx)("div",{className:"border-b-1 p-3 base-drop-down-search-input",children:Object(y.jsx)(Xc.Input,{className:"bg-gray-400",id:"label-search-input",placeholder:C,maxLength:"20",onChange:function(e){return z(e.target.value)},suffix:Object(y.jsx)(_P,{})})}),Object(y.jsx)("div",{className:"".concat(f),children:Object(y.jsxs)("div",{className:"w-full h-full flex flex-col justify-center",children:[Object(y.jsx)("div",{className:"mt-2 flex-1 overflow-x-hidden overflow-y-auto w-full",children:F.map((function(e){return H(e)}))}),l&&d&&Object(y.jsx)("div",{className:"flex justify-center border-t border-solid border-neutral-100",children:Object(y.jsx)("div",{className:"mx-4 my-2 w-full h-full",children:Object(y.jsx)(m.Button,{onClick:function(){N(!1),d()},style:{width:"100%",color:u},type:"outline",ghost:!h,danger:h,dataTestId:"item-drop-bottom-button",children:l})})})]})})]})]})};IP.defaultProps={value:null,id:"",isInvalid:!1,rightOffset:24,heightClass:"h-100",mainClass:"items-drop-down-field",isLoading:!1,isServerSideFilter:!1,bottomButtonText:null,onBottomButtonClick:null,bottomButtonTextColor:"",ItemComponent:null,onFilter:void 0,mergeSearchInputWithValue:!1,searchPlaceholderText:"Search...",itemOptionClassName:"gr-whitespace-nowrap"};var DP=IP;IP.ClickableElement=function(e){return e.children};var kP=n.p+"static/media/no_products_found.1b084a4b.svg",LP=function(e){var t=e.item,n=Object(a.useRef)(null),r=t.value,c=t.key,i=t.label,o=t.type;return r?Object(y.jsx)("div",{className:"w-full pb-2 pt-1 px-2 flex flex-col","data-testid":"item-with-value",children:Object(y.jsx)("div",{className:"flex flex-row justify-between w-full align-middle text-sm pl-2",children:Object(y.jsx)("div",{ref:n,className:"break-normal w-3/4",children:"".concat(null===r||void 0===r?void 0:r.name," - ").concat(null===r||void 0===r?void 0:r.type," ").concat(null===r||void 0===r||!r.form||"Fertilizer"!==(null===r||void 0===r?void 0:r.type)&&"Chemical"!==(null===r||void 0===r?void 0:r.type)?"":"(".concat(null===r||void 0===r?void 0:r.form,")"))})})},c):"empty"===i?Object(y.jsxs)("div",{className:"flex flex-col justify-center items-center h-full","data-testid":"item-empty-value",children:[Object(y.jsx)("img",{className:"w-1/2 mx-auto",src:kP,alt:"empty-state","data-testid":"empty-image"}),Object(y.jsx)("p",{"data-testid":"empty-table-state-message",className:"text-sm mb-4",children:"Enter at least three characters to search the materials list"})]},c):"loading"===i?Object(y.jsx)("div",{className:"flex flex-col justify-center items-center h-full","data-testid":"item-loading-value",children:Object(y.jsx)("div",{className:"w-1/2 mx-auto","data-testid":"loading-spinner",children:Object(y.jsx)(m.Spinner,{})})},c):i.startsWith("empty-")?Object(y.jsx)("div",{className:"px-2 ml-2 text-neutral-60","data-testid":"item-empty-value",children:"No ".concat("COMMON"===o?"common materials":"materials"," found")},c):Object(y.jsx)("div",{className:"text-neutral-60 pl-2","data-testid":"item-without-value",children:i},i)},FP=function(e){var t=e.onChange,n=e.value,r=e.id,c=e.cleanUpCallback,i=Object(a.useState)(""),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)([{key:"empty",label:"empty",type:"PRODUCT"}]),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(void 0),m=Object(b.a)(f,2),v=m[0],O=m[1],h=zi(s,300),x=Object(a.useContext)(SC),g=x.getVendorMaterials,C=x.isLoading,P=function(e){var t,n,a=null===(t=e.materials)||void 0===t?void 0:t.filter(c).map((function(e){return{key:e.id,label:e.name,type:"MATERIAL",value:Object(I.a)(Object(I.a)({},e),{},{source:"MATERIAL"})}})),r=null===(n=e.commonMaterials)||void 0===n?void 0:n.filter(c).map((function(e){return{key:e.id,label:e.name,type:"COMMON",value:Object(I.a)(Object(I.a)({},e),{},{source:"COMMON"})}}));return[{key:"materials",label:"Materials",type:"MATERIAL",items:a.length>0?a:[{key:"empty-materials",label:"empty-materials",type:"MATERIAL"}]},{key:"common",label:"Common Materials",type:"COMMON",items:r.length>0?r:[{key:"empty-common",label:"empty-common",type:"COMMON"}]}]};Object(a.useEffect)((function(){n!==v&&O(n)}),[n]),Object(a.useEffect)((function(){function e(){return(e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,g(h);case 2:(t=e.sent)&&p(P(t.data));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}(null===h||void 0===h?void 0:h.length)>=3&&function(){e.apply(this,arguments)}()}),[h]);return Object(y.jsx)(DP,{rightOffset:0,heightClass:"h-64",mainClass:"items-drop-down-field-1",value:v,onChange:function(e){O(e),l(void 0),t(e)},id:r,items:C?[{key:"loading",label:"loading",type:"PRODUCT"}]:j,ItemComponent:LP,onFilter:function(e,t){l(t)},isServerSideFilter:!0,mergeSearchInputWithValue:!0,searchPlaceholderText:"Search by material name",valueRenderer:function(e){return e?"".concat(e.name):""},isLoading:C,itemOptionClassName:""},v)};FP.defaultProps={value:"",id:"",cleanUpCallback:function(){return!0}};var MP=FP,VP=function(e){var t=e.product,n=e.matchedProduct,r=e.handleSelect,c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(),d=Object(b.a)(l,2),u=d[0],j=d[1];Object(a.useEffect)((function(){n&&j({id:null===n||void 0===n?void 0:n.vendorId,name:null===n||void 0===n?void 0:n.vendorPropertyName})}),[n]);var p,f=function(){return n?n.error?{label:"ERROR",color:"red"}:{label:"MATCHED",color:"green"}:{label:"UNMATCHED",color:"yellow"}},m=function(e){return Object(I.a)(Object(I.a)({},e),{},{source:"CUSTOM",id:e.productId,name:e.productName})};return Object(y.jsx)("div",{className:"justify-self-start pr-15 col-span-w w-full mb-8",children:Object(y.jsxs)("div",{className:"grid items-center grid-cols-7",children:[Object(y.jsx)("div",{className:"text-sm col-span-3",style:{position:"relative"},children:Object(y.jsxs)("div",{className:"flex flex-row items-center",children:[Object(y.jsx)("div",{className:"mr-4 mt-6 flex-none w-22",children:Object(y.jsx)(Xc.Tag,{color:f().color,"data-testid":"status-tag",children:f().label},"product-status")}),Object(y.jsxs)("div",{className:"flex flex-col my-2 w-full",children:[Object(y.jsx)("span",{className:"text-gray-600",children:"Cropwise Product"}),Object(y.jsx)("div",{className:"mt-1 p-2 rounded-md bg-gray-200 border-gray-500 border-1 text-gray-600",children:"".concat(t.productName," (").concat(t.quantityUnit,")")})]})]})}),Object(y.jsx)("div",{className:"flex items-center justify-center h-full col-span-1",children:Object(y.jsx)("span",{className:"mb-1 mt-8",children:Object(y.jsx)(bP,{})})}),Object(y.jsxs)("div",{className:"flex flex-col col-span-3",children:[o?Object(y.jsxs)("div",{className:"flex flex-col my-2 w-full",children:[Object(y.jsx)("span",{className:"text-gray-600 mt-8",children:"Simplot Product"}),Object(y.jsx)("div",{className:"mt-1 p-2 rounded-md bg-gray-200 border-gray-500 border-1 text-gray-600",children:"New Custom Simplot Product"})]}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"text-neutral-600 text-left text-sm mt-8","data-testid":"cropzones-heading",children:"Simplot Materials"}),Object(y.jsx)("div",{className:"flex items-center justify-center cropzone-dropdown",children:Object(y.jsx)(MP,{id:"cwfProductMatch",value:u,onChange:function(e){r(e,t)},cleanUpCallback:(p=t.productType,"cropprotection"===p.toLowerCase()?function(e){return"Chemical"===e.type}:"fertilizer"===p.toLowerCase()?function(e){return"Fertilizer"===e.type}:function(e){return"Fertilizer"!==e.type&&"Chemical"!==e.type})})})]}),Object(y.jsxs)("div",{className:"my-auto pt-2",children:[Object(y.jsx)(Xc.Switch,{size:"medium",checked:o,onChange:function(){s(!o),o?r(m(t)):r(m(t),t)}}),Object(y.jsx)("span",{className:"ml-2",children:"Use Cropwise data to create custom Simplot product"})]}),(null===n||void 0===n?void 0:n.error)&&Object(y.jsx)("div",{className:"w-full bg-red-200 text-red-800 p-2 mt-2 rounded-md",children:null===n||void 0===n?void 0:n.error})]})]})})};VP.defaultProps={matchedProduct:void 0};var BP=VP,UP=function(e){var t=e.products,n=e.matches,a=e.matchesWithErrors,r=e.onSelectMatch,c=function(e){var t,r=n.find((function(t){return t.cwfId===e.productId}));if(r)return Object(I.a)(Object(I.a)({},r),{},{error:null===(t=a.find((function(t){return t.cwfId===e.productId})))||void 0===t?void 0:t.error})};return Object(y.jsx)("div",{className:"grid w-full h-full",children:Object(y.jsx)("div",{className:"mb-5",children:null===t||void 0===t?void 0:t.map((function(e){return Object(y.jsx)(BP,{product:e,matchedProduct:c(e),handleSelect:r},e.productId)}))})})};UP.defaultProps={matches:[],matchesWithErrors:[]};var zP=UP,ZP=function(){var e=lx(),t=e.events,n=e.triggerAnalyticsEvent,r=Object(a.useContext)(nx).goForward,c=Object(a.useState)([]),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)([]),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)([]),f=Object(b.a)(p,2),m=f[0],O=f[1],h=Object(a.useContext)(DC),x=h.state,g=x.matches,C=x.fetchedMatches,P=h.isLoading,A=h.fetchMatches,S=h.submitMatches,T=h.updateMatches,N=Object(a.useContext)(SC),E=N.state.tasks,w=N.loadSubmission,_=N.isLoading,R=ni();Object(a.useEffect)((function(){P||A(),_||w()}),[]),Object(a.useEffect)((function(){if(!_){var e=E.flatMap((function(e){return e.products}));j(e.reduce((function(e,t){return-1===e.findIndex((function(e){return e.productId===t.productId}))&&e.push(t),e}),[]))}}),[E]),Object(a.useEffect)((function(){s(u.filter((function(e){return-1===g.findIndex((function(t){return t.cwfId===e.productId}))})))}),[g,C,u]);var I=function(){var e=Object(Y.a)(G.a.mark((function e(){var a,c,i,o;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n(t.epic.Integrations.submissionProductsMatched,{vendor:KO}),e.next=3,S();case 3:if(void 0!==(a=e.sent)){e.next=6;break}return e.abrupt("return",r());case 6:201===(null===a||void 0===a?void 0:a.status)?r():(R.error("Unable to match products.",{supportButton:!0,content:"We were unable to match at least one of your products. Review the errors and select a new Simplot Common Material"}),207===(null===(c=207===(null===a||void 0===a?void 0:a.status)?a:null===a||void 0===a?void 0:a.response)||void 0===c?void 0:c.status)&&O(null===c||void 0===c||null===(i=c.data)||void 0===i?void 0:i.filter((function(e){return e.error}))),422===(null===c||void 0===c?void 0:c.status)&&O(null===c||void 0===c||null===(o=c.data)||void 0===o?void 0:o.filter((function(e){return e.error}))));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsxs)("div",{className:"w-84/100 bg-white flex flex-col px-6 py-4 rounded-xl font-body mb-mtcm","data-testid":"properties-match-view",children:[Object(y.jsx)("div",{className:"flex flex-col w-full mb-3",id:"properties-match-top-header",children:Object(y.jsx)(NP,{title:"Match Products",description:"Match products from Cropwise Financials product list to products, chemicals or materials on the Simplot integration.",isLoading:P,isMatchCountVisible:!0,unmatchCount:o.length})}),Object(y.jsx)("div",{className:"w-full mb-5 overflow-y-auto",children:!P&&Object(y.jsx)(zP,{products:u,matches:g,onSelectMatch:function(e,t){if(m&&O(m.filter((function(e){return e.cwfId===t.productId}))),!t)return T(Object(v.a)(g.filter((function(t){return t.vendorId!==e.id}))));var n={vendorPropertyName:e.name,vendorId:e.id,cwfId:t.productId,type:"Product",source:e.source,cwfProduct:t,simplotProduct:e},a=g.filter((function(e){return e.cwfId!==t.productId}));return a.length!==g.length?T([].concat(Object(v.a)(a),[n])):T([].concat(Object(v.a)(g),[n]))},unmatchedProducts:o,matchesWithErrors:m})}),Object(y.jsx)(Ax,{onNext:I,loading:P,nextLabel:"Next: Review and Submit",nextDisabled:P||o.length>0,integrationType:KO,isBottomFixed:!0})]})},YP={1:Object(y.jsx)(ky,{}),2:Object(y.jsx)(Vy,{}),3:Object(y.jsx)(UC,{context:KO,FooterComponent:Ax}),4:Object(y.jsx)(By,{}),5:Object(y.jsx)(SP,{integrationName:KO}),6:Object(y.jsx)(ZP,{}),7:Object(y.jsx)(ay,{FooterComponent:Ax,ReviewComponent:wy})},HP=function(e){var t=e.fixedStep,n=Object(a.useContext)(nx).state.step;return YP[null!==t&&void 0!==t?t:n]};HP.propTypes={fixedStep:Ec.PropTypes.number};var GP=HP,WP=[{caption:"Sign in"},{caption:"Select Organization"},{caption:"Select Crop Seasons"},{caption:"Select Properties"},{caption:"Match Crop Zones"},{caption:"Match Products"},{caption:"Review and Submit"}],qP=function(){return Object(y.jsx)(FC,{integrationType:KO,progressBarSteps:WP,selectPropertiesStep:4,StepSelector:GP})},JP=function(){return Object(y.jsx)(hh,{children:Object(y.jsx)(rx,{children:Object(y.jsx)(Zi.e,{initialValues:{},children:function(){return Object(y.jsx)(NC,{integrationType:KO,children:Object(y.jsx)(qP,{})})}})})})},KP=Object(a.createContext)(),QP=function(e){var t=e.children,n=Object(a.useState)([]),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(new Map),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useState)(),O=Object(b.a)(m,2),h=O[0],x=O[1],g=Object(a.useState)(),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(!1),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)(),_=Object(b.a)(w,2),R=_[0],I=_[1],D=Object(a.useState)(),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)(!1),V=Object(b.a)(M,2),B=V[0],U=V[1],z=Object(a.useContext)(we),Z=CO().loadMatchCropZone,Y=Object(a.useContext)(ac),H=Object(b.a)(Y,2)[1],G=function(e){x(e)},W=function(e){i((function(t){return[].concat(Object(v.a)(t),[e]).filter((function(n,a){return[].concat(Object(v.a)(t),[e]).indexOf(n)===a}))}))},q=function(e){i((function(t){return Object(v.a)(t).filter((function(t){return t!==e}))}))},J=function(){i([])},K=function(e){z.sendEventToAmplitude(z.events.epic.Integrations.JohnDeere.selectCropZone),d(e)},Q=function(){U((function(e){return!e}))},X=function(e){A(e)},$=function(){E(!0)},ee=function(){E(!1)},te=function(e){I(e)},ne=function(e){F(e)},re=function(e){0===p.size&&(null===e||void 0===e?void 0:e.length)>0&&f(new Map(e.flatMap((function(e){var t;return null===(t=e.fields)||void 0===t?void 0:t.map((function(e){return[e.id,e.geometry]}))}))))},ce=function(e,t,n){t.length&&!n.length?(H({type:Mr,payload:"success"}),H({type:Hr,payload:{cropZoneName:P,operationMapped:t.length}})):t.length&&n.length?(H({type:Mr,payload:"warning"}),H({type:Hr,payload:{cropZoneName:P,operationMapped:"".concat(t.length," / ").concat(e.length)}})):(H({type:Mr,payload:"error"}),H({type:Hr,payload:{cropZoneName:P,operationMapped:n.length}})),H({type:Vr,payload:!0})},ie=function(){if(h&&c&&l){var e=Intl.DateTimeFormat().resolvedOptions(),t=(new Date).toLocaleString(e.locale,{timeZone:"".concat(e.timeZone),hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"});Promise.allSettled(c.map((function(e){return Z(e,l,h,t)}))).then((function(e){!function(e){var t=ae.a.flatMapDeep(e.map((function(e){return e.value}))),n=ae.a.flatMapDeep(t.filter((function(e){return e.status>=200&&e.status<=300}))),a=ae.a.flatMapDeep(t.filter((function(e){return e.status>=301&&e.status<=500})));if(a.length)return z.sendEventToAmplitude(z.events.epic.Integrations.JohnDeere.cropZoneMatchFailure),ce(t,n,a),void Q();if(z.sendEventToAmplitude(z.events.epic.Integrations.JohnDeere.operationsMatched,{operationsMatched:n.length}),z.sendEventToAmplitude(z.events.epic.Integrations.JohnDeere.cropZoneMatchSuccess),(null===L||void 0===L?void 0:L.operations.length)===c.length){if((null===R||void 0===R?void 0:R.length)-1===0)return ce(t,n,a),void history.back();if((null===R||void 0===R?void 0:R.length)-1>=1)return ce(t,n,a),void Q()}ce(t,n,a),Q()}(e),ee()}))}else ee()},oe=Object(a.useMemo)((function(){return{getOperationId:W,operationReset:J,removeOperationId:q,fieldId:l,setCropZoneId:d,cropSeasonId:h,toMatchCropZone:ie,getCs:G,getCropZoneId:K,operationIds:c,getCropZoneName:X,isLoadingMatcher:N,buttonIsLoading:$,getSourceFields:te,getSelectedSourceField:ne,reloadData:B,extractFieldsGeometriesFromFarms:re,fieldsGeometries:p}}),[h,l,c,N,B,p]);return Object(y.jsx)(KP.Provider,{value:oe,children:t})};QP.defaultProps={children:null};var XP=n(2822),$P=function(){return JSON.parse(localStorage.getItem("selectedCropSeasons"))},eA=function(e){var t=e.sourceField,n=e.selectedSourceField,r=e.onChange,c=Object(a.useContext)(KP).fieldsGeometries,i=t.fieldId===(null===n||void 0===n?void 0:n.fieldId);return Object(y.jsx)(pu,{className:"rounded-xl px-16px py-8px",style:{boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.15)"},onClick:function(){i||r(t)},children:Object(y.jsxs)("div",{className:"flex flex-row items-center",children:[Object(y.jsx)(m.Radio,{checked:i,onChange:function(e){e.target.checked&&r(t)}}),Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsxs)("span",{className:"pl-8px inline-block w-full",children:[t.farmName," / ",t.fieldName]}),Object(y.jsxs)("div",{className:"flex flex-row justify-between pl-8px mt-1",children:[Object(y.jsx)("div",{className:"rounded",style:{width:"108px",height:"48px",backgroundColor:"#F3F4F6",border:"1px solid #A3A9B9"},children:(null===c||void 0===c?void 0:c.get(t.fieldId))&&Object(y.jsx)(Kp,{id:t.fieldId,features:[{type:"Feature",geometry:null===c||void 0===c?void 0:c.get(t.fieldId)}],height:45,width:105,color:"#A3A9B9",className:"flex-shrink-0"})}),Object(y.jsxs)("span",{className:"text-neutral-600 text-sm",children:[t.operations.length," operation",1===t.operations.length?"":"s"]})]})]})]})})},tA=function(e){var t=e.isLoading,n=e.sourceFields,a=e.selectedSourceField,r=e.onChange;return Object(y.jsxs)("div",{"data-testid":"source-field-list",className:"w-full pt-6 px-6 h-full flex flex-col",children:[Object(y.jsxs)("div",{className:"mb-4",children:[Object(y.jsx)("span",{className:"text-base",children:"Source Fields"}),Object(y.jsx)("p",{className:"text-normal",children:"Your fields matched to machinery data. Match operations to your crop zones"})]}),Object(y.jsx)("div",{className:"flex flex-1 flex-col",children:Object(y.jsx)("div",{className:"pt-3 px-1 h-0 flex-grow overflow-y-auto",children:Object(y.jsx)("div",{className:"flex flex-col gap-y-2",children:t?Object(y.jsx)(m.Spinner,{}):n.map((function(e){return Object(y.jsx)(eA,{sourceField:e,selectedSourceField:a,onChange:r},e.fieldId)}))})})})]})},nA=n(2821),aA=n.p+"static/media/chevron_right.976a9027.svg",rA=function(e){var t=e.header,n=e.content,r=e.headerHeight,c=e.isProperty,i=e.isFullWidthButton,o=e.toggleCallback,s=e.dynamicToggle,l=e.canExpand,d=Object(a.useState)(s&&l),u=Object(b.a)(d,2),j=u[0],p=u[1];return Object(y.jsxs)("div",{className:"bg-white rounded mb-4",style:{boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.15)"},"data-testid":"accordion-container",children:[Object(y.jsxs)("button",{className:"flex flex-row items-center focus:outline-none ".concat(c?"py-6":""," \n        ").concat(i||c?"justify-between w-full":"","\n        "),type:"button","data-testid":"accordion-toggle",onClick:function(){s||p(!j),o()},styles:{height:r},children:[t,Object(y.jsx)("img",{className:"pr-16px",src:s&&l||j?Di:aA,alt:"expand collapse accordion"})]}),(s&&l||j)&&Object(y.jsx)("div",{className:"p-4","data-testid":"accordion-content",children:n})]})};rA.defaultProps={toggleCallback:function(){},dynamicToggle:!1,canExpand:!0};var cA,iA,oA,sA,lA,dA=rA,uA=function(e){var t=e;return t=(t=t.replace(/-/g," ")).toUpperCase()},bA=function(e){var t=e.replace(/[^a-zA-Z- ]/g,"").match(/\b\w/g);return t=t.join("")},jA=function(e){return e.slice(0,1).toUpperCase()+e.slice(1).toLowerCase()},pA=n(2820),fA=function(e){return e&&Object(ya.a)(Date.parse(e),"MM/dd/yyyy")},mA=function(e,t){return t?e&&Object(ya.a)(Object(pA.a)(e),t):fA(e)},vA=function(e){return e?Object(ya.a)(Date.parse(e),"MMM d, h:mm aaaa"):""},OA=function(e){return Object(ya.a)(Date.parse(e),"MMM d. y h:mm aaaa")},hA=function(e){return Object(ya.a)(Date.parse(e),"MMMM d, y, h:mm aaaa")},xA=function(e){return e&&Object(ya.a)("number"===typeof e?e:Date.parse(e),"PPP")},gA=function(e){return e&&Object(ya.a)(Date.parse(e),"h:mm aaaa")},CA=function(e){return"".concat(e<10?"0":"").concat(e)},yA=function(e){return"".concat(e.getFullYear(),"-").concat(CA(e.getMonth()+1),"-").concat(CA(e.getDate()))},PA=["title","titleId"];function AA(){return AA=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},AA.apply(this,arguments)}function SA(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function TA(e,t){var n=e.title,r=e.titleId,c=SA(e,PA);return a.createElement("svg",AA({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,cA||(cA=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.4999 12H13.4999L14.877 15.6467C15.1241 16.3008 14.6407 17 13.9415 17H10.0594C9.36032 17 8.87698 16.301 9.12379 15.647L10.4999 12ZM11.4999 14L10.9999 15H12.9999L12.4999 14H11.4999Z",fill:"#E85D78"})),iA||(iA=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.9999 23L10.9999 19H12.9999L12.9999 23H10.9999Z",fill:"#E85D78"})),oA||(oA=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.832 21.0508L14.1679 18.5547L15.832 17.4453L17.4961 19.9414L15.832 21.0508Z",fill:"#E85D78"})),sA||(sA=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.50382 19.9415L8.16792 17.4453L9.83202 18.5547L8.16792 21.0509L6.50382 19.9415Z",fill:"#E85D78"})),lA||(lA=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.18927 3.58212C4.7155 2.92036 5.18851 2 6.00238 2H17.9972C18.8111 2 19.2841 2.92034 18.8104 3.5821L13.4999 11H10.4999L5.18927 3.58212ZM7.94297 4L11.5144 9H12.4852L16.0566 4H7.94297Z",fill:"#E85D78"})))}var NA,EA,wA,_A=a.forwardRef(TA),RA=(n.p,["title","titleId"]);function IA(){return IA=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},IA.apply(this,arguments)}function DA(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function kA(e,t){var n=e.title,r=e.titleId,c=DA(e,RA);return a.createElement("svg",IA({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,NA||(NA=a.createElement("path",{d:"M14.7029 2.14993L15.1655 1.55956C14.8939 1.34672 14.512 1.34672 14.2404 1.55956L14.7029 2.14993Z",fill:"#FF785A"})),EA||(EA=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.8223 5.07637C16.8471 4.927 16.8609 4.77262 16.8609 4.61389C16.8609 3.6845 16.3881 2.90403 15.9956 2.40689C15.7918 2.14877 15.5895 1.94152 15.438 1.79834C15.3617 1.72633 15.2971 1.66942 15.25 1.62925C15.2264 1.60914 15.2071 1.59315 15.1928 1.58149L15.1752 1.56723L15.1693 1.56256L15.1671 1.56085L15.1655 1.55956C15.1655 1.55956 15.1655 1.55956 14.7029 2.14993C14.2404 1.55956 14.2404 1.55956 14.2404 1.55956L14.2387 1.56085L14.2366 1.56256L14.2307 1.56723L14.2131 1.58149C14.1988 1.59315 14.1795 1.60914 14.1559 1.62925C14.1088 1.66942 14.0442 1.72633 13.9679 1.79834C13.8164 1.94152 13.614 2.14877 13.4103 2.40689C13.0178 2.90403 12.545 3.6845 12.545 4.61389C12.545 4.76851 12.5581 4.919 12.5817 5.06475C12.3624 5.00977 12.1531 4.97517 11.9664 4.9532C11.6398 4.91476 11.3502 4.91127 11.1418 4.91721C11.0369 4.9202 10.951 4.92562 10.8893 4.93053C10.8584 4.93299 10.8335 4.93533 10.8151 4.9372L10.7925 4.93959L10.7851 4.94044L10.7824 4.94077L10.7812 4.9409C10.7812 4.9409 10.7803 4.94102 10.8707 5.68555L10.7812 4.9409C10.4387 4.98249 10.1677 5.25259 10.1261 5.59517L10.8707 5.68555C10.1261 5.59517 10.1261 5.59517 10.1261 5.59517L10.1259 5.59725L10.1256 5.59999L10.1247 5.60744L10.1223 5.63C10.1204 5.64836 10.1181 5.67332 10.1156 5.70421C10.1107 5.76593 10.1053 5.85184 10.1023 5.95666C10.0964 6.16509 10.0999 6.4547 10.1383 6.7813C10.2123 7.41033 10.4298 8.29657 11.087 8.95375C11.7442 9.61092 12.6304 9.82844 13.2595 9.90246C13.5861 9.9409 13.8757 9.94439 14.0841 9.93845C14.1889 9.93546 14.2748 9.93004 14.3366 9.92513C14.3675 9.92267 14.3924 9.92033 14.4108 9.91846L14.4333 9.91607L14.4408 9.91522L14.4435 9.9149L14.4446 9.91476C14.4446 9.91476 14.4455 9.91465 14.3848 9.41423L14.4446 9.91476C14.5452 9.90255 14.6405 9.87053 14.7246 9.82288C14.8088 9.87053 14.9031 9.90244 15.0037 9.91465L15.0644 9.41427C15.0037 9.9147 15.0037 9.91465 15.0037 9.91465L15.0058 9.9149L15.0085 9.91522L15.016 9.91607L15.0385 9.91846C15.0569 9.92033 15.0818 9.92267 15.1127 9.92513C15.1745 9.93004 15.2604 9.93546 15.3652 9.93845C15.5736 9.94439 15.8632 9.9409 16.1898 9.90246C16.8189 9.82844 17.7051 9.61092 18.3623 8.95375C19.0194 8.29658 19.237 7.41033 19.311 6.7813C19.3494 6.4547 19.3529 6.16509 19.347 5.95666C19.344 5.85184 19.3386 5.76593 19.3336 5.70421C19.3312 5.67332 19.3288 5.64836 19.327 5.63L19.3246 5.60744L19.3237 5.59999L19.3234 5.59725L19.3233 5.59613C19.3233 5.59613 19.3232 5.59517 18.5786 5.68555L19.3233 5.59613C19.2817 5.25354 19.0116 4.9826 18.669 4.94102L18.5786 5.68555C18.669 4.94102 18.669 4.94102 18.669 4.94102L18.6669 4.94077L18.6642 4.94044L18.6567 4.93959L18.6342 4.9372C18.6158 4.93533 18.5909 4.93299 18.56 4.93053C18.4983 4.92562 18.4123 4.9202 18.3075 4.91721C18.0991 4.91127 17.8095 4.91476 17.4829 4.9532C17.2834 4.97667 17.058 5.01458 16.8223 5.07637ZM14.5876 5.89146C14.6262 5.94031 14.6649 5.98685 14.7029 6.03084C14.741 5.98685 14.7797 5.94031 14.8183 5.89146C15.1298 5.49681 15.3609 5.04531 15.3609 4.61389C15.3609 4.18247 15.1298 3.73097 14.8183 3.33632C14.7797 3.28747 14.741 3.24093 14.7029 3.19694C14.6649 3.24093 14.6262 3.28747 14.5876 3.33632C14.2761 3.73097 14.045 4.18247 14.045 4.61389C14.045 5.04531 14.2761 5.49681 14.5876 5.89146ZM13.6149 8.42977C13.6107 8.37173 13.6051 8.31148 13.5979 8.24967C13.5391 7.75032 13.3833 7.26763 13.0782 6.96257C12.7731 6.65751 12.2904 6.50168 11.7911 6.44292C11.7293 6.43564 11.669 6.43008 11.611 6.42589C11.6152 6.48393 11.6208 6.54418 11.628 6.60599C11.6868 7.10534 11.8426 7.58803 12.1477 7.89309C12.4527 8.19815 12.9354 8.35398 13.4348 8.41274C13.4966 8.42002 13.5568 8.42559 13.6149 8.42977ZM15.8344 8.42977C15.8386 8.37173 15.8442 8.31148 15.8514 8.24967C15.9102 7.75032 16.066 7.26763 16.3711 6.96257C16.6762 6.65751 17.1588 6.50168 17.6582 6.44292C17.72 6.43564 17.7803 6.43008 17.8383 6.42589C17.8341 6.48393 17.8285 6.54418 17.8213 6.60599C17.7625 7.10534 17.6067 7.58803 17.3016 7.89309C16.9966 8.19815 16.5139 8.35398 16.0145 8.41274C15.9527 8.42002 15.8925 8.42559 15.8344 8.42977Z",fill:"#FF785A"})),wA||(wA=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.1667 22C17.3167 22 18.25 21.0917 18.25 19.9725C18.25 19.8346 18.2333 19.6968 18.2083 19.567H18.6667C19.8167 19.567 20.75 18.6587 20.75 17.5395C20.75 17.353 20.725 17.1664 20.675 16.9961C21.45 16.696 22 15.9661 22 15.1065C22 14.1089 21.2583 13.2817 20.2833 13.1114C20.3167 12.9735 20.3333 12.8275 20.3333 12.6735C20.3333 11.5543 19.4 10.6459 18.25 10.6459H13.3417C12 10.6459 11.4073 10.5899 10.7403 10.1747C10.459 9.99957 10.2161 9.78891 10.0147 9.55575C9.63098 9.11126 9.39867 8.58501 9.34137 8.06756L6.39167 9.21047C3.74167 10.2323 2 12.7302 2 15.512C2 19.0966 4.98333 22 8.66667 22H16.1667ZM8.66667 20.378C5.90833 20.378 3.66667 18.1964 3.66667 15.512C3.66667 13.3953 4.99167 11.4975 7.00833 10.7189L8.51154 10.1373C9.45 11.6274 11.4062 12.268 13.3417 12.268H18.25C18.4833 12.268 18.6667 12.4464 18.6667 12.6735C18.6667 12.9005 18.4833 13.079 18.25 13.079H12V14.701H19.9167C20.15 14.701 20.3333 14.8794 20.3333 15.1065C20.3333 15.3336 20.15 15.512 19.9167 15.512H12V17.134H18.6667C18.9 17.134 19.0833 17.3124 19.0833 17.5395C19.0833 17.7666 18.9 17.945 18.6667 17.945H12V19.567H16.1667C16.4 19.567 16.5833 19.7454 16.5833 19.9725C16.5833 20.1996 16.4 20.378 16.1667 20.378H8.66667Z",fill:"#FF785A"})))}var LA,FA,MA,VA,BA=a.forwardRef(kA),UA=(n.p,["title","titleId"]);function zA(){return zA=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},zA.apply(this,arguments)}function ZA(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function YA(e,t){var n=e.title,r=e.titleId,c=ZA(e,UA);return a.createElement("svg",zA({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,LA||(LA=a.createElement("path",{d:"M10.4073 5.77816C11.1922 5.27305 11.1983 4.06746 10.4211 3.08541C9.64384 2.10336 8.37753 1.71673 7.59269 2.22184C6.80785 2.72695 6.80168 3.93254 7.57892 4.91459C8.35616 5.89664 9.62247 6.28327 10.4073 5.77816Z",fill:"#2B9C92"})),FA||(FA=a.createElement("path",{d:"M12.7338 13.3526C13.284 12.539 12.9539 11.2738 11.9963 10.5268C11.0388 9.77974 9.81647 9.83375 9.26622 10.6474C8.71597 11.461 9.04614 12.7262 10.0037 13.4732C10.9612 14.2203 12.1835 14.1662 12.7338 13.3526Z",fill:"#2B9C92"})),MA||(MA=a.createElement("path",{d:"M15.5789 7.08541C14.8017 8.06746 14.8078 9.27305 15.5927 9.77816C16.3775 10.2833 17.6438 9.89664 18.4211 8.91459C19.1983 7.93254 19.1922 6.72695 18.4073 6.22184C17.6225 5.71673 16.3562 6.10336 15.5789 7.08541Z",fill:"#2B9C92"})),VA||(VA=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 13C1.89543 13 1 13.8954 1 15V23H23V15C23 13.8954 22.1046 13 21 13H18.7808C17.8547 13 17.1448 13.614 16.8179 14.2904C16.3693 15.2189 15.1396 17 12 17C8.86039 17 7.63068 15.2189 7.18208 14.2904C6.85523 13.614 6.14526 13 5.21922 13H3ZM3 21V15H5.21925C5.21925 15 5.22277 15 5.22997 15.0024C5.23796 15.0051 5.25184 15.0112 5.26998 15.0241C5.30878 15.0515 5.35156 15.0991 5.38128 15.1606C6.04685 16.538 7.85681 19 12 19C16.1432 19 17.9531 16.538 18.6187 15.1606C18.6484 15.0991 18.6912 15.0515 18.73 15.0241C18.7482 15.0112 18.762 15.0051 18.77 15.0024C18.7772 15 18.7808 15 18.7808 15H21V21H3Z",fill:"#2B9C92"})))}var HA,GA=a.forwardRef(YA),WA=(n.p,["title","titleId"]);function qA(){return qA=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},qA.apply(this,arguments)}function JA(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function KA(e,t){var n=e.title,r=e.titleId,c=JA(e,WA);return a.createElement("svg",qA({width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,HA||(HA=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 1.5C4.86 1.5 1.5 4.86 1.5 9C1.5 13.14 4.86 16.5 9 16.5C13.14 16.5 16.5 13.14 16.5 9C16.5 4.86 13.14 1.5 9 1.5ZM8.25 5.25V6.75H9.75V5.25H8.25ZM8.25 8.25V12.75H9.75V8.25H8.25ZM3 9C3 12.3075 5.6925 15 9 15C12.3075 15 15 12.3075 15 9C15 5.6925 12.3075 3 9 3C5.6925 3 3 5.6925 3 9Z",fill:"#0071CD"})))}var QA,XA,$A=a.forwardRef(KA),eS=(n.p,["title","titleId"]);function tS(){return tS=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},tS.apply(this,arguments)}function nS(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function aS(e,t){var n=e.title,r=e.titleId,c=nS(e,eS);return a.createElement("svg",tS({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,QA||(QA=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 13C1.89543 13 1 13.8954 1 15V23H23V15C23 13.8954 22.1046 13 21 13H18.7808C17.8547 13 17.1448 13.614 16.8179 14.2904C16.3693 15.2189 15.1396 17 12 17C8.86039 17 7.63068 15.2189 7.18208 14.2904C6.85523 13.614 6.14526 13 5.21922 13H3ZM3 21V15H5.21925C5.21925 15 5.22277 15 5.22997 15.0024C5.23796 15.0051 5.25184 15.0112 5.26998 15.0241C5.30878 15.0515 5.35156 15.0991 5.38128 15.1606C6.04685 16.538 7.85681 19 12 19C16.1432 19 17.9531 16.538 18.6187 15.1606C18.6484 15.0991 18.6912 15.0515 18.73 15.0241C18.7482 15.0112 18.762 15.0051 18.77 15.0024C18.7772 15 18.7808 15 18.7808 15H21V21H3Z",fill:"#E99921"})),XA||(XA=a.createElement("path",{d:"M16.2702 8.69358C16.2702 8.44306 16.236 8.21532 16.2019 7.97619L17.5 6.82609L16.3613 4.85611L14.7101 5.41408C14.3458 5.10663 13.9358 4.86749 13.4803 4.69669L13.1387 3H10.8613L10.5197 4.69669C10.0642 4.86749 9.65424 5.10663 9.28985 5.41408L7.63872 4.85611L6.5 6.82609L7.79814 7.97619C7.76398 8.21532 7.72981 8.44306 7.72981 8.69358C7.72981 8.9441 7.76398 9.17184 7.79814 9.41097L6.5 10.5611L7.63872 12.5311L9.28985 11.9731C9.65424 12.2805 10.0642 12.5197 10.5197 12.6905L10.8613 14.3872H13.1387L13.4803 12.6905C13.9358 12.5197 14.3458 12.2805 14.7101 11.9731L16.3613 12.5311L17.5 10.5611L16.2019 9.41097C16.236 9.17184 16.2702 8.9441 16.2702 8.69358ZM12 10.971C10.7474 10.971 9.72257 9.94617 9.72257 8.69358C9.72257 7.44099 10.7474 6.41615 12 6.41615C13.2526 6.41615 14.2774 7.44099 14.2774 8.69358C14.2774 9.94617 13.2526 10.971 12 10.971Z",fill:"#E99921"})))}var rS,cS,iS=a.forwardRef(aS),oS=(n.p,["title","titleId"]);function sS(){return sS=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},sS.apply(this,arguments)}function lS(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function dS(e,t){var n=e.title,r=e.titleId,c=lS(e,oS);return a.createElement("svg",sS({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,rS||(rS=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.4464 17.8608C14.9252 19.0745 12.9973 19.8 10.9 19.8C5.98467 19.8 2 15.8153 2 10.9C2 5.98467 5.98467 2 10.9 2C15.8153 2 19.8 5.98467 19.8 10.9C19.8 12.9974 19.0745 14.9254 17.8607 16.4466L21.9805 20.5664L20.5663 21.9806L16.4464 17.8608ZM17.6 10.9C17.6 14.6003 14.6003 17.6 10.9 17.6C7.19964 17.6 4.19995 14.6003 4.19995 10.9C4.19995 7.19964 7.19964 4.19995 10.9 4.19995C14.6003 4.19995 17.6 7.19964 17.6 10.9Z",fill:"#8354D6"})),cS||(cS=a.createElement("path",{d:"M7.21213 7.0104C7.21425 7.06461 7.21841 7.14104 7.22657 7.23489C7.24283 7.422 7.27524 7.68153 7.34025 7.97425C7.46773 8.54821 7.73273 9.30578 8.30154 9.87453C8.87853 10.4515 9.58886 10.6571 10.1265 10.7241C10.2778 10.743 10.4183 10.7513 10.5425 10.7535V15.9447H11.4947V13.8721C11.603 13.8781 11.7234 13.8821 11.8519 13.8821C12.3524 13.8819 13.0367 13.8216 13.6124 13.533C14.216 13.2304 14.6312 12.6541 14.8835 12.2132C15.0142 11.9847 15.1117 11.7736 15.1767 11.6194C15.2094 11.542 15.2341 11.4782 15.2511 11.4326C15.2511 11.4326 15.2997 11.3266 15.3999 10.9925C15.2511 10.8751 14.9935 10.7525 14.9935 10.7525C14.9492 10.7295 14.8873 10.6992 14.8103 10.6662C14.6568 10.6004 14.439 10.522 14.1768 10.4696C13.6514 10.3645 12.9269 10.361 12.2019 10.796C11.9223 10.9638 11.689 11.1636 11.4947 11.3748L11.4952 10.2486C11.4957 10.2335 11.4962 10.2124 11.4966 10.1859C11.4974 10.133 11.4975 10.0581 11.4949 9.96583C11.4898 9.78189 11.474 9.52607 11.4312 9.23586C11.3475 8.66852 11.1521 7.91018 10.6761 7.31582C10.1537 6.66352 9.33294 6.47167 8.73884 6.4187C8.43007 6.39117 8.15149 6.39832 7.95068 6.41204C7.84974 6.41893 7.76708 6.42759 7.70842 6.43471C7.70842 6.43471 7.67487 6.43471 7.2099 6.51398C7.20994 6.899 7.21213 7.0104 7.21213 7.0104Z",fill:"#8354D6"})))}var uS,bS=a.forwardRef(dS),jS=(n.p,["title","titleId"]);function pS(){return pS=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},pS.apply(this,arguments)}function fS(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function mS(e,t){var n=e.title,r=e.titleId,c=fS(e,jS);return a.createElement("svg",pS({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,uS||(uS=a.createElement("path",{d:"M21.98 14H22H21.98ZM5.35 13C6.54 13 6.77 14 8.68 14C10.63 14 10.77 13 12.01 13C13.2 13 13.43 14 15.34 14C17.29 14 17.43 13 18.67 13C19.86 13 20.07 13.98 21.98 14V12C20.79 12 20.56 11 18.65 11C16.7 11 16.56 12 15.32 12C14.13 12 13.9 11 11.99 11C10.04 11 9.9 12 8.66 12C7.47 12 7.24 11 5.33 11C3.38 11 3.24 12 2 12V14C3.9 14 4.17 13 5.35 13ZM18.67 15C16.72 15 16.58 16 15.34 16C14.15 16 13.92 15 12.01 15C10.06 15 9.91 16 8.67 16C7.43 16 7.29 15 5.34 15C3.39 15 3.24 16 2 16V18C3.95 18 4.11 17 5.34 17C6.58 17 6.72 18 8.67 18C10.62 18 10.77 17 12.01 17C13.2 17 13.43 18 15.34 18C17.28 18 17.43 17 18.67 17C19.86 17 20.09 18 22 18V16C20.76 16 20.62 15 18.67 15ZM5.35 9C6.54 9 6.77 10 8.68 10C10.63 10 10.77 9 12.01 9C13.2 9 13.43 10 15.34 10C17.29 10 17.43 9 18.67 9C19.86 9 20.07 9.98 21.98 10V8C20.79 8 20.56 7 18.65 7C16.7 7 16.56 8 15.32 8C14.13 8 13.9 7 11.99 7C10.04 7 9.9 8 8.66 8C7.47 8 7.24 7 5.33 7C3.38 7 3.24 8 2 8V10C3.9 10 4.17 9 5.35 9Z",fill:"#0092E4"})))}var vS,OS,hS=a.forwardRef(mS),xS=(n.p,["title","titleId"]);function gS(){return gS=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},gS.apply(this,arguments)}function CS(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function yS(e,t){var n=e.title,r=e.titleId,c=CS(e,xS);return a.createElement("svg",gS({width:32,height:32,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,vS||(vS=a.createElement("rect",{x:.5,y:.5,width:31,height:31,rx:15.5,fill:"#EB4B4B",stroke:"#EB4B4B"})),OS||(OS=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.16458 20.2486L15.1495 8.49234C15.4385 8.00588 16.0536 7.8542 16.5233 8.15357C16.6564 8.23842 16.7684 8.35446 16.8503 8.49234L23.8353 20.2486C24.1564 20.7891 23.9937 21.4969 23.4718 21.8295C23.297 21.941 23.0957 22 22.8904 22H9.10949C8.49674 22 8 21.4855 8 20.8508C8 20.6382 8.05698 20.4297 8.16458 20.2486ZM16 20C16.5523 20 17 19.5523 17 19C17 18.4477 16.5523 18 16 18C15.4477 18 15 18.4477 15 19C15 19.5523 15.4477 20 16 20ZM16 12C15.4477 12 15 12.4477 15 13V16C15 16.5523 15.4477 17 16 17C16.5523 17 17 16.5523 17 16V13C17 12.4477 16.5523 12 16 12Z",fill:"white"})))}var PS=a.forwardRef(yS),AS=(n.p,function(){var e=document.querySelectorAll("#checked-items");return Object(v.a)(e)}),SS={JOHN_DEERE:"JOHN DEERE"},TS=function(e){var t=e.isCheckedAllInstances,n=e.operation,r=e.selectedField,c={HARVEST:Object(y.jsx)(BA,{}),PLANTING:Object(y.jsx)(GA,{}),APPLICATION:Object(y.jsx)(_A,{}),TILLAGE:Object(y.jsx)(iS,{}),OBSERVATION:Object(y.jsx)(bS,{}),IRRIGATION:Object(y.jsx)(hS,{}),MISSING:Object(y.jsx)(PS,{})},i=Object(a.useState)(!1),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useContext)(KP),u=d.getOperationId,j=d.removeOperationId,p=d.operationReset,f=d.operationIds,v=d.fieldsGeometries,O=function(e){e.stopPropagation(),l((function(e){return!e})),u(null===n||void 0===n?void 0:n.id),AS().forEach((function(e){e.checked||j(e.dataset.operationid)}))},h=function(){AS().forEach((function(e){u(e.dataset.operationid)}))};Object(a.useEffect)((function(){if(r){if(t)return l(!0),void h();if(AS().length===f.length)return l(!1),void p();if(f.length&&r.operations.find((function(e){return e.id===f[0]})))return l(!0),void h();l(!1),p()}}),[t]);return Object(y.jsx)(dA,{header:function(){var e,t,a=n.operation_types[0];return Object(y.jsxs)("div",{"data-testid":"source-operation-".concat(n.id),className:"h-40px w-670px flex flex-row items-center pl-4",children:[Object(y.jsx)(m.Checkbox,{onClick:O,checked:s,id:"checked-items","data-operationId":null===n||void 0===n?void 0:n.id}),Object(y.jsx)("div",{className:"ml-4",children:c[a]?c[a]:c.MISSING}),Object(y.jsx)("span",{className:"ml-4",children:jA(n.operation_types[0])}),Object(y.jsx)("span",{className:"".concat(s?"font-semibold":""," ml-4"),children:OA(n.start_date_time)}),(null===n||void 0===n?void 0:n.aliases)&&Object(y.jsx)("div",{className:"ml-auto",children:Object(y.jsx)(m.TagCloud,{children:null===(e=n.aliases)||void 0===e||null===(t=e.filter((function(e){return(null===e||void 0===e?void 0:e.system_type)&&SS[e.system_type]})))||void 0===t?void 0:t.map((function(e){return Object(y.jsx)(m.Tag,{color:"#696F88",children:SS[e.system_type]},e.system_type)}))})})]})}(),content:function(){var e,t,a=(t=null===n||void 0===n||null===(e=n.task_measures[0])||void 0===e?void 0:e.value,parseFloat(t)/4046.864224);return Object(y.jsxs)("div",{className:"flex flex-row",style:{minHeight:"200px"},children:[Object(y.jsxs)("div",{style:{width:"360px"},children:[Object(y.jsx)("span",{className:"h-24px w-82px text-sm rounded text-white font-semibold px-2 py-1 ",style:{backgroundColor:"#868CA2"},children:"Boundary"}),Object(y.jsxs)("div",{className:"flex flex-row mt-2",children:[Object(y.jsx)("div",{className:"mr-2 pt-6px",children:Object(y.jsx)("svg",{width:"12",height:"16",viewBox:"0 0 12 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2C8.5125 2 10.5 3.9275 10.5 6.65C10.5 8.405 9.0375 10.73 6 13.505C2.9625 10.73 1.5 8.405 1.5 6.65C1.5 3.9275 3.4875 2 6 2ZM12 6.65C12 2.915 9.15 0.5 6 0.5C2.85 0.5 0 2.915 0 6.65C0 9.14 2.0025 12.0875 6 15.5C9.9975 12.0875 12 9.14 12 6.65ZM4.5 6.5C4.5 7.325 5.175 8 6 8C6.825 8 7.5 7.325 7.5 6.5C7.5 5.675 6.825 5 6 5C5.175 5 4.5 5.675 4.5 6.5Z",fill:"#696F88"})})}),Object(y.jsxs)("div",{children:[Object(y.jsx)("span",{className:"font-normal text-sm ",children:n.farms[0].description}),Object(y.jsx)("br",{}),Object(y.jsx)("span",{className:"font-normal text-sm",children:null===r||void 0===r?void 0:r.fieldName})]})]}),Object(y.jsxs)("div",{className:"flex flex-row mt-4 items-center",children:[Object(y.jsx)("div",{className:"rounded ",style:{width:"108px",height:"58px",backgroundColor:"#F3F4F6"},children:(null===v||void 0===v?void 0:v.get(null===r||void 0===r?void 0:r.fieldId))&&Object(y.jsx)(Kp,{id:null===r||void 0===r?void 0:r.fieldId,features:[{type:"Feature",geometry:null===v||void 0===v?void 0:v.get(null===r||void 0===r?void 0:r.fieldId)}],height:58,width:108,color:"#A3A9B9",className:"flex-shrink-0"})}),Object(y.jsxs)("p",{className:"ml-6 text-sm",children:[Object(y.jsx)("span",{className:"text-neutral-50 font-normal",children:"Total Area"}),Object(y.jsx)("br",{}),Object(y.jsxs)("span",{className:"flex flex-row font-semibold text-base",children:[a.toFixed(2)," ac"," ",a.toFixed(2)<=0?Object(y.jsx)("div",{className:"mt-1",children:Object(y.jsx)(m.Popup,{enableHover:!0,position:"top",align:"center",hasArrow:!0,bgColor:"#232630",trigger:Object(y.jsx)("div",{className:"pl-1",children:Object(y.jsx)($A,{})}),children:Object(y.jsxs)("div",{className:"text-xs text-white",children:[a," ac"]})})}):null]})]})]})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("span",{className:"h-24px w-82px text-sm rounded text-white font-semibold px-2 py-1 ",style:{backgroundColor:"#868CA2"},children:"Details"}),Object(y.jsxs)("div",{className:"flex flex-col mt-2",children:[Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)("div",{className:"mr-2",style:{paddingTop:"6px"},children:Object(y.jsx)("svg",{width:"16",height:"18",viewBox:"0 0 16 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14 2.25H13.25V0.75H11.75V2.25H4.25V0.75H2.75V2.25H2C1.175 2.25 0.5 2.925 0.5 3.75V15.75C0.5 16.575 1.175 17.25 2 17.25H14C14.825 17.25 15.5 16.575 15.5 15.75V3.75C15.5 2.925 14.825 2.25 14 2.25ZM14 15.75H2V7.5H14V15.75ZM2 6H14V3.75H2V6Z",fill:"#696F88"})})}),Object(y.jsxs)("div",{children:[Object(y.jsxs)("p",{className:"font-normal text-sm mt-1",children:[Object(y.jsx)("span",{className:"text-neutral-50 font-normal mr-2",children:"Start:"}),OA(n.start_date_time)]}),Object(y.jsxs)("p",{className:"font-normal text-sm",children:[Object(y.jsx)("span",{className:"text-neutral-50 font-normal mr-2",children:"End:"}),OA(n.end_date_time)]})]})]}),Object(y.jsxs)("div",{className:"flex flex-row mt-4 items-center",children:[Object(y.jsx)("svg",{width:"18",height:"14",viewBox:"0 0 18 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.75 6.55L9 0.25L17.25 6.55L16.3425 7.735L15 6.715V13.75H3V6.715L1.6575 7.7425L0.75 6.55ZM13.5 12.25H12.75V9.25H11.25V6.25H6.75V9.25H5.25V12.25H4.5V5.575L9 2.14L13.5 5.575V12.25ZM6.75 10.75V12.25H8.25V10.75H6.75ZM9.75 10.75V12.25H11.25V10.75H9.75ZM9.75 9.25V7.75H8.25V9.25H9.75Z",fill:"#696F88"})}),Object(y.jsxs)("p",{className:"ml-2",children:[Object(y.jsx)("span",{className:"text-neutral-50 font-normal mr-2",children:"Products:"}),n.products.map((function(e){return Object(y.jsx)("div",{children:Object(y.jsx)("span",{className:"font-normal text-sm",children:e.description},e.id)},e.id)}))]})]})]})]})]})}(),headerHeight:"40px"})},NS=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return null===(e=Object(v.a)(t))||void 0===e?void 0:e.sort((function(e,t){return e.start_date_time>t.start_date_time?-1:e.start_date_time<t.start_date_time?1:0}))},ES=function(e){var t=e.selectedSourceField,n=e.isLoadingOperations,r=e.selectedSeasons,c=Object(a.useState)(void 0),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useRef)(t),d=CO(),u=d.loadUnmappedFarms,j=d.unmappedFarms,p=d.isLoadingFields,f=Object(a.useState)([]),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)(!1),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(!1),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)([]),w=Object(b.a)(E,2),_=w[0],R=w[1],D=n?[]:NS(null===t||void 0===t?void 0:t.operations),k=Object(a.useContext)(KP),L=k.toMatchCropZone,F=k.getCropZoneId,M=k.getCropZoneName,V=k.operationReset,B=k.operationIds,U=k.fieldId,z=k.cropSeasonId,Z=k.isLoadingMatcher,Y=k.buttonIsLoading,H=k.reloadData,G=k.getCs,W=k.extractFieldsGeometriesFromFarms;Object(a.useEffect)((function(){M(null===o||void 0===o?void 0:o.name)}),[o]),Object(a.useEffect)((function(){F(null===o||void 0===o?void 0:o.id)}),[o,p]),Object(a.useEffect)((function(){V(),N(!1)}),[O]),Object(a.useEffect)((function(){var e;G(null===o||void 0===o||null===(e=o.cropSeasons[0])||void 0===e?void 0:e.id)}),[o]),Object(a.useEffect)((function(){s(void 0),G(void 0),V(),N(!1)}),[t]),Object(a.useEffect)((function(){(0!==AS().length||0!==B.length)&&AS().length===B.length?(R(!0),N(!0)):R(!1)}),[B]),Object(a.useEffect)((function(){var e;if(r.length&&((null===(e=l.current)||void 0===e?void 0:e.fieldId)===(null===t||void 0===t?void 0:t.fieldId)?u(r):l.current=t,null!==j&&void 0!==j&&j.length&&t)){var n=ae.a.flattenDeep(j.map((function(e){return e.fields.filter((function(e){return e.id===t.fieldId})).map((function(t){return t.cropzones.map((function(n){return Object(I.a)(Object(I.a)({},n),{},{fieldName:t.name,farmName:e.name})}))}))})));h(n)}}),[j,H,r,t]),Object(a.useEffect)((function(){null!==j&&void 0!==j&&j.length&&W(j)}),[j]);return Object(y.jsxs)("div",{className:"flex flex-col h-full items-center mt-8",children:[Object(y.jsxs)("div",{className:"h-40px w-720px flex flex-row justify-between items-center mb-4",children:[Object(y.jsx)("div",{style:{width:"46%"},className:"pointer-events-none",children:Object(y.jsx)(m.Input,{value:null===t||void 0===t?void 0:t.fieldName})}),Object(y.jsx)(nA.a,{fill:"696F88"}),Object(y.jsxs)("div",{style:{width:"46%"},children:[Object(y.jsx)(m.Select,{onClick:function(){P(!C)},inputValue:null===o||void 0===o?void 0:o.name,items:[],placeholder:"Select Crop Zone"}),C?Object(y.jsxs)("div",{className:"absolute z-50 mt-1",children:[O.length?Object(y.jsx)("div",{className:"bg-white rounded w-332px pt-6px pb-6px font-semibold\ttext-xs text-neutral-600 pl-3",children:"Crop Zones in Source Field"}):Object(y.jsx)("div",{}),Object(y.jsx)("div",{children:p?Object(y.jsx)("div",{className:"h-40px w-332px bg-white",children:Object(y.jsx)(m.Spinner,{size:"sm"})}):O.length?O.map((function(e){return Object(y.jsx)(pu,{onClick:function(){!function(e){P(!1),s(e)}(e)},className:"bg-white rounded w-332px max-h-80 overflow-auto py-6px",children:Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"w-30px mr-4"}),Object(y.jsxs)("div",{children:[Object(y.jsxs)("div",{className:"font-normal text-sm text-neutral-1000",children:[e.fieldName," / ",e.name]}),Object(y.jsx)("div",{className:"text-xs\tfont-normal text-neutral-600",children:e.farmName})]})]})},e.id)})):Object(y.jsx)("div",{className:"bg-white rounded w-332px max-h-80 overflow-auto px-3 py-8px",children:"No crop zones for this field for selected crop season. Try changing your crop season selection"})})]}):Object(y.jsx)("div",{})]})]}),Object(y.jsxs)("div",{className:"h-480px w-720px bg-white rounded overflow-y-scroll",style:{border:"1px solid #C2C7D0"},children:[Object(y.jsx)("div",{className:"h-48px flex w-full bg-white shadow items-center mb-4 sticky",style:{width:"718px",borderRadius:"6px 6px 0px 0px",position:"absolute",zIndex:"1"},children:Object(y.jsx)(m.Checkbox,{label:"Select All instances",style:{marginLeft:"24px"},checked:_,onClick:function(){N((function(e){return!e}))}})}),Object(y.jsx)("div",{className:"mt-60px",children:Object(y.jsx)("div",{className:"flex flex-col items-center h-full px-16px",id:"listOfInstances",children:n?Object(y.jsx)(m.Spinner,{}):null===D||void 0===D?void 0:D.map((function(e,n){return Object(y.jsx)(TS,{index:n,operation:e,selectedField:t,isCheckedAllInstances:T},e.id)}))})})]}),Object(y.jsxs)("div",{className:"h-76px w-720px flex flex-row items-center justify-end",children:[Object(y.jsx)("div",{className:"font-normal text-sm text-neutral-600 mr-26px",children:B.length?B.length>1?"".concat(B.length," operations will be updated."):"1 operation will be updated.":""}),Object(y.jsx)(m.Button,{type:"primary",onClick:function(){Y(),L()},disabled:!(null!==B&&void 0!==B&&B.length)||!z||!U||Z,loading:Z,children:"Match to Crop Zone"})]})]})};var wS=function(){var e,t,n=null===ac||void 0===ac||null===(e=ac._currentValue[0])||void 0===e||null===(t=e.organization)||void 0===t?void 0:t.id,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(null),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(!1),p=Object(b.a)(j,2),f=p[0],m=p[1],v=Object(a.useState)(null),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useContext)(ac),C=Object(b.a)(g,2)[1],y=function(e){return Dn.post(Array.isArray(e)?e:[e],{headers:{"cwf-context":JSON.stringify({organization_id:n})}}).promise},P=function(){var e=Object(Y.a)(G.a.mark((function e(t,n,a){var r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u(),o(!0),r=y(t),e.next=5,r.then((function(){n&&n()})).catch((function(e){u(e.message),a&&a()})).finally((function(){o(!1)}));case 5:case"end":return e.stop()}}),e)})));return function(t,n,a){return e.apply(this,arguments)}}(),A=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,i;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.itemsToUpdate,a=void 0===n?[]:n,r=t.itemsToCreate,c=void 0===r?[]:r,u(),o(!0),(i=[]).push(y(a)),c.forEach((function(e){i.push(Yt.create(e).promise)})),e.next=8,Promise.all(i).catch((function(e){u(e.message)})).finally((function(){o(!1)}));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),S=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Yt.fetch(t),a=n.promise,e.abrupt("return",a);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),T=function(){var e=Object(Y.a)(G.a.mark((function e(t){var a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u(),o(!0),r=(a=function(){return Yt.update(t.id,t,{headers:{"cwf-context":JSON.stringify({organization_id:n})}})})(),c=r.promise,e.abrupt("return",c.then((function(){a().promise.catch((function(e){u(e.message)})).finally((function(){o(!1)}))})));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),N=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return x(null),m(!0),n=Yn(Rn,"product/".concat(t,"/hide")).patch(),a=n.promise,e.next=5,a.catch((function(e){x(e.message),m(!1),C({type:Yr,payload:!0}),C({type:Zr,payload:"Unable to remove product."}),C({type:zr,payload:"error"}),C({type:Ur,payload:!0})})).finally((function(){m(!1)}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{fetchCustomProduct:S,addUpdateListPrice:P,addProducts:A,updateCustomProduct:T,isUpdateLoading:i,updateError:d,setUpdateError:u,removeProduct:N,isRemoveLoading:f,removeError:h,setRemoveError:x}},_S=function(e){var t;return Object(I.a)({productId:null!==(t=e.productId)&&void 0!==t?t:e.id,averagePricePerUnit:parseFloat(e.averagePricePerUnit)},null!==e&&void 0!==e&&e.packageWeight?{packageWeight:parseFloat(null===e||void 0===e?void 0:e.packageWeight)}:{})},RS=function(e){return Object.keys(e).reduce((function(t,n){return Object(I.a)(Object(I.a)({},t),{},Object(et.a)({},n,isNaN(e[n])?parseFloat(e[n].replace(/%/g,"")):e[n]))}),{})},IS=function(e){var t;return{id:null!==(t=e.id)&&void 0!==t?t:e.productId,name:e.name,manufacturer:e.manufacturer,standardUnit:e.standardUnit,type:e.type,makeUp:e.makeUp,density:parseFloat(e.density),stdFactor:parseFloat(e.stdFactor),stdPackageUnit:e.standardUnit,formulation:RS(e.formulation),averagePricePerUnit:parseFloat(e.averagePricePerUnit)}},DS=function(e,t){var n=Object(a.useContext)(ac),r=Object(b.a)(n,1)[0],c=Object(a.useState)((function(){if("undefined"===typeof window)return t;try{var n=window.sessionStorage.getItem(e);return n?JSON.parse(n):t}catch(a){return t}})),i=Object(b.a)(c,2),o=i[0],s=i[1];return{storedValue:o,setValue:function(t){try{var n=t instanceof Function?t(o):t;s(n),"undefined"!==typeof window&&window.sessionStorage.setItem(e,JSON.stringify(n))}catch(a){r(a)}}}},kS=n.p+"static/media/close.c1fb5b22.svg",LS=n(70),FS=n(39),MS=function(e){if(!e&&0!==e)return null;var t=(new LS.Pound).ConversionFactor,n=(new LS.Gallon).ConversionFactor;return FS.b.divideSafeRound(FS.b.multiplyRound(FS.b.parseFloatRound(e),t),n)},VS=function(e){if(!e&&0!==e)return null;var t=(new LS.Pound).ConversionFactor,n=(new LS.Gallon).ConversionFactor;return FS.b.divideSafeRound(FS.b.multiplyRound(FS.b.parseFloatRound(e),n),t)};n(1545);var BS=function(e){var t=e.fieldName,n=e.type,r=e.isDisabled,c=e.isRequired,i=e.precision,o=e.inputSuffix,s=e.id,l=e.inputPrefix,d=e.onControlledChange,u=e.round,j=Object(Zi.h)(),p=j.values,f=j.touched,m=j.errors,v=j.setFieldValue,O=j.setFieldTouched,h=j.validateField,x=p[t],g=m[t],C=Object(a.useState)(""),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(!1),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useCallback)((function(e){var t;if(g)S(e);else{var n=null===(t=FS.b.parseFloatRound(e,i))||void 0===t?void 0:t.toFixed(i),a=isNaN(n);S(a?e:n)}}),[i,g]);Object(a.useEffect)((function(){E||_(x)}),[x,E,_]);var R=function(e,t){var n;return function(){for(var a=arguments.length,r=new Array(a),c=0;c<a;c++)r[c]=arguments[c];var i=this;clearTimeout(n),n=setTimeout((function(){return e.apply(i,r)}),t)}}((function(){if(w(!1),!m[t]){var e=FS.b.parseFloatRound(x,u);v(t,isNaN(e)?"":e).then((function(){h(t),_(x)})),O(t,!1)}}),300),I=function(){w(!0)};return Object(y.jsx)(Zi.b,{name:t,children:function(){return Object(y.jsx)(Xc.Input,{"data-testid":"".concat(t,"-input"),id:s,disabled:r,prefix:l,suffix:o,size:"middle",type:n,required:c,className:m[t]&&f[t]?"border border-remove":"",value:E?x:A,onChange:(e=t,function(n){var a=n.target.value;O(t,!0),v(e,a).then((function(){h(e),_(a)})),d&&d(n)}),onBlur:R,onFocus:I});var e}})};BS.defaultProps={isDisabled:!1,isRequired:!1,precision:2,inputSuffix:null,inputPrefix:"",id:"",type:"text",onControlledChange:null,round:FS.a};var US=BS,zS=function(){var e=Object(Zi.h)().setFieldValue;return Object(y.jsxs)("div",{name:"ChemicalSection","data-testid":"product-chemical-section",children:[Object(y.jsx)("div",{className:"mt-12 font-bold text-lg",children:"Major"}),Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)(m.Columns,{wrap:!0,children:[Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pr-2",children:Object(y.jsx)(m.Input,{id:"n-input",name:"formulation.N",label:"N",placeholder:"0%",onChange:function(t){e("formulation.N",t.target.value)}})})}),Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pl-2 pr-2",children:Object(y.jsx)(m.Input,{id:"p-input",name:"formulation.P",label:"P",placeholder:"0%",onChange:function(t){e("formulation.P",t.target.value)}})})}),Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pl-2",children:Object(y.jsx)(m.Input,{id:"k-input",name:"formulation.K",label:"K",placeholder:"0%",onChange:function(t){e("formulation.K",t.target.value)}})})})]})}),Object(y.jsx)("div",{className:"mt-12 font-bold text-lg",children:"Minor"}),Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)(m.Columns,{wrap:!0,children:[Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pr-2",children:Object(y.jsx)(m.Input,{id:"c-ainput",name:"formulation.Ca",label:"Ca",placeholder:"0%",onChange:function(t){e("formulation.Ca",t.target.value)}})})}),Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pl-2 pr-2",children:Object(y.jsx)(m.Input,{id:"mg-input",name:"formulation.Mg",label:"Mg",placeholder:"0%",onChange:function(t){e("formulation.Mg",t.target.value)}})})}),Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pl-2",children:Object(y.jsx)(m.Input,{id:"s-input",name:"formulation.S",label:"S",placeholder:"0%",onChange:function(t){e("formulation.S",t.target.value)}})})})]})}),Object(y.jsx)("div",{className:"mt-12 font-bold text-lg",children:"Micro"}),Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)(m.Columns,{wrap:!0,children:[Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pr-2",children:Object(y.jsx)(m.Input,{id:"fe-input",name:"formulation.Fe",label:"Fe",placeholder:"0%",onChange:function(t){e("formulation.Fe",t.target.value)}})})}),Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pl-2 pr-2",children:Object(y.jsx)(m.Input,{id:"cu-input",name:"formulation.Cu",label:"Cu",placeholder:"0%",onChange:function(t){e("formulation.Cu",t.target.value)}})})}),Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pl-2",children:Object(y.jsx)(m.Input,{id:"mn-input",name:"formulation.Mn",label:"Mn",placeholder:"0%",onChange:function(t){e("formulation.Mn",t.target.value)}})})}),Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pl-2",children:Object(y.jsx)(m.Input,{id:"zn-input",name:"formulation.Zn",label:"Zn",placeholder:"0%",onChange:function(t){e("formulation.Zn",t.target.value)}})})})]})}),Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)(m.Columns,{wrap:!0,children:[Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pr-2",children:Object(y.jsx)(m.Input,{id:"b-input",name:"formulation.B",label:"B",placeholder:"0%",onChange:function(t){e("formulation.B",t.target.value)}})})}),Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pl-2 pr-2",children:Object(y.jsx)(m.Input,{id:"mo-input",name:"formulation.Mo",label:"Mo",placeholder:"0%",onChange:function(t){e("formulation.Mo",t.target.value)}})})}),Object(y.jsx)(m.Column,{width:"w-1/4",children:Object(y.jsx)("div",{className:"pl-2",children:Object(y.jsx)(m.Input,{id:"cl-input",name:"formulation.Cl",label:"Cl",placeholder:"0%",onChange:function(t){e("formulation.Cl",t.target.value)}})})})]})})]})},ZS=Fu.e().shape({S:Fu.d().default(0),B:Fu.d().default(0),Cl:Fu.d().default(0),N:Fu.d().default(0),P:Fu.d().default(0),K:Fu.d().default(0),Ca:Fu.d().default(0),Mg:Fu.d().default(0),Cu:Fu.d().default(0),Fe:Fu.d().default(0),Mn:Fu.d().default(0),Mo:Fu.d().default(0),Zn:Fu.d().default(0)}),YS={name:Fu.f().trim().required("Product Name is a required field"),manufacturer:Fu.f().trim().required("Manufacturer is a required field"),standardUnit:Fu.f().trim().required("Standard Unit is a required field"),type:Fu.f().default("Fertilizer"),makeUp:Fu.f().trim().required("Make-Up is a required field"),densityInLbsPerGallon:Fu.d().transform((function(e,t){return""===t?void 0:e})).nullable().default(0),density:Fu.d().default(),stdFactor:Fu.d().default(0),stdPackageUnit:Fu.f().trim().default(""),formulation:ZS},HS=Fu.e().shape(YS),GS=Fu.e().shape(Object(I.a)(Object(I.a)({},YS),{},{densityInLbsPerGallon:Fu.d().nullable(),density:Fu.d().when("makeUp",{is:function(e){return e&&"liquid"===e.toLowerCase()},then:Fu.d().required("Required").positive("Density must be a positive number"),otherwise:Fu.d().positive("Density must be a positive number")})})),WS=Fu.e().shape({name:Fu.f().trim().required("Product Name is a required field"),manufacturer:Fu.f().trim().required("Manufacturer is a required fields"),standardUnit:Fu.f().trim().required("Standard Unit is a required field"),type:Fu.f().default("Service"),makeUp:Fu.f().trim().default(""),density:Fu.d().default(0),stdFactor:Fu.d().default(0),stdPackageUnit:Fu.f().trim().default(""),formulation:ZS}),qS=[{key:"gallon",value:"gallon"},{key:"quart",value:"quart"},{key:"ton",value:"ton"},{key:"pound",value:"pound"},{key:"acre inch",value:"acre inch"},{key:"acre",value:"acre"},{key:"liter",value:"liter"},{key:"metric ton",value:"metric ton"},{key:"kilogram",value:"kilogram"}],JS=[{key:"ton",value:"ton"},{key:"pound",value:"pound"},{key:"acre",value:"acre"},{key:"metric ton",value:"metric ton"},{key:"kilogram",value:"kilogram"}],KS="Density (lb / gal)",QS=function(e){var t=e.setValidationSchema,n=Object(Zi.h)(),r=n.values,c=n.setFieldValue,i=n.setFieldTouched,o=n.validateField,s=n.validateForm,l=Object(a.useState)(KS),d=Object(b.a)(l,2),u=d[0],j=d[1];return Object(a.useEffect)((function(){"Liquid"===r.makeUp?(t(GS),j("".concat(KS,"*")),s()):(t(HS),j(KS),s())}),[r.makeUp]),Object(a.useEffect)((function(){if(null===r||void 0===r||!r.densityInLbsPerGallon)return c("density"),void i("density");c("density",MS(r.densityInLbsPerGallon)),i("density"),o("density")}),[null===r||void 0===r?void 0:r.densityInLbsPerGallon,c]),Object(y.jsx)("div",{children:Object(y.jsxs)("div",{name:"Fertilizer","data-testid":"fertilizer-tab",children:[Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)(m.Columns,{wrap:!0,children:[Object(y.jsx)(m.Column,{width:"w-1/2",children:Object(y.jsx)("div",{className:"pr-2",children:Object(y.jsx)(Qi,{id:"makeUp",label:"Make-Up*",control:m.Select,name:"makeUp",placeholder:"Select Make-Up","data-testid":"makeupselect",items:[{key:"Solid",value:"Solid"},{key:"Liquid",value:"Liquid"}]})})}),Object(y.jsx)(m.Column,{width:"w-1/2",children:Object(y.jsx)("div",{className:"pl-2",children:Object(y.jsx)(Qi,{id:"standardUnit",label:"Standard Unit*",control:m.Select,name:"standardUnit",placeholder:"Select Standard Unit","data-testid":"standard-unit-select",items:function(e,t){var n=JS;return"Service"!==e&&"Liquid"===t&&(n=qS),n}(null===r||void 0===r?void 0:r.type,null===r||void 0===r?void 0:r.makeUp)})})})]})}),Object(y.jsx)("div",{className:"mt-8",children:Object(y.jsx)(m.Columns,{wrap:!0,children:Object(y.jsx)(m.Column,{width:"w-1/2",children:Object(y.jsxs)("div",{className:"pr-2",children:[Object(y.jsxs)("div",{className:"text-neutral-60 flex",children:[u,"LIQUID"===r.makeUp?Object(y.jsx)("div",{className:"text-remove",children:"*"}):null]}),Object(y.jsx)(US,{id:"densityInLbsPerGallon",fieldName:"densityInLbsPerGallon"}),Object(y.jsx)(Zi.a,{name:"density",component:"div",className:"text-remove"})]})})})}),Object(y.jsx)(zS,{})]})})},XS=[{key:"acre",value:"acre"},{key:"hectare",value:"hectare"},{key:"hour",value:"hour"},{key:"day",value:"day"}],$S=[{key:"centiliter",value:"centiliter"},{key:"cubic foot",value:"cubic foot"},{key:"cubic inch",value:"cubic inch"},{key:"cubic meter",value:"cubic meter"},{key:"cubic yard",value:"cubic yard"},{key:"fluid ounce",value:"fluid ounce"},{key:"milliliter",value:"milliliter"},{key:"pint",value:"pint"},{key:"gram",value:"gram"},{key:"long ton",value:"long ton"},{key:"ounce",value:"ounce"}].concat(qS,JS),eT=function(e){var t,n=e.fieldValue,a=Object(Zi.h)(),r=a.values,c=a.setFieldValue;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"text-neutral-60",children:n}),Object(y.jsx)(Xc.Input,{placeholder:"0%",name:"formulation.".concat(n),value:null===(t=r.formulation)||void 0===t?void 0:t[n],onChange:function(e){c("formulation.".concat(n),e.target.value)},onBlur:function(e){var t=parseFloat(e.target.value.replace(/%/g,"")).toFixed(2);c("formulation.".concat(n),isNaN(t)?"":"".concat(t,"%"))}})]})},tT=n.p+"static/media/productValidationAlert.1372f4cb.svg",nT=n.p+"static/media/chevron_left.b80fe32c.svg",aT=n.p+"static/media/seeds.99168252.svg",rT=n.p+"static/media/service.ed6450ca.svg",cT=n.p+"static/media/spray.56df6adf.svg",iT={byRatePerArea:{key:"ByRatePerArea",value:"ratePerAreaValue",unit:"ratePerAreaUnit",title:"Rate/Area"},byTotalProduct:{key:"ByTotalProduct",value:"totalProductValue",unit:"totalProductUnit",title:"Total Product"},byRatePerTank:{key:"ByRatePerTank",value:"ratePerTankValue",unit:"ratePerTankUnit",title:"Rate/Tank"}},oT=[{key:"None",value:"None"},{key:"Aerial",value:"Aerial"},{key:"Air Blast",value:"Air Blast"},{key:"Chemigation",value:"Chemigation"},{key:"Fertigation",value:"Fertigation"},{key:"Fumigation",value:"Fumigation"},{key:"Ground",value:"Ground"},{key:"Ground - Banded",value:"Ground - Banded"},{key:"Ground - Broadcast",value:"Ground - Broadcast"},{key:"Ground - Hooded",value:"Ground - Hooded"},{key:"Ground - In Furrow",value:"Ground - In Furrow"},{key:"Ground - Incorporated",value:"Ground - Incorporated"},{key:"Ground - Seed Treatment",value:"Ground - Seed Treatment"},{key:"Ground - Spot",value:"Ground - Spot"},{key:"Ground - Variable Rate",value:"Ground - Variable Rate"},{key:"Ground - Wipe",value:"Ground - Wipe"},{key:"Ground Application",value:"Ground Application"},{key:"Planting",value:"Planting"},{key:"Re-Planting",value:"Re-Planting"},{key:"Sidedress / Topdress",value:"Sidedress"},{key:"Storage",value:"Storage"},{key:"Topdress",value:"Topdress"},{key:"Tree Injection",value:"Tree Injection"},{key:"Water Run",value:"Water Run"}],sT=[{key:"None",value:"None"},{key:"Pre-Plant",value:"Pre-Plant"},{key:"Planting",value:"Planting"},{key:"Growing",value:"Growing"},{key:"Harvest",value:"Harvest"},{key:"Storage",value:"Storage"},{key:"Annual",value:"Annual"}],lT=[{key:"clear",value:"- Clear filter"},{key:"custom",value:"Custom Product"},{key:"cropProtection",value:"Crop Protection"},{key:"fertilizer",value:"Fertilizer"},{key:"seed",value:"Seed"},{key:"service",value:"Service"}],dT=function(e){var t,n,a=e.productType,r=e.iconSize,c=null===(t=lT.find((function(e){var t=e.key;return 0===a.localeCompare(t,void 0,{sensitivity:"accent"})})))||void 0===t?void 0:t.value;switch(a){case"Seed":n=aT;break;case"Service":n=rT;break;default:n=cT}return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("img",{width:r,className:"mr-1",src:n,alt:"product type icon"}),c]})};dT.defaultProps={iconSize:18};var uT=dT,bT=(n(1546),"mb-6"),jT="text-neutral-60",pT="h-6 text-base leading-6",fT=function(e){var t,n,r,c,i,o,s,l,d,u,j,p=e.product,v=Object(a.useContext)(ac),O=Object(b.a)(v,1)[0].organization,h=ZO(Object(f.useFlags)(),O),x=Object(Zi.h)(),g=x.values,C=x.setValues,P=x.setFieldValue,A=x.errors,S=function(e){P(e.target.name,e.target.value)};Object(a.useEffect)((function(){C(p)}),[C,p]);var T=[p.producttype,p.productType].includes("Seed");return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(Xc.Row,{className:bT,gutter:32,children:[Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsx)("div",{className:jT,children:"Product Name"}),Object(y.jsx)("div",{className:pT,children:null!==(t=null!==(n=g.productName)&&void 0!==n?n:g.name)&&void 0!==t?t:"---"})]}),Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsx)("div",{className:jT,children:"Manufacturer"}),Object(y.jsx)("div",{className:pT,children:null!==(r=null!==(c=g.manufacturerName)&&void 0!==c?c:g.manufacturer)&&void 0!==r?r:"---"})]})]}),Object(y.jsxs)(Xc.Row,{className:bT,gutter:32,children:[Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsx)("div",{className:jT,children:"Product Type"}),Object(y.jsx)(Xc.Row,{className:pT,children:Object(y.jsx)(uT,{productType:null!==(i=null!==(o=g.productType)&&void 0!==o?o:g.producttype)&&void 0!==i?i:"---"})})]}),!T&&Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsx)("div",{className:jT,children:"EPA Number"}),Object(y.jsx)("div",{className:pT,children:null!==(s=g.registrationNumber)&&void 0!==s&&s.length||null!==(l=g.registrationnumber)&&void 0!==l&&l.length?null!==(d=g.registrationNumber)&&void 0!==d?d:g.registrationnumber:"---"})]})]}),Object(y.jsxs)(Xc.Row,{className:bT,gutter:32,children:[Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsx)("div",{className:jT,children:"List Price"}),Object(y.jsx)(Qi,{style:{borderRight:"none",borderLeft:"none"},control:m.Input,name:"averagePricePerUnit",value:0===g.averagePricePerUnit?void 0:g.averagePricePerUnit,onChange:S,onBlur:function(e){var t=parseFloat(e.target.value).toFixed(2);P("averagePricePerUnit",isNaN(t)?"":t)},attachLeft:Object(y.jsx)("div",{children:"$"}),attachRight:Object(y.jsxs)("div",{style:{backgroundColor:"white",borderLeft:"none"},className:"flex w-fit mr-10px",children:[Object(y.jsxs)("span",{className:"mr-1",children:["per ",Object(va.g)(null!==(u=g.stdUnit)&&void 0!==u?u:g.stdunit)]}),gT(A,"averagePricePerUnit")]})})]}),Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsx)("div",{className:jT,children:"Standard Unit"}),Object(y.jsx)("div",{className:pT,children:g.stdUnit?g.stdUnit:g.stdunit})]})]}),T&&h&&Object(y.jsxs)(Xc.Row,{"data-testid":"package-weight-row",className:bT,gutter:32,children:[Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsx)("div",{className:jT,children:"Package Weight Density"}),Object(y.jsx)(Qi,{control:m.Input,name:"packageWeight",value:0===g.packageWeight?void 0:g.packageWeight,onChange:S,attachRight:Object(y.jsxs)("div",{style:{backgroundColor:"white",borderLeft:"none"},className:"flex w-fit mr-10px",children:[Object(y.jsx)("span",{className:"mr-1",children:"seeds per lbs"}),gT(A,"packageWeight")]})})]}),Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsx)("div",{className:jT,children:"Standard Package Unit"}),Object(y.jsx)("div",{"data-testid":"standard-package-unit",className:pT,children:null!==(j=g.stdPackageUnit)&&void 0!==j?j:g.stdpackageunit})]})]})]})},mT=Fu.e().shape({name:Fu.f().required("Required"),makeUp:Fu.f().required("Required"),type:Fu.f().required("Required"),manufacturer:Fu.f().required("Required"),standardUnit:Fu.f().required("Required"),averagePricePerUnit:Fu.d().positive("List Price must be a positive number"),densityInLbsPerGallon:Fu.d().when("makeUp",{is:"LIQUID",then:Fu.d().required("Required").positive("Density must be a positive number"),otherwise:Fu.d().nullable().notRequired()}),density:Fu.d().when("makeUp",{is:"LIQUID",then:Fu.d().required("Required").positive("Density must be a positive number"),otherwise:Fu.d().nullable().notRequired()})}),vT=Fu.e().shape({type:Fu.f().required("Required"),name:Fu.f().required("Required"),manufacturer:Fu.f().required("Required"),standardUnit:Fu.f().required("Required")}),OT=Fu.e().shape({averagePricePerUnit:Fu.d().positive("List Price must be a positive number"),packageWeight:Fu.d().notOneOf([0],"Weight cannot be 0").positive("Weight must be a positive number").typeError("Weight must be a number")}),hT=function(e){var t=e.handleEdit,n=e.editProductHeader,r=e.product,c=e.visible,i=e.saveText,o=e.onClose,s=wS().fetchCustomProduct,l=Object(a.useState)(r),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(),f=Object(b.a)(p,2),m=f[0],v=f[1];Object(a.useEffect)((function(){c||j(),r&&(r.custom||r.isNew)?"SERVICE"===r.type?function(e,t,n){t(e),n("SERVICE")}(r,j,v):function(e,t,n,a,r){t(e),n("FERTILIZER"),r&&!e.isNew&&a(e.productId).then((function(n){t(Object(I.a)(Object(I.a)({},n.data),{},{averagePricePerUnit:e.averagePricePerUnit,custom:!0,densityInLbsPerGallon:VS(null===e||void 0===e?void 0:e.density)}))}))}(r,j,v,s,c):function(e){e("MASTER")}(v)}),[r,c]);var O={MASTER:OT,FERTILIZER:mT,SERVICE:vT}[m]||Fu.e().shape({});return r?Object(y.jsx)(Zi.e,{enableReinitialize:!0,validationSchema:O,initialValues:r,onSubmit:t,validator:function(){return{}},validateOnBlur:!0,children:function(e){var t=e.isSubmitting,a=e.handleSubmit,s=e.isValid;return Object(y.jsx)(Xc.Drawer,{className:"add-product-drawer",open:c,placement:"right",closable:!1,maskClosable:!1,onClose:o,width:"50%",footer:Object(y.jsxs)(Xc.Row,{justify:"space-between",children:[Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.outline,className:"px-3",onClick:o,children:Object(y.jsxs)(Xc.Row,{children:[Object(y.jsx)("img",{className:"mr-1",alt:"plus",src:nT}),Object(y.jsx)("span",{children:"Back"})]})}),Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.primary,loading:t,disabled:!s,onClick:a,children:i})]}),children:Object(y.jsx)("div",{className:"h-full",children:Object(y.jsxs)("div",{className:"pt-4 pr-4 pb-5 pl-8",children:[Object(y.jsx)(Xc.Row,{justify:"end",children:Object(y.jsx)("button",{type:"button",onClick:o,children:Object(y.jsx)("img",{alt:"close",src:kS})})}),r.custom||r.isNew?Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-xl font-semibold",children:n}),u?Object(y.jsx)(yT,{setSchema:v,product:u}):null]}):Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"ml-2 mb-5 text-xl font-semibold",children:n}),Object(y.jsx)(fT,{product:r})]})]})})})}}):null};hT.defaultProps={saveText:"Save"};var xT=hT,gT=function(e,t){return null!==e&&void 0!==e&&e[t]?Object(y.jsx)("img",{src:tT,alt:""}):null},CT=function(e){var t,n,r,c,i,o,s=e.product,l=e.setSchema,d=Object(Zi.h)(),u=d.values,j=d.setValues,p=d.setFieldValue,f=d.errors,v=d.validateField,O=d.validateForm,h=d.setFieldTouched,x=Object(a.useState)(),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(),S=Object(b.a)(A,2),T=S[0],N=S[1],E="mb-6",w="text-neutral-60 flex",_=function(){var e;return null!==(e=u.standardUnit)&&void 0!==e?e:u.standardunit},R=function(e,t){return p(t,e.target.value)},D=function(e,t){return p(t,JSON.parse(e.target.value).key)};return Object(a.useEffect)((function(){s.isNew||j(Object(I.a)(Object(I.a)({},s),{},{densityInLbsPerGallon:VS(s.density)}))}),[j,s]),Object(a.useEffect)((function(){if(u.formulation||p("formulation",{}),"SERVICE"===u.type&&N(XS),"FERTILIZER"===u.type)switch(u.makeUp){case"SOLID":N(JS),P(""),O();break;case"LIQUID":N(qS),P("lb/gal"),O();break;default:N($S)}}),[u.type,u.formulation,u.makeUp]),Object(a.useEffect)((function(){if(null===u||void 0===u||!u.densityInLbsPerGallon)return p("density"),h("density"),void v("density");p("density",MS(u.densityInLbsPerGallon)),h("density"),v("density")}),[null===u||void 0===u?void 0:u.densityInLbsPerGallon,p]),Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{children:Object(y.jsx)(Xc.Col,{children:Object(y.jsxs)(Xc.Row,{className:"mb-6 text-neutral-60",children:[Object(y.jsx)("span",{children:" Need a custom crop protection or seed product?"}),Object(y.jsx)("a",{className:"pl-2 text-neutral-60",style:{color:"blue",textDecoration:"underline"},href:"https://www.syngentadigital.com/us/product-request-form",target:"_blank",rel:"noreferrer",children:"Request here."})]})})}),Object(y.jsxs)("div",{children:[" ",Object(y.jsx)(Xc.Row,{className:E,gutter:32,children:Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsxs)("div",{className:w,children:["Product Type",Object(y.jsx)("div",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Qi,{control:m.Select,name:"type",value:null!==(t=u.type)&&void 0!==t?t:u.type,onChange:function(e){D(e,"type"),l&&l(JSON.parse(e.target.value).key)},items:[{key:"FERTILIZER",value:"Fertilizer"},{key:"SERVICE",value:"Service"}]})]})}),Object(y.jsxs)(Xc.Row,{className:E,gutter:32,children:[Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsxs)("div",{className:w,children:["Product Name",Object(y.jsx)("div",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Qi,{control:m.Input,name:"name",value:u.name,onChange:function(e){return R(e,"name")}})]}),Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsxs)("div",{className:w,children:["Manufacturer",Object(y.jsx)("div",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Qi,{control:m.Input,name:"manufacturer",value:u.manufacturer,onChange:function(e){return R(e,"manufacturer")}})]})]}),"FERTILIZER"===u.type&&Object(y.jsxs)(Xc.Row,{className:E,gutter:32,children:[Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsxs)("div",{className:w,children:["Make-Up",Object(y.jsx)("div",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Qi,{control:m.Select,name:"makeUp",value:null!==(n=null!==(r=u.makeUp)&&void 0!==r?r:u.makeup)&&void 0!==n?n:"Solid",onChange:function(e){return D(e,"makeUp")},placeholder:null!==(c=null!==(i=u.makeUp)&&void 0!==i?i:u.makeup)&&void 0!==c?c:"",items:[{key:"SOLID",value:"Solid"},{key:"LIQUID",value:"Liquid"}]})]}),Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsxs)("div",{className:w,children:["Density","LIQUID"===u.makeUp?Object(y.jsx)("div",{className:"text-remove",children:"*"}):null]}),Object(y.jsx)(US,{id:"densityInLbsPerGallon",fieldName:"densityInLbsPerGallon",label:C,inputSuffix:C,onControlledChange:function(e){return R(e,"densityInLbsPerGallon")}}),Object(y.jsx)(Zi.a,{name:"density",component:"div",className:"text-remove text-wrap"})]})]}),Object(y.jsxs)(Xc.Row,{className:E,gutter:32,children:[Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsx)("div",{className:w,children:"List Price"}),Object(y.jsx)(Qi,{style:{borderRight:"none",borderLeft:"none"},control:m.Input,name:"averagePricePerUnit",value:0===u.averagePricePerUnit?void 0:u.averagePricePerUnit,onChange:function(e){return R(e,"averagePricePerUnit")},onBlur:function(e){var t=parseFloat(e.target.value).toFixed(2);p("averagePricePerUnit",isNaN(t)?"":t)},attachLeft:"$",attachRight:Object(y.jsxs)("div",{style:{backgroundColor:"white",borderLeft:"none"},className:"flex w-fit mr-10px",children:["per ",Object(va.g)(null!==(o=u.stdUnit)&&void 0!==o?o:u.stdunit),gT(f,"averagePricePerUnit")]})})]}),Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsxs)("div",{className:w,children:["Standard Unit",Object(y.jsx)("div",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Qi,{control:m.Select,name:"standardUnit",value:_(),onChange:function(e){return D(e,"standardUnit")},placeholder:_(),items:T})]})]}),"FERTILIZER"===u.type&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Xc.Row,{className:"font-bold text-lg  mb-6",children:"Major"}),Object(y.jsxs)(Xc.Row,{gutter:32,className:E,children:[Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"N"})}),Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"P"})}),Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"K"})})]}),Object(y.jsx)(Xc.Row,{className:"font-bold text-lg  mb-6",children:"Minor"}),Object(y.jsxs)(Xc.Row,{gutter:32,className:E,children:[Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"Ca"})}),Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"Mg"})}),Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"S"})})]}),Object(y.jsx)(Xc.Row,{className:"font-bold text-lg  mb-6",children:"Micro"}),Object(y.jsxs)(Xc.Row,{gutter:32,style:{flexFlow:"nowrap"},className:E,children:[Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"Fe"})}),Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"Cu"})}),Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"Mn"})}),Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"Zn"})})]}),Object(y.jsxs)(Xc.Row,{gutter:32,className:E,children:[Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"B"})}),Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"Mo"})}),Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(eT,{fieldValue:"Cl"})})]})]})]})]})};CT.defaultProps={setSchema:function(){return null}};var yT=CT,PT=Fu.e().shape({packageWeight:Fu.d().notOneOf([0],"Weight cannot be 0").positive("Weight must be a positive number").typeError("Weight must be a number")}),AT=(wc.a.shape({productName:wc.a.string.isRequired,productId:wc.a.string.isRequired,operationsCount:wc.a.number.isRequired,cropName:wc.a.string,stdPackageUnit:wc.a.string.isRequired,manufacturerName:wc.a.string.isRequired,registrationNumber:wc.a.string.isRequired}),"success"),ST="mb-6",TT="text-neutral-60",NT="h-6 text-base leading-6 text-neutral-1000",ET=function(e){var t=e.product,n=e.isExpanded,a=e.isLoading,r=e.resolvedProducts,c=e.onExpand,i=e.onSubmit,o=t.cropName,s=t.productId,l=t.productName,d=t.stdPackageUnit,u=t.manufacturerName,b=t.operationsCount,j=t.averagePricePerUnit,p=r.find((function(e){return e.productId===s})),f=null===p||void 0===p?void 0:p.packageWeight;return Object(y.jsxs)("div",{className:"bg-white rounded mb-4",style:{boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.15)"},children:[Object(y.jsxs)("button",{className:"flex flex-row items-center focus:outline-none justify-between w-full p-4",type:"button",onClick:c,"data-testid":"product-accordion-expand-button",children:[Object(y.jsxs)("header",{className:"flex justify-between w-full pr-1",children:[Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)(Ag,{cropObject:{name:o}}),Object(y.jsx)("h1",{className:"ml-2 text-base leading-6 tracking-tighter ".concat(n?"font-semibold":"font-normal"),children:l})]}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("span",{className:"flex bg-blue-30 rounded-md px-1 font-semibold text-xs text-blue-70 mr-2",children:"".concat(b," TASK").concat(b>1?"S":"")}),Object(y.jsx)("span",{className:"rounded-md px-1 font-semibold text-xs mx-2 ".concat(p?"text-green-700 bg-green-200":"text-yellow-700 bg-yellow-200"),children:p?"WEIGHT ENTERED":"NO WEIGHT"})]})]}),Object(y.jsx)("img",{className:"pr-16px",src:n?EP:Di,alt:"expand collapse accordion"})]}),n&&Object(y.jsx)(Zi.e,{validateOnBlur:!0,validationSchema:PT,onSubmit:i,initialValues:{productId:s,packageWeight:f,averagePricePerUnit:j},children:function(e){var t=e.submitForm,n=e.dirty,r=e.isValid,c=e.errors;return Object(y.jsxs)("div",{className:"p-4","aria-expanded":"true",children:[Object(y.jsx)("p",{className:"text-base font-normal leading-6 tracking-tighter mb-1",children:"Enter weight value"}),Object(y.jsx)(Xc.Row,{className:"".concat(ST," package-weight-row"),gutter:32,children:Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsx)("div",{className:TT,children:"Package Weight Density"}),Object(y.jsx)(Qi,{control:m.Input,name:"packageWeight",attachRight:Object(y.jsxs)("div",{style:{backgroundColor:"white",borderLeft:"none"},className:"flex w-fit mr-10px",children:[Object(y.jsx)("span",{className:"mr-1",children:"seeds per lbs"}),gT(c,"packageWeight")]})})]})}),Object(y.jsxs)(Xc.Row,{className:ST,gutter:32,children:[Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsx)("div",{className:TT,children:"Standard Package Unit"}),Object(y.jsx)("div",{className:NT,children:Object(va.g)(d)})]}),Object(y.jsxs)(Xc.Col,{span:12,children:[Object(y.jsx)("div",{className:TT,children:"Manufacturer"}),Object(y.jsx)("div",{className:NT,children:u})]})]}),Object(y.jsx)(Xc.Row,{justify:"end",children:Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.primary,loading:a,disabled:!r||!n,onClick:t,children:"Save"})})]})}})]})};ET.defaultProps={isLoading:!1};var wT=ET,_T={error:"Unable to save Package Weight Values",success:"Package Weight Entered.",default:"Package Weight Values Required"},RT=function(e){var t=e.showToast,n=e.setShowToast,a=e.state,r=e.setIsDrawerOpen,c=(null===_T||void 0===_T?void 0:_T[a])||_T.default;return Object(y.jsxs)(Qc,{type:a,title:c,open:t,onClose:function(){n(!1)},customStyle:{top:"16px"},timeout:5e3,isBold:!0,children:["info"===a&&Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("p",{className:"text-sm font-normal mb-2",children:"We\u2019ve imported your planting task records, please enter a package weight for each seed product."}),Object(y.jsx)(m.Button,{size:"lg",type:"primary",onClick:function(){n(!1),r(!0)},style:{marginLeft:"auto"},children:"Add Package Weight"})]}),"success"===a&&Object(y.jsx)("div",{children:Object(y.jsx)("p",{className:"text-sm font-normal mb-2",children:"You can edit Package Weight in the Products page."})}),"error"===a&&Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"text-sm font-normal mb-4",children:"An error prevented your package weight value from being saved. Please try again."}),Object(y.jsx)(m.Button,{size:"lg",type:"primary",onClick:function(){return window.open("https://agconnections.zendesk.com/hc/en-us/categories/7419295252627-Cropwise-Financials","_blank","noopener")},style:{marginLeft:"auto"},children:"Contact Support"})]})]})};RT.defaultProps={setIsDrawerOpen:null};var IT=RT,DT=function(e){var t=e.products,n=e.onClose,r=e.onFinish,c=e.open,i=wS(),o=i.addUpdateListPrice,s=i.isUpdateLoading,l=i.updateError,d=i.setUpdateError,u=DS("product-entered-package-weight",[]),j=u.storedValue,p=u.setValue,f=Object(a.useState)(j),m=Object(b.a)(f,2),O=m[0],h=m[1],x=Object(a.useState)(),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useCallback)((function(e){o(_S(e),(function(){return function(e){h((function(t){var n=t.findIndex((function(t){return t.productId===e.productId}));if(-1!==n){var a=Object(v.a)(t);return a[n]=e,a}return[].concat(Object(v.a)(t),[e])})),P((function(e){return e+1}))}(e)}))}),[]),S=Object(a.useCallback)((function(e){P((function(t){return t===e?null:e}))}),[]);return Object(a.useEffect)((function(){p(O)}),[O]),Object(a.useEffect)((function(){t.length>0&&(null===O||void 0===O?void 0:O.length)>0&&(null===O||void 0===O?void 0:O.length)>=t.length&&(p([]),h([]),r())}),[O,t]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Xc.Drawer,{open:c,title:Object(y.jsxs)("header",{children:[Object(y.jsx)("button",{type:"button",onClick:n,className:"absolute top-3 right-4",style:{},children:Object(y.jsx)("img",{alt:"close",src:kS})}),Object(y.jsx)("h1",{className:"font-semibold text-xl mb-2",children:"Add Package Weight"}),Object(y.jsxs)("p",{children:["Before you can match crop zones, we need to ",Object(y.jsx)("br",{}),"know the package weight for the following seed ",Object(y.jsx)("br",{}),"products."]})]}),placement:"right",onClose:n,width:"700px",closable:!1,children:t.map((function(e,t){return Object(y.jsx)(wT,{product:e,resolvedProducts:O,isExpanded:t===C,isLoading:s,onExpand:function(){return S(t)},onSubmit:A},e.productId)}))}),Object(y.jsx)(IT,{showToast:l,setShowToast:d,state:"error"})]})};DT.defaultProps={products:[]};var kT=DT,LT=function(){var e=Object(a.useState)({isVisible:!1,state:null}),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],p=CO(),f=p.isLoadingWeight,m=p.loadProductsMissingWeight,v=p.productsWithoutWeight,O=function(){return s(!0)},h=function(){return s(!1)},x=Object(a.useCallback)((function(){r({state:AT,isVisible:!0}),h(),j(!1),m()}),[]);return Object(a.useEffect)((function(){m()}),[]),Object(a.useEffect)((function(){!f&&v.length>0&&(j(!0),s(!0))}),[f,v]),Object(y.jsxs)(y.Fragment,{children:[u&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{"data-testid":"package-weight-button",className:"pt-6 px-6 flex flex-col",children:Object(y.jsxs)("div",{className:"pb-4",style:{borderBottom:"1px solid #DFE2E7"},children:[Object(y.jsx)("span",{className:"text-base",children:"Package Weight"}),Object(y.jsx)("p",{className:"text-normal mb-20px",children:"Define package weight for certain seed products"}),Object(y.jsx)(Xc.Button,{className:"bg-white",onClick:O,"data-testid":"add-product-package-weight",children:"Add Package Weight"})]})}),Object(y.jsx)(kT,{showDrawer:O,open:o,products:v,onClose:h,onFinish:x})]}),Object(y.jsx)(IT,{showToast:n.isVisible,setShowToast:function(e){return r((function(t){return Object(I.a)(Object(I.a)({},t),{},{isVisible:e})}))},state:n.state,setIsDrawerOpen:s})]})},FT=function(){var e=Object(a.useState)(),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)($P()),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)([]),d=Object(b.a)(l,2),u=d[0],j=d[1],f=Object(p.h)(),m=Object(a.useContext)(ac),v=Object(b.a)(m,2),O=v[0],h=O.cropZoneMatcherType,x=O.showToastCropZoneMatcher,g=O.additionalInformationToastCropZoneMatcher,C=v[1],P=Object(a.useState)(x),A=Object(b.a)(P,2),S=A[0],T=A[1],N=CO(),E=N.loadMappedOperations,w=N.isLoadingMappedOperations,_=N.mappedOperations,R=Object(a.useContext)(KP),I=R.getSourceFields,D=R.getSelectedSourceField,k=R.reloadData,L=g.operationMapped,F=g.cropZoneName;return Object(a.useEffect)((function(){null!==_&&void 0!==_&&_.length&&j(_)}),[_]),Object(a.useEffect)((function(){E()}),[k]),Object(a.useEffect)((function(){D(n)}),[n]),Object(a.useEffect)((function(){null!==u&&void 0!==u&&u.length&&r(u[0])}),[u]),Object(a.useEffect)((function(){I(u)}),[u]),Object(a.useEffect)((function(){T(x)}),[x]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(lo,{onOrganizationSelect:function(){E()},hideCropSeasonDropdown:!1,hideOrganizationDropdown:!1,onCropSeasonSelect:function(){s($P())},disabled:!0,children:Object(y.jsx)(lo.Item,{title:"Integrations",value:"Crop Zone Matching",isLast:!0})}),Object(y.jsxs)("div",{"data-testid":"crop-zone-matcher-landing",className:"flex flex-row w-full h-full",children:[Object(y.jsxs)("div",{className:"flex flex-col w-123",children:[Object(y.jsx)(pu,{className:"pl-24px",onClick:function(){f.goBack()},children:Object(y.jsxs)("div",{className:"flex h-56px items-center",children:[Object(y.jsx)(XP.a,{fill:"696F88"}),Object(y.jsx)("span",{className:"h-28px ml-20px text-xl font-normal",children:"Crop Zone Matching"})]})}),Object(y.jsxs)("div",{className:"bg-white",style:{height:"calc(100% - 56px)"},children:[Object(y.jsx)(LT,{}),Object(y.jsx)(tA,{isLoading:w,sourceFields:u,selectedSourceField:n,onChange:r})]})]}),Object(y.jsx)("div",{className:"w-full h-full",children:Object(y.jsx)(ES,{selectedSourceField:n,isLoadingOperations:w,selectedSeasons:o})}),Object(y.jsx)(Qc,{type:h,title:"".concat(HO(h)," ").concat(F),open:S,onClose:function(){C({type:Vr,payload:!1})},s:!0,timeout:5500,children:Object(y.jsx)("p",{className:"text-sm font-body",children:"".concat(L," ").concat(YO(h)," ")})})]})]})},MT=function(){return Object(y.jsx)(QP,{children:Object(y.jsx)(FT,{})})},VT=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useContext)(ac),i=Object(b.a)(c,2)[1],o=localStorage.getItem("selectedOrganizationId"),s=ni(),l=Object(p.h)(),d=Object(a.useCallback)((function(e){var t=e.email,n=e.password,a=un.createChildApi({action:"integrations/agrian/auth"}).create({email:t,password:n},{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),a.then((function(e){return e})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[o]),j=Object(a.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=un.createChildApi({action:"integrations/agrian/growers"}).fetch(null,void 0,{headers:{"cwf-context":JSON.stringify({organization_id:o})}}),n=t.promise;return r(!0),n.then((function(e){return e})).catch(Ae.default).catch((function(t){e||uc(i)(t)})).finally((function(){return r(!1)}))}),[o]);return{authenticate:d,saveOrganizationMatch:Object(a.useCallback)((function(e){var t=e.growerId,n=e.organizationId,a=e.growerDescription,c=un.createChildApi({action:"integrations/agrian/match"}).create([{cwfEntityId:o,agrianEntityDescription:a,agrianEntityId:t,type:"Grower"},{cwfEntityId:o,agrianEntityDescription:a,agrianEntityId:n,type:"Organization"}],{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),c.then((function(e){return e})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[o]),growers:j,getAgrianRecommendationsBySeason:Object(a.useCallback)((function(e){var t=un.createChildApi({action:"integrations/agrian/recommendations"}).fetch(null,e,{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),t.then((function(e){return e})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[o]),getAgrianRecommendationsBySeasonWithoutCache:Object(a.useCallback)((function(e){var t=J.a.get("".concat(u.e,"/integrations/agrian/recommendations"),{params:e,headers:{"cwf-context":JSON.stringify({organization_id:o}),common:{Authorization:"Bearer ".concat(Ve())}}});return r(!0),t.then((function(e){return e})).catch(Ae.default).catch(uc(i)).finally((function(){return r(!1)}))}),[o]),importRecommendations:Object(a.useCallback)((function(e){var t=e.recommendationsIds,n=e.seasonId,a=un.createChildApi({action:"integrations/agrian/recommendations"}).create({ids:t,seasonId:n},{headers:{"cwf-context":JSON.stringify({organization_id:o})}}).promise;return r(!0),a.then((function(e){if(207===(null===e||void 0===e?void 0:e.status)){var t,n=null===e||void 0===e||null===(t=e.data)||void 0===t?void 0:t.filter((function(e){return"ERROR"===e.status})).map((function(e){return"".concat(e.title,": ").concat(e.message)})).join("\n");s.error("Your recommendations were partially created. Some records weren't imported due to errors:",{actionButtonLabel:"View imported recommendations",actionButton:function(){return l.replace(Cc.recommendations)},content:n,supportButton:!0,timeout:6e4})}else s.success("Recommendations imported",{actionButton:function(){return l.replace(Cc.recommendations)}});return e})).catch(Ae.default).catch((function(e){var t;if([422,400].includes(null===(t=e.response)||void 0===t?void 0:t.status)){var n,a,r,c,i,o,l=null!==(n=e.response)&&void 0!==n&&null!==(a=n.data)&&void 0!==a&&a.errors?Object.values(null===(r=e.response)||void 0===r||null===(c=r.data)||void 0===c?void 0:c.errors).join("\n"):null===(i=e.response)||void 0===i||null===(o=i.data)||void 0===o?void 0:o.message;s.error("Validation error while importing recommendations",{content:l,supportButton:!0,timeout:6e4})}else{var d=dc({},e);s.error("Error while importing recommendations",{content:d.displayMessage,supportButton:!0,timeout:3e4})}throw e})).finally((function(){return r(!1)}))}),[o]),loading:n}},BT=function(e){var t=e.buttonText,n=e.integrationType,r=lx({onMountTriggerEvent:{event:Ee.epic.Integrations.submissionStarted,data:{vendor:n}}}).triggerAnalyticsEvent,c=Object(p.h)(),i=Object(a.useContext)(Kh).goForward,o=VT(),s=o.loading,l=o.growers,d=o.authenticate,u=Object(a.useState)(""),j=Object(b.a)(u,2),f=j[0],v=j[1],O=Object(a.useState)(""),h=Object(b.a)(O,2),x=h[0],g=h[1];Object(a.useEffect)((function(){function e(){return(e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return!0,e.next=3,l(true);case 3:e.sent&&(r(Ee.epic.Integrations.submissionCredentialsFilled,{vendor:n}),i());case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[l,i,r,n]);var C=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),e.next=3,d({email:f,password:x});case 3:return e.sent&&(r(Ee.epic.Integrations.submissionCredentialsFilled,{vendor:n}),i()),e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(y.jsx)("div",{className:"flex self-center bg-white h-100 w-130 rounded-md mt-10 p-6 shadow-sm",children:Object(y.jsxs)(m.Form,{onSubmit:C,children:[Object(y.jsxs)("div",{className:"w-full mb-5 flex gap-5 items-center",children:[Object(y.jsx)("div",{className:"rounded-xl border p-3",children:Object(y.jsx)("img",{src:NO,alt:""})}),Object(y.jsxs)("div",{className:"flex flex-col justify-center",children:[Object(y.jsx)("h3",{className:"font-bold text-2xl",children:"Agrian Integration"}),Object(y.jsx)("h2",{children:"Sign in with your Agrian credentials"})]})]}),Object(y.jsx)("hr",{}),s?Object(y.jsx)("div",{className:"flex w-full flex-col items-center justify-center h-full pb-20",children:Object(y.jsx)(m.Spinner,{})}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex flex-col w-full items-center justify-center",children:[Object(y.jsx)("div",{className:" w-full",children:Object(y.jsx)(m.Form.Field,{label:"E-mail *",labelFor:"agrianEmail",children:Object(y.jsx)(m.Input,{name:"agrianEmail",type:"email",id:"agrianEmail",required:!0,value:f,style:{paddingLeft:"10px",borderColor:"#e2e8f0"},placeholder:"Enter your e-mail address from Agrian vendor",onChange:function(e){v(e.target.value)}})})}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(m.Form.Field,{label:"Password *",labelFor:"agrianPassword",children:Object(y.jsx)(m.Input,{name:"agrianPassword",type:"password",id:"agrianPassword",required:!0,value:x,placeholder:"Enter your password from Agrian vendor",style:{paddingLeft:"10px",borderColor:"#e2e8f0"},onChange:function(e){g(e.target.value)}})})})]}),Object(y.jsxs)("div",{className:"flex flex-row w-full mt-10 items-start justify-between",children:[Object(y.jsx)(m.Button,{type:"outline",className:"absolute",onClick:c.goBack,children:"< Back"}),Object(y.jsx)(m.Button,{type:"submit",children:t})]})]})]})})};BT.defaultProps={buttonText:"Start New Submission",integrationType:QO};var UT=BT,zT=function(e){var t=e.integrationType,n=e.title,r=lx(),c=r.events,i=r.triggerAnalyticsEvent,o=Ix(),s=o.selectedOrganization,l=o.setSelectedOrganization,d=Object(a.useState)([]),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useContext)(Kh),m=f.releaseStepForward,v=f.blockStepForward,O=f.goForward,h=VT(),x=h.loading,g=h.saveOrganizationMatch,C=h.growers,P=nC(),A=P.getMatches,S=P.loading,T=Object(a.useContext)(ac),N=Object(b.a)(T,1)[0].organization;Object(a.useEffect)((function(){function e(){return t.apply(this,arguments)}function t(){return(t=Object(Y.a)(G.a.mark((function e(){var t,n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,A({vendor:QO,matchTypes:["Grower"]});case 2:null!==(n=e.sent)&&void 0!==n&&null!==(t=n.data)&&void 0!==t&&t.length&&l(null===(a=n.data)||void 0===a||null===(r=a.find((function(e){return e.cwfEntityId===N.id})))||void 0===r?void 0:r.agrianEntityId);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function n(){return(n=Object(Y.a)(G.a.mark((function t(){var n;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,C();case 2:if(!(n=t.sent)){t.next=7;break}return p(n.data),t.next=7,e();case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}!function(){n.apply(this,arguments)}()}),[]),Object(a.useEffect)((function(){s?m():v()}),[s]);var E=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=j.find((function(e){return e.id===s})),e.next=3,g({growerId:null===t||void 0===t?void 0:t.id,organizationId:null===t||void 0===t?void 0:t.organization_id,growerDescription:null===t||void 0===t?void 0:t.name});case 3:e.sent&&(i(c.epic.Integrations.submissionOrganizationFilled,{vendor:QO}),O());case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),w=Object(a.useCallback)((function(e){l(e)}),[]);return Object(y.jsxs)("div",{className:"flex flex-col self-center bg-white top-30 left-26 h-100 w-140 rounded-md mb-20 p-6 shadow-sm","data-testid":"agrian-organization-selection",children:[Object(y.jsx)("h1",{className:"mb-6 ml-8 font-body text-base font-normal leading-8 tracking-tight text-left",children:n}),Object(y.jsx)("div",{className:"w-2/3 ml-8 flex-1 h-full",children:Object(y.jsx)(My,{vendor:"Agrian ",organizations:j,csLoaded:!x&&!S,selectedId:s,onSelect:w,isRequired:!0})}),Object(y.jsx)(mx,{nextDisabled:!s,onNext:E,integrationType:t})]})};zT.defaultProps={integrationType:QO,title:"Select an organization for your submission."};var ZT=zT,YT=function(){var e=lx(),t=e.events,n=e.triggerAnalyticsEvent,r=Object(a.useContext)(Kh).goForward,c=Object(a.useContext)(SC).updateSubmissionFilterCropZoneIds,i=Object(a.useState)(!0),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Ix().selectedProperties;return Object(a.useEffect)((function(){if(l(!s),d&&!s){var e=aC(d);c(e),n(t.epic.Integrations.submissionPropertiesSelected,{vendor:QO,cropZonesLength:e.length}),r()}}),[d]),Object(y.jsx)(Wx,{integrationName:QO})},HT={1:Object(y.jsx)(UT,{}),2:Object(y.jsx)(ZT,{}),3:Object(y.jsx)(UC,{context:QO,FooterComponent:mx}),4:Object(y.jsx)(YT,{}),5:Object(y.jsx)(SP,{integrationName:QO}),6:Object(y.jsx)(ay,{FooterComponent:mx,ReviewComponent:wy})},GT=function(e){var t=e.fixedStep,n=Object(a.useContext)(Kh).state.step;return HT[null!==t&&void 0!==t?t:n]};GT.propTypes={fixedStep:Ec.PropTypes.number};var WT=GT,qT=[{caption:"Sign in"},{caption:"Select Organization"},{caption:"Select Crop Seasons"},{caption:"Select Properties"},{caption:"Match Fields"},{caption:"Review and Submit"}],JT=function(){return Object(y.jsx)(FC,{integrationType:QO,progressBarSteps:qT,selectPropertiesStep:4,StepSelector:WT})},KT=function(){return Object(y.jsx)(hh,{children:Object(y.jsx)(Xh,{children:Object(y.jsx)(Zi.e,{initialValues:{},children:function(){return Object(y.jsx)(NC,{integrationType:QO,children:Object(y.jsx)(JT,{})})}})})})},QT={itemsPerPage:5,columns:[{field:"date",title:"Submission Date",sortable:!0,width:"calc((100% - 85px) / 6)",position:"left"},{field:"status",title:"Submission Status",sortable:!0,width:"calc((100% - 85px) / 6)",position:"left"},{field:"taskCount",title:"Task Count",width:"calc((100% - 85px) / 6)",position:"left"},{field:"cropSeasons",title:"Crop Seasons",width:"calc((100% - 85px) / 6)",position:"left"},{field:"propertiesCount",title:"Properties",width:"calc((100% - 85px) / 6)",position:"left"},{width:"85px",position:"left"}]},XT={data:[],page:0,pages:0,limit:QT.itemsPerPage,elements:0,integrationType:""},$T=Object(a.createContext)(XT),eN=function(e){var t=e.integrationType,n=e.children,r=Object(a.useState)(Object(I.a)(Object(I.a)({},XT),{},{integrationType:t})),c=Object(b.a)(r,2),i=c[0],o=c[1],s=tC(),l=s.listSubmissions,d=s.loading,u=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){var n,a,r,c,s=arguments;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.length>0&&void 0!==s[0]?s[0]:void 0,a=s.length>1&&void 0!==s[1]?s[1]:void 0,r=s.length>2&&void 0!==s[2]?s[2]:void 0,e.next=5,l({vendor:t.toLowerCase(),page:null!==r&&void 0!==r?r:0,limit:i.limit,sortDir:(null!==n&&void 0!==n?n:"desc").toUpperCase(),sortBy:null!==a&&void 0!==a?a:"created_at"});case 5:200===(null===(c=e.sent)||void 0===c?void 0:c.status)&&o((function(e){return Object(I.a)(Object(I.a)({},e),c.data)}));case 7:case"end":return e.stop()}}),e)}))),[l,t,i.limit]),j=Object(a.useMemo)((function(){return{state:i,getData:u,loading:d}}),[i,d,u]);return Object(y.jsx)($T.Provider,{value:j,children:n})};eN.defaultProps={integrationType:"",children:null};var tN=eN,nN=function(e){var t=e.type,n={bgColor:"#FFE4AE",fontColor:"#744A0B",text:t};switch(t){case"done":n.bgColor="#C3EAD1",n.fontColor="#0C612C",n.text="Submitted";break;case"in_progress":n.bgColor="#C6E6FF",n.fontColor="#005693",n.text="Submission in Progress";break;case"pending":n.bgColor="#A9EFE8",n.fontColor="#165C56",n.text="Submission Pending";break;case"error":n.bgColor="#FFD9D9",n.fontColor="#9C2628",n.text="Errors in Submission"}return Object(y.jsx)(m.Tag,{color:n.bgColor,children:Object(y.jsx)("span",{className:"p-2",style:{color:n.fontColor},children:n.text})})};nN.defaultProps={type:""};var aN=nN,rN=function(e){var t=e.propertiesNames,n=e.propertiesCount,a=e.propertiesArea;return Object(y.jsx)(m.Popup,{enableHover:!0,position:"top",align:"center",hasArrow:!0,bgColor:"#232630",trigger:Object(y.jsxs)("div",{className:"flex flex-col w-full justify-start","data-testid":"hover-properties-name",children:[Object(y.jsxs)("div",{className:"text-sm flex align-center",children:[Object(y.jsx)(fy,{}),Object(y.jsx)("span",{className:"ml-1",children:"".concat(n," ").concat(n>1?"properties":"property")})]}),Object(y.jsxs)("span",{className:"text-xs text-neutral-60 text-left",children:[null===a||void 0===a?void 0:a.toFixed(2)," ac"]})]}),children:Object(y.jsx)("div",{className:"gr-w-40 text-xs text-white",children:t.join(", ")})})};rN.defaultProps={propertiesNames:[],propertiesCount:null,propertiesArea:null};var cN=rN,iN=function(e){var t=e.cropSeasons,n=mo().width,a=Object(ne.take)(t,function(e){return e<=1410?1:e>=1411&&e<=1599?2:3}(n)),r=t.filter((function(e){return!a.some((function(t){return t.id===e.id}))}));return Object(y.jsxs)("div",{className:"flex gap-2 justify-start",children:[a.map((function(e){return Object(y.jsx)("div",{className:"w-auto",children:Object(y.jsx)(m.Tag,{color:"#696F88",children:Object(y.jsx)("span",{className:"p-2",children:e.name})})},e.id)})),r.length>0&&Object(y.jsx)(m.Popup,{enableHover:!0,position:"top",align:"center",hasArrow:!0,bgColor:"#232630",trigger:Object(y.jsxs)("span",{className:"font-bold","data-testid":"size-remaining",children:["+",r.length]}),children:Object(y.jsx)("div",{className:"gr-w-40 text-xs text-white",children:r.map((function(e){return e.name})).join(", ")})})]})};iN.defaultProps={cropSeasons:[]};var oN=iN,sN=function(){return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.75 3.75V14.25H14.25V9H15.75V14.25C15.75 15.075 15.075 15.75 14.25 15.75H3.75C2.9175 15.75 2.25 15.075 2.25 14.25V3.75C2.25 2.925 2.9175 2.25 3.75 2.25H9V3.75H3.75ZM10.5 3.75V2.25H15.75V7.5H14.25V4.8075L6.8775 12.18L5.82 11.1225L13.1925 3.75H10.5Z",fill:"#696F88"})})},lN=function(e){var t=e.id,n=Object(a.useContext)($T).state.integrationType,r=Object(p.h)();return Object(y.jsxs)("a",{className:"flex flex-line justify-start align-center",href:!1,onClick:function(){return r.push("".concat(Cc.integrations,"/").concat(n,"/submission/").concat(t))},children:[Object(y.jsx)(sN,{})," ",Object(y.jsx)("span",{className:"ml-1",children:"View"})]})},dN=function(e){var t=e.submission;return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"flex w-full justify-start",children:mA(t.date,"MMM dd, yyyy h:mm aaaa")})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"flex w-auto justify-start",children:Object(y.jsx)(aN,{type:t.status})})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"text-left",children:t.taskCount})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(oN,{cropSeasons:t.cropSeasons})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(cN,{propertiesArea:t.propertiesArea,propertiesCount:t.propertiesCount,propertiesNames:t.propertiesNames})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(lN,{id:t.id})})]})},uN=(n(1547),function(){var e=Object(a.useContext)($T),t=e.getData,n=e.loading,r=e.state,c=r.data,i=r.elements,o=r.page,s=r.limit,l=Object(a.useState)({sortBy:"date",sortDir:"desc"}),d=Object(b.a)(l,2),u=d[0],j=d[1],p=function(){var e=Object(Y.a)(G.a.mark((function e(a,r){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,t(r,"date"===a?"created_at":a);case 4:j({sortBy:a,sortDir:r});case 5:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),f=function(){var e=Object(Y.a)(G.a.mark((function e(a){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,t(u.sortDir,"date"===u.sortBy?"created_at":u.sortBy,a);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){function e(){return(e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t();case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[]),Object(y.jsx)(y.Fragment,{children:(null===c||void 0===c?void 0:c.length)>0&&Object(y.jsxs)("div",{className:"mb-6",children:[Object(y.jsx)("div",{className:"w-full mb-2 font-semibold",children:Object(y.jsx)("p",{className:"text-xl",children:"Previous Submissions"})}),Object(y.jsxs)("div",{className:"flex flex-col bg-white rounded-xl justify-between w-full syt-antd-table-wrapper ".concat(n?"previous-submission-table-loading":""),children:[Object(y.jsx)(ol,{isLoading:n,listType:"Pevious Submissions",items:c,tableColumns:QT.columns,onSort:p,sortBy:u.sortBy,sortDir:u.sortDir,simpleSortMode:!0,"data-testid":"submission-history-table",hasRouting:!1,message:"Click in the button on top of screen and create a new submission",children:function(e){var t=e.rows;return n?null:t.map((function(e){return Object(y.jsx)(dN,{submission:e},e.id)}))}}),Object(y.jsx)("div",{className:"w-full pr-2 ".concat(n?"pointer-events-none cursor-not-allowed":""),children:Ho(i,o,f,null,s)})]})]})})});uN.defaultProps={};var bN=uN,jN=function(e){var t=e.buttonText,n=e.breadcrumbText,a=e.ownerText,r=e.headerText,c=e.targetPath,i=e.LogoImg,o=Object(p.h)();return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(lo,{hideCropSeasonDropdown:!0,disabled:!0,children:Object(y.jsx)(lo.Item,{title:"Integrations",value:n,isLast:!0})}),Object(y.jsxs)("div",{className:"flex flex-col w-full items-start mt-5",children:[Object(y.jsx)(m.Button,{type:"outline",className:"absolute",icon:Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.e}),onClick:function(){return o.replace("".concat(Cc.integrations))},children:"Back"}),Object(y.jsxs)("div",{className:"mt-3 w-full border-b flex gap-5 items-center justify-between rounded-lg pt-2 pb-6",children:[Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"bg-white rounded-xl shadow-md border p-6",children:Object(y.jsx)("img",{src:i,alt:""})}),Object(y.jsxs)("div",{className:"pl-5 flex flex-col justify-center",children:[Object(y.jsx)("h3",{className:"font-bold text-2xl",children:r}),Object(y.jsxs)("h2",{children:["By ",a]})]})]}),Object(y.jsx)("a",{className:"gr-button","data-size":"lg","data-type":"primary",href:!1,onClick:function(){o.push("".concat(Cc.integrations,"/").concat(c))},children:Object(y.jsx)("span",{className:"pl-6 pr-6",children:t})})]})]})]})};jN.defaultProps={buttonText:"Start a new Submission"};var pN=jN,fN=function(e){var t=e.number,n=e.header,a=e.description,r=e.key,c=void 0===r?"key":r;return Object(y.jsxs)("div",{className:"flex flex-line",children:[Object(y.jsx)("span",{className:"p-4 h-4 w-4 flex items-center justify-center border rounded-3xl bg-info-dark-blue text-white border-info-dark-blue mr-2 font-semibold",children:t}),Object(y.jsx)("div",{className:"`flex items-center",children:Object(y.jsxs)("div",{className:"flex flex-col",children:[Object(y.jsx)("p",{className:"font-bold",children:n}),Object(y.jsx)("p",{className:"text-normal",children:a})]})})]},c)};fN.defaultProps={key:"key"};var mN=fN,vN=function(e){var t=e.steps,n=void 0===t?eh:t;return Object(y.jsxs)("div",{className:"w-full flex flex-col bg-white rounded-xl border border-gray-400 font-body shadow-2xl mb-10",style:{padding:"2.25rem"},children:[Object(y.jsx)("div",{className:"w-full font-semibold ",children:Object(y.jsx)("p",{className:"text-base",children:"How to submit"})}),Object(y.jsx)("div",{className:"flex flex-line w-full items-start mt-4 mb-6 gap-12",children:n.map((function(e){return Object(y.jsx)(mN,{number:e.number,header:e.header,description:e.description},e.number)}))}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)("p",{className:"text-normal",children:"You can review and resubmit to processors at any point"})})]})};vN.defaultProps={steps:eh};var ON=vN,hN=[{number:1,header:"Sign In",description:"Authenticate with your vendor credentials"},{number:2,header:"Select Organization",description:"Select an organization which you would like to submit Task records"},{number:3,header:"Select Crop Seasons",description:"Select the Crop Seasons with which you would like to submit Task records"},{number:4,header:"Select Properties",description:"Select the Properties with Tasks records you would like to submit"},{number:5,header:"Match Properties",description:"Match the Cropwise Financials properties with the integration vendor"},{number:6,header:"Match Products",description:"Match the Cropwise Financials products with the integration vendor"},{number:7,header:"Review and Submit",description:"Review your Task records and then submit the information to the processor"}],xN=function(){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(pN,{headerText:"".concat(KO," Processor Integration"),breadcrumbText:KO,ownerText:KO,targetPath:KO,LogoImg:TO}),Object(y.jsx)("div",{className:"w-full border-t-1 mb-5"}),Object(y.jsx)(tN,{integrationType:KO,children:Object(y.jsx)(bN,{})}),Object(y.jsx)(ON,{steps:hN})]})},gN=function(){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(pN,{headerText:"".concat(QO," Processor Integration"),breadcrumbText:QO,ownerText:QO,targetPath:QO,LogoImg:NO}),Object(y.jsx)("div",{className:"w-full border-t-1 mb-5"}),Object(y.jsx)(tN,{integrationType:QO,children:Object(y.jsx)(bN,{})}),Object(y.jsx)(ON,{})]})},CN=[{number:1,header:"Select Crop Seasons",description:"Select the Crop Seasons with which you would like to submit Task records"},{number:2,header:"Select Properties",description:"Select the Properties with Tasks records you would like to submit"},{number:3,header:"Select Products",description:"Select the products you would like to include in the submission."},{number:4,header:"Enter Field Details",description:"Enter remaining field information needed for submission"},{number:5,header:"Review and Submit",description:"Review your Task records and then submit the information to the processor"}],yN=function(){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(pN,{headerText:"".concat($O," Regulatory Integration"),breadcrumbText:$O,ownerText:$O,targetPath:$O,LogoImg:EO}),Object(y.jsx)("div",{className:"w-full border-t-1 mb-5"}),Object(y.jsx)(tN,{integrationType:$O,children:Object(y.jsx)(bN,{})}),Object(y.jsx)(ON,{steps:CN})]})},PN=function(){var e=lx(),t=e.events,n=e.triggerAnalyticsEvent,r=Object(a.useContext)($h).goForward,c=Object(a.useContext)(SC).updateSubmissionFilterCropZoneIds,i=Object(a.useContext)(Xg).updateFarmsMatch,o=Object(a.useState)(!0),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(Zi.h)().values;return Object(a.useEffect)((function(){d(!l),i(u.selectedProperties),u.selectedProperties&&!l&&(c(aC(u.selectedProperties)),n(t.epic.Integrations.submissionPropertiesSelected,{vendor:$O}),r())}),[u.selectedProperties]),Object(y.jsx)(Wx,{integrationName:$O})},AN=function(e){var t=e.firstLabel,n=e.secondLabel,a=e.status,r=e.isTagVisible,c=e.pastSubmission,i=Object(y.jsx)("div",{className:"ml-6",children:Object(y.jsx)(Xc.Tag,{color:"neutral","data-testid":"field-past-submission",children:"Previously Submitted"},"field-past-submission")});return Object(y.jsxs)("div",{className:"m-4 flex flex-row w-full justify-start",children:[r&&Object(y.jsx)("span",{className:"text-yellow-700",children:Object(y.jsx)(Xc.Tag,{color:function(e){switch(e){case ah:case"complete":return"green";case"need_info":return"yellow";default:return"red"}}(a),"data-testid":"status-tag",children:function(e){switch(e){case ah:return"SUBMITTED";case"complete":return"COMPLETE";case"need_info":return"NEEDS INFO";default:return"ERROR"}}(a)},"field-status")}),Object(y.jsx)("span",{className:"ml-2 ","data-testid":"farm-name",children:t}),Object(y.jsxs)("span",{className:"ml-2 font-bold","data-testid":"farm-name",children:["/ ",n]}),c&&Object(y.jsx)(m.Popup,{enableHover:!0,position:"top",align:"center",hasArrow:!0,bgColor:"#232630",trigger:i,children:Object(y.jsxs)("div",{className:"gr-w-48 text-xs text-white text-left","data-testid":"previously-submitted-hover-content",children:["This record was last submitted on"," ",vA(c.submittedAt)," with Document Number"," ",c.internalRecordId]})})]})};AN.defaultProps={firstLabel:"NOT_DEFINED_FIRST_LABEL",secondLabel:"NOT_DEFINED_SECOND_LABEL",status:"NOT_DEFINED_STATUS",isTagVisible:!0,pastSubmission:null};var SN=AN,TN=function(e){var t=e.setStateSelected,n=Object(Zi.h)(),r=n.setFieldValue,c=n.values,i=Object(a.useContext)(ac),o=Object(b.a)(i,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Search,value:null===c||void 0===c?void 0:c.state,name:"state",items:Nl,label:"State",placeholder:"Select State",type:"text",disabled:!o,"data-testid":"ui-field-state",onSelect:function(e){r("state",e.key),r("county",""),t(!0)}})};TN.defaultProps={setStateSelected:function(){}};var NN=TN,EN=n(799),wN=function(){var e,t=Object(Zi.h)().values,n=Object(a.useState)(),r=Object(b.a)(n,2),c=r[0],i=r[1],o=!t.state||"null"===t.state;return Object(a.useEffect)((function(){i(o?"You must first select a state.":null)}),[t.state]),Object(y.jsx)(Qi,{control:m.Search,value:null===t||void 0===t?void 0:t.county,errorMessage:c,name:"county",label:"County",disabled:o,items:(e=null===t||void 0===t?void 0:t.state,(null===e||void 0===e?void 0:e.length)>0?(EN.a.getCountiesByState(e)||[]).map((function(e){return{key:e,value:e}})):null),placeholder:"Select County"})},_N=function(){return Object(y.jsx)(Qi,{placeholder:"Enter township",control:m.Input,type:"text",name:"township",id:"township",label:"Township"})},RN=function(){var e=Object(Zi.h)().values,t=Object(a.useState)(),n=Object(b.a)(t,2),r=n[0],c=n[1],i=!e.township;return Object(a.useEffect)((function(){c(i?"Township must be entered first":null)}),[e.township]),Object(y.jsx)(Qi,{control:m.Select,type:"text",name:"townshipDirection",id:"townshipDirection",errorMessage:r,placeholder:"Select principle meridian direction",items:[{key:"none",value:"None"},{key:"north",value:"North"},{key:"south",value:"South"}],disabled:i})},IN=function(){return Object(y.jsx)(Qi,{placeholder:"Enter range",control:m.Input,type:"text",name:"range",id:"range",label:"Range"})},DN=function(){var e=Object(Zi.h)().values,t=Object(a.useState)(),n=Object(b.a)(t,2),r=n[0],c=n[1],i=!e.range;return Object(a.useEffect)((function(){c(i?"Range must be entered first":null)}),[e.range]),Object(y.jsx)(Qi,{type:"text",control:m.Select,name:"rangeDirection",id:"rangeDirection",errorMessage:r,placeholder:"Select baseline direction",items:[{key:"none",value:"None"},{key:"east",value:"East"},{key:"west",value:"West"}],disabled:i})},kN=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit,n=Object(Zi.h)().values;return Object(y.jsx)(Qi,{value:n.permitId,placeholder:"Enter permit ID",control:m.Input,id:"permitId",name:"permitId",label:"Permit ID","data-testid":"ui-field-permit-id",disabled:!t})},LN=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{placeholder:"Enter site ID",control:m.Input,id:"siteId",name:"siteId",label:"Site ID","data-testid":"siteId",disabled:!t})},FN=function(e){var t=e.label,n=e.halfWidth,a=e.children,r=e.suffix,c=e.suffixOffset,i=e.noLabelMarginTop,o=e.labelMarginTop,s=n?"":"col-span-2",l=t?o:i;return Object(y.jsxs)("div",{className:"relative flex flex-col ".concat(s," justify-center ").concat(l," mb-2 gap-y-0"),"data-testid":"ui-field-editor",children:[t&&Object(y.jsx)("span",{className:"text-sm text-neutral-600",children:t}),a,r&&Object(y.jsx)("div",{className:"text-sm absolute ".concat(c," top-1"),children:r})]})};FN.defaultProps={halfWidth:!1,label:"",suffix:"",suffixOffset:"right-2",noLabelMarginTop:"mt-8",labelMarginTop:"mt-4"};var MN=FN,VN=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{placeholder:"Enter section",control:m.Input,type:"text",id:"section",name:"section",label:"Section","data-testid":"section",disabled:!t})},BN=function(e){var t=e.geometry,n=e.name,a=e.farm;return Object(y.jsxs)("div",{className:"flex flex-col w-full",children:[Object(y.jsxs)("div",{className:"flex flex-row w-full justify-start",children:[Object(y.jsx)("div",{className:"w-1/2",children:Object(y.jsx)("div",{className:"mt-2 bg-gray-100 rounded-lg overflow-hidden text-left mr-4 p-4",children:Object(y.jsx)(tP,{className:"rounded-lg min-h-60",feature:lP({name:n,farm:a,geometry:t}),containerStyle:{height:"310px"}},"property-preview-with-vendor=any")})}),Object(y.jsxs)("div",{className:"grid grid-cols-2 w-1/2 gap-x-2",children:[Object(y.jsx)(MN,{label:"State",labelMarginTop:"mt-2",children:Object(y.jsx)(NN,{})}),Object(y.jsx)(MN,{label:"County",labelMarginTop:"mt-2",children:Object(y.jsx)(wN,{})}),Object(y.jsx)(MN,{labelMarginTop:"mt-2",children:Object(y.jsx)(VN,{})}),Object(y.jsx)(MN,{halfWidth:!0,children:Object(y.jsx)(_N,{})}),Object(y.jsx)(MN,{halfWidth:!0,children:Object(y.jsx)(RN,{})}),Object(y.jsx)(MN,{halfWidth:!0,children:Object(y.jsx)(IN,{})}),Object(y.jsx)(MN,{halfWidth:!0,children:Object(y.jsx)(DN,{})})]})]}),Object(y.jsxs)("div",{className:"grid grid-cols-2 border-t-1 mt-4 gap-x-2",children:[Object(y.jsx)(MN,{halfWidth:!0,htmlFor:"permitId",children:Object(y.jsx)(kN,{})}),Object(y.jsx)(MN,{halfWidth:!0,children:Object(y.jsx)(LN,{})})]})]})};BN.defaultProps={name:"NOT_DEFINED_NAME",farm:"NOT_DEFINED_FARM"};var UN=BN,zN=function(e){var t=e.field,n=e.toggleCallback,a=e.selectedId,r=t.status,c=t.fieldName,i=t.cropZoneName,o=t.fieldId,s=t.cropZoneId,l=t.geometry;return Object(y.jsx)(dA,{header:Object(y.jsx)(SN,{firstLabel:c,secondLabel:i,status:r}),isFullWidthButton:!0,content:Object(y.jsx)(UN,{name:i,farm:c,geometry:l}),toggleCallback:n,dynamicToggle:!0,canExpand:"".concat(o,"#").concat(s)===a,isProperty:!1,headerHeight:"40px"})};zN.defaultProps={toggleCallback:function(){},selectedId:""};var ZN=Object(a.memo)(zN),YN=function(){var e=lx(),t=e.events,n=e.triggerAnalyticsEvent,r=Object(a.useContext)($h),c=r.goForward,i=r.blockStepForward,o=Object(a.useContext)(ac),s=Object(b.a)(o,2),l=s[0].isEnableInfoTabEdit,d=s[1],u=Object(a.useContext)(SC),j=u.state,p=j.fields,f=j.submissionId,v=u.isLoading,O=u.getSubmissionFields,h=u.setSubmissionFields,x=Object(Zi.h)(),g=x.values,C=x.setValues,P=Object(a.useState)(""),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)(p),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(p.filter((function(e){return"need_info"===e.status})).length),D=Object(b.a)(R,2),k=D[0],L=D[1];Object(a.useEffect)((function(){function e(){return(e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O();case 2:e.sent||i();case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}f&&function(){e.apply(this,arguments)}()}),[f,i]),Object(a.useEffect)((function(){_(p)}),[p,_]),Object(a.useEffect)((function(){return l||d({type:"IS_ENABLE_INFO_TAB_EDIT",payload:!0}),function(){d({type:"IS_ENABLE_INFO_TAB_EDIT",payload:!1})}}),[]),Object(a.useEffect)((function(){L(w.filter((function(e){return"need_info"===e.status})).length)}),[w]);var F=function(e){return Object(I.a)(Object(I.a)({},e),{},{rangeNumber:e.range,townshipNumber:e.township})};Object(a.useEffect)((function(){""!==S&&function(e,t){var n,a="need_info";n=F(t),["state","county","section","townshipNumber","townshipDirection","rangeNumber","rangeDirection","permitId","siteId"].every((function(e){return n[e]}))&&["north","south"].includes(n.townshipDirection)&&["west","east"].includes(n.rangeDirection)&&(a="complete");var r=w.map((function(n){return"".concat(n.fieldId,"#").concat(n.cropZoneId)===e?Object(I.a)(Object(I.a)(Object(I.a)({},n),F(t)),{},{status:a}):n}));_(r)}(S,g)}),[g]);var M=function(e){if(S==="".concat(e.fieldId,"#").concat(e.cropZoneId))T(""),C(Object(I.a)(Object(I.a)({},g),{},{state:"",county:"",section:"",township:"",townshipNumber:"",townshipDirection:"",rangeNumber:"",range:"",rangeDirection:"",permitId:"",siteId:""}));else{var t=e.state||"CA";T("".concat(e.fieldId,"#").concat(e.cropZoneId)),C(Object(I.a)(Object(I.a)(Object(I.a)({},g),function(e){return Object(I.a)(Object(I.a)({},e),{},{range:e.rangeNumber,township:e.townshipNumber})}(e)),{},{state:t}))}},V=function(){c(),n(t.epic.Integrations.submissionFieldsFilledRegulatoryData,{vendor:$O})},B=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=w.filter((function(e){return-1===p.findIndex((function(t){var n=Object(I.a)({},e);return delete n.range,delete n.township,JSON.stringify(t)===JSON.stringify(n)}))})),null!==t&&void 0!==t&&t.length){e.next=4;break}return V(),e.abrupt("return");case 4:return e.next=6,h(t);case 6:e.sent&&V();case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsxs)("div",{className:"flex flex-col bg-white top-30 left-26 w-140 rounded-md mb-20 p-6 shadow-sm","data-testid":"submission-crop-season-selection",children:[Object(y.jsxs)("div",{className:"mb-4 flex flex-row",children:[Object(y.jsxs)("div",{className:"flex flex-col",children:[Object(y.jsx)("div",{className:"text-lg leading-7 font-semibold text-neutral-1000 mb-2",children:"Enter Field Details"}),Object(y.jsx)("p",{className:"text-sm leading-6 text-neutral-70",children:"Enter property details for the fields you are submitting. Any details entered from the property page will be shown here."})]}),!v&&Object(y.jsx)("div",{className:"flex h-full items-center",children:Object(y.jsx)("span",{className:"ml-4 p-3 text-base ".concat(0!==k?" text-yellow-700 bg-yellow-200":" text-green-700 bg-green-200"," rounded-lg whitespace-no-wrap h-fit flex fle-row"),children:0!==k?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("strong",{"data-testid":"need-info-fields",className:"mr-1",children:k})," ","Fields Need Info"]}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"mr-3 w-fit h-fit p-1 rounded-full bg-green-600",children:Object(y.jsx)(m.Icon,{size:12,icon:"checkmark",color:"#FFFFFF"})}),Object(y.jsx)("div",{children:"Fields Details Entered"})]})})})]}),v?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(y.Fragment,{children:w.map((function(e){return Object(y.jsx)(ZN,{field:e,toggleCallback:function(){return M(e)},selectedId:S},"field-".concat(e.fieldId,"-").concat(e.cropZoneId))}))}),Object(y.jsx)(px,{onNext:B,loading:v,nextLabel:"Next: Review and Submit",nextDisabled:0!==k})]})},HN=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useContext)(ac),i=Object(b.a)(c,2),o=i[0].organization,s=i[1];return{getProductsMatches:Object(a.useCallback)((function(e){var t=e.submissionId,n=bn.createChildApi({action:"integrations/calag/submissions/".concat(t,"/products")}).fetch(null,void 0,{headers:{"cwf-context":JSON.stringify({organization_id:o.id})}}).promise;return r(!0),n.then((function(e){return e})).catch(Ae.default).catch(uc(s)).finally((function(){return r(!1)}))}),[o]),updateProductsMatches:Object(a.useCallback)((function(e){var t=bn.createChildApi({action:"integrations/calag/match/products"}).create(e,{headers:{"cwf-context":JSON.stringify({organization_id:o.id})}}).promise;return r(!0),t.then((function(e){return e})).catch(Ae.default).catch(uc(s)).finally((function(){return r(!1)}))}),[o]),loading:n}},GN=function(e){var t=e.width,n=e.height,a=e.color,r=e.size;return Object(y.jsxs)("svg",{width:"".concat(t),height:"".concat(n),viewBox:"0 0 ".concat(r," ").concat(r),fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.87499 9H10.125L11.1578 11.735C11.3431 12.2256 10.9806 12.75 10.4562 12.75H7.54458C7.02027 12.75 6.65777 12.2258 6.84287 11.7352L7.87499 9ZM8.62499 10.5L8.24999 11.25H9.74999L9.37499 10.5H8.62499Z",fill:a}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.24999 17.25L8.24999 14.25H9.74999V17.25H8.24999Z",fill:a}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11.874 15.7881L10.626 13.916L11.874 13.084L13.1221 14.9561L11.874 15.7881Z",fill:a}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.87789 14.9561L6.12597 13.084L7.37404 13.916L6.12597 15.7881L4.87789 14.9561Z",fill:a}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.89199 2.68659C3.53666 2.19027 3.89141 1.5 4.50181 1.5H13.498C14.1084 1.5 14.4631 2.19025 14.1078 2.68658L10.125 8.25H7.87499L3.89199 2.68659ZM5.95726 3L8.63583 6.75H9.3639L12.0425 3H5.95726Z",fill:a})]})};GN.defaultProps={color:"#696F88",height:18,width:18,size:18};var WN=GN,qN=/^\d+-\d+-[A-Za-z]{2}(-\d+)?$/,JN=function(e){var t=e.product,n=e.matchedRegistrationNumber,r=e.checked,c=Object(a.useContext)(SC),i=c.state.selectedProducts,o=c.setSelectedProducts,s=i.find((function(e){return e.productId===t.productId})),l=Object(y.jsx)("div",{className:"w-52",children:Object(y.jsx)(Qi,{style:{borderColor:null!==s&&void 0!==s&&s.error?"#EB4B4B":"#e2e8f0"},placeholder:"CDPR Registration #",control:m.Input,required:r,type:"text",id:"product_".concat(t.productId),name:"product_".concat(t.productId),value:null===s||void 0===s?void 0:s.overrideRegistrationNumber,onChange:function(e){return function(e){var t=null===e||void 0===e?void 0:e.replace(/\s/g,""),n=t&&qN.test(t);s.overrideRegistrationNumber=t,s.error=!n,o(i)}(e.target.value)}})});return Object(y.jsxs)("div",{className:"flex p-4 flex-line items-center justify-center w-full rounded shadow-md ",children:[Object(y.jsxs)(pu,{className:"flex items-center justify-center",onClick:function(){var e=i.findIndex((function(e){return e.productId===t.productId}));e>=0?i.splice(e,1):i.push(Object(I.a)(Object(I.a)({},t),{},{overrideRegistrationNumber:rC(t.overrideRegistrationNumber||n)})),o(i)},children:[Object(y.jsx)("div",{className:"mr-2",children:Object(y.jsx)(m.Checkbox,{checked:r,color:"#0071cd"})}),Object(y.jsxs)("div",{className:"flex items-center justify-center",children:[Object(y.jsx)(WN,{width:24,height:24,size:18}),Object(y.jsx)("span",{className:"ml-1 font-lg",children:t.productName})]})]}),Object(y.jsxs)("div",{className:"ml-auto flex justify-center items-center",children:[r&&Object(y.jsx)("div",{className:"mr-10",children:Object(y.jsx)(m.Popup,{enableHover:!0,position:"top",align:"center",hasArrow:!0,bgColor:"#232630",trigger:l,children:Object(y.jsx)("div",{className:"gr-w-64 text-xs text-white","data-testid":"product-input-hover-content",children:"Here it is expected that a valid CDPR registration number will be filled in. You can use the link above to search."})})}),Object(y.jsx)("div",{children:Object(y.jsx)(m.Tag,{color:"#C6E6FF",children:Object(y.jsxs)("span",{className:"p-1 text-blue-70",children:[t.countApplications," ","".concat(t.countApplications>1?"APPLICATIONS":"APPLICATION")]})})})]})]})};JN.defaultProps={matchedRegistrationNumber:void 0};var KN=JN,QN=["1101+","1102","1103","1104","1105+","1106","1107","1108","1143","1144","1146","1147","1148"],XN=["1201","1202","1203","1204","1205","1206","1207","1208","1209","1210","1211","1242","1243","1245","1247","1248","1249","1259"],$N=[{name:"1100 series",codes:[].concat(QN,["1109","1145","1149","1190"])},{name:"1200 series",codes:[].concat(XN,["1290"])},{name:"1100-1300 series",codes:[].concat(QN,["1145+"],XN,["1390"])},{name:"1400 series",codes:["1401","1402","1403","1404","1405","1406","1407","1408","1409","1410","1411","1412","1413","1447","1452","1455","1472","1490"]},{name:"1500 series",codes:["1501","1502","1590"]},{name:"1600 series",codes:["1601","1602","1603","1604","1605","1690"]},{name:"1700 series",codes:["1701","1702","1703","1704","1705"]}],eE=[{key:"grower",value:"Grower Applied"},{key:"pco",value:"PCO Applied"}],tE=[{key:"PCB",value:"PCB"},{key:"PCM",value:"PCM"},{key:"APC",value:"APC"},{key:"JPC",value:"JPC"},{key:"PAC",value:"PAC"},{key:"UAPC",value:"UAPC"},{key:"UJPC",value:"UJPC"},{key:"VCT",value:"VCT"}],nE=function(){var e=lx(),t=e.events,n=e.triggerAnalyticsEvent,r=Object(a.useContext)($h),c=r.state.comingFromStep,i=r.goForward,o=r.goBack,s=r.releaseStepForward,l=Object(a.useContext)(ac),d=Object(b.a)(l,1)[0].error,u=Object(a.useState)(!1),j=Object(b.a)(u,2),p=j[0],f=j[1],v=Object(a.useState)(new Map),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(!0),T=Object(b.a)(S,2),N=T[0],E=T[1],w=HN(),_=w.loading,R=w.getProductsMatches,D=w.updateProductsMatches,k=Object(a.useContext)(SC),L=k.state,F=L.selectedProducts,M=L.products,V=L.submissionId,B=k.isLoading,U=k.setSelectedProducts,z=k.startSubmission,Z=k.getSubmissionProducts,H=k.setSubmissionProducts,W=Object(a.useState)(!1),q=Object(b.a)(W,2),J=q[0],K=q[1];Object(a.useEffect)((function(){2===c?(U([]),z().then((function(){E(!1)}))):E(!1)}),[]),Object(a.useEffect)((function(){function e(){return(e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!V||N){e.next=4;break}return e.next=3,Z();case 3:f(!0);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[V,N]),Object(a.useEffect)((function(){function e(){return(e=Object(Y.a)(G.a.mark((function e(){var t,n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,R({submissionId:V});case 2:(null===(n=e.sent)||void 0===n||null===(t=n.data)||void 0===t?void 0:t.length)>0&&x(null===n||void 0===n||null===(a=n.data)||void 0===a?void 0:a.reduce((function(e,t){return e.set(t.cwfProductId,t.calAgRegistrationNumber),e}),new Map));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}V&&(null===M||void 0===M?void 0:M.length)>0&&p&&function(){e.apply(this,arguments)}()}),[V,M,p,x,R]);var Q=Object(a.useCallback)((function(){var e=!J;K(e),U(e?M.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{overrideRegistrationNumber:rC(e.overrideRegistrationNumber||h.get(e.productId))})})):[])}),[J,h]);Object(a.useEffect)((function(){K(M.length&&F.length===M.length)}),[F,U,M]);var X=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return A(!0),e.next=3,H();case 3:if(e.sent instanceof Error){e.next=9;break}return e.next=7,D(null===F||void 0===F?void 0:F.map((function(e){return{cwfProductId:e.productId,calAgRegistrationNumber:e.overrideRegistrationNumber}})));case 7:n(t.epic.Integrations.submissionProductsSelected,{vendor:$O}),i();case 9:A(!1);case 10:case"end":return e.stop()}}),e)}))),[H,D,i,n,t]);return Object(a.useEffect)((function(){!N&&d&&o()}),[d,N]),Object(a.useEffect)((function(){F.length>0&&s()}),[F,s]),Object(y.jsxs)("div",{className:"flex flex-col bg-white top-30 left-26 w-140 rounded-md shadow-lg mb-20","data-testid":"submission-calag-products-selection",children:[Object(y.jsxs)("div",{className:"p-10",children:[Object(y.jsx)("h1",{className:"text-xl leading-7 font-normal font-semibold text-neutral-1000 mb-2",children:"Select Products"}),Object(y.jsx)("h2",{className:"mb-6 font-body text-base font-normal text-neutral-70 text-left",children:"Based on the crop seasons and properties you selected we\u2019ve found a list of relevant products to submit. Choose which products you\u2019d like to submit."}),Object(y.jsxs)("div",{className:"h-full w-full mt-4",children:[Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"ml-4",children:Object(y.jsx)(m.Checkbox,{label:"Select All",onChange:Q,checked:J,color:"#0071cd"})}),Object(y.jsx)("div",{className:"ml-auto",children:Object(y.jsx)("a",{href:"https://apps.cdpr.ca.gov/docs/label/prodnam.cfm",type:"button",target:"_blank",rel:"noopener noreferrer",children:Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)("div",{className:"block px-2 font-normal text-center w-36 text-green-700",children:"Search for CDPR Registration Number"}),Object(y.jsx)(XC,{fill:"#0C612C"})]})})})]}),Object(y.jsx)("div",{className:"border-t-2 pt-4 mt-4 gap-1 flex flex-col",children:P||!B&&!_?Object(y.jsx)(y.Fragment,{children:M.map((function(e){return Object(y.jsx)(KN,{matchedRegistrationNumber:h.get(e.productId),product:e,checked:F.some((function(t){return t.productId===e.productId}))},e.productId)}))}):Object(y.jsx)(m.Spinner,{})})]})]}),Object(y.jsx)(px,{onNext:X,nextLabel:"Next: Enter Field Details",loading:P||B,nextDisabled:!F.length||F.some((function(e){return e.error||!e.overrideRegistrationNumber}))})]})},aE=function(e){var t=e.onRemove,n=Object(a.useContext)(SC),r=n.removeTaskFromCropzone,c=n.setOpenRemoveTaskModal,i=n.state.openRemoveTaskModal;return Object(y.jsxs)(ao,{open:i,type:"buttonless",style:{paddingLeft:"2rem"},children:[Object(y.jsxs)("div",{className:"flex flex-line w-full mt-2 justify-between","data-testid":"remove-task-modal",children:[Object(y.jsx)("div",{className:"flex mr-4",children:Object(y.jsx)(bg,{color:"red-700"})}),Object(y.jsxs)("div",{className:"flex flex-col pr-10",style:{flexGrow:1},children:[Object(y.jsx)("div",{className:"flex flex-row justify-items-center pb-4",children:Object(y.jsx)("h3",{className:"font-bold text-lg leading-6 text-gray-900 w-full",children:"Are you sure you want to remove?"})}),Object(y.jsx)("div",{className:"flex flex-col mb-4",children:"This pesticide usage report will be removed from this submission. You can include it in a future submission."})]})]}),Object(y.jsx)("div",{className:"pr-10",children:Object(y.jsxs)("div",{className:"mt-5 flex flex-row items-center justify-between w-full",children:[Object(y.jsx)("div",{className:"mr-5",children:Object(y.jsx)(m.Button,{type:"outline",id:"cancel-button",onClick:function(){c(!1)},children:"Cancel"})}),Object(y.jsx)("div",{children:Object(y.jsx)(m.Button,{type:"primary-danger",id:"submit-button",onClick:function(){c(!1),r(),t()},children:"Remove"})})]})})]})};aE.defaultProps={onRemove:function(){}};var rE=aE;function cE(e){return!0===e?"Yes":!1===e?"No":""===e||null===e||"undefined"===typeof e||"null"===e?Object(y.jsxs)("div",{children:[Object(y.jsx)("span",{className:"neutral-70",children:"None entered"}),Object(y.jsx)("br",{})]}):e.split?e.split("\n").map((function(e){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("span",{children:e}),Object(y.jsx)("br",{})]})})):Array.isArray(e)?e.filter((function(e){return!!e})).length>0?e.map((function(e){return cE(e)})):cE(""):e.toString()}function iE(e){var t=e.label,n=e.value,a=e.icon,r=e.WidthLabel,c=e.widthValue,i=e.ghostValue,o=e.displayIcon;return Object(y.jsxs)("div",{className:"flex w-full mr-4 mt-4 pb-2 border-b-1 border-neutral-20 ".concat(t?"justify-center":""),"data-testid":"property-row",children:[t&&Object(y.jsx)(m.Column,{width:"".concat(r," relative opacity-50"),children:t},Object(cc.generate)()),Object(y.jsxs)(m.Column,{width:"".concat(c," relative ").concat(i?"text-gray-500":""),children:[a&&o&&Object(y.jsx)("img",{className:"mr-2 w-6 h-6 inline-block",alt:"Field Icon",src:a}),cE(n)]},Object(cc.generate)())]})}iE.defaultProps={label:"",icon:"",WidthLabel:"w-1/2",widthValue:"w-1/2",ghostValue:!1,displayIcon:!0};var oE=iE,sE=function(e){var t=e.size,n=e.color;return Object(y.jsx)("svg",{width:t,height:t,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"trash-icon",className:"fill-current text-".concat(n),children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.875 2.25H7.125L6.375 3H3.75V4.5H14.25V3H11.625L10.875 2.25ZM12 6.75V14.25H6V6.75H12ZM4.5 5.25H13.5V14.25C13.5 15.075 12.825 15.75 12 15.75H6C5.175 15.75 4.5 15.075 4.5 14.25V5.25Z"})})};sE.defaultProps={color:"red-700",size:20};var lE=Object(a.memo)(sE),dE=function(){var e=xl("companies"),t=Object(a.useContext)(ac),n=Object(b.a)(t,2),r=n[0].organization,c=n[1],i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(!0),j=Object(b.a)(d,2),p=j[0],f=j[1],m=Object(a.useState)(null),v=Object(b.a)(m,2),O=v[0],h=v[1],x=Object(a.useCallback)((function(){e.fetch().promise.then((function(e){var t=e.data;t&&l(t)})).catch(Ae.default).catch(uc(c)).catch((function(e){uc(c)(e)})).finally((function(){f(!1)}))}),[e,c]);Object(a.useEffect)((function(){return x()}),[x]);var g=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h(!0),n={headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:r.id}),Authorization:"Bearer ".concat(Ve())}},a=J.a.post("".concat(u.d,"/v1/base/company"),t,n),e.abrupt("return",a.then((function(e){var t=e.data;return l(s.concat([t])),t})).catch(Ae.default).catch(uc(c)).finally((function(){h(!1)})));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{companies:s,loading:p,isCreatingCompany:O,createCompany:g,loadCompanies:x}},uE=function(){var e=xl("people"),t=Object(a.useContext)(ac),n=Object(b.a)(t,2),r=n[0].organization,c=n[1],i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(null),j=Object(b.a)(d,2),p=j[0],f=j[1],m=Object(a.useState)(!0),v=Object(b.a)(m,2),O=v[0],h=v[1],x=Object(a.useCallback)((function(){e.fetch().promise.then((function(e){var t=e.data;return t&&l(t),t})).catch(Ae.default).catch((function(e){return uc(c)(e),e})).finally((function(){h(!1)}))}),[e,c]);Object(a.useEffect)((function(){return x()}),[x]);var g=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),n={headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:r.id}),Authorization:"Bearer ".concat(Ve())}},a=J.a.post("".concat(u.d,"/v1/base/people"),t,n),e.abrupt("return",a.then((function(e){var t=e.data;return l(s.concat([t])),t})).catch(Ae.default).finally((function(){f(!1)})));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{people:s,loading:O,createPerson:g,isCreatingPerson:p,loadPeople:x}},bE=function(e){var t=e.size,n=e.color;return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 20 20",fill:"none","data-testid":"person-icon",className:"fill-current text-".concat(n),children:Object(y.jsx)("g",{id:"person",children:Object(y.jsx)("path",{id:"icon/social/person_24px",fillRule:"evenodd",clipRule:"evenodd",d:"M10.0002 3.33203C8.1585 3.33203 6.66683 4.8237 6.66683 6.66536C6.66683 8.50703 8.1585 9.9987 10.0002 9.9987C11.8418 9.9987 13.3335 8.50703 13.3335 6.66536C13.3335 4.8237 11.8418 3.33203 10.0002 3.33203ZM11.6668 6.66536C11.6668 5.7487 10.9168 4.9987 10.0002 4.9987C9.0835 4.9987 8.3335 5.7487 8.3335 6.66536C8.3335 7.58203 9.0835 8.33203 10.0002 8.33203C10.9168 8.33203 11.6668 7.58203 11.6668 6.66536ZM15.0002 14.9987C14.8335 14.407 12.2502 13.332 10.0002 13.332C7.7585 13.332 5.19183 14.3987 5.00016 14.9987H15.0002ZM3.3335 14.9987C3.3335 12.782 7.77516 11.6654 10.0002 11.6654C12.2252 11.6654 16.6668 12.782 16.6668 14.9987V16.6654H3.3335V14.9987Z"})})})};bE.defaultProps={color:"neutral-600",size:20};var jE=Object(a.memo)(bE),pE=function(e){var t=e.size,n=e.color;return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 20 20",fill:"none","data-testid":"company-icon",className:"fill-current text-".concat(n),children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.99984 5.83333H18.3332V17.5H1.6665V2.5H9.99984V5.83333ZM3.33317 15.8333H4.99984V14.1667H3.33317V15.8333ZM4.99984 12.5H3.33317V10.8333H4.99984V12.5ZM3.33317 9.16667H4.99984V7.5H3.33317V9.16667ZM4.99984 5.83333H3.33317V4.16667H4.99984V5.83333ZM6.6665 15.8333H8.33317V14.1667H6.6665V15.8333ZM8.33317 12.5H6.6665V10.8333H8.33317V12.5ZM6.6665 9.16667H8.33317V7.5H6.6665V9.16667ZM8.33317 5.83333H6.6665V4.16667H8.33317V5.83333ZM16.6665 15.8333V7.5H9.99984V9.16667H11.6665V10.8333H9.99984V12.5H11.6665V14.1667H9.99984V15.8333H16.6665ZM14.9998 9.16667H13.3332V10.8333H14.9998V9.16667ZM13.3332 12.5H14.9998V14.1667H13.3332V12.5Z"})})};pE.defaultProps={color:"neutral-600",size:20};var fE=Object(a.memo)(pE),mE=n.p+"static/media/company.a79daa65.svg",vE=n.p+"static/media/person.4244debf.svg",OE=function(){var e=Object(Zi.h)().values;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"col-span-2 my-4 mr-4 ",children:Object(y.jsx)(Qi,{value:e.addressLineOne,placeholder:"",control:m.Input,type:"text",name:"addressLineOne",label:"Address Line 1"})}),Object(y.jsx)("div",{className:"col-span-2 my-4 mr-4 ",children:Object(y.jsx)(Qi,{value:e.addressLineTwo,placeholder:"",control:m.Input,type:"text",name:"addressLineTwo",label:"Address Line 2"})}),Object(y.jsx)("div",{className:"col-span-2 my-4 mr-4 ",children:Object(y.jsx)(Qi,{value:e.city,placeholder:"",control:m.Input,type:"text",name:"city",label:"City"})}),Object(y.jsx)("div",{className:"col-span-1 my-4 mr-4 ",children:Object(y.jsx)(Qi,{value:e.state,placeholder:"",control:m.Select,items:[{key:null,value:"\u2002"}].concat(Nl),type:"text",name:"state",label:"State"})}),Object(y.jsx)("div",{className:"col-span-1 my-4 mr-4 ",children:Object(y.jsx)(Qi,{value:e.zipCode,placeholder:"",control:m.Input,type:"text",name:"zipCode",label:"Zip Code"})})]})},hE=function(){var e=Object(Zi.h)(),t=e.values,n=e.handleChange,r=e.errors,c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Ro("worker/companies",["company.name"]),d=l.loaded,u=l.items;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-8 w-1/2 pr-4",children:[Object(y.jsxs)("label",{htmlFor:"owner-name",className:"text-neutral-60 tracking-tighter text-sm",children:["Name",Object(y.jsx)("span",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Xc.Input,{required:!0,name:"name",id:"owner-name",type:"default",size:"middle",value:t.name,status:(null===r||void 0===r?void 0:r.name)&&"error",caption:null===r||void 0===r?void 0:r.name,onChange:n})]}),Object(y.jsx)("h3",{className:"text-base font-semibold block mb-4",children:"Basic Info"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5 w-full mr-8",children:[Object(y.jsx)("label",{htmlFor:"email",className:"text-neutral-60 tracking-tighter text-sm",children:"Email Address"}),Object(y.jsx)(Xc.Input,{type:"default",size:"middle",name:"email",id:"email",value:t.email,status:(null===r||void 0===r?void 0:r.email)&&"error",caption:null===r||void 0===r?void 0:r.email,onChange:n})]}),Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5 w-full",children:[Object(y.jsx)("label",{htmlFor:"phone",className:"text-neutral-60 tracking-tighter text-sm",children:"Phone Number"}),Object(y.jsx)(Xc.Input,{type:"default",size:"middle",name:"phone",id:"phone",value:t.phone,onChange:n})]})]}),Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5 w-1/2 pr-4",children:[Object(y.jsx)("label",{htmlFor:"company",className:"text-neutral-60 tracking-tighter text-sm",children:"Company"}),Object(y.jsx)(Xc.Select,{value:t.company,onDropdownVisibleChange:function(e){return s(e)},suffixIcon:Object(y.jsx)("img",{src:Di,style:{transform:o?"rotate(180deg)":null},height:18,width:18,alt:"Select dropdown icon"}),loading:!d,children:null===u||void 0===u?void 0:u.map((function(e){return Object(y.jsx)(Xc.Select.Option,{value:e.id,children:e.name},e.id)}))})]}),Object(y.jsx)("h3",{className:"text-base font-semibold block mb-4",children:"Address"}),Object(y.jsx)("div",{className:"relative py-6 grid gap-4 -mr-4 grid-cols-4",children:Object(y.jsx)(OE,{})}),Object(y.jsx)("h3",{className:"text-base font-semibold block mb-4",children:"License Info"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5 w-full mr-8",children:[Object(y.jsx)("label",{htmlFor:"applicatorLicense",className:"text-neutral-60 tracking-tighter text-sm",children:"Applicator License"}),Object(y.jsx)(Xc.Input,{type:"default",size:"middle",name:"applicatorLicenseNumber",id:"applicatorLicenseNumber",value:t.applicatorLicenseNumber,onChange:n})]}),Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5 w-full",children:[Object(y.jsx)("label",{htmlFor:"applicatorLicenseExpirationDate",className:"text-neutral-60 tracking-tighter text-sm",children:"Valid Through"}),Object(y.jsx)(Qi,{name:"applicatorLicenseExpirationDate",control:m.DatePicker,dateFormat:"M j, Y",placeholder:" ",value:t.applicatorLicenseExpirationDate,onChange:n})]})]}),Object(y.jsx)("div",{className:"my-8 relative",children:Object(y.jsx)(Qi,{value:t.notes,label:"Notes",control:m.TextArea,id:"notes",name:"notes",className:"h-32 overscroll-auto",onChange:n})})]})},xE=function(){var e=Object(Zi.h)(),t=e.handleChange,n=e.values,a=e.errors;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-8 w-1/2 pr-4",children:[Object(y.jsxs)("label",{htmlFor:"owner-name",className:"text-neutral-60 tracking-tighter text-sm",children:["Name",Object(y.jsx)("span",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Xc.Input,{required:!0,name:"name",id:"owner-name",type:"default",size:"middle",value:n.name,onChange:t,status:(null===a||void 0===a?void 0:a.name)&&"error",caption:null===a||void 0===a?void 0:a.name})]}),Object(y.jsx)("h3",{className:"text-base font-semibold block mb-4",children:"Basic Info"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5 w-full mr-8",children:[Object(y.jsx)("label",{htmlFor:"legalName",className:"text-neutral-60 tracking-tighter text-sm",children:"Legal Name"}),Object(y.jsx)(Xc.Input,{type:"default",size:"middle",name:"legalName",id:"legalName",value:n.legalName})]}),Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5 w-full",children:[Object(y.jsx)("label",{htmlFor:"email",className:"text-neutral-60 tracking-tighter text-sm",children:"Email Address"}),Object(y.jsx)(Xc.Input,{type:"default",size:"middle",name:"email",id:"email",value:n.email,status:(null===a||void 0===a?void 0:a.email)&&"error",caption:null===a||void 0===a?void 0:a.email})]})]}),Object(y.jsx)("div",{className:"flex flex-col gap-1 mb-5 w-1/2 pr-4",children:Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5 w-full",children:[Object(y.jsx)("label",{htmlFor:"phone",className:"text-neutral-60 tracking-tighter text-sm",children:"Phone Number"}),Object(y.jsx)(Xc.Input,{type:"default",size:"middle",name:"phone",id:"phone",value:n.phone})]})}),Object(y.jsx)("h3",{className:"text-base font-semibold block mb-4",children:"Address"}),Object(y.jsx)("div",{className:"relative py-6 grid gap-4 -mr-4 grid-cols-4",children:Object(y.jsx)(OE,{})}),Object(y.jsx)("div",{className:"my-8 relative",children:Object(y.jsx)(Qi,{value:n.notes,label:"Notes",control:m.TextArea,id:"notes",name:"notes",className:"h-32 overscroll-auto"})})]})},gE=(n(1548),Fu.e().shape({name:Fu.f().required("name is required")})),CE=function(e){var t=e.open,n=e.onClose,r=e.onCompanyPeopleAdded,c=e.title,i=Object(a.useState)(!1),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)("Company"),u=Object(b.a)(d,2),j=u[0],p=u[1],f=uE(),m=f.createPerson,v=f.isCreatingPerson,O=dE(),h=O.createCompany,x=O.isCreatingCompany,g=function(e){var t=e.isValid,n=e.dirty;return!t||!n||v||x};return Object(y.jsx)(Zi.e,{initialValues:{},onSubmit:function(e,t){var a=t.resetForm;if("People"===j){var c={name:e.name,email:e.email,phone:e.phone,companyId:e.company,address:{line1:e.addressLineOne,line2:e.addressLineTwo,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country},applicatorLicenseNumber:e.applicatorLicenseNumber,applicatorLicenseNumberExpirationDate:e.applicationLicenseExperiationDate,notes:e.notes};m(c).then((function(t){var c=t.id,i=t.name;c&&i&&(r({type:"People",id:c,name:i,licenseNumber:e.applicatorLicenseNumber}),a(),n())}))}else{var i={name:e.name,email:e.email,legalName:e.legalName,phone:e.phone,address:{line1:e.addressLineOne,line2:e.addressLineTwo,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country},notes:e.notes};h(i).then((function(e){var t=e.id,c=e.name;t&&c&&(r({type:"Company",id:t,name:c}),a(),n())}))}},validationSchema:gE,children:function(e){var a=e.isValid,r=e.dirty,i=e.submitForm,o=e.resetForm;return Object(y.jsxs)(Xc.Drawer,{maskClosable:!0,open:t,className:"cwf-add-company-people-drawer",placement:"right",closable:!1,onClose:function(){o(),n()},bodyStyle:{padding:0},footer:Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsx)(Xc.Button,{type:"outline",onClick:function(){o(),n()},children:"Cancel"}),Object(y.jsx)(Xc.Button,{disabled:g({isValid:a,dirty:r}),className:"company-people-add-save-button",type:"primary",onClick:i,children:"Save"})]}),width:"50%",children:[Object(y.jsx)("div",{className:"relative",children:Object(y.jsx)("div",{className:"absolute top-0 right-0 m-3",children:Object(y.jsx)("button",{type:"button",onClick:function(){o(),n()},children:Object(y.jsx)("img",{src:kS,alt:"Close icon",width:20,height:20})})})}),Object(y.jsxs)("div",{className:"px-8 py-6",children:[Object(y.jsxs)("div",{className:"flex gap-4 items-center mb-6","data-testid":"company-people-container",children:[Object(y.jsx)("h1",{className:"text-xl font-semibold block mb-0",children:c}),Object(y.jsxs)(Xc.Select,{className:"w-140px",onChange:p,value:j,onDropdownVisibleChange:function(e){return l(e)},suffixIcon:Object(y.jsx)("img",{src:Di,style:{transform:s?"rotate(180deg)":null},height:18,width:18,alt:"Select dropdown icon"}),children:[Object(y.jsx)(Xc.Select.Option,{value:"People",children:Object(y.jsxs)("div",{className:"flex items-center gap-2",children:[Object(y.jsx)("img",{src:vE,alt:"Person icon",className:"h-15px"})," ","Person"]})}),Object(y.jsx)(Xc.Select.Option,{value:"Company",children:Object(y.jsxs)("div",{className:"flex items-center gap-2",children:[Object(y.jsx)("img",{src:mE,alt:"Company icon"})," Company"]})})]})]}),v||x?Object(y.jsx)("div",{className:"flex items-center justify-center h-100",children:Object(y.jsx)(Xc.Spin,{})}):Object(y.jsx)("div",{className:"mb-8",children:"People"===j?Object(y.jsx)(hE,{}):Object(y.jsx)(xE,{})})]})]})}})};CE.defaultProps={title:"Create New Owner"};var yE=CE,PE=function(e){var t=e.item,n=t.value,a=t.key,r=t.label,c=t.type;if(!n)return"empty"===r?Object(y.jsx)("div",{className:"px-2 ml-2 text-neutral-60","data-testid":"item-empty-value",children:"No ".concat("People"===c?"people":"companies"," found")},a):Object(y.jsx)("div",{className:"text-neutral-60 p-2 ml-2","data-testid":"item-without-value",children:r},a);var i=n.type;return Object(y.jsxs)("div",{className:"w-full h-full px-2 py-1 ml-2 flex items-center","data-testid":"item-with-value",children:[Object(y.jsx)("span",{children:"People"===i?Object(y.jsx)(jE,{size:16}):Object(y.jsx)(fE,{size:16})}),Object(y.jsx)("div",{className:"pl-2",children:n.name})]},a)},AE=function(e){var t=e.bottomButtonText,n=e.onChange,r=e.value,c=e.id,i=e.title,o=Object(a.useState)([]),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(!1),j=Object(b.a)(u,2),p=j[0],f=j[1],m=dE(),v=m.companies,O=m.loading,h=m.loadCompanies,x=uE(),g=x.people,C=x.loading,P=x.loadPeople,A=Object(a.useCallback)((function(){return null!==r&&void 0!==r&&r.type?Object(y.jsxs)("div",{className:"w-full h-full p-2 flex items-center","data-testid":"selected-company-people",children:[Object(y.jsx)("span",{children:"People"===(null===r||void 0===r?void 0:r.type)?Object(y.jsx)(jE,{size:16}):Object(y.jsx)(fE,{size:16})}),Object(y.jsx)("div",{className:"pl-2",children:r.name})]}):null}),[r]);return Object(a.useEffect)((function(){return O||C||d([{key:"company-label",label:"COMPANIES",type:"Company",items:v.length>0?v.map((function(e){return{key:e.id,label:e.name,value:Object(I.a)(Object(I.a)({},e),{},{type:"Company"})}})):[{key:"empty-companies",label:"empty",type:"Company"}]},{key:"people-label",label:"PEOPLE",type:"People",items:g.length>0?g.map((function(e){return{key:e.id,label:e.name,value:Object(I.a)(Object(I.a)({},e),{},{type:"People"})}})):[{key:"empty-people",label:"empty",type:"People"}]}]),function(){d([])}}),[g,v,O,C]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(DP,{rightOffset:0,heightClass:"h-64",valueRenderer:A,value:r,bottomButtonText:t,onBottomButtonClick:function(){f(!0)},onChange:n,id:c,items:l,ItemComponent:PE}),Object(y.jsx)(yE,{onClose:function(){return f(!1)},onCompanyPeopleAdded:function(e){n(e),h(),P()},open:p,title:i})]})};AE.defaultProps={value:null,id:"",bottomButtonText:"",title:"Create New Owner"};var SE=AE,TE=function(e){var t=e.item,n=t.value,a=t.key,r=t.label,c=t.checked;return n?Object(y.jsx)("div",{className:"w-full flex items-center m-2 pl-4 text-xs","data-testid":"item-with-value",children:Object(y.jsx)(m.Radio,{ariaLabel:r,id:"".concat(r,"-yes"),name:r,checked:c,value:r,label:r})},a):Object(y.jsx)("div",{className:"text-neutral-60 pl-2","data-testid":"item-without-value",children:r},r)},NE=function(e){var t=e.onChange,n=e.value,r=e.id,c=Object(Zi.h)(),i=c.errors,o=c.touched,s=Object(a.useMemo)((function(){return $N.reduce((function(e,t){return e.concat([{key:t.name,label:t.name,items:t.codes.map((function(e){return{key:t.name+e,value:e,label:e}}))}])}),[])}),[]);return Object(y.jsx)(DP,{valueRenderer:function(){return n?Object(y.jsx)("div",{className:"w-full h-full flex items-center ml-2",children:Object(y.jsx)("div",{children:n})}):null},value:n,onChange:t,id:r,heightClass:"h-330px",isInvalid:void 0!==(null===i||void 0===i?void 0:i.fumigationCode)&&void 0!==(null===o||void 0===o?void 0:o.fumigationCode),items:s,ItemComponent:TE,onFilter:function(e,t){return!e.value||e.value.includes(t)}})};NE.defaultProps={value:void 0,id:""};var EE=NE,wE=function(e){var t=e.propertyDetails,n=e.task,r=e.isReadOnly,c=lx(),i=c.events,o=c.triggerAnalyticsEvent,s=Object(Zi.h)(),l=s.values,d=s.setFieldValue,u=ox().redirectToTask,b=Object(a.useContext)(SC),j=b.setOpenRemoveTaskModal,p=b.state,f=p.integrationType,O=p.submissionId,h=Object(a.useContext)(vh).state.selectedProperties,x=function(e,t){d(e,t)};return Object(y.jsxs)("div",{className:"flex flex-col w-full p-4",children:[Object(y.jsxs)("div",{className:"flex flex-row w-full justify-start",children:[Object(y.jsxs)("div",{className:"w-1/2 mr-8",children:[Object(y.jsx)("div",{className:"text-sm leading-7 font-bold text-neutral-1000 mb-2",children:"Applicator Details"}),r?Object(y.jsxs)(y.Fragment,{children:[!(null!==l&&void 0!==l&&l.applicator)&&Object(y.jsx)(oE,{label:"Applicator",value:"Not informed yet"}),(null===l||void 0===l?void 0:l.applicator)&&Object(y.jsx)(oE,{label:"Applicator",value:1===(null===l||void 0===l?void 0:l.applicator)?"Grower Applied":"PCO Applied"}),2===(null===l||void 0===l?void 0:l.applicator)&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(oE,{label:"PCO",value:null===l||void 0===l?void 0:l.applicatorName}),Object(y.jsx)(oE,{label:"Applicator Type",value:null===l||void 0===l?void 0:l.applicatorLicenseType}),Object(y.jsx)(oE,{label:"Applicator Number",value:null===l||void 0===l?void 0:l.applicatorLicenseNumber})]})]}):Object(y.jsxs)("div",{className:"grid grid-cols-2 gap-x-2",children:[Object(y.jsx)(MN,{halfWidth:!0,children:Object(y.jsx)(Qi,{label:"Applicator",control:m.Select,id:"applicatorType",name:"applicatorType",items:eE})}),"pco"===(null===l||void 0===l?void 0:l.applicatorType)&&Object(y.jsxs)("div",{className:"grid grid-cols-2 border-t-1 mt-4 gap-x-2 col-span-2",children:[Object(y.jsx)(MN,{label:"PCO",halfWidth:!0,children:Object(y.jsx)(SE,{id:"pco-select",value:l.pco,onChange:function(e){!function(e){d("pco",e),"People"===e.type&&e.licenseNumber?d("pcoNumber",e.licenseNumber):d("pcoNumber","")}(e)},bottomButtonText:"Create New PCO",title:"Create a PCO"})}),Object(y.jsx)("div",{className:"grid grid-cols-2 col-span-2",children:Object(y.jsx)(MN,{halfWidth:!0,children:Object(y.jsx)(Qi,{label:"Applicator Type",control:m.Select,id:"pcoType",name:"pcoType",items:tE})})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Qi,{label:"Applicator Number",control:m.Input,type:"text",id:"pcoNumber",name:"pcoNumber",onChange:function(e){return x("pcoNumber",e.target.value)}})})]})]})]}),Object(y.jsxs)("div",{className:"w-1/2 capitalize",children:[Object(y.jsx)("div",{className:"text-sm leading-7 font-bold text-neutral-1000 mb-2",children:"[".concat(t.fieldName,"] / [").concat(t.cropZoneName,"]")}),Object(y.jsx)(oE,{label:"State",value:t.state}),Object(y.jsx)(oE,{label:"County",value:t.county}),Object(y.jsx)(oE,{label:"Section",value:t.section}),Object(y.jsx)(oE,{label:"Township",value:"".concat(t.townshipNumber,"\n").concat(t.townshipDirection)}),Object(y.jsx)(oE,{label:"Range",value:"".concat(t.rangeNumber,"\n").concat(t.rangeDirection)}),Object(y.jsx)(oE,{label:"Permit ID",value:t.permitId}),Object(y.jsx)(oE,{label:"Site ID",value:t.siteId})]})]}),Object(y.jsxs)("div",{className:"flex flex-row w-full justify-start mt-8",children:[Object(y.jsxs)("div",{className:"w-1/4 mr-8",children:[Object(y.jsx)("div",{className:"text-sm leading-7 font-bold text-neutral-1000 mb-2",children:"Application Method"}),Object(y.jsx)(oE,{widthValue:"w-full",value:sC(n.products)})]}),Object(y.jsxs)("div",{className:"w-1/4 mr-8",children:[Object(y.jsx)("div",{className:"text-sm leading-7 font-bold text-neutral-1000 mb-2",children:"Application Date"}),Object(y.jsx)(oE,{widthValue:"w-full",value:hA(n.dueDate)})]}),"Fumigation"===sC(n.products)&&Object(y.jsxs)("div",{className:"w-1/2 grid grid-cols-2 gap-x-2",children:[Object(y.jsx)("div",{className:"text-sm leading-7 font-bold text-neutral-1000 col-span-2",children:"Fumigation Code"}),r?Object(y.jsx)(oE,{value:null===l||void 0===l?void 0:l.fumigationCode}):Object(y.jsx)(MN,{halfWidth:!0,noLabelMarginTop:"mt-3",children:Object(y.jsx)(EE,{id:"fumigation-select",value:l.fumigationCode,onChange:function(e){return function(e){x("fumigationCode",e)}(e)}})}),Object(y.jsx)(MN,{halfWidth:!0,noLabelMarginTop:"mt-3",children:Object(y.jsx)("a",{href:"https://www.cdpr.ca.gov/docs/emon/vocs/vocproj/ffm_code-table.pdf",type:"button",target:"_blank",rel:"noopener noreferrer",children:Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)("div",{className:"block px-4 font-normal text-center w-36 text-green-700",children:"Fumigation Code List"}),Object(y.jsx)(XC,{fill:"#0C612C"})]})})})]})]}),Object(y.jsx)("div",{className:"w-full mt-8",children:Object(y.jsxs)("div",{children:[Object(y.jsxs)("div",{className:"flex flex-row justify-between",children:[Object(y.jsx)("div",{className:"text-sm leading-7 font-bold text-neutral-1000 mb-2",children:"Applied Products"}),!r&&Object(y.jsx)("div",{className:"w-fit",children:Object(y.jsxs)(Xc.Button,{type:"outline",className:"w-full flex flex-row text-xs",onClick:function(){return function(){o(i.epic.Integrations.submissionTaskClick,{vendor:f});var e=Object(v.a)(new Set(h.flatMap((function(e){return e.properties})).flatMap((function(e){return e.cropSeasons})).map((function(e){return e.id})))),t={taskId:n.taskId,cropSeasonsIds:e};u(t,O,f)}()},"data-testid":"edit-task-from-product-button",children:[Object(y.jsx)("div",{className:"text-right",children:Object(y.jsx)(mg,{})}),Object(y.jsx)("span",{className:"ml-1",children:"Edit"})]})})]}),Object(y.jsx)("div",{className:"mt-2",children:Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{children:"Cropwise Product"}),Object(y.jsx)(m.Table.Cell,{children:"Rate (per area)"}),Object(y.jsx)(m.Table.Cell,{children:"Total applied"}),Object(y.jsx)(m.Table.Cell,{children:"CDPR Registration #"})]}),n.products.map((function(e){return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"text-left",children:[Object(y.jsx)("div",{className:"font-bold",children:e.productName}),Object(y.jsx)("div",{className:"mt-2 text-neutral-300",children:e.manufacturerName})]})}),Object(y.jsx)(m.Table.Cell,{children:"".concat(Number(null===e||void 0===e?void 0:e.ratePerArea).toFixed(2)," ").concat(null===e||void 0===e?void 0:e.ratePerAreaUnit)}),Object(y.jsx)(m.Table.Cell,{children:"".concat(Number(null===e||void 0===e?void 0:e.quantity).toFixed(2)," ").concat(null===e||void 0===e?void 0:e.quantityUnit)}),Object(y.jsx)(m.Table.Cell,{children:rC(e.overrideRegistrationNumber)})]},e.trackingId)}))]})})]})}),!r&&Object(y.jsx)("div",{className:"w-full mt-8 flex justify-end",children:Object(y.jsxs)(Xc.Button,{type:"outline",onClick:function(){j(!0,n)},style:{borderColor:"#c53030"},"data-testid":"remove-task-button",children:[Object(y.jsx)(lE,{color:"red-700"}),Object(y.jsx)("span",{className:"text-red-700 ml-2",children:"Remove From Submission"})]})})]})};wE.defaultProps={isReadOnly:!1};var _E=wE,RE=function(e){var t,n=e.form,a=e.toggleCallback,r=e.selectedId,c=e.isReadOnly,i=e.pastSubmissions,o=n.formId,s=n.task,l=n.propertyDetails,d=n.status,u=n.errorMessage,b=s.name,j=s.products,p=l.cropZoneName,f=i.find((function(e){return e.cropZoneId===s.cropZoneId&&e.taskId===s.taskId}));return Object(y.jsx)(dA,{header:Object(y.jsx)(SN,{firstLabel:"[".concat(p,"] [").concat(b,"]"),secondLabel:(t=j,"[".concat(t.map((function(e){return e.productName})).join("], ["),"]")),status:d,isTagVisible:!c||d===rh||d===ah,pastSubmission:f}),content:l&&s?Object(y.jsxs)(y.Fragment,{children:[d===rh&&Object(y.jsx)(ly,{submissionResult:{status:rh,errorMessage:u}}),Object(y.jsx)(_E,{propertyDetails:l,task:s,isReadOnly:c})]}):void 0,isFullWidthButton:!0,toggleCallback:a,dynamicToggle:!0,canExpand:o===r,isProperty:!1,headerHeight:"40px"})};RE.defaultProps={toggleCallback:function(){},selectedId:"",isReadOnly:!1,pastSubmissions:[]};var IE=Object(a.memo)(RE),DE=function(e){switch(iC(e[0])){case"F":return"Fumigation";case"G":return"Ground";case"A":return"Aerial";default:return e[0]}},kE=function(e,t){return{purExtraData:{forms:e.map((function(e){var t=DE(e.applicationMethods.split(", "));return Object(I.a)(Object(I.a)({taskId:e.task.taskId,cropZoneId:e.task.cropZoneId,applicationMethod:t,applicator:"pco"===e.applicatorType?2:1},"pco"===e.applicatorType?{applicatorLicenseNumber:e.pcoNumber,applicatorLicenseType:e.pcoType,applicatorName:e.pco.name,applicatorType:e.pco.type,applicatorId:e.pco.id}:{}),"Fumigation"===t?{fumigationCode:e.fumigationCode}:{})})),counties:t}}},LE=(n(1549),function(e){var t=e.forms,n=e.counties,r=Object(a.useContext)(SC).state.fields,c=Object(v.a)(new Set(t.flatMap((function(e){return e.task.products.flatMap((function(e){return e.productName}))}))));return Object(y.jsxs)("div",{children:[Object(y.jsx)(Xc.Alert,{className:"calag-submission-details-load-alerts",message:"You will be unable to change this information once submitted, verify it is correct before you submit.",showIcon:!0,type:"warning"}),Object(y.jsxs)("div",{className:"mt-10 flex flex-col w-full",children:[Object(y.jsx)("span",{className:"mb-4 font-bold",children:"Submission Details"}),Object(y.jsx)(oE,{label:"Total Pesticide Usage Reports",value:"".concat(t.length)}),Object(y.jsx)(oE,{label:"Total Fields in Submission",value:"".concat(r.length)}),Object(y.jsx)(oE,{label:"Counties in Submission",value:n.map((function(e){return e.name}))}),Object(y.jsx)(oE,{label:"Products in Submission",value:c})]})]})}),FE=function(e){var t=e.counties,n=e.setCounties,a=e.isLoading,r=function(e,t,a){n((function(n){var r=n;return r[a][e]=t,Object(v.a)(r)}))},c={paddingLeft:"10px",maxWidth:"300px",borderColor:"#e2e8f0"};return Object(y.jsxs)("div",{className:"mt-8 flex flex-col w-full",children:[Object(y.jsx)("span",{className:"mb-4",children:"Please provide username and password for each county included in your submission."}),a?Object(y.jsxs)("div",{className:"mt-20",children:[Object(y.jsx)(m.Spinner,{className:"mb-4"}),Object(y.jsx)("div",{className:"mt-4 text-center",children:Object(y.jsx)("span",{className:"font-bold",children:"Submitting your data"})})]}):t.map((function(e,t){return Object(y.jsxs)("div",{className:"mt-2",children:[Object(y.jsxs)("span",{className:"font-bold",children:[e.name," login"]}),Object(y.jsx)(m.Form.Field,{label:"Username *",children:Object(y.jsx)(m.Input,{name:"countyUsername",type:"text",required:!0,value:e.username,style:c,onChange:function(e){r("username",e.target.value,t)}})}),Object(y.jsx)(m.Form.Field,{label:"Password *",children:Object(y.jsx)(m.Input,{name:"countyPassword",type:"password",required:!0,value:e.password,style:c,onChange:function(e){r("password",e.target.value,t)}})})]},e.name)}))]})},ME=function(e){var t=e.forms,n=lx(),r=n.events,c=n.triggerAnalyticsEvent,i=Object(a.useContext)(SC),o=i.state.openDrawerCounties,s=i.submitIntegrationWithExtraData,l=i.setOpenDrawerCounties,d=Object(a.useState)([]),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(!1),m=Object(b.a)(f,2),O=m[0],h=m[1];Object(a.useEffect)((function(){t.length&&!j.length&&p(Object(v.a)(new Set(t.filter((function(e){return e.propertyDetails})).map((function(e){return e.propertyDetails.county})))).map((function(e){return{name:e,username:"",password:""}})))}),[t]);var x=Object(a.useState)(1),g=Object(b.a)(x,2),C=g[0],P=g[1],A=function(){l(!1)},S=Object(a.useMemo)((function(){return j.every((function(e){return!!e.username&&!!e.password}))}),[j]),T=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1!==C){e.next=4;break}return c(r.epic.Integrations.submissionRegulatoryDataReview,{vendor:$O}),P(2),e.abrupt("return");case 4:return h(!0),c(r.epic.Integrations.submissionCredentialsFilled,{vendor:$O}),c(r.epic.Integrations.submissionRunning,{vendor:$O}),e.next=9,s(kE(t,j));case 9:h(!1);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),N=!t.length||1!==C&&!S||O;return Object(y.jsxs)(Xc.Drawer,{maskClosable:!0,open:o,className:"cwf-submit-counties-drawer",placement:"right",closable:!1,onClose:function(){A()},bodyStyle:{padding:0},footer:Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsx)(Xc.Button,{type:"outline",onClick:function(){A()},children:"Cancel"}),Object(y.jsx)(Xc.Button,{disabled:N,className:"owner-add-save-button",type:"primary",onClick:T,children:1===C?"Next":"Complete Submission"})]}),width:"35%",children:[Object(y.jsx)("div",{className:"relative",children:Object(y.jsx)("div",{className:"absolute top-0 right-0 m-3",children:Object(y.jsx)("button",{type:"button",onClick:function(){A()},children:Object(y.jsx)("img",{src:kS,alt:"Close icon",width:20,height:20})})})}),Object(y.jsxs)("div",{className:"px-10 py-10",children:[Object(y.jsx)("div",{className:"flex gap-4 items-center mb-6","data-testid":"owner-container",children:Object(y.jsx)("h1",{className:"text-xl font-semibold block mb-0",children:"Submit your pesticide usage reports"})}),1===C&&Object(y.jsx)(LE,{forms:t,counties:j}),2===C&&Object(y.jsx)(FE,{counties:j,setCounties:p,isLoading:O})]})]})},VE=function(e){var t=e.isLoading,n=e.missingInfoAmount;return t?null:Object(y.jsx)("div",{className:"flex h-full items-center",children:Object(y.jsx)("span",{className:"ml-4 p-3 text-base ".concat(0!==n?" text-yellow-700 bg-yellow-200":" text-green-700 bg-green-200"," rounded-lg whitespace-no-wrap h-fit flex fle-row"),children:0!==n?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("strong",{"data-testid":"need-info-fields",className:"mr-1",children:n})," ","Forms Need Info"]}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"mr-3 w-fit h-fit p-1 rounded-full bg-green-600",children:Object(y.jsx)(m.Icon,{size:12,icon:"checkmark",color:"#FFFFFF"})}),Object(y.jsx)("div",{children:"Forms Complete"})]})})})},BE=function(e){var t=e.FooterComponent,n=e.loading,r=lx(),c=r.events,i=r.triggerAnalyticsEvent,o=Object(a.useContext)(SC),s=o.state,l=s.tasks,d=s.fields,u=s.extraData,j=s.isReadOnly,p=s.submissionResult,f=s.openDrawerCounties,O=s.pastSubmissions,h=o.isLoading,x=o.setOpenDrawerCounties,g=Object(Zi.h)(),C=g.values,P=g.setValues,A=Object(a.useState)(""),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)([]),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)(0),k=Object(b.a)(D,2),L=k[0],F=k[1],M=function(e){var t=new Map(Object.entries(e));if(!["task","propertyDetails","formId","applicatorType"].every((function(e){return t.get(e)})))return!1;if("pco"===e.applicatorType){if(!["pco","pcoType","pcoNumber"].every((function(e){return t.get(e)})))return!1}if("Fumigation"===e.task.products[0].applicationMethod){if(!["fumigationCode"].every((function(e){return t.get(e)})))return!1}return!0};Object(a.useEffect)((function(){F(_.filter((function(e){return"need_info"===e.status})).length)}),[_]);var V=Object(a.useCallback)((function(e,t){if(!u)return e;var n=Object(I.a)({},e),a=u.purExtraData.forms.find((function(e){return t==="form-task-".concat(e.taskId,"-").concat(e.cropZoneId,"-").concat(e.applicationMethod)}));return a&&(n=Object(I.a)(Object(I.a)(Object(I.a)({},n),a),{},{applicatorType:1===a.applicator?"grower":"pco",pco:{id:a.applicatorId,name:a.applicatorName,type:a.applicatorType},pcoType:a.applicatorLicenseType,pcoNumber:a.applicatorLicenseNumber})),j||(n.status=M(n)?"complete":"need_info"),n}),[u,j]);Object(a.useEffect)((function(){var e;l&&l.length>0&&d&&d.length>0&&R((e=l,e.reduce((function(e,t){var n;if(!t.products||1===(null===(n=t.products)||void 0===n?void 0:n.length))return e.concat([t]);var a=oC(t,"F"),r=oC(t,"A"),c=oC(t,"G"),i=oC(t,"O");return e.concat([a,r,c,i].filter((function(e){return null!=e})))}),[])).map((function(e){return function(e){if(null!==e&&void 0!==e&&e.taskId){var t,n=sC(e.products),a=DE(n.split(", ")),r="form-task-".concat(e.taskId,"-").concat(e.cropZoneId,"-").concat(a);_&&(t=_.find((function(e){return e.formId===r}))),t=V(t,r);var c,i,o="need_info";if(j&&null!==(null===p||void 0===p?void 0:p.response)){var s,l,u=null===p||void 0===p||null===(s=p.response)||void 0===s||null===(l=s.details)||void 0===l?void 0:l.find((function(t){var n,r,c;return(null===(n=t.vendorPayload)||void 0===n?void 0:n.cwfTaskId)===e.taskId&&(null===(r=t.vendorPayload)||void 0===r?void 0:r.cwfCropZoneId)===e.cropZoneId&&(null===(c=t.vendorPayload)||void 0===c?void 0:c.applicationMethod)===iC(a)}));o=null===u||void 0===u?void 0:u.status,c=null===u||void 0===u?void 0:u.errorMessage,i=null===u||void 0===u?void 0:u.applicatorType}var b=Object(I.a)({formId:r,task:e,applicationMethods:n,propertyDetails:d.find((function(t){return t.cropZoneId===e.cropZoneId})),applicatorType:i||"grower"},t);return o===rh||o===ah?Object(I.a)(Object(I.a)({},b),{},{status:o,errorMessage:c}):Object(I.a)(Object(I.a)({},b),{},{status:M(b)?"complete":"need_info"})}return{}}(e)})))}),[l,d]);Object(a.useEffect)((function(){""!==T&&function(e){var t=Object(v.a)(_).map((function(t){if(t.status===rh)return t;if(e===t.formId){var n=C.applicatorType,a=C.pco,r=C.pcoType,c=C.pcoNumber,i=C.fumigationCode,o=Object(I.a)(Object(I.a)({},t),{},{applicatorType:n,pco:a,pcoType:r,pcoNumber:c,fumigationCode:i});return Object(I.a)(Object(I.a)({},o),!j&&{status:!j&&M(o)?"complete":"need_info"})}return t}));R(t)}(T)}),[C]);var B=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i(c.epic.Integrations.submissionApplicatorDetailsFilled,{vendor:$O}),x(!0);case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex flex-col bg-white top-30 left-26 w-full rounded-md mb-20 px-6 py-4 shadow-sm","data-testid":"submission-crop-season-selection",children:[Object(y.jsx)(uy,{integrationType:$O,submissionResult:p,subtitle:"Review details and enter any missing information.",RightComponent:function(){return Object(y.jsx)(VE,{isLoading:h,missingInfoAmount:L})}}),f||!h&&!n?Object(y.jsx)(y.Fragment,{children:_.map((function(e){return Object(y.jsx)(IE,{form:e,toggleCallback:function(){return function(e){T===e.formId?(P(Object(I.a)(Object(I.a)({},C),{},{applicatorType:"",pco:{},pcoType:"",pcoNumber:"",fumigationCode:""})),N("")):(P(Object(I.a)(Object(I.a)({},C),{},{pco:"",pcoType:"",pcoNumber:"",fumigationCode:""},e)),N(e.formId))}(e)},selectedId:T,isReadOnly:j,pastSubmissions:O},e.formId)}))}):Object(y.jsx)(m.Spinner,{}),!j&&t&&Object(y.jsx)(t,{onNext:B,nextLabel:"Submit",nextDisabled:0!==L})]}),Object(y.jsx)(rE,{onRemove:function(){N("")}}),Object(y.jsx)(ME,{forms:_})]})};BE.defaultProps={FooterComponent:null,loading:!1};var UE=BE,zE={1:Object(y.jsx)(UC,{context:$O,FooterComponent:px}),2:Object(y.jsx)(PN,{}),3:Object(y.jsx)(nE,{}),4:Object(y.jsx)(YN,{}),5:Object(y.jsx)(ay,{FooterComponent:px,ReviewComponent:UE,needFields:!0,needSolveMatch:!1})},ZE=function(e){var t=e.fixedStep,n=Object(a.useContext)($h).state.step;return zE[null!==t&&void 0!==t?t:n]};ZE.propTypes={fixedStep:Ec.PropTypes.number};var YE=ZE,HE=[{caption:"Select Crop Seasons"},{caption:"Select Properties"},{caption:"Select Products"},{caption:"Enter Field Details"},{caption:"Review and Submit"}],GE=function(){return Object(y.jsx)(FC,{integrationType:$O,progressBarSteps:HE,selectPropertiesStep:2,StepSelector:YE})},WE=function(){var e=Object(p.j)().id;return Object(y.jsx)(hh,{children:Object(y.jsx)(tx,{children:Object(y.jsx)(Zi.e,{initialValues:{},children:function(){return Object(y.jsx)(NC,{integrationType:$O,submissionId:e,children:Object(y.jsx)(GE,{})})}})})})},qE=[{number:1,header:"Sign In",description:"Authenticate with your vendor credentials"},{number:2,header:"Select Organization",description:"Select an organization to pull available Recommendations"},{number:3,header:"Select Records",description:"Select the Agrian crop year and corresponding crop season, then choose the records to import"},{number:4,header:"Match Properties",description:"Match your Agrian field with the corresponding crop zones"},{number:5,header:"Match Products",description:"Match the products used in your recommendation with those in the Cropwise product list"},{number:6,header:"Review and Submit",description:"Review your matches and data, then import the records to Cropwise Financials"}],JE=function(){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(pN,{LogoImg:NO,buttonText:"Import my Agrian Recommendations",headerText:"Agrian Recommendation Integration",breadcrumbText:"Agrian Recommendation",ownerText:QO,targetPath:XO}),Object(y.jsx)("div",{className:"w-full border-t-1 mb-5"}),Object(y.jsx)(ON,{steps:qE})]})},KE=function(e){var t=e.isLoading,n=e.unmatchedEntities,a=e.title,r=e.description;return Object(y.jsxs)("div",{"data-testid":"top-header",children:[Object(y.jsx)("div",{className:"w-full flex h-10 mb-2 items-center font-semibold",children:Object(y.jsx)("p",{className:"text-xl",children:a})}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsxs)("div",{className:"grid grid-cols-10",children:[Object(y.jsx)("div",{className:"col-span-8 justify-self-start",children:Object(y.jsx)("p",{className:"font-normal text-sm ",children:r})}),t?Object(y.jsx)("div",{className:"col-span-2 justify-self-end",children:Object(y.jsx)(m.Spinner,{size:"sm"})}):Object(y.jsx)("div",{className:"col-span-2 justify-self-end",children:0===n?Object(y.jsx)("div",{"data-testid":"all-matched",children:Object(y.jsxs)(m.Tag,{color:"#DFFBE8",children:[Object(y.jsx)(gh.a,{style:{marginLeft:"7px",fontSize:16,color:"#DFFBE8",backgroundColor:"#0C612C",borderRadius:"50%"}}),Object(y.jsx)("span",{className:"text-base mr-2 ml-2 font-thin text-green-900",children:"All Matched"})]},"unmatched-properties-length")}):Object(y.jsx)("div",{"data-testid":"unmatched-properties",children:Object(y.jsx)(m.Tag,{color:"#FFE4AE",children:Object(y.jsxs)("div",{className:"text-base mr-2 ml-2 text-yellow-700",children:[Object(y.jsx)("span",{className:"font-bold","data-testid":"unmatched-properties-count",children:Math.max(n,0)}),Object(y.jsx)("span",{className:"font-thin",children:" Unmatched"})]})},"unmatched-properties-length")})})]})})]})};KE.defaultProps={isLoading:!1};var QE=KE,XE=function(e){var t=e.property,n=e.matched;return t.hide?Object(y.jsx)(m.Tag,{color:"#F3F4F6",children:Object(y.jsx)("span",{className:" justify-self-center w-full text-xs mr-5 text-neutral-60 ml-2",children:"Hidden"})}):n?Object(y.jsx)(m.Tag,{color:"#C3EAD1",children:Object(y.jsx)("span",{className:" justify-self-center w-full text-xs mr-5 text-green-900 ml-2",children:"Matched"})}):Object(y.jsx)(m.Tag,{color:"#FFE4AE",children:Object(y.jsx)("span",{className:"justify-self-center w-full text-xs mr-5 text-yellow-700",children:"Unmatched"})})};XE.defaultProps={matched:void 0,property:{}};var $E=XE,ew=function(e,t,n){return n.find((function(n){return e.some((function(e){return e.id===n.cwfId}))&&n.vendorId===t.id}))},tw=function(e){return e?e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase():e},nw=(n(1550),function(e){var t=e.property,n=e.fftSelectGroups,r=e.matched,c=Object(a.useContext)(Xg).addPropertyMatchIdWithVendorIdInControl;return Object(y.jsx)("div",{className:"justify-self-start pr-15 col-span-w w-full",children:Object(y.jsxs)("div",{className:"grid items-center grid-cols-3",children:[Object(y.jsx)("div",{className:"text-sm col-span-1",style:{position:"relative"},children:Object(y.jsx)("div",{className:"mt-2 bg-gray-100 rounded-lg overflow-hidden text-left p-4",children:Object(y.jsx)(pP,{vendorId:null===t||void 0===t?void 0:t.id})})}),Object(y.jsx)("div",{className:"flex items-center justify-center h-full col-span-1",children:Object(y.jsx)("span",{className:"mb-1",children:Object(y.jsx)(bP,{})})}),Object(y.jsxs)("div",{className:"flex flex-col col-span-1",children:[Object(y.jsx)("div",{className:"text-neutral-600 text-left mb-1 text-sm","data-testid":"cropzones-heading",children:"Cropwise Crop Zones"}),Object(y.jsx)("div",{className:"flex items-center justify-center",children:(null===n||void 0===n?void 0:n.length)>0&&Object(y.jsxs)("div",{className:"relative inline-block w-full cropzone-dropdown",children:[Object(y.jsx)("div",{className:"prefix-icon",children:Object(y.jsx)("img",{alt:"Search icon",src:Fi})}),Object(y.jsx)(Xc.Select,{disabled:t.hide,size:"middle",onChange:function(e){c(e,t.id)},filterOption:function(e,t){var n;return null===(n=tw(t.title))||void 0===n?void 0:n.includes(tw(e))},showSearch:!0,suffixIcon:Object(y.jsx)(Xc.ChevronDown,{className:"dark-blue"}),placeholder:"Search by crop zone, field, or farm name",optionLabelProp:"label","data-testid":"select-cwf-cropzone",options:n,defaultValue:r?{label:r.name,value:r.id}:null})]})}),r&&Object(y.jsx)("div",{className:"mt-2 bg-gray-100 rounded-lg overflow-hidden w-67 p-4",children:Object(y.jsx)(tP,{className:"rounded-lg",feature:lP(r),area:(null===r||void 0===r?void 0:r.reportedArea)||(null===r||void 0===r?void 0:r.boundaryArea)},"property-preview")})]})]})})});nw.defaultProps={fftSelectGroups:[],property:{},matched:void 0};var aw=nw,rw=function(e){var t=e.property,n=e.isOpen,r=e.openProperty,c=e.cropZones,i=e.fftSelectGroups,o=Object(a.useContext)(Xg),s=o.isLoading,l=o.state.matches,d=Object(a.useState)(),u=Object(b.a)(d,2),j=u[0],p=u[1];return Object(a.useEffect)((function(){if(null!==l&&void 0!==l&&l.length&&null!==c&&void 0!==c&&c.length){var e=ew(c,t,l);p(c.find((function(t){return t.id===(null===e||void 0===e?void 0:e.cwfId)})))}}),[l,c]),s?Object(y.jsx)("div",{className:"col-span-2 justify-self-end",children:Object(y.jsx)(m.Spinner,{size:"sm"})}):Object(y.jsxs)("div",{"data-testid":"property-collapse",className:"text-l rounded-lg p-4 shadow-md mt-1 grid-flow-row auto-rows-max max-w-800 mb-5",children:[Object(y.jsxs)(pu,{className:"flex bg-transparent text-info-dark max-w-800",onClick:function(){return r(t)},children:[Object(y.jsx)("div",{className:"w-20","data-testid":"property-match-status",children:Object(y.jsx)($E,{property:t,matched:j})}),Object(y.jsx)("div",{className:"flex justify-start ml-2","data-testid":"property-title",children:Object(y.jsxs)("span",{className:"font-semibold ".concat(t.hide?"text-neutral-50":""),children:["\xa0",null===t||void 0===t?void 0:t.name]})}),Object(y.jsx)("div",{className:"flex justify-end flex-1",children:n?Object(y.jsx)(Yy.a,{fontSize:"small",className:"text-neutral-600"}):Object(y.jsx)(Ux.a,{fontSize:"small",className:"text-neutral-600"})})]}),n&&Object(y.jsx)(aw,{property:t,fftSelectGroups:i,cropZones:c,matched:j})]})};rw.defaultProps={cropZones:[],fftSelectGroups:[],property:{},isOpen:!1};var cw=rw,iw=function(e){var t=e.vendorFarms,n=e.cropZones,r=e.fftSelectGroups,c=Object(a.useState)(null),i=Object(b.a)(c,2),o=i[0],s=i[1],l=function(e){var t=o===e.id;s(t?null:e.id)};return Object(y.jsx)("div",{className:"grid w-full h-full",children:Object(y.jsx)("div",{className:"mb-5",children:null===t||void 0===t?void 0:t.map((function(e){return Object(y.jsxs)("div",{className:"mt-7",children:[Object(y.jsx)("div",{className:"justify-self-start",children:Object(y.jsxs)("div",{className:"flex flex-row items-center text-2xl font-semibold",children:[Object(y.jsx)(qC,{}),Object(y.jsx)("span",{"data-testid":"farm-name",className:"ml-2",children:null===e||void 0===e?void 0:e.name})]})}),Object(y.jsx)("div",{children:e.fields.map((function(e){return Object(y.jsx)(cw,{property:e,cropZones:n,fftSelectGroups:r,openProperty:l,isOpen:o===e.id},e.id)}))})]},e.id)}))})})};iw.defaultProps={vendorFarms:[],cropZones:[],fftSelectGroups:[]};var ow=iw,sw=function(){var e=Object(a.useContext)(Kh).goForward,t=Object(a.useState)([]),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)([]),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)([]),m=Object(b.a)(f,2),O=m[0],h=m[1],x=Object(a.useContext)(Xg),g=x.fetchVendorProperties,C=x.fetchMatches,P=x.submitMatches,A=x.updateMatches,S=x.isLoading,T=x.updateUnmatchedEntities,N=x.state,E=N.vendorProperties,w=N.unmatchedEntities,_=N.matches,R=Ix(),D=R.selectedCropSeasons,k=R.selectedRecommendations,L=rv({fetchType:gm}),F=L.loading,M=L.dataSorted,V=L.reloadData,B=ni();Object(a.useEffect)((function(){V({seasonIds:null===D||void 0===D?void 0:D.map((function(e){return e.id}))}),g(),C()}),[]),Object(a.useEffect)((function(){if(E.length){var e=new Map(k.flatMap((function(e){return e.farms.map((function(e){return[e.id,Object(I.a)(Object(I.a)({},e),{},{fields:[]})]}))})));new Map(k.flatMap((function(e){return e.fields.map((function(e){return[e.id,e]}))}))).forEach((function(t){var n=E.find((function(n){return n.id===t.id&&e.get(n.farmId)}));n&&e.get(n.farmId).fields.push(Object(I.a)(Object(I.a)({},t),n))})),h(Object(v.a)(e).map((function(e){return Object(b.a)(e,2)[1]})))}}),[E,k]),Object(a.useEffect)((function(){if(M.properties){var e=Mh(M.properties,null===D||void 0===D?void 0:D.map((function(e){return e.id})));c(e)}}),[M.properties]),Object(a.useEffect)((function(){if(null!==r&&void 0!==r&&r.length&&!s.length){var e=null===r||void 0===r?void 0:r.flatMap((function(e){return e.fields.filter((function(e){var t;return null===(t=e.cropzones)||void 0===t?void 0:t.length})).map((function(t){return{farm:e,field:t}}))})),t=e.map((function(e){return function(e,t){return{label:Object(y.jsxs)("span",{className:"text-xs font-semibold",children:[e.name," / ",t.name]}),title:"".concat(e.name," / ").concat(t.name),options:t.cropzones.map((function(e){var t=Ag({cropObject:{name:e.crop.name},size:14});return{label:Object(y.jsxs)("div",{className:"flex flex-col",children:[Object(y.jsx)("span",{className:"font-medium",children:e.name}),Object(y.jsxs)("div",{className:"flex items-center font-normal",children:[Object(y.jsx)("div",{className:"mr-2px",children:t}),Object(y.jsx)("small",{className:"text-gray-600",children:e.crop.name})]})]}),title:e.name,value:e.id}}))}}(e.farm,e.field)}));l(t),p(e.flatMap((function(e){return e.field.cropzones})))}}),[r]);var U=function(){var t=Object(Y.a)(G.a.mark((function t(){var n,a,r,c;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=!0,a=_.map((function(e){return e.cwfId})),r=Object(v.a)(new Set(a)),c=r.map((function(e){return[e,a.filter((function(t){return t===e})).length]})),c.forEach((function(e){e[1]>1&&(n=!1)})),!n){t.next=11;break}return t.next=8,P();case 8:e(),t.next=12;break;case 11:B.error("Unable to create property matching",{supportButton:!0,content:"The same Cropwise Crop Zone is selected for multiple fields. Please choose different Crop Zone for each field."});case 12:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();Object(a.useEffect)((function(){if(null!==O&&void 0!==O&&O.length){var e=null===O||void 0===O?void 0:O.flatMap((function(e){return e.fields.map((function(e){return e.id}))}));A(_.filter((function(t){return e.includes(t.vendorId)})))}}),[O]);return Object(a.useEffect)((function(){null!==_&&void 0!==_&&_.length&&null!==O&&void 0!==O&&O.length&&null!==j&&void 0!==j&&j.length&&function(){var e,t=null===(e=O.flatMap((function(e){return e.fields})))||void 0===e?void 0:e.filter((function(e){return!e.hide})),n=null===t||void 0===t?void 0:t.filter((function(e){return!ew(j,e,_)})).length;T(n)}()}),[_,O,j]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"w-84/100 bg-white flex flex-col px-6 py-4 rounded-xl font-body mb-mtcm","data-testid":"properties-match-view",children:[Object(y.jsx)("div",{className:"flex flex-col w-full mb-3",id:"properties-match-top-header",children:Object(y.jsx)(QE,{isLoading:F||S,title:"Match Properties",description:"Match applicable fields from Agrian to crop zones within Cropwise Financials.",unmatchedEntities:w})}),Object(y.jsx)("div",{className:"w-full mb-5 overflow-y-auto",children:!F&&!S&&Object(y.jsx)(ow,{vendorFarms:O,cropZones:j,fftSelectGroups:s})})]}),Object(y.jsx)(mx,{onNext:U,loading:S||F,nextLabel:"Next: Match Products",nextDisabled:S||F||w>0,integrationType:XO,isBottomFixed:!0})]})},lw=function(e){var t=e.item,n=t.value,a=t.key,r=t.label,c=t.type;return n?Object(y.jsx)("div",{className:"w-full h-full px-2 py-1 ml-2 flex items-center","data-testid":"item-with-value",children:Object(y.jsx)("div",{children:n.name})},a):"empty"===r?Object(y.jsx)("div",{className:"px-2 ml-2 text-neutral-60","data-testid":"item-empty-value",children:"No ".concat(c," Seasons found")},a):Object(y.jsx)("div",{className:"text-neutral-60 p-2 ml-2","data-testid":"item-without-value",children:r},a)},dw=function(e){var t=e.onChange,n=e.value,r=e.id,c=Object(a.useState)({active:[],upcoming:[],past:[]}),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)([]),d=Object(b.a)(l,2),u=d[0],j=d[1],p=dd(),f=p.cropSeasons,m=p.loaded;Object(a.useEffect)((function(){if(m&&(null===f||void 0===f?void 0:f.length)>0){var e=(new Date).getTime(),t={active:[],upcoming:[],past:[]};f.forEach((function(n){e>n.startDateEpoch?e>n.endDateEpoch?t.past.push(n):t.active.push(n):t.upcoming.push(n)})),s(Object(I.a)({},t))}}),[m,f]);var v=Object(a.useCallback)((function(){return null!==n&&void 0!==n&&n.type?Object(y.jsx)("div",{className:"w-full h-7 p-2 flex items-center text-base","data-testid":"selected-crop-season",children:Object(y.jsx)("div",{className:"pl-2",children:n.name})}):null}),[n]);return Object(a.useEffect)((function(){return o&&j([{key:"active-seasons",label:"Active Seasons",type:"Active",items:o.active.length>0?o.active.map((function(e){return{key:e.id,label:e.name,value:Object(I.a)(Object(I.a)({},e),{},{type:"Active"})}})):[{key:"empty-active",label:"empty",type:"Active"}]},{key:"upcoming-seasons",label:"Upcoming Seasons",type:"Upcoming",items:o.upcoming.length>0?o.upcoming.map((function(e){return{key:e.id,label:e.name,value:Object(I.a)(Object(I.a)({},e),{},{type:"Upcoming"})}})):[{key:"empty-upcoming",label:"empty",type:"Upcoming"}]},{key:"past-seasons",label:"Past Seasons",type:"Past",items:o.past.length>0?o.past.map((function(e){return{key:e.id,label:e.name,value:Object(I.a)(Object(I.a)({},e),{},{type:"Past"})}})):[{key:"empty-past",label:"empty",type:"Past"}]}]),function(){j([])}}),[o]),Object(y.jsx)(DP,{rightOffset:0,heightClass:"h-64",mainClass:"items-drop-down-field-1",valueRenderer:v,value:n,onChange:t,id:r,items:u,ItemComponent:lw})};dw.defaultProps={value:null,id:""};var uw=dw,bw=function(e){var t=e.title,n=e.message,a=e.overlayIcon,r=e.button,c=e.dataTestId,i=void 0===c?"empty-table-state":c;return Object(y.jsxs)("div",{"data-testid":i,className:"w-full h-full flex flex-col justify-center items-center",children:[Object(y.jsx)("img",{width:234,src:null!==a&&void 0!==a?a:kP,alt:"empty-state"}),Object(y.jsx)("p",{className:"text-sm font-semibold mb-2 ".concat("/static/media/noDocumentFound.e8c780e2.svg"===a?"mt-10":null),children:t}),n&&Object(y.jsx)("p",{"data-testid":"empty-table-state-message",className:"text-sm mb-4",children:n}),r]})};bw.defaultProps={title:"No Results Found",message:"",overlayIcon:null,button:null,dataTestId:"empty-table-state"};var jw=bw,pw="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOoAAACgCAYAAAACV/BEAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAABHnSURBVHgB7Z1rbBzXeYa/3aUuvkms7cpNK1e7NtAWblMxiYHK6Q+tYMdVpcKkUTuN0x9cOk3zKyXVpoCDFiVZF0jRtCb1Iz+SoOaqgO0GcSDJiW+SXK4Q1FILFJLsREFQy7O0bLNWbfFi3UXu5Lxn9+zODmf2Qi45s5z3AQazO7O73JXmnfc73znnOyKEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEVBETEjA7k+q/oUvE7hSJ4/FGdbCz+jX2hDo+LVLIi8yp7fBJIZGCQl1xdqZFEhDmdvXPrx67RdkwEGtOifeoyGW1z00LWbVQqCuCFme3epARhzC7uu5SW0q2br1Lksk71LZJOjtv1ufweHr6Ymm7oPf5/AcyMXFOcrk35eTJt/UxBzkl/n0iL2WFrDoo1GVlV0b9E/eqB2k86+y8STKZB6S7e5sWKZ4vBYgV2759r2nxlsiLFu38sMgreSGE+AGB7rbUZnd2ft4eGPiOPT7+hr2cWNYH9tjYYTuZfNzG3y1tY8U2MCHEAULc3SeMQAcHn7Gnpi7YKw0Em04/4RDsrkEhbQ1D35aQVu3OmyCGAYSz/f3dMjDQ3VRoa9qjaIcC7NFuBfgcPG42VM5mj8jw8HPmM/Pqv7tP5Ec5IW0HhbpkdKJIhZiSTKc/KWNje3QiqB5oU5469XYpMWSVBVoLCLWYgLpLtm//pODvNSLeoaFnlWCfLT2zh1TCaVhIW0GhLok/6lcX/ijEMjj4Re2itYAoDx48rp3OmbGFW6bTv6Mzvlu2bKoSH143M1N02nz+3IJsL8Saydwvvb0P1PzbeO+OHV83NwTVtTP/MJNNJALsHkH7L5nss0+cOFOzzYhEkrPNiISPSTAtpg2LvzcycsD1mX12JvOUTirVAn+39B6LiSayytk1hou9q+urNYXmFCiSSxBSq7O/XtneoaHaSSyIvCLWXV1CyOqjKNLe3qdqiqen50l7pbO/TsHCYbPZwzVfi++mXjtFsZJVRjHcrSXS/fuPGQFoN60Xii4HcEwjWLi4300CIXTpuzIMJqsF9EXu1k7ph2n/4eKHYIPE6epwV78bBpyVbVayStAjjfQF7+VOOAbnMu3WIFzUD4Td9ZJejjbruBDSnsBldk/5uRJECnGakDiIkUj1MOE4Nj+xOrLBI0JI+1Ecs+uXrTUihXOFGdMerSVW81tU/3BaCGkfiu1SPxEaFwq7SA1OsXpFBzhWSS6lFztPlpCVRIe8um3nBfoq6yWXwggig1rt7Up7ddeQEBJmLMvqvPfeAT0LBllRN3CeWhd72DFizGRGPM+XunammAUODxzr68ELLx4fe2j3kxmMocUgezep1Jf0mFnLetpzAP7XznxdloMHb31AHvyl+6UVYNwvxh7v3/+30tOzreocjuO8IivyYp+QwIkLqWLi7OTgv2X/I4PHg4N/uuA8ZqFApBiE38gsmVZy6PwROTT1mrQC3IAw+L+vb8Rd0kUP9McmunQMXZWEjLes93p+/Pqbvm1PZ8hbi7966wm9tQrzeWZ79fwRuxWYEBjtbTemLcu2ajigo5awrMlkIhEf2TvyQ/0ck7/dDA8/o/cjI38uQfCFTY/ofaucFdPy4JyjowdruGqsnxng4KFQDYk4KjQkjx/7uQ5pS6FfGcznzGZf08fdbbqV4t5bPtNysSKEh0j37j244FzpdyqR3pAREigUquKtd97rESlkDr16Qt5990PPCeDGTXFhB0mrxYobDypGeLlqZTJ6vFtIoFCoioTE9bC5w4eKBei7u+9b8Jpc7ieeThsErRYrstsQ6b59R6qOI9lU+r1phr/BEnmhvmVNZtQuiccIe+Eu7mwuyqcg01uv1MpK0kqxwjkhygMHji84Vwnzb+wREhiRF2oiIbqU5umfntVhr5djHjhwTO+9nDZIWiVWUzQN/afu8BfFwktwcnmARFqoTjc9ffodfQzV/dwg7PVy2jDQrFivXL0mH56fkdmPqwVpnPPgwWNVxytlSmNspwZIh0QY5aa95vHp02f1HoJ0gqp/YQl7GxnxBLF6jV6CQKdnLug9iMdjsuGWSrVDOOfAwHd16dLe3ur3IspQYXGy2E7lYlRBEFlHRb+plNaEAT9ToW+x0HW1a2JRJuDltO1AoVCQ/zt3Xm9GpMXjdtVz45yONWzKVG5ea5JCAiG6jhq3e5xDneGon/703QteZi7cIMPef777Gw29zstx43H/e/Gly1dl/bq15edwTi+hotZwkTVop3Jt1gCIbhs1LlUB3uzsJc+q86aCvTskbiecIa4Tp6MCuGpxWY1zC44XsdlFExCRFKoOe+1YOYuJbC+oXJAVcOGGMYnUDOvXrfF01mvXrkvBtsvPze/EeqxOKr8/lhQSCJEU6nyiUNXVMDtzWe+9HNWyzpUXF25XINIbb1jnea4wXyg/3rix+PvdjlohtlFIIERSqDE7lnY+R9hbi6UuOBwGnG1RJ3Pz8wuOzcy4HfUOIcESSaHGY7GtEjHWrl3jeXxubl5I+IloMilWFfpu2HCjrHY6EhzW3c5E7n8P9ZDc2csNG2+o+Z5G1i4NO2ineiWUvI5t2VId6q6G39/uRPA2699p73VBplKbFox/bVcwGqnWMTO4w90mr/x+e0JIIERPqB0L+wI3b75d770EafoWV4tY3XQkEuXHGC4J3Mkjh1A5fDAg2HApAbGaC9VJV1dK773OtRsYNugEbtrRUREqBAk3dTvqqVPmtyc4KikgIifU+bmOpNfxe+65U/cfup3TuEvlYm1PMOYXm5O1a6ozwRg+6DUCq9KvepWOGhB01BK/dudteu9up5rB+O3uqNeuzy045hwEYcb4es3HLf12JdLDdNSAiJxQEx1zea/j27b9pt4fPVo9KN2UI/GqftBOXLvmJdT15ceoYgG85+PqfxOKNEDoqCW23VcUqtfsEQgVIbHXuXbBPQAfI5Wc7VP8Nq+aUJXfbB8VEhjRE+pcR97rMAY9wFW9xGhcxrhOu4G26aXLV6qO3XxTpe8YoS02r7C38pvjOSGBEUFHveKbEPk95apezmmKUWezR9qymwbzTp3ASZ1CNTV9K+VBK5RC/rzIj3JCAiNyQk2lUhBq3uvcI49+Vu/dZTMBagr5FaoOO9Oz1YPsOzdUZgOZwuJeYa8pQ6PICQmUiFZ4iKnEiJ10H0VfKsJfuMjIyMWq/kS4zdDQs7pQNZa7aGRGzXKt6tYMFy5erhp4Dyd1uqm5KXkVFq/clGL7hARKJJNJBbvgOxTuc3/wKU/nhDBR4KydXBVT2JxuipDX7aa48cBNM5nqsBfnGPaSQMESFtY7k7bXduonZ+wNGx61Ozs/77kCGhb5xTms7BZ2/v+j6arfdvXq9arzmcxTtt9izWZFdZFdGSGBE0lHTcxfy/mdQ/a370sP+Drn2NiAPod1RcMMnBRhr+H2WzfK2rWVlg4SY2ibYjkLLzfFOdFu+lJWSOBEUqilhFLO7/zjSqgQLNqkXssRIgRGZjisITAEOu2o0gCROtulEOLw8HM6nPdarBnt1mISyR4WEgqiO+DBtn1VBpH273nI11WLq43fUSpYHa6hhbMfX9KV8AHmmv7KplurRAoefvgftBBHRr68oHAbRIwblNBNQ0V0hVq4mq11Gq6Kgfq4aN1ihBPt3/83el+86M9J0KCa4PmpWTk/PaufY+TRr95x24JaSXv2FG8uuNm4Q15glpdUn7hHCAkDKsEy7pdUwvbc93I6odLV9VXPZA2SMDifTPYFmly6fOWqffb9c/o7T7z7gf3xhUuerzMJonT6Cc/zo6MHSgmk3VMqiTQksjMpJBQkJMIM/MXXJlRMkfE7v/nO23WFwlde/h+ZmbkoO3d+puq8mRKGYXZYXKmn574VrVhoFnxC4ghhLgpt//JtnbJu3cJCZsPDz+roAN/55Zf/Xtavr3ZaRAWPPfZPcuXKdTxdr/pO0yrgGhD5jbzI/54SQoKknqti27btL7XTZLOHPZ1ocPCZsrOeOHHGXk6uX5+zZ2Yv2pMffKRd9KOpWe2ofkxNXSh3wyAywHM3iAbQ7WTctrf3qdLvebzkrlzEmASMZU2m6wn1x6+/aW/e3Kv7T/2EiDAY53GBI4RsJRDn1WvX7Y8vXtIb+kPn5wt13+cUIMTnJVIAcZrXjI+/Ue5brYTCf8hFjEnwNOKqL7783+WBEH7tUacw4GJBtlshMnPjgOP7YdwWIjXf3wyAqAx6oFBJCGjEVbF9819+UDd5hOPm4odQcLGvJHBE45D4nnjuh1OkcFunSBE5GKGrzWJiiYSCMxPvjzYr1lrtUVzwxl3xWrRvl9NhnQI1LuoX6jrbrRAp6Ol5coFIsfX3f4diJeEBhbmVEK1GxPrt775UDoPrtUedgsXrIZBaLtcMED4cG0kiI9B6ITfOmdcbkeIzvERqbkQmWUaxBkdMSBnLOtclicJ4I+uAnv7pWfnKl7+ll2wcGvqi5zQxJxhbu3fvC47auZt0VwmGJG7depd+XK9rB10oudwbcuqUpYcwms/C+zD1DgMYai0Riff09Y3qUUm9vfer77RHfy+A9+LzduwoTs0bH/9GVUVCdO2gi0f0iKX5HSKv5IWsGBSqC2vi/QGJxRoacQ+RfuXPvqVXK4dAxsf/se5aqhDDvn2vVQnNAMFhaKJTsKb4t7s6Il6DyeyYJ1tP5Hg/RIYpbQDf0bKe1sLHd8Dn1BKpgWINDgrVA2tickj9yww2+vrRkRdkr9oA3LXRieUQEASCyofYe632DYoC3qRFvHVrSrnw7za8uLLTRTExHjcXzJjBYHwcg6M3IlIDxUpCxdsTk9lG2qvuvlZn8ihInMkltKf793xbf0/Ttt6//1j5de42aT3YZl156Kg1gFhjMelt5j3Pf/8/lbv+UDsXXA8Ou3174w64VOCgcDxToO1zD35K/m7oC8pNiwXGn/7XI/Lk8L/rx3BouCocu56TuqGzriwUah3QbROPxfqbeQ9E+vz3X5cfqA2PAcJNtCe9SnIuFYTLmEOKyd6mLYuKigMDD5XrFTvBzeT551+X985+pMcyYw2aZoUKKNaVg0JtgGbbrE6MKP7r2M/1c1N532R7FyNcZ/YXdY2MOE11ikce/f2yg9YD2evH/uSbFGvIoVAbxLImM5JANthe1AB1OOuhV0/KoUMnyqI1mKytSRi5KWZ+L6ikj6VF6aw6AXH+8aOflQdViOtyz7zaktIAFGv4oVCbQIk1KQlR/ayNCcAPhJvHlVjRrYMNIv6ZEks9kLW9ZeMNuqQpJrVvu++3vJ3TtvdIoZCTROKENAjFGm4o1EVQDIXRbrVbOv0LAp6dvSzvnv2wfAxzYvW+sVA2J/PSl0p9Il+6qVjSBBRreKFQFwmEYMdlqNms8DKRV8IYTv365qzzIGYFqV1amoBiDScU6hIJWLB5FebuRf2nUmVF13ezlOOv71HOut22VQzQ4HekWMMHhdoidKiJsi5FMSRleUGIO6xC3Fwzb2ome02xhgsKdRnA/NZC3O6Ji2xXPtYlSyZWrENsF476uWfD341ibUso1GWmFH52Sdzuklh8eykBlVT/9J0eyah8cRc7ifVx4gUsZpU4mUptaulq3xRr+0GhRhSKtb2gUCMMxdo+UKgRh2JtDyhUQrG2ARQq0VCs4YZCJWUo1vBCoZIqKNZwQqGSBVCs4YNCJZ5QrOGCQiW+UKzhIborjpO6pLZ8YkhsGW7ktff89p3y3Pf+WgoFW5ceddcsrvu3UitT/K1doaOSuiy3s6IwWyYziod5uqk3FCppiOUSK0XaGBQqaZhWi5UibRwKlTRFq8RKkTYHhUqaZqlipUibh0Ili2KxYh0Y6NZdMUKRNgWFShbNYsSKkqhCkTYN+1HJollMP2tn5815irR56KhkyTTqrAUl6rshbtI0FCppCfXESpEuDQqVtAw/sVKkS4dCJS3FLVaKlJCQArFa70zaZyBaQkh4wWoBQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhESYXwAMHtFe/aPFqQAAAABJRU5ErkJggg==",fw=n.p+"static/media/no_search_results_found.5cb343c8.svg",mw=function(e){var t,n,r,c=e.recommendation,i=e.handleSelection,o=e.selectedRecommendations,s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(!1),p=Object(b.a)(j,2),f=p[0],v=p[1],O=function(e,t,n){return e.length<80?e:Object(y.jsxs)(y.Fragment,{children:[t?e:"".concat(e.substring(0,80),"..."),Object(y.jsx)("button",{type:"button",className:"text-blue-50 ml-2 cursor-pointer",onClick:n,onKeyPress:n,children:t?"show less":"show more"})]})};return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(m.Checkbox,{checked:(r=c.id,!(!o||0===o.length)&&-1!==o.findIndex((function(e){return e.id===r}))),onChange:function(){i(c)}})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"text-left",children:c.description})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"text-left",children:Yd(c.startDate)})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"text-left",children:O(null===(t=c.fields)||void 0===t?void 0:t.map((function(e){return e.name})).join(", "),d,(function(){return u(!d)}))})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"text-left",children:O(null===(n=c.products)||void 0===n?void 0:n.map((function(e){return e.productName})).join(", "),f,(function(){return v(!f)}))})}),Object(y.jsx)(m.Table.Cell,{children:c.lastSubmission&&Object(y.jsx)("div",{className:"bg-gray-200 text-neutral-50 font-semibold px-2 rounded-sm",children:Yd(c.lastSubmission)})})]})},vw=function(e){var t=e.handleSort,n=e.sortBy,r=e.sortDir,c=e.filteredRecommendations,i=e.handleSelection,o=e.selectedRecommendations,s=e.isLoading,l=e.isCropYearAndCropSeasonSelected,d=e.PaginationComponent,u=Object(a.useCallback)((function(e){return Is(e,n,r)}),[n,r]);return Object(y.jsx)(y.Fragment,{children:l?Object(y.jsx)("div",{children:s?Object(y.jsxs)("div",{"data-testid":"loading-agrian-records",className:"w-full h-full py-24 flex flex-col justify-center items-center",children:[Object(y.jsx)(m.Spinner,{}),Object(y.jsx)("p",{className:"text-sm font-semibold mt-4",children:"Loading Agrian records..."})]}):Object(y.jsx)(y.Fragment,{children:void 0!==c&&0!==(null===c||void 0===c?void 0:c.length)?Object(y.jsxs)("div",{"data-testid":"agrian-recommendations-table",children:[Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{}),Object(y.jsx)(m.Table.Cell,{sortable:!0,sort:u("doc_number"),onClick:t("doc_number"),children:"Recommendation Name"}),Object(y.jsx)(m.Table.Cell,{sortable:!0,sort:u("start_at"),onClick:t("start_at"),children:"Proposed Date"}),Object(y.jsx)(m.Table.Cell,{children:"Fields"}),Object(y.jsx)(m.Table.Cell,{children:"Products"}),Object(y.jsx)(m.Table.Cell,{children:"Last Import"})]}),null===c||void 0===c?void 0:c.map((function(e){return Object(y.jsx)(mw,{recommendation:e,selectedRecommendations:o,handleSelection:i},e.id)}))]}),Object(y.jsx)("div",{style:{minHeight:"35px"},children:d&&Object(y.jsx)(d,{})})]}):Object(y.jsx)("div",{className:"py-24",children:Object(y.jsx)(jw,{title:"No Records Found",message:"Change the selected crop year or try a different search.",overlayIcon:fw,dataTestId:"empty-view-no-recommendation"})})})}):Object(y.jsx)("div",{className:"py-24",children:Object(y.jsx)(jw,{title:"No Crop Year Selected and Crop Season Selected",overlayIcon:pw,dataTestId:"empty-view-no-recommendation"})})})},Ow=(n(1551),function(){var e,t=Object(a.useState)(""),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)(1),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(0),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(25),v=Object(b.a)(f,1)[0],O=Object(a.useState)(),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)(),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(!0),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)([]),R=Object(b.a)(_,2),I=R[0],D=R[1],k=Object(a.useState)(!1),L=Object(b.a)(k,2),F=L[0],M=L[1],V=lx(),B=V.events,U=V.triggerAnalyticsEvent,z=Object(a.useContext)(Kh),Z=z.goForward,H=z.releaseStepForward,W=VT(),q=W.loading,J=W.getAgrianRecommendationsBySeasonWithoutCache,K=Object(Zi.h)(),Q=K.values,X=K.setFieldValue,$=Ix(),ee=$.selectedCropSeasons,te=$.setSelectedCropSeasons,ne=$.selectedRecommendations,ae=$.setSelectedRecommendations,re=zi(r,300);Object(a.useEffect)((function(){function e(){return(e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Q.agrianCropYear&&(null===ee||void 0===ee?void 0:ee.length)>0)){e.next=6;break}return U(B.epic.Integrations.importRecommendationSearched,{vendor:XO}),e.next=4,J({cwfSeasonId:null===(t=ee[0])||void 0===t?void 0:t.id,displayPrevious:E,query:re,sortDir:null===A||void 0===A?void 0:A.toUpperCase(),sortBy:x,season:Q.agrianCropYear,page:s,limit:v});case 4:(n=e.sent)&&(H(),ae([]),X("recommendations",n.data));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[Q.agrianCropYear,ee,E,x,A,re,s]),Object(a.useEffect)((function(){M(Q.agrianCropYear&&(null===ee||void 0===ee?void 0:ee.length)>0)}),[Q.agrianCropYear,ee]),Object(a.useEffect)((function(){if(Q.recommendations){var e=Q.recommendations,t=e.data,n=e.elements;p(n),D(t)}}),[Q.recommendations]);var ce=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:U(B.epic.Integrations.importRecommendationSelected,{vendor:XO}),Z();case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"w-full mx-6",children:[Object(y.jsx)("div",{className:"flex flex-col bg-white top-30 left-26 rounded-md p-6 shadow-sm","data-testid":"submission-recommendation-selection",children:Object(y.jsxs)("div",{className:"mb-4",children:[Object(y.jsxs)("div",{className:"flex flex-col",children:[Object(y.jsx)("div",{className:"text-lg leading-7 font-semibold text-neutral-1000 mb-2",children:"Select Records"}),Object(y.jsx)("p",{className:"text-sm leading-6 text-neutral-70",children:"Select your Agrian crop year and the corresponding crop season to see Agrian recommendations for import."})]}),Object(y.jsxs)("div",{className:"grid grid-cols-2 gap-x-2 text-sm",children:[Object(y.jsx)(MN,{label:"Agrian Crop Year*",halfWidth:!0,children:Object(y.jsx)("div",{className:"mt-1",children:Object(y.jsx)(Qi,{control:m.Select,id:"agrianCropYear",name:"agrianCropYear",items:ch})})}),Object(y.jsx)(MN,{label:"Cropwise Financials Crop Season*",halfWidth:!0,children:Object(y.jsx)("div",{className:"text-sm",children:Object(y.jsx)(uw,{id:"cwfCropSeason",value:ee?ee[0]:null,onChange:function(e){te([e])}})})})]})]})}),Object(y.jsxs)("div",{className:"flex flex-row mt-4 mb-1 items-center",children:[Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsxs)("div",{className:"mr-4 relative inline-block min-w-360px base-drop-down-search-input",children:[Object(y.jsx)("div",{className:"prefix-icon",children:Object(y.jsx)("img",{alt:"Search icon",src:Fi})}),Object(y.jsx)(Xc.Input,{id:"label-search-input",placeholder:"Search names of records, fields or products",allowClear:!0,disabled:!F,type:"default",autoComplete:"off",onChange:function(e){return t=e.target.value,void c(t);var t}})]}),Object(y.jsxs)("div",{className:"my-auto",children:[Object(y.jsx)(Xc.Switch,{size:"medium",checked:F&&E,onChange:function(e){w(e)}}),Object(y.jsx)("span",{className:"ml-2 ".concat((!E||!F)&&"text-gray-500"," "),children:"Display previously imported recommendations"})]})]}),Object(y.jsx)("div",{className:"w-40 ml-auto text-right",children:Object(y.jsx)("span",{className:"".concat((null===ne||void 0===ne?void 0:ne.length)>0?"text-blue-50":"text-gray-500"," font-bold"),children:"".concat(null!==(e=null===ne||void 0===ne?void 0:ne.length)&&void 0!==e?e:0," ").concat((null===ne||void 0===ne?void 0:ne.length)>1?"records":"record"," selected")})})]}),Object(y.jsx)("div",{className:"flex flex-col bg-white top-30 left-26 rounded-md mb-24 shadow-sm","data-testid":"submission-recommendation-table",children:Object(y.jsx)(vw,{handleSort:function(e){return function(){g(e),S(Rs(Is(e,x,A)))}},sortBy:x,sortDir:A,filteredRecommendations:I,handleSelection:function(e){if(!(null!==ne&&void 0!==ne&&ne.length)>0)return ae([e]);var t=null===ne||void 0===ne?void 0:ne.filter((function(t){return t.id!==e.id}));return t.length!==(null===ne||void 0===ne?void 0:ne.length)?ae(t):ae([e].concat(ne))},selectedRecommendations:ne,isLoading:q,isCropYearAndCropSeasonSelected:F,PaginationComponent:function(){return Ho(j,s-1,(function(e){return l(e+1)}),null,v)}})})]}),Object(y.jsx)(mx,{onNext:ce,loading:q,nextLabel:"Next: Match Properties",nextDisabled:!(null!==ne&&void 0!==ne&&ne.length)>0||!(null!==ee&&void 0!==ee&&ee.length)>0||!(null!==Q&&void 0!==Q&&Q.agrianCropYear),integrationType:XO,isBottomFixed:!0})]})}),hw=function(){var e=Ix(),t=e.selectedCropSeasons,n=e.selectedRecommendations,r=rv({fetchType:gm}),c=r.dataSorted,i=r.reloadData,o=r.loading,s=Object(a.useContext)(Xg),l=s.fetchVendorProperties,d=s.fetchMatches,u=s.isLoading,j=s.state,p=j.vendorProperties,f=j.matches,m=Object(a.useState)([]),O=Object(b.a)(m,2),h=O[0],x=O[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),y=C[0],P=C[1];return Object(a.useEffect)((function(){i({seasonIds:null===t||void 0===t?void 0:t.map((function(e){return e.id}))}),l(),d()}),[]),Object(a.useEffect)((function(){P(!(!u&&!o))}),[u,o]),Object(a.useEffect)((function(){if(p.length){var e=new Map(n.flatMap((function(e){return e.farms.map((function(e){return[e.id,Object(I.a)(Object(I.a)({},e),{},{fields:[]})]}))})));new Map(n.flatMap((function(e){return e.fields.map((function(e){return[e.id,e]}))}))).forEach((function(t){var a,r=p.find((function(n){return n.id===t.id&&e.get(n.farmId)}));if(r){var i=function(e){return e.id===r.id};r.recommendations=n.filter((function(e){return e.fields.some(i)}));var o=null===f||void 0===f||null===(a=f.find((function(e){return e.vendorId===r.id})))||void 0===a?void 0:a.cwfId;r.cwfCropZone=null===c||void 0===c?void 0:c.properties.flatMap((function(e){return e.fields})).flatMap((function(e){return e.cropzones})).find((function(e){return e.id===o})),r&&e.get(r.farmId).fields.push(Object(I.a)(Object(I.a)({},t),r))}})),x(Object(v.a)(e).map((function(e){return Object(b.a)(e,2)[1]})))}}),[p,t,n,f,c]),Object(a.useMemo)((function(){return{recommendationsFarmFieldTree:h,loading:y}}),[h,y])},xw=function(e){var t=e.text,n=e.maxLength,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1];return t.length<=n?t:Object(y.jsxs)(y.Fragment,{children:[i?t:"".concat(t.substring(0,n),"..."),Object(y.jsx)("button",{type:"button",className:"text-blue-50 ml-2 cursor-pointer",onClick:function(){return o(!i)},onKeyPress:function(){return o(!i)},children:i?"show less":"show more"})]})},gw=function(){var e,t=Object(p.h)(),n=Object(Zi.h)().values,r=Ix(),c=r.selectedCropSeasons,i=r.selectedRecommendations,o=Object(a.useState)([]),s=Object(b.a)(o,2),l=s[0],d=s[1],u=lx(),j=u.events,f=u.triggerAnalyticsEvent,O=VT(),h=O.loading,x=O.importRecommendations,g=hw(),C=g.recommendationsFarmFieldTree,P=g.loading,A=function(e){l[e]&&l[e].current.scrollIntoView({behavior:"smooth",block:"center"})},S=function(e){return Object(v.a)(new Set(e.products.map((function(e){return e.productName})))).join(", ")};return Object(a.useEffect)((function(){d((function(e){return null===C||void 0===C?void 0:C.map((function(t,n){return e[n]||Object(a.createRef)()}))}))}),[C]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(si,{open:h,message:"Importing Recommendations"}),Object(y.jsx)("div",{className:"w-full mx-6",children:Object(y.jsxs)("div",{className:"flex flex-col bg-white top-30 left-26 rounded-md pt-6 pl-6 pr-6 shadow-sm","data-testid":"agrian-recommendation-review",children:[Object(y.jsxs)("div",{children:[Object(y.jsxs)("div",{className:"flex flex-col",children:[Object(y.jsx)("div",{className:"text-lg leading-7 font-semibold text-neutral-1000 mb-2",children:"Review and Import"}),Object(y.jsx)("p",{className:"text-sm leading-6 text-neutral-70",children:"Review matched data before importing"})]}),Object(y.jsx)("div",{className:"h-px w-full bg-gray-500 mt-6 mb-6"}),Object(y.jsx)("div",{className:"w-full flex h-15 items-center font-semibold",children:Object(y.jsxs)("p",{className:"text-2xl",children:["Agrian Import ",(new Date).toLocaleDateString("en-Us")]})}),Object(y.jsxs)("div",{className:"h-full mt-6 flex justify-start items-center",children:[Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"font-thin text-xs text-gray-600",children:"Agrian Crop Year"}),Object(y.jsx)("div",{className:"items-center","data-testid":"agrian-crop-year",children:Object(y.jsx)("p",{className:"text-2xl pr-2 w-auto overflow-x-auto",children:null===n||void 0===n?void 0:n.agrianCropYear})})]}),Object(y.jsx)(bP,{width:"80",height:"25"}),Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"font-thin text-xs text-gray-600",children:"Cropwise Crop Season"}),Object(y.jsx)("div",{className:"items-center","data-testid":"cwf-crop-season",children:Object(y.jsx)("p",{className:"text-2xl pr-2 w-auto overflow-x-auto",children:null===(e=c[0])||void 0===e?void 0:e.name})})]})]})]}),P?Object(y.jsxs)("div",{"data-testid":"loading-agrian-records",className:"w-full h-full py-24 flex flex-col justify-center items-center",children:[Object(y.jsx)(m.Spinner,{}),Object(y.jsx)("p",{className:"text-sm font-semibold mt-4",children:"Loading records..."})]}):Object(y.jsx)("div",{className:"flex flex-col bg-white top-30 left-26 rounded-md mb-24 shadow-sm","data-testid":"recommendation-review-table",children:null===C||void 0===C?void 0:C.map((function(e,t){return Object(y.jsxs)("div",{children:[Object(y.jsxs)("div",{className:"w-full flex justify-between align-middle mt-10",children:[Object(y.jsx)("div",{className:"flex justify-start",children:Object(y.jsx)("div",{"data-testid":"agrian-farm",className:"w-full",ref:function(e){return l[t]?(l[t].current=e,l[t].current):e},children:Object(y.jsx)(hy,{farm:e,selectFarm:A,farms:C,selectFarmTextSize:"text-sm"})})}),Object(y.jsx)("div",{className:"flex justify-end mt-1",children:Object(y.jsxs)(m.TagCloud,{children:[Object(y.jsxs)(m.Tag,{color:"#D60469",children:[e.fields.length," Fields"]},"cropzones-length"),Object(y.jsxs)(m.Tag,{color:"#2B9C92",children:[Object(v.a)(new Set(e.fields.flatMap((function(e){return e.recommendations})).map((function(e){return e.id})))).length," ","Recommendations"]},"applications-length")]})})]}),e.fields.map((function(e){var t,n,a,r,c;return Object(y.jsxs)("div",{children:[Object(y.jsxs)("div",{className:"h-full mt-6 flex justify-start items-center","data-testid":"agrian-field-collapse",children:[Object(y.jsx)("div",{className:"text-base font-semibold text-neutral-1000","data-testid":"agrian-field-name",children:e.name}),Object(y.jsx)(bP,{width:"80",height:"25"}),Object(y.jsx)("div",{className:"text-base font-semibold text-neutral-1000","data-testid":"cwf-cropzone-name",children:null!==(t=null===(n=e.cwfCropZone)||void 0===n?void 0:n.name)&&void 0!==t?t:"N/A"}),Object(y.jsx)("div",{className:"ml-3",children:Object(y.jsx)(Ag,{cropObject:null===(a=e.cwfCropZone)||void 0===a?void 0:a.crop,size:28})}),Object(y.jsx)("div",{className:"text-sm font-normal text-neutral-1000 ml-1","data-testid":"cwf-crop-name",children:null===(r=e.cwfCropZone)||void 0===r||null===(c=r.crop)||void 0===c?void 0:c.name})]}),Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{children:"Recommendation Name"}),Object(y.jsx)(m.Table.Cell,{children:"Proposed Date"}),Object(y.jsx)(m.Table.Cell,{children:"Products"})]}),e.recommendations.map((function(t){return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:t.description}),Object(y.jsx)(m.Table.Cell,{children:Yd(t.startDate)}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(xw,{text:S(t),maxLength:120})})]},"".concat(t.id,"_").concat(e.id))}))]})]},e.id)}))]},e.id)}))})]})}),Object(y.jsx)(mx,{onNext:function(){var e;f(j.epic.Integrations.importRecommendationTriggered,{vendor:XO}),x({recommendationsIds:i.map((function(e){return e.id})),seasonId:null===(e=c[0])||void 0===e?void 0:e.id}).then((function(){return t.replace("".concat(Cc.integrations,"/AgrianRecommendation/landing-page"))}))},loading:P||h,nextDisabled:P||h,nextLabel:"Import Records",integrationType:XO,isBottomFixed:!0})]})},Cw=function(e,t){return t?e.filter((function(e){var n;return(null===(n=e.producttype)||void 0===n?void 0:n.toLowerCase())===(null===t||void 0===t?void 0:t.toLowerCase())})):e},yw=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,n=Object(a.useContext)(ac),r=Object(b.a)(n,2),c=r[1],i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(s),j=Object(b.a)(d,2),p=j[0],f=j[1],m=Object(a.useState)(!1),O=Object(b.a)(m,2),h=O[0],x=O[1],g=Object(a.useState)(),C=Object(b.a)(g,2),y=C[0],P=C[1],A=Object(a.useState)(1),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(!1),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)([]),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useRef)(null),V=Object(a.useRef)(null),B=Object(a.useRef)(null),U=Object(a.useRef)(null),z=Object(a.useRef)(null),Z=Object(a.useRef)(null),H=function(){var n=Object(Y.a)(G.a.mark((function n(){var a,r,c,i;return G.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(U.current){n.next=2;break}return n.abrupt("return",L);case 2:return a=[{key:"name",operation:":",value:e,orPredicate:!1}],r=Yt.createChildApi({action:"product/search"}),c=r.create(a),i=c.promise,n.abrupt("return",i.then((function(e){var n=e.data.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{custom:!0,stdpackageunit:e.standardUnit,stdunit:e.standardUnit,productDensity:e.density,producttype:e.type,productId:e.id})}));return n=Cw(n,t),F(n),n})).catch(Ae.default).catch((function(){return F([]),[]})));case 6:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}(),W=Object(a.useCallback)(function(){var t=Object(Y.a)(G.a.mark((function t(n){var a;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=null===e||void 0===e?void 0:e.trim().toLowerCase(),t.abrupt("return",J.a.get("".concat(u.i,"/products/search?productName=").concat(a,"&pageNo=").concat(n),{headers:{common:{Authorization:"Bearer ".concat(Ve())}}}).then((function(e){P(Math.ceil(e.data.totalResults/e.data.resultsPerPage));var t=e.data.items.filter((function(e){return"Active"===e.status}));return R(Boolean(t.length)),t})).catch(Ae.default).catch((function(){return l([]),[]})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e]),q=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return x(!0),e.abrupt("return",J.a.get("".concat(u.i,"/products/").concat(t,"/?format=json&c=en-US"),{headers:{common:{Authorization:"Bearer ".concat(Ve())}}}).then((function(e){return e.data})).catch(Ae.default).catch((function(){return{}})).finally((function(){x(!1)})));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[]),K=function(e,n){var a=W(e),r=H();x(!0),Promise.all([a,r]).then((function(e){var a=Object(b.a)(e,2),r=a[0],c=a[1];if(n){var i=Object(Ru.a)([].concat(Object(v.a)(r),Object(v.a)(c)));f(Cw(i,t)),l(i)}else{var o=[].concat(Object(v.a)(s),Object(v.a)(r)),d=Object(Ru.a)(o);f(Cw(d,t)),l(d)}})).finally((function(){return x(!1)}))};return Object(a.useEffect)((function(){if(Z.current=B.current!==T,U.current=M.current!==e,z.current=V.current!==t,(null===e||void 0===e?void 0:e.length)>=3&&(Z.current||U.current||z.current)){var n=U.current?1:T;M.current=e,V.current=t,B.current=n,n!==T&&N(n),K(n,U.current)}else l([]),f([]),N(1),P(0)}),[c,e,t,T]),{loadSearchProducts:W,searchProductById:q,products:s,loading:h,setLoading:x,setProducts:l,filteredProducts:p,setFilteredProducts:f,totalPages:y,setTotalPages:P,pageNo:T,setPageNo:N,hasNextPage:_,setHasNextPage:R}},Pw=function(e){var t,n=e.item,r=Object(a.useRef)(null),c=n.value,i=n.key,o=n.label;if(!c){if("empty"===o)return Object(y.jsxs)("div",{className:"flex flex-col justify-center items-center h-full","data-testid":"item-empty-value",children:[Object(y.jsx)("img",{className:"w-1/2 mx-auto",src:kP,alt:"empty-state","data-testid":"empty-image"}),Object(y.jsx)("p",{"data-testid":"empty-table-state-message",className:"text-sm mb-4",children:"Enter at least three characters to search the product list"})]},i);if("loading"===o)return Object(y.jsx)("div",{className:"flex flex-col justify-center items-center h-full","data-testid":"item-loading-value",children:Object(y.jsx)("div",{className:"w-1/2 mx-auto","data-testid":"loading-spinner",children:Object(y.jsx)(m.Spinner,{})})},i)}return Object(y.jsxs)("div",{className:"w-full pb-2 pt-1 px-2 flex flex-col","data-testid":"item-with-value",children:[Object(y.jsxs)("div",{className:"flex flex-row justify-between w-full align-middle text-sm",children:[Object(y.jsxs)("div",{ref:r,className:"break-normal w-3/4",children:[c.name,Object(y.jsx)("span",{className:"text-gray-600 text-xs",children:" (".concat(c.stdunit,")")})]}),Object(y.jsx)("div",{children:Object(y.jsx)("span",{className:"text-xs bg-gray-200 text-gray-600 p-1 mt-1 rounded-md",children:c.producttype})})]}),Object(y.jsx)("div",{children:Object(y.jsx)("p",{className:"text-gray-600 text-xs mt-1",style:{width:"calc(100% -".concat(null===r||void 0===r||null===(t=r.current)||void 0===t?void 0:t.clientWidth,"px)")},children:c.manufacturer})})]},i)},Aw=function(){var e=Object(a.useState)(null),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useCallback)((function(e){In.fetch(e).promise.then((function(e){var t=e.data;return r(t)})).catch((function(){return r(null)}))}),[]),i=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Zt.fetch(t),a=n.promise,e.abrupt("return",a.then((function(e){var t=e.data,n=t.stdunit,a=t.stdpackageunit,r=t.density;return Object(K.getCompatibleUnits)([n,a],r)})).catch(Ae.default).catch((function(){return[]})));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),o=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Yt.fetch(t),a=n.promise,e.abrupt("return",a.then((function(e){var t=e.data,n=t.standardUnit,a=t.stdPackageUnit,r=t.density;return Object(K.getCompatibleUnits)([n,a],r)})).catch(Ae.default).catch((function(){return[]})));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{getMasterListProductUnits:i,getProductUnits:o,getProduct:c,product:n}},Sw=function(e){var t=e.onChange,n=e.value,r=e.id,c=Object(a.useState)(""),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)([{key:"empty",label:"empty",type:"PRODUCT"}]),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(void 0),f=Object(b.a)(p,2),m=f[0],v=f[1],O=zi(o,300),h=yw(O,""),x=h.filteredProducts,g=h.searchProductById,C=h.loading,P=ni(),A=Aw(),S=A.getProduct,T=A.product,N=Object(a.useState)(!1),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(!1),I=Object(b.a)(R,2),D=I[0],k=I[1],L=Object(a.useState)(null),F=Object(b.a)(L,2),M=F[0],V=F[1],B=wS(),U=B.addProducts,z=B.updateError;Object(a.useEffect)((function(){T&&v({name:T.productName,id:T.productId,stdunit:T.stdUnit})}),[T]),Object(a.useEffect)((function(){function e(){return(e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,g(n);case 2:(t=e.sent)?v(t):S(n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}n&&!m&&function(){e.apply(this,arguments)}()}),[n]),Object(a.useEffect)((function(){!C&&(null===x||void 0===x?void 0:x.length)>0&&(j(x.map((function(e){return{key:e.id,label:"".concat(e.name," - ").concat(e.manufacturer),type:"PRODUCT",value:e}}))),D&&(k(!D),v(x[0]),t(x[0])))}),[C,x]);var Z=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.custom){e.next=4;break}return n=IS(t),e.next=4,U({itemsToCreate:[n]});case 4:z?P.error("Unable to save changes",{supportButton:!0,content:"An error prevented your product(s) from being added to your list. Please try again."}):(P.success("Changes saved."),s(t.name),k(!0)),_(!1),V();case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(DP,{rightOffset:0,heightClass:"h-64",mainClass:"items-drop-down-field-1",value:m,onChange:function(e){v(e),s(void 0),t(e)},id:r,items:C?[{key:"loading",label:"loading",type:"PRODUCT"}]:u,ItemComponent:Pw,bottomButtonText:"+ Create Custom Product",onFilter:function(e,t){s(t)},isServerSideFilter:!0,onBottomButtonClick:function(){V({isNew:!0,custom:!0,formulation:{},type:"FERTILIZER"}),_(!0)},mergeSearchInputWithValue:!0,searchPlaceholderText:"Search by product name or manufacturer",valueRenderer:function(e){return e?"".concat(e.name," (").concat(e.stdunit,")"):""},isLoading:C,bottomButtonTextColor:"#0C612C",itemOptionClassName:""},m),Object(y.jsx)(xT,{handleEdit:Z,product:M,visible:w,onClose:function(){return _(!1)},editProductHeader:"Add Custom Product",saveText:"Create Product"})]})};Sw.defaultProps={value:"",id:""};var Tw=Sw,Nw=function(e){var t,n=e.product,a=e.matchedProduct,r=e.handleSelect;return Object(y.jsx)("div",{className:"justify-self-start pr-15 col-span-w w-full mb-8",children:Object(y.jsxs)("div",{className:"grid items-center grid-cols-7",children:[Object(y.jsx)("div",{className:"text-sm col-span-3",style:{position:"relative"},children:Object(y.jsxs)("div",{className:"flex flex-row items-center",children:[Object(y.jsx)("div",{className:"mr-4 mt-6 flex-none w-22",children:Object(y.jsx)(Xc.Tag,{color:a?"green":"yellow","data-testid":"status-tag",children:a?"MATCHED":"UNMATCHED"},"product-status")}),Object(y.jsxs)("div",{className:"flex flex-col my-2 w-full",children:[Object(y.jsx)("span",{className:"text-gray-600",children:"Agrian Product"}),Object(y.jsx)("div",{className:"mt-2 p-2 rounded-md bg-gray-200 border-gray-500 border-1 text-gray-600",children:"".concat(n.productName," (").concat(n.unit,")")})]})]})}),Object(y.jsx)("div",{className:"flex items-center justify-center h-full col-span-1",children:Object(y.jsx)("span",{className:"mb-1 mt-8",children:Object(y.jsx)(bP,{})})}),Object(y.jsxs)("div",{className:"flex flex-col col-span-3",children:[Object(y.jsx)("div",{className:"text-neutral-600 text-left mb-1 text-sm","data-testid":"cropzones-heading",children:"Cropwise Product"}),Object(y.jsx)("div",{className:"flex items-center justify-center cropzone-dropdown",children:Object(y.jsx)(Tw,{id:"cwfProductMatch",value:null!==(t=null===a||void 0===a?void 0:a.cwfEntityId)&&void 0!==t?t:null,onChange:function(e){r(e)}})})]})]})})};Nw.defaultProps={matchedProduct:void 0};var Ew=Nw,ww=function(e){var t=e.products,n=e.matches,a=e.onSelectMatch;return Object(y.jsx)("div",{className:"grid w-full h-full",children:Object(y.jsx)("div",{className:"mb-5",children:null===t||void 0===t?void 0:t.map((function(e){return Object(y.jsx)(Ew,{product:e,matchedProduct:n.find((function(t){return t.agrianEntityId===e.productId})),handleSelect:function(t){return a(e,t)}},e.productId)}))})})};ww.defaultProps={matches:[]};var _w=ww,Rw="SET_MATCHES",Iw="SET_FETCHED_MATCHES",Dw=function(e,t){switch(t.type){case Rw:return Object(I.a)(Object(I.a)({},e),{},{matches:t.payload});case Iw:return Object(I.a)(Object(I.a)({},e),{},{matches:t.payload,fetchedMatches:t.payload});default:return e}},kw={matches:[],fetchedMatches:[],errorMessage:"",matchEntityType:""},Lw=Object(a.createContext)(kw),Fw=function(e){var t=e.integrationType,n=e.children,r=e.onCompleteMatch,c=Object(a.useReducer)(Dw,Object(I.a)(Object(I.a)({},kw),{},{integrationType:t,children:n,matchEntityType:["Product"]})),i=Object(b.a)(c,2),o=i[0],s=i[1],l=nC(),d=l.getMatches,u=l.createMatches,j=l.loading,p=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];s({type:t?Iw:Rw,payload:e})},f=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==(t=o.matches.filter((function(e){return-1===o.fetchedMatches.findIndex((function(t){return e.cwfEntityId===t.cwfEntityId&&e.agrianEntityId===t.agrianEntityId}))}))).length){e.next=3;break}return e.abrupt("return",r());case 3:return e.next=5,u({vendor:QO,matches:t});case 5:201===(null===(n=e.sent)||void 0===n?void 0:n.status)&&r();case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),m=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d({vendor:QO,matchTypes:o.matchEntityType});case 2:200===(null===(t=e.sent)||void 0===t?void 0:t.status)&&p(t.data,!0);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),v=Object(a.useMemo)((function(){return{state:o,integrationContext:XO,dispatch:s,updateMatches:p,submitMatches:f,fetchMatches:m,isLoading:j}}),[o,j]);return Object(y.jsx)(Lw.Provider,{value:v,children:n})};Fw.defaultProps={children:null,integrationType:KO,onCompleteMatch:null};var Mw=Fw,Vw=function(){var e=lx(),t=e.events,n=e.triggerAnalyticsEvent,r=Object(a.useContext)(Kh).goForward,c=Object(a.useState)([]),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)([]),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useContext)(Lw),f=p.state.matches,m=p.isLoading,O=p.fetchMatches,h=p.submitMatches,x=p.updateMatches,g=Ix().selectedRecommendations,C=ni();Object(a.useEffect)((function(){m||O()}),[]),Object(a.useEffect)((function(){var e=g.flatMap((function(e){return e.products}));j(e.reduce((function(e,t){return-1===e.findIndex((function(e){return e.productId===t.productId}))&&e.push(t),e}),[]))}),[g]),Object(a.useEffect)((function(){s(u.filter((function(e){return-1===f.findIndex((function(t){return t.agrianEntityId===e.productId}))})))}),[f,u]);var P=function(){var e=Object(Y.a)(G.a.mark((function e(){var a,c,i,o;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=!0,c=f.filter((function(e){return u.findIndex((function(t){return t.productId===e.agrianEntityId}))>=0})).map((function(e){return e.cwfEntityId})),i=Object(v.a)(new Set(c)),o=i.map((function(e){return[e,c.filter((function(t){return t===e})).length]})),o.forEach((function(e){e[1]>1&&(a=!1)})),!a){e.next=12;break}return n(t.epic.Integrations.importRecommendationProductsMatch,{vendor:XO}),e.next=9,h();case 9:r(),e.next=13;break;case 12:C.error("Unable to create product matching",{supportButton:!0,content:"The same Cropwise Product is selected for multiple products. Please choose different Cropwise Product for each product."});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"w-84/100 bg-white flex flex-col px-6 py-4 rounded-xl font-body mb-mtcm","data-testid":"properties-match-view",children:[Object(y.jsx)("div",{className:"flex flex-col w-full mb-3",id:"properties-match-top-header",children:Object(y.jsx)(NP,{title:"Match Products",description:"Match products from your Agrian recommendations to products on the Cropwise Financials product list.",isLoading:m,isMatchCountVisible:!0,unmatchCount:o.length})}),Object(y.jsx)("div",{className:"w-full mb-5 overflow-y-auto",children:!m&&Object(y.jsx)(_w,{products:u,matches:f,onSelectMatch:function(e,t){if(!t)return x(Object(v.a)(f.filter((function(t){return t.agrianEntityId!==e.productId}))));var n={agrianEntityDescription:e.productName,agrianEntityId:e.productId,cwfEntityId:t.id,type:"Product"},a=f.filter((function(t){return t.agrianEntityId!==e.productId}));return a.length!==f.length?x([].concat(Object(v.a)(a),[n])):x([].concat(Object(v.a)(f),[n]))},unmatchedProducts:o})})]}),Object(y.jsx)(mx,{onNext:P,loading:m,nextLabel:"Next: Match Products",nextDisabled:m||o.length>0,integrationType:XO,isBottomFixed:!0})]})},Bw={1:Object(y.jsx)(UT,{buttonText:"Start New Import",integrationType:XO}),2:Object(y.jsx)(ZT,{integrationType:XO,title:"Select an organization to pull available Recommendations"}),3:Object(y.jsx)(Ow,{}),4:Object(y.jsx)(sw,{}),5:Object(y.jsx)(Vw,{}),6:Object(y.jsx)(gw,{})},Uw=function(e){var t=e.fixedStep,n=Object(a.useContext)(Kh).state.step;return Bw[null!==t&&void 0!==t?t:n]};Uw.propTypes={fixedStep:Ec.PropTypes.number};var zw=Uw,Zw=qE.map((function(e){return{caption:e.header}})),Yw=function(){var e=lx(),t=e.events,n=e.triggerAnalyticsEvent,r=Object(a.useContext)(Kh),c=r.state,i=c.step,o=c.canGoNext,s=r.gotoStep;return Object(y.jsxs)("div",{"data-testid":"base-integration",children:[Object(y.jsx)(lo,{hideCropSeasonDropdown:!0,disabled:!0,children:Object(y.jsx)(lo.Item,{title:"Integrations",value:XO,isLast:!0})}),Object(y.jsxs)("div",{className:"z-50 min-h-50 h-full left-0 right-0 bottom-0 top-18 flex flex-col items-center mb-48",children:[Object(y.jsx)(Ph,{stepArray:Zw,currentStep:i,canGoNext:o,gotoStep:s}),Object(y.jsx)(eC,{integrationType:XO,onCompleteMatch:function(){n(t.epic.Integrations.importRecommendationPropertiesMatch,{vendor:XO})},children:Object(y.jsx)(Mw,{integrationType:XO,onCompleteMatch:function(){n(t.epic.Integrations.ingestionRecommendationProductsMatch,{vendor:XO})},children:Object(y.jsx)(zw,{fixedStep:i})})})]})]})},Hw=function(){return Object(y.jsx)(hh,{children:Object(y.jsx)(Xh,{children:Object(y.jsx)(Zi.e,{initialValues:{},children:function(){return Object(y.jsx)(NC,{integrationType:XO,children:Object(y.jsx)(Yw,{})})}})})})},Gw=[{id:"integrations",key:"index",path:Cc.integrations,exact:!0,secure:!0,disabled:!1,icon:id,nav:"leftNav",component:WO},{id:"integration",key:"mcCain",path:"".concat(Cc.integrations,"/McCain"),exact:!0,secure:!0,component:Vg},{id:"integration",key:"simplot",path:"".concat(Cc.integrations,"/Simplot/landing-page"),exact:!0,secure:!0,component:xN},{id:"integration",key:"simplot-new-submission",path:"".concat(Cc.integrations,"/Simplot"),exact:!0,secure:!0,component:JP},{id:"integration",key:"simplot-view-submission",path:"".concat(Cc.integrations,"/Simplot/submission/:id"),exact:!0,secure:!0,component:JP},{id:"integration",key:"agrian-landing",path:"".concat(Cc.integrations,"/Agrian/landing-page"),exact:!0,secure:!0,component:gN},{id:"integration",key:"agrian-view-submission",path:"".concat(Cc.integrations,"/Agrian/submission/:id"),exact:!0,secure:!0,component:KT},{id:"integration",key:"agrian-new-submission",path:"".concat(Cc.integrations,"/Agrian"),exact:!0,secure:!0,component:KT},{id:"integration",key:"agrian-recommendation-landing",path:"".concat(Cc.integrations,"/AgrianRecommendation/landing-page"),exact:!0,secure:!0,component:JE},{id:"integration",key:"agrian-recommendation",path:"".concat(Cc.integrations,"/AgrianRecommendation"),exact:!0,secure:!0,component:Hw},{id:"integration",key:"cal-ag",path:"".concat(Cc.integrations,"/CalAgPermits"),exact:!0,secure:!0,component:WE},{id:"integration",key:"cal-ag-landing",path:"".concat(Cc.integrations,"/CalAgPermits/landing-page"),exact:!0,secure:!0,component:yN},{id:"integration",key:"cal-ag-view-submission",path:"".concat(Cc.integrations,"/CalAgPermits/submission/:id"),exact:!0,secure:!0,component:WE},{id:"integration",key:"crop-zone-matcher",path:"".concat(Cc.integrationCropZoneMatcher),exact:!0,secure:!0,component:MT}],Ww=[{field:"name",title:"Invoice",sortable:!0},{field:"date",title:"Invoice Date",sortable:!0},{field:"dueDate",title:"Due Date",sortable:!0},{field:"totalCost",title:"Total Invoice Cost",sortable:!1},{field:"productCount",title:"Product Count",sortable:!1},{field:"cropSeasons",title:"Seasons",sortable:!1}],qw="name",Jw="asc",Kw=0,Qw=50,Xw="tile",$w=["results"],e_=function(){var e=Object(a.useRef)({invoices:0}),t=Object(a.useState)({data:[],error:null,isLoading:!1,isError:!1,isSuccess:!1}),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useCallback)(Object(Y.a)(G.a.mark((function t(){var n,a,r,i,o,s,l,d,b,j,p,f,m,v,O,h,x=arguments;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=x.length>0&&void 0!==x[0]?x[0]:{},a=n.size,r=void 0===a?Qw:a,i=n.pageNo,o=void 0===i?Kw:i,s=n.searchBy,l=void 0===s?null:s,d=n.sortBy,b=void 0===d?qw:d,j=n.sortDir,p=void 0===j?Jw:j,f=n.cropSeasonIds,m=void 0===f?[]:f,v=n.startDate,O=n.endDate,e.current.invoices+=1,h=e.current.invoices,c((function(e){return Object(I.a)(Object(I.a)({},e),{},{isLoading:!0})})),t.abrupt("return",J.a.get("".concat(u.d,"/v1/invoice/summaries"),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:localStorage.getItem("selectedOrganizationId")}),Authorization:"Bearer ".concat(Ve())},params:Object(I.a)(Object(I.a)({size:r,pageNo:o,sortBy:b,sortDir:p,cropSeasonIds:m.join(",")},l?{searchBy:l}:{}),v&&O?{startDate:v,endDate:O}:{})}).then((function(t){var n=t.data,a=n.results,r=Object(te.a)(n,$w);return h===e.current.invoices&&c((function(e){return Object(I.a)(Object(I.a)(Object(I.a)({},e),r),{},{data:a,isSuccess:!0,error:null})})),n})).catch(Ae.default).catch((function(t){return h===e.current.invoices&&c((function(e){return Object(I.a)(Object(I.a)({},e),{},{isError:!0,error:t})})),{}})).finally((function(){h===e.current.invoices&&c((function(e){return Object(I.a)(Object(I.a)({},e),{},{isLoading:!1})}))})));case 6:case"end":return t.stop()}}),t)}))),[]);return{invoices:r,fetchInvoices:i}},t_=function(e){var t=e.hasPermission,n=Object(p.h)();return t()?Object(y.jsx)(m.Button,{id:"add-invoice-button",type:"primary",onClick:function(e){e.stopPropagation(),n.push("".concat(Cc.invoices,"/invoice"))},icon:Object(y.jsx)(Eo.a,{}),children:"Create Invoice"}):null},n_=function(e){var t=e.name,n=e.tags,r=e.notFoundMessage,c=e.showCreate,i=e.editTag,o=e.filterTags,s=e.selectedTags,l=e.setSelectedTagIds,d=e.isLoading,u=e.selectButtonClick,j=e.setFieldTouchedParent,p=Object(a.useState)([]),f=Object(b.a)(p,2),v=f[0],O=f[1],h=Object(Zi.h)().setFieldValue;return Object(a.useEffect)((function(){O(s||[])}),[s,O]),Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.Form,{children:[Object(y.jsx)("div",{className:"text-xl align-middle font-bold mb-2",children:"Tags"}),Object(y.jsx)("div",{"data-testid":"task-name",className:"text-lg",children:t}),Object(y.jsx)("div",{className:"mb-8",children:Object(y.jsx)(m.Form.Field,{children:Object(y.jsx)(Qi,{control:m.Input,placeholder:"Search Tags",name:"tagSearch",id:"tagSearch",items:[],onChange:function(e){var t;t=e.target.value,h("tagSearch",t),o(t)},onKeyPress:function(e){"Enter"===e.key&&e.preventDefault()}})})}),Object(y.jsx)("div",{className:"mb-2",children:"Tags"}),d?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)("ul",{children:n&&(null===n||void 0===n?void 0:n.length)>0?null===n||void 0===n?void 0:n.map((function(e){var t=null===v||void 0===v?void 0:v.includes(e.id),n=""!==e.color?e.color:null;return Object(y.jsxs)("li",{"data-testid":"custom-tag",className:"flex mb-1",children:[Object(y.jsxs)(m.Tag,{"data-testid":"custom-tag",id:e.id,color:n,onClick:function(){return function(e){var t=Object(ne.cloneDeep)(v);v.includes(e)?t.splice(t.indexOf(e),1):t.push(e),O(t),l(t)}(e.id)},children:[Object(y.jsx)("span",{children:e.name}),Object(y.jsx)(ui.a,{"data-testid":"tag-is-marked",icon:di.d,size:"1x",style:{visibility:t?"visible":"hidden",color:"#FFFFFF"}})]},e.id),Object(y.jsx)(m.Button,{"data-testid":"edit-button",type:"cancel",onClick:function(){return i(e)},children:Object(y.jsx)(ui.a,{icon:di.l,size:"1x",style:{visibility:"visible"}})})]},e.id)})):r}),Object(y.jsx)("div",{className:"mt-4 mb-4 border"}),Object(y.jsx)("div",{"data-testid":"create-tag-button",className:"w-full",children:Object(y.jsx)(m.Button,{className:"w-full",style:{width:"100%"},id:"add-tag-button",type:"primary",onClick:function(){return c()},children:"Create a new tag"})}),Object(y.jsx)("div",{"data-testid":"select-tags-button",className:"w-full mt-4",children:Object(y.jsx)(m.Button,{className:"w-full",style:{width:"100%"},id:"add-tag-button",type:"primary",onClick:function(){j("Tags"),u()},disabled:0===(null===v||void 0===v?void 0:v.length),children:"Select tag(s)"})})]})})};n_.defaultProps={setFieldTouchedParent:function(){}};var a_=n_,r_=[{name:"green",hex:"#5EBB7F"},{name:"yellow",hex:"#E99921"},{name:"orange",hex:"#FF785A"},{name:"purple",hex:"#BA99F6"},{name:"blue",hex:"#31B4F2"},{name:"red",hex:"#EB4B4B"},{name:"teal",hex:"#46BBB0"},{name:"pink",hex:"#FF7D96"}],c_=function(e){var t=e.backToLanding,n=e.selectedTag,r=e.resetForm,c=e.checkForDups,i=e.disableCreateBtn,o=e.handleSubmit,s=e.handleDelete,l=Object(a.useState)(null),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(Zi.h)().setFieldValue,f=Object(a.useState)("Create Tag"),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)(!0),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(!0),S=Object(b.a)(A,2),T=S[0],N=S[1],E=function(){return i||C||T};return Object(a.useEffect)((function(){n&&(j(n.color),P(!1),p("tagName",n.name),p("id",n.id),p("color",n.color),h("Edit Tag"),N(""===n.name))}),[n,p]),Object(y.jsxs)("div",{"data-testid":"create-tag-modal",children:[Object(y.jsx)("div",{className:"flex w-full mb-12",children:Object(y.jsxs)(m.Button,{"data-testid":"back-button",id:"back-to-landing",type:"cancel",style:{width:"100%"},onClick:function(){return t(r)},children:[Object(y.jsx)(ui.a,{icon:di.e,size:"2x",style:{visibility:"visible"}}),Object(y.jsx)("div",{"data-testid":"back-button-label",className:"text-xl align-middle font-bold ml-4 w-full text-left",children:O})]})}),Object(y.jsx)(m.Form.Field,{children:Object(y.jsx)(Qi,{name:"tagName",label:"Tag Name",control:m.Input,onChange:function(e){return t=e.target.value,N(""===t),p("tagName",t),void c(t,null===n||void 0===n?void 0:n.id);var t}})}),Object(y.jsx)("div",{className:"-mt-3 mb-5",children:"Tag name should be unique"}),Object(y.jsx)("div",{className:"mb-2",children:"Select Color"}),Object(y.jsx)("div",{className:"flex justify-between text-white mb-5",children:r_.map((function(e){var t=e.hex===u;return Object(y.jsx)("button",{"data-testid":"color-button",className:"w-8 h-8 border rounded-full",type:"button",style:{backgroundColor:e.hex},onClick:function(){return function(e){p("color",e),j(e),P(!1)}(e.hex)},children:Object(y.jsx)(ui.a,{icon:di.d,size:"1x",style:{visibility:t?"visible":"hidden",color:"#FFFFFF"}})})}))}),Object(y.jsx)("div",{className:"border mt-2 mb-5"}),n?Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("button",{"data-testid":"delete-button",className:"border border-solid rounded m-2 p-2 w-full mr-8",style:{backgroundColor:"#CF3537",color:"#FFFFFF"},id:"delete-tag-button",type:"button",onClick:s,children:"Delete"}),Object(y.jsx)("button",{"data-testid":"save-button",className:"border border-solid rounded m-2 p-2 w-full ml-8 ".concat(E()?"cursor-not-allowed":""),style:{backgroundColor:E()?"#f3f4f6":"#14803C",color:"#FFFFFF"},onClick:o,id:"save-tag-button",type:"button",disabled:E(),children:"Save"})]}):Object(y.jsx)(m.Button,{id:"create-tag-button",type:"primary",style:{width:"100%"},onClick:o,disabled:E(),children:"Create"})]})};c_.defaultProps={selectedTag:null};var i_=c_,o_=function(e){var t=e.backToLanding,n=e.resetForm,a=e.handleSubmit;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{"data-testid":"back-button",className:"flex w-full mb-12",children:Object(y.jsxs)(m.Button,{id:"back-to-landing",type:"cancel",style:{width:"100%"},onClick:function(){return t(n)},children:[Object(y.jsx)(ui.a,{icon:di.e,size:"2x",style:{visibility:"visible"}}),Object(y.jsx)("div",{"data-testid":"back-button-label",className:"text-xl align-middle font-bold ml-4 w-full text-left",children:"Delete Tag?"})]})}),Object(y.jsx)("div",{"data-testid":"delete-message",children:"This will remove the tag from all cards and cannot be undone. Do you want to proceed?"}),Object(y.jsx)("div",{className:"border mt-2 mb-5"}),Object(y.jsx)("button",{"data-testid":"delete-button",className:"border border-solid rounded m-2 p-2 w-full mr-8",style:{backgroundColor:"#CF3537",color:"#FFFFFF"},id:"delete-tag-button",type:"button",onClick:a,children:"Delete"})]})},s_=function(e){var t=e.open,n=e.close,r=e.name,c=e.selectedTags,i=e.returnSelectedTags,o=e.setFieldTouchedParent,s=Object(a.useState)(!0),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(!1),p=Object(b.a)(j,2),f=p[0],v=p[1],O=Object(a.useState)(!1),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)([]),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(A),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)(null),R=Object(b.a)(_,2),I=R[0],D=R[1],k=Object(a.useState)(!1),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Object(a.useState)(!1),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=Object(a.useState)(!1),H=Object(b.a)(Z,2),W=H[0],q=H[1],J=Object(a.useState)(!1),K=Object(b.a)(J,2),Q=K[0],X=K[1],$=Object(a.useState)([]),ee=Object(b.a)($,2),te=ee[0],ne=ee[1],ae=Object(a.useState)(!1),re=Object(b.a)(ae,2),ce=re[0],ie=re[1],oe=function(){u(!1),v(!0)},se=function(e){z(!0),D(e),oe()},le=function(){D(null),oe()},de=function(e){ie(!0),ne(e)},ue=function(e){e&&e(),z(!1),q(!1),v(!1),g(!1),u(!0)},be=function(){g(!1),v(!0)},je=function(e,t){var n=A.filter((function(n){return n.name.toLocaleLowerCase()===e.toLocaleLowerCase()&&n.id!==t}));q((null===n||void 0===n?void 0:n.length)>0)},pe=function(){v(!1),g(!0)},fe=function(){ne([]),n()},me=function(){var e=A.map((function(e){var t=e;return delete t.description,t})).filter((function(e){return null===te||void 0===te?void 0:te.includes(e.id)}));i(e),fe()},ve=function(){var e='No tags created. Tap on "Create a new tag" button to create one.';return(null===A||void 0===A?void 0:A.length)>0&&(e="No results found"),e},Oe=function(e){var t=""!==e?A.filter((function(t){return t.name.toLocaleLowerCase().includes(e.toLocaleLowerCase())})):A;w(t)},he=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return X(!0),t=Gt.fetch(),n=t.promise,e.next=4,n.then((function(e){var t=e.data.results,n=[];null===t||void 0===t||t.forEach((function(e){"|>"!==(null===e||void 0===e?void 0:e.name)&&"!"!==(null===e||void 0===e?void 0:e.name)&&"v"!==(null===e||void 0===e?void 0:e.name)&&"?"!==(null===e||void 0===e?void 0:e.name)&&"[]"!==(null===e||void 0===e?void 0:e.name)&&n.push(e)})),S(n),w(n),X(!1)})).catch(Ae.default).catch((function(e){uc(e),X(!1)}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),xe=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,i,o,s;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(M(!0),n={id:null===t||void 0===t?void 0:t.id,name:null===t||void 0===t?void 0:t.tagName,description:"",color:null===t||void 0===t?void 0:t.color},!f){e.next=12;break}if(!U){e.next=9;break}return a=Wt.update(n.id,n),r=a.promise,e.next=7,r.then((function(){ie(!0),M(!1),v(!1),he(),u(!0)})).catch(Ae.default).catch((function(e){M(!1),uc(e)}));case 7:e.next=12;break;case 9:return c=Wt.create(n),i=c.promise,e.next=12,i.then((function(){M(!1),v(!1),he(),u(!0)})).catch(Ae.default).catch((function(e){M(!1),uc(e)}));case 12:if(!x){e.next=16;break}return o=Wt.delete(n.id,n),s=o.promise,e.next=16,s.then((function(){ie(!0),M(!1),g(!1),he(),u(!0)})).catch(Ae.default).catch((function(e){M(!1),uc(e)}));case 16:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){return t&&(z(!1),q(!1),v(!1),g(!1),u(!0),ne((null===c||void 0===c?void 0:c.length)>0?null===c||void 0===c?void 0:c.split(","):[]),he()),function(){return S([])}}),[c,t]),Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(ao,{open:t,close:fe,onCancel:function(){ue()},onConfirm:function(){return me()},isSaving:F,type:"buttonless",children:Object(y.jsx)("div",{className:"-ml-6 mr-6",children:Object(y.jsx)(Zi.e,{initialValues:{tagName:"",color:"",id:""},onSubmit:function(e,t){var n=t.resetForm;xe(e),n()},children:function(e){var t=e.handleSubmit,n=e.resetForm;return Object(y.jsxs)("div",{"data-testid":"tags",children:[Object(y.jsxs)("div",{className:"flex w-full text-right",children:[Object(y.jsx)("div",{className:"w-full"}),Object(y.jsx)(m.Button,{type:"overlay",ghost:!0,icon:Object(y.jsx)(Kx.a,{}),onClick:function(){!function(e){ce?(e(),ie(!1),me()):fe()}(n)}})]}),Object(y.jsx)("div",{children:d&&Object(y.jsx)(a_,{"data-testid":"tags-landing",name:r,tags:E,notFoundMessage:ve(),showCreate:le,editTag:se,filterTags:Oe,selectedTags:te,setSelectedTagIds:de,isLoading:Q,selectButtonClick:me,setFieldTouchedParent:o})}),Object(y.jsx)("div",{children:f&&Object(y.jsx)(i_,{"data-testid":"tags-create",backToLanding:ue,selectedTag:I,resetForm:n,checkForDups:je,disableCreateBtn:W,handleSubmit:t,handleDelete:pe})}),Object(y.jsx)("div",{children:x&&Object(y.jsx)(o_,{"data-test":"tags-delete",tagId:I.id,backToLanding:be,resetForm:n,handleSubmit:t})})]})}})})})})};s_.defaultProps={selectedTags:null,returnSelectedTags:function(){},setFieldTouchedParent:function(){},name:""};var l_=s_,d_=n(2823),u_=O.StyleSheet.create({title:{fontFamily:"Noto Sans",fontWeight:"normal",fontSize:9,marginBottom:6,color:"#363948"},details:{fontFamily:"Noto Sans",fontWeight:"medium",fontSize:9,color:"#14151C"}}),b_=function(e){var t=e.vendorName,n=e.invoiceDate,a=e.invoiceDueDate;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(O.View,{children:[Object(y.jsx)(O.Text,{style:u_.title,children:"Vendor"}),Object(y.jsx)(O.Text,{style:u_.details,children:t})]}),Object(y.jsxs)(O.View,{children:[Object(y.jsx)(O.Text,{style:u_.title,children:"Date"}),Object(y.jsx)(O.Text,{style:u_.details,children:n})]}),Object(y.jsxs)(O.View,{children:[Object(y.jsx)(O.Text,{style:u_.title,children:"Due Date"}),Object(y.jsx)(O.Text,{style:u_.details,children:a})]})]})};b_.defaultProps={vendorName:"",invoiceDate:"",invoiceDueDate:""};var j_=b_,p_=[{label:"Description",width:40},{label:"Reg. No.",width:13},{label:"Manufacturer",width:22},{label:"Quantity",width:12},{label:"Total Price",width:13,alignment:"right"}],f_=function(e){var t=e.map((function(e){return[Ia(e.productName,{width:"".concat(40,"%")}),Ia(e.registrationNumber,{width:"".concat(13,"%")}),Ia(e.manufacturer,{width:"".concat(22,"%")}),Ia("".concat(ee(e.totalQuantityValue,"fixed")," ").concat(Object(va.g)(e.totalQuantityUnit)),{width:"".concat(12,"%")}),Ia(ee(e.totalCostValue,"currency"),{width:"".concat(13,"%"),textAlign:"right"})]})),n=null===e||void 0===e?void 0:e.reduce((function(e,t){return e+t.totalCostValue}),0);return t.push([Ia("Total Price: ".concat(ee(n,"currency")),{width:"100%",fontSize:11,fontWeight:"medium",paddingVertical:6,textAlign:"right"})]),t};O.Font.register({family:"Noto Sans",fonts:[{src:x},{src:g},{src:C}]});var m_=O.StyleSheet.create({body:{paddingHorizontal:20,paddingBottom:85},overallView:{paddingHorizontal:10},viewContainer:{marginBottom:27},vendorDetails:{width:"60%",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:15}}),v_=function(e){var t=e.invoice;return t?Object(y.jsx)(O.Document,{children:Object(y.jsxs)(O.Page,{style:m_.body,children:[Object(y.jsx)(da,{type:"Invoice",title:t.title,organization:t.organizationName,cropSeasons:t.cropSeasons.map((function(e){return e.name}))}),Object(y.jsxs)(O.View,{style:m_.overallView,children:[Object(y.jsx)(O.View,{style:m_.vendorDetails,children:Object(y.jsx)(j_,{vendorName:t.vendorName,invoiceDate:t.invoiceDateEpoch>0?new Date(t.invoiceDate).toLocaleDateString():"--",invoiceDueDate:t.invoiceDueDateEpoch>0?new Date(t.invoiceDueDate).toLocaleDateString():"--"})}),Object(y.jsx)(O.View,{style:m_.viewContainer,children:Object(y.jsx)(R,{headerItems:p_,bodyItems:t.mappedInvoiceProductEntries})}),Object(y.jsx)(O.View,{style:m_.viewContainer,children:Object(y.jsx)(ma,{notes:t.notes})})]}),Object(y.jsx)(ja,{year:t.year,fullDate:t.fullDate})]})}):null};v_.defaultProps={invoice:null};var O_=v_;function h_(e){var t,n=e.onSubmit,a=e.memberRole,r=e.memberFinancialAccess,c=e.isSaving,i=Object(Zi.h)().values,o=Object(p.h)(),s=Object(p.j)().id;return Object(y.jsxs)("div",{"data-testid":"invoice-top-header",className:"flex items-center justify-between px-3",children:[Object(y.jsxs)("div",{className:"flex justify-start",children:[Object(y.jsxs)("div",{className:"mr-12",children:[Object(y.jsx)("div",{className:"text-sm text-gray-600",children:"Invoice Date"}),Object(y.jsx)("div",{className:"text-2xl text-charcoal",children:null!==i&&void 0!==i&&i.invoiceDate?Object(ya.a)(new Date(null===i||void 0===i?void 0:i.invoiceDate),"MMM d, yyyy"):"Jan 02, 2020"})]}),Object(y.jsxs)("div",{className:"mr-8",children:[Object(y.jsx)("div",{className:"text-sm text-gray-600",children:"Total Products"}),Object(y.jsx)("div",{className:"text-2xl text-charcoal",children:(null===i||void 0===i||null===(t=i.invoiceProducts)||void 0===t?void 0:t.length)||0})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-sm text-gray-600",children:"Total Cost"}),Object(y.jsx)("div",{className:"text-2xl text-charcoal",children:function(e){var t=0;return"Full control"===a&&"none"===r?"":"Admin"===a||"View Only"===a||"Full control"===a&&"WRITE"===r||"Full control"===a&&"READ"===r&&"invoice"!==s?(null===e||void 0===e||e.forEach((function(e){t+=Number((null===e||void 0===e?void 0:e.totalCostValue)||0)})),function(e){return Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:"2",children:e||0})}(t)):""}(null===i||void 0===i?void 0:i.invoiceProducts)})]})]}),Object(y.jsxs)("div",{className:"flex justify-end flex-1",children:[Object(y.jsx)("div",{children:Object(y.jsx)(m.Button,{type:"primary",ghost:!0,onClick:function(){return o.push(Cc.invoices)},id:"cancelInvoice",children:"Cancel"})}),Object(y.jsx)("div",{className:"ml-4",children:Object(y.jsx)(m.Button,{id:"saveInvoice",type:"primary",loading:c,disabled:c,onClick:n,children:"Save"})})]})]})}h_.defaultProps={isSaving:!1};var x_=h_,g_=function(){var e,t=dE().companies,n=Object(Zi.h)(),r=n.values,c=n.setFieldValue,i=Object(a.useState)(null),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)([]),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(!1),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)({extraTagsCount:0,extraTagsNames:[],tagsToDisplay:[]}),g=Object(b.a)(x,2),C=g[0],P=g[1],A=null===t||void 0===t?void 0:t.map((function(e){return{value:e.name,key:e.id}})),S=function(e,t){var n=0===(null===e||void 0===e?void 0:e.length)?"":null===e||void 0===e?void 0:e.split(",").map((function(e){var n,a=t.filter((function(t){return t.id===e}));return{name:null===(n=a[0])||void 0===n?void 0:n.name,id:e,color:a[0].color}}));(null===n||void 0===n?void 0:n.length)>0&&(p(n),P(Af(n,55)))},T=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Gt.fetch(),n=t.promise,e.next=3,n.then((function(e){var t=e.data.results;l(t),S(null!==r&&void 0!==r&&r.flagIds?null===r||void 0===r?void 0:r.flagIds:[],t)})).catch(Ae.default).catch();case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){s||T()}),[s]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(l_,{open:O,close:function(){return h(!1)},name:null===r||void 0===r?void 0:r.invoiceNumber,selectedTags:(e=null===r||void 0===r?void 0:r.flagIds,0===(null===e||void 0===e?void 0:e.length)?"":null===e||void 0===e?void 0:e.split(",").reduce((function(e,t){return"".concat(e,",").concat(t)}))),returnSelectedTags:function(e){var t=null===e||void 0===e?void 0:e.map((function(e){return e.id}));c("flagIds",t.length>0?null===t||void 0===t?void 0:t.reduce((function(e,t){return"".concat(e,",").concat(t)})):[]),p(e),P(Af(e,55))}}),Object(y.jsx)(Qi,{label:"Invoice Number *",control:m.Input,name:"invoiceNumber","data-testid":"invoiceNumber"}),Object(y.jsx)(Qi,{label:"Company",control:m.Select,name:"vendor",items:A,"data-testid":"company"}),Object(y.jsx)(Qi,{control:m.DatePicker,"data-testid":"invoiceDate-test",label:"Invoice Date *",name:"invoiceDate",dateFormat:"M d, Y"}),Object(y.jsx)(Qi,{control:m.DatePicker,"data-testid":"invoiceDueDate-test",label:"Invoice Due Date",name:"invoiceDueDate",dateFormat:"M d, Y"}),Object(y.jsxs)("div",{children:[Object(y.jsx)(m.Label,{absolute:!0,children:"Tags"}),C.extraTagsNames.length>0?Object(y.jsx)(fu,{position:"botton",ariaLabel:"Invoice Tags",top:"1.5rem",msg:Object(y.jsx)(Pf,{extraTagsNames:C.extraTagsNames}),component:Object(y.jsx)(Nf,{setOpenTags:function(){return h(!0)},tags:j,displayTagsObject:C,viewKey:vd,disabled:!0})}):Object(y.jsx)(Nf,{setOpenTags:function(){return h(!0)},tags:j,displayTagsObject:C,viewKey:vd,disabled:!0})]})]})},C_=function(){return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(Qi,{control:m.TextArea,name:"notes",id:"notes",maxLength:"1000",className:"h-32 overscroll-auto",resizeDisabled:!0})})},y_=function(e){var t=e.memberRole,n=e.memberFinancialAccess;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{"data-testid":"invoice-info-title",className:"flex justify-between mb-10 font-medium text-lg",children:"Invoice Info"}),Object(y.jsx)("div",{className:"grid items-end grid-cols-2 gap-24 mb-12 gap-y-12",children:Object(y.jsx)(g_,{memberRole:t,memberFinancialAccess:n})}),Object(y.jsx)("div",{"data-testid":"invoice-notes-title",className:"flex justify-between mb-10 font-medium text-lg",children:"Notes"}),Object(y.jsx)("div",{className:"grid items-end grid-cols-1",children:Object(y.jsx)(C_,{})})]})},P_=function(e){var t=e.setValidationSchema,n=Object(Zi.h)(),a=n.setFieldValue,r=n.values,c=m.RadioButtonGroup.RadioButton;return Object(y.jsx)("div",{className:"flex",children:Object(y.jsx)("div",{className:"mt-4",children:Object(y.jsxs)(Qi,{selected:function(e){var t="Fertilizer";return"Service"===e&&(t="Service"),t}(null===r||void 0===r?void 0:r.type),control:m.RadioButtonGroup,name:"type",onChange:function(e){a("type",e),t(e)},children:[Object(y.jsx)(Qi,{value:"Fertilizer",id:"Fertilizer",name:"fertilizerService",control:c,onChange:function(e){return a(e)},children:"Fertilizer"}),Object(y.jsx)(Qi,{value:"Service",id:"Service",name:"fertilizerService",control:c,onChange:function(e){return a(e)},children:"Service"})]})})})},A_=function(){return Object(y.jsx)("div",{children:Object(y.jsx)("div",{name:"Service","data-testid":"service-tab",children:Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsx)(m.Column,{wrap:!0,children:Object(y.jsx)(m.Column,{width:"w-1/2",children:Object(y.jsxs)("div",{className:"pr-2",children:[Object(y.jsx)("div",{children:Object(y.jsx)(Qi,{id:"standardUnit",label:"Standard Unit*",control:m.Select,name:"standardUnit",placeholder:"Select","data-testid":"standard-unit-select",items:[{key:"acre",value:"acre"},{key:"hectare",value:"hectare"},{key:"hour",value:"hour"},{key:"day",value:"day"}]})}),Object(y.jsxs)("div",{children:[Object(y.jsx)("br",{}),Object(y.jsx)("br",{}),Object(y.jsx)("br",{}),Object(y.jsx)("br",{}),Object(y.jsx)("br",{}),Object(y.jsx)("br",{})]})]})})})})})})},S_=document.getElementById("cwf-modal-root"),T_=function(e){var t=e.open,n=e.onClose,r=e.handleSave,c=e.setModalTab,i=Object(a.useContext)(ac),o=Object(b.a)(i,1)[0],s=Object(a.useState)(HS),l=Object(b.a)(s,2),d=l[0],u=l[1],j={id:"",name:"",manufacturer:"",standardUnit:"",type:c,makeUp:"",density:0,densityInLbsPerGallon:0,stdFactor:1,stdPackageUnit:"",formulation:{S:0,B:0,Cl:0,N:0,P:0,K:0,Ca:0,Mg:0,Cu:0,Fe:0,Mn:0,Mo:0,Zn:0},organizationId:o.organization.id},p=function(e){u("Fertilizer"===e?HS:WS)},f=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,c,i;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=Object(I.a)(Object(I.a)({},t),{},{stdPackageUnit:t.standardUnit,type:t.type.toUpperCase(),makeUp:"Fertilizer"===t.type?t.makeUp.toUpperCase():"SOLID"}),e.next=3,Yt.create(a);case 3:return c=e.sent,i=c.promise,e.next=7,i.then((function(e){r(e.data),n()})).catch(Ae.default).catch((function(e){uc(e)}));case 7:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();return Object(y.jsx)(Zi.e,{enableReinitialize:!0,initialValues:j,validationSchema:d,onSubmit:function(e,t){var n=t.resetForm;return f(e,n)},children:function(e){var a=e.values,r=e.handleSubmit;return t?Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(m.SimpleModal,{open:t,close:n,onConfirm:r,confirmLabel:"Save",children:Object(y.jsxs)("fieldset",{"data-testid":"custom-product-form",children:[Object(y.jsxs)("div",{className:"flex items-center justify-between",children:[Object(y.jsx)("div",{className:"font-bold text-lg",children:"Create a Custom Product"}),Object(y.jsx)("div",{className:"w-1/2 text-sm",children:Object(y.jsxs)("span",{children:["Need a custom crop protection or seed product?",Object(y.jsx)("a",{className:"pl-2 text-blue-300",href:"https://www.syngentadigital.com/us/product-request-form",target:"_blank",rel:"noreferrer",children:"Request here."})]})})]}),Object(y.jsx)(P_,{setValidationSchema:p}),Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)(m.Columns,{wrap:!0,children:[Object(y.jsx)(m.Column,{width:"w-1/2",children:Object(y.jsx)("div",{className:"pr-2",children:Object(y.jsx)(Qi,{control:m.Input,id:"name",name:"name",label:"Product Name*"})})}),Object(y.jsx)(m.Column,{width:"w-1/2",children:Object(y.jsx)("div",{className:"pl-2",children:Object(y.jsx)(Qi,{control:m.Input,id:"manufacturer",name:"manufacturer",label:"Manufacturer*",placeholder:"Unspecified"})})})]})}),"Service"!==(null===a||void 0===a?void 0:a.type)?Object(y.jsx)(QS,{setValidationSchema:u}):Object(y.jsx)(A_,{})]})})}):null}})};T_.defaultProps={setModalTab:"Fertilizer"};var N_=function(e){return Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).JEST_WORKER_ID?Object(y.jsx)(T_,Object(I.a)({},e)):i.a.createPortal(Object(y.jsx)(T_,Object(I.a)({},e)),S_)},E_=(n(1552),function(e){var t=e.text;return e.canRender?Object(y.jsx)("p",{"data-testid":"warning-message",className:"message-text",children:t}):null});E_.defaultProps={text:"",canRender:!1};var w_=E_,__=function(e){var t=e.items,n=e.value,a=e.onChange;return Object(y.jsx)(m.Select,{style:{whiteSpace:"nowrap"},id:"type-filter-select",placeholder:"Filter by type",items:t,value:n,onChange:a})};__.defaultProps={value:void 0};var R_=__,I_=n(279),D_=n.n(I_),k_=function(e){var t=e.split("-").map((function(e){return e.replace(/^0+/,"")}));return"-"===(t=(t=t.map((function(e){return e.replace(/\b[A-Z]{2}/,"")}))).join("-"))[t.length-1]&&(t=t.slice(0,-2)),t},L_=r.a.forwardRef((function(e,t){var n=e.addProduct,a=e.product,r=e.isFirst,c=function(e){return Object(I.a)(Object(I.a)({},e),{},{manufacturer:e.manufacturer,producttype:e.producttype||e.type,stdunit:e.stdunit||e.standardUnit,registrationnumber:e.registrationnumber||""})}(a),i=Object(y.jsxs)("div",{className:"border ".concat(r?"mt-3":"border-t-0"," p-5"),children:[Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsx)("div",{className:"truncate text-lg font-bold",children:c.name}),Object(y.jsx)(m.Button,{id:"add-product-button",circular:!0,type:"primary",size:"sm",icon:Object(y.jsx)(D_.a,{style:{fontSize:16}}),onClick:function(){return n(c)}})]}),Object(y.jsx)("div",{className:"truncate text-sm text-neutral-300",children:c.manufacturer}),Object(y.jsx)("div",{className:"truncate text-sm text-neutral-300",children:c.producttype}),Object(y.jsx)("div",{className:"truncate text-sm text-neutral-300",children:c.stdunit}),Object(y.jsx)("div",{className:"truncate text-sm text-neutral-300",children:k_(c.registrationnumber)})]});return t?Object(y.jsx)("div",{ref:t,children:i}):Object(y.jsx)("div",{children:i})}));L_.propTypes={addProduct:wc.a.func.isRequired,product:wc.a.shape({name:wc.a.string.isRequired,manufacturer:wc.a.string.isRequired,producttype:wc.a.string.isRequired,stdunit:wc.a.string.isRequired,registrationnumber:wc.a.string.isRequired}).isRequired,isFirst:wc.a.bool},L_.defaultProps={isFirst:!1};var F_=L_,M_=function(e){var t=e.addProduct,n=e.toggleCreateCustomProductModal,r=e.products,c=e.setPageNo,i=e.isLoading,o=e.hasNextPage,s=Object(a.useRef)(),l=Object(a.useCallback)((function(e){i||(s.current&&s.current.disconnect(),s.current=new IntersectionObserver((function(e){e[0].isIntersecting&&o&&c((function(e){return e+1}))})),e&&s.current.observe(e))}),[i,o,c]),d=r.map((function(e,n){return r.length===n+1?Object(y.jsx)(F_,{addProduct:function(){return t(e)},product:e,isFirst:0===n,ref:l},null===e||void 0===e?void 0:e.id):Object(y.jsx)(F_,{addProduct:function(){return t(e)},product:e,isFirst:0===n},null===e||void 0===e?void 0:e.id)}));return Object(y.jsxs)("div",{className:"mt-6",children:[Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"text-sm font-bold uppercase",children:"PRODUCTS & SERVICES"})}),Object(y.jsx)("div",{className:"mt-6",children:Object(y.jsx)("div",{"data-testid":"create-custom-product-button",children:Object(y.jsxs)(pu,{className:"w-full text-center text-md pt-2 pb-2 border rounded border-green-600 text-green-600",onClick:n,children:[Object(y.jsx)(D_.a,{style:{fontSize:16}})," ",Object(y.jsx)("span",{children:"Create Custom"})]})})}),d,i&&Object(y.jsx)("div",{"data-testid":"product-spinner",className:"my-3",children:Object(y.jsx)(m.Spinner,{})})]})},V_=function(e){var t=e.toggleCreateCustomProductModal,n=e.productsLength,a=e.searchTextLength,r=e.isLoading,c=0===n&&a<3||r?"Search a word or phrase and we will show you a list of products to choose from":"No product found. Try your search again.";return Object(y.jsxs)("div",{className:"mt-6 border",children:[Object(y.jsx)("div",{className:"flex items-center justify-center",children:Object(y.jsx)("img",{className:"w-full",src:pw,alt:""})}),Object(y.jsx)("div",{className:"ml-6 mr-6",children:Object(y.jsx)("p",{className:"text-sm text-center",children:c})}),0===n&&a>0&&Object(y.jsx)("div",{className:"m-6 flex justify-center items-center",children:Object(y.jsxs)(m.Button,{id:"create-custom-product-button",onClick:t,size:"sm",type:"primary",children:[Object(y.jsx)(D_.a,{style:{fontSize:16}}),Object(y.jsx)("div",{className:"ml-1 whitespace-no-wrap text-xs",children:"Create Custom"})]})})]})},B_=n.p+"static/media/info.a2ebda1e.svg",U_=function(e){var t=Object(a.useState)(zn(e,{urlVersion:"/v1"}));return Object(b.a)(t,1)[0]},z_=n(60),Z_=n.n(z_),Y_=[{key:"ByRatePerArea",value:"ratePerAreaValue",unit:"ratePerAreaUnit",title:"Rate"},{key:"ByTotalProduct",value:"totalProductValue",unit:"totalProductUnit",title:"Total Product"},{key:"ByRatePerTank",value:"ratePerTankValue",unit:"ratePerTankUnit",title:"Rate/Tank"}],H_=function(e){var t,n,a,r;return e?{since:null===(t=e[0])||void 0===t||null===(n=t.toISOString().split("T"))||void 0===n?void 0:n[0],until:null===(a=e[1])||void 0===a||null===(r=a.toISOString().split("T"))||void 0===r?void 0:r[0]}:{since:null,until:null}},G_=function(e){return Y_.find((function(t){return t.key===e}))},W_=function(e){return{id:e.productId,productId:e.productId,productName:e.productName,manufacturerName:e.manufacturerName,areaUnit:e.areaUnit,averagePriceAtTimeOfCreation:e.averagePriceAtTimeOfCreation,averagePriceUnitAtTimeOfCreation:e.averagePriceUnitAtTimeOfCreation,totalProductValue:FS.b.parseFloatRound(e.totalProductValue,FS.a,Z_.a.ROUND_HALF_UP),totalProductUnit:e.totalProductUnit,ratePerAreaValue:FS.b.parseFloatRound(e.ratePerAreaValue,FS.a,Z_.a.ROUND_HALF_UP),ratePerAreaUnit:e.ratePerAreaUnit,ratePerTankValue:FS.b.parseFloatRound(e.ratePerTankValue,FS.a,Z_.a.ROUND_HALF_UP),ratePerTankUnit:e.ratePerTankUnit,totalCostAtTimeOfCreation:e.totalCostAtTimeOfCreation,appliedAreaValue:FS.b.parseFloatRound(e.appliedAreaValue,FS.a,Z_.a.ROUND_HALF_UP),appliedAreaUnit:e.appliedAreaUnit,applicationMethod:e.applicationMethod,targetPest:e.targetPest,specificCostPerUnit:FS.b.parseFloatRound(e.specificCostPerUnit),specificCostUnit:e.specificCostUnit,shareOwnerInformation:e.shareOwnerInformation,productDensity:e.density,custom:e.custom,customProductValue:FS.b.parseFloatRound(e.customProductValue,FS.a,Z_.a.ROUND_HALF_UP),customProductUnit:e.customProductUnit,hasCost:e.hasCost,customRateType:e.customRateType,associatedProduct:e.associatedProduct,coveragePercent:FS.b.divideSafeRound(e.coveragePercent,100,Z_.a.ROUND_HALF_UP)}},q_=function(e){return J.a.get("".concat(u.i,"/pests/search?pestName=").concat(e),{headers:{common:{Authorization:"Bearer ".concat(Ve())}}})},J_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=Object(a.useContext)(ac),r=Object(b.a)(n,2),c=r[1],i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(!1),u=Object(b.a)(d,2),j=u[0],p=u[1];return Object(a.useEffect)((function(){var n=(null!==e&&void 0!==e?e:"").trim();n.length<t||(p(!0),q_(n).then((function(e){l(e.data)})).catch(Ae.default).catch((function(e){uc(c)(e)})).finally((function(){p(!1)})))}),[c,e,t]),{pests:s,loading:j}},K_="targetPest",Q_=function(e){var t=e.pest,n=e.onSelectPest,r=Object(Zi.h)().setFieldTouched,c=Object(a.useState)(void 0),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(t?t.name:null),d=Object(b.a)(l,2),u=d[0],j=d[1],p=zi(u,300),f=J_(p),v=f.pests,O=f.loading,h=Object(a.useRef)(!1),x=Object(a.useMemo)((function(){return null!==v&&void 0!==v&&v.length?v.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{key:e.nameid,value:e.name})})):[]}),[v]);return Object(a.useEffect)((function(){O||0===x.length||h.current||(h.current=!0,s(t?Object(I.a)(Object(I.a)({},t),{},{key:t.id,value:t.name}):void 0))}),[t,O,x.length]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"-mt-1 mb-1",children:Object(y.jsx)(m.Label,{children:"Target Pest"})}),Object(y.jsx)(Qi,{control:m.Search,id:K_,name:K_,placeholder:"Search pests",items:x,loading:O,selectedValue:null===o||void 0===o?void 0:o.key,onChange:function(e){j(e.target.value),e.target.value||(s(void 0),n(null),r("targetPest",!0))},onSelect:function(e){r(K_,!0),s(e),n(e)}})]})};Q_.defaultProps={pest:void 0};var X_=Q_,$_=function(e){return{totalProductValue:e.totalProductValue||0,ratePerAreaValue:e.ratePerAreaValue||0,ratePerAreaUnit:e.ratePerAreaUnit||e.stdunit||"",ratePerTankValue:e.ratePerTankValue||0,ratePerTankUnit:e.ratePerTankUnit||e.stdunit||"",totalProductUnit:e.totalProductUnit||e.stdpackageunit||"",areaUnit:"acre",appliedAreaValue:e.totalAreaValue||0,coveragePercent:100,appliedAreaUnit:"acre",averagePriceUnitAtTimeOfCreation:"",averagePriceAtTimeOfCreation:0,totalCostAtTimeOfCreation:0,specificCostPerUnit:0,specificCostUnit:e.specificCostUnit||e.stdpackageunit,applicationMethod:e.applicationMethod||"",targetPest:e.targetPest,targetPestId:e.targetPestId,density:(null===e||void 0===e?void 0:e.density)||(null===e||void 0===e?void 0:e.productDensity)||(null===e||void 0===e?void 0:e.stdfactor)||0,productDensity:(null===e||void 0===e?void 0:e.density)||(null===e||void 0===e?void 0:e.productDensity)||(null===e||void 0===e?void 0:e.stdfactor)||0,shareOwnerInformation:{percentGrowerResponsibility:100,totalFromGrowerInventoryQuantity:100,totalFromGrowerInventoryUnit:""},stdfactor:e.stdfactor||1,stdpackageunit:e.stdpackageunit||"",stdunit:e.stdunit||"",custom:e.custom}},eR=[{key:"None",value:"None"},{key:"Aerial",value:"Aerial"},{key:"Air Blast",value:"Air Blast"},{key:"Chemigation",value:"Chemigation"},{key:"Fertigation",value:"Fertigation"},{key:"Fumigation",value:"Fumigation"},{key:"Ground",value:"Ground"},{key:"Ground - Banded",value:"Ground - Banded"},{key:"Ground - Broadcast",value:"Ground - Broadcast"},{key:"Ground - Hooded",value:"Ground - Hooded"},{key:"Ground - In Furrow",value:"Ground - In Furrow"},{key:"Ground - Incorporated",value:"Ground - Incorporated"},{key:"Ground - Seed Treatment",value:"Ground - Seed Treatment"},{key:"Ground - SpotankSizeChangeRemovt",value:"Ground - Spot"},{key:"Ground - Variable Rate",value:"Ground - Variable Rate"},{key:"Ground - Wipe",value:"Ground - Wipe"},{key:"Ground Application",value:"Ground Application"},{key:"Planting",value:"Planting"},{key:"Re-Planting",value:"Re-Planting"},{key:"Sidedress / Topdress",value:"Sidedress"},{key:"Storage",value:"Storage"},{key:"Topdress",value:"Topdress"},{key:"Tree Injection",value:"Tree Injection"},{key:"Water Run",value:"Water Run"}],tR=function(e){var t,n,r,c=e.open,i=e.onClose,o=e.product,s=e.isEdit,l=e.prodIndex,d=e.memberRole,u=e.memberFinancialAccess,j=e.selectedApplicationOption,p=Object(a.useContext)(we),v=Object(f.useFlags)(),O=null===ac||void 0===ac||null===(t=ac._currentValue[0])||void 0===t||null===(n=t.organization)||void 0===n?void 0:n.id,h=v.fePriceOverride&&(v.beProductPriceListEnabled||(null===(r=v.beProductPriceListEnableByOrgId)||void 0===r?void 0:r.includes(O))),x=U_("inventory/product"),g=Object(a.useState)(null),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(Zi.h)(),T=S.values,N=S.setFieldValue,E=S.setFieldTouched,w=Object(a.useState)(!1),_=Object(b.a)(w,2),R=_[0],D=_[1],k=Object(a.useState)(!1),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Object(a.useState)($_({})),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=Object(a.useState)(!0),Y=Object(b.a)(Z,2),H=Y[0],G=Y[1],W=Object(a.useState)([]),q=Object(b.a)(W,2),J=q[0],Q=q[1],X=Object(a.useState)(!1),$=Object(b.a)(X,2),ee=$[0],te=$[1],ne=Aw(),ae=ne.getMasterListProductUnits,re=ne.getProductUnits,ce=Object(a.useRef)(null),ie=Object(a.useState)(0),oe=Object(b.a)(ie,2),se=oe[0],le=oe[1],de=Object(a.useState)(!1),ue=Object(b.a)(de,2),be=ue[0],je=ue[1],pe=!se||se===+(null===U||void 0===U?void 0:U.averagePriceAtTimeOfCreation),fe=se!==+(null===U||void 0===U?void 0:U.averagePriceAtTimeOfCreation),me=fe?{opacity:1,pointerEvents:"inherit"}:{opacity:.5,pointerEvents:"none"},ve=h?" grid-cols-4 ":" grid-cols-3 ",Oe=h?" ":" hidden ",he=h?" col-span-2 ":" ";Object(a.useLayoutEffect)((function(){ce.current&&h&&(ce.current.closest("[role=dialog]").style.maxWidth="672px")})),Object(a.useEffect)((function(){!H&&U||(z($_({})),Q([]),G(!1))}),[U,H]),Object(a.useEffect)((function(){var e=$_({});o&&(e=$_(Object(I.a)(Object(I.a)({},o),{},{applicationMethod:"",totalAreaValue:null===T||void 0===T?void 0:T.totalAreaValue,density:null===T||void 0===T?void 0:T.density}))),z(e)}),[o,null===T||void 0===T?void 0:T.density]);var xe=G_(j),ge=function(){G(!0),i()},Ce=function(e,t,n,a,r){var c=Object(K.calculateProductValues)(e,t,n,a,r,U,T);z(c)},ye=function(e,t){var n="area"===t,a={changedPct:n?function(e,t){var n=0;return Number.parseFloat(e)>0&&(n=FS.b.parseFloatRound(Number.parseFloat(t)/Number.parseFloat(e)*100,2,Z_.a.ROUND_HALF_UP)),n}(null===T||void 0===T?void 0:T.totalAreaValue,e):e,changedArea:n?e:function(e,t){var n=0;return Number.parseFloat(t)>0&&(n=FS.b.parseFloatRound(e*(t/100),2,Z_.a.ROUND_HALF_UP)),n}(null===T||void 0===T?void 0:T.totalAreaValue,e)};Ce(xe.key,null===U||void 0===U?void 0:U[xe.value],{},a)},Pe=function(e){Ce(xe.key,null===U||void 0===U?void 0:U[xe.value],{},{},e)},Ae=Object(a.useState)(),Se=Object(b.a)(Ae,2),Te=Se[0],Ne=Se[1];Object(a.useEffect)((function(){Ne(Object(va.g)(null===U||void 0===U?void 0:U.stdpackageunit))}),[null===U||void 0===U?void 0:U.stdpackageunit]),Object(a.useEffect)((function(){var e=s?function(e){var t=$_(e);return t.density=e.density||e.productDensity||e.stdfactor,t.totalProductValue=e.totalProductValue,t.ratePerAreaValue=e.ratePerAreaValue,t.ratePerTankValue=e.ratePerTankValue,t.areaUnit=e.areaUnit,t.appliedAreaValue=e.appliedAreaValue,t.coveragePercent=e.coveragePercent,t.appliedAreaUnit=e.appliedAreaUnit,t.averagePriceUnitAtTimeOfCreation=e.averagePriceUnitAtTimeOfCreation,t.averagePriceAtTimeOfCreation=e.averagePriceAtTimeOfCreation,t.totalCostAtTimeOfCreation=e.totalCostAtTimeOfCreation,t.specificCostPerUnit=e.specificCostPerUnit,t.specificCostUnit=e.specificCostUnit,t.applicationMethod=e.applicationMethod,t.shareOwnerInformation=e.shareOwnerInformation,t}(Object(I.a)(Object(I.a)({},o),{},{applicationMethod:"",totalAreaValue:null===T||void 0===T?void 0:T.totalAreaValue})):$_(Object(I.a)(Object(I.a)({},o),{},{applicationMethod:"",totalAreaValue:null===T||void 0===T?void 0:T.totalAreaValue}));s?(N("productUnit",null===o||void 0===o?void 0:o[xe.unit]),N("applicationMethod",null===o||void 0===o?void 0:o.applicationMethod),null!==o&&void 0!==o&&o.saveAsNewListPriceDate&&te(!0)):(N("productUnit",null===o||void 0===o?void 0:o.stdunit),N("applicationMethod","")),z(e),D(!1),M(!1)}),[s,o,null===T||void 0===T?void 0:T.totalAreaValue,xe.unit,N,null===T||void 0===T?void 0:T.density]),Object(a.useEffect)((function(){c&&o&&(o.custom?re(o.id).then(Q):ae(o.id).then(Q),h&&x.fetch(o.id).promise.then((function(e){le(e.data.averagePricePerUnit)})).catch((function(){le(0)})))}),[c,s,o]),Object(a.useEffect)((function(){c&&p.sendEventToAmplitude(p.events.epic.Tasks.addProductSuccess)}),[c]),Object(a.useEffect)((function(){c&&o&&se&&!be&&(s||(je(!0),z(Object(I.a)(Object(I.a)({},U),{},{averagePriceAtTimeOfCreation:se}))))}),[c,s,o,se,U,be]);var Ee=function(){var e;return(null===U||void 0===U?void 0:U.totalCostAtTimeOfCreation)*((null===U||void 0===U||null===(e=U.shareOwnerInformation)||void 0===e?void 0:e.percentGrowerResponsibility)/100)},_e=function(){if(h&&!s)return"Price/Unit";var e="Price/";return e+=null===U||void 0===U?void 0:U.stdpackageunit};return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(Zi.c,{name:"products",children:function(e){var t,n,a=e.push;return Object(y.jsxs)(ao,{open:c,close:i,onCancel:function(){p.sendEventToAmplitude(p.events.epic.Tasks.cancelProduct),ge(),p.sendEventToAmplitude(p.events.epic.Tasks.cancelProductSuccess)},onConfirm:function(){p.sendEventToAmplitude(p.events.epic.Tasks.saveProduct),E("save product"),s?T.products[l]=Object(I.a)(Object(I.a)({},U),{},{saveAsNewListPriceDate:ee?(new Date).getTime():0,productName:o.name,manufacturerName:o.manufacturer,productId:o.id}):a(Object(I.a)(Object(I.a)({},U),{},{saveAsNewListPriceDate:ee?(new Date).getTime():0,productName:o.name,manufacturerName:o.manufacturer,productId:o.id})),ge(),p.sendEventToAmplitude(p.events.epic.Tasks.saveProductSuccess)},children:[Object(y.jsx)("div",{ref:ce}),P&&Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){return A("")},children:P}),o?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"font-bold text-lg","data-testid":"product-name",children:o.name})}),Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"text-sm text-neutral-300","data-testid":"manufacturer",children:o.manufacturer})}),Object(y.jsxs)("div",{className:"flex mb-6 mt-6",children:[("ByTotalProduct"===j||"ByRatePerTank"===j)&&Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Rate/Area"}),Object(y.jsx)("div",{children:Object(y.jsxs)("div",{className:"text-xl",children:[null===U||void 0===U?void 0:U.ratePerAreaValue," ",null===U||void 0===U?void 0:U.ratePerAreaUnit]})})]}),"ByTotalProduct"!==j&&Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Total Product"}),Object(y.jsxs)("div",{className:"text-xl","data-testid":"total-product",children:[Number(null===U||void 0===U?void 0:U.totalProductValue).toFixed(2)," ",Te]})]}),Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Product Cost"}),Object(y.jsx)("div",{className:"text-xl",children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===U||void 0===U?void 0:U.totalCostAtTimeOfCreation})})]})]}),Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)("div",{className:"grid ".concat(ve," gap-6 mb-12"),children:[Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Input,label:xe.title,name:xe.value,value:null===U||void 0===U?void 0:U[xe.value],onChange:function(e){Ce(j,e.target.value)},onFocus:function(e){return e.target.select()}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{style:{whiteSpace:"nowrap"},control:m.Select,label:"Unit",name:"productUnit",items:J,value:null===U||void 0===U?void 0:U[xe.unit],onChange:function(e){!function(e){var t={rateUnit:"ByRatePerArea"===xe.key?e:null===U||void 0===U?void 0:U.ratePerAreaUnit,tankUnit:"ByRatePerTank"===xe.key?e:null===U||void 0===U?void 0:U.ratePerTankUnit,totalProdUnit:"ByTotalProduct"===xe.key?e:null===U||void 0===U?void 0:U.totalProductUnit};Ce(xe.key,null===U||void 0===U?void 0:U[xe.value],t)}(JSON.parse(e.target.value).key)}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Input,label:"Applied Area",name:"productAppliedArea",value:null===U||void 0===U?void 0:U.appliedAreaValue,onChange:function(e){F||ye(e.target.value,"area")},onFocus:function(){return D(!0)},onBlur:function(){return D(!1)},imask:{mask:"num \\ac",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:[","],thousandsSeparator:","}}}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Input,label:"Applied Area %",name:"productAppliedAreaPercent",value:null===U||void 0===U?void 0:U.coveragePercent,onChange:function(e){e.target.value&&(R||ye(e.target.value,"pct"))},onFocus:function(){return M(!0)},onBlur:function(){return M(!1)},imask:{mask:"num%",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:[","],thousandsSeparator:","}}}})}),Object(y.jsxs)("div",{className:"my-2 relative",children:[Object(y.jsx)(Qi,{control:m.Input,label:_e(),name:"pricePerUnit",disabled:"Full control"===d&&("none"===u||"READ"===u),value:(null===U||void 0===U?void 0:U.averagePriceAtTimeOfCreation)||0,onChange:function(e){e.target.value&&Pe(e.target.value)},maskType:"usCurrency"}),Object(y.jsxs)("div",{"data-test-id":"unitLabel",className:"".concat(Oe," absolute gr-text-neutral-600 pointer-events-none"),style:{right:5,top:6},children:["/",Te]})]}),Object(y.jsx)("div",{className:"".concat(Oe," my-2 w-full"),style:{whiteSpace:"nowrap"},children:Object(y.jsx)(m.Button,{label:"Reset",name:"reset",type:"primary-ghost",disabled:pe,onClick:function(){p.sendEventToAmplitude(p.events.epic.ProductList.resetToListPrice,{productId:o.id}),Pe(se)},children:"Reset to List Price"})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Input,label:"Total Grower Cost",name:"totalGrowerCost",value:"Full control"===d&&"none"===u&&s?"":Ee().toFixed(2),disabled:!0})}),Object(y.jsxs)("div",{style:me,className:"".concat(Oe," mb-2 -mt-6 col-span-4"),children:[Object(y.jsxs)("div",{className:"flex flex-row justify-left",children:[Object(y.jsx)("span",{className:"inline-block",children:fe?Object(y.jsx)(zo,{color:"#0071CD",id:"savePriceList",name:"savePriceList",defaultChecked:ee,onChange:function(e){return te(e.currentTarget.checked)}},"enabled"):Object(y.jsx)(zo,{id:"disabledSavePriceList",name:"disabledSavePriceList"},"disabled")}),Object(y.jsx)("label",{htmlFor:fe?"savePriceList":"disabledSavePriceList",className:"inline-block pl-2 -mt-2px text-sm",children:"Save as new list price"})]}),Object(y.jsxs)("div",{className:"flex flex-row justify-left ".concat(ee&&fe?"":"invisible"),children:[Object(y.jsx)("img",{alt:"info",src:B_,className:"mr-1 mt-1"}),Object(y.jsx)("span",{className:"text-sm mt-1",children:"This will not change any existing records"})]})]}),Object(y.jsx)("div",{className:"my-2 ".concat(he),children:Object(y.jsx)(Qi,{control:m.Select,label:"Application Method",name:"applicationMethod",items:eR,onChange:function(e){z(Object(I.a)(Object(I.a)({},U),{},{applicationMethod:JSON.parse(e.target.value).key}))}})}),Object(y.jsx)("div",{className:"col-span-2 -mt-3",children:Object(y.jsx)(X_,{pest:o.targetPest,onSelectPest:function(e){z(Object(I.a)(Object(I.a)({},U),{},{targetPest:e?{latinNames:e.latinnames,name:e.name,id:e.nameid}:void 0}))}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Input,label:"Grower Share",name:"growerShare",value:null===U||void 0===U||null===(t=U.shareOwnerInformation)||void 0===t?void 0:t.percentGrowerResponsibility,disabled:!0,onChange:function(e){z(Object(I.a)(Object(I.a)({},U),{},{shareOwnerInformation:Object(I.a)(Object(I.a)({},null===U||void 0===U?void 0:U.shareOwnerInformation),{},{percentGrowerResponsibility:e.target.value})}))},imask:{mask:"num%",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:[","],thousandsSeparator:","}}}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Input,label:"From Inventory",name:"fromInventory",disabled:!0,value:null===U||void 0===U||null===(n=U.shareOwnerInformation)||void 0===n?void 0:n.totalFromGrowerInventoryQuantity,onChange:function(e){z(Object(I.a)(Object(I.a)({},U),{},{shareOwnerInformation:Object(I.a)(Object(I.a)({},null===U||void 0===U?void 0:U.shareOwnerInformation),{},{totalFromGrowerInventoryQuantity:e.target.value})}))},imask:{mask:"num%",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:[","],thousandsSeparator:","}}}})})]})})]}):Object(y.jsx)(m.Spinner,{})]})}})})};tR.defaultProps={prodIndex:0,product:null};var nR=tR,aR=function(e){var t=e.applicationOption,n=e.product,a=e.className,r=void 0===a?"":a;return Object(y.jsxs)("div",{className:"flex flex-col ".concat(r),children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300 mb-2",children:t.title}),Object(y.jsx)("div",{className:"flex flex-row items-center text-xl",children:Object(y.jsxs)("span",{className:"pr-2","data-testid":"total-product",children:["".concat(Number(null===n||void 0===n?void 0:n[t.value]).toFixed(2)," "),Object(va.g)(n[t.unit])]})})]})};aR.defaultProps={className:""};var rR=aR,cR="targetPest",iR=function(e){var t=e.pest,n=e.onSelectPest,r=Object(Zi.h)().setFieldTouched,c=Object(a.useState)(void 0),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(t?t.name:null),d=Object(b.a)(l,2),u=d[0],j=d[1],p=zi(u,300),f=J_(p),v=f.pests,O=f.loading,h=Object(a.useMemo)((function(){return null!==v&&void 0!==v&&v.length?v.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{key:e.nameid,value:e.name})})):[]}),[v]);return Object(a.useEffect)((function(){O||0===h.length||s(t?Object(I.a)(Object(I.a)({},t),{},{key:t.nameid,value:t.name}):void 0)}),[t,O,h.length]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"-mt-1 mb-1",children:Object(y.jsx)(m.Label,{children:"Target Pest"})}),Object(y.jsx)(Qi,{control:m.Search,id:cR,name:cR,placeholder:"Search pests",items:h,loading:O,selectedValue:null===o||void 0===o?void 0:o.key,onChange:function(e){j(e.target.value)},onSelect:function(e){r(cR,!0),n(e)}})]})};iR.defaultProps={pest:void 0};var oR=iR,sR=function(e){return Object(I.a)(Object(I.a)({},e),{},{totalProductValue:(null===e||void 0===e?void 0:e.totalProductValue)||0,ratePerAreaValue:(null===e||void 0===e?void 0:e.ratePerAreaValue)||0,ratePerAreaUnit:(null===e||void 0===e?void 0:e.ratePerAreaUnit)||(null===e||void 0===e?void 0:e.stdpackageunit)||"",ratePerTankValue:(null===e||void 0===e?void 0:e.ratePerTankValue)||0,ratePerTankUnit:(null===e||void 0===e?void 0:e.ratePerTankUnit)||(null===e||void 0===e?void 0:e.stdpackageunit)||"",productRateValue:(null===e||void 0===e?void 0:e.ratePerAreaValue)||(null===e||void 0===e?void 0:e.ratePerTankValue)||0,productRateUnit:(null===e||void 0===e?void 0:e.ratePerAreaUnit)||(null===e||void 0===e?void 0:e.stdunit)||"",totalProductUnit:(null===e||void 0===e?void 0:e.totalProductUnit)||(null===e||void 0===e?void 0:e.stdpackageunit)||"",areaValue:(null===e||void 0===e?void 0:e.appliedAreaValue)||(null===e||void 0===e?void 0:e.area)||(null===e||void 0===e?void 0:e.areaValue)||0,areaUnit:"acre",appliedAreaValue:(null===e||void 0===e?void 0:e.totalAreaValue)||0,coveragePercent:100,appliedAreaUnit:"acre",averagePriceUnitAtTimeOfCreation:"",averagePriceAtTimeOfCreation:0,totalCostAtTimeOfCreation:0,specificCostValue:(null===e||void 0===e?void 0:e.specificCostValue)||0,specificCostPerUnit:0,specificCostUnit:(null===e||void 0===e?void 0:e.specificCostUnit)||(null===e||void 0===e?void 0:e.stdpackageunit),applicationMethod:(null===e||void 0===e?void 0:e.applicationMethod)||"",targetPest:null===e||void 0===e?void 0:e.targetPest,targetPestId:null===e||void 0===e?void 0:e.targetPestId,productDensity:(null===e||void 0===e?void 0:e.productDensity)||(null===e||void 0===e?void 0:e.density)||e.stdfactor||0,shareOwnerInformation:{percentGrowerResponsibility:100,totalFromGrowerInventoryQuantity:100,totalFromGrowerInventoryUnit:""},totalProductCost:(null===e||void 0===e?void 0:e.totalProductCost)||0,stdfactor:(null===e||void 0===e?void 0:e.stdfactor)||1,stdpackageunit:(null===e||void 0===e?void 0:e.stdpackageunit)||"",stdunit:(null===e||void 0===e?void 0:e.stdunit)||(null===e||void 0===e?void 0:e.ratePerAreaUnit)||""})},lR=Object.values(iT),dR=function(e){var t=e.open,n=e.onClose,r=e.product,c=e.isEdit,i=e.prodIndex,o=Object(Zi.h)(),s=o.values,l=o.setFieldValue,d=o.setFieldTouched,u=Aw(),j=u.getMasterListProductUnits,p=u.getProductUnits,f=Object(a.useState)(!1),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)(!1),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)([]),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(sR(Object(I.a)(Object(I.a)({},{}),{},{applicationMethod:"",totalAreaValue:null===s||void 0===s?void 0:s.totalAreaValue}))),w=Object(b.a)(E,2),_=w[0],R=w[1],D=lR.find((function(e){return e.key===s.applicationStrategy})),k=function(){N([]),R(sR({})),n()},L=function(e,t){return Number.parseFloat(e)<=Number.parseFloat(t)?Number.parseFloat(e):Number.parseFloat(t)},F=function(){var e=Object(Y.a)(G.a.mark((function e(t,n,a,r){var c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c=Object(K.calculateProductValues)(t,n,a,r,void 0,_,s),R(c);case 2:case"end":return e.stop()}}),e)})));return function(t,n,a,r){return e.apply(this,arguments)}}(),M=function(e,t){var n="area"===t,a={changedPct:n?Object(K.roundValue)(function(e,t){var n=0;return Number.parseFloat(e)>0&&(n=Number.parseFloat(t)/Number.parseFloat(e)*100),n}(null===s||void 0===s?void 0:s.totalAreaValue,e)):e,changedArea:n?e:Object(K.roundValue)(function(e,t){var n=0;return Number.parseFloat(t)>0&&(n=e*(t/100)),n}(null===s||void 0===s?void 0:s.totalAreaValue,e))};F(D.value,null===_||void 0===_?void 0:_[D.value],{},a)},V=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a={rateUnit:D.key===iT.byRatePerArea.key?n:null===_||void 0===_?void 0:_.ratePerAreaUnit,tankUnit:D.key===iT.byRatePerTank.key?n:null===_||void 0===_?void 0:_.ratePerTankUnit,totalProdUnit:D.key===iT.byTotalProduct.key?n:null===_||void 0===_?void 0:_.totalProductUnit},F(D.value,null===_||void 0===_?void 0:_[D.value],a);case 2:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){t&&(null!==r&&void 0!==r&&r.custom?p(null===r||void 0===r?void 0:r.id).then(N):j(null===r||void 0===r?void 0:r.id).then(N))}),[t,r]),Object(a.useEffect)((function(){var e=c?function(e){var t=sR(e);return t.specificCostUnit=e.totalProductUnit,t.stdpackageunit=e.totalProductUnit,t}(Object(I.a)(Object(I.a)({},r),{},{totalAreaValue:null===s||void 0===s?void 0:s.totalAreaValue})):sR(Object(I.a)(Object(I.a)({},r),{},{applicationMethod:"",totalAreaValue:null===s||void 0===s?void 0:s.totalAreaValue}));if(R(e),c)l("productUnit",null===r||void 0===r?void 0:r[D.unit]),l("applicationMethod",null===r||void 0===r?void 0:r.applicationMethod);else{l("productUnit",null===r||void 0===r?void 0:r.stdunit),l("applicationMethod","");var t=r.stdunit,n=r.stdpackageunit,a=r.density;N(Object(K.getCompatibleUnits)([t,n],a))}h(!1),P(!1)}),[t,c,r,null===s||void 0===s?void 0:s.totalAreaValue,D.unit,l]),Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(Zi.c,{name:"products",children:function(e){var a=e.push;return Object(y.jsxs)(ao,{open:t,close:n,onCancel:k,onConfirm:function(){d("Add Product"),c?s.products[i]=Object(I.a)(Object(I.a)({},_),{},{productName:r.name,manufacturerName:r.manufacturer,productId:r.id}):a(Object(I.a)(Object(I.a)({},_),{},{productName:r.name,manufacturerName:r.manufacturer,productId:r.id})),k()},children:[Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"font-bold text-lg","data-testid":"product-name",children:r.name})}),Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"text-sm text-neutral-300","data-testid":"manufacture",children:r.manufacturer})}),Object(y.jsx)("div",{className:"flex mt-8",children:D.key===iT.byRatePerArea.key?Object(y.jsx)(rR,{applicationOption:iT.byTotalProduct,product:_}):D.key===iT.byTotalProduct.key?Object(y.jsx)(rR,{applicationOption:iT.byRatePerArea,product:_}):D.key===iT.byRatePerTank.key?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(rR,{className:"mr-6",applicationOption:iT.byRatePerTank,product:_}),Object(y.jsx)(rR,{applicationOption:iT.byTotalProduct,product:_})]}):null}),Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)("div",{className:"grid grid-cols-3 gap-6 mb-12",children:[Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Input,label:D.title,name:D.value,value:null===_||void 0===_?void 0:_[D.value],onFocus:function(e){return e.target.select()},onChange:function(e){F(D.value,e.target.value)}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{style:{whiteSpace:"nowrap"},control:m.Select,label:"Unit",name:"productUnit",value:null===_||void 0===_?void 0:_[D.unit],items:T,onChange:function(e){V(null===_||void 0===_?void 0:_[D.unit],JSON.parse(e.target.value).key)}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Input,label:"Applied Area",name:"productAppliedArea",value:null===_||void 0===_?void 0:_.appliedAreaValue,onChange:function(e){if(!C){var t=L(e.target.value,null===s||void 0===s?void 0:s.totalAreaValue);M(t,"area")}},onFocus:function(e){e.target.select(),h(!0)},onBlur:function(){return h(!1)},imask:{mask:"num \\ac",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:[","],thousandsSeparator:","}}}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Input,label:"Applied Area %",name:"productAppliedAreaPercent",value:null===_||void 0===_?void 0:_.coveragePercent,onChange:function(e){if(e.target.value&&!O){var t=L(e.target.value,100);M(t,"pct")}},onFocus:function(e){e.target.select(),P(!0)},onBlur:function(){return P(!1)},imask:{mask:"num%",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:[","],thousandsSeparator:","}}}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Select,label:"Application Method",name:"applicationMethod",items:oT,onChange:function(e){R(Object(I.a)(Object(I.a)({},_),{},{applicationMethod:JSON.parse(e.target.value).key}))}})}),Object(y.jsx)("div",{className:"-mt-3",children:Object(y.jsx)(oR,{pest:r.targetPest,onSelectPest:function(e){R(Object(I.a)(Object(I.a)({},_),{},{targetPestId:e.pestid,targetPest:{latinnames:e.latinnames,name:e.name,nameid:e.nameid,pestid:e.pestid}}))}})})]})})]})}})})};dR.defaultProps={prodIndex:0};var uR=dR,bR=function(e){return{totalProductValue:e.totalProductValue||0,ratePerAreaValue:e.productRateValue||0,ratePerAreaUnit:e.productRateUnit||e.stdunit||"",ratePerTankValue:e.ratePerTankValue||0,ratePerTankUnit:e.ratePerTankUnit||e.stdunit||"",totalProductUnit:e.totalProductUnit||e.stdpackageunit||"",areaUnit:"acre",appliedAreaValue:e.areaValue||0,coveragePercent:100,appliedAreaUnit:"acre",averagePriceUnitAtTimeOfCreation:"",averagePriceAtTimeOfCreation:e.specificCostValue||0,totalCostAtTimeOfCreation:e.totalProductCost||0,specificCostPerUnit:0,applicationCount:e.applicationCount||0,specificCostUnit:e.specificCostUnit||e.stdpackageunit,applicationMethod:e.applicationMethod||"",targetPest:e.targetPest,targetPestId:e.targetPestId,productDensity:e.productDensity||e.stdfactor||0,shareOwnerInformation:{percentGrowerResponsibility:100,totalFromGrowerInventoryQuantity:100,totalFromGrowerInventoryUnit:""},stdfactor:e.stdfactor||1,stdpackageunit:e.stdpackageunit||"",stdunit:e.stdunit||"",custom:e.custom,targetDateEpoch:e.targetDateEpoch||0,timingEvent:e.timingEvent||"",timingEventTag:e.timingEventTag||""}},jR=function(e){var t=e.open,n=e.onClose,r=e.product,c=e.isEdit,i=e.rowIndex,o=e.memberRole,s=e.memberFinancialAccess,l=Object(Zi.h)(),d=l.values,u=l.setFieldValue,j=l.setFieldTouched,p=Aw(),f=p.getMasterListProductUnits,v=p.getProductUnits,O=Object(a.useState)(bR({})),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)([]),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(!1),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)(),R=Object(b.a)(_,2),D=R[0],k=R[1],L="ByRatePerArea",F="ratePerAreaValue";Object(a.useEffect)((function(){k(Object(va.g)(null===x||void 0===x?void 0:x.specificCostUnit))}),[null===x||void 0===x?void 0:x.specificCostUnit]),Object(a.useEffect)((function(){var e=bR({});r.productId&&(e=bR(Object(I.a)(Object(I.a)({},r),{},{totalProductUnit:null===r||void 0===r?void 0:r.stdpackageunit,applicationMethod:"",totalAreaValue:null===d||void 0===d?void 0:d.totalAreaValue}))),g(e)}),[r,null===d||void 0===d?void 0:d.totalAreaValue]),Object(a.useEffect)((function(){t&&(null!==r&&void 0!==r&&r.custom?v(null===r||void 0===r?void 0:r.productId).then(S):f(null===r||void 0===r?void 0:r.productId).then(S))}),[t,c,r]);var M=function(){u("timingEvent",""),u("targetDate",""),n()};Object(a.useEffect)((function(){c&&u("targetDate",null===r||void 0===r?void 0:r.targetDateEpoch)}),[r,u,c]);var V=function(e){if(e){var t="Price / ";return t+=null===e||void 0===e?void 0:e.toLowerCase()}return"Price/Unit"},B=function(e,t,n,a,r){g(Object(K.calculateProductValues)(e,t,n,a,r,x,d))},U=function(e,t){var n="area"===t,a={changedPct:n?function(e,t){var n=0;return Number.parseFloat(e)>0&&(n=Number.parseFloat(t)/Number.parseFloat(e)*100),n}(null===d||void 0===d?void 0:d.totalAreaValue,e):e,changedArea:n?e:function(e,t){var n=0;return Number.parseFloat(t)>0&&(n=e*(t/100)),n}(null===d||void 0===d?void 0:d.totalAreaValue,e)};B(L,null===x||void 0===x?void 0:x[F],{},a)},z=function(e,t){return Number.parseFloat(e)<=Number.parseFloat(t)?Number.parseFloat(e):Number.parseFloat(t)},Z=function(e){return e&&!isNaN(e)&&e>0};return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(Zi.c,{name:"planProductEntries",children:function(e){var n=e.push;return Object(y.jsxs)(ao,{open:t,close:M,confirmLabel:"Save",onConfirm:function(){return function(e){j("planProductEntries");var t={productId:r.productId,density:x.productDensity,trackingId:r.trackingId,productRateValue:x.ratePerAreaValue,productRateUnit:x.ratePerAreaUnit,areaValue:x.appliedAreaValue,areaUnit:x.areaUnit,totalProductValue:x.totalProductValue,totalProductUnit:x.stdpackageunit,pricingStrategy:r.pricingStrategy,specificCostValue:x.averagePriceAtTimeOfCreation,specificCostUnit:x.specificCostUnit,totalProductCost:x.totalCostAtTimeOfCreation,coveragePercent:x.coveragePercent,applicationCount:x.applicationCount,targetDateEpoch:x.targetDateEpoch,timingEvent:x.timingEvent,timingEventTag:x.timingEventTag,manufacturerName:r.manufacturerName,productDensity:x.productDensity,productName:r.productName,shareOwnerInformation:Object(I.a)({},x.shareOwnerInformation),stdfactor:x.stdfactor,stdpackageunit:x.stdpackageunit,stdunit:x.stdunit,currency:r.currency,custom:r.custom};c?d.planProductEntries[i]=t:e(t),M()}(n)},children:[Object(y.jsxs)("div",{className:"mb-6",children:[Object(y.jsx)("div",{className:"flex w-full justify-between",children:Object(y.jsx)("div",{className:"font-bold text-lg","data-testid":"product-name",children:null===r||void 0===r?void 0:r.productName})}),Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"text-sm text-neutral-300","data-testid":"manufacture",children:null===r||void 0===r?void 0:r.manufacturerName})})]}),Object(y.jsxs)("div",{className:"flex grid-cols-2 gap-6 mb-12",children:[Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Total Product"}),Object(y.jsx)("div",{children:Object(y.jsx)("div",{className:"flex mr-6 text-xl","data-testid":"total-product",children:(null===x||void 0===x?void 0:x.totalProductValue)%1===0?Object(y.jsxs)(y.Fragment,{children:[null===x||void 0===x?void 0:x.totalProductValue," ",D]}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(yf,{roundedTo:2,children:null===x||void 0===x?void 0:x.totalProductValue})," ",null===x||void 0===x?void 0:x.totalProductUnit,"s"]})})})]}),Object(y.jsx)("div",{children:"Full control"===o&&"none"===s&&c?null:Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Product Cost"}),Object(y.jsx)("div",{className:"text-xl ",children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===x||void 0===x?void 0:x.totalCostAtTimeOfCreation})})]})})]}),Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)("div",{className:"grid grid-cols-3 gap-6 mb-12",children:[Object(y.jsx)("div",{className:"my-2 mb-6",children:Object(y.jsx)(Qi,{control:m.Input,label:"Rate",name:"ratePerAreaValue",value:null===x||void 0===x?void 0:x.ratePerAreaValue,onChange:function(e){return B(L,e.target.value)}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{style:{whiteSpace:"nowrap"},control:m.Select,label:"Unit",name:"productUnit",value:null===x||void 0===x?void 0:x.ratePerAreaUnit,items:A,onChange:function(e){!function(e){var t={rateUnit:"ByRatePerArea"===L?e:null===x||void 0===x?void 0:x.ratePerAreaUnit,tankUnit:"ByRatePerTank"===L?e:null===x||void 0===x?void 0:x.ratePerTankUnit,totalProdUnit:"ByTotalProduct"===L?e:null===x||void 0===x?void 0:x.totalProductUnit};B(L,null===x||void 0===x?void 0:x[F],t)}(JSON.parse(e.target.value).key)}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Input,label:V(null===x||void 0===x?void 0:x.stdpackageunit),name:"pricePerUnit",disabled:!("Full control"!==o||"none"!==s||!c)||"Full control"===o&&"READ"===s,value:null===x||void 0===x?void 0:x.averagePriceAtTimeOfCreation,onChange:function(e){return t=e.target.value,void B(L,null===x||void 0===x?void 0:x[F],{},{},t);var t},maskType:"usCurrency"})}),Object(y.jsx)("div",{className:"my-2 mb-6",children:Object(y.jsx)(Qi,{control:m.Input,label:"Applied Area",name:"productAppliedArea",value:null===x||void 0===x?void 0:x.appliedAreaValue,onChange:function(e){if(Z(e.target.value)){var t=z(e.target.value,null===d||void 0===d?void 0:d.totalAreaValue);U(t,"area")}},onFocus:function(){return w(!0)},onBlur:function(){return w(!1)},imask:{mask:"num \\ac",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:[","],thousandsSeparator:","}}}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Input,label:"Applied Area %",name:"productAppliedAreaPercent",value:null===x||void 0===x?void 0:x.coveragePercent,onChange:function(e){if(Z(e.target.value)&&!E){var t=z(e.target.value,100);U(t,"pct")}},imask:{mask:"num%",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:[","],thousandsSeparator:","}}}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Input,label:"# of Applications",name:"applicationCount",value:null===x||void 0===x?void 0:x.applicationCount,onChange:function(e){g(Object(K.calculateNumberOfApplications)(x,Math.trunc(e.target.value)||""))},imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,scale:0}}}})}),Object(y.jsx)("div",{className:"my-2 mb-6",children:Object(y.jsx)(Qi,{control:m.Select,label:"Timing",name:"timingEvent",value:null===x||void 0===x?void 0:x.timingEvent,items:sT,"data-testid":"timingEvent",onChange:function(e){var t=JSON.parse(e.target.value).value;g(Object(I.a)(Object(I.a)({},x),{},{timingEvent:"None"===t?"":t}))}})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.Select,label:"Timing Tag",name:"timingEventTag",value:null===x||void 0===x?void 0:x.timingEventTag})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(Qi,{control:m.DatePicker,label:"Target Date",name:"targetDate",dateFormat:"M d, Y",onChange:function(e){g(Object(I.a)(Object(I.a)({},x),{},{targetDateEpoch:Date.parse(e.target.value[0].toISOString())})),u("targetDate",e.target.value[0])}})})]})})]})}})})};jR.defaultProps={rowIndex:null,product:{targetDateEpoch:"",productRateUnit:"",totalProductUnit:"",custom:!1},memberRole:"",memberFinancialAccess:""};var pR=jR,fR=function(e){var t=e.open,n=e.onClose,r=e.product,c=e.isEdit,i=e.rowIndex,o=e.memberRole,s=e.memberFinancialAccess,l=Aw(),d=l.getMasterListProductUnits,u=l.getProductUnits,j=Object(a.useState)([]),f=Object(b.a)(j,2),v=f[0],O=f[1],h=Object(Zi.h)(),x=h.values,g=h.setFieldError,C=h.errors,P=Object(a.useState)(r),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)(!1),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(c?FS.b.divideSafeRound(null===r||void 0===r?void 0:r.totalCostValue,null===r||void 0===r?void 0:r.totalQuantityValue):0),D=Object(b.a)(R,2),k=D[0],L=D[1],F=Object(a.useState)(null),M=Object(b.a)(F,2),V=M[0],B=M[1],U=Object(p.j)().id;Object(a.useEffect)((function(){T(r)}),[r]),Object(a.useEffect)((function(){t&&(null!==r&&void 0!==r&&r.custom?u(null===r||void 0===r?void 0:r.productId).then(O):d(null===r||void 0===r?void 0:r.productId).then(O))}),[t,r]);var z=function(){g("totalQuantityUnit"),g("unitPrice"),n()},Z=function(e,t,n){return n&&0!==Number.parseFloat(n)?Number.parseFloat(n):Number.parseFloat(e)*t},Y=function(e,t){return t/Number.parseFloat(e)},H=function(){return"Full control"===o&&("none"===s||"READ"===s)},G=function(e){var t=Object(I.a)(Object(I.a)({},S),{},{totalQuantityUnit:null===S||void 0===S?void 0:S.totalQuantityUnit,timingEvent:null===x||void 0===x?void 0:x.timingEvent,timingEventTag:null===x||void 0===x?void 0:x.timingEventTag,totalCostValue:(null===S||void 0===S?void 0:S.totalCostValue)||0,totalQuantityValue:(null===S||void 0===S?void 0:S.totalQuantityValue)||0});delete t.density,c?x.invoiceProducts[i]=t:e(t),z()},W=function(e){var t=e.target.value;0==t?g("totalQuantityValue","Cannot save with Total Product of 0"):g("totalQuantityValue"),T(Object(I.a)(Object(I.a)({},S),{},{totalQuantityValue:t,totalCostValue:Z(t,k,null===S||void 0===S?void 0:S.totalCostValue)||0}));var n=Y(t,null===S||void 0===S?void 0:S.totalCostValue);n<0&&g("unitPrice","Unit price must be positive"),L(n||0)},q=function(e){var t,n,a,c=Number.parseFloat(e.target.value);if(c<0)g("unitPrice","Unit price must be positive");else if(c){g("unitPrice");var i=(t=c,n=null===S||void 0===S?void 0:S.totalCostValue,(a=null===S||void 0===S?void 0:S.totalQuantityValue)&&0!==Number.parseFloat(a)?Number.parseFloat(a):n/Number.parseFloat(t));i&&g("totalQuantityValue");var o=Z(i,c,i||null===r||void 0===r?void 0:r.totalCostValue);T(Object(I.a)(Object(I.a)({},S),{},{totalCostValue:o,totalQuantityValue:i})),L(c)}else{var s=Y(null===S||void 0===S?void 0:S.totalQuantityValue,null===S||void 0===S?void 0:S.totalCostValue);L(isNaN(s)?0:s)}},J=function(e){var t=e.target.value;if(!isNaN(t)){if(null===S||void 0===S||!S.totalQuantityValue)return T(Object(I.a)(Object(I.a)({},S),{},{totalCostValue:t})),void L(0);var n=Y(null===S||void 0===S?void 0:S.totalQuantityValue,t);T(Object(I.a)(Object(I.a)({},S),{},{totalCostValue:t})),n<0&&g("unitPrice","Unit price must be positive"),L(isNaN(n)?0:n)}};return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(Zi.c,{name:"invoiceProducts",children:function(e){var a,r,c=e.push;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(ao,{open:t,close:z,onCancel:z,confirmLabel:"Save",onConfirm:function(){return function(e){0===(null===S||void 0===S?void 0:S.totalCostValue)?_(!0):G(e)}(c)},hasError:null===(a=Object.values(C))||void 0===a?void 0:a.length,children:[Object(y.jsxs)("div",{className:"mb-6",children:[Object(y.jsx)("div",{className:"flex w-full justify-between",children:Object(y.jsx)("div",{"data-testid":"invoice-product-name",className:"font-bold text-lg",children:null===S||void 0===S?void 0:S.productName})}),Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"text-sm text-neutral-300",children:null===S||void 0===S?void 0:S.manufacturerName})})]}),Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)("div",{className:"grid grid-cols-9 gap-3 mb-12",children:[Object(y.jsx)("div",{className:"my-2 mb-6 col-span-2",children:Object(y.jsx)(Qi,{control:m.Input,error:!(null===C||void 0===C||!C.totalQuantityValue),errorMessage:null===C||void 0===C?void 0:C.totalQuantityValue,label:"Total Product",name:"totalQuantityValue",value:FS.b.parseFloatRound(null===S||void 0===S?void 0:S.totalQuantityValue,2,Z_.a.ROUND_HALF_UP),onBlur:function(e){return W(e)},onChange:function(e){return W(e)},type:"number"})}),Object(y.jsx)("div",{className:"my-2 col-span-2",children:Object(y.jsx)(Qi,{style:{whiteSpace:"nowrap"},control:m.Select,label:"Unit",name:"totalQuantityUnit",value:null===S||void 0===S?void 0:S.totalQuantityUnit,items:v,onChange:function(e){return function(e){T(Object(I.a)(Object(I.a)({},S),{},{totalQuantityUnit:JSON.parse(e.target.value).key}))}(e)}})}),Object(y.jsx)("div",{className:"my-2 col-span-2",children:Object(y.jsx)(Qi,{attachLeft:"$",control:m.Input,disabled:H(),error:!(null===C||void 0===C||!C.unitPrice),errorMessage:null===C||void 0===C?void 0:C.unitPrice,label:"Unit Price",name:"unitPrice",onBlur:function(e){return q(e)},onChange:function(e){return L(e.target.value)},type:"number",value:H()?null:FS.b.parseFloatRound(k,2,Z_.a.ROUND_HALF_UP)})}),Object(y.jsx)("div",{className:"my-2 col-span-3",children:Object(y.jsx)(Qi,{attachLeft:"$",control:m.Input,disabled:H(),label:"Total Cost",name:"totalCost",onBlur:function(e){return J(e)},onChange:function(e){return J(e)},type:"number",value:"Full control"===o&&"none"===s||"Full control"===o&&"READ"===s&&"invoice"===U?"":null!==(r=FS.b.parseFloatRound(null===S||void 0===S?void 0:S.totalCostValue,2,Z_.a.ROUND_HALF_UP))&&void 0!==r?r:0})})]})}),V&&Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){return B(null)},children:V})]}),Object(y.jsx)(ao,{open:w,close:function(){return _(!1)},onCancel:function(){return _(!1)},confirmLabel:"Yes",onConfirm:function(){G(c),_(!1),n()},type:"confirmation",title:"You are about to save a Product with a price of $0",children:Object(y.jsx)("p",{children:"Are you sure you want to save?"})})]})}})})};fR.defaultProps={open:!1,isEdit:!1,rowIndex:null};var mR=fR,vR=function(e){var t=e.memberRole,n=e.memberFinancialAccess,r=e.selectedApplicationOption,c=e.setCustomProductCreated,i=e.productFieldName,o=Object(a.useState)(!1),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useContext)(we),j=Object(p.i)().pathname,f=Object(Zi.h)(),O=f.values,h=f.setFieldValue,x=Object(a.useState)(""),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(null),S=Object(b.a)(A,2),T=S[0],N=S[1],E=zi(C,300),w=zi(T,300),_=yw(E,w),R=_.products,I=_.filteredProducts,D=_.loading,k=_.setLoading,L=_.setPageNo,F=_.hasNextPage,M=Object(a.useState)(!1),V=Object(b.a)(M,2),B=V[0],U=V[1],z=Object(a.useState)(null),Z=Object(b.a)(z,2),Y=Z[0],H=Z[1],G=Object(a.useState)(!1),W=Object(b.a)(G,2),q=W[0],J=W[1],K=function(){U(!1),H(null)},Q=function(){d((function(e){return!e}))};return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(N_,{open:l,onClose:function(){return d(!1)},handleSave:function(e){var t=function(e,t,n){return n.includes("plans")?{productId:e.id,density:e.density,trackingId:"",productRateValue:0,productRateUnit:e.standardUnit,areaValue:t.area,areaUnit:"acre",totalProductValue:0,totalProductUnit:e.standardUnit,pricingStrategy:"SystemDefined",specificCostValue:0,specificCostUnit:e.standardUnit,totalProductCost:0,coveragePercent:100,applicationCount:1,targetDateEpoch:"",timingEvent:"",timingEventTag:"",manufacturerName:e.manufacturer,productDensity:e.density,productName:e.name,shareOwnerInformation:{percentGrowerResponsibility:100,totalFromGrowerInventoryQuantity:100,totalFromGrowerInventoryUnit:""},stdfactor:e.stdFactor,stdpackageunit:e.standardUnit,stdunit:e.standardUnit,currency:"USD",custom:!0}:n.includes("invoices")?{productId:e.id,totalQuantityUnit:e.standardUnit,totalQuantityValue:e.totalQuantityValue||0,trackingId:"",totalCostValue:0,manufacturerName:e.manufacturer,productDensity:e.density,productName:e.name,totalCostCurrency:"USD",custom:!0}:{applicationMethod:"",appliedAreaUnit:"acre",appliedAreaValue:t.totalAreaValue||t.totalApplied,areaUnit:"acre",averagePriceAtTimeOfCreation:0,averagePriceUnitAtTimeOfCreation:"",coveragePercent:100,manufacturerName:e.manufacturer,productDensity:e.density,productId:e.id,productName:e.name,ratePerAreaUnit:e.standardUnit,ratePerAreaValue:0,ratePerTankUnit:e.standardUnit,ratePerTankValue:0,shareOwnerInformation:{percentGrowerResponsibility:100,totalFromGrowerInventoryQuantity:100,totalFromGrowerInventoryUnit:""},specificCostPerUnit:0,specificCostUnit:e.standardUnit,stdfactor:e.stdFactor,stdpackageunit:e.standardUnit,stdunit:e.standardUnit,targetPest:void 0,targetPestId:void 0,totalCostAtTimeOfCreation:0,totalProductCost:0,totalProductUnit:e.standardUnit,totalProductValue:0,custom:!0}}(e,O,j);h(i,[].concat(Object(v.a)(O[i]),[t])),d(!1),c(!0)},setModalTab:"Fertilizer"}),function(){if(Y){if(j.includes("tasks"))return Object(y.jsx)(nR,{values:O,open:B,product:Y,onClose:K,isEdit:!1,memberRole:t,memberFinancialAccess:n,selectedApplicationOption:r});if(j.includes("recommendations"))return Object(y.jsx)(uR,{values:O,open:B,product:Y,onClose:K,isEdit:!1});if(j.includes("plans"))return Object(y.jsx)(pR,{values:O,open:B,product:Y,onClose:K,isEdit:!1,memberRole:t,memberFinancialAccess:n});if(j.includes("invoices"))return Object(y.jsx)(mR,{values:O,open:B,product:Y,onClose:K,isEdit:!1,memberRole:t,memberFinancialAccess:n})}return null}(),Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Input,{id:"products-search",placeholder:"Search Products/Services",onChange:function(e){var t=e.target.value;t.length>=3?(k(!1),P(t),J(!1)):(J(!0),P(""))},onClick:function(){return J(!0)}}),Object(y.jsx)(w_,{canRender:q,text:"Type at least 3 characters to search"})]}),Object(y.jsx)("div",{className:"w-full mt-6",children:Object(y.jsx)(R_,{items:lT,value:T,onChange:function(e){var t="clear"!==JSON.parse(e.target.value).key?JSON.parse(e.target.value).key:null;N(t)}})}),Object(y.jsxs)("div",{className:"overflow-scroll",style:{height:"calc(100% - 64px - 1.5rem)"},children:[Object(y.jsx)(M_,{addProduct:function(e){j.includes("plans")?H(function(e,t){return{productId:e.id||"",density:e.density||0,trackingId:e.trackingId||"",productRateValue:e.productRateValue||0,productRateUnit:e.productRateUnit||e.stdunit||"",areaValue:e.areaValue||(null===t||void 0===t?void 0:t.area)||0,areaUnit:e.areaUnit||"acre",totalProductValue:e.totalProductValue||0,totalProductUnit:e.totalProductUnit||e.stdpackageunit||"",pricingStrategy:e.pricingStrategy||"SystemDefined",specificCostValue:e.specificCostValue||0,specificCostUnit:e.specificCostUnit||e.stdpackageunit,totalProductCost:e.totalProductCost||0,coveragePercent:e.coveragePercent||100,applicationCount:e.applicationCount||1,targetDateEpoch:e.targetDateEpoch||"",timingEvent:e.timingEvent||"",timingEventTag:e.timingEventTag||"",manufacturerName:e.manufacturer||"",productDensity:e.density||0,productName:e.name||"",shareOwnerInformation:{percentGrowerResponsibility:100,totalFromGrowerInventoryQuantity:100,totalFromGrowerInventoryUnit:""},stdfactor:e.stdfactor||1,stdpackageunit:e.stdpackageunit||"",stdunit:e.stdunit||"",currency:"USD",custom:e.custom}}(e,O)):j.includes("invoice")?H(function(e){return{productId:e.id||"",density:e.density,trackingId:e.trackingId||"",totalQuantityValue:e.totalQuantityValue||0,totalQuantityUnit:e.totalQuantityUnit||e.stdunit||"",totalCostValue:e.totalCostValue||0,totalCostCurrency:e.totalCostCurrency||"USD",timingEvent:e.timingEvent||"",timingEventTag:e.timingEventTag||"",productDensity:e.density||0,productName:e.name||"",custom:e.custom,manufacturerName:e.manufacturer||""}}(e)):(u.sendEventToAmplitude(u.events.epic.Tasks.addProduct),H(e)),U(!0)},toggleCreateCustomProductModal:Q,products:I,isLoading:D,setPageNo:L,hasNextPage:F}),(0===(null===I||void 0===I?void 0:I.length)||(null===C||void 0===C?void 0:C.length)<3)&&Object(y.jsx)(V_,{toggleCreateCustomProductModal:Q,productsLength:null===R||void 0===R?void 0:R.length,searchTextLength:C.length,isLoading:D})]})]})};vR.defaultProps={productFieldName:"products",selectedApplicationOption:void 0};var OR=vR,hR=function(){var e=Object(a.useState)(),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(!0),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useContext)(ac),d=Object(b.a)(l,2)[1];return Object(a.useEffect)((function(){J.a.get("".concat(u.i,"/products/search?productName="),{headers:{common:{Authorization:"Bearer ".concat(Ve())}}}).then((function(e){var t=Object(Ru.a)(e.data.items.filter((function(e){return"Active"===e.status}))).slice(0,100);r(t),s(!1)})).catch(Ae.default).catch((function(e){uc(d)(e),s(!1)}))}),[d]),{products:n,loading:o}};function xR(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;if(null!=e){var a=t?" ".concat(t):"";return"".concat(ee(FS.b.parseFloatRound(e,n),"fixed",n)).concat(a)}}function gR(e){if(e)return ee(FS.b.parseFloatRound(e,4),"percent",2)}var CR=function(e){if(e&&!Number.isFinite(e))try{e=new Z_.a(e).toNumber()}catch(t){return}return(0,Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format)(e)},yR=function(){return Object(y.jsxs)("svg",{width:"166",height:"128",viewBox:"0 0 166 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M74.6387 110.975H91.9899L105.595 127.164H88.2435L74.6387 110.975ZM79.9197 113.438L89.3846 124.701H100.314L90.8487 113.438H79.9197Z",fill:"#73DC78"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.455078 0.491623L34.8691 14.4748H131.131L165.545 0.494863V99.7757L145.062 108.181V127.161H45.0461L33.8786 113.231L0.455078 99.785V0.491623ZM37.1951 113.438L46.2219 124.698H140.465L131.421 113.438L37.1951 113.438ZM133.998 112.721L142.608 123.44V109.189L133.998 112.721ZM130.784 110.975V30.5715L48.7885 30.5715L48.7884 110.973L130.784 110.975ZM46.3335 110.972L46.3336 29.8323L35.8574 18.787V110.972L46.3335 110.972ZM33.4025 16.5363V110.386L2.90995 98.1188V4.14655L33.4025 16.5363ZM37.4925 16.9379L48.0874 28.1084L130.784 28.1084V16.9379H37.4925ZM133.239 16.2759V110.371L163.09 98.1219V4.14948L133.239 16.2759Z",fill:"#00004B"})]})},PR=function(){return Object(y.jsxs)("div",{id:"empty-products-display",className:"w-full h-full mt-24 flex flex-col items-center justify-center",children:[Object(y.jsx)(yR,{}),Object(y.jsx)("span",{className:"mt-6 text-xl",children:"Select a product from the list to add it to this invoice"})]})},AR=function(e){var t,n=e.removeProduct,r=e.noBlank,c=e.memberRole,i=e.memberFinancialAccess,o=e.setCustomProductCreated,s=e.customProductCreated,l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(null),f=Object(b.a)(p,2),v=f[0],O=f[1],h=Object(Zi.h)().values,x=Object(a.useState)(),g=Object(b.a)(x,1)[0],C=Object(a.useState)(null),P=Object(b.a)(C,2),A=P[0],S=P[1];Object(a.useEffect)((function(){var e;if((null===(e=h.invoiceProducts)||void 0===e?void 0:e.length)>0){var t=h.invoiceProducts.length-1,n=h.invoiceProducts[t];n.custom&&s&&(S(n),O(t),j(!0),o(!1))}}),[h.invoiceProducts,s]);var T=function(){},N=function(){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(m.Table.Cell,{sort:g,onClick:T,children:"Total Product"}),Object(y.jsx)(m.Table.Cell,{sort:g,onClick:T,children:"Unit Price"}),Object(y.jsx)(m.Table.Cell,{sort:g,onClick:T,children:"Total Price per Product"})]})};return Object(y.jsxs)("div",{"data-testid":"invoice-product-table",children:[A&&Object(y.jsx)(mR,{values:h,open:u,product:A,onClose:function(){j(!1),S(null)},isEdit:!0,rowIndex:v,memberRole:c,memberFinancialAccess:i}),null!==(t=h.invoiceProducts)&&void 0!==t&&t.length?function(){var e,t;return Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{sort:g,onClick:T,children:"Products (".concat(null===h||void 0===h||null===(e=h.invoiceProducts)||void 0===e?void 0:e.length,")")}),N(),Object(y.jsx)(m.Table.Cell,{})]}),null===h||void 0===h||null===(t=h.invoiceProducts)||void 0===t?void 0:t.map((function(e,t){return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"text-left",children:[Object(y.jsx)("div",{className:"font-bold",children:null===e||void 0===e?void 0:e.productName}),Object(y.jsx)("div",{className:"mt-2 text-neutral-300",children:null===e||void 0===e?void 0:e.manufacturerName})]})}),Object(y.jsx)(m.Table.Cell,{children:xR(null===e||void 0===e?void 0:e.totalQuantityValue,null===e||void 0===e?void 0:e.totalQuantityUnit)}),"Full control"!==c||"none"!==i&&"READ"!==i?Object(y.jsxs)(m.Table.Cell,{children:["$",(a=null===e||void 0===e?void 0:e.totalCostValue,r=null===e||void 0===e?void 0:e.totalQuantityValue,Number(Number.parseFloat(a)/Number.parseFloat(r)).toFixed(2)||1)]}):Object(y.jsx)(m.Table.Cell,{}),"Full control"!==c||"none"!==i&&"READ"!==i?Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"flex w-28 items-center justify-around",children:Object(y.jsxs)("div",{children:["$",(null===e||void 0===e?void 0:e.totalCostValue)||"0"]})})}):Object(y.jsx)(m.Table.Cell,{}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{"data-testid":"invoice-table-options-menu",children:Object(y.jsx)(Wo,{onAction:function(a){return function(e,t,a){switch(e){case"edit":O(a),S(t),j(!0);break;case"remove":n(a)}}(a,e,t)},options:As})})})]});var a,r}))]})}():Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(m.Table,{children:Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{sort:g,onClick:T,children:"Products(0)"}),N()]})}),r?Object(y.jsx)(y.Fragment,{}):Object(y.jsx)(PR,{})]})]})};AR.defaultProps={noBlank:!1};var SR=AR;var TR=function(e){var t=e.memberRole,n=e.memberFinancialAccess,r=hR(),c=r.products,i=r.loading,o=Object(Zi.h)(),s=o.values,l=o.setFieldValue,d=Object(a.useState)(null),u=Object(b.a)(d,2),j=u[0],p=(u[1],Object(a.useState)(!0)),f=Object(b.a)(p,2),v=f[0],O=f[1],h=Object(a.useState)(null===c||void 0===c?void 0:c.slice(0,2)),x=Object(b.a)(h,2)[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1];return Object(a.useEffect)((function(){x(null===c||void 0===c?void 0:c.slice(0,2))}),[c]),Object(y.jsx)(y.Fragment,{children:i?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{className:"flex justify-between h-full",children:[v?Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){O(!1)},children:j}):null,Object(y.jsx)("div",{className:"w-3/12",children:Object(y.jsx)(OR,{memberRole:t,memberFinancialAccess:n,setCustomProductCreated:A,productFieldName:"invoiceProducts"})}),Object(y.jsx)("div",{className:"ml-4 flex-grow",children:Object(y.jsx)(SR,{products:null===s||void 0===s?void 0:s.invoiceProducts,removeProduct:function(e){var t=Object(ne.cloneDeep)(null===s||void 0===s?void 0:s.invoiceProducts);t.splice(e,1),x(t),l("invoiceProducts",t)},memberRole:t,memberFinancialAccess:n,setCustomProductCreated:A,customProductCreated:P})})]})})},NR=Fu.e().shape({invoiceNumber:Fu.f().trim().required("Required"),invoiceDate:Fu.c().required("Required")}),ER=function(e){var t=Object(a.useContext)(ac),n=Object(b.a)(t,2)[1],r=Object(a.useState)(!!e),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(),p=Object(b.a)(j,2),f=p[0],m=p[1],v=Object(a.useState)(""),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useCallback)((function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e,a=arguments.length>1?arguments[1]:void 0,r=Nn.fetch(t),c=r.promise,i=r.cancel;return c.then((function(e){var t=e.data;m(t)})).catch(Ae.default).catch(uc(n,{showTryAgain:!!a})).finally((function(){o(!1)})),{promise:c,cancel:i}}),[n,e]);return{saving:d,error:h,saveInvoice:function(e){return u(!0),Nn.create(e).promise.catch(Ae.default).catch((function(e){var t,a,r,c;null!==(t=e.response)&&void 0!==t&&null!==(a=t.data)&&void 0!==a&&a.validationErrors?x("Error saving invoice: ".concat(e.response.data.message)):null!==(r=e.response)&&void 0!==r&&null!==(c=r.data)&&void 0!==c&&c.displayErrorMessage?x(e.response.data.displayErrorMessage):uc(n)(e)})).finally((function(){u(!1)}))},updateInvoice:function(e){return u(!0),Nn.update(e.id,e).promise.catch(Ae.default).catch((function(){return uc(n)})).finally((function(){u(!1)}))},fetchInvoice:g,setError:x,loading:i,invoice:f}},wR={invoiceNumber:"",vendor:"",invoiceDate:new Date(Date.now()),invoiceDueDate:"",cropSeason:JSON.parse(localStorage.getItem("selectedCropSeasons"))||[],notes:"",flagIds:[],invoiceProducts:[]},_R=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},a=Nn.createChildApi({action:"invoice/".concat(e)}),r=a.fetch(),c=r.promise;c.then((function(e){var a=e.data;if(a){var r,c,i,o=Object(I.a)(Object(I.a)({},a),{},{invoiceDate:new Date(null===a||void 0===a?void 0:a.invoiceDateEpoch),invoiceDueDate:new Date(null===a||void 0===a?void 0:a.invoiceDueDate),cropSeason:null===a||void 0===a||null===(r=a.cropSeasons)||void 0===r||null===(c=r[0])||void 0===c?void 0:c.seasonId,flagIds:null===(i=a.flagIds)||void 0===i?void 0:i.reduce((function(e,t){return"".concat(e,",").concat(t)}))});"01/01/1970"===(null===o||void 0===o?void 0:o.invoiceDueDate)&&(null===o||void 0===o||delete o.invoiceDueDate,null===o||void 0===o||delete o.invoiceDueDateEpoch),t(o)}n(!1)})).catch(Ae.default).catch((function(){n(!1)}))},RR=function(){var e=We().user,t=Object(p.j)().id,n=Object(a.useState)(wR),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(!0),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useContext)(ac),j=Object(b.a)(u,2)[1],f=Object(a.useState)(null),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)(!0),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(null),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)(JSON.parse(localStorage.getItem("selectedCropSeasons"))||null),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(p.h)(),V="";V=(null===t||void 0===t?void 0:t.length)>0?t:"invoice";var B="invoice"===t||!1,U=t===(null===c||void 0===c?void 0:c.id)||!1,z=ER(V),Z=z.saveInvoice,H=z.updateInvoice,W=z.error,q=z.setError,J=z.saving;Object(a.useEffect)((function(){_R(V,i,d)}),[j,V]);var K=Object(a.useCallback)(Object(Y.a)(G.a.mark((function t(){var n,a;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Jt.fetch(),a=n.promise,t.next=3,a.then((function(t){var n,a=t.data,r=null===a||void 0===a||null===(n=a.members)||void 0===n?void 0:n.filter((function(t){return t.email===e.email}))[0];N(r)})).catch(Ae.default).catch((function(e){uc(j)(e)}));case 3:case"end":return t.stop()}}),t)}))),[j,e.email]);Object(a.useEffect)((function(){T||K(),"Full control"!==(null===T||void 0===T?void 0:T.role)||Object.prototype.hasOwnProperty.call(T,"financialAccess")?R(null===T||void 0===T?void 0:T.financialAccess):R("none")}),[T,K]);var Q=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,i,o,s,l,d;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=Date.parse(null===t||void 0===t?void 0:t.invoiceDate),o=Date.parse(null===t||void 0===t?void 0:t.invoiceDueDate),s=L.map((function(e){return{seasonId:e,name:""}})),delete t.totalQuantityUnit,(null===t||void 0===t||null===(n=t.invoiceProducts)||void 0===n?void 0:n.length)>0&&t.invoiceProducts.forEach((function(e){delete e.manufacturerName})),delete(l=Object(I.a)(Object(I.a)({},t),{},{invoiceDueDateEpoch:o,invoiceDateEpoch:i,cropSeasons:s,flagIds:(null===t||void 0===t||null===(a=t.flagIds)||void 0===a?void 0:a.length)>0?null===t||void 0===t||null===(r=t.flagIds)||void 0===r?void 0:r.split(","):[]})).invoiceDate,delete l.invoiceDueDate,delete l.cropSeason,delete l.cropsSeasons,void 0===(null===t||void 0===t?void 0:t.id)&&delete l.id,d="",!((null===t||void 0===t||null===(c=t.id)||void 0===c?void 0:c.length)>0)){e.next=18;break}return e.next=15,H(l);case 15:d=e.sent,e.next=21;break;case 18:return e.next=20,Z(l);case 20:d=e.sent;case 21:d&&(h("Save Succeeded"),M.push(Cc.invoices));case 22:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"invoices",children:[Object(y.jsxs)(lo,{disabled:B||U,hideCropSeasonDropdown:!1,onCropSeasonSelect:function(){F(JSON.parse(localStorage.getItem("selectedCropSeasons"))||null)},children:[Object(y.jsx)(lo.Item,{title:"Invoices",value:"All Invoices",to:Cc.invoices}),Object(y.jsx)(lo.Item,{title:"Invoices",value:B?"Create Invoice":"Edit Invoice",isLast:!0})]}),l?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(y.Fragment,{children:[W&&Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){return q("")},children:W}),Object(y.jsx)(Zi.e,{initialValues:c,validationSchema:NR,onSubmit:Q,children:function(e){var t=e.submitForm;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(x_,{onSubmit:t,memberRole:null===T||void 0===T?void 0:T.role,memberFinancialAccess:_,isSaving:J}),l?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{"data-testid":"tabs-content",style:{height:"calc(100% - 58px)"},children:[C?Object(y.jsx)(m.Toast,{onClose:function(){P(!1)},children:O}):null,Object(y.jsx)("div",{className:"px-6 pt-4 -mx-4 bg-white",style:{height:"calc(100% - 16px)"},children:Object(y.jsxs)(m.Tabs,{children:[Object(y.jsx)(m.Tabs.Tab,{label:"Details",children:Object(y.jsx)(y_,{memberRole:null===T||void 0===T?void 0:T.role,memberFinancialAccess:_})}),Object(y.jsx)(m.Tabs.Tab,{label:"Products",children:Object(y.jsx)(TR,{memberRole:null===T||void 0===T?void 0:T.role,memberFinancialAccess:_})})]})})]})]})}})]})]})})},IR=function(){var e=Object(a.useContext)(we),t=Object(a.useContext)(ac),n=Object(b.a)(t,2),r=n[0].organization,c=n[1],i=dE().companies,o=hx(),s=o.downloadPDFV2,l=o.downloading,d=o.setDownloading,u=Object(a.useState)(),j=Object(b.a)(u,2),f=j[0],m=j[1],v=Object(O.usePDF)({document:Object(y.jsx)(O_,{invoice:f})}),h=Object(b.a)(v,2),x=h[0],g=h[1],C=Object(a.useRef)(void 0);Object(a.useEffect)((function(){f&&g()}),[f]),Object(a.useEffect)((function(){!x.loading&&x.url&&C.current!==x.url&&f&&(C.current=x.url,s(C.current,"Invoice - ".concat(f.title,".pdf")),m(null))}),[x]);var P=Object(a.useState)({open:!1,id:null}),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)([]),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(!1),D=Object(b.a)(R,2),k=D[0],L=D[1],F=Object(a.useState)({id:"",title:""}),M=Object(b.a)(F,2),V=M[0],B=M[1],U=Object(a.useState)(wR),z=Object(b.a)(U,2),Z=z[0],H=z[1],W=Object(p.h)(),q=function(e){W.push("".concat(Cc.invoices,"/").concat(e.invoiceId,"/view"))},J=function(e){W.push({pathname:"".concat(Cc.invoices,"/").concat(e.invoiceId),invoiceID:e.invoiceId})},K=function(e){T({id:e.invoiceId,open:!0})},Q=function(e){_(e.flags?e.flags.reduce((function(e,t){var n=t.id;return"".concat(e,",").concat(n)}),""):""),B({id:e.invoiceId,title:e.title}),L(!0),_R(e.invoiceId,H)},X=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Nn.fetch(t),a=n.promise,e.next=3,a.then((function(e){return e.data.invoiceProducts})).catch(Ae.default).catch((function(e){return uc(c)(e),[]}));case 3:return r=e.sent,e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ee=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=ae.a.cloneDeep(Cm)).applicationStrategy=Om[1].key,a=t.invoiceProducts){e.next=7;break}return e.next=6,X(t.invoiceId);case 6:a=e.sent;case 7:return r=a.map((function(e){var t=FS.b.divideSafeRound(e.totalCostValue,e.totalQuantityValueInStandardPackageUnit);return $(Object(I.a)(Object(I.a)({},e),{},{specificCostValue:t,totalProductValue:e.totalQuantityValue,totalProductUnit:e.totalQuantityUnit,totalProductCost:e.totalCostValue,productRateUnit:e.totalQuantityUnit,specificCostUnit:e.productStandardPackageUnit}))})),c=new Date(t.invoiceDate),n.products=r,n.source=t.invoiceId,n.startDate=c,n.dueDate=Object(d_.a)(c,2),n.authorizedDate=c,n.properties=[],e.abrupt("return",n);case 16:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),te=function(){var t=Object(Y.a)(G.a.mark((function t(n){var a;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return c({type:pr,payload:!0}),t.next=3,ee(n);case 3:a=t.sent,c({type:pr,payload:!1}),c({type:"SET_CONVERT_PLAN",payload:a}),jc(c,"SET_TASK_CREATION_FROM",e.events.epic.Tasks.pages.fromInvoice),e.sendEventToAmplitude(e.events.epic.Tasks.createTask,{page:e.events.epic.Tasks.pages.fromInvoice}),W.push("".concat(Cc.tasks,"/convert"));case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),ne=function(e){var t,n="--";(null===i||void 0===i?void 0:i.length)>0&&""!==e&&(n=null===(t=i.find((function(t){return t.id===e})))||void 0===t?void 0:t.name);return n||"--"},re=Object(p.j)().id,ce=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,c,i,o,s,l,u;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d(!0),n=ne(t.vendor),a=new Date,c=Object(ya.a)(a,"yyyy"),i=Object(ya.a)(a,"MM/dd/yyyy h:mm aaa"),e.next=7,X(t.invoiceId);case 7:if(o=e.sent,s=f_(o),l=Object(I.a)(Object(I.a)({},t),{},{vendorName:n,year:c,fullDate:i,organizationName:r.name,mappedInvoiceProductEntries:s}),re){e.next=18;break}return e.next=13,Nn.fetch(t.invoiceId);case 13:u=e.sent,u.promise.then((function(e){var t=e.data;if(t){var n=t.notes;m(Object(I.a)(Object(I.a)({},l),{},{notes:n}))}})).catch(Ae.default),e.next=19;break;case 18:m(Object(I.a)({},l));case 19:d(!1);case 20:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{handleAction:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;n&&r(a);var c={view:q,edit:J,delete:K,createTask:te,shareOrPrint:function(){return ce(t)},tag:Q,duplicate:function(){}};c[e](t)},deleteModalState:S,invoiceTags:w,openTags:k,selectedInvoiceTitleAndId:V,selectedInvoiceData:Z,setOpenTags:L,setInvoiceTags:_,setDeleteModalState:T,shareOrPrint:ce,downloadingPDF:l}},DR=function(e){var t=(null===e||void 0===e?void 0:e.map((function(e){return e.name})))||[];return 0===t.length?"N/A":t.join(", ")},kR=function(e){var t=e.cost,n=e.memberRole,a=e.memberFinancialAccess;return("Full control"!==n&&"View Only"!==n||"none"!==a)&&("Admin"===n||"View Only"===n||"Full control"===n&&"WRITE"===a||"Full control"===n&&"READ"===a)?CR(t):""},LR=function(e){var t=e.invoices,n=e.setReRenderInvoices,r=e.memberRole,c=e.memberFinancialAccess,i=e.pageNo,o=e.onDelete,s=e.onPageChange,l=e.totalInvoices,d=Object(a.useContext)(ac),u=Object(b.a)(d,2)[1],j=Object(a.useState)(null),p=Object(b.a)(j,2)[1],f=IR(),v=f.handleAction,O=f.deleteModalState,h=f.invoiceTags,x=f.openTags,g=f.selectedInvoiceTitleAndId,C=f.selectedInvoiceData,P=f.setOpenTags,A=f.setInvoiceTags,S=f.setDeleteModalState,T=f.downloadingPDF,N=Object(a.useState)(-1),E=Object(b.a)(N,2),w=E[0],_=E[1];Object(a.useEffect)((function(){T||_(-1)}),[T]);var R=function(){var e=Object(Y.a)(G.a.mark((function e(t){var a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n(!1),P(!1),delete(a=Object(I.a)(Object(I.a)({},C),{},{flagIds:t.map((function(e){return e.id}))})).invoiceDate,delete a.invoiceDueDate,delete a.cropSeason,e.next=8,Nn.update(C.id,a);case 8:return r=e.sent,c=r.promise,e.next=12,c.then((function(){A(t),n(!0)})).catch(Ae.default).catch((function(e){var t,n,a,r;null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.validationErrors?p("Error saving task: ".concat(e.response.data.message)):null!==(a=e.response)&&void 0!==a&&null!==(r=a.data)&&void 0!==r&&r.displayErrorMessage?p(e.response.data.displayErrorMessage):uc(u)(e)}));case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),D=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o(O.id),S({open:!1,id:null});case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{"data-testid":"invoice-tileboard",children:[Object(y.jsx)(ib,{open:O.open,itemType:"Invoice",onCancel:function(){return S({open:!1,id:null})},onDelete:D}),Object(y.jsx)(l_,{open:x,close:function(){return P(!1)},name:g.title,selectedTags:h,returnSelectedTags:R}),Object(y.jsxs)(ll,{children:[Ho(l,i,s),Object(y.jsx)(Xd,{title:"Cropwise Financials Invoices",totalItems:t.length,testId:"invoices-board-title",children:Object(y.jsx)("div",{className:"flex flex-wrap w-full",children:null!==t&&void 0!==t&&t.length?t.map((function(e,t){var n,a;return Object(y.jsxs)(lu,{title:e.title,linkTo:"".concat(Cc.invoices,"/").concat(e.invoiceId,"/view"),subtitle:e.invoiceDate?zd(e.invoiceDateEpoch):"N/A",onAction:function(n){v(n,e,!0,t,_)},menuItems:Os,testId:"invoice",runningProcesses:T&&w===t,children:[Object(y.jsx)("div",{className:"flex flex-wrap w-full mt-2 mb-2",children:(null===e||void 0===e?void 0:e.flags)&&Object(y.jsx)(m.TagCloud,{children:null===e||void 0===e||null===(n=e.flags)||void 0===n?void 0:n.map((function(e){return Object(y.jsx)(m.Tag,{color:e.color,children:e.name},e.id)}))})}),Object(y.jsxs)("div",{className:"flex flex-wrap w-full",children:[Object(y.jsx)(uu,{title:"Due Date",value:e.invoiceDueDate?zd(e.invoiceDueDateEpoch):"N/A"}),Object(y.jsx)(uu,{title:"Total Invoice Cost",value:(a=null===e||void 0===e?void 0:e.totalCost,kR({cost:a,memberRole:r,memberFinancialAccess:c}))}),Object(y.jsx)(uu,{title:"Product Count",value:(null===e||void 0===e?void 0:e.productCount)||0}),Object(y.jsx)(uu,{title:"Season(s)",value:DR(null===e||void 0===e?void 0:e.cropSeasons)})]})]},e.invoiceId)})):""})},null),Object(y.jsx)("div",{style:{minHeight:"35px"},children:Ho(l,i,s)})]})]})})};LR.defaultProps={invoices:[]};var FR=LR,MR=function(e){var t=e.invoice,n=e.onAction,a=e.getTotInvCostValue,r=e.menuOptions,c=e.runningProcesses;return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex flex-col items-start text-sm font-bold",children:[Object(y.jsx)(j.b,{to:"".concat(Cc.invoices,"/").concat(t.invoiceId,"/view"),children:null===t||void 0===t?void 0:t.title}),Object(y.jsx)("div",{className:"flex flex-wrap w-full mt-2 mb-2",children:t.flags&&t.flags.map((function(e){return Object(y.jsx)("div",{className:"border rounded pl-1 pr-1 mr-2",style:{backgroundColor:e.color,color:"#FFFFFF"},children:e.name})}))})]})}),Object(y.jsx)(m.Table.Cell,{children:t.invoiceDate?zd(t.invoiceDateEpoch):"N/A"}),Object(y.jsx)(m.Table.Cell,{children:t.invoiceDueDate?zd(t.invoiceDueDateEpoch):"N/A"}),Object(y.jsx)(m.Table.Cell,{children:a(null===t||void 0===t?void 0:t.totalCost)}),Object(y.jsx)(m.Table.Cell,{children:(null===t||void 0===t?void 0:t.productCount)||"0"}),Object(y.jsxs)(m.Table.Cell,{children:[DR(null===t||void 0===t?void 0:t.cropSeasons),Object(y.jsx)("div",{"data-testid":"invoice-table-options-menu",className:"absolute right-0 flex-none w-10 mr-2",children:c?Object(y.jsx)(m.Spinner,{size:"sm"}):Object(y.jsx)(Wo,{onAction:n,options:r})})]})]},null===t||void 0===t?void 0:t.invoiceId)},VR=function(e){var t=e.invoices,n=e.onDelete,r=e.setReRenderInvoices,c=e.memberRole,i=e.memberFinancialAccess,o=e.pageNo,s=e.onPageChange,l=e.totalInvoices,d=e.sortBy,u=e.sortDir,j=e.onSort,p=IR(),f=p.handleAction,m=p.deleteModalState,v=p.invoiceTags,O=p.openTags,h=p.selectedInvoiceTitleAndId,x=p.selectedInvoiceData,g=p.setOpenTags,C=p.setInvoiceTags,P=p.setDeleteModalState,A=p.downloadingPDF,S=Object(a.useContext)(ac),T=Object(b.a)(S,2)[1],N=Object(a.useState)(null),E=Object(b.a)(N,2)[1],w=Object(a.useState)(-1),_=Object(b.a)(w,2),R=_[0],D=_[1],k=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r(!1),g(!1),delete(n=Object(I.a)(Object(I.a)({},x),{},{flagIds:t.map((function(e){return e.id}))})).invoiceDate,delete n.invoiceDueDate,delete n.cropSeason,e.next=8,Nn.update(x.id,n);case 8:return a=e.sent,c=a.promise,e.next=12,c.then((function(){C(t),r(!0)})).catch(Ae.default).catch((function(e){var t,n,a,r;null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.validationErrors?E("Error saving task: ".concat(e.response.data.message)):null!==(a=e.response)&&void 0!==a&&null!==(r=a.data)&&void 0!==r&&r.displayErrorMessage?E(e.response.data.displayErrorMessage):uc(T)(e)}));case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),L=function(e){return kR({cost:e,memberRole:c,memberFinancialAccess:i})};return Object(y.jsx)("div",{className:"min-w-content","data-testid":"invoices-table",style:{minWidth:"min-content"},children:Object(y.jsxs)(ll,{children:[Object(y.jsx)(ib,{open:m.open,itemType:"Invoice",onCancel:function(){return P({open:!1,id:null})},onDelete:function(){n(m.id),P({open:!1,id:null})}}),Object(y.jsx)(l_,{open:O,close:function(){return g(!1)},name:h.title,selectedTags:v,returnSelectedTags:k}),Ho(l,o,s),Object(y.jsx)(ol,{listType:"invoices",routePath:Cc.invoices,items:t,tableColumns:Ww,onSort:j,sortBy:d,sortDir:u,children:function(e){return e.rows.map((function(e,t){return Object(y.jsx)(MR,{onAction:function(n){f(n,e,!0,t,D)},menuOptions:Os,invoice:e,getTotInvCostValue:L,runningProcesses:A&&R===t},e.invoiceId)}))}}),Object(y.jsx)("div",{className:"pb-12",children:Ho(l,o,s)})]})})};VR.defaultProps={invoices:[]};var BR=VR,UR=function(e){var t=e.hasPermission,n=Object(p.h)();return Object(y.jsx)(Vd,{buttonText:"Create Invoice",onClick:function(e){e.stopPropagation(),n.push("".concat(Cc.invoices,"/invoice"))},subtitle:"We were unable to find any invoices under this organization.",setPermission:t})},zR=Sd(vd,Xw),ZR=function(){var e,t,n=Object(a.useRef)(!0),r=Object(p.j)(),c=r.id,i=r.view,o=Object(a.useRef)(i),s=Object(a.useContext)(ac),l=Object(b.a)(s,2),d=l[0].loggedInUserOrgPermission,u=d.role,j=d.financialAccess,f=void 0===j?"none":j,v=l[1],O=Object(p.h)(),h=Object(a.useState)(""),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useState)([]),A=Object(b.a)(P,2)[1],S=Object(a.useState)(),T=Object(b.a)(S,2),N=T[0],E=(T[1],Object(a.useState)(null)),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)(!0),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)([]),V=Object(b.a)(M,2),B=V[0],U=V[1],z=Object(a.useState)("--"),Z=Object(b.a)(z,2),H=Z[0],W=Z[1],q=Object(a.useState)(null),J=Object(b.a)(q,2)[1],K=Object(a.useState)(!1),Q=Object(b.a)(K,2),X=Q[0],$=Q[1],ee=dd().cropSeasons,te=dE().companies,ne=IR(),ae=ne.handleAction,re=ne.deleteModalState,ce=ne.openTags,ie=ne.selectedInvoiceTitleAndId,oe=ne.setOpenTags,se=ne.setDeleteModalState,le=ne.downloadingPDF;Object(a.useEffect)((function(){return function(){n.current=!1}}),[]),Object(a.useLayoutEffect)((function(){!L&&"print"===o.current&&X&&(o.current=null,ae("shareOrPrint",Object(I.a)(Object(I.a)({},_),{},{invoiceId:_.id,title:_.invoiceNumber,flags:_.flagIds,invoiceProducts:_.invoiceProducts})))}),[L,X]),Object(a.useEffect)((function(){le||o.current||window.close()}),[le]);var de=function(e){return"Full control"===u&&"none"===f||"View Only"===u&&"none"===f?"":"Admin"===u||"View Only"===u||"Full control"===u&&"WRITE"===f||"Full control"===u&&"READ"===f?(X||$(!0),xR(e)):""},ue={year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"},be=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Gt.fetch(),a=n.promise,e.next=3,a.then((function(e){var n=e.data.results.filter((function(e){var n;return null===t||void 0===t||null===(n=t.flagIds)||void 0===n?void 0:n.includes(e.id)}));A(n),U(n||[])})).catch(Ae.default).catch((function(e){uc(e)}));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),je=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],null===t||void 0===t||t.map((function(e){return n.push(e.id)})),a=Object(I.a)(Object(I.a)({},_),{},{flagIds:n}),r=Nn.update(_.id,a),c=r.promise,e.next=6,c.then((function(){U(t)})).catch(Ae.default).catch((function(e){var t,n,a,r;null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.validationErrors?J("Error saving task: ".concat(e.response.data.message)):null!==(a=e.response)&&void 0!==a&&null!==(r=a.data)&&void 0!==r&&r.displayErrorMessage?J(e.response.data.displayErrorMessage):uc(v)(e)}));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();Object(a.useEffect)((function(){Nn.createChildApi({action:"invoice/".concat(c)}).fetch().promise.then((function(e){var t=e.data;if(n.current){var a;if(R(t),be(t),C(function(e){var t,n=[];return null===e||void 0===e||null===(t=e.cropSeasons)||void 0===t||t.forEach((function(e){return n.push(e.name)})),n}(t)),(null===te||void 0===te?void 0:te.length)>0&&""!==t.vendor)W(null===(a=te.filter((function(e){return e.id===t.vendor}))[0])||void 0===a?void 0:a.name);F(!1)}})).catch(Ae.default).catch((function(e){uc(v)(e),F(!1)}))}),[ee,te,v,c]);return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(lo,{onOrganizationSelect:function(){O.push("/app/invoices")},disabled:!0,children:[Object(y.jsx)(lo.Item,{title:"Invoices",value:"All Invoices",to:Cc.invoices}),Object(y.jsx)(lo.Item,{title:"Invoices",value:null===_||void 0===_?void 0:_.invoiceNumber,isLast:!0,"data-testid":"Invoices"})]}),L||le?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{id:"invoice-view",children:[Object(y.jsx)("div",{className:"mt-3",children:Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsxs)("div",{className:"flex justify-between w-1/2 mr-16",children:[Object(y.jsx)(Fl,{className:"mx-4",header:"Invoice Date",data:(null===_||void 0===_?void 0:_.invoiceDateEpoch)>0?new Date(null===_||void 0===_?void 0:_.invoiceDateEpoch).toLocaleString("en-us",{year:"numeric",month:"short",day:"numeric"}):"--",testId:"invoiceDate"}),Object(y.jsx)(Fl,{className:"mx-4",header:"Total Products",data:null===_||void 0===_||null===(e=_.invoiceProducts)||void 0===e?void 0:e.length,testId:"totalProducts"}),Object(y.jsx)(Fl,{className:"mx-4",header:"Total Cost",data:de(null===_||void 0===_||null===(t=_.invoiceProducts)||void 0===t?void 0:t.reduce((function(e,t){return e+t.totalCostValue}),0)),testId:"totalCost"})]}),Object(y.jsx)("div",{className:"flex self-center mr-6","data-html2canvas-ignore":!0,children:Object(y.jsx)(Wo,{onAction:function(e){return ae(e,Object(I.a)(Object(I.a)({},_),{},{invoiceId:_.id,title:_.invoiceNumber,flags:_.flagIds,invoiceProducts:_.invoiceProducts}))},options:Ns})})]})}),Object(y.jsx)(ib,{open:re.open,itemType:"Invoice",onCancel:function(){return se({open:!1,id:null})},onDelete:function(){Nn.delete(_.id).promise.then((function(){O.push(Cc.invoices)})).catch(Ae.default).catch((function(e){uc(v)(e)})),se({open:!1,id:null})}}),Object(y.jsx)(l_,{open:ce,close:function(){return oe(!1)},name:ie.title,selectedTags:null===B||void 0===B?void 0:B.reduce((function(e,t){return"".concat(e,",").concat(t.id)}),""),returnSelectedTags:je}),Object(y.jsxs)(Kv.a,{className:"mt-6",children:[Object(y.jsx)("div",{className:"flex py-5 ml-4",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsxs)(m.Column,{width:"w-full",children:[Object(y.jsx)("div",{className:"text-2xl font-bold ml-4",children:"Invoice Details"}),Object(y.jsx)(Fl,{className:"mx-4 mt-4",header:"Invoice Name/Number",data:null===_||void 0===_?void 0:_.invoiceNumber,testId:"invNumber"})]})}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsx)(m.Column,{width:"w-120",children:Object(y.jsx)(Fl,{className:"mx-4 mt-4",header:"Invoice Date",data:(null===_||void 0===_?void 0:_.invoiceDateEpoch)>0?new Date(null===_||void 0===_?void 0:_.invoiceDateEpoch).toLocaleString("en-us",ue):"--",testId:"invDate"})}),Object(y.jsx)(m.Column,{width:"w-56",children:Object(y.jsx)("div",{className:"flex items-center w-full h-full mt-4",children:Object(y.jsx)("svg",{width:"53",height:"16",viewBox:"0 0 53 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M52.7071 8.7071C53.0976 8.31658 53.0976 7.68341 52.7071 7.29289L46.3431 0.928928C45.9526 0.538404 45.3195 0.538404 44.9289 0.928928C44.5384 1.31945 44.5384 1.95262 44.9289 2.34314L50.5858 8L44.9289 13.6569C44.5384 14.0474 44.5384 14.6805 44.9289 15.0711C45.3195 15.4616 45.9526 15.4616 46.3431 15.0711L52.7071 8.7071ZM8.74228e-08 9L52 9L52 7L-8.74228e-08 7L8.74228e-08 9Z",fill:"#696F88"})})})}),Object(y.jsx)(m.Column,{width:"w-120",children:Object(y.jsx)(Fl,{className:"mx-4 mt-4",header:"Due Date",data:(null===_||void 0===_?void 0:_.invoiceDueDateEpoch)>0?new Date(null===_||void 0===_?void 0:_.invoiceDueDateEpoch).toLocaleString("en-us",ue):"--",testId:"invDate"})})]}),Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsx)(Fl,{className:"mx-4 mt-4",header:"Company",data:H,testId:"vendorName"})})}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsxs)(m.Column,{width:"w-120",children:[Object(y.jsx)(Fl,{className:"mx-4 mt-4",header:"Crop Season"}),Object(y.jsx)("div",{className:"ml-3 mt-2",children:g&&Object(y.jsx)(m.TagCloud,{children:null===g||void 0===g?void 0:g.map((function(e){return Object(y.jsx)(m.Tag,{children:e})}))})})]}),Object(y.jsxs)(m.Column,{width:"w-full",children:[Object(y.jsx)(Fl,{className:"mx-4 mt-4",header:"Tags"}),Object(y.jsx)("div",{className:"ml-3 mt-2",children:(null===B||void 0===B?void 0:B.length)>0&&Object(y.jsx)(m.TagCloud,{children:null===B||void 0===B?void 0:B.map((function(e){return Object(y.jsx)(m.Tag,{color:e.color,children:e.name},e.id)}))})})]})]})]})}),Object(y.jsx)("div",{className:"mt-12 py-6 border-t ml-6 mr-6",id:"invoice-pagebreaker-1",children:Object(y.jsxs)("div",{className:"mt-12",children:[Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Products & Services"}),Object(y.jsx)("div",{className:"mt-12",children:(null===_||void 0===_?void 0:_.invoiceProducts)&&function(){var e,t,n=function(){};return Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsxs)(m.Table.Cell,{sort:N,onClick:n,children:["Product Name (",null===_||void 0===_||null===(e=_.invoiceProducts)||void 0===e?void 0:e.length,")"]}),Object(y.jsx)(m.Table.Cell,{sort:N,onClick:n,children:"Total Product"}),Object(y.jsx)(m.Table.Cell,{sort:N,onClick:n,children:"Unit Price"}),Object(y.jsx)(m.Table.Cell,{sort:N,onClick:n,children:"Total Price per Product"})]}),null===_||void 0===_||null===(t=_.invoiceProducts)||void 0===t?void 0:t.map((function(e){return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:e.productName}),Object(y.jsx)(m.Table.Cell,{children:xR(e.totalQuantityValue,Object(va.g)(null===e||void 0===e?void 0:e.totalQuantityUnit))}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:e.totalCostValue/e.totalQuantityValue})}),Object(y.jsx)(m.Table.Cell,{children:de(e.totalCostValue)})]})}))]})}()})]})}),Object(y.jsxs)("div",{className:"mt-6 py-4 ml-6 mr-4",children:[Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Notes"}),Object(y.jsx)("div",{className:"mt-3 border p-4 h-64 mb-8 overflow-y-scroll",children:null===_||void 0===_?void 0:_.notes})]})]})]})]})},YR=[{id:"invoices",key:"invoices",path:Cc.invoices,exact:!0,secure:!0,disabled:!1,component:function(){var e=zR.get(),t=Object(p.h)(),n=Object(a.useContext)(ac),r=Object(b.a)(n,2),c=r[0],i=c.loggedInUserOrgPermission,o=c.loadingOrg,s=c.isGlobalCropSeasonLoading,l=r[1],d=Object(a.useState)(void 0!==i),u=Object(b.a)(d,2),j=u[0],f=u[1],v=Object(a.useState)(null!==e&&void 0!==e?e:Xw),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)(!0),_=Object(b.a)(w,2),R=_[0],D=_[1],k=Object(a.useState)(0),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Object(a.useState)({}),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=Object(a.useState)(Jw),Y=Object(b.a)(Z,2),H=Y[0],G=Y[1],W=Object(a.useState)(qw),q=Object(b.a)(W,2),J=q[0],K=q[1],Q=Object(a.useState)(),X=Object(b.a)(Q,2),$=X[0],ee=X[1],te=zi($,500),ae=e_(),re=ae.invoices,ce=ae.fetchInvoices,ie=Object(a.useRef)(),oe=Object(a.useRef)();Object(a.useEffect)((function(){var e,t,n=JSON.stringify(U),a=(te!==ie.current||n!==oe.current)&&0!==F;ie.current=te,oe.current=n,ce({pageNo:a?0:F,searchBy:te,cropSeasonIds:JSON.parse(localStorage.getItem("selectedCropSeasons")),startDate:null===U||void 0===U||null===(e=U.daterange)||void 0===e?void 0:e[0],endDate:null===U||void 0===U||null===(t=U.daterange)||void 0===t?void 0:t[1],sortDir:H,sortBy:J}),a&&M(0)}),[ce,F,te,U,H,J]),Object(a.useEffect)((function(){var e=new URLSearchParams(location.search),t=e.get("search"),n=e.get("filters");n&&z(JSON.parse(n)),t&&ee(t)}),[]),Object(a.useEffect)((function(){!function(){var e=new URLSearchParams;te&&e.set("search",te),Object.keys(U).length&&e.set("filters",JSON.stringify(U)),t.replace({search:e.toString()})}()}),[te,t,U]),Object(a.useEffect)((function(){Object(ne.isEmpty)(i)?f(!1):f(!0),"Full control"!==(null===i||void 0===i?void 0:i.role)&&"View Only"!==(null===i||void 0===i?void 0:i.role)||Object.prototype.hasOwnProperty.call(i,"financialAccess")?E(null===i||void 0===i?void 0:i.financialAccess):E("none")}),[i]),Object(a.useEffect)((function(){P&&(ce({cropSeasonIds:JSON.parse(localStorage.getItem("selectedCropSeasons"))}),A(!1))}),[P,ce]);var se=Object(a.useCallback)((function(e,t){K(e),G(t)}),[]),le=Object(a.useCallback)((function(e){var t=e.target.value;z((function(e){return 2===t.length?Object(I.a)(Object(I.a)({},e),{},{daterange:t}):0===t.length?Object(I.a)(Object(I.a)({},e),{},{daterange:[]}):e}))}),[]),de=function(e){Nn.delete(e).promise.then((function(){A(!0)})).catch(Ae.default).catch((function(e){uc(l)(e)}))},ue=function(){var e,t=null===i||void 0===i||null===(e=i.role)||void 0===e?void 0:e.toLowerCase();return("full control"===t||"admin"===t)&&"WRITE"===nr};return Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"invoices",children:[Object(y.jsx)(lo,{onOrganizationSelect:function(){return A(!0)},hideCropSeasonDropdown:!1,onCropSeasonSelect:function(){return A(!0)},children:Object(y.jsx)(lo.Item,{title:"Invoices",value:"All Invoices",isLast:!0})}),location&&location.state&&location.state.toastRenderContents&&R?Object(y.jsx)(m.Toast,{isError:!1,onClose:function(){D(!1)},children:location.state.toastRenderContents}):null,o||!j||s?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex items-center justify-between",children:[Object(y.jsx)(To,{id:"invoice-search-input",name:"search_invoices",placeholder:"Search name",showCropSeason:!1,onChange:function(e){ee(e.target.value)},onChangeLabel:ne.noop,onChangeProductType:ne.noop,onChangeTaskType:ne.noop,onDateRangeChange:le}),Object(y.jsxs)("div",{className:"flex items-center gap-4",children:[Object(y.jsx)(Rd,{testId:"invoices-view-toggle",view:h,changeView:function(e){x(e),zR.save(e)}}),Object(y.jsx)(t_,{hasPermission:ue})]})]}),Object(y.jsx)("div",{children:re.isLoading?Object(y.jsx)(m.Spinner,{}):0===(null===re||void 0===re?void 0:re.numberOfElements)?Object(y.jsx)(UR,{hasPermission:ue}):"tile"===h?Object(y.jsx)(FR,{invoices:re.data,setReRenderInvoices:A,memberRole:null===i||void 0===i?void 0:i.role,memberFinancialAccess:N,pageNo:F,totalInvoices:null===re||void 0===re?void 0:re.totalElements,onDelete:de,onPageChange:M}):Object(y.jsx)(BR,{invoices:re.data,setReRenderInvoices:A,memberRole:null===i||void 0===i?void 0:i.role,memberFinancialAccess:N,pageNo:F,totalInvoices:null===re||void 0===re?void 0:re.totalElements,sortDir:H,sortBy:J,onDelete:de,onPageChange:M,onSort:se})})]})]})},icon:Jl,nav:"leftNav"},{id:"invoice",key:"invoice",path:"".concat(Cc.invoices,"/:id"),exact:!0,secure:!0,disabled:!1,component:RR,minPermissions:{minAllowedRole:$a}},{id:"invoiceView",key:"invoiceView",path:"".concat(Cc.invoices,"/:id/:view"),exact:!0,secure:!0,component:ZR}],HR=function(e,t){return e.localeCompare(t,void 0,{sensitivity:"accent"})},GR=function(e){var t;return null!==(t=null===e||void 0===e?void 0:e.name)&&void 0!==t?t:null===e||void 0===e?void 0:e.productName},WR=function(e){var t;return null!==(t=null===e||void 0===e?void 0:e.manufacturer)&&void 0!==t?t:null===e||void 0===e?void 0:e.manufacturerName},qR=function(e,t){var n=t.toLowerCase(),a={category1:[],category2:[],category3:[],category4:[]};e.forEach((function(e){var t=GR(e).toLowerCase(),r=WR(e).toLowerCase();t.startsWith(n)?a.category1.push(e):t.includes(n)?a.category2.push(e):r.startsWith(n)?a.category3.push(e):r.includes(n)&&a.category4.push(e)}));var r=[a.category1.slice().sort((function(e,t){return HR(GR(e),GR(t))})),a.category2.slice().sort((function(e,t){return HR(GR(e),GR(t))})),a.category3.slice().sort((function(e,t){return HR(WR(e),WR(t))})),a.category4.slice().sort((function(e,t){return HR(WR(e),WR(t))}))];return ae.a.flatMap(r)},JR=function(e){var t,n,r=Object(a.useRef)(0),c=Object(a.useContext)(ac),i=Object(b.a)(c,2),o=i[0].organization,s=i[1],l=null===ac||void 0===ac||null===(t=ac._currentValue[0])||void 0===t||null===(n=t.organization)||void 0===n?void 0:n.id,d=Object(a.useState)([]),j=Object(b.a)(d,2),p=j[0],f=j[1],m=Object(a.useState)(!1),v=Object(b.a)(m,2),O=v[0],h=v[1],x=Object(a.useState)([]),g=Object(b.a)(x,2),C=g[0],y=g[1],P=Object(a.useState)(!1),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)(0),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(0),D=Object(b.a)(R,2),k=D[0],L=D[1],F=Object(a.useState)(Object(I.a)({pageNo:k,size:wo},e)),M=Object(b.a)(F,2),V=M[0],B=M[1],U=Object(a.useState)(null),z=Object(b.a)(U,2),Z=z[0],H=z[1],W=[],q=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,c,i;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T(!0),r.current+=1,n=r.current,a=Object(I.a)(Object(I.a)({},V),t),e.next=6,Rn.fetch(void 0,a);case 6:return c=e.sent,i=c.promise,e.next=10,i.then((function(e){var t=e.data;if(r.current===n){var c;if(null!==a&&void 0!==a&&null!==(c=a.searchBy)&&void 0!==c&&c.length)return y(qR(t.results,null===a||void 0===a?void 0:a.searchBy,W)),void _(t.totalElements);y(t.results),_(t.totalElements)}})).catch(Ae.default).catch((function(e){uc(s)(e)})).finally((function(){T(!1)}));case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[V,s,T]),K=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h(!0),t=J.a.get("".concat(u.d,"/v1/inventory/products"),{headers:{"cwf-context":JSON.stringify({organization_id:l}),Authorization:"Bearer ".concat(Ve())},params:{size:-1}}),e.next=4,t.then((function(e){var t=e.data;f(t.results)})).catch(Ae.default).catch((function(e){uc(s)(e)})).finally((function(){h(!1)}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Q=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T(!0),e.next=3,In.fetch(t);case 3:return n=e.sent,a=n.promise,e.next=7,a.then((function(e){var t=e.data;H(t)})).catch(Ae.default).catch((function(e){uc(s)(e)})).finally((function(){T(!1)}));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),X=Object(a.useCallback)(Object(Y.a)(G.a.mark((function t(){return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:q(e);case 1:case"end":return t.stop()}}),t)}))),[q]);Object(a.useEffect)((function(){X()}),[X,V,o]);var $=Object(a.useCallback)((function(e){B((function(t){return Object(I.a)(Object(I.a)({},t),{},{pageNo:0,searchBy:e})}))}),[B]),ee=Object(a.useCallback)((function(e,t){L(e),B((function(n){return Object(I.a)(Object(I.a)(Object(I.a)({},n),t),{},{pageNo:e})}))}),[B]),te=Object(a.useCallback)((function(e,t){B((function(n){return Object(I.a)(Object(I.a)({},n),{},{pageNo:0,sortBy:e,sortDir:t})}))}),[B]);return{getProducts:q,products:C,productsCount:w,pageNo:V.pageNo,goToPage:ee,isLoading:S,reset:function(){B(Object(I.a)(Object(I.a)({},V),{},{pageNo:k,totalPages:0,size:wo}))},reload:X,filterByNameQuery:$,sort:te,sortBy:V.sortBy,sortDir:V.sortDir,getAllUseProducts:K,allProducts:p,isLoadingAllProducts:O,getProduct:Q,selectedProduct:Z}},KR=function(e,t){var n=t.reduce((function(t,n){var a=e.some((function(e){return e.productId===n.id}));return a||t.push(Object(I.a)(Object(I.a)({},n),{},{productName:n.name,productType:n.type.replace(/ /gi,""),manufacturerName:n.manufacturer})),t}),[]);return e.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{type:e.productType.toUpperCase()})})).concat(n)},QR=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=U_("inventory/products"),n=Object(a.useContext)(ac),r=Object(b.a)(n,2),c=r[1],i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(!0),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(0),m=Object(b.a)(f,2),v=m[0],O=m[1],h=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=localStorage.getItem("selectedOrganizationId"),e.next=3,Ht.fetch(n);case 3:a=e.sent,a.promise.then((function(e){var n=KR(t,e.data);l(Object(ne.sortBy)(n,"productName")),O(n.length)})).catch(Ae.default).catch(uc(c)).finally((function(){return p(!1)}));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),x=Object(a.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:wo;p(!0);var a=t.fetch(void 0,{pageNo:e,size:n}),r=a.promise;r.then((function(e){var t=e.data;h(t.results)})).catch(Ae.default).catch(uc(c)).finally((function(){return p(!1)}))}),[t]);return Object(a.useEffect)((function(){e&&x()}),[x,e]),{products:s,setProducts:l,setLoading:p,loading:j,totalInventoryProducts:v,setTotalInventoryProducts:O,getInventoryDetails:x}},XR=function(e){var t=e.products,n=e.isLoading,a=Object(p.h)(),r=function(e){var t=e.manufacturerName||e.manufacturer?[e.manufacturerName||e.manufacturer]:[],n=!1!==e.custom?["Custom"]:[];return[].concat(n,t)};return Object(y.jsx)("div",{"data-testid":"products-tile-board",className:"mx-4",children:function(){var e=[];return t.forEach((function(t){var n=e.findIndex((function(e){return e.isCustom===t.isCustom}));-1===n?e.push({isCustom:t.isCustom,items:[t]}):e[n].items.push(t)})),Object(ne.sortBy)(e,[function(e){return e.isCustom}]).reverse()}().map((function(e){return Object(y.jsx)(Xd,{title:e.isCustom?"Custom Products":"Products and Services",totalItems:e.items.length,testId:"product",children:n?Object(y.jsx)("div",{className:"flex items-center w-full h-40",children:Object(y.jsx)(m.Spinner,{size:"lg"})}):e.items.map((function(e){return Object(y.jsx)(lu,{testId:"product",linkTo:"".concat(Cc.inventory,"/").concat(e.productId||e.id,"/view"),title:e.productName||(null===e||void 0===e?void 0:e.name),subtitle:r(e).join(" \u2022 "),onAction:function(){!function(e,t){({view:function(){a.push("".concat(Cc.inventory,"/").concat((null===t||void 0===t?void 0:t.productId)||(null===t||void 0===t?void 0:t.id),"/view"))},edit:function(){},delete:function(){},flag:function(){},duplicate:function(){}})[e]()}("view",e)},contextMenuHide:!0,children:Object(y.jsxs)("div",{"data-testid":"product-card-details",className:"flex flex-wrap w-full",children:[Object(y.jsx)(uu,{id:"product-type",title:"Type",value:Object(ne.startCase)(e.productType||e.type),testId:"product"}),Object(y.jsx)(uu,{id:"product-avg-price-per-unit",title:"Avg. Price/Unit",value:Object(y.jsxs)(y.Fragment,{children:["$",Object(y.jsx)(hu,{children:e.averagePricePerUnit||0}),"/",Object(va.g)(e.productQuantityUnit)]}),testId:"product"}),Object(y.jsx)(uu,{id:"product-purchased-amount",title:"Invoiced (Qty)",value:Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(hu,{children:e.purchased||0})," ",Object(va.g)(e.purchasedUnit)||Object(va.g)(e.appliedUnit)]}),testId:"product"}),Object(y.jsx)(uu,{id:"product-applied-amount",title:"Applied (Qty)",value:Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(hu,{children:e.productQuantityValue||0})," ",Object(va.g)(e.productQuantityUnit)||Object(va.g)(e.purchasedUnit)]}),testId:"product"}),Object(y.jsx)(uu,{id:"product-available-amount",title:"Available (Qty)",value:Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(hu,{children:e.purchased-e.productQuantityValue||0})," ",Object(va.g)(e.productQuantityUnit)||Object(va.g)(e.purchasedUnit)]}),testId:"product"})]})},e.productId||e.id)}))},e.isCustom)}))})};XR.defaultProps={products:[]};var $R=XR,eI=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[];return!1!==e.custom&&t.push("Custom"),(e.manufacturerName||e.manufacturer)&&t.push(e.manufacturerName||e.manufacturer),t.join(" \u2022 ")},tI=function(e){var t=e.product,n=e.onAction;return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsxs)("span",{className:"flex flex-col",children:[Object(y.jsx)("span",{className:"w-64 pb-2 text-sm font-bold text-left truncate","data-testid":"product-name",children:Object(y.jsx)(j.b,{to:"".concat(Cc.inventory,"/").concat(t.productId||t.id,"/view"),children:(null===t||void 0===t?void 0:t.productName)||(null===t||void 0===t?void 0:t.name)})}),Object(y.jsx)("span",{className:"w-64 text-sm text-left text-gray-600 truncate","data-testid":"product-manufacturer",children:eI(t)})]})}),Object(y.jsx)(m.Table.Cell,{children:(null===t||void 0===t?void 0:t.productType)||t.type}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(hu,{children:t.purchased||0})," ",Object(va.g)(t.productQuantityUnit)]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(hu,{children:t.productQuantityValue||0})," ",Object(va.g)(t.productQuantityUnit)]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(hu,{children:t.purchased-t.productQuantityValue||0})," ",Object(va.g)(t.productQuantityUnit)]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsxs)("div",{children:["$",Object(y.jsx)(hu,{children:t.averagePricePerUnit||0}),"/",Object(va.g)(t.productQuantityUnit)]}),Object(y.jsx)("div",{"data-testid":"product-table-options-menu",className:"flex-none w-10 absolute right-0 mr-5",children:Object(y.jsx)(m.Button,{type:"link-default",onClick:function(){return n("view",t)},children:"View"})})]})]},t.productId||t.id)},nI=function(e,t,n){return"name"===t?Object(ne.orderBy)(e,[function(e){return e.productName.toString().toLowerCase()}],[n]):"available"===t?Object(ne.orderBy)(e,[function(e){return e.purchased-e.productQuantityValue}],[n]):Object(ne.orderBy)(e,[t],[n])},aI=function(e){var t=e.products,n=e.totalInventoryProducts,r=e.setTotalInventoryProducts,c=e.isLoading,i=Object(p.h)(),o=Object(a.useState)(),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(),j=Object(b.a)(u,2),f=j[0],m=j[1],v=Object(a.useState)(null),O=Object(b.a)(v,1)[0],h=Object(ne.cloneDeep)(t),x=[{field:"name",title:"Products (".concat(n,")"),level:"1",sortable:!0},{field:"type",title:"Type",level:"0",sortable:!0},{field:"purchased",title:"Invoiced (Qty)",level:"0",sortable:!0},{field:"applied",title:"Applied (Qty)",level:"0",sortable:!0},{field:"available",title:"Available (Qty)",level:"0",sortable:!0},{field:"avgPricePerUnit",title:"Avg. Price/Unit",level:"0",sortable:!0}];h=l?function(e,t,n){if(!n)return e;var a=e.map((function(e){return Object(ne.cloneDeep)(e)}));return"name"===t?a=nI(a,"productName",n):"type"===t?a=nI(a,"productType",n):"purchased"===t?a=nI(a,"purchased",n):"applied"===t?a=nI(a,"applied",n):"available"===t?a=nI(a,"available",n):"avgPricePerUnit"===t&&(a=nI(a,"averagePricePerUnit",n)),a}(h,l,f):h;var g=function(e,t){({view:function(){i.push("".concat(Cc.inventory,"/").concat((null===t||void 0===t?void 0:t.productId)||(null===t||void 0===t?void 0:t.id),"/view"))},edit:function(){},delete:function(){},flag:function(){},duplicate:function(){}})[e]()};return Object(a.useEffect)((function(){r(t.length)}),[t]),Object(y.jsx)("div",{className:"mx-2 my-4 min-w-content","data-testid":"products-table",style:{minWidth:"min-content"},children:Object(y.jsxs)(ll,{children:[O&&Object(y.jsx)(p.b,{push:!0,to:"".concat(O)}),Object(y.jsx)(ol,{listType:"products",routePath:Cc.inventory,isLoading:c,items:h,tableColumns:x,onSort:function(e,t){d(e),m(t)},sortBy:l,sortDir:f,children:function(e){var t=e.rows;return c?Object(y.jsx)("div",{style:{height:"80vh"}}):t.map((function(e){return Object(y.jsx)(tI,{product:e,onAction:g},e)}))}})]})})};aI.defaultProps={products:[]};var rI=aI,cI=Sd(pd,"tile"),iI=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2),n=t[0],r=n.loadingOrg,c=n.loggedInUserOrgPermission,i=t[1],o=cI.get(),s=JR({sortBy:"productName",sortDir:"asc"}),l=s.products,d=s.getProducts,u=s.productsCount,j=s.isLoading,p=s.pageNo,f=s.goToPage,v=QR(),O=v.loading,h=v.totalInventoryProducts,x=v.setTotalInventoryProducts,g=v.getInventoryDetails,C=!j&&0===(null===l||void 0===l?void 0:l.length),P=Object(a.useState)(o),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)([]),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)([]),I=Object(b.a)(R,2),D=I[0],k=I[1],L=Object(a.useState)(!1),F=Object(b.a)(L,2),M=F[0],V=F[1];Object(a.useEffect)((function(){d()}),[]),Object(a.useEffect)((function(){return"tile"===S&&i({type:br,payload:"#F5F8FC"}),function(){i({type:br,payload:null})}}),[S,i]),Object(a.useEffect)((function(){_(l)}),[l]);var B=function(){return cr(null===c||void 0===c?void 0:c.role,Xa)};return Object(y.jsxs)("div",{className:"h-full w-full","data-testid":"products",children:[Object(y.jsx)(lo,{onOrganizationSelect:function(){return g()},hideCropSeasonDropdowns:!0,children:Object(y.jsx)(lo.Item,{title:"Products",value:"All",isLast:!0,disabled:!0})}),O||r?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex items-center justify-between",children:[Object(y.jsx)(To,{id:"products-search-input",name:"search_products",placeholder:"Search Products",filterItems:w,selectedProductTypes:D,onChange:function(e){!function(e){var t=e?l.filter((function(t){return t.productName.toLocaleLowerCase().includes(e.toLocaleLowerCase())||t.manufacturerName.toLocaleLowerCase().includes(e.toLocaleLowerCase())})):l;x(t.length),_(t)}(e.target.value)},onDateRangeChange:ne.noop,onFilterChange:ne.noop,onChangeLabel:ne.noop,onChangeProductType:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=n.map((function(e){return e.key})).join(",");k(a);var r=l.filter((function(e){return n.some((function(t){return e.productType.toLowerCase()===t.value.toLowerCase().replace(/ /gi,"")}))}));n.length?(x(r.length),_(r)):(x(l.length),_(l))},onChangeTaskType:ne.noop,showDateRange:!1,showCropSeason:!1,showProductType:!0}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)(Rd,{testId:"products-view-toggle",view:S,changeView:function(e){T(e),cI.save(e)}}),B()&&Object(y.jsx)("div",{className:"pl-2 whitespace-no-wrap",children:Object(y.jsx)(m.Button,{type:"primary",id:"add-products-button",onClick:function(){return V(!0)},icon:Object(y.jsx)(Eo.a,{}),children:"Create Product"})})]})]}),Object(y.jsx)("div",{children:w&&0!==w.length?Object(y.jsxs)("div",{children:["tile"===S&&Object(y.jsx)($R,{products:w,isLoading:j}),"list"===S&&Object(y.jsx)(rI,{products:w,totalInventoryProducts:h,setTotalInventoryProducts:x,isLoading:j})," ",!C&&Object(y.jsx)("div",{className:"pr-6 border-t-1 border-neutral-20 ".concat(j?"pointer-events-none cursor-not-allowed":""),children:Ho(u,p,(function(e){f(e)}))})]}):Object(y.jsx)(Vd,{buttonText:"Create Product",setPermission:B,onClick:function(){V(!0)},subtitle:"We were unable to find any products under this organization."})}),M&&Object(y.jsx)(N_,{open:M,onClose:function(){return V(!1)},handleSave:function(e){var t=w;t.push({productId:e.id,purchased:0,applied:0,available:0,averagePricePerUnit:0,productName:e.name,manufacturerName:e.manufacturer,productType:e.type,custom:!0}),_(t),V(!1)},setModalTab:"Fertilizer"})]})]})},oI=function(e){var t=Object(a.useState)([]),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)(!0),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(null),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useCallback)((function(e){xn.fetch("?size=".concat(100)).promise.then((function(t){var n=e?t.data.results.filter((function(t){return t.products.filter((function(t){return t.productId===e})).length>0?t:null})).filter((function(e){return"complete"===e.status})):t.data.results;c(n),l(!1)})).catch((function(e){p(e),l(!1)})).catch(Ae.default)}),[]);return Object(a.useEffect)((function(){f(e)}),[e,f]),{tasks:r,tasksLoading:s,tasksError:j}},sI=n(800),lI=n.n(sI),dI=function(e){var t=Object(a.useState)(null),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)(null),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(!0),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useCallback)((function(e){an.fetch("".concat(e)).promise.then((function(e){c(e.data),p(!1)})).catch(Ae.default).catch((function(){return p(!1)}))}),[]),m=function(e){for(var t=lI()(e),n=new ArrayBuffer(t.length),a=new Uint8Array(n),r=0;r<t.length;r++)a[r]=t.charCodeAt(r);return new Blob([n],{type:"application/pdf"})},v=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=jn.fetch(t),a=n.promise,e.next=3,a.then((function(e){var t=e.data.data;if(t){var n=m(t),a=URL.createObjectURL(n);window.open(a)}else l("We were unable to find any documentation for this product.")})).catch(Ae.default);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){f(e)}),[e,f]),{dataDocumentation:r,isLoading:j,openFile:v,error:s,setError:l}},uI=function(e){var t=Object(a.useContext)(ac),n=Object(b.a)(t,2)[1],r=Object(a.useState)(),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(!0),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(!1),p=Object(b.a)(j,2),f=p[0],m=p[1],v=Object(a.useState)(!1),O=Object(b.a)(v,2),h=O[0],x=O[1];return Object(a.useEffect)((function(){Fn.fetch(e).promise.then((function(e){o(e.data),u(!1)})).catch(Ae.default).catch((function(e){uc(n)(e),u(!1)}))}),[]),{reiphiData:i,setReiphiData:o,reiphiLoading:d,saveREIPHI:function(e,t,a,r){m(!0);var c=(null===t||void 0===t?void 0:t.cropid)||(null===t||void 0===t?void 0:t.cropId),i={rei:null===t||void 0===t?void 0:t.rei,phi:null===t||void 0===t?void 0:t.phi,reiu:null===t||void 0===t?void 0:t.reiu,phiu:null===t||void 0===t?void 0:t.phiu},o="reiphi/".concat(e,"/").concat(c),s=a&&"CWF"===(null===t||void 0===t?void 0:t.source),l=Fn.createChildApi({action:o});return(s?l.update("",i):l.create(i)).promise.then((function(e){r(Object(I.a)(Object(I.a)({},e.data),{},{i:null===t||void 0===t?void 0:t.i,cropName:null===t||void 0===t?void 0:t.cropName}))})).catch(Ae.default).catch((function(e){uc(n)(e)})).finally((function(){return m(!1)}))},deleteREIPHI:function(e,t){x(!0);var a=(null===e||void 0===e?void 0:e.cropid)||e.cropId,r="".concat(e.productId,"/").concat(a),c=Object(I.a)({},e);return delete c.i,Fn.delete(r,c).promise.then((function(){t(!0)})).catch(Ae.default).catch((function(e){uc(n)(e)})).finally((function(){return x(!1)}))},saving:f,deleting:h}},bI=function(e){var t=Object(a.useState)([]),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)(!0),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(null),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useCallback)((function(e){Tn.fetch("?size=".concat(1e4)).promise.then((function(t){var n=t.data.results.filter((function(t){var n;return(null!==(n=t.invoiceProducts)&&void 0!==n?n:[]).filter((function(t){return t.productId===e||t.id===e})).length>0?t:null}));c(n),l(!1)})).catch((function(e){p(e),l(!1)})).catch(Ae.default)}),[]);return Object(a.useEffect)((function(){l(!0),f(e)}),[e,f]),{invoices:r,invsLoading:s,invsError:j}},jI=n(2824),pI=function(e){var t=e.children,n=e.setRowData,r=e.rowData,c=e.onFilter,i=e.pageClick,o=e.totalRecordCount,s=e.pageNumber,l=dd().cropSeasons,d=Object(a.useState)(null),u=Object(b.a)(d,2),j=u[0],p=u[1],f=zi(j,300),v=Object(a.useState)([]),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(null),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(null),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)([]),_=Object(b.a)(w,2),R=_[0],D=_[1],k=Object(a.useRef)(null);return Object(a.useEffect)((function(){if(l){var e=l.map((function(e){return{key:e.id,value:e.name}}));D(e)}}),[l]),Object(a.useEffect)((function(){var e,t=n(r);if(null===t||void 0===t||null===(e=t.tableRows)||void 0===e||!e.length||k.current===s)return E(t),void(k.current=-1);k.current=s;var a=t.tableRows.slice(s*wo,(s+1)*wo);E(Object(I.a)(Object(I.a)({},t),{},{tableRows:a}))}),[r,n,s]),Object(a.useEffect)((function(){var e=(null===P||void 0===P?void 0:P.split(","))||[];c(f,e,h)}),[f,P,h]),Object(y.jsxs)("div",{className:"-ml-6 -mr-6","data-testid":"inventory-filtering",children:[Object(y.jsxs)("div",{className:"flex justify-between items-center pb-6",children:[Object(y.jsx)("div",{className:"flex",children:Object(y.jsx)(m.Input,{className:" border-none",type:"text",name:"search",placeholder:"Search",onChange:function(e){return p(e.target.value)}})}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(m.Select,{multiple:!0,value:P,items:R,placeholder:"Filter by season",onChange:function(e,t,n){var a=n.map((function(e){return e.key})).join(",");A(a)}})}),Object(y.jsx)("div",{className:"relative w-64 text-gray-400 focus-within:text-gray-600 mr-4",children:Object(y.jsx)(m.DatePicker,{onChange:function(e){var t;2===(null===(t=e.target.value)||void 0===t?void 0:t.length)?x(e.target.value):x([])},isRangePicker:!0})}),Ho(o,s,i)]})]}),t({tableData:N}),Ho(o,s,i)]})};pI.defaultProps={onFilter:function(){},totalRecordCount:0,pageNumber:0};var fI=pI,mI=function(e){var t=e.tableRows,n=e.setRedirect;return Object(y.jsx)(y.Fragment,{children:null===t||void 0===t?void 0:t.map((function(e){var t;return Object(y.jsx)(m.Table.Row,{children:null===(t=e.rowData)||void 0===t?void 0:t.map((function(t,a){return Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{children:t}),(r=e.link,c=a===e.rowData.length-1,c?Object(y.jsx)("div",{className:"flex-none w-10 absolute right-0 mr-5",children:Object(y.jsx)(m.Button,{type:"link-default",className:"right-0",onClick:function(){return n(r)},children:"View"})}):"")]})},t);var r,c}))},null===e||void 0===e?void 0:e.id)}))})};mI.defaultProps={tableRows:[],setRedirect:function(){}};var vI=mI,OI=function(e,t,n){return e===t?n:null},hI=function(e){var t=e.sortBy,n=e.colSortDir,r=e.sortClick,c=e.headerColumns,i=Object(a.useCallback)((function(e){return OI(e,t,n)}),[t,n]);return Object(y.jsx)(m.Table.Header,{children:null===c||void 0===c?void 0:c.map((function(e){var a=e.field,c=e.width,o=e.sortable,s=e.title;return Object(y.jsx)(m.Table.Cell,{width:c,sortable:o,sort:i(a),onClick:function(){return function(e){if(t){var a=OI(e,t,n);r(e,(c=a)?"asc"===c?"dsc":null:"asc")}var c}(a)},children:s},a)}))})};hI.defaultProps={sortBy:null,colSortDir:null,sortClick:null};var xI=hI,gI=function(e){var t=e.data,n=e.setRedirect;return Object(y.jsxs)(m.Table,{"data-testid":"inv-data-table",children:[Object(y.jsx)(xI,{sortBy:null,colSortDir:"asc",sortClick:function(){},headerColumns:null===t||void 0===t?void 0:t.tableHeader}),Object(y.jsx)(vI,{tableRows:null===t||void 0===t?void 0:t.tableRows,setRedirect:function(e){n(e)}})]})};gI.defaultProps={data:null,setRedirect:null};var CI=gI,yI=function(e){var t=e.invoices,n=e.productId,r=e.setRedirect,c=Object(a.useState)([]),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(0),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(0),f=Object(b.a)(p,2),v=f[0],O=f[1],h=function(e){r(e)},x=Object(a.useCallback)((function(e){var t=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"});return{tableHeader:[{field:"name",sortable:!0,title:"Name"},{field:"invoiceDate",sortable:!0,title:"Invoice Date"},{field:"totalUnits",sortable:!0,title:"Total Units"},{field:"totalPrice",sortable:!0,title:"Total Price"},{field:"pricePerUnit",sortable:!0,title:"Price Per Unit"}],tableRows:e.map((function(e){var a=e.invoiceProducts.filter((function(e){return e.productId===n})).map((function(e){var n=e.totalCostValue/e.totalQuantityValue||0;return["".concat(e.totalQuantityValue," ").concat(Object(va.g)(e.totalQuantityUnit)),t.format(e.totalCostValue),"".concat(t.format(n),"/").concat(Object(va.g)(e.totalQuantityUnit))]}));return{id:e.id,rowData:[e.invoiceNumber,new Date(e.invoiceDateEpoch).toLocaleDateString(),a[0][0],a[0][1],a[0][2]],link:"".concat(Cc.invoices,"/").concat(e.id,"/view")}}))}}),[n]);Object(a.useEffect)((function(){t&&(O(t.length),s(ae.a.cloneDeep(t)))}),[t]);return t?Object(y.jsx)("div",{"data-testid":"inv-invoice-tab",children:Object(y.jsx)(fI,{setRowData:x,rowData:o,onFilter:function(e,n,a){var r=ae.a.cloneDeep(t);e&&(r=r.filter((function(t){return t.invoiceNumber.toLowerCase().includes(e.toLowerCase())}))),n.length>0&&(r=r.filter((function(e){return e.cropSeasons.some((function(e){var t=e.seasonId;return n.includes(t)}))}))),2===a.length&&(r=r.filter((function(e){var t=new Date(Object(ya.a)(new Date(e.invoiceDate),"yyyy/MM/dd")),n=new Date(Object(ya.a)(new Date(a[0]),"yyyy/MM/dd")),r=new Date(Object(ya.a)(new Date(a[1]),"yyyy/MM/dd"));return Object(jI.a)(t,{start:n,end:r})}))),s(r)},pageClick:j,totalRecordCount:v,pageNumber:u,children:function(e){var t=e.tableData;return Object(y.jsx)(CI,{data:t,setRedirect:h})}})}):Object(y.jsx)(m.Spinner,{})};yI.defaultProps={invoices:[],productId:null,setRedirect:function(){}};var PI=yI,AI=function(e){var t=e.tasks,n=e.productId,r=e.setRedirect,c=Object(a.useState)([]),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(0),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(0),f=Object(b.a)(p,2),v=f[0],O=f[1],h=function(e){r(e)},x=Object(a.useCallback)((function(e){return{tableHeader:[{field:"name",sortable:!0,title:"Name"},{field:"completedDate",sortable:!0,title:"Completed Date"},{field:"rate",sortable:!0,title:"Rate"},{field:"appliedArea",sortable:!0,title:"Applied Area"},{field:"totalProduct",sortable:!0,title:"Total Product"}],tableRows:e.map((function(e){var t=e.products.filter((function(e){return e.productId===n})).map((function(e){var t=e.ratePerAreaValue.toFixed(2),n=e.appliedAreaValue.toFixed(2),a=e.totalProductValue.toFixed(2);return["".concat(t," ").concat(Object(va.g)(e.ratePerAreaUnit),"/").concat(Object(va.g)(e.appliedAreaUnit)),"".concat(n," ").concat(Object(va.g)(e.appliedAreaUnit)),"".concat(a," ").concat(Object(va.g)(e.totalProductUnit))]}));return{id:e.taskId,rowData:[e.name,new Date("Custom"===e.duration?e.dueDateEpoch:e.startDateEpoch+3600*e.duration).toLocaleDateString(),t[0][0],t[0][1],t[0][2]],link:"".concat(Cc.tasks,"/").concat(e.taskId,"/view")}}))}}),[n]);Object(a.useEffect)((function(){t&&(O(t.length),s(ae.a.cloneDeep(t)))}),[t]);return t?Object(y.jsx)("div",{"data-testid":"inv-task-tab",children:Object(y.jsx)(fI,{setRowData:x,rowData:o,onFilter:function(e,n,a){var r=ae.a.cloneDeep(t);e&&(r=r.filter((function(t){return t.name.toLowerCase().includes(e.toLowerCase())}))),n.length>0&&(r=r.filter((function(e){return e.cropSeasonIds.some((function(e){var t=e.id;return n.includes(t)}))}))),2===a.length&&(r=r.filter((function(e){var t=new Date(Object(ya.a)(new Date(e.startDateEpoch+3600*e.duration),"yyyy/MM/dd")),n=new Date(Object(ya.a)(new Date(a[0]),"yyyy/MM/dd")),r=new Date(Object(ya.a)(new Date(a[1]),"yyyy/MM/dd"));return Object(jI.a)(t,{start:n,end:r})}))),s(r)},pageClick:j,totalRecordCount:v,pageNumber:u,children:function(e){var t=e.tableData;return Object(y.jsx)(CI,{data:t,setRedirect:h})}})}):Object(y.jsx)(m.Spinner,{})};AI.defaultProps={tasks:null,productId:null,setRedirect:function(){}};var SI=AI,TI=function(e){var t,n,r=e.id,c=e.selectedProduct,i=e.invoices,o=e.tasks,s=e.reloadData,l=e.setRedirect,d=c.productName,u=Object(a.useState)(0),j=Object(b.a)(u,2),p=j[0],f=j[1],v=dd().cropSeasons;Object(a.useEffect)((function(){if(v){var e=v.map((function(e){return e.id}));s({seasonIds:e})}}),[v]);var O=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"});return Object(y.jsx)(y.Fragment,{children:d?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"mb-6 border-b-2",children:Object(y.jsxs)("div",{className:"flex mb-6",children:[Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("div",{className:"text-sm",children:"Average Price/Unit"}),Object(y.jsxs)("div",{className:"text-xl",children:[O.format(isNaN(null===c||void 0===c?void 0:c.averagePricePerUnit)?0:null===c||void 0===c?void 0:c.averagePricePerUnit),"/",Object(va.g)(null===c||void 0===c?void 0:c.averagePriceUnit)]})]}),Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("div",{className:"text-sm",children:"Available Quantity"}),Object(y.jsx)("div",{className:"text-xl",children:Object(y.jsxs)("p",{children:[null===c||void 0===c||null===(t=c.available)||void 0===t?void 0:t.toFixed(2)," ",Object(va.g)(null===c||void 0===c?void 0:c.stdPackageUnit)]})})]}),Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("div",{className:"text-sm",children:"Total Invoiced Quantity"}),Object(y.jsxs)("div",{className:"text-xl",children:[null===c||void 0===c?void 0:c.purchased.toFixed(2)," ",null!==c&&void 0!==c&&c.purchasedUnit?Object(va.g)(null===c||void 0===c?void 0:c.purchasedUnit):""]})]}),Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("div",{className:"text-sm",children:"Total Applied Quantity"}),Object(y.jsxs)("div",{className:"text-xl",children:[null===c||void 0===c||null===(n=c.productQuantityValue)||void 0===n?void 0:n.toFixed(2)," ",Object(va.g)(null===c||void 0===c?void 0:c.productQuantityUnit)]})]})]})}),Object(y.jsx)("div",{children:Object(y.jsxs)(m.Tabs,{activeTab:p,children:[Object(y.jsx)(m.Tabs.Tab,{label:"Invoices",onClick:function(){return f(0)},active:0===p,children:Object(y.jsx)(PI,{invoices:i,productId:r,cropSeasonsArray:v,setRedirect:l})}),Object(y.jsx)(m.Tabs.Tab,{label:"Tasks",onClick:function(){return f(1)},active:1===p,children:Object(y.jsx)(SI,{tasks:o,productId:r,cropSeasonsArray:v,setRedirect:l})})]})})]}):Object(y.jsx)(m.Spinner,{})})},NI=function(e){var t=e.setPermission,n=e.section,a=e.children,r=e.openAddEditModal;return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(Vd,{className:"w-1",buttonText:function(){switch(n){case"inventory":case"documentation":return"";default:return"Add Crop"}}(),onClick:function(){var e=function(){return r(!1)};return"documentation"===n&&(e=function(){}),"inventory"===n&&(e=""),e}(),subtitle:function(){switch(n){case"inventory":return"";case"documentation":return"No documentation found for this product";default:return"No Crop found to display REI/PHI information"}}(),imageToUse:function(){switch(n){case"inventory":return"inventory";case"documentation":return"documentation";default:return"REIPHI"}}(),setPermission:t,children:a})})};NI.defaultProps={setPermission:function(){return!1},section:"",children:Object(y.jsx)(y.Fragment,{}),openAddEditModal:function(){}};var EI=NI,wI=function(){return Object(y.jsx)("svg",{width:"20",height:"25",viewBox:"0 0 20 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M12.3334 0.807495H3.00002C1.71669 0.807495 0.666687 1.8575 0.666687 3.14083V21.8075C0.666687 23.0908 1.71669 24.1408 3.00002 24.1408H17C18.2834 24.1408 19.3334 23.0908 19.3334 21.8075V7.80749L12.3334 0.807495ZM17 21.8075H3.00002V3.14083H12.3334V7.80749H17V21.8075ZM10 18.3075C8.71669 18.3075 7.66669 17.2575 7.66669 15.9742V9.55749C7.66669 9.23083 7.92335 8.97416 8.25002 8.97416C8.57669 8.97416 8.83335 9.23083 8.83335 9.55749V15.9742H11.1667V9.55749C11.1667 7.94749 9.86002 6.64083 8.25002 6.64083C6.64002 6.64083 5.33335 7.94749 5.33335 9.55749V15.9742C5.33335 18.5525 7.42169 20.6408 10 20.6408C12.5784 20.6408 14.6667 18.5525 14.6667 15.9742V11.3075H12.3334V15.9742C12.3334 17.2575 11.2834 18.3075 10 18.3075Z",fill:"#696F88"})})},_I=function(e){var t=e.description,n=e.fileName,a=e.openFile;return Object(y.jsx)("div",{"data-testid":"document-single-card",className:"border flex flex-wrap flex-col rounded-xl w-full h-48 shadow-documentation-card text-center cursor-pointer",onClick:a,onKeyDown:a,role:"button",tabIndex:0,children:Object(y.jsxs)("div",{className:"flex flex-col items-center justify-center h-screen",children:[Object(y.jsx)("div",{className:"place-self-center",children:Object(y.jsx)(wI,{})}),Object(y.jsx)("div",{className:"text-sm text-neutral-80 pt-4 pb-1",children:t}),Object(y.jsx)("div",{className:"text-xs text-neutral-600 w-full",children:function(e){if(e.length>20){var t=e.slice(-6,e.length),a=e.slice(0,10);return"".concat(a,"...").concat(t)}return n}(n)})]})})},RI=function(e){var t,n,a=e.dataDocumentation,r=e.openFile;return a&&(null===a||void 0===a||null===(t=a.documentdescriptions)||void 0===t?void 0:t.length)>0?Object(y.jsx)("div",{className:"grid grid-cols-auto-fill gap-6",children:null===a||void 0===a||null===(n=a.documentdescriptions)||void 0===n?void 0:n.map((function(e){var t=e.filename,n=e.description,a=e.id;return Object(y.jsx)(_I,{description:n,fileName:t,openFile:function(){return r(a)}},a)}))}):Object(y.jsx)(EI,{section:"documentation"})},II=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=Fh(t),r=n.filter((function(e){return"CWF"===e.source}));return n.reduce((function(t,n){if(a.some((function(e){return e.crop.id.replace(/-/gi,"")===n.cropId.replace(/-/gi,"")}))||r.find((function(e){return e.cropId===n.cropId}))){var c,i=null===e||void 0===e?void 0:e.find((function(e){return e.crop.id===n.cropId.replace(/-/gi,"")})),o=n.cropName&&""!==(null===n||void 0===n?void 0:n.cropName)?null===n||void 0===n?void 0:n.cropName:null===i||void 0===i||null===(c=i.crop)||void 0===c?void 0:c.name,s=n.editedOnDateEpoch>0?new Date(n.editedOnDateEpoch).toLocaleDateString("en-US"):"";t.push(Object(I.a)(Object(I.a)({},n),{},{dateEdited:s,cropName:o}))}return t}),[])},DI=n.p+"static/media/edit_outlined.8d78cdec.svg",kI=n.p+"static/media/delete_outlined.8a388ab4.svg",LI=n(27),FI=function(e){var t,n,a=e.product,r=e.editClick,c=e.deleteClick,i=Object(I.a)(Object(I.a)({},a),{},{name:null===a||void 0===a||null===(t=a.cropName)||void 0===t?void 0:t.replace(/ /g,"")}),o=null!==i&&void 0!==i&&null!==(n=i.name)&&void 0!==n&&n.includes(":")?null===i||void 0===i?void 0:i.name.split(":")[0].trim():null===i||void 0===i?void 0:i.name;return Object(y.jsxs)("div",{className:"h-full w-full border rounded p-4",children:[Object(y.jsx)("div",{className:"w-full pb-4 mb-3 border-b","data-testid":"product-title",children:Object(y.jsxs)("div",{className:"flex justify-between text-xl",children:[Object(y.jsxs)("div",{className:"flex ".concat("CWF"===a.source?"w-5/6":"w-11/12"),children:[Object(y.jsx)("div",{className:"mr-2",children:o in yg?Object(y.jsx)(Ag,{cropObject:i}):Object(y.jsx)("img",{src:LI.default,alt:""})}),Object(y.jsx)("div",{className:"truncate",children:null===a||void 0===a?void 0:a.cropName})]}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("button",{"data-testid":"edit-button",type:"button",onClick:function(){return r(a.id)},children:Object(y.jsx)("img",{src:DI,alt:""})}),"CWF"===a.source&&Object(y.jsx)("button",{"data-testid":"delete-button",className:"ml-1",type:"button",onClick:function(){return c(a.id)},children:Object(y.jsx)("img",{src:kI,alt:""})})]})]})}),Object(y.jsxs)("div",{className:"flex w-full justify-between text-md","data-testid":"product-details",children:[Object(y.jsx)(Fl,{header:"REI",data:"".concat(null===a||void 0===a?void 0:a.rei," ").concat(null===a||void 0===a?void 0:a.reiu),testId:"rei-field"}),Object(y.jsx)(Fl,{header:"PHI",data:"".concat(null===a||void 0===a?void 0:a.phi," ").concat(null===a||void 0===a?void 0:a.phiu),testId:"phi-field"}),(null===a||void 0===a?void 0:a.dateEdited)&&Object(y.jsx)(Fl,{className:"mr-6",header:"Edited On",data:"".concat(null===a||void 0===a?void 0:a.dateEdited),testId:"edited-date-field"}),!(null!==a&&void 0!==a&&a.dateEdited)&&Object(y.jsx)("div",{})]})]})};FI.defaultProps={editClick:function(){},deleteClick:function(){}};var MI=FI,VI=Fu.e().shape({rei:Fu.d().min(0),phi:Fu.d().min(0),cropid:Fu.f().nullable().required("You must select a crop")}),BI={prodid:null,cropid:null,parentid:null,rei:0,phi:0,reiu:"hour",phiu:"day"},UI=function(e){var t=e.openEdit,n=e.onClose,r=e.isEdit,c=e.crop,i=e.productId,o=e.saveREIPHI,s=Object(a.useState)([]),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Du().crops,p=Object(a.useState)(r?"Edit REI/PHI Information":"Add REI/PHI Information"),f=Object(b.a)(p,1)[0],v=Object(a.useState)(c||Object(I.a)(Object(I.a)({},BI),{},{prodid:i})),O=Object(b.a)(v,1)[0],h=Object(a.useState)({cropid:null===c||void 0===c?void 0:c.cropId,cropName:null===c||void 0===c?void 0:c.cropName}),x=Object(b.a)(h,2),g=x[0],C=x[1],P=(null===c||void 0===c?void 0:c.reiu)||"hour",A=(null===c||void 0===c?void 0:c.phiu)||"day";return Object(a.useEffect)((function(){if(!r&&j){var e=(null===j||void 0===j?void 0:j.map((function(e){return{key:e.id,value:e.name}})))||[];u(e)}}),[r,j,c]),Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(Zi.e,{initialValues:O,validationSchema:VI,children:function(e){var a=e.values;return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(ao,{open:t,close:n,onCancel:function(){return n()},onConfirm:function(){return function(e){o(i,Object(I.a)(Object(I.a)({},e),{},{i:(null===c||void 0===c?void 0:c.i)||-1,cropid:null===g||void 0===g?void 0:g.cropid,cropName:null===g||void 0===g?void 0:g.cropName}),r,n)}(a)},confirmLabel:r?"Update":"Add",children:Object(y.jsxs)("div",{className:"pt-4 pb-4",children:[Object(y.jsx)("div",{className:"text-2xl font-semibold mb-10","data-testid":"modal-title",children:f}),r?Object(y.jsx)("div",{className:"text-lg mb-12","data-testid":"edit-crop-title",children:null===c||void 0===c?void 0:c.cropName}):Object(y.jsx)("div",{className:"h-full w-full mb-12","data-testid":"add-select-search",children:Object(y.jsx)(m.Form.Field,{label:"Select Crop",children:Object(y.jsx)("div",{className:"mt-1",children:Object(y.jsx)(Qi,{control:m.Search,name:"cropid",items:d,placeholder:"Select",label:"Select Crop",onSelect:function(e){C({cropid:e.key,cropName:e.value})}})})})}),Object(y.jsxs)("div",{className:"flex w-full h-full justify-between -mt-8",children:[Object(y.jsx)(m.Form.Field,{label:"REI",children:Object(y.jsxs)("div",{className:"flex w-full mt-1","data-testid":"rei-input",children:[Object(y.jsx)(Qi,{control:m.Input,name:"rei"}),Object(y.jsx)("div",{className:"pl-2 pt-1",children:P})]})}),Object(y.jsx)(m.Form.Field,{label:"PHI",children:Object(y.jsxs)("div",{className:"flex w-full mt-1","data-testid":"phi-input",children:[Object(y.jsx)(Qi,{control:m.Input,name:"phi"}),Object(y.jsx)("div",{className:"pl-2 pt-1",children:A})]})})]})]})})})}})})};UI.defaultProps={crop:null,productId:null};var zI=UI,ZI=(n(1553),function(e){var t=e.dataREIPHI,n=e.dataDocumentation,r=e.productId,c=e.properties,i=e.saveREIPHI,o=e.deleteREIPHI,s=e.updateREIPHI,l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(!1),f=Object(b.a)(p,2),v=f[0],O=f[1],h=Object(a.useState)(null),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useState)(!1),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)([]),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(null),D=Object(b.a)(R,2),k=D[0],L=D[1],F=function(e){e&&w.splice(null===k||void 0===k?void 0:k.i,1),T(!1)},M=function(e,t){C(t),O(e),j(!0)},V=function(e){e&&(v?w[e.i]=e:w.push(e)),s(e),j(!1)},B=function(){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("ul",{className:"list-disc text-m text-neutral-80 leading-7 pt-8 py-2 mt-2",children:[Object(y.jsx)("li",{children:"REI (Restricted Entry Interval): Time limit for access on the field after application of the product. Measured in hours."}),Object(y.jsx)("li",{children:"PHI (Pre-Harvested Interval): Time limit for harvesting after application. Measured in days."}),Object(y.jsx)("li",{children:"REI/PHI: Is indicated on the label of the preparation and/or on the manufacturer's website."})]}),Object(y.jsx)("p",{className:"text-m text-neutral-1000 leading-10 py-2",children:"Note: User is responsible for checking labels for accuracy."}),u&&Object(y.jsx)(zI,{openEdit:u,onClose:V,crop:g,isEdit:v,productId:r,saveREIPHI:i})]})};return Object(a.useEffect)((function(){var e=II(n.reiphiitems,c,t);_(e)}),[t,n.reiphiitems,c]),w.length>0?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"grid justify-end py-2 mb-2",children:Object(y.jsx)(m.Button,{type:"primary",ghost:!0,onClick:function(){return M(!1)},children:"Add Crop"})}),Object(y.jsx)("div",{className:"crops-container border-b",children:Object(y.jsx)(m.Columns,{wrap:!0,children:Object(ne.sortBy)(w,"name").map((function(e,t){return Object(y.jsx)(m.Column,{width:"gr-w-1/2 p-4",children:Object(y.jsx)(MI,{product:e,editClick:function(){return M(!0,Object(I.a)(Object(I.a)({},e),{},{i:t}))},deleteClick:function(){L(e),T(!0)}})},e.cropid)}))})}),Object(y.jsx)("div",{className:"ml-6",children:B()}),Object(y.jsx)(ao,{open:S,title:"Delete REI/PHI Information?",close:F,cancelLabel:"Cancel",confirmLabel:"Delete",onCancel:F,type:"error",onConfirm:function(){o(k,F)},children:Object(y.jsx)("div",{className:"pr-6",children:"Are you sure you want to delete this information? This action cannot be undone."})})]}):Object(y.jsx)(EI,{setPermission:function(){return!0},openAddEditModal:M,children:B()})});ZI.defaultProps={dataREIPHI:[]};var YI=ZI,HI=function(){var e=Object(p.j)().id,t=Object(a.useContext)(ac),n=Object(b.a)(t,1)[0].isGlobalCropSeasonLoading,r=QR(),c=r.products,i=r.loading,o=uI(e),s=o.reiphiData,l=o.reiphiLoading,d=o.saveREIPHI,u=o.deleteREIPHI,j=Object(a.useState)(null),f=Object(b.a)(j,2),O=f[0],h=f[1],x=Object(a.useState)(null),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(s),S=Object(b.a)(A,2),T=S[0],N=S[1],E=oI(e),w=E.tasks,_=E.tasksLoading,R=bI(e),D=R.invoices,k=R.invsLoading,L=dI(e),F=L.dataDocumentation,M=L.isLoading,V=L.openFile,B=L.error,U=rv({fetchType:gm,isCacheOn:!0}),z=U.dataSorted,Z=U.reloadData,Y=Object(a.useMemo)((function(){var t=c.find((function(t){return t.productId===e||t.id===e}));return Object(I.a)(Object(I.a)({},t),{},{productName:(null===t||void 0===t?void 0:t.name)||(null===t||void 0===t?void 0:t.productName),manufacturer:null===t||void 0===t?void 0:t.manufacturer})}),[c,e]),H=function(e){if(e){var t=Object(v.a)(T),n=null===T||void 0===T?void 0:T.findIndex((function(t){return t.cropId===e.cropId}));n>-1?t[n]=Object(I.a)(Object(I.a)({},e),{},{i:void 0}):t.push(e),N(t)}};Object(a.useEffect)((function(){s&&N(s)}),[s]),Object(a.useEffect)((function(){B&&P(B)}),[B]);return Object(y.jsxs)(y.Fragment,{children:[O&&Object(y.jsx)(p.b,{push:!0,to:O}),Object(y.jsxs)("div",{className:"h-full w-full",children:[Object(y.jsxs)(lo,{hideCropSeasonDropdown:!0,children:[Object(y.jsx)(lo.Item,{title:"Inventory",value:"All",to:Cc.inventory}),Object(y.jsx)(lo.Item,{title:"Product",value:(null===Y||void 0===Y?void 0:Y.productName)||(null===Y||void 0===Y?void 0:Y.name),isLast:!0})]}),Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"product-detail-page",children:[Object(y.jsxs)("div",{className:"flex py-4",children:[Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-sm",children:"Product Name"}),Object(y.jsx)("div",{className:"text-3xl",children:(null===Y||void 0===Y?void 0:Y.productName)||(null===Y||void 0===Y?void 0:Y.name)})]}),Object(y.jsxs)("div",{className:"ml-24 mr-4",children:[Object(y.jsx)("div",{className:"text-sm",children:"Manufacturer"}),Object(y.jsx)("div",{className:"text-3xl",children:(null===Y||void 0===Y?void 0:Y.manufacturerName)||(null===Y||void 0===Y?void 0:Y.manufacturer)})]})]}),Object(y.jsx)("div",{className:"w-full h-full py-6",children:Object(y.jsx)("div",{className:"w-full h-full",children:n||k||_||M||l||i?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(m.Tabs,{pane:!0,children:[Object(y.jsx)(m.Tabs.Tab,{label:"Inventory",children:Object(y.jsx)(TI,{id:e,selectedProduct:Y,invoices:D,tasks:w,reloadData:Z,setRedirect:h})}),Object(y.jsxs)(m.Tabs.Tab,{label:"Documentation",children:[C&&Object(y.jsx)(Qc,{icon:"error",onClose:function(){return P(null)},children:C}),Object(y.jsx)(RI,{dataDocumentation:F,openFile:V})]}),Object(y.jsx)(m.Tabs.Tab,{label:"REI/PHI",children:Object(y.jsx)(YI,{dataREIPHI:T,dataDocumentation:F,productId:e,properties:z.properties,saveREIPHI:d,deleteREIPHI:u,updateREIPHI:H})})]})})})]})]})]})},GI=[{id:"inventory",key:"inventory",path:Cc.inventory,exact:!0,secure:!0,disabled:!1,component:iI,icon:rd,nav:"leftNav"},{id:"inventorydetails",key:"inventorydetails",path:"".concat(Cc.inventory,"/:id/view"),exact:!0,secure:!0,disabled:!1,component:HI}],WI=n(413),qI=n.n(WI),JI=function(e){return Object(y.jsx)(m.Button,Object(I.a)(Object(I.a)({},e),{},{type:"primary",children:Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)(qI.a,{style:{fontSize:16}}),Object(y.jsx)("span",{className:"ml-2",children:"Edit"})]})}))},KI=function(e){var t=e.title,n=e.subtitle,a=e.children,r=e.actions;return Object(y.jsxs)("div",{"data-testid":"equipment-item-section-header",className:"flex items-center w-full",children:[a&&Object(y.jsx)("div",{"data-class":"py-2",className:"w-10 h-10 text-center rounded",children:Object(y.jsx)("div",{className:"flex items-center h-full align-middle",children:a})}),Object(y.jsxs)("div",{className:"flex-1",children:[Object(y.jsx)("div",{className:"font-bold text-syngenta-navy",children:t}),Object(y.jsx)("div",{className:"text-xs text-gray-600",children:n})]}),r]})};KI.defaultProps={title:"",subtitle:"",children:null,actions:null};var QI=KI,XI=Fu.e().shape({name:Fu.f().trim().required(),primaryContactEmail:Fu.f().email("Primary Contact Email is not valid"),primaryContactPhoneNumber:Fu.f().matches(/^[+]?(1\-|1\s|1|\d{3}\-|\d{3}\s)?((\(\d{3}\))|\d{3})(\-|\s)?(\d{3})(\-|\s)?(\d{4,7})$/g,"Primary Contact phone number is not valid")}),$I=function(e){var t,n=e.organization,r=e.onSave,c=e.userDetails,i=e.members,o=Object(I.a)(Object(I.a)({},n),{},{primaryContactEmail:(null===n||void 0===n?void 0:n.primaryContactEmail)||"",primaryContactName:(null===n||void 0===n?void 0:n.primaryContactName)||"",primaryContactPhoneNumber:(null===n||void 0===n?void 0:n.primaryContactPhoneNumber)||"",billingAddress:Object(I.a)(Object(I.a)({},null===n||void 0===n?void 0:n.billingAddress),{},{address1:(null===n||void 0===n||null===(t=n.billingAddress)||void 0===t?void 0:t.address1)||""})}),s=Object(a.useState)({id:"",name:"",email:"",memberStatus:"",role:""}),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(!1),p=Object(b.a)(j,2),f=p[0],v=p[1],O=!f,h=function(){v((function(e){return!e}))};Object(a.useEffect)((function(){if((null===i||void 0===i?void 0:i.length)>0){var e=null===i||void 0===i?void 0:i.filter((function(e){return e.accountId===c.id}))[0];"Pending"!==(null===e||void 0===e?void 0:e.memberStatus)&&u({id:(null===e||void 0===e?void 0:e.accountId)||"",name:(null===e||void 0===e?void 0:e.name)||"",email:(null===e||void 0===e?void 0:e.email)||"",memberStatus:(null===e||void 0===e?void 0:e.memberStatus)||"",role:(null===e||void 0===e?void 0:e.role)||""})}}),[i,c.id]);return Object(y.jsx)("div",{"data-testid":"organization-detail",className:"mb-6",children:Object(y.jsx)(Zi.e,{initialValues:o,enableReinitialize:!0,validationSchema:XI,onSubmit:function(e){r({id:e.id,name:e.name,primaryContactName:e.primaryContactName||"",primaryContactEmail:e.primaryContactEmail||"",primaryContactPhoneNumber:e.primaryContactPhoneNumber||"",billingAddress:{address1:e.billingAddress.address1||"",address2:"",postCode:"",state:"",country:""},languageCountry:n.languageCountry||"en-US",areaUnit:n.areaUnit||"acres",masterListGroup:"en-US",timeZone:n.timeZone||"GMT"}),v(!1)},children:function(e){var t,n=e.submitForm,a=e.resetForm,r=e.values,c=e.setFieldValue;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex items-center mt-2",children:[Object(y.jsx)(QI,{title:"Organization",children:Object(y.jsx)("svg",{width:"30",height:"23",viewBox:"0 0 30 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M4.5 9.85714C6.15469 9.85714 7.5 8.38371 7.5 6.57143C7.5 4.75915 6.15469 3.28571 4.5 3.28571C2.84531 3.28571 1.5 4.75915 1.5 6.57143C1.5 8.38371 2.84531 9.85714 4.5 9.85714ZM25.5 9.85714C27.1547 9.85714 28.5 8.38371 28.5 6.57143C28.5 4.75915 27.1547 3.28571 25.5 3.28571C23.8453 3.28571 22.5 4.75915 22.5 6.57143C22.5 8.38371 23.8453 9.85714 25.5 9.85714ZM27 11.5H24C23.175 11.5 22.4297 11.8645 21.8859 12.4549C23.775 13.5895 25.1156 15.6379 25.4062 18.0714H28.5C29.3297 18.0714 30 17.3373 30 16.4286V14.7857C30 12.9734 28.6547 11.5 27 11.5ZM15 11.5C17.9016 11.5 20.25 8.9279 20.25 5.75C20.25 2.5721 17.9016 0 15 0C12.0984 0 9.75 2.5721 9.75 5.75C9.75 8.9279 12.0984 11.5 15 11.5ZM18.6 13.1429H18.2109C17.2359 13.6562 16.1531 13.9643 15 13.9643C13.8469 13.9643 12.7688 13.6562 11.7891 13.1429H11.4C8.41875 13.1429 6 15.792 6 19.0571V20.5357C6 21.8962 7.00781 23 8.25 23H21.75C22.9922 23 24 21.8962 24 20.5357V19.0571C24 15.792 21.5812 13.1429 18.6 13.1429ZM8.11406 12.4549C7.57031 11.8645 6.825 11.5 6 11.5H3C1.34531 11.5 0 12.9734 0 14.7857V16.4286C0 17.3373 0.670312 18.0714 1.5 18.0714H4.58906C4.88438 15.6379 6.225 13.5895 8.11406 12.4549Z",fill:"#73DB78"})})}),f?Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:function(){a(),h()},children:"Cancel"}),Object(y.jsx)("div",{className:"ml-2",children:Object(y.jsx)(m.Button,{type:"submit",onClick:n,children:"Save"})})]}):(t=null===d||void 0===d?void 0:d.role,"FULL CONTROL"!==t.toUpperCase()?Object(y.jsx)(JI,{onClick:h}):Object(y.jsx)(JI,{onClick:h,disabled:!0}))]}),Object(y.jsx)(ll,{children:Object(y.jsx)(m.Form,{children:Object(y.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[Object(y.jsx)(m.Form.Field,{label:"Organization Name",children:Object(y.jsx)(Qi,{control:m.Input,name:"name",disabled:O})}),Object(y.jsx)("div",{}),Object(y.jsx)(m.Form.Field,{label:"Primary Contact Name",children:Object(y.jsx)(Qi,{control:m.Input,name:"primaryContactName",disabled:O})}),Object(y.jsx)(m.Form.Field,{label:"Primary Contact Email",children:Object(y.jsx)(Qi,{control:m.Input,name:"primaryContactEmail",disabled:O})}),Object(y.jsx)(m.Form.Field,{label:"Billing Address",children:Object(y.jsx)(Qi,{control:m.Input,name:"billingAddress.address1",disabled:O})}),Object(y.jsx)(m.Form.Field,{label:"Primary Contact Phone Number",children:Object(y.jsx)(Qi,{control:m.Input,name:"primaryContactPhoneNumber",disabled:O,onBlur:function(){return function(e,t){var n=e.replace(/[^\d]/g,"");10===n.length?t("primaryContactPhoneNumber","(".concat(n.slice(0,3),") ").concat(n.slice(3,6),"-").concat(n.slice(6))):n.length>10&&t("primaryContactPhoneNumber","+".concat(n))}(r.primaryContactPhoneNumber,c)}})})]})})})]})}})})};$I.defaultProps={organization:null,userDetails:{},members:[]};var eD=$I,tD=function(e){var t=e.orgName,n=e.deleteConfirm,a=e.setDeleteConfirm,r=e.error;return Object(y.jsxs)("div",{className:"flex flex-col items-center justify-center pr-6 -ml-6 text-center",children:[Object(y.jsx)("svg",{width:"162",height:"162",viewBox:"0 0 162 162",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"mt-6 mb-10",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M80.919 0.166626C36.299 0.166626 0.166504 36.38 0.166504 81C0.166504 125.62 36.299 161.833 80.919 161.833C125.62 161.833 161.833 125.62 161.833 81C161.833 36.38 125.62 0.166626 80.919 0.166626ZM89.0832 89.0833V40.5833H72.9165V89.0833H89.0832ZM89.0832 121.417V105.25H72.9165V121.417H89.0832ZM16.3332 81C16.3332 116.728 45.2715 145.667 80.9998 145.667C116.728 145.667 145.666 116.728 145.666 81C145.666 45.2716 116.728 16.3333 80.9998 16.3333C45.2715 16.3333 16.3332 45.2716 16.3332 81Z",fill:"#CF3537"})}),Object(y.jsxs)("div",{className:"mb-2 text-2xl font-semibold leading-8",children:["Delete the organization ",t,"?"]}),Object(y.jsx)("p",{className:"mb-24 text-lg leading-7",children:"You are about to permanently delete this organization. This cannot be undone. Are you sure you want to proceed?"}),Object(y.jsx)("div",{className:"mb-10",children:Object(y.jsxs)("div",{className:"flex items-center ",children:[Object(y.jsx)("div",{className:"mr-4",children:" Type \u201cDelete\u201d to confirm"}),Object(y.jsx)(m.Input,{placeholder:"Type Here",value:n,onChange:function(e){return a(e.target.value)},error:r,errorMessage:r})]})})]})},nD=function(e){var t=e.open,n=e.close,r=e.orgName,c=Object(a.useContext)(ac),i=Object(b.a)(c,2),o=i[0],s=o.organization,l=o.organizations,d=i[1],u=Object(a.useState)(!1),j=Object(b.a)(u,2),p=j[0],f=j[1],v=Object(a.useState)(!1),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(""),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(!1),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Oc().setOrganization,_=h?Object(y.jsx)(tD,{orgName:r,deleteConfirm:P,setDeleteConfirm:A,error:N}):Object(y.jsxs)("span",{children:["You are about to permanently delete ",r,". This cannot be undone. Are you sure you want to proceed?"]}),R=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(h){e.next=4;break}x(!0),e.next=13;break;case 4:if("delete"!==P.toLowerCase()){e.next=12;break}return f(!0),t=null===l||void 0===l?void 0:l.find((function(e){return!(null===s||void 0===s||!s.id)&&(null===e||void 0===e?void 0:e.id)!==(null===s||void 0===s?void 0:s.id)})),n=Jt.delete(),a=n.promise,e.next=10,a.then((function(){if(!t)return localStorage.removeItem("selectedOrganizationId"),void(window.location="/app/welcome");w(t),window.location="".concat(Cc.organizations,"/").concat(t.id)})).catch(Ae.default).catch((function(e){f(!1),uc(d)(e)}));case 10:e.next=13;break;case 12:E("Invalid input");case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)(m.SimpleModal,{open:t,title:"Delete this Organization?",close:n,cancelLabel:"Cancel",confirmLabel:"Delete",onCancel:function(){return n(),void x(!1)},type:"error",onConfirm:R,isSaving:p,children:_})};tD.defaultProps={error:null},nD.defaultProps={orgName:""};var aD=Object(p.l)(nD),rD=function(e){var t=e.organization,n=Object(a.useState)(!1),r=Object(b.a)(n,2),c=r[0],i=r[1];return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(aD,{open:c,orgName:null===t||void 0===t?void 0:t.name,close:function(){return i(!1)}}),Object(y.jsxs)("div",{className:"flex items-center justify-between pt-6 pb-12 ml-6",children:[Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-lg text-syngenta-navy",children:"Delete Organization"}),Object(y.jsx)("div",{className:"text-sm text-neutral-300",children:"Deleting an organization is an irreversible action."})]}),Object(y.jsx)(m.Button,{danger:!0,type:"text",onClick:function(){return i(!0)},children:"Delete"})]})]})};rD.defaultProps={organization:null};var cD=rD,iD=n(2848),oD=function(e,t){var n=null===e||void 0===e?void 0:e.split(" ");if(void 0!==e){if(2===(null===n||void 0===n?void 0:n.length)&&"Full control"===e)return n[0]+n[1].charAt(0).toUpperCase()+n[1].substring(1);if(2===(null===n||void 0===n?void 0:n.length)&&"View Only"===e)return n[0]+n[1];if("Admin"===(null===e||void 0===e?void 0:e.role))return n[0]}else{var a,r=null===t||void 0===t||null===(a=t.role)||void 0===a?void 0:a.split(" ");if("Full control"===(null===t||void 0===t?void 0:t.role))return r[0]+r[1].charAt(0).toUpperCase()+r[1].substring(1);if("View Only"===(null===t||void 0===t?void 0:t.role))return r[0]+r[1];if("Admin"===(null===t||void 0===t?void 0:t.role))return r[0]}return""},sD=function(e){var t=e.selected,n=e.disabled,a=e.onClick,r=e.display,c=e.icon,i=e.id,o="".concat(n&&"opacity-25 cursor-not-allowed");return Object(y.jsxs)("button",{id:i,"data-testid":"user-role-".concat(Object(ne.kebabCase)(i)),style:{width:"154px",height:"96px"},className:"group border-cornflower-blue-500 border p-2 rounded mr-2 focus:outline-none\n        ".concat(t?"bg-cornflower-blue-500 text-white font-bold":"hover:bg-opacity-25 active:bg-opacity-50 hover:bg-blue-200 bg-white hover:cornflower-blue-200 text-cornflower-blue-500"," ").concat(o),type:"button",disabled:n,onClick:a,children:[c,Object(y.jsx)("div",{className:"whitespace-no-wrap truncate ".concat(t?"text-white":"text-cornflower-blue-500"),children:r})]})};sD.defaultProps={id:"",selected:!1,disabled:!1,display:"",icon:Object(y.jsx)(ui.a,{size:"2x"})};var lD=sD,dD={Author:"Can modify data directly associated with the user either by authorship or assignment.",FullControl:"Grants full control over all organization record management and reporting. Cannot manipulate organization profile details. This user type can view, but not manage other member permissions or invite other users.",Admin:"Grants administrative control over all organizational data. This user type can manage other member permissions, including inviting other users.",ViewOnly:"Grants read-only access to all organization records and reporting. This user cannot view or manage other member permissions."},uD=function(e){var t=e.field,n=t.value,a=t.name,r=t.onChange,c=e.singleMember,i=dD[n]||"",o=Object(Zi.h)().setFieldValue,s=function(e){"Admin"===e?o("financialAccess","WRITE"):("ViewOnly"===e||"FullControl"===e)&&o("financialAccess",null),r({target:{value:e,name:a}})};return Object(y.jsxs)("div",{"data-testid":"userRole",children:[Object(y.jsx)("p",{className:"text-lg font-medium text-syngenta-navy",children:"User Role"}),Object(y.jsx)("p",{className:"mb-6 font-medium text-gray-600",children:"Control what the members of your organization have access to."}),Object(y.jsxs)("div",{style:{justifyContent:"space-between"},className:"flex",children:[Object(y.jsx)(lD,{id:"admin",display:"Admin",selected:"Admin"===n,onClick:function(){return s("Admin")},icon:Object(y.jsx)(ui.a,{size:"2x",icon:di.u}),disabled:"Full control"===(null===c||void 0===c?void 0:c.role)}),Object(y.jsx)(lD,{id:"fullControl",display:"Full Control",selected:"FullControl"===n,onClick:function(){return s("FullControl")},icon:Object(y.jsx)(ui.a,{size:"2x",icon:di.c})}),Object(y.jsx)(lD,{id:"viewOnly",display:"View Only",selected:"ViewOnly"===n,onClick:function(){return s("ViewOnly")},icon:Object(y.jsx)(ui.a,{size:"2x",icon:di.h}),disabled:"Full control"===(null===c||void 0===c?void 0:c.role)&&"READ"===(null===c||void 0===c?void 0:c.financialAccess)})]}),Object(y.jsx)("div",{"data-testid":"userRoleText",className:"h-10 mt-6 mb-10 text-sm text-center text-gray-600",children:i})]})},bD=function(e){var t=e.disabled,n=e.id,a=e.isSelected,r=e.name,c=e.onToggle,i="".concat(t&&"opacity-25 cursor-not-allowed");return Object(y.jsx)("button",{disabled:t,style:{width:"154px",height:"64px"},className:"\n      border border-cornflower-blue-500 font-medium rounded p-2 rounded mr-2 focus:outline-none\n        ".concat(a?"bg-cornflower-blue-500 text-white font-bold":"hover:bg-opacity-25 active:bg-opacity-50 hover:bg-blue-200 bg-white text-cornflower-blue-500","\n        ").concat(i,"\n      "),type:"button","data-testid":n||"financial-".concat(Object(ne.kebabCase)(r)),onClick:c,children:r})};bD.defaultProps={disabled:null,id:"",isSelected:!1,name:""};var jD=bD,pD=function(e){var t=e.field,n=t.value,a=t.onChange,r=t.name,c=e.singleMember,i=Object(Zi.f)("role"),o=Object(b.a)(i,1)[0].value,s={Admin:["WRITE"],Author:["WRITE","READ","none"],FullControl:["WRITE"],ViewOnly:["READ"]}[o]||[],l=function(e){a({target:{value:e,name:r}})};return Object(y.jsxs)("div",{className:"font-medium text-syngenta-navy",children:[Object(y.jsx)("p",{className:"text-lg ",children:"Financial Information Access"}),Object(y.jsx)("p",{className:"mb-6 text-gray-600",children:"Control how much access a member has to financial information."}),Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsx)(jD,{disabled:!s.includes("WRITE")||("Full control"===(null===c||void 0===c?void 0:c.role)&&"READ"===(null===c||void 0===c?void 0:c.financialAccess)||"Full control"===(null===c||void 0===c?void 0:c.role)&&!Object.prototype.hasOwnProperty.call(c,"financialAccess")),isSelected:"WRITE"===n,onToggle:function(){return l("WRITE")},name:"Edit Access"}),Object(y.jsx)(jD,{disabled:!s.includes("READ"),isSelected:"READ"===n,onToggle:function(){return l("READ")},name:"View Only"}),Object(y.jsx)(jD,{disabled:!s.includes("none"),isSelected:"none"===n,onToggle:function(){return l("none")},name:"No Access"})]})]})},fD=Fu.e().shape({firstName:Fu.f().trim().required("First name is required"),lastName:Fu.f().trim().required("Last name is required"),email:Fu.f().email().required("Email is not valid")}),mD=Jt.createChildApi({action:"organization/member/invite"}),vD=Jt.createChildApi({action:"organization/member"}),OD=function(e){var t=e.data,n=e.open,r=e.onClose,c=e.getOrganization,i=e.singleMember,o=Object(a.useContext)(ac),s=Object(b.a)(o,2)[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],f=Object(a.useState)(""),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(p.h)(),g="";g="https://qa.financials.cropwise.com/app/property-landing";var C,P,A=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return j(!0),e.next=3,mD.create(t);case 3:n=e.sent,n.promise.then((function(){c(),j(!1),r()})).catch(Ae.default).catch((function(e){e.response.data.message.includes("Member already present in given org")&&500===e.response.status?(h("The email address you are trying to use is already associated with a member of your organization."),j(!1)):(uc(s)(e),j(!1))}));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),S=function(e){return{accountId:e.accountId,name:"".concat(e.firstName," ").concat(e.lastName),financialAccess:e.financialAccess,role:e.role}},T=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=S(t),j(!0),a=vD.update(null,n),a.promise.then((function(){var e,n;e=t.role,n=t.financialAccess,c(),j(!1),r(),"ViewOnly"===e&&(x.push(Cc.properties),s({type:"SELECT_MEMBER",payload:{role:er,financialAccess:n}}))})).catch(Ae.default).catch((function(e){uc(s)(e),j(!1)}));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),N=function(){var e;return(null===t||void 0===t||null===(e=t.accountId)||void 0===e?void 0:e.length)>0&&"Revoked"===(null===t||void 0===t?void 0:t.memberStatus)?"Grant Access":void 0===(null===t||void 0===t?void 0:t.accountId)&&"Revoked"===(null===t||void 0===t?void 0:t.memberStatus)?"Resend Invite":"Invite Member"};return Object(y.jsx)(Zi.e,{initialValues:{firstName:(null===t||void 0===t?void 0:t.firstName)||function(e){var t,n=null===e||void 0===e?void 0:e.split(" ");if((null===n||void 0===n?void 0:n.length)>0&&(null===(t=n[0])||void 0===t?void 0:t.length)>0)return n[0];return""}(null===t||void 0===t?void 0:t.name)||"",lastName:(null===t||void 0===t?void 0:t.lastName)||function(e){var t,n=null===e||void 0===e?void 0:e.split(" ");if((null===n||void 0===n?void 0:n.length)>0&&(null===(t=n[1])||void 0===t?void 0:t.length)>0)return n[1];return""}(null===t||void 0===t?void 0:t.name),email:(null===t||void 0===t?void 0:t.email)||"",financialAccess:(C=t,P=i,("Joined"!==(null===C||void 0===C?void 0:C.memberStatus)?"Full control"===(null===P||void 0===P?void 0:P.role)||"View Only"===(null===P||void 0===P?void 0:P.role)?"READ":"WRITE":"Admin"===(null===C||void 0===C?void 0:C.role)||"Full control"===(null===C||void 0===C?void 0:C.role)&&"WRITE"===(null===C||void 0===C?void 0:C.financialAccess)||"Full control"===(null===C||void 0===C?void 0:C.role)&&"READ"===(null===C||void 0===C?void 0:C.financialAccess)?null===C||void 0===C?void 0:C.financialAccess:"Full control"!==(null===C||void 0===C?void 0:C.role)||Object.prototype.hasOwnProperty.call(C,"financialAccess")?"View Only"===(null===C||void 0===C?void 0:C.role)&&"READ"===(null===C||void 0===C?void 0:C.financialAccess)?null===C||void 0===C?void 0:C.financialAccess:"View Only"!==(null===C||void 0===C?void 0:C.role)||Object.prototype.hasOwnProperty.call(C,"financialAccess")?"":"none":"none")||""),role:oD(null===t||void 0===t?void 0:t.role,i)||"Admin",accountId:(null===t||void 0===t?void 0:t.accountId)||""},enableReinitialize:!0,validationSchema:fD,onSubmit:function(e){if(e.accountId){var t=e;delete t.email,T(t)}else{delete e.accountId,e.financialAccess?A({name:"".concat(e.firstName," ").concat(e.lastName),email:e.email,role:e.role,clientId:"ddcd4fe8157148fc90b0fe95753f2bd0",redirectUri:g,financialAccess:e.financialAccess}):h("Please select a level of Financial Information Access.")}},children:function(e){var a=e.handleSubmit,c=e.resetForm;return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.SimpleModal,{cancelLabel:"Cancel",onConfirm:a,confirmLabel:"Save",open:n,close:function(){r(),c(),h("")},title:N(),isSaving:u,children:[O&&Object(y.jsx)(m.Toast,{icon:"error",duration:7e3,onClose:function(){return h("")},children:O}),Object(y.jsx)("div",{"data-testid":"inviteModal",className:"pr-6 mt-8",children:Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"grid grid-cols-2 gap-6 mb-12",children:[Object(y.jsx)(Qi,{control:m.Input,label:"First Name",name:"firstName"}),Object(y.jsx)(Qi,{control:m.Input,label:"Last Name",name:"lastName"})]}),Object(y.jsxs)("div",{className:"mb-8",children:[Object(y.jsx)(Qi,{control:m.Input,label:"Email",name:"email",disabled:null===t||void 0===t?void 0:t.email,imask:{mask:/^[ A-Za-z0-9_@./#-]*$/}}),Object(y.jsxs)("div",{className:"text-neutral-600 text-base mt-2 ".concat(null!==t&&void 0!==t&&t.email?"":"hidden"),children:["In order to change email address, you must request a",Object(y.jsxs)("span",{className:"text-neutral-1000",children:[" ","new invitation."]})]})]}),Object(y.jsx)(Zi.b,{name:"role",component:uD,singleMember:i}),Object(y.jsx)(Zi.b,{name:"financialAccess",component:pD,singleMember:i})]})})]})})}})};OD.defaultProps={data:null,open:!1,onClose:function(){},getOrganization:function(){},singleMember:{}};var hD=OD,xD=function(e){var t,n,a,r=e.member,c=e.status,i=e.statusDate,o=new Date(i),s=function(){var e=new Date,t=new Date(i),n=new Date(Object(ya.a)(t.setDate(t.getDate()+30),"MMMM d, yyyy"));return"Pending"===c&&e>n};return"Joined"===c?(t="#14803C",n="#8CD0A5",a="Member Joined on ".concat(Object(ya.a)(o,"MMMM d, yyyy"))):"Expired"===c||s()?(t="#787D96",n="#D7DAE0",a="Invitation Expired on ".concat(Object(ya.a)(o,"MMMM d, yyyy"))):"Pending"===c?(t="#E99921",n="#FFE4AE",a="Invite Pending, expires on ".concat(Object(ya.a)(o.setDate(o.getDate()+30),"MMMM d, yyyy"))):"Revoked"===c&&(t="#D95032",n="#FFAEAE",a="".concat("Revoked"===c&&void 0===(null===r||void 0===r?void 0:r.accountId)?"Invite":"Access"," Revoked on  ").concat(Object(ya.a)(o,"MMMM d, yyyy"))),Object(y.jsxs)("div",{"data-testid":"member-invite-status",className:"flex flex-col items-start text-sm leading-5 capitalize text-neutral-600",children:[Object(y.jsx)("div",{children:Object(y.jsx)(m.Tag,{color:n,children:Object(y.jsx)("span",{style:{color:t},children:s()?"Expired":c})})}),Object(y.jsx)("div",{children:a})]})};xD.defaultProps={status:null,statusDate:null};var gD=xD,CD=function(e){var t=e.open,n=e.onClose,r=e.invitationId,c=e.getOrganization,i=Object(a.useContext)(ac),o=Object(b.a)(i,2)[1],s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Jt.createChildApi({action:"organization/invitation"}),p=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:u(!0),t=j.delete(r),t.promise.then((function(){c(),u(!1),n()})).catch(Ae.default).catch((function(e){uc(o)(e),u(!1),n()}));case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)("div",{"data-testid":"cancel-invite",children:Object(y.jsx)(m.SimpleModal,{onConfirm:p,open:t,close:n,title:"Cancel Invite",type:"confirmation",isSaving:d,children:Object(y.jsx)("div",{className:"pr-6",children:"Are you sure you want to cancel this Invite?"})})})};CD.defaultProps={open:!1,onClose:function(){},invitationId:"",getOrganization:function(){}};var yD=CD,PD=function(e){var t=e.open,n=e.onClose,r=e.accountId,c=e.getOrganization,i=Object(a.useContext)(ac),o=Object(b.a)(i,2)[1],s=(Object(p.j)().id,Object(a.useState)(!1)),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Jt.createChildApi({action:"organization/account/".concat(r,"/revoke")}),f=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:u(!0),t=j.delete(null),t.promise.then((function(){c(),u(!1),n()})).catch(Ae.default).catch((function(e){uc(o)(e),u(!1),n()}));case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)("div",{"data-testid":"RevokeAccessModal",children:Object(y.jsx)(m.SimpleModal,{onConfirm:f,open:t,close:n,title:"Revoke Access",type:"confirmation",isSaving:d,children:Object(y.jsx)("div",{className:"pr-6",children:"Are you sure you want to revoke this member's access?"})})})};PD.defaultProps={open:!1,onClose:function(){},accountId:"",getOrganization:function(){}};var AD=PD,SD=function(e){var t=e.open,n=e.onClose,r=e.accountId,c=e.getOrganization,i=Object(a.useContext)(ac),o=Object(b.a)(i,2)[1],s=Object(p.j)().id,l=Object(p.h)(),d=Object(a.useState)(!1),u=Object(b.a)(d,2),j=u[0],f=u[1],v=Jt.createChildApi({action:"organization/account/".concat(r)}),O=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:f(!0),t=v.delete(null),t.promise.then((function(){l.replace("".concat(Cc.organizations,"/").concat(s)),c()})).catch(Ae.default).catch((function(e){uc(o)(e)})).finally((function(){f(!1),n()}));case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)("div",{"data-testid":"DeleteRevokedModal",children:Object(y.jsx)(m.SimpleModal,{onConfirm:O,open:t,close:n,title:"Delete Revoked",type:"confirmation",isSaving:j,children:Object(y.jsx)("div",{className:"pr-6",children:"Are you sure you want to delete this revoked member from your list?"})})})};SD.defaultProps={open:!1,onClose:function(){},accountId:"",getOrganization:function(){}};var TD=SD,ND=function(e){var t=e.member,n=e.getOrganization,r=e.userDetails,c=e.singleMember,i=Object(a.useState)(!1),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(!1),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(!1),m=Object(b.a)(f,2),v=m[0],O=m[1],h=Object(a.useState)(!1),x=Object(b.a)(h,2),g=x[0],C=x[1],P=We().user,A=t.memberStatus,S=t.email,T=[];"Pending"!==A&&"Revoked"!==A&&(T=qo(T,{value:"editAccess",text:"Edit Access"})),"Pending"===A&&(T=qo(T,{value:"revokeInvite",text:"Revoke Invite",className:"text-red-500"})),"Joined"===A&&S!==P.email&&(T=qo(T,{value:"revokeAccess",text:"Revoke Access",className:"text-red-500"})),"Revoked"===A&&(T=qo(T,{value:"resendInvite",text:"Resend Invite"}),T=qo(T,rs("delete")));return Object(y.jsxs)("div",{"data-testid":"more-button",children:[Object(y.jsx)(hD,{open:s,data:t,onClose:l,getOrganization:n,userDetails:r,singleMember:c}),Object(y.jsx)(AD,{open:j,accountId:t.accountId,onClose:p,getOrganization:n}),Object(y.jsx)(TD,{open:g,accountId:t.accountId,member:t,onClose:C,getOrganization:n}),Object(y.jsx)(yD,{open:v,invitationId:t.invitationId,onClose:O,getOrganization:n}),Object(y.jsx)(Wo,{onAction:function(e){({editAccess:function(){return l(!s)},revokeInvite:function(){return O(!v)},revokeAccess:function(){return p(!j)},resendInvite:function(){return l(!s)},delete:function(){return C(!g)}})[e]()},options:T})]})};ND.defaultProps={member:{},getOrganization:function(){},singleMember:{},userDetails:{}};var ED=ND,wD=function(e){var t=e.onClick;return e.members?Object(y.jsxs)("div",{className:"flex flex-col items-center justify-center h-64 bg-white rounded shadow-md radius",children:[Object(y.jsx)("div",{className:"px-4 text-xl leading-6 text-center text-gray-800",children:"This organization doesn\u2019t have members yet."}),Object(y.jsx)("div",{className:"px-4 mt-2 mb-10 text-base leading-5 text-center text-gray-700",children:"Add some to include them in tasks and reports."}),Object(y.jsx)(m.Button,{icon:Object(y.jsx)(Hs.a,{}),type:"primary",iconRight:!0,onClick:function(){return t(!0)},children:"Start here"})]}):Object(y.jsx)(m.Spinner,{})},_D=function(e){var t=e.members,n=e.getOrganization,r=e.userDetails,c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)([]),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(),f=Object(b.a)(p,2),v=f[0],O=f[1],h=Object(a.useState)(!1),x=Object(b.a)(h,2),g=x[0],C=x[1];return Object(a.useEffect)((function(){var e=null===t||void 0===t?void 0:t.filter((function(e,t,n){return n.findIndex((function(t){return t.accountId===e.accountId&&t.name===e.name}))===t||"Pending"===e.memberStatus})).filter((function(e){return!Object.prototype.hasOwnProperty.call(e,"accountId")&&"Pending"===e.memberStatus||"Joined"===e.memberStatus||Object.prototype.hasOwnProperty.call(e,"accountId")&&("Expired"===e.memberStatus||"Revoked"===e.memberStatus)}));e&&j(Object(Ru.a)(e))}),[t]),Object(a.useEffect)((function(){var e=null===t||void 0===t?void 0:t.filter((function(e){return(null===e||void 0===e?void 0:e.email)===(null===r||void 0===r?void 0:r.email)}))[0];O(e)}),[t,null===r||void 0===r?void 0:r.email]),Object(a.useEffect)((function(){void 0===o&&(C(!0),setTimeout((function(){C(!1)}),1e3))}),[o]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(hD,{open:o,onClose:s,getOrganization:n,userDetails:r,singleMember:v}),Object(y.jsx)(QI,{title:"Organization Members",subtitle:"Add members to your organization and manage their access.",actions:Object(y.jsx)("div",{children:"Admin"===(null===v||void 0===v?void 0:v.role)&&Object(y.jsx)(m.Button,{onClick:function(){s(!0)},disabled:g,ghost:!0,type:"primary",children:"Invite Member"})}),children:Object(y.jsx)("svg",{width:"30",height:"23",viewBox:"0 0 30 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M4.5 9.85714C6.15469 9.85714 7.5 8.38371 7.5 6.57143C7.5 4.75915 6.15469 3.28571 4.5 3.28571C2.84531 3.28571 1.5 4.75915 1.5 6.57143C1.5 8.38371 2.84531 9.85714 4.5 9.85714ZM25.5 9.85714C27.1547 9.85714 28.5 8.38371 28.5 6.57143C28.5 4.75915 27.1547 3.28571 25.5 3.28571C23.8453 3.28571 22.5 4.75915 22.5 6.57143C22.5 8.38371 23.8453 9.85714 25.5 9.85714ZM27 11.5H24C23.175 11.5 22.4297 11.8645 21.8859 12.4549C23.775 13.5895 25.1156 15.6379 25.4062 18.0714H28.5C29.3297 18.0714 30 17.3373 30 16.4286V14.7857C30 12.9734 28.6547 11.5 27 11.5ZM15 11.5C17.9016 11.5 20.25 8.9279 20.25 5.75C20.25 2.5721 17.9016 0 15 0C12.0984 0 9.75 2.5721 9.75 5.75C9.75 8.9279 12.0984 11.5 15 11.5ZM18.6 13.1429H18.2109C17.2359 13.6562 16.1531 13.9643 15 13.9643C13.8469 13.9643 12.7688 13.6562 11.7891 13.1429H11.4C8.41875 13.1429 6 15.792 6 19.0571V20.5357C6 21.8962 7.00781 23 8.25 23H21.75C22.9922 23 24 21.8962 24 20.5357V19.0571C24 15.792 21.5812 13.1429 18.6 13.1429ZM8.11406 12.4549C7.57031 11.8645 6.825 11.5 6 11.5H3C1.34531 11.5 0 12.9734 0 14.7857V16.4286C0 17.3373 0.670312 18.0714 1.5 18.0714H4.58906C4.88438 15.6379 6.225 13.5895 8.11406 12.4549Z",fill:"#73DB78"})})}),Object(y.jsx)(ll,{className:"w-full mt-4",children:null!==u&&void 0!==u&&u.length?Object(y.jsxs)(m.Table,{items:u,children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{children:"Members"}),Object(y.jsx)(m.Table.Cell,{children:"Email"}),Object(y.jsx)(m.Table.Cell,{children:"Role"}),Object(y.jsx)(m.Table.Cell,{children:"Status"}),Object(y.jsx)(m.Table.Cell,{})]}),u.map((function(e){return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:e.name}),Object(y.jsx)(m.Table.Cell,{children:e.email}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("span",{title:"hard coded data",children:e.role})}),Object(y.jsx)(m.Table.Cell,{children:e.memberStatus&&Object(y.jsx)(gD,{member:e,status:e.memberStatus,statusDate:e.date})}),Object(y.jsx)(m.Table.Cell,{children:"Admin"===(null===v||void 0===v?void 0:v.role)&&Object(y.jsx)(ED,{member:e,getOrganization:n,userDetails:r,singleMember:v})})]},e.accountId)}))]}):Object(y.jsx)(wD,{onClick:s,members:u})})]})};_D.defaultProps={getOrganization:function(){},members:null,userDetails:{}},wD.defaultProps={onClick:function(){}};var RD=_D,ID=function(){var e=We().user,t=Object(a.useState)(null),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)(!1),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useContext)(ac),u=Object(b.a)(d,2),j=u[0].organization,f=u[1],v=Object(a.useState)(),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(!1),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useCallback)(Object(Y.a)(G.a.mark((function t(){var n,a;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return l(!0),n=Jt.fetch(),a=n.promise,t.next=4,a.then((function(t){var n,a=t.data;c(a);var r=null===a||void 0===a||null===(n=a.members)||void 0===n?void 0:n.filter((function(t){return t.email===e.email}))[0];x(r),l(!1)})).catch(Ae.default).catch((function(e){l(!1),uc(f)(e)}));case 4:case"end":return t.stop()}}),t)}))),[f,e.email]),_=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Jt.update(null,t,!1),a=n.promise,e.next=3,a.then((function(){A("Your changes have been saved!"),location.reload()})).catch(Ae.default).catch((function(e){uc(f)(e)}));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();Object(a.useEffect)((function(){r||w()}),[r,w]);return Object(y.jsxs)(y.Fragment,{children:[N&&Object(y.jsx)(p.b,{push:!0,to:{pathname:"".concat(Cc.organizations,"/").concat(j.id)}}),Object(y.jsx)(lo,{onOrganizationSelect:function(){E(!0),w()}}),P&&Object(y.jsx)(m.Toast,{isError:!1,onClose:function(){return A()},children:P}),Object(y.jsx)(y.Fragment,{children:s?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(eD,{organization:r,onSave:_,userDetails:e,members:null===r||void 0===r?void 0:r.members}),Object(y.jsx)(RD,{members:null===r||void 0===r?void 0:r.members,getOrganization:w,userDetails:e}),"Full control"!==(null===h||void 0===h?void 0:h.role)&&Object(y.jsx)(cD,{organization:r})]})})]})};ID.defaultProps={};var DD=ID,kD=[{id:"organization",key:"organizations",path:"".concat(Cc.organizations,"/:id"),secure:!0,disabled:!1,component:DD,icon:Kl,nav:"leftNav",minPermissions:{minAllowedRole:$a},redirect:Cc.properties},{id:"organizationEntry",key:"organizationEntry",path:"".concat(Cc.organizations,"/:id"),exact:!0,secure:!0,component:DD,minPermissions:{minAllowedRole:$a}}];function LD(e){var t=e.subtitle,n=e.children;return Object(y.jsx)("div",{className:"mt-4 p-10 bg-white border rounded-none sm:rounded border-neutral",children:Object(y.jsxs)("div",{className:"flex flex-col justify-center",children:[Object(y.jsx)("div",{className:"self-center",children:Object(y.jsx)("img",{width:"356",height:"318",src:dl,alt:"icon"})}),Object(y.jsx)("div",{className:"self-center mb-3",children:Object(y.jsx)("p",{children:t})}),Object(y.jsx)("div",{className:"self-center",children:n})]})})}LD.defaultProps={children:null};var FD=LD,MD=function(e){var t=e.user,n=t.id,a=t.name,r=t.email,c=t.permissionLevel,i=t.applicatorLicenseNumber,o=t.applicatorLicenseExpirationDateEpoch,s=e.menu,l=e.onAction,d=Date.parse(new Date(o)),u=d?Object(ya.a)(d,"MMM d, yyyy"):"";return Object(y.jsxs)(m.Table.Row,{id:n,children:[Object(y.jsx)(m.Table.Cell,{onClick:function(){return l("view")},children:Object(y.jsx)("span",{className:"font-bold",children:a})}),Object(y.jsx)(m.Table.Cell,{children:r}),Object(y.jsx)(m.Table.Cell,{children:i}),Object(y.jsx)(m.Table.Cell,{children:i?u:""}),Object(y.jsxs)(m.Table.Cell,{children:[Object(ne.capitalize)(c),Object(y.jsx)("div",{className:"absolute right-0 flex-none w-10 mr-2",children:s})]})]})},VD=[{field:"name",title:"Name",sortable:!0},{field:"email",title:"Email",sortable:!0},{field:"license",title:"License",sortable:!0},{field:"expirationDate",title:"Expiration Date",sortable:!0},{field:"permission",title:"Permission",sortable:!0}],BD=function(e){var t=e.people,n=e.onAction,r=e.getMenu,c=e.totalPeople,i=e.peoplePageNumber,o=e.handlePageChange,s=Object(a.useState)(),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(),p=Object(b.a)(j,2),f=p[0],m=p[1],v=Object(a.useState)(t),O=Object(b.a)(v,2),h=O[0],x=O[1];return Object(a.useEffect)((function(){x(t)}),[t]),Object(y.jsxs)(ll,{children:[Ho(c,i,o),Object(y.jsx)(ol,{listType:"People",items:h,tableColumns:VD,onSort:function(e,t){m(e),u(t),x(function(e,t,n){if(!n)return e;var a=e.map((function(e){return Object(ne.cloneDeep)(e)}));switch(t){case"name":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.name.toLowerCase()}],n);case"email":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.email}],n);case"license":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.applicatorLicenseNumber}],n);case"expirationDate":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.applicatorLicenseExpirationDateEpoch}],n);case"permission":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.permissionLevel}],n);default:return a}}(h,e,t))},sortBy:f,sortDir:d,children:function(e){return e.rows.map((function(e){return Object(y.jsx)(MD,{user:e,onAction:function(t){n(t,e)},menu:r(e)},e.id)}))}}),Ho(c,i,o),Object(y.jsx)("div",{className:"mb-12",children:" "})]})};BD.defaultProps={people:[]};var UD=BD,zD=function(e){var t=e.children;return Object(y.jsx)("div",{className:"flex items-center justify-between flex-1 md:ml-0",children:t})},ZD=function(e){var t=e.onChange,n=e.placeholder,r=e.delay,c=mo().width,i=Object(a.useState)(null),o=Object(b.a)(i,2),s=o[0],l=o[1],d=zi(s,r);return Object(a.useEffect)((function(){t(d)}),[t,d]),Object(y.jsx)("div",{children:Object(y.jsxs)("label",{children:[Object(y.jsx)("span",{className:"sr-only",children:"Search"}),Object(y.jsx)(Xc.Input,{allowClear:!0,type:"text",autoComplete:"off",prefix:Object(y.jsx)("img",{alt:"Search icon",src:Fi}),placeholder:c<=386?"Search...":n,onChange:function(e){return l(e.target.value)}})]})})};ZD.defaultProps={delay:300,placeholder:""};var YD=ZD,HD=function(e){var t=e.onChange,n=e.children;return Object(y.jsxs)("div",{className:"flex mb-4",children:[Object(y.jsx)(zD,{children:Object(y.jsx)(YD,{name:"search_people",placeholder:"Search People",onChange:t})}),n]})};HD.defaultProps={children:null};var GD=HD,WD=function(){var e=Object(a.useState)(0),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Ro("worker/people",["contactInfo.name.givenName","contactInfo.name.surname"],"contactInfo.name.givenName",n),i=c.loaded,o=c.items,s=c.setItems,l=c.totalItems,d=c.setReload,u=Object(p.h)(),j=xl("people"),f=Object(a.useContext)(we),v=Object(a.useContext)(ac),O=Object(b.a)(v,1)[0].loggedInUserOrgPermission.role,h=Object(a.useState)(null),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useState)([]),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)(null),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(!1),I=Object(b.a)(R,2),D=I[0],k=I[1],L=Object(a.useState)(!1),F=Object(b.a)(L,2),M=F[0],V=F[1];Object(a.useEffect)((function(){T(function(e,t){if(t){var n=t.match(/[^ ]+/g),a=[],r=e.filter((function(e){return function(e,t){var n=function(t){return e.name.toLowerCase().includes(t.toLowerCase())};return t.length,t.every(n)}(e,n)}));return r&&r.forEach((function(e){a.push(e)})),a}return e}(o,g))}),[o,g]);var B=function(){V(!1)},U=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(w){e.next=2;break}return e.abrupt("return");case 2:return f.sendEventToAmplitude(f.events.epic.People.deletePerson),k(!0),B(),e.next=7,j.delete(w).promise.then((function(){s((function(e){return e.filter((function(e){return e.id!==w}))}))})).catch(Ae.default).catch((function(e){console.error(e)}));case 7:_(null),k(!1);case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),z=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a={view:function(){u.push("people/".concat(n.id,"/view"))},edit:function(){f.sendEventToAmplitude(f.events.epic.People.editPerson),u.push("people/".concat(n.id))},delete:function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:_(n.id),V(!0);case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),print:function(){}},a[t]();case 2:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),Z=function(){return or({role:O},{minAllowedRole:$a})?Object(y.jsx)(m.Button,{id:"add-person-button",type:"primary",icon:Object(y.jsx)(Eo.a,{}),onClick:function(){u.push("".concat(Cc.people,"/person"))},children:"Add Person"}):null},H=function(e){return Object(y.jsx)(Wo,{onAction:function(t){z(t,e)},options:hs})},W=function(e){r(e),d(!0)};return Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"people",children:[Object(y.jsx)(lo,{onOrganizationSelect:function(){r(0),d(!0)},hideCropSeasonDropdown:!0,children:Object(y.jsx)(lo.Item,{title:"People",value:"All People",isLast:!0})}),Object(y.jsx)(GD,{onChange:C,children:Z()}),!i||D?Object(y.jsx)(m.Spinner,{}):S.length>0?Object(y.jsx)(UD,{people:S,onAction:z,getMenu:H,totalPeople:l,peoplePageNumber:n,handlePageChange:W}):Object(y.jsx)(FD,{subtitle:"We were unable to find any person under this organization.",children:Z()}),Object(y.jsx)(ib,{open:M,itemType:"Person",onCancel:B,onDelete:U})]})};function qD(e){var t=e.fullName,n=e.onChange,a=e.onBlur,r=e.errors;return Object(y.jsx)(m.Form.Field,{children:Object(y.jsxs)("div",{className:"block",children:[Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)("div",{className:"block text-sm font-medium leading-5 gr-text-gray-600 sm:mt-px sm:pt-2",children:"Name*"})}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(m.Input,{id:"full-name-input",onChange:n,onBlur:a,defaultValue:t,name:"fullName",error:r,errorMessage:r})})]})})}qD.defaultProps={fullName:"",errors:null};var JD=qD;function KD(e){var t=e.emailAddress,n=e.onChange,a=e.errors;return Object(y.jsx)(m.Form.Field,{children:Object(y.jsxs)("div",{className:"block mr-6",children:[Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)("div",{className:"block text-sm font-medium leading-5 gr-text-gray-600 sm:mt-px sm:pt-2",children:"Email Address"})}),Object(y.jsx)("div",{className:"w-auto",children:Object(y.jsx)(m.Input,{id:"email-address-input",onChange:n,defaultValue:t,name:"emailAddress",error:a,errorMessage:a})})]})})}KD.defaultProps={emailAddress:"",errors:null};var QD=KD;function XD(e){var t=e.phoneNumber,n=e.onChange,a=e.errors;return Object(y.jsx)(m.Form.Field,{children:Object(y.jsxs)("div",{className:"block ml-6",children:[Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)("div",{className:"block text-sm font-medium leading-5 gr-text-gray-600 sm:mt-px sm:pt-2",children:"Phone Number"})}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(m.Input,{id:"phone-number-input",onChange:n,defaultValue:t,name:"phoneNumber",error:a,errorMessage:a})})]})})}XD.defaultProps={phoneNumber:"",errors:null};var $D=XD;function ek(e){var t=e.streetAddress,n=e.title,a=e.name,r=e.onChange,c=e.errors,i=e.blockMargin,o=e.id,s="block ".concat(i);return Object(y.jsx)(m.Form.Field,{children:Object(y.jsxs)("div",{className:s,children:[Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)("div",{className:"block text-sm font-medium leading-5 gr-text-gray-600 sm:mt-px sm:pt-2",children:n})}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(m.Input,{id:o,onChange:r,value:t,name:a,error:c.streetAddress,errorMessage:c.streetAddress})})]})})}ek.defaultProps={streetAddress:"",title:"",name:"",errors:null,blockMargin:"",id:"id"};var tk=ek;function nk(e){var t=e.cityName,n=e.onChange,a=e.errors;return Object(y.jsx)(m.Form.Field,{children:Object(y.jsxs)("div",{className:"block mr-6",children:[Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)("div",{className:"block text-sm font-medium leading-5 gr-text-gray-600 sm:mt-px sm:pt-2",children:"City"})}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(m.Input,{id:"city-input",onChange:n,defaultValue:t,name:"cityName",error:a,errorMessage:a})})]})})}nk.defaultProps={cityName:"",errors:null};var ak=nk;function rk(e){var t=e.country,n=e.onChange,a=go(n,xo);return Object(y.jsx)(m.Select,{id:"country-select",items:[{key:"United States",value:"United States"},{key:"Canada",value:"Canada"},{key:"France",value:"France"}],value:t,onChange:a})}rk.defaultProps={country:null};function ck(e){var t=e.value,n=e.onChange,a=go(n,xo);return Object(y.jsx)(m.Select,{id:"state-select",items:Nl,value:t,onChange:a})}ck.defaultProps={value:null};var ik=ck;function ok(e){var t=e.state,n=e.setFieldValue;return Object(y.jsx)(m.Form.Field,{children:Object(y.jsxs)("div",{className:"block ml-6",children:[Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)("div",{className:"block text-sm font-medium leading-5 gr-text-gray-600 sm:mt-px sm:pt-2",children:"State"})}),Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(ik,{value:t,onChange:n})," "]})]})})}ok.defaultProps={state:null};var sk=ok;function lk(e){var t=e.postalCode,n=e.errors,a=e.onChange;return Object(y.jsx)(m.Form.Field,{children:Object(y.jsxs)("div",{className:"block ml-6",children:[Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)("div",{className:"block text-sm font-medium leading-5 gr-text-gray-600 sm:mt-px sm:pt-2",children:"Zip Code"})}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(m.Input,{id:"postal-code-input",value:t,name:"postalCode",onChange:a,error:n,errorMessage:n})})]})})}lk.defaultProps={postalCode:"",errors:null};var dk=lk;function uk(e){var t=e.notes,n=e.onChange,a=e.errors;return Object(y.jsx)(m.Form.Field,{children:Object(y.jsx)("div",{className:"block",children:Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(m.TextArea,{id:"notes-textarea",name:"notes",error:a,value:t,onChange:n,rows:"8"})})})})}uk.defaultProps={notes:"",errors:null};var bk=uk,jk=function(e){return{line1:e.streetAddress1,line2:e.streetAddress2,city:e.cityName,state:e["object Object"],zipCode:e.postalCode,country:e.country,addressId:""}},pk=function(e){var t,n,a,r,c,i;return{fullName:e.name,emailAddress:e.email,country:null===(t=e.address)||void 0===t?void 0:t.country,streetAddress1:null===(n=e.address)||void 0===n?void 0:n.line1,streetAddress2:null===(a=e.address)||void 0===a?void 0:a.line2,cityName:null===(r=e.address)||void 0===r?void 0:r.city,state:null===(c=e.address)||void 0===c?void 0:c.state,postalCode:null===(i=e.address)||void 0===i?void 0:i.zipCode,notes:e.notes,phoneNumber:e.phone,applicatorLicense:{value:e.applicatorLicenseNumber,expiry:e.applicatorLicenseExpirationDateEpoch>0?e.applicatorLicenseExpirationDateEpoch:""}}},fk=(Sd(jd,{id:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6"}),localStorage.getItem("selectedOrganizationId"),{id:"",name:"",email:"",phone:"",address:{line1:"",line2:"",city:"",state:"",zipCode:"",country:"",addressId:""},applicatorLicenseNumber:"",applicatorLicenseExpirationDateEpoch:"",applicatorLicenseExpirationDate:"",notes:""});function mk(e){var t=e.expiration,n=e.onChange,a=e.title;return Object(y.jsx)(m.Form.Field,{children:Object(y.jsx)("div",{"data-testid":"expirationField",className:"flex",children:Object(y.jsxs)("div",{className:"w-full ml-6",children:[Object(y.jsx)("div",{className:"block text-sm font-medium leading-5 gr-text-gray-600 sm:mt-px sm:pt-2",children:a}),Object(y.jsx)("div",{className:"block text-sm font-medium leading-5 text-gray-700 sm:mt-px sm:pt-2 w-full",children:Object(y.jsx)(m.DatePicker,{id:"expiry-date-picker",onChange:n,defaultValue:t,dates:t,name:"expiry",dateFormat:"M d, Y"})})]})})})}mk.defaultProps={expiration:null,title:""};var vk=mk;function Ok(e){var t=e.title,n=e.licenseNumber,a=e.onChange,r=e.errors;return Object(y.jsx)(m.Form.Field,{children:Object(y.jsx)("div",{className:"flex mr-6",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("div",{className:"block text-sm font-medium leading-5 gr-text-gray-600 sm:mt-px sm:pt-2",children:t}),Object(y.jsx)("div",{"data-testid":"license-number-field",className:"block text-sm font-medium leading-5 text-gray-700 sm:mt-px sm:pt-2",children:Object(y.jsx)(m.Input,{id:"license-number-input",onChange:a,defaultValue:n,name:"applicatorLicense",error:r,errorMessage:r})})]})})})}Ok.defaultProps={title:"",licenseNumber:"",errors:null};var hk=Ok,xk=function(e){e.isCreateScreen;var t=e.license,n=e.onChange,r=(e.handleClick,Object(a.useState)(!0)),c=Object(b.a)(r,2),i=(c[0],c[1],Date.parse(new Date(t.expiry))),o=(i&&Object(ya.a)(i,"MMM dd, yyyy"),Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-2xl font-bold mt-10",children:"License Info"}),Object(y.jsxs)("div",{className:"flex","data-testid":"applicatorLicenseUI",children:[Object(y.jsx)("div",{className:"flex w-full",children:Object(y.jsx)(hk,{title:"Applicator License",onChange:function(e){var t=e.target.value;n((function(e){return Object(I.a)(Object(I.a)({},e),{},{value:t,licenseType:"Applicator"})}))},licenseNumber:t.value})}),Object(y.jsx)("div",{className:"flex w-full",children:Object(y.jsx)(vk,{onChange:function(e){var t=e.target.value[0];n((function(n){return e.target?Object(I.a)(Object(I.a)({},n),{},{expiry:t?Date.parse(e.target.value[0].toISOString()):"",licenseType:"Applicator"}):n}))},expiration:t.expiry,title:"Valid Through"})})]})]}));return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(m.Form.Field,{children:o})})};xk.defaultProps={isCreateScreen:!1,license:{},handleClick:function(){}};var gk=xk,Ck=function(e){var t=e.user,n=e.handleDelete,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(p.h)(),l=pk(t),d=Object(a.useContext)(we),u=Date.parse(new Date(t.applicatorLicenseExpirationDateEpoch)),j=u?Object(ya.a)(u,"MMM d, yyyy"):"";return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"text-xl w-full font-medium",children:"View Person"}),Object(y.jsx)("div",{children:Object(y.jsx)(Wo,{onAction:function(e){({edit:function(){d.sendEventToAmplitude(d.events.epic.People.editPerson),s.push("".concat(Cc.people,"/").concat(t.id))},delete:function(){o(!0)},print:function(){}})[e]()},options:xs})})]}),Object(y.jsxs)("div",{className:"py-5",children:[Object(y.jsxs)("div",{className:"bg-white w-full p-6",children:[Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("div",{className:"text-xl font-bold",children:"Basic Info"}),Object(y.jsx)("div",{className:"flex py-5",children:Object(y.jsx)(Fl,{data:l.fullName,header:"Name",className:"w-1/3",testId:"person-fullname"})}),Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsx)(Fl,{data:l.emailAddress,header:"Email",className:"w-1/3",testId:"person-email"}),Object(y.jsx)(Fl,{data:l.phoneNumber,header:"Phone",className:"w-1/3",testId:"person-phone"})]})]}),Object(y.jsx)("div",{className:"w-full border-b py-5"}),Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("div",{className:"text-xl font-bold py-5",children:"Address Info"}),l.streetAddress1&&Object(y.jsxs)("div",{children:[Object(y.jsx)(Fl,{data:l.streetAddress1,testId:"person-street1"}),Object(y.jsx)(Fl,{data:l.streetAddress2,testId:"person-street2"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)(Fl,{data:"".concat(l.cityName,","),className:"mr-2",testId:"person-city"}),Object(y.jsx)(Fl,{data:l.state,className:"mr-2",testId:"person-state"}),Object(y.jsx)(Fl,{data:l.postalCode,testId:"person-zip"})]})]})]}),Object(y.jsx)("div",{className:"w-full border-b py-5"}),Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("div",{className:"text-xl font-bold py-5",children:"License Info"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)(Fl,{data:l.applicatorLicense.value,header:"Applicator License",className:"w-1/3",testId:"person-license-number"}),Object(y.jsx)(Fl,{data:j,header:"Valid Through",testId:"person-expires"})]})]}),Object(y.jsx)("div",{className:"w-full border-b py-5"}),Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("div",{className:"text-xl font-bold py-5",children:"Notes"}),Object(y.jsx)(m.TextArea,{"data-testid":"person-notes",className:"h-64 overscroll-auto",resizeDisabled:!0,disabled:!0,value:l.notes})]})]}),Object(y.jsx)(ib,{open:i,itemType:"Person",onCancel:function(){return o(!1)},onDelete:n})]})]})},yk=["type"],Pk=function(){var e=Object(a.useState)(void 0),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(fk),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],f=Object(a.useState)(null),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useContext)(ac),g=Object(b.a)(x,2),C=g[0].loggedInUserOrgPermission.role,P=g[1],A=xl("worker"),S=xl("people"),T=Object(a.useContext)(we),N=Object(a.useState)(!1),E=Object(b.a)(N,2),w=E[0],_=E[1],R=function(){return j(!0)},I=Object(p.j)(),D=I.id,k=I.view,L="person"===D,F=D&&o.id||L,M="view"===k,V=D===o.id,B=function(){h(Cc.people)},U=function(){T.sendEventToAmplitude(T.events.epic.People.deletePerson),function(e){var t=function(){var t=Object(Y.a)(G.a.mark((function t(){return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return j(!1),t.next=3,S.delete(e.id).promise.then((function(){h(Cc.people)})).catch(Ae.default);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();t().catch(uc(P))}(o)};Object(a.useEffect)((function(){var e;if(!L){var t,n=A.fetch(D);return t=n.promise,e=n.cancel,t.then((function(e){var t=e.data;return s(function(e){var t=e;return delete t.accessGranted,delete t.permissionLevel,delete t.memberSinceDateEpoch,delete t.memberSinceDate,t}(t))||r(function(e){return{value:e.applicatorLicenseNumber,expiry:e.applicatorLicenseExpirationDateEpoch}}(t))})).catch(Ae.default),function(){P({type:"SET_TOOLBAR",payload:null}),e()}}return function(){return e&&e()}}),[P,D,A,L]);return Object(y.jsxs)("div",{className:"w-full h-full",children:[Object(y.jsxs)(lo,{disabled:L||M||V,children:[Object(y.jsx)(lo.Item,{title:"People",value:"All People",to:Cc.people}),Object(y.jsx)(lo.Item,{title:"Person",value:L?"Create Person":M?o.name:"Edit Person",isLast:!0})]}),O&&Object(y.jsx)(p.b,{push:!0,to:"".concat(O)}),F&&!M?Object(y.jsxs)("div",{style:{minHeight:"35rem"},children:[Object(y.jsx)(ib,{open:u,itemType:"Person",onCancel:function(){return j(!1)},onDelete:U}),Object(y.jsx)(Zi.e,{initialValues:pk(o),validate:function(e){var t={};return e.fullName&&!/^\s+$/.test(e.fullName)||(t.fullName="Required"),t},onSubmit:function(e){T.sendEventToAmplitude(T.events.epic.People.createPerson),_(!0),function(e){if(L)Xv(e,S,_,B,P);else{e.type;var t=Object(te.a)(e,yk);Qv(t,S,_,B,P)}}(function(e,t,n){var a=Object(ne.cloneDeep)(e);return a.name=t.fullName,a.email=t.emailAddress,a.notes=t.notes,a.address=jk(t),a.applicatorLicenseNumber=n?n.value:"",a.applicatorLicenseExpirationDateEpoch=n?n.expiry:"",a.phone=t.phoneNumber,a.notes=t.notes,a}(o,e,n))},children:function(e){var t=e.errors,n=e.touched,a=e.values,c=e.handleChange,i=e.handleBlur,s=e.setFieldValue,l=e.handleSubmit,d=Object.keys(t).length>0;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"flex text-gray-800",children:Object(y.jsxs)("div",{className:"flex w-full",children:[Object(y.jsx)("div",{className:"text-lg w-full text-3xl",children:L?"Create Person":"Edit Person Info"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)(Jv,{isCreateScreen:true,redirectPath:Cc.people,openModal:R,setRedirect:h}),Object(y.jsx)("div",{className:"ml-4",children:Object(y.jsx)(m.Button,{type:"primary",onClick:l,disabled:d,children:"Save"})})]})]})}),Object(y.jsx)("div",{className:"py-5",children:Object(y.jsxs)(m.Card,{children:[Object(y.jsx)(m.Card.Content,{children:Object(y.jsx)(m.Form,{children:Object(y.jsxs)("div",{className:"p-5",children:[Object(y.jsx)("div",{className:"text-2xl font-bold mt-10",children:"Basic Info"}),Object(y.jsx)("div",{className:"flex",children:Object(y.jsx)(JD,{fullName:a.fullName,onChange:c,onBlur:i,errors:n.fullName&&t.fullName})}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)(QD,{emailAddress:a.emailAddress,onChange:c,errors:t.emailAddress}),Object(y.jsx)($D,{phoneNumber:a.phoneNumber,onChange:c,errors:t.phoneNumber})]}),Object(y.jsx)("div",{className:"text-2xl font-bold mt-10",children:"Address Info"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)(tk,{streetAddress:a.streetAddress1,title:"Address Line 1",name:"streetAddress1",onChange:c,errors:t,blockMargin:"mr-6",id:"street-address-1-input"}),Object(y.jsx)(tk,{streetAddress:a.streetAddress2,title:"Address Line 2",name:"streetAddress2",onChange:c,errors:t,blockMargin:"ml-6",id:"street-address-2-input"})]}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"w-1/2",children:Object(y.jsx)(ak,{cityName:a.cityName,onChange:c,errors:t.cityName})}),Object(y.jsx)("div",{className:"w-1/2",children:Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)(sk,{state:a.state,setFieldValue:s,errors:t.state}),Object(y.jsx)(dk,{postalCode:a.postalCode,onChange:c,errors:t.postalCode})]})})]}),Object(y.jsx)(gk,{onChange:function(e){r(e)},isCreateScreen:o.applicatorLicenseNumber&&0===o.applicatorLicenseNumber.length,license:a.applicatorLicense,handleClick:l}),Object(y.jsx)("div",{className:"text-2xl font-bold mt-10",children:"Notes"}),Object(y.jsx)(bk,{notes:a.notes,errors:t.notes,onChange:c})]})})}),d&&Object(y.jsx)("div",{className:"p-5 -m-5",children:Object(y.jsx)("div",{className:"flex justify-end",children:Object(y.jsx)(co,{error:d,consoleMessage:!Object(ne.isEmpty)(n)&&"Unable to save. Please review errors above.",toastMessage:!Object(ne.isEmpty)(n)&&w&&"Your entry was not saved. Please correct any errors."})})})]})})]})}})]}):M&&""!==o.name?Object(y.jsx)(Ck,{user:o,handleDelete:U,role:C}):Object(y.jsx)(m.Spinner,{})]})},Ak=[{id:"people",key:"people",path:Cc.people,exact:!0,secure:!0,disabled:!1,component:WD,icon:Ql,nav:"leftNav"},{id:"personEntry",key:"personEntry",path:"".concat(Cc.people,"/:id"),exact:!0,secure:!0,component:Pk,minPermissions:{minAllowedRole:$a}},{id:"personView",key:"personView",path:"".concat(Cc.people,"/:id/:view"),exact:!0,secure:!0,component:Pk}],Sk=[{type:"rent",title:"Land Rent"},{type:"equipment",title:"Equipment"},{type:"insurance",title:"Insurance"},{type:"labor",title:"Labor"},{type:"repairs",title:"Repairs"},{type:"taxes",title:"Taxes"},{type:"returnToManagement",title:"Return To Management"}],Tk=[{field:"name",title:"Plan",sortable:!0},{field:"plannedArea",title:"Planned Area",sortable:!0},{field:"crop",title:"Crop",sortable:!0},{field:"fixedCostPerAcre",title:"Fixed Cost/Ac",sortable:!0},{field:"varCostPerAcre",title:"Var Cost/Ac",sortable:!0},{field:"projRevPerAcre",title:"Proj Rev/Ac",sortable:!0},{field:"createdAt",title:"Created",sortable:!0}],Nk={name:function(e,t){return Object(ne.orderBy)([function(e){return null===e||void 0===e?void 0:e.name}],e,t)},plannedArea:function(e,t){return Object(ne.orderBy)([function(e){return null===e||void 0===e?void 0:e.estimatedAreaValue}],e,t)},crop:function(e,t){return Object(ne.orderBy)([function(e){var t;return null===e||void 0===e||null===(t=e.crop)||void 0===t?void 0:t.name}],e,t)},fixedCostPerAcre:function(e,t){return Object(ne.orderBy)([function(e){return null===e||void 0===e?void 0:e.fixedCost}],e,t)},varCostPerAcre:function(e,t){return Object(ne.orderBy)([function(e){return null===e||void 0===e?void 0:e.variableCost}],e,t)},projRevPerAcre:function(e,t){return Object(ne.orderBy)([function(e){return null===e||void 0===e?void 0:e.projectRevenue}],e,t)},createdAt:function(e,t){return Object(ne.orderBy)([function(e){return null===e||void 0===e?void 0:e.createdOn}],e,t)}},Ek=function(e){return isNaN(e)?parseFloat(e.replace(/[$,]/g,"")):parseFloat(e)},wk=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.revenue&&e.revenue.yieldPerArea&&e.area?(e.revenue.yieldPerArea*e.area).toFixed(2):0},_k=function(e,t){if(t){var n=t.match(/[^ ]+/g),a=[],r=e.filter((function(e){return function(e,t){var n=function(t){return e.name.toLowerCase().includes(t.toLowerCase())};return t.length,t.every(n)}(e,n)}));return r&&r.forEach((function(e){a.push(e)})),a}return e},Rk=function(e,t,n){var a=Nk[t];return a&&n?a(n,e):e},Ik=function(e,t){if(2!==t.length)return e;var n=t[0].getTime(),a=t[1].getTime();return e.filter((function(e){var t=new Date(e.createdOn).getTime();return t<=a&&t>=n}))},Dk=zn("plan/plansummaries",{urlVersion:"/v1"}),kk=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,r,c,i,o,s,l,d,u,b,j,p,f,m,v,O;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=t.pageNo,r=t.size,c=t.seasonIdsCommaSeparated,i=t.dateRange,o=t.nameQuery,s=t.sortBy,l=t.sortDir,d={pageNo:a,size:r,seasonIdsCommaSeparated:c},u=yn.fetch(null,d),b=u.promise,j=Dk.fetch(null,d),p=j.promise,e.next=6,b.then((function(e){var t=e.data;return{rawPlans:t.results.reduce((function(e,t){return e[t.id]=t,e}),{}),totalElements:t.totalElements}}));case 6:return f=e.sent,m=f.rawPlans,v=f.totalElements,e.next=11,p.then((function(e){e.data.results.forEach((function(e){m[e.planId]=Object(I.a)(Object(I.a)({},m[e.planId]),e)}))}));case 11:return m=Object.values(m),n.id,O=Ik(m,i),O=_k(O,o),O=Rk(O,s,l),e.abrupt("return",{promise:Promise.resolve({data:{results:O,totalElements:v}})});case 17:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),Lk=kk,Fk=function(e){var t=Object(a.useContext)(ac),n=Object(b.a)(t,2),r=n[0].organization,c=n[1],i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(!1),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(0),m=Object(b.a)(f,2),v=m[0],O=m[1],h=Object(a.useState)(0),x=Object(b.a)(h,2),g=x[0],C=x[1],y=Object(a.useState)(Object(I.a)({pageNo:g,size:wo,dateRange:[],nameQuery:"",sortBy:"",sortDir:"",seasonIdsCommaSeparated:JSON.parse(localStorage.getItem("selectedCropSeasons")).join(",")},e)),P=Object(b.a)(y,2),A=P[0],S=P[1],T=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return p(!0),e.next=3,Lk(Object(I.a)(Object(I.a)({},A),t),r);case 3:return n=e.sent,a=n.promise,e.next=7,a.then((function(e){var t=e.data;l(t.results),O(t.totalElements)})).catch(Ae.default).catch((function(e){uc(c)(e)})).finally((function(){p(!1)}));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[A,c,r,p]),N=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:T();case 1:case"end":return e.stop()}}),e)}))),[T]);Object(a.useEffect)((function(){return function(){null}}),[]),Object(a.useEffect)((function(){N()}),[N,A]);var E=Object(a.useCallback)((function(e){S((function(t){return Object(I.a)(Object(I.a)({},t),{},{pageNo:0,nameQuery:e})}))}),[S]),w=Object(a.useCallback)((function(e){2!==e.length&&0!==e.length||S((function(t){return Object(I.a)(Object(I.a)({},t),{},{pageNo:0,dateRange:e})}))}),[S]),_=Object(a.useCallback)((function(e){C(e),S((function(t){return Object(I.a)(Object(I.a)({},t),{},{pageNo:e})}))}),[S]),R=Object(a.useCallback)((function(e,t){S((function(n){return Object(I.a)(Object(I.a)({},n),{},{pageNo:0,sortBy:e,sortDir:t})}))}),[S]);return{getPlans:T,plans:s,plansCount:v,pageNo:g,goToPage:_,isLoading:j,reset:function(){S(Object(I.a)(Object(I.a)({},A),{},{pageNo:g,totalPages:0,size:wo,seasonIdsCommaSeparated:JSON.parse(localStorage.getItem("selectedCropSeasons")).join(",")}))},reload:N,filterByNameQuery:E,filterByDateRange:w,sort:R,sortBy:A.sortBy,sortDir:A.sortDir}},Mk=[{key:"Pre-Plant",value:"Pre-Plant"},{key:"Planting",value:"Planting"},{key:"Growing",value:"Growing"},{key:"Harvest",value:"Harvest"},{key:"Storage",value:"Storage"},{key:"Annual",value:"Annual"}],Vk=function(e){var t=e.sort,n=e.handleSort,a=e.numProducts,r=e.markAll,c=e.allAreMarked;return Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(m.Checkbox,{onChange:function(e){r(e.target.checked)},checked:c})}),Object(y.jsx)(m.Table.Cell,{sortable:!0,sort:t,onClick:n,children:"Product Name (".concat(a,")")}),Object(y.jsx)(m.Table.Cell,{sortable:!0,sort:t,onClick:n,children:"Rate/Area"}),Object(y.jsx)(m.Table.Cell,{sortable:!0,sort:t,onClick:n,children:"Area Applied (ac)"}),Object(y.jsx)(m.Table.Cell,{sortable:!0,sort:t,onClick:n,children:"Coverage %"}),Object(y.jsx)(m.Table.Cell,{sortable:!0,sort:t,onClick:n,children:"Total Product"}),Object(y.jsx)(m.Table.Cell,{children:"Total Cost"})]})},Bk=function(e){var t=e.products,n=e.onAction;return Object(y.jsx)(y.Fragment,{children:t&&t.filter((function(e){return!e.hide})).map((function(e){return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(m.Checkbox,{onChange:function(t){return n(t.target.checked,e.trackingId)},id:"product.marked",checked:e.marked})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"text-left",children:[Object(y.jsx)("div",{className:"font-bold",children:e.productName}),Object(y.jsx)("div",{className:"mt-2 text-neutral-300",children:e.manufacturerName})]})}),Object(y.jsx)(m.Table.Cell,{children:"".concat(e.productRateValue," ").concat(e.productRateUnit)}),Object(y.jsx)(m.Table.Cell,{children:"".concat(e.areaValue," ac")}),Object(y.jsx)(m.Table.Cell,{children:"".concat(100*Number.parseFloat(e.coveragePercent),"%")}),Object(y.jsx)(m.Table.Cell,{children:"".concat(e.totalProductValue," ").concat(e.totalProductUnit)}),Object(y.jsx)(m.Table.Cell,{children:"$".concat(e.totalProductCost)})]},e.trackingId)}))})},Uk=function(e){var t=e.planProducts,n=e.markAll,a=e.markUnmarkProduct,r=e.loading,c=e.allAreMarked;return r?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(m.Table,{children:[Object(y.jsx)(Vk,{sort:"",handleSort:function(){},numProducts:t.filter((function(e){return e.marked})).length,markAll:n,allAreMarked:c}),Object(y.jsx)(Bk,{products:t,onAction:a})]})},zk=function(e,t,n,a){var r=e.map((function(e){var r,c=function(e,t,n,a){var r,c=null===e||void 0===e||null===(r=e.properties)||void 0===r?void 0:r.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{selectedCropSeason:null===a||void 0===a?void 0:a.cropSeasonIds})})),i=[];return(null===c||void 0===c?void 0:c.length)>0&&(null===c||void 0===c||c.forEach((function(e){var a;(null===e||void 0===e||null===(a=e.fields)||void 0===a?void 0:a.length)>0&&(null===e||void 0===e||e.fields.forEach((function(a){null===a||void 0===a||a.cropzones.forEach((function(r){var c;null!==t&&void 0!==t&&t.includes(r.id)&&i.push(Object(I.a)(Object(I.a)({},r),{},{farmId:e.id,fieldName:a.name,features:null===(c=n.features)||void 0===c?void 0:c.filter((function(e){return a.id===e.properties.id}))}))}))})))}))),i}(t,[e.cropZoneIdValue],n,a);return{areaType:(null===e||void 0===e?void 0:e.boundaryAreaUnit)||"",areaUnit:"acres",areaValue:(null===e||void 0===e?void 0:e.areaValue)||"",boundaryArea:(null===e||void 0===e?void 0:e.boundaryArea)||"",coveragePct:100,crop:{id:(null===e||void 0===e?void 0:e.cropId)||"",name:""},cropZoneId:(null===e||void 0===e?void 0:e.cropZoneIdValue)||"",farmId:(null===(r=c[0])||void 0===r?void 0:r.farmId)||"",name:(null===e||void 0===e?void 0:e.name)||"",reportedArea:(null===e||void 0===e?void 0:e.reportedArea)||""}}));return r},Zk=function(e){var t=e.open,n=e.close,r=e.currentPlan,c=Object(a.useState)([]),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],f=hR().loading,v=function(){n()},O=Object(p.h)(),h=Object(a.useState)(Mk),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useState)([]),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)(null),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(null),D=Object(b.a)(R,2),k=D[0],L=D[1],F=Object(a.useContext)(ac),M=Object(b.a)(F,2)[1],V=rv({fetchType:xm}),B=V.dataSorted,U=V.fieldsAndAreasGeoJSONCollection,z=V.reloadData,Z=[{key:"clear",value:"- Clear Filter"},{key:"none",value:"None"}],Y=function(){_(null),L(null),function(){var e=o.map((function(e){var t=e;return t.hide=!1,t.marked=!1,t}));s(e)}(),j(!1),n()},H=function(){var e=o.filter((function(e){return e.marked})),t=function(e,t,n,a){var r=Object(I.a)({},Cm),c=t.map((function(e){return $(e)}));return r.products=c,r.properties=zk(null===e||void 0===e?void 0:e.cropZones,n,a,e)||[],r.totalApplied=null===e||void 0===e?void 0:e.cropZones.reduce((function(e,t){return e+t.areaValue}),0),r.totalAreaValue=r.totalApplied,r.cropSeasonIds=e.cropSeasonIds.reduce((function(e,t){return"".concat(e,", ").concat(t)})),r.source=e.id,r}(r,e,B,U);M({type:"SET_CONVERT_PLAN",payload:t}),O.push("".concat(Cc.tasks,"/convert"))},G=function(){var e=null===o||void 0===o?void 0:o.filter((function(e){return!e.hide})).length,t=null===o||void 0===o?void 0:o.filter((function(e){return!e.hide&&e.marked})).length;j(e===t&&e>0)},W=function(e){var t=o.map((function(t){var n=t;return n.marked=t.hide?t.marked:e,n}));s(t),G()},q=function(e,t){var n=o.map((function(n){return Object(I.a)(Object(I.a)({},n),{},{marked:t===n.trackingId?e:n.marked})}));s(n),G()};return Object(a.useEffect)((function(){var e,t,n=null===r||void 0===r||null===(e=r.planProductEntries)||void 0===e?void 0:e.map((function(e){return Object(I.a)({marked:!1,hide:!1},e)}));s(n);var a=Object(ne.cloneDeep)(Z).concat(Object(ne.cloneDeep)(Mk));C(a);var c=Object(ne.cloneDeep)(Z);null===r||void 0===r||null===(t=r.planProductEntries)||void 0===t||t.forEach((function(e){e.timingEventTag&&-1===c.findIndex((function(t){return t.key===e.timingEventTag}))&&c.push({key:e.timingEventTag,value:e.timingEventTag})})),T(c)}),[null===r||void 0===r?void 0:r.planProductEntries]),Object(a.useEffect)((function(){G()})),Object(a.useEffect)((function(){z()}),[]),Object(y.jsx)(m.Modal,{open:t,onClose:n,onCancel:function(){return v()},onConfirm:function(){return v()},size:"lg",hideClose:!0,children:Object(y.jsxs)("div",{className:"p-5",children:[Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Convert to Task"}),Object(y.jsx)(Zi.e,{initialValues:{timing:"",timingTag:""},onSubmit:function(){return H()},children:function(e){var t=e.values,n=e.handleSubmit;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex w-full w-1/3",children:[Object(y.jsx)("div",{className:"w-full mr-4",children:Object(y.jsx)(m.Form.Field,{label:"Timing",children:Object(y.jsx)(Qi,{control:m.Select,value:w,items:g,id:"timing",name:"timing",onChange:function(e){var t=null;"clear"!==JSON.parse(e.target.value).key&&(t=JSON.parse(e.target.value).key),function(e){var t=e.key,n="none"===t?"":t,a=o.map((function(e){var a="clear"===n?e.marked:n===e.timingEvent;return Object(I.a)(Object(I.a)({},e),{},{hide:"clear"!==t&&!a})}));s(a),G()}(JSON.parse(e.target.value)),_(t)}})})}),Object(y.jsx)(m.Form.Field,{label:"Timing Tag",children:Object(y.jsx)(Qi,{control:m.Select,selected:t.timingTag,value:k,items:S,id:"timingTag",name:"timingTag",onChange:function(e){var t=null;"clear"!==JSON.parse(e.target.value).key&&(t=JSON.parse(e.target.value).key),function(e){var t=e.key,n="none"===t?"":t,a=o.map((function(e){var a=!e.timingEventTag||n===e.timingEventTag;return Object(I.a)(Object(I.a)({},e),{},{hide:"clear"!==t&&!a})}));s(a),G()}(JSON.parse(e.target.value)),L(t)}})})]}),Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Products & Services"}),Object(y.jsx)("div",{className:"text-sm pb-4",children:"Select the product(s) you want to include in your task"}),Object(y.jsx)("div",{className:"h-80 overflow-y-auto mb-8 border border-solid",children:Object(y.jsx)(Uk,{planProducts:o,markAll:W,markUnmarkProduct:q,loading:f,allAreMarked:u,id:"productsTable",name:"productsTable"})}),Object(y.jsxs)("div",{className:"flex justify-end",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(m.Button,{className:"pr-2",onClick:function(){Y()},children:"Cancel"})}),Object(y.jsx)(m.Button,{type:"primary",onClick:n,children:"Next"})]})]})}})]})})};Zk.defaultProps={currentPlan:null};var Yk=Zk,Hk={byRatePerArea:{key:"ByRatePerArea",value:"ratePerAreaValue",unit:"ratePerAreaUnit",title:"Rate/Area"},byTotalProduct:{key:"ByTotalProduct",value:"totalProductValue",unit:"totalProductUnit",title:"Total Product"},byRatePerTank:{key:"ByRatePerTank",value:"ratePerTankValue",unit:"ratePerTankUnit",title:"Rate/Tank"}};function Gk(e){var t=bA(e.name),n=Object(ya.a)(new Date,"yyMMdd"),a=Object(ya.a)(new Date,"kkmm");return{applicationStrategy:Hk.byRatePerArea.key,applicators:[],authorizationDate:new Date,authorizedBy:void 0,authorizedByName:void 0,coveragePercent:100,cropSeasonIds:JSON.parse(localStorage.getItem("selectedCropSeasons"))||null,expirationDate:Object(iD.a)(new Date,{days:31}),name:"".concat(t," ").concat(n," ").concat(a),notes:"",number:"",properties:[],proposedDate:new Date,products:[],propertiesGroupBy:"property",source:void 0,totalAreaValue:0,tankInformation:{tankSizeValue:0,tankSizeUnit:"gallon",tankCount:0,carrierPerAreaValue:0,carrierPerAreaUnit:"gallon",totalCarrierValue:0,totalCarrierUnit:"gallon",tankValueTypeEnteredByUser:"CarrierPerArea"},timingEvent:void 0}}var Wk={apiToFormValues:function(){var e,t,n,a,r,c,i,o,s,l,d,u,b,j,p,f,m=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},v=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",O=Gk({name:v}),h=(null!==(e=m.cropZones)&&void 0!==e?e:[]).reduce((function(e,t){return e+t.areaValue}),0);return{applicationStrategy:null!==(t=m.applicationStrategy)&&void 0!==t?t:O.applicationStrategy,applicators:null!==(n=m.applicators)&&void 0!==n?n:O.applicators,authorizationDate:m.authorisedOnEpoch?new Date(m.authorisedOnEpoch):O.authorizationDate,authorizedBy:null!==(a=m.authorisedById)&&void 0!==a?a:O.authorizedBy,authorizedByName:null!==(r=m.authorisedByName)&&void 0!==r?r:O.authorizedByName,coveragePercent:null!==(c=m.coveragePercent)&&void 0!==c?c:O.coveragePercent,cropSeasonIds:null!==(i=m.cropSeasonIds)&&void 0!==i?i:O.cropSeasonIds,expirationDate:m.expirationDateEpoch?new Date(m.expirationDateEpoch):O.expirationDate,flagIds:m.flagIds,name:null!==(o=m.title)&&void 0!==o?o:O.name,notes:null!==(s=m.notes)&&void 0!==s?s:O.notes,number:null!==(l=m.number)&&void 0!==l?l:O.number,properties:(null!==(d=m.cropZones)&&void 0!==d?d:[]).map((function(e){return{areaValue:e.areaValue,areaUnit:e.areaUnit,crop:{id:e.cropId},cropZoneId:e.cropZoneIdValue}})),proposedDate:m.proposedDateEpoch?new Date(m.proposedDateEpoch):O.proposedDate,products:(null!==(u=m.recommendationProductEntries)&&void 0!==u?u:[]).map((function(e){return{productId:e.productId,productName:e.productName,manufacturerName:e.manufacturerName,ratePerAreaValue:e.productRatePerAreaValue,ratePerAreaUnit:e.productRatePerAreaUnit,areaUnit:e.areaUnit,ratePerTankValue:e.productRatePerTankValue,ratePerTankUnit:e.productRatePerTankUnit,totalProductValue:e.totalProductValue,totalProductUnit:e.totalProductUnit,coveragePercent:100*e.coveragePercent,appliedAreaValue:e.productAppliedAreaValue,appliedAreaUnit:e.productAppliedAreaUnit,productDensity:e.productDensity,applicationMethod:e.applicationMethod,targetPestId:e.targetPestId,custom:e.custom}})),propertiesGroupBy:null!==(b=m.propertiesGroupBy)&&void 0!==b?b:O.propertiesGroupBy,source:null!==(j=m.source)&&void 0!==j?j:O.source,totalApplied:Math.round(100*(h+Number.EPSILON))/100,totalAreaValue:Math.round(100*(h+Number.EPSILON))/100,tankInformation:null!==(p=m.tankInformation)&&void 0!==p?p:O.tankInformation,timingEvent:null!==(f=m.timingEvent)&&void 0!==f?f:O.timingEvent}},formValuesToApi:function(e){var t,n,a,r,c,i={applicationStrategy:e.applicationStrategy,applicators:null===(t=e.applicators)||void 0===t?void 0:t.map((function(e){return{personId:e.personId,personName:"",companyName:"",companyId:e.companyId}})),authorisedById:e.authorizedBy,authorisedByName:e.authorizedByName,authorisedOnEpoch:new Date(null!==(n=e.authorizationDate)&&void 0!==n?n:"").valueOf(),coveragePercent:null===e||void 0===e?void 0:e.coveragePercent,cropSeasonIds:Object(ne.compact)(e.cropSeasonIds),cropZones:e.properties.map((function(e){return{areaValue:e.areaValue,areaUnit:"acre",cropId:e.crop.id,cropZoneIdValue:e.cropZoneId}})),expirationDateEpoch:new Date(null!==(a=e.expirationDate)&&void 0!==a?a:"").valueOf(),flagIds:e.flagIds,number:null!==(r=e.number)&&void 0!==r?r:"",proposedDateEpoch:new Date(null!==(c=e.proposedDate)&&void 0!==c?c:"").valueOf(),recommendationProductEntries:null===e||void 0===e?void 0:e.products.map((function(t){return{productId:t.productId,productName:t.productName,manufacturerName:t.manufacturerName,productRatePerAreaValue:t.ratePerAreaValue,productRatePerAreaUnit:t.ratePerAreaUnit,areaUnit:t.areaUnit,productRatePerTankValue:t.appliedAreaValue*t.ratePerAreaValue/e.tankInformation.tankCount,productRatePerTankUnit:t.ratePerTankUnit,totalProductValue:t.totalProductValue,totalProductUnit:t.totalProductUnit,coveragePercent:t.coveragePercent/100,productAppliedAreaValue:t.appliedAreaValue,productAppliedAreaUnit:t.appliedAreaUnit,productDensity:t.productDensity,applicationMethod:t.applicationMethod,targetPestId:t.targetPestId,custom:t.custom||!1,stdunit:t.stdunit}})),source:e.source,tankInformation:{tankCount:e.tankInformation.tankCount,tankValueTypeEntered:"CarrierPerArea",tankSizeUnit:"gallon",tankSizeValue:e.tankInformation.tankSizeValue,carrierPerAreaUnit:"gallon",carrierPerAreaValue:e.tankInformation.carrierPerAreaValue,totalCarrierUnit:"gallon",totalCarrierValue:e.tankInformation.totalCarrierValue},timingEvent:e.timingEvent,title:e.name,type:"LANDDB"};return e.notes&&(i.notes=e.notes),i}},qk=function(e,t,n,a,r){var c=Gk(e),i=n.map((function(e){return $(e)}));c.products=i,c.properties=zk(t.cropZones,a,r,t)||[];var o=t.cropZones.reduce((function(e,t){return e+t.areaValue}),0);return c.totalApplied=o,c.cropSeasonIds=t.cropSeasonIds.reduce((function(e,t){return"".concat(e,", ").concat(t)})),c.source=[{id:t.id,name:t.name}],c},Jk=function(e){var t=e.open,n=e.close,r=e.currentPlan,c=Object(a.useState)([]),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],f=hR().loading,v=Object(p.h)(),O=Object(a.useState)(Mk),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)([]),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(null),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)(null),R=Object(b.a)(_,2),D=R[0],k=R[1],L=We().user,F=Object(a.useContext)(ac),M=Object(b.a)(F,2)[1],V=rv({fetchType:xm}),B=V.dataSorted,U=V.fieldsAndAreasGeoJSONCollection,z=V.reloadData,Z=[{key:"clear",value:"- Clear Filter"},{key:"none",value:"None"}],Y=function(){w(null),k(null),function(){var e=o.map((function(e){var t=e;return t.hide=!1,t.marked=!1,t}));s(e)}(),j(!1),n()},H=function(){var e=null===o||void 0===o?void 0:o.filter((function(e){return!e.hide})).length,t=null===o||void 0===o?void 0:o.filter((function(e){return!e.hide&&e.marked})).length;j(e===t&&e>0)},G=function(e){var t=o.map((function(t){var n=t;return n.marked=t.hide?t.marked:e,n}));s(t),H()},W=function(e,t){var n=o.map((function(n,a){return Object(I.a)(Object(I.a)({},n),{},{marked:a===t?e:n.marked})}));s(n),H()};return Object(a.useEffect)((function(){var e,t,n=null===r||void 0===r||null===(e=r.planProductEntries)||void 0===e?void 0:e.map((function(e){return Object(I.a)({marked:!1,hide:!1},e)}));s(n);var a=Object(ne.cloneDeep)(Z).concat(Object(ne.cloneDeep)(Mk));g(a);var c=Object(ne.cloneDeep)(Z);null===r||void 0===r||null===(t=r.planProductEntries)||void 0===t||t.forEach((function(e){e.timingEventTag&&-1===c.findIndex((function(t){return t.key===e.timingEventTag}))&&c.push({key:e.timingEventTag,value:e.timingEventTag})})),S(c)}),[null===r||void 0===r?void 0:r.planProductEntries]),Object(a.useEffect)((function(){H()})),Object(a.useEffect)((function(){z()}),[]),Object(y.jsx)(m.Modal,{open:t,onClose:n,onCancel:n,onConfirm:n,size:"lg",hideClose:!0,children:Object(y.jsxs)("div",{className:"p-5",children:[Object(y.jsx)("div",{className:"text-2xl font-bold mt-2 mb-6",children:"Convert to Recommendation"}),Object(y.jsx)(Zi.e,{initialValues:{timing:"",timingTag:""},onSubmit:function(){return function(){var e=o.filter((function(e){return e.marked})),t=qk(L,r,e,B,U);M({type:"SET_CONVERT_PLAN",payload:t}),v.push("".concat(Cc.recommendations,"/convert"))}()},children:function(e){var t=e.values,n=e.handleSubmit;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex w-full w-1/3 mb-4",children:[Object(y.jsx)("div",{className:"w-full mr-4",children:Object(y.jsx)(m.Form.Field,{label:"Timing",children:Object(y.jsx)(Qi,{control:m.Select,value:E,items:x,id:"timing",name:"timing",onChange:function(e){var t=null;"clear"!==JSON.parse(e.target.value).key&&(t=JSON.parse(e.target.value).key),function(e){var t=e.key,n="none"===t?"":t,a=o.map((function(e){var a="clear"===n?e.marked:n===e.timingEvent;return Object(I.a)(Object(I.a)({},e),{},{hide:"clear"!==t&&!a})}));s(a),H()}(JSON.parse(e.target.value)),w(t)}})})}),Object(y.jsx)(m.Form.Field,{label:"Timing Tag",children:Object(y.jsx)(Qi,{control:m.Select,selected:t.timingTag,value:D,items:A,id:"timingTag",name:"timingTag",onChange:function(e){var t=null;"clear"!==JSON.parse(e.target.value).key&&(t=JSON.parse(e.target.value).key),function(e){var t=e.key,n="none"===t?"":t,a=o.map((function(e){var a=!e.timingEventTag||n===e.timingEventTag;return Object(I.a)(Object(I.a)({},e),{},{hide:"clear"!==t&&!a})}));s(a),H()}(JSON.parse(e.target.value)),k(t)}})})]}),Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Products & Services"}),Object(y.jsx)("div",{className:"text-sm pb-4 mb-4",children:"Select the product(s) you want to include in your recommendation"}),Object(y.jsx)("div",{className:"h-80 overflow-y-auto mb-8 border border-solid",children:Object(y.jsx)(Uk,{planProducts:o,markAll:G,markUnmarkProduct:W,loading:f,allAreMarked:u,id:"productsTable",name:"productsTable"})}),Object(y.jsxs)("div",{className:"flex justify-end",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(m.Button,{className:"pr-2",onClick:function(){Y()},children:"Cancel"})}),Object(y.jsx)(m.Button,{type:"primary",onClick:n,children:"Next"})]})]})}})]})})};Jk.defaultProps={currentPlan:null};var Kk=Jk,Qk=O.StyleSheet.create({title:{fontFamily:"Noto Sans",fontWeight:"medium",fontSize:12,marginBottom:12},container:{border:"1px solid #DFE2E7",padding:12,display:"flex",flexDirection:"row",flexWrap:"wrap"},column:{width:"50%"},row:{width:"100%",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:6,marginBottom:12},key:{fontFamily:"Noto Sans",fontSize:9,width:"50%"},value:{fontWeight:"medium"},breakContainer:{width:"100%",marginTop:9,display:"flex",flexDirection:"row",justifyContent:"space-between",paddingHorizontal:6},breakTitle:{width:"75%",fontSize:9,color:"#696F88",fontFamily:"Noto Sans"},breakValue:{width:"25%",fontSize:9,fontWeight:"medium",fontFamily:"Noto Sans",paddingLeft:3}}),Xk=function(e){var t=e.estimatedAreaValue,n=e.projectedRevenue,a=e.cost,r=e.projNetRevPerArea,c=e.projNetRev,i=a+e.totalFixedCost;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(O.Text,{style:Qk.title,children:"Profitability"}),Object(y.jsxs)(O.View,{style:Qk.container,children:[Object(y.jsxs)(O.View,{style:Qk.column,children:[Object(y.jsxs)(O.View,{style:Qk.row,children:[Object(y.jsx)(O.Text,{style:Qk.key,children:"Est. Area"}),Object(y.jsx)(O.Text,{style:Object(I.a)(Object(I.a)({},Qk.key),Qk.value),children:ee(t,"fixed")})]}),Object(y.jsxs)(O.View,{style:Qk.row,children:[Object(y.jsx)(O.Text,{style:Qk.key,children:"Est. Yield / Area"}),Object(y.jsx)(O.Text,{style:Object(I.a)(Object(I.a)({},Qk.key),Qk.value),children:ee(n.yieldPerArea,"fixed")})]}),Object(y.jsxs)(O.View,{style:Qk.row,children:[Object(y.jsx)(O.Text,{style:Qk.key,children:"Est. Price / Unit"}),Object(y.jsx)(O.Text,{style:Object(I.a)(Object(I.a)({},Qk.key),Qk.value),children:ee(n.pricePerUnit,"currency")})]}),Object(y.jsxs)(O.View,{style:Qk.row,children:[Object(y.jsx)(O.Text,{style:Qk.key,children:"FSA Income"}),Object(y.jsx)(O.Text,{style:Object(I.a)(Object(I.a)({},Qk.key),Qk.value),children:ee(n.fsaPayment,"currency")})]}),Object(y.jsxs)(O.View,{style:Qk.row,children:[Object(y.jsx)(O.Text,{style:Qk.key,children:"Total Revenue"}),Object(y.jsx)(O.Text,{style:Object(I.a)(Object(I.a)({},Qk.key),Qk.value),children:ee(t*n.yieldPerArea*n.pricePerUnit,"currency")})]})]}),Object(y.jsxs)(O.View,{style:Qk.column,children:[Object(y.jsxs)(O.View,{style:Qk.row,children:[Object(y.jsx)(O.Text,{style:Qk.key,children:"Crop Share %"}),Object(y.jsx)(O.Text,{style:Object(I.a)(Object(I.a)({},Qk.key),Qk.value),children:ee(n.cropSharePercent,"percent")})]}),Object(y.jsxs)(O.View,{style:Qk.row,children:[Object(y.jsx)(O.Text,{style:Qk.key,children:"Costs"}),Object(y.jsx)(O.Text,{style:Object(I.a)(Object(I.a)({},Qk.key),Qk.value),children:ee(i,"currency")})]}),Object(y.jsxs)(O.View,{style:Qk.row,children:[Object(y.jsx)(O.Text,{style:Qk.key,children:"Cost/Area"}),Object(y.jsx)(O.Text,{style:Object(I.a)(Object(I.a)({},Qk.key),Qk.value),children:ee(i/t,"currency")})]}),Object(y.jsxs)(O.View,{style:Qk.row,children:[Object(y.jsx)(O.Text,{style:Qk.key,children:"Net Revenue / Area"}),Object(y.jsx)(O.Text,{style:Object(I.a)(Object(I.a)({},Qk.key),Qk.value),children:ee(r,"currency")})]}),Object(y.jsxs)(O.View,{style:Qk.row,children:[Object(y.jsx)(O.Text,{style:Qk.key,children:"Total Net Revenue"}),Object(y.jsx)(O.Text,{style:Object(I.a)(Object(I.a)({},Qk.key),Qk.value),children:ee(c,"currency")})]})]}),Object(y.jsxs)(O.View,{style:[Qk.breakContainer,{marginTop:18}],children:[Object(y.jsxs)(O.Text,{style:Qk.breakTitle,children:["Break Even Yield On Variable and Fixed @"," ",ee(n.pricePerUnit,"currency")]}),Object(y.jsx)(O.Text,{style:Qk.breakValue,children:ee(i/t/n.pricePerUnit,"fixed")})]}),Object(y.jsxs)(O.View,{style:Qk.breakContainer,children:[Object(y.jsxs)(O.Text,{style:Qk.breakTitle,children:["Break Even Unit Price On Variable and Fixed @"," ",ee(n.yieldPerArea,"fixed")]}),Object(y.jsx)(O.Text,{style:Qk.breakValue,children:ee(i/t/n.yieldPerArea,"currency")})]})]})]})};Xk.defaultProps={estimatedAreaValue:0,projectedRevenue:{yieldPerArea:0,pricePerUnit:0,cropSharePercent:0,fsaPayment:0},cost:0,projNetRevPerArea:0,projNetRev:0,totalFixedCost:0};var $k=Xk,eL=[{label:"Product",width:19},{label:"Timing",width:9},{label:"Area",width:9},{label:"%Applied",width:9},{label:"Rate",width:13},{label:"App Cnt",width:5},{label:"Total Quantity Applied",width:15},{label:"Cost/Area",width:10},{label:"Cost",width:11,alignment:"right"}],tL=[{label:"Equipment",width:16},{label:"Rent",width:13},{label:"Insurance",width:16},{label:"Labor",width:13},{label:"Repairs",width:13},{label:"Taxes",width:13},{label:"Return to Mgt",width:16,alignment:"right"}],nL=22,aL=[{label:"Farm",width:nL},{label:"Field",width:nL},{label:"Crop Zone",width:nL},{label:"Crop",width:nL},{label:"Area",width:12}],rL=function(e){var t=e.map((function(e){return[Ia(e.productName,{width:"".concat(19,"%")}),Ia(e.timingEvent,{width:"".concat(9,"%")}),Ia(ee(e.areaValue,"fixed"),{width:"".concat(9,"%")}),Ia(ee(e.coveragePercent,"percent"),{width:"".concat(9,"%")}),Ia("".concat(ee(e.productRateValue,"fixed")," ").concat(Object(va.g)(e.productRateUnit)),{width:"".concat(13,"%")}),Ia(e.applicationCount.toString(),{width:"".concat(5,"%")}),Ia("".concat(ee(e.totalProductValue,"fixed")," ").concat(Object(va.g)(e.totalProductUnit)),{width:"".concat(15,"%")}),Ia(ee(e.totalProductCost/e.areaValue,"currency"),{width:"".concat(10,"%")}),Ia(ee(e.totalProductCost,"currency"),{width:"".concat(11,"%"),textAlign:"right"})]})),n=t.reduce((function(e,t){var n,a=t[8];return e+(n=a.label,Number(n.replace(/[^0-9.-]+/g,"")))}),0);return t.push([Ia("Total Cost: ".concat(ee(n,"currency")),{width:"100%",fontSize:11,fontWeight:"medium",paddingVertical:6})]),t},cL=function(e,t){return[[Ia(ee(e.fixedCost.equipment,"currency"),{width:"".concat(16,"%")}),Ia(ee(e.fixedCost.landRent,"currency"),{width:"".concat(13,"%")}),Ia(ee(e.fixedCost.insurance,"currency"),{width:"".concat(16,"%")}),Ia(ee(e.fixedCost.labor,"currency"),{width:"".concat(13,"%")}),Ia(ee(e.fixedCost.repairs,"currency"),{width:"".concat(13,"%")}),Ia(ee(e.fixedCost.taxes,"currency"),{width:"".concat(13,"%")}),Ia(ee(e.fixedCost.returnToMgt,"currency"),{width:"".concat(16,"%"),textAlign:"right"})],[Ia("Total Fixed Cost: ".concat(ee(t,"currency")),{width:"100%",fontSize:11,fontWeight:"medium",paddingVertical:6})]]},iL=O.StyleSheet.create({viewContainer:{marginBottom:27}}),oL=function(e){var t=e.plan;return t?Object(y.jsxs)(wa,{headerTitle:t.name,type:"Plan",orgName:t.organizationName,cropName:t.cropName,cropSeasons:t.cropSeasons,generatedYear:t.year,generatedFullDate:t.fullDate,children:[Object(y.jsx)(O.View,{style:iL.viewContainer,children:Object(y.jsx)(R,{title:"Products",headerItems:eL,bodyItems:t.planProductEntries})}),Object(y.jsx)(O.View,{style:iL.viewContainer,children:Object(y.jsx)(R,{title:"Fixed Costs(Annual)",headerItems:tL,bodyItems:t.fixedCosts})}),Object(y.jsx)(O.View,{style:iL.viewContainer,children:Object(y.jsx)($k,{estimatedAreaValue:t.estimatedAreaValue,projectedRevenue:t.projectedRevenue,cost:t.totalCost,projNetRevPerArea:t.projNetRevPerArea,projNetRev:t.projNetRev,totalFixedCost:t.totalFixedCost})}),Object(y.jsx)(O.View,{style:iL.viewContainer,children:Object(y.jsx)(R,{title:"Fields",headerItems:aL,bodyItems:t.cropZones,titleRight:"Area: ".concat(ee(t.areaSum,"fixed")," ac.")})}),Object(y.jsx)(O.View,{style:iL.viewContainer,children:Object(y.jsx)(ma,{notes:t.notes})})]}):null};oL.defaultProps={plan:null};var sL=oL,lL=function(e){var t,n,a,r,c,i,o;return(Number(null===e||void 0===e||null===(t=e.fixedCost)||void 0===t?void 0:t.equipment)+Number(null===e||void 0===e||null===(n=e.fixedCost)||void 0===n?void 0:n.insurance)+Number(null===e||void 0===e||null===(a=e.fixedCost)||void 0===a?void 0:a.labor)+Number(null===e||void 0===e||null===(r=e.fixedCost)||void 0===r?void 0:r.landRent)+Number(null===e||void 0===e||null===(c=e.fixedCost)||void 0===c?void 0:c.repairs)+Number(null===e||void 0===e||null===(i=e.fixedCost)||void 0===i?void 0:i.returnToMgt)+Number(null===e||void 0===e||null===(o=e.fixedCost)||void 0===o?void 0:o.taxes))*(null===e||void 0===e?void 0:e.estimatedAreaValue)},dL=function(e){var t,n;return(Number(null===e||void 0===e||null===(t=e.projectedRevenue)||void 0===t?void 0:t.yieldPerArea)||0)*Number((null===e||void 0===e||null===(n=e.projectedRevenue)||void 0===n?void 0:n.pricePerUnit)||0)*(Number(null===e||void 0===e?void 0:e.estimatedAreaValue)||1)},uL=function(e){return dL(e)/(Number(null===e||void 0===e?void 0:e.estimatedAreaValue)||1)},bL=function(e){var t;return null===e||void 0===e||null===(t=e.planProductEntries)||void 0===t?void 0:t.map((function(e){return null===e||void 0===e?void 0:e.totalProductCost})).reduce((function(e,t){return e+t}),0)},jL=function(e){var t=(null===e||void 0===e?void 0:e.projectedRevenue)||{},n=t.cropSharePercent,a=void 0===n?1:n,r=t.pricePerUnit,c=void 0===r?0:r,i=t.fsaPayment,o=void 0===i?0:i,s=t.yieldPerArea,l=(void 0===s?0:s)*c*(null===e||void 0===e?void 0:e.estimatedAreaValue);return((Number(l)||0)+Number(o))*Number(a)-(lL(e)||0)-(bL(e)||0)},pL=function(e){return(jL(e)||0)/(null===e||void 0===e?void 0:e.estimatedAreaValue)},fL=function(e,t,n){var a=e*t;if((null===n||void 0===n?void 0:n.productRateUnit)!==(null===n||void 0===n?void 0:n.totalProductUnit)){var r=Object(K.getConvertUnitFromTo)(Number.parseFloat(n.productRateValue*n.areaValue),n.productRateUnit,null===n||void 0===n?void 0:n.totalProductUnit,n);a=Number.parseFloat(r.Value||r)}return a>0&&a!==1/0?a.toFixed(2):"0.00"},mL=function(){var e=Object(p.h)(),t=Object(a.useContext)(we),n=Object(a.useContext)(ac),r=Object(b.a)(n,1)[0].organization,c=Au("plan"),i=hx(),o=i.downloadPDFV2,s=i.downloading,l=i.setDownloading,d=Object(a.useState)(),j=Object(b.a)(d,2),f=j[0],m=j[1],h=Object(a.useState)(!1),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(O.usePDF)({document:Object(y.jsx)(sL,{plan:f})}),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)(null),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useRef)(void 0);Object(a.useEffect)((function(){f&&T()}),[f]),Object(a.useEffect)((function(){!S.loading&&S.url&&R.current!==S.url&&f&&(R.current=S.url,o(R.current,"Plan - ".concat(f.name,".pdf")),m(null))}),[S]);var D=function(t){e.push({pathname:"".concat(Cc.plans,"/").concat(t),selectedView:"edit-fromView"})},k=function(t){e.push({pathname:"".concat(Cc.plans,"/").concat(t),state:{selectedView:"edit-dup"}})},L=function(){_("delete"),t.sendEventToAmplitude(t.events.epic.Plans.deletePlan)},F=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,i,o,s,d,b,j,p,f,O,h,x,g,C,y,P,A,S,T,N;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l(!0),n=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="".concat(u.h,"/crops/").concat(t,"?location=@CWF"),e.next=3,J.a.get(n,{headers:{common:{Authorization:"Bearer ".concat(Ve())}}}).catch((function(){return{}}));case 3:return a=e.sent,r=a.data,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),a=c.fetch(t),i=a.promise,e.next=5,i.catch((function(){return{}}));case 5:if(o=e.sent,!(s=o.data)){e.next=25;break}return b=s.cropZones.map(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,i;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ca(t.cropZoneIdValue);case 2:return n=e.sent,a=n.cropZone,r=n.field,c=n.farm,i=n.crop,e.abrupt("return",Object(I.a)(Object(I.a)({},t),{},{farmName:c.name,fieldName:r.name,cropZoneName:a.name,cropName:i.name}));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),j=$t.fetch(s.cropSeasonIds[0]),p=j.promise,e.next=12,Promise.allSettled([].concat(Object(v.a)(b),[p,n(s.cropId)]));case 12:f=e.sent,O=f.slice(0,-2),h=f.slice(-2,-1),x=f.slice(-1),g=Da(s.cropZones),C=bL(s),y=pL(s),P=jL(s),A=new Date,S=Object(ya.a)(A,"yyyy"),T=Object(ya.a)(A,"MM/dd/yyyy h:mm aaa"),N=lL(s),m(Object(I.a)(Object(I.a)({},s),{},{cropZones:(E=O.filter((function(e){return"fulfilled"===e.status})).map((function(e){return e.value})),E.map((function(e){return[Ia(e.farmName,{width:"".concat(nL,"%")}),Ia(e.fieldName,{width:"".concat(nL,"%")}),Ia(e.cropZoneName,{width:"".concat(nL,"%")}),Ia(e.cropName,{width:"".concat(nL,"%")}),Ia(ee(e.areaValue,"fixed"),{width:"".concat(12,"%")})]}))),organizationName:r.name,cropSeasons:h.filter((function(e){return"fulfilled"===e.status})).map((function(e){return e.value.data.name})),cropName:null===(d=x[0].value)||void 0===d?void 0:d.name,planProductEntries:rL(s.planProductEntries),fixedCosts:cL(s,N),areaSum:g,totalCost:C,costPerArea:C/s.estimatedAreaValue,projNetRevPerArea:y,projNetRev:P,year:S,fullDate:T,totalFixedCost:N}));case 25:l(!1);case 26:case"end":return e.stop()}var E}),e)})));return function(t){return e.apply(this,arguments)}}();return{handleAction:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n={edit:D,tag:function(){return _("tag")},duplicate:k,convertTask:function(){return _("convertToTask")},convertToRec:function(){return _("convertToRec")},shareOrPrint:F,delete:L};n[e](t)},currentOpenModal:w,setCurrentOpenModal:_,downloadingPDF:s,shareOrPrint:F,setLoadingTags:C,loadingTags:g}};mL.defaultProps={plan:{}};var vL=mL,OL=function(e,t){return e.filter((function(e){var n=e.cropSeasons;return t&&"-1"!==t?n.some((function(e){return e.seasonId===t})):!n.length}))},hL=function(e){var t=e.open,n=e.close,r=e.planName,c=e.planId,i=Au("plan"),o=Object(p.h)(),s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useContext)(ac),f=Object(b.a)(j,2)[1],m=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u(!0),t=i.delete(c),n=t.promise,e.next=4,n.then((function(){o.push({pathname:Cc.plans}),o.go({pathname:Cc.plans})})).catch(Ae.default).catch((function(e){u(!1),uc(f)(e)}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)(ao,{open:t,title:'Delete "'+r+'"',close:n,cancelLabel:"Cancel",confirmLabel:"Delete",onCancel:function(){n()},type:"error",onConfirm:function(){return m()},isSaving:d,children:Object(y.jsx)("div",{className:"pr-6",children:"You are about to permanently delete this plan. This cannot be undone. Are you sure you want to proceed?"})})};hL.defaultProps={planName:"",planId:""};var xL=Object(p.l)(hL),gL=function(e){var t=e.plans,n=e.loadPlanSummaries,r=e.setTagsLoading,c=e.totalPlans,i=e.planPageNumber,o=e.handlePageChange,s=Object(a.useState)(null),l=Object(b.a)(s,1)[0],d=Object(a.useContext)(ac),u=Object(b.a)(d,2),j=u[0].loggedInUserOrgPermission,f=u[1],m=Object(a.useState)(!1),v=Object(b.a)(m,2),O=v[0],h=v[1],x=Object(a.useState)(),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(!1),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(!1),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)(-1),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)(-1),V=Object(b.a)(M,2),B=V[0],U=V[1],z=function(){return h(!1)},Z=function(){return N(!1)},H=function(){return R(!1)},W=null!==t&&void 0!==t&&t.length?function(e){return Object(ne.uniqBy)(e.map((function(e){return e.cropSeasons})).flat(),(function(e){return e.seasonId})).map((function(t){var n=t.seasonId;return{id:n,name:t.name,plans:OL(e,n)}}))}(t):[],q=Object(a.useState)(),J=Object(b.a)(q,2),K=J[0],Q=J[1],X=Object(a.useState)(!1),$=Object(b.a)(X,2),ee=$[0],te=$[1],ae=Object(a.useState)(""),re=Object(b.a)(ae,2),ce=re[0],ie=re[1],oe=Object(a.useState)(),se=Object(b.a)(oe,2),le=se[0],de=se[1],ue=Object(a.useState)([]),be=Object(b.a)(ue,2),je=be[0],pe=be[1],fe=Object(a.useState)(null),me=Object(b.a)(fe,2)[1],ve=ir(j.financialAccess,"READ"),Oe=Object(p.h)(),he=Object(a.useContext)(we),xe=vL(),ge=xe.shareOrPrint,Ce=xe.downloadingPDF,ye=function(){var e=Object(Y.a)(G.a.mark((function e(n,a,r,c,i){var o;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=null===t||void 0===t?void 0:t.find((function(e){return e.id===(null===a||void 0===a?void 0:a.planId)})),F(r),U(c),{view:function(){Oe.push({pathname:"".concat(Cc.plans,"/").concat(a.planId,"/view"),state:{selectedView:"edit-fromView",seasonName:i}})},edit:function(){Oe.push({pathname:"".concat(Cc.plans,"/").concat(a.planId)})},duplicate:function(){Oe.push({pathname:"".concat(Cc.plans,"/").concat(a.planId),state:{selectedView:"edit-dup"}})},tag:function(){var e;ie(a.name),de(a.planId),pe((null===(e=a.flags)||void 0===e?void 0:e.length)>0||void 0!==a.flags?a.flags:[]),te(!0)},convertTask:function(){jc(f,Qr,he.events.epic.Tasks.pages.fromPlan),he.sendEventToAmplitude(he.events.epic.Tasks.createTask,{page:he.events.epic.Tasks.pages.fromPlan}),P(o),N(!0)},convertToRec:function(){P(o),R(!0)},shareOrPrint:function(){ge(a.planId)},delete:function(){he.sendEventToAmplitude(he.events.epic.Plans.deletePlan),Q(a),h(!0)}}[n]();case 5:case"end":return e.stop()}}),e)})));return function(t,n,a,r,c){return e.apply(this,arguments)}}(),Pe=function(){var e=Object(Y.a)(G.a.mark((function e(a){var c,i,o,s;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r(!0),c=t.filter((function(e){return e.id===le})),delete(i=Object(I.a)(Object(I.a)({},c[0]),{},{id:c[0].planId,flagIds:a.map((function(e){return e.id}))})).createdOn,delete i.variableCost,delete i.projectRevenue,delete i.netRevenue,delete i.planId,delete i.cropSeasons,delete i.crop,delete i.fixedCost,delete i.flags,e.next=14,Pn.update(le,i);case 14:return o=e.sent,s=o.promise,e.next=18,s.then((function(){pe(a),r(!1),n()})).catch(Ae.default).catch((function(e){var t,n,a,c;null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.validationErrors?me("Error saving task: ".concat(e.response.data.message)):null!==(a=e.response)&&void 0!==a&&null!==(c=a.data)&&void 0!==c&&c.displayErrorMessage?me(e.response.data.displayErrorMessage):uc(f)(e),r(!1)}));case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Se=function(e){return t=e,n="USD",a=2,Object(y.jsx)(yf,{unit:"USD"===n?"usCurrency":n,roundedTo:a,children:t});var t,n,a};return Object(a.useEffect)((function(){Ce||(F(-1),U(-1))}),[Ce]),Object(y.jsx)("div",{className:"my-4 min-w-content","data-testid":"plans-tile-board",style:{minWidth:"min-content"},children:Object(y.jsxs)(ll,{children:[Ho(c,i,o),Object(y.jsx)("div",{className:"pb-2",children:" "}),l&&Object(y.jsx)(p.b,{push:!0,to:"".concat(l)}),function(){var e;return(null===C||void 0===C||null===(e=C.id)||void 0===e?void 0:e.length)>0?Object(y.jsx)(Yk,{open:T,close:Z,currentPlan:C}):Object(y.jsx)(y.Fragment,{})}(),function(){var e;return(null===C||void 0===C||null===(e=C.id)||void 0===e?void 0:e.length)>0?Object(y.jsx)(Kk,{open:_,close:H,currentPlan:C}):Object(y.jsx)(y.Fragment,{})}(),function(){var e;return(null===K||void 0===K||null===(e=K.planId)||void 0===e?void 0:e.length)>0?Object(y.jsx)(xL,{open:O,close:z,planName:null===K||void 0===K?void 0:K.name,planId:null===K||void 0===K?void 0:K.planId}):Object(y.jsx)(y.Fragment,{})}(),Object(y.jsx)(l_,{open:ee,close:function(){te(!1)},name:ce,selectedTags:null===je||void 0===je?void 0:je.reduce((function(e,t){return"".concat(e,",").concat(t.id)}),""),returnSelectedTags:function(e){Pe(e)}}),W.map((function(e,n){var a;return Object(y.jsx)(Xd,{title:"Crop Season: ".concat(e.name||""),totalItems:null===(a=e.plans)||void 0===a?void 0:a.length,testId:"plans",children:e.plans.map((function(a,r){var c,i,o,s,l,d,u,b=null===t||void 0===t?void 0:t.find((function(e){return(null===e||void 0===e?void 0:e.id)===(null===a||void 0===a?void 0:a.planId)})),j=Af(null===a||void 0===a?void 0:a.flags,27);return Object(y.jsxs)(lu,{testId:"plan",linkTo:"".concat(Cc.plans,"/").concat(a.planId,"/view"),title:a.name,subtitle:a.crop.name||"No Crop",runningProcesses:Ce&&L===n&&B===r,onAction:function(t){ye(t,a,n,r,e.name)},menuItems:ls,children:[Object(y.jsx)("div",{"data-testid":"plan-card-details",className:"flex flex-wrap w-full",children:j.extraTagsNames.length>0?Object(y.jsx)(fu,{position:"bottom",ariaLabel:"Task Tags",top:"1.5rem",msg:Object(y.jsx)(Pf,{extraTagsNames:j.extraTagsNames}),component:Object(y.jsx)(Sf,{displayTagsObject:j,isLandingPage:!0,viewKey:ud})}):Object(y.jsx)(Sf,{displayTagsObject:j,isLandingPage:!0,viewKey:ud})}),Object(y.jsxs)("div",{className:"flex flex-wrap w-full",children:[Object(y.jsx)(uu,{id:"plan-planned-area",title:"Planned Area",value:null===a||void 0===a?void 0:a.estimatedAreaValue.toFixed(2),testId:"plan"}),Object(y.jsx)(uu,{id:"plan-created",title:"Created",value:null===a||void 0===a?void 0:a.createdOn,testId:"plan"}),Object(y.jsx)(uu,{id:"plan-fixed-cost-per-acre",title:"Fixed Cost/Acre",value:Se((null===a||void 0===a?void 0:a.fixedCost)/(null===a||void 0===a?void 0:a.estimatedAreaValue)),testId:"plan",hideValue:!ve}),Object(y.jsx)(uu,{id:"plan-variable-cost-per-acre",title:"Variable Cost/Acre",value:Se((null===a||void 0===a?void 0:a.variableCost)/(null===a||void 0===a?void 0:a.estimatedAreaValue)),testId:"plan",hideValue:!ve}),Object(y.jsx)(uu,{id:"plan-projected-revenue-per-acre",title:"Proj. Rev/Acre",value:Se(((null===b||void 0===b||null===(c=b.projectedRevenue)||void 0===c?void 0:c.yieldPerArea)*(null===b||void 0===b||null===(i=b.projectedRevenue)||void 0===i?void 0:i.pricePerUnit)*(null===b||void 0===b?void 0:b.estimatedAreaValue)+(null===b||void 0===b||null===(o=b.projectedRevenue)||void 0===o?void 0:o.fsaPayment))/(null===a||void 0===a?void 0:a.estimatedAreaValue)),testId:"plan",hideValue:!ve}),Object(y.jsx)(uu,{id:"plan-projected-net-revenue-per-acre",title:"Proj. Net Rev/Acre",value:Se((((null===b||void 0===b||null===(s=b.projectedRevenue)||void 0===s?void 0:s.yieldPerArea)*(null===b||void 0===b||null===(l=b.projectedRevenue)||void 0===l?void 0:l.pricePerUnit)*(null===b||void 0===b?void 0:b.estimatedAreaValue)+(null===b||void 0===b||null===(d=b.projectedRevenue)||void 0===d?void 0:d.fsaPayment))*(null===b||void 0===b||null===(u=b.projectedRevenue)||void 0===u?void 0:u.cropSharePercent)-((null===a||void 0===a?void 0:a.fixedCost)+(null===a||void 0===a?void 0:a.variableCost)))/(null===a||void 0===a?void 0:a.estimatedAreaValue)),hideValue:!ve})]})]},a.planId)}))},e.id)})),Ho(c,i,o),Object(y.jsx)("div",{className:"mb-12",children:" "})]})})};gL.defaultProps={plans:[]};var CL=gL,yL=function(e){var t,n,r,c,i,o=e.plan,s=e.fullPlan,l=e.onAction,d=e.runningProcesses,u=Object(a.useContext)(ac),p=Object(b.a)(u,1)[0].loggedInUserOrgPermission,f=ir(p.financialAccess,"READ"),v=function(e,t,n){return Object(y.jsx)(yf,{unit:"USD"===t?"usCurrency":t,roundedTo:n,children:e})};return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex flex-col items-start ",children:[Object(y.jsx)("span",{className:"text-sm font-bold",children:Object(y.jsx)(j.b,{to:"".concat(Cc.plans,"/").concat(o.planId,"/view"),children:o.name})}),(null===o||void 0===o?void 0:o.flags)&&Object(y.jsx)(m.TagCloud,{children:null===o||void 0===o||null===(t=o.flags)||void 0===t?void 0:t.map((function(e){return Object(y.jsx)(m.Tag,{color:e.color,children:e.name},e.id)}))})]})}),Object(y.jsx)(m.Table.Cell,{children:Number(null===o||void 0===o?void 0:o.estimatedAreaValue).toFixed(2)}),Object(y.jsx)(m.Table.Cell,{children:(null===o||void 0===o||null===(n=o.crop)||void 0===n?void 0:n.name)||"none"}),Object(y.jsx)(m.Table.Cell,{children:f?Object(y.jsx)(y.Fragment,{children:v((null===o||void 0===o?void 0:o.fixedCost)/(null===o||void 0===o?void 0:o.estimatedAreaValue),null===o||void 0===o?void 0:o.currency,2)}):""}),Object(y.jsx)(m.Table.Cell,{children:f?Object(y.jsx)(y.Fragment,{children:v((null===o||void 0===o?void 0:o.variableCost)/(null===o||void 0===o?void 0:o.estimatedAreaValue),null===o||void 0===o?void 0:o.currency,2)}):""}),Object(y.jsx)(m.Table.Cell,{children:f?Object(y.jsx)(y.Fragment,{children:v(((null===s||void 0===s||null===(r=s.projectedRevenue)||void 0===r?void 0:r.yieldPerArea)*(null===s||void 0===s||null===(c=s.projectedRevenue)||void 0===c?void 0:c.pricePerUnit)*(null===s||void 0===s?void 0:s.estimatedAreaValue)+(null===s||void 0===s||null===(i=s.projectedRevenue)||void 0===i?void 0:i.fsaPayment))/(null===o||void 0===o?void 0:o.estimatedAreaValue),null===o||void 0===o?void 0:o.currency,2)}):""}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)("div",{className:"mr-4",children:null===o||void 0===o?void 0:o.createdOn}),Object(y.jsx)("div",{"data-testid":"plan-table-options-menu",className:"absolute right-0 flex-none w-10 mr-2",children:d?Object(y.jsx)(m.Spinner,{size:"sm"}):Object(y.jsx)(Wo,{onAction:function(e){return l(e,o)},options:ls})})]})]},o.planId)};yL.defaultProps={runningProcesses:!1};var PL=yL,AL=function(e){var t=e.plans,n=e.loadPlanSummaries,r=e.setTagsLoading,c=e.totalPlans,i=e.planPageNumber,o=e.handlePageChange,s=Object(a.useContext)(we),l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],f=Object(a.useContext)(ac),v=Object(b.a)(f,2)[1],O=Object(a.useState)(),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)(!1),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(!1),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)(!1),R=Object(b.a)(_,2),D=R[0],k=R[1],L=Object(a.useState)(""),F=Object(b.a)(L,2),M=F[0],V=F[1],B=Object(a.useState)(),U=Object(b.a)(B,2),z=U[0],Z=U[1],H=Object(a.useState)([]),W=Object(b.a)(H,2),q=W[0],J=W[1],K=Object(a.useState)(null),Q=Object(b.a)(K,2)[1],X=Object(a.useState)(),$=Object(b.a)(X,2),ee=$[0],te=$[1],ae=Object(a.useState)(),re=Object(b.a)(ae,2),ce=re[0],ie=re[1],oe=Object(a.useState)(t),se=Object(b.a)(oe,2),le=se[0],de=se[1],ue=Object(p.h)(),be=vL(),je=be.shareOrPrint,pe=be.downloadingPDF,fe=Object(a.useState)(),me=Object(b.a)(fe,2),ve=me[0],Oe=me[1],he=Object(a.useState)(-1),xe=Object(b.a)(he,2),ge=xe[0],Ce=xe[1],ye=function(){var e=Object(Y.a)(G.a.mark((function e(n,a,r){var c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c=null===t||void 0===t?void 0:t.find((function(e){return e.id===(null===a||void 0===a?void 0:a.planId)})),Ce(r),{view:function(){ue.push({pathname:"".concat(Cc.plans,"/").concat(a.planId,"/view"),state:{selectedView:"edit-fromView"}})},edit:function(){ue.push({pathname:"".concat(Cc.plans,"/").concat(a.planId),selectedView:"edit"})},tag:function(){var e;V(a.name),Z(a.planId),J((null===(e=a.flags)||void 0===e?void 0:e.length)>0||void 0!==a.flags?a.flags:[]),k(!0)},duplicate:function(){ue.push({pathname:"".concat(Cc.plans,"/").concat(a.planId),state:{selectedView:"edit-dup"}})},delete:function(){Oe(a),j(!0)},convertTask:function(){jc(v,Qr,s.events.epic.Tasks.pages.fromPlan),s.sendEventToAmplitude(s.events.epic.Tasks.createTask,{page:s.events.epic.Tasks.pages.fromPlan}),g(c),S(!0)},convertToRec:function(){g(c),w(!0)},shareOrPrint:function(){je(a.planId)}}[n]();case 4:case"end":return e.stop()}}),e)})));return function(t,n,a){return e.apply(this,arguments)}}(),Pe=function(){var e=Object(Y.a)(G.a.mark((function e(a){var c,i,o,s;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r(!0),c=t.filter((function(e){return e.id===z})),delete(i=Object(I.a)(Object(I.a)({},c[0]),{},{id:c[0].planId,flagIds:a.map((function(e){return e.id}))})).createdOn,delete i.variableCost,delete i.projectRevenue,delete i.netRevenue,delete i.planId,delete i.cropSeasons,delete i.crop,delete i.fixedCost,delete i.flags,e.next=14,Pn.update(z,i);case 14:return o=e.sent,s=o.promise,e.next=18,s.then((function(){J(a),r(!1),n()})).catch(Ae.default).catch((function(e){var t,n,a,c;null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.validationErrors?Q("Error saving task: ".concat(e.response.data.message)):null!==(a=e.response)&&void 0!==a&&null!==(c=a.data)&&void 0!==c&&c.displayErrorMessage?Q(e.response.data.displayErrorMessage):uc(v)(e),r(!1)}));case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(y.jsx)("div",{className:"mx-2 my-4 min-w-content","data-testid":"plans-table",style:{minWidth:"min-content"},children:Object(y.jsxs)(ll,{children:[Ho(c,i,o),Object(y.jsx)(Yk,{open:A,close:function(){return S(!1)},currentPlan:x}),Object(y.jsx)(xL,{open:u,close:function(){return j(!1)},planName:null===ve||void 0===ve?void 0:ve.name,planId:null===ve||void 0===ve?void 0:ve.planId}),Object(y.jsx)(Kk,{open:E,close:function(){return w(!1)},currentPlan:x}),Object(y.jsx)(l_,{open:D,close:function(){k(!1)},name:M,selectedTags:null===q||void 0===q?void 0:q.reduce((function(e,t){return"".concat(e,",").concat(t.id)}),""),returnSelectedTags:function(e){Pe(e)}}),Object(y.jsx)(ol,{listType:"plans",routePath:"/app/plan",items:le,tableColumns:Tk,onSort:function(e,t){te(e),ie(t),de(function(e,t,n){if(!n)return e;var a=null===e||void 0===e?void 0:e.map((function(e){return Object(ne.cloneDeep)(e)}));switch(t){case"name":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.name.toLowerCase()}],n);case"plannedArea":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.estimatedAreaValue}],n);case"crop":return Object(ne.orderBy)(a,[function(e){var t;return null===e||void 0===e||null===(t=e.crop)||void 0===t?void 0:t.name}],n);case"fixedCostPerAcre":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.fixedCost}],n);case"varCostPerAcre":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.variableCost}],n);case"projRevPerAcre":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.projectRevenue}],n);case"createdAt":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.createdOn}],n);default:return a}}(le,e,t))},sortBy:ee,sortDir:ce,children:function(e){return e.rows.map((function(e,t){return Object(y.jsx)(y.Fragment,{children:e?Object(y.jsx)(PL,{onAction:function(n){ye(n,e,t)},plan:e,fullPlan:e,runningProcesses:pe&&ge===t},e.id):Object(y.jsx)(m.Spinner,{})})}))}}),Ho(c,i,o),Object(y.jsx)("div",{className:"mb-12",children:" "})]})})},SL=Sd(ud,"tile"),TL=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0],n=t.loadingOrg,r=t.loggedInUserOrgPermission,c=t.isGlobalCropSeasonLoading,i=SL.get(),o=Object(a.useState)(null!==i&&void 0!==i?i:"tile"),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Fk(),j=u.plans,f=u.pageNo,O=u.plansCount,h=u.goToPage,x=u.isLoading,g=u.reset,C=u.filterByNameQuery,P=u.filterByDateRange,A=u.reload,S=Object(a.useState)(null),T=Object(b.a)(S,2),N=T[0],E=T[1],w=zi(N,300),_=Object(a.useState)(!1),R=Object(b.a)(_,2),I=R[0],D=R[1],k=Object(a.useState)(!0),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Object(a.useState)(!1),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=cr(null===r||void 0===r?void 0:r.role,"Full control");Object(a.useEffect)((function(){C(w)}),[w,C]);var Y=function(){g()};return Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"plans",children:[Object(y.jsx)(lo,{hideCropSeasonDropdown:!1,onCropSeasonSelect:Y,onOrganizationSelect:Y,children:Object(y.jsx)(lo.Item,{title:"Plans",value:"All Plans",isLast:!0,disabled:!0})}),location&&location.state&&location.state.toastRenderContents&&F?Object(y.jsx)(m.Toast,{isError:!1,onClose:function(){M(!1)},children:location.state.toastRenderContents}):null,I&&Object(y.jsx)(p.b,{push:!0,to:{pathname:"".concat(Cc.plans,"/plan")}}),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex items-center justify-between",children:[Object(y.jsx)(To,{id:"plan-search-input",filterItems:[{key:"seasons",value:"Seasons"},{key:"farms",value:"Farms"},{key:"crops",value:"Crops"},{key:"flags",value:"Flags"}],selectedItems:[],name:"search_plans",placeholder:"Search Plans",onChange:function(e){E(e.target.value)},onFilterChange:ne.noop,onChangeLabel:ne.noop,onChangeProductType:ne.noop,onChangeTaskType:ne.noop,onDateRangeChange:function(e){P(Object(v.a)(e.target.value))},showCropSeason:!1}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)(Rd,{testId:"plans-view-toggle",view:l,changeView:function(e){d(e),SL.save(e)}}),Object(y.jsx)("div",{className:"pl-2 whitespace-no-wrap",children:Z&&Object(y.jsx)(m.Button,{id:"add-plan-button",type:"primary",onClick:function(e){e.stopPropagation(),D(!0)},icon:Object(y.jsx)(Eo.a,{}),children:"Create Plan"})})]})]}),U||x||n||c?Object(y.jsx)(m.Spinner,{}):j&&0===j.length?Object(y.jsx)(Vd,{buttonText:"Create Plan",onClick:function(e){e.stopPropagation(),D(!0)},subtitle:"We were unable to find any plans under this organization.",setPermission:function(){return Z}}):"tile"===l?Object(y.jsx)(CL,{plans:j,planPageNumber:f,totalPlans:O,handlePageChange:h,loadPlanSummaries:A,setTagsLoading:z}):Object(y.jsx)(AL,{plans:Object(ne.orderBy)(j,[function(e){return e.name.toLowerCase()}],"asc"),planPageNumber:f,totalPlans:O,handlePageChange:h,loadPlanSummaries:A,setTagsLoading:z})]})]})},NL=Fu.e().shape({name:Fu.f().label("Plan Name").trim().max(128,"Name must be 128 characters or less.").required("Required").typeError("Required"),crops:Fu.a().label("Crop").nullable(),area:Fu.d().required("Required").typeError("Required"),revenue:Fu.e().shape({yieldPerArea:Fu.d(),salePricePerUnit:Fu.d(),fsaPayment:Fu.d(),cropShare:Fu.d()}).nullable()}),EL=[["name","crops","area","cropSeason"],["productApplications"],["totalSelectedArea","coverage"],["costs"],["revenue","fsaPaymentPerAcre"],["notes"]],wL={readOnly:!1},_L=function(){var e=Object(Zi.f)("_planMeta"),t=Object(b.a)(e,1)[0];return Object(I.a)(Object(I.a)({},wL),t.value)},RL=function(e){var t=e.variableCost,n=e.fixedCost,a=e.totalProjectedNetRevenue,r=e.perAcreProjectedNetRevenue,c=e.memberRole,i=e.memberFinancialAccess,o=Object(p.j)().id,s=function(e){return"Full control"===c&&"none"===i?"":"Admin"===c||"View Only"===c||"Full control"===c&&"WRITE"===i||"Full control"===c&&"READ"===i&&"plan"!==o?e:""};return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex flex-col mr-4 w-50",children:[Object(y.jsx)("div",{className:"text-neutral-300 opacity-60",children:"Variable Cost"}),Object(y.jsx)("div",{"data-testid":"variable-cost",className:"text-neutral-300",children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:s(t)})})]}),Object(y.jsxs)("div",{className:"flex flex-col mr-4 w-50",children:[Object(y.jsx)("div",{className:"text-neutral-300 opacity-60",children:"Fixed Cost"}),Object(y.jsx)("div",{"data-testid":"variable-cost",className:"text-neutral-300",children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:s(n||0)})})]}),Object(y.jsxs)("div",{className:"flex flex-col mr-4 w-50",children:[Object(y.jsx)("div",{className:"text-neutral-300 opacity-60",children:"Proj. Net Revenue"}),Object(y.jsx)("div",{"data-testid":"net-revenue",className:"text-neutral-300",children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:s(a||0)})})]}),Object(y.jsxs)("div",{className:"flex flex-col mr-4 w-50",children:[Object(y.jsx)("div",{className:"text-neutral-300 opacity-60",children:"Proj. Net Revenue Per Area"}),Object(y.jsx)("div",{"data-testid":"net-revenue-per-acre",className:"text-neutral-300",children:Object(y.jsxs)("div",{children:[isFinite(r)&&Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:s(r||0)}),"/ac"]})})]})]})},IL=function(e){var t=e.isSaving,n=e.history,r=e.fixedCost,c=e.totalProjectedNetRevenue,i=e.onSubmit,o=e.perAcreProjectedNetRevenue,s=e.variableCost,l=e.selectedview,d=e.values,u=e.memberRole,j=e.memberFinancialAccess,f=Object(a.useState)(),v=Object(b.a)(f,2),O=v[0],h=v[1],x=_L().readOnly,g=Object(p.j)().id;return Object(y.jsxs)(y.Fragment,{children:[O&&Object(y.jsx)(p.b,{push:!0,to:O}),Object(y.jsxs)("div",{"data-testid":"plan-top-header",className:"flex items-center justify-between px-12",style:{height:"100px"},children:[Object(y.jsx)(RL,{fixedCost:r||0,variableCost:s||0,totalProjectedNetRevenue:c||0,perAcreProjectedNetRevenue:o||0,values:d,memberRole:u,memberFinancialAccess:j}),Object(y.jsxs)("div",{className:"flex justify-end flex-1",children:[Object(y.jsx)("div",{children:Object(y.jsx)(m.Button,{type:"primary",ghost:!0,onClick:function(){"edit-fromView"===l?n.push("".concat(Cc.plans,"/").concat(g,"/view")):n.push(Cc.plans)},id:"cancelPlan",children:"Cancel"})}),Object(y.jsx)("div",{className:"ml-4",children:x?Object(y.jsx)(m.Button,{type:"primary",onClick:function(){x&&h("".concat(Cc.plans,"/").concat(g))},id:"editPlan",icon:Object(y.jsx)(qI.a,{style:{fontSize:".8rem"}}),children:"Edit"}):Object(y.jsx)(m.Button,{type:"primary",onClick:i,disabled:t,loading:t,id:"savePlan",children:"Save"})})]})]})]})};IL.defaultProps={values:{crop:""},isSaving:!1};var DL=Object(p.l)(IL),kL=function(){var e=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=!0===t.custom?Yt.fetch(t.productId):Zt.fetch(t.productId),a=n.promise,e.next=3,a.catch(Ae.default).catch((function(){return{data:{stdfactor:t.productRateValue,stdunit:t.productRateUnit,stdpackageunit:t.specificCostUnit,density:t.density}}}));case 3:return r=e.sent,0===(c=r.data).stdFactor?c.stdFactor=1:0===c.stdfactor&&(c.stdfactor=1),e.abrupt("return",Object(I.a)(Object(I.a)({},t),{},{density:c.density,stdfactor:!0===t.custom?c.stdFactor:c.stdfactor,stdunit:!0===t.custom?c.standardUnit:c.stdunit,stdpackageunit:!0===t.custom?c.stdPackageUnit:c.stdpackageunit}));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t=function(){var t=Object(Y.a)(G.a.mark((function t(n,a){var r,c,i,o;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.stdfactor,c=n.stdunit,i=n.stdpackageunit,o=n,r&&c&&i){t.next=6;break}return t.next=5,e(n);case 5:o=t.sent;case 6:return t.abrupt("return",X(o,a));case 7:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}();return{appliedAreaCalculation:t,getStdUnits:e}};function LL(e){return isNaN(e)?parseFloat(e.replace(/[$,]/g,"")):parseFloat(e)}var FL=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=kL(),n=t.appliedAreaCalculation,a=e.setFieldValue,r=e.values,c=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,a,r,c,i=arguments;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:[],a=i.length>1?i[1]:void 0,r=t.map(function(){var e=Object(Y.a)(G.a.mark((function e(t){var r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(t,a);case 2:return r=e.sent,e.abrupt("return",r);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),e.next=5,Promise.all(r);case 5:return c=e.sent,e.abrupt("return",c);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),i=function(e){a&&r&&(r.fixedCost.landRent_PerAc&&a("fixedCost.landRent",parseFloat(Number(LL(r.fixedCost.landRent_PerAc))*Number(e))),r.fixedCost.repairs_PerAc&&a("fixedCost.repairs",parseFloat(Number(LL(r.fixedCost.repairs_PerAc))*Number(e))),r.fixedCost.returnToMgt_PerAc&&a("fixedCost.returnToMgt",parseFloat(Number(LL(r.fixedCost.returnToMgt_PerAc))*Number(e))),r.fixedCost.equipment_PerAc&&a("fixedCost.equipment",parseFloat(Number(LL(r.fixedCost.equipment_PerAc))*Number(e))),r.fixedCost.taxes_PerAc&&a("fixedCost.taxes",parseFloat(Number(LL(r.fixedCost.taxes_PerAc))*Number(e))),r.fixedCost.labor_PerAc&&a("fixedCost.labor",parseFloat(Number(LL(r.fixedCost.labor_PerAc))*Number(e))),r.fixedCost.insurance_PerAc&&a("fixedCost.insurance",parseFloat(Number(LL(r.fixedCost.insurance_PerAc))*Number(e))),r.projectedRevenue.fsaPaymentPerAc&&a("projectedRevenue.fsaPayment",parseFloat(Number(LL(r.projectedRevenue.fsaPaymentPerAc))*Number(e))),r.projectedRevenue.yieldTotal&&a("projectedRevenue.yieldTotal",parseFloat(Number(LL(r.projectedRevenue.pricePerUnit))*Number(r.projectedRevenue.yieldPerArea)*Number(e))))};return{recalculateProducts:c,recalculateCosts:i}},ML=function(){var e=Object(Zi.h)(),t=e.values,n=e.setFieldValue,r=e.setFieldTouched,c=e.touched,i=FL({values:t,setFieldValue:n}),o=i.recalculateProducts,s=i.recalculateCosts,l=Du().crops,d=(null===l||void 0===l?void 0:l.map((function(e){return{key:e.id,value:e.name}})))||[];Object(a.useEffect)((function(){var e=c.estimatedAreaValue||!t.totalApplied?t.estimatedAreaValue:t.totalApplied;if(e>0){var a=Ek(e);o(t.planProductEntries,a).then((function(e){n("planProductEntries",e)})),n("area",a),s(e)}}),[null===t||void 0===t?void 0:t.estimatedAreaValue]);return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(m.Columns,{wrap:!0,children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{className:"w-1/3 mr-8",children:Object(y.jsx)(m.Form.Field,{label:"Plan Name *",children:Object(y.jsx)(Qi,{control:m.Input,name:"name","data-testid":"planName"})})}),Object(y.jsx)("div",{className:"w-1/3 mr-8",children:Object(y.jsx)(m.Form.Field,{label:"Planned Area *",children:Object(y.jsx)(Qi,{control:m.Input,name:"estimatedAreaValue","data-testid":"plannedArea",onBlur:function(e){var a,c,i,o,s,l,d=Number.isNaN(Ek(e.target.value))?1:Ek(e.target.value);(d!==t.estimatedAreaValue&&r("estimatedAreaValue"),null!==t&&void 0!==t&&null!==(a=t.projectedRevenue)&&void 0!==a&&a.pricePerUnit&&null!==t&&void 0!==t&&null!==(c=t.projectedRevenue)&&void 0!==c&&c.yieldPerArea&&d)&&n("projectedRevenue.yieldTotal",parseFloat(d*Ek(null===t||void 0===t||null===(o=t.projectedRevenue)||void 0===o?void 0:o.pricePerUnit)*Ek(null===t||void 0===t||null===(s=t.projectedRevenue)||void 0===s?void 0:s.yieldPerArea)).toFixed(2));null!==t&&void 0!==t&&null!==(i=t.projectedRevenue)&&void 0!==i&&i.fsaPayment&&d&&n("projectedRevenue.fsaPaymentPerAc",parseFloat(Ek(null===t||void 0===t||null===(l=t.projectedRevenue)||void 0===l?void 0:l.fsaPayment)/d).toFixed(2));n("estimatedAreaValue",d)},imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1}}}})})}),Object(y.jsx)("div",{className:"w-1/3 mr-8",children:Object(y.jsx)(m.Form.Field,{label:"Crop",children:Object(y.jsx)(Qi,{control:m.Search,name:"cropId",items:d,"data-testid":"cropSelect",selectedValue:function(){var e=null===l||void 0===l?void 0:l.find((function(e){return(null===e||void 0===e?void 0:e.id)===(null===t||void 0===t?void 0:t.cropId)}));return(null===e||void 0===e?void 0:e.id)||null}()})})})]})})})})},VL=function(e,t,n,a){return"Full control"===e&&"READ"===t&&"plan"!==n?a:"Full control"===e&&"none"===t?null:a},BL=function(e,t,n,a){return"Full control"===e&&"READ"===t&&"plan"!==n?a:"Full control"===e&&"none"===t?null:a},UL=function(e){var t,n,a,r=e.memberRole,c=e.memberFinancialAccess,i=e.planId,o=Object(Zi.h)(),s=o.values,l=o.setFieldValue,d=o.setFieldTouched;return a="Full control"===r&&"none"===c||"Full control"===r&&"READ"===c,Object(y.jsx)(m.Form.Field,{label:"Land Rent",children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsxs)("div",{className:"w-full flex items-center",children:[Object(y.jsx)("div",{"data-testid":"LandRent_Total",className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Total",id:"fixedCost.landRent",name:"fixedCost.landRent",disabled:a,value:VL(r,c,i,null===s||void 0===s||null===(t=s.fixedCost)||void 0===t?void 0:t.landRent),onBlur:function(e){d("fixedCost.landRent"),l("fixedCost.landRent",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.landRent_PerAc",parseFloat(Ek(e.target.value)/(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.landRent_PerAc",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})}),Object(y.jsx)("div",{"data-testid":"LandRent_PerAc",className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Per Ac",id:"fixedCost.landRent_PerAc",name:"fixedCost.landRent_PerAc",disabled:a,value:VL(r,c,i,null===s||void 0===s||null===(n=s.fixedCost)||void 0===n?void 0:n.landRent_PerAc),onBlur:function(e){d("fixedCost.landRent_PerAc"),l("fixedCost.landRent_PerAc",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.landRent",parseFloat(Ek(e.target.value)*(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.landRent",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})})]})})})},zL=function(e){var t,n,a,r=e.memberRole,c=e.memberFinancialAccess,i=e.planId,o=Object(Zi.h)(),s=o.values,l=o.setFieldValue,d=o.setFieldTouched;return a="Full control"===r&&"none"===c||"Full control"===r&&"READ"===c,Object(y.jsx)(m.Form.Field,{label:"Repairs",children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsxs)("div",{className:"w-full flex items-center",children:[Object(y.jsx)("div",{className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Total",id:"fixedCost.repairs",name:"fixedCost.repairs",value:VL(r,c,i,null===s||void 0===s||null===(t=s.fixedCost)||void 0===t?void 0:t.repairs),disabled:a,onBlur:function(e){d("fixedCost.repairs"),l("fixedCost.repairs",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.repairs_PerAc",parseFloat(Ek(e.target.value)/(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.repairs_PerAc",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})}),Object(y.jsx)("div",{className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Per Ac",id:"fixedCost.repairs_PerAc",name:"fixedCost.repairs_PerAc",disabled:a,value:VL(r,c,i,null===s||void 0===s||null===(n=s.fixedCost)||void 0===n?void 0:n.repairs_PerAc),onBlur:function(e){d("fixedCost.repairs_PerAc"),l("fixedCost.repairs_PerAc",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.repairs",parseFloat(Ek(e.target.value)*(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.repairs",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})})]})})})},ZL=function(e){var t,n,a,r=e.memberRole,c=e.memberFinancialAccess,i=e.planId,o=Object(Zi.h)(),s=o.values,l=o.setFieldValue,d=o.setFieldTouched;return a="Full control"===r&&"none"===c||"Full control"===r&&"READ"===c,Object(y.jsx)(m.Form.Field,{label:"Return to Management",children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsxs)("div",{className:"w-full flex items-center",children:[Object(y.jsx)("div",{className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Total",id:"fixedCost.returnToMgt",name:"fixedCost.returnToMgt",value:VL(r,c,i,null===s||void 0===s||null===(t=s.fixedCost)||void 0===t?void 0:t.returnToMgt),disabled:a,onBlur:function(e){d("fixedCost.returnToMgt"),l("fixedCost.returnToMgt",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.returnToMgt_PerAc",parseFloat(Ek(e.target.value)/(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.returnToMgt_PerAc",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})}),Object(y.jsx)("div",{className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Per Ac",id:"fixedCost.returnToMgt_PerAc",name:"fixedCost.returnToMgt_PerAc",value:VL(r,c,i,null===s||void 0===s||null===(n=s.fixedCost)||void 0===n?void 0:n.returnToMgt_PerAc),disabled:a,onBlur:function(e){d("fixedCost.returnToMgt_PerAc"),l("fixedCost.returnToMgt_PerAc",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.returnToMgt",parseFloat(Ek(e.target.value)*(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.returnToMgt",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})})]})})})},YL=function(e){var t,n,a,r=e.memberRole,c=e.memberFinancialAccess,i=e.planId,o=Object(Zi.h)(),s=o.values,l=o.setFieldValue,d=o.setFieldTouched;return a="Full control"===r&&"none"===c||"Full control"===r&&"READ"===c,Object(y.jsx)(m.Form.Field,{label:"Equipment",children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsxs)("div",{className:"w-full flex items-center",children:[Object(y.jsx)("div",{className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Total",id:"fixedCost.equipment",value:VL(r,c,i,null===s||void 0===s||null===(t=s.fixedCost)||void 0===t?void 0:t.equipment),disabled:a,name:"fixedCost.equipment",onBlur:function(e){d("fixedCost.equipment"),l("fixedCost.equipment",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.equipment_PerAc",parseFloat(Ek(e.target.value)/(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.equipment_PerAc",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})}),Object(y.jsx)("div",{className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Per Ac",id:"fixedCost.equipment_PerAc",name:"fixedCost.equipment_PerAc",disabled:a,value:VL(r,c,i,null===s||void 0===s||null===(n=s.fixedCost)||void 0===n?void 0:n.equipment_PerAc),onBlur:function(e){d("fixedCost.equipment_PerAc"),l("fixedCost.equipment_PerAc",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.equipment",parseFloat(Ek(e.target.value)*(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.equipment",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})})]})})})},HL=function(e){var t,n,a,r=e.memberRole,c=e.memberFinancialAccess,i=e.planId,o=Object(Zi.h)(),s=o.values,l=o.setFieldValue,d=o.setFieldTouched;return a="Full control"===r&&"none"===c||"Full control"===r&&"READ"===c,Object(y.jsx)(m.Form.Field,{label:"Taxes",children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsxs)("div",{className:"w-full flex items-center",children:[Object(y.jsx)("div",{className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Total",id:"fixedCost.taxes",disabled:a,name:"fixedCost.taxes",value:VL(r,c,i,null===s||void 0===s||null===(t=s.fixedCost)||void 0===t?void 0:t.taxes),onBlur:function(e){d("fixedCost.taxes"),l("fixedCost.taxes",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.taxes_PerAc",parseFloat(Ek(e.target.value)/(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.taxes_PerAc",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})}),Object(y.jsx)("div",{className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Per Ac",id:"fixedCost.taxes_PerAc",disabled:a,name:"fixedCost.taxes_PerAc",value:VL(r,c,i,null===s||void 0===s||null===(n=s.fixedCost)||void 0===n?void 0:n.taxes_PerAc),onBlur:function(e){d("fixedCost.taxes_PerAc"),l("fixedCost.taxes_PerAc",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.taxes",parseFloat(Ek(e.target.value)*(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.taxes",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})})]})})})},GL=function(e){var t,n,a,r=e.memberRole,c=e.memberFinancialAccess,i=e.planId,o=Object(Zi.h)(),s=o.values,l=o.setFieldValue,d=o.setFieldTouched;return a="Full control"===r&&"none"===c||"Full control"===r&&"READ"===c,Object(y.jsx)(m.Form.Field,{label:"Labor",children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsxs)("div",{className:"w-full flex items-center",children:[Object(y.jsx)("div",{"data-testid":"Labor_Total",className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Total",disabled:a,id:"fixedCost.labor",name:"fixedCost.labor",value:VL(r,c,i,null===s||void 0===s||null===(t=s.fixedCost)||void 0===t?void 0:t.labor),onBlur:function(e){d("fixedCost.labor"),l("fixedCost.labor",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.labor_PerAc",parseFloat(Ek(e.target.value)/(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.labor_PerAc",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})}),Object(y.jsx)("div",{"data-testid":"Labor_PerAc",className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Per Ac",disabled:a,id:"fixedCost.labor_PerAc",name:"fixedCost.labor_PerAc",value:VL(r,c,i,null===s||void 0===s||null===(n=s.fixedCost)||void 0===n?void 0:n.labor_PerAc),onBlur:function(e){d("fixedCost.labor_PerAc"),l("fixedCost.labor_PerAc",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.labor",parseFloat(Ek(e.target.value)*(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.labor",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})})]})})})},WL=function(e){var t,n,a,r=e.memberRole,c=e.memberFinancialAccess,i=e.planId,o=Object(Zi.h)(),s=o.values,l=o.setFieldValue,d=o.setFieldTouched;return a="Full control"===r&&"none"===c||"Full control"===r&&"READ"===c,Object(y.jsx)(m.Form.Field,{label:"Insurance",children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsxs)("div",{className:"w-full flex items-center",children:[Object(y.jsx)("div",{className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Total",disabled:a,id:"fixedCost.insurance",name:"fixedCost.insurance",value:VL(r,c,i,null===s||void 0===s||null===(t=s.fixedCost)||void 0===t?void 0:t.insurance),onBlur:function(e){d("fixedCost.insurance"),l("fixedCost.insurance",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.insurance_PerAc",parseFloat(Ek(e.target.value)/(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.insurance_PerAc",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})}),Object(y.jsx)("div",{className:"w-full flex-grow mt-8 mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Per Ac",disabled:a,id:"fixedCost.insurance_PerAc",name:"fixedCost.insurance_PerAc",value:VL(r,c,i,null===s||void 0===s||null===(n=s.fixedCost)||void 0===n?void 0:n.insurance_PerAc),onBlur:function(e){d("fixedCost.insurance_PerAc"),l("fixedCost.insurance_PerAc",Ek(e.target.value)),Ek(e.target.value)?l("fixedCost.insurance",parseFloat(Ek(e.target.value)*(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("fixedCost.insurance",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})})]})})})},qL=function(e){var t=e.memberRole,n=e.memberFinancialAccess,a=Object(p.j)().id;return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{className:"flex items-top",children:[Object(y.jsx)(m.Columns,{wrap:!0,children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsxs)("div",{className:"border-r",children:[Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(UL,{memberRole:t,memberFinancialAccess:n,planId:a})}),Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(zL,{memberRole:t,memberFinancialAccess:n,planId:a})}),Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(ZL,{memberRole:t,memberFinancialAccess:n,planId:a})})]})})}),Object(y.jsx)(m.Columns,{wrap:!0,children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsx)("div",{className:"ml-4",children:Object(y.jsxs)("div",{className:"border-r",children:[Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(YL,{memberRole:t,memberFinancialAccess:n,planId:a})}),Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(HL,{memberRole:t,memberFinancialAccess:n,planId:a})})]})})})}),Object(y.jsx)(m.Columns,{wrap:!0,children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsxs)("div",{className:"ml-4",children:[Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(GL,{memberRole:t,memberFinancialAccess:n,planId:a})}),Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(WL,{memberRole:t,memberFinancialAccess:n,planId:a})})]})})})]})})},JL=function(){return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsx)("div",{className:"flex items-center-1000",children:Object(y.jsx)(m.Form.Field,{children:Object(y.jsx)(Qi,{control:m.TextArea,name:"notes",id:"notes",maxLength:"1000",className:"h-64 overscroll-auto",resizeDisabled:!0})})})})})},KL=function(e){var t,n,a,r=e.memberRole,c=e.memberFinancialAccess,i=e.chkEdit,o=Object(Zi.h)(),s=o.values,l=o.setFieldValue,d=o.setFieldTouched;return a="Full control"===r&&"none"===c||"Full control"===r&&"READ"===c,Object(y.jsx)(m.Column,{children:Object(y.jsx)("div",{className:"w-full mr-8",children:Object(y.jsx)(m.Form.Field,{label:"Yield",children:Object(y.jsx)("div",{children:Object(y.jsxs)("div",{className:"w-full flex items-center mt-8 mr-4",children:[Object(y.jsx)(m.Column,{width:"w-full mr-4",children:Object(y.jsx)("div",{className:"w-full flex items-center mr-4",children:Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Total",id:"projectedRevenue.yieldTotal",name:"projectedRevenue.yieldTotal",imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],thousandsSeparator:","}}},disabled:!0})})})}),Object(y.jsx)(m.Column,{width:"w-full mr-4",children:Object(y.jsx)("div",{className:"w-full flex items-center mr-4",children:Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Per Ac",id:"projectedRevenue.yieldPerArea",name:"projectedRevenue.yieldPerArea",disabled:a,value:BL(r,c,i,null===s||void 0===s||null===(t=s.projectedRevenue)||void 0===t?void 0:t.yieldPerArea),onBlur:function(e){var t,n,a;(d("projectedRevenue.yieldPerArea"),l("projectedRevenue.yieldPerArea",Ek(e.target.value)),isNaN(Ek(e.target.value))&&l("projectedRevenue.yieldPerArea",Ek(e.target.value)),null!==s&&void 0!==s&&null!==(t=s.projectedRevenue)&&void 0!==t&&t.pricePerUnit&&Ek(e.target.value))&&l("projectedRevenue.yieldTotal",parseFloat(Ek(null===e||void 0===e||null===(n=e.target)||void 0===n?void 0:n.value)*Ek(null===s||void 0===s||null===(a=s.projectedRevenue)||void 0===a?void 0:a.pricePerUnit)*Ek(null===s||void 0===s?void 0:s.area)).toFixed(2))},imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})})})}),Object(y.jsx)(m.Column,{width:"w-full mr-4",children:Object(y.jsx)("div",{className:"w-full flex items-center mr-4",children:Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Sale Price Per Unit",id:"projectedRevenue.pricePerUnit",name:"projectedRevenue.pricePerUnit",disabled:a,value:BL(r,c,i,null===s||void 0===s||null===(n=s.projectedRevenue)||void 0===n?void 0:n.pricePerUnit),onBlur:function(e){var t,n,a;(d("projectedRevenue.pricePerUnit"),l("projectedRevenue.pricePerUnit",Ek(e.target.value)),isNaN(Ek(e.target.value))&&l("projectedRevenue.pricePerUnit",Ek(e.target.value)),null!==s&&void 0!==s&&s.area&&Ek(e.target.value)&&null!==s&&void 0!==s&&null!==(t=s.projectedRevenue)&&void 0!==t&&t.yieldPerArea)&&l("projectedRevenue.yieldTotal",parseFloat(Ek(null===e||void 0===e||null===(n=e.target)||void 0===n?void 0:n.value)*Ek(null===s||void 0===s?void 0:s.area)*Ek(null===s||void 0===s||null===(a=s.projectedRevenue)||void 0===a?void 0:a.yieldPerArea)).toFixed(2))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})})})})]})})})})})},QL=function(e){var t,n,a,r=e.memberRole,c=e.memberFinancialAccess,i=e.chkEdit,o=Object(Zi.h)(),s=o.values,l=o.setFieldValue,d=o.setFieldTouched;return a="Full control"===r&&"none"===c||"Full control"===r&&"READ"===c,Object(y.jsx)(m.Column,{children:Object(y.jsx)("div",{className:"w-full mr-8",children:Object(y.jsx)(m.Form.Field,{label:"FSA Payment",children:Object(y.jsx)("div",{children:Object(y.jsxs)("div",{className:"w-full flex items-center mt-8 mr-4",children:[Object(y.jsx)(m.Column,{width:"w-full mr-4",children:Object(y.jsx)("div",{className:"w-full flex items-center mr-4",children:Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Total",id:"projectedRevenue.fsaPayment",disabled:a,value:BL(r,c,i,null===s||void 0===s||null===(t=s.projectedRevenue)||void 0===t?void 0:t.fsaPayment),name:"projectedRevenue.fsaPayment",onBlur:function(e){d("projectedRevenue.fsaPayment"),l("projectedRevenue.fsaPayment",Ek(e.target.value)),Ek(e.target.value)?l("projectedRevenue.fsaPaymentPerAc",parseFloat(Ek(e.target.value)/(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("projectedRevenue.fsaPaymentPerAc",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})})})}),Object(y.jsx)(m.Column,{width:"w-full mr-4",children:Object(y.jsx)("div",{className:"w-full flex items-center mr-4",children:Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Per Ac",id:"projectedRevenue.fsaPaymentPerAc",disabled:a,name:"projectedRevenue.fsaPaymentPerAc",value:BL(r,c,i,null===s||void 0===s||null===(n=s.projectedRevenue)||void 0===n?void 0:n.fsaPaymentPerAc),onBlur:function(e){d("projectedRevenue.fsaPaymentPerAc"),l("projectedRevenue.fsaPaymentPerAc",Ek(e.target.value)),Ek(e.target.value)?l("projectedRevenue.fsaPayment",parseFloat(Ek(e.target.value)*(null===s||void 0===s?void 0:s.area)).toFixed(2)):l("projectedRevenue.fsaPayment",Ek(e.target.value))},imask:{mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})})})})]})})})})})},XL=function(e){var t,n=e.memberRole,a=e.memberFinancialAccess,r=e.chkEdit,c=Object(Zi.h)(),i=c.values,o=c.setFieldValue,s=c.setFieldTouched;return t="Full control"===n&&"none"===a||"Full control"===n&&"READ"===a,Object(y.jsx)(m.Column,{children:Object(y.jsx)("div",{className:"w-full mr-8",children:Object(y.jsx)(m.Form.Field,{label:"Crop Share %",children:Object(y.jsx)("div",{children:Object(y.jsx)("div",{className:"w-full flex items-center mt-8 mr-4",children:Object(y.jsx)(m.Column,{width:"w-full mr-4",children:Object(y.jsx)("div",{className:"w-full flex items-center mr-4",children:Object(y.jsx)("div",{className:"w-full flex-grow mr-4",children:Object(y.jsx)(Qi,{control:m.Input,label:"Total",id:"projectedRevenue.cropSharePercent",disabled:t,name:"projectedRevenue.cropSharePercent",value:BL(n,a,r,null===i||void 0===i?void 0:i.projectedRevenue.cropSharePercent),onBlur:function(e){s("projectedRevenue.cropSharePercent"),e.target.value?o("projectedRevenue.cropSharePercent",parseFloat(Ek(e.target.value))):o("projectedRevenue.cropSharePercent",parseFloat(Ek(100)))},imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})})})})})})})})})},$L=function(e){var t=e.memberRole,n=e.memberFinancialAccess,a=Object(p.j)().id;return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{className:"w-full flex items-center mr-8",children:[Object(y.jsx)("div",{className:"border-r",children:Object(y.jsx)(KL,{memberRole:t,memberFinancialAccess:n,chkEdit:a})}),Object(y.jsx)("div",{className:"border-r ml-4",children:Object(y.jsx)(QL,{memberRole:t,memberFinancialAccess:n,chkEdit:a})}),Object(y.jsx)("div",{className:"ml-4",children:Object(y.jsx)(XL,{memberRole:t,memberFinancialAccess:n,chkEdit:a})})]})})},eF=function(e){var t=e.memberRole,n=e.memberFinancialAccess;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"font-medium text-lg mt-10",children:"Plan Info"}),Object(y.jsx)(ML,{}),Object(y.jsx)("div",{className:"border-b"}),Object(y.jsx)("div",{"data-testid":"more-info-title",className:"font-medium text-lg mt-10",children:"Fixed Cost"}),Object(y.jsx)(qL,{memberRole:t,memberFinancialAccess:n}),Object(y.jsx)("div",{className:"border-b"}),Object(y.jsx)("div",{"data-testid":"more-info-title",className:"font-medium text-lg mt-10",children:"Projected Revenue"}),Object(y.jsx)($L,{memberRole:t,memberFinancialAccess:n}),Object(y.jsx)("div",{"data-testid":"more-info-title",className:"font-medium text-lg mt-10",children:"Notes"}),Object(y.jsx)(JL,{})]})},tF=n(73),nF=function(){var e=Object(a.useState)(null),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(!1),i=Object(b.a)(c,1)[0],o=Object(a.useState)(!1),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(0),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useState)([]),v=Object(b.a)(m,2),O=v[0],h=v[1];return Object(a.useEffect)((function(){d(i)}),[d,i]),Object(a.useEffect)((function(){f(Object(tF.b)(O))}),[O.length]),{fields:n||[],setFields:r,loading:l,originalTotalArea:p,setProperties:h}};function aF(e){return null===e||void 0===e?void 0:e.properties.map((function e(t){return t.fields?t.fields.map(e).flat():t.cropzones?t.cropzones.map(e).flat():t.archived?[t.id]:[]})).flat()}function rF(e,t){var n=function(e){return Object(ne.orderBy)(e,"archived")},a=function e(t){return t.fields?t.fields.map(e).flat():t.cropzones?t.cropzones.map(e).flat():[t.id]},r=function(e){if(!e.archived)return!0;var n=a(e);return n.length>0&&n.find((function(e){return-1!==(null===t||void 0===t?void 0:t.indexOf(e))}))};return null===e||void 0===e?void 0:e.properties.filter(r).map((function(e){return Object(I.a)(Object(I.a)({},e),{},{fields:n(e.fields.filter(r).map((function(e){return Object(I.a)(Object(I.a)({},e),{},{cropzones:n(e.cropzones.filter(r))})})))})}))}var cF=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;return FS.b.parseFloatRound(e/100*t,n,Z_.a.ROUND_HALF_UP)},iF=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;return FS.b.parseFloatRound(e/t*100,n,Z_.a.ROUND_HALF_UP)},oF=function(e,t){var n=[],a=e.map((function(e){return e.id})),r=t.properties.filter((function(e){return a.includes(e.cropZoneId)})).filter((function(e){return!0===e.hydrated})),c=r.map((function(e){return e.cropZoneId})).filter((function(e){return a.includes(e)})),i=function(e){var t=Math.round(100*(e.boundaryArea+Number.EPSILON))/100;return e.areaValue?t=e.areaValue:e.reportedArea>0&&(t=Math.round(100*(e.reportedArea+Number.EPSILON))/100),t};return e.filter((function(e){return!c.includes(e.id)})).forEach((function(e){var t={farmId:e.farmId,fieldId:e.fieldId,cropZoneId:e.id,cropSeasonIds:e.cropSeasons.map((function(e){return e.id})),areaUnit:"acres",originalAcres:e.areaValue&&e.reportedArea>0?Math.round(100*(e.reportedArea+Number.EPSILON))/100:Math.round(100*(e.boundaryArea+Number.EPSILON))/100,areaValue:i(e),coveragePct:e.coveragePct||100,boundaryArea:Math.round(100*(e.boundaryArea+Number.EPSILON))/100,reportedArea:Math.round(100*(e.reportedArea+Number.EPSILON))/100,areaType:e.areaType||"reported",name:e.name,crop:e.crop,features:e.features,fieldName:e.fieldName,hydrated:!0};n.push(t)})),r.length>0||n.length>0?[].concat(Object(v.a)(r.slice()),n):null},sF=function(e,t,n,a){var r=[];return(null===e||void 0===e?void 0:e.length)>0&&e.forEach((function(e){e.fields.length>0&&e.fields.forEach((function(c){c.cropzones.forEach((function(i){var o,s=a.properties.find((function(e){return e.cropZoneId===i.id}));null!==t&&void 0!==t&&t.includes(i.id)&&r.push(Object(I.a)(Object(I.a)({},i),{},{farmId:(null===s||void 0===s?void 0:s.farmId)||e.id,fieldName:c.name,fieldId:c.id,features:null===(o=n.features)||void 0===o?void 0:o.filter((function(e){return c.id===e.properties.id})),areaValue:null===s||void 0===s?void 0:s.areaValue,coveragePct:s?s.coveragePct:100}))}))}))})),r},lF=function(e){var t,n,r,c,i,o=e.propertyLandingPageData,s=e.loading,l=e.fieldsAndAreasGeoJSONCollection,d=e.selectedCropSeasonIds,u=Object(Zi.h)(),j=u.values,p=u.setFieldValue,f=u.setFieldTouched,v=u.touched,O=FL({values:j,setFieldValue:p}),h=O.recalculateProducts,x=O.recalculateCosts,g=Object(a.useState)(null===j||void 0===j||null===(t=j.cropZones)||void 0===t?void 0:t.map((function(e){return null===e||void 0===e?void 0:e.cropZoneIdValue}))),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(null!==j&&void 0!==j&&j.propertiesGroupBy?null===j||void 0===j?void 0:j.propertiesGroupBy:"property"),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)(null),_=Object(b.a)(w,2),R=_[0],D=_[1],k=Object(a.useState)(!0),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Object(a.useState)(null),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=m.RadioButtonGroup.RadioButton,Y=Object(a.useState)(!1),H=Object(b.a)(Y,2),G=H[0],W=H[1],q=Object(a.useState)(null===(n=j.cropZones)||void 0===n?void 0:n.map((function(e){return e.cropZoneIdValue}))),J=Object(b.a)(q,1)[0],K=Object(a.useState)(aF(o)),Q=Object(b.a)(K,1)[0],X=Object(a.useState)(rF(o,J)),$=Object(b.a)(X,1)[0],ee=Object(a.useState)(j.cropZones),te=Object(b.a)(ee,1)[0],ne=nF(),ae=ne.originalTotalArea,re=ne.setProperties,ce=Mh($,d),ie=Object(a.useMemo)((function(){var e=[];return(null===ce||void 0===ce?void 0:ce.length)>0&&(null===ce||void 0===ce||ce.forEach((function(t){var n;(null===t||void 0===t||null===(n=t.fields)||void 0===n?void 0:n.length)>0&&(null===t||void 0===t||t.fields.forEach((function(n){null===n||void 0===n||n.cropzones.forEach((function(a){var r;null!==P&&void 0!==P&&P.includes(a.id)&&e.push(Object(I.a)(Object(I.a)({},a),{},{farmId:t.id,fieldName:n.name,features:null===(r=l.features)||void 0===r?void 0:r.filter((function(e){return n.id===e.properties.id}))}))}))})))}))),e}),[o,P]);Object(a.useEffect)((function(){void 0!==d&&0!==d.length||(W(!0),D("Please select a cropseason on the Details Tab before selecting a property."),M(!0))}),[]),Object(a.useEffect)((function(){var e=[],t=ie.map((function(e){return e.id})),n=j.cropZones.filter((function(e){return t.includes(e.cropZoneIdValue)}));n.map((function(e){return e.cropZoneIdValue}));ie.forEach((function(t){var a,r=null===(a=n.find((function(e){return e.cropZoneIdValue===t.id})))||void 0===a?void 0:a.areaValue,c=t.reportedArea>0?t.reportedArea:t.boundaryArea,i=r||c,o={farmId:t.farmId,cropZoneIdValue:t.id,areaUnit:"acres",originalAcres:t.areaValue||Math.round(100*(c+Number.EPSILON))/100,areaValue:t.areaValue||Math.round(100*(i+Number.EPSILON))/100,coveragePct:t.coveragePct||Math.round(i/c*1e4)/100,boundaryArea:Math.round(100*(t.boundaryArea+Number.EPSILON))/100,reportedArea:Math.round(100*(t.reportedArea+Number.EPSILON))/100,areaType:t.areaType||"reported",name:t.name,crop:t.crop,features:t.features,fieldName:t.fieldName};e.push(o)})),p("cropZones",[].concat(e)),re([].concat(e))}),[ie,p]);Object(a.useEffect)((function(){te.length!==j.cropZones.length&&f("FFT Changed");var e=j.cropZones.reduce((function(e,t){return e+t.areaValue}),0);p("totalApplied",Math.round(100*(e+Number.EPSILON))/100),p("totalAreaValue",Math.round(100*(e+Number.EPSILON))/100)}),[j.cropZones]),Object(a.useEffect)((function(){p("propertiesGroupBy","property")}),[]);var oe=function(e){A(e),0===e.length&&(p("totalApplied",0),p("totalAreaValue",0),p("coveragePercent",100))},se=function(e){p("area",e),p("estimatedAreaValue",e),h(j.planProductEntries,e).then((function(e){p("planProductEntries",e)})),x(e)};Object(a.useEffect)((function(){if(ae){var e=iF(j.totalApplied,ae);e!==Number(j.coveragePercent)&&!Number.isNaN(e)&&Number.isFinite(e)&&p("coveragePercent",e),!v.estimatedAreaValue&&j.totalApplied>1?se(j.totalApplied):v.estimatedAreaValue||se(1)}}),[j.totalApplied]);return Object(y.jsxs)("div",{className:"-mx-2 -mr-6","data-testid":"properties-tab",children:[Object(y.jsxs)("div",{className:"flex justify-end mb-6",children:[Object(y.jsxs)("div",{className:"mr-6",children:[F?Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){M(!1)},children:R}):null,Object(y.jsx)(Qi,{label:"Total Applied",control:m.Input,name:"totalApplied",disabled:0===j.cropZones.length||0===j.coveragePercent,onBlur:function(e){f("totalApplied");var t=Number(e.target.value);if(p("totalApplied",t),t!==Number(e.target.defaultValue)){var n=iF(t,ae);p("cropZones",Object(tF.a)(n,iF(Number(e.target.defaultValue),ae),j.cropZones)),p("coveragePercent",n)}},imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,scale:2,signed:!1,thousandsSeparator:"",padFractionalZeros:!1,normalizeZeros:!0,radix:".",mapToRadix:[","],min:0}}}})]}),Object(y.jsx)(Qi,{label:"Coverage %",control:m.Input,name:"coveragePercent",disabled:0===j.cropZones.length,onBlur:function(e){f("coveragePercent"),p("coveragePercent",Number(e.target.value)),Number(e.target.value)!==Number(e.target.defaultValue)&&p("cropZones",Object(tF.a)(Number(e.target.value),Number(e.target.defaultValue),j.cropZones))},imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,scale:2,signed:!1,thousandsSeparator:"",padFractionalZeros:!1,normalizeZeros:!1,radix:".",mapToRadix:[","],min:0}}}})]}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"w-1/4 pr-8",children:Object(y.jsxs)("div",{className:"mb-3",children:[Object(y.jsx)("div",{className:"mb-4 text-sm font-semibold uppercase",children:"Properties"}),Object(y.jsx)(m.Form.Field,{label:"Properties"}),s?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Qi,{control:m.Select,name:"propertiesGroupBy",value:N,items:[{key:"property",value:"Group By Property"},{key:"crop",value:"Group By Crop"}],onChange:function(e){!function(e){var t=JSON.parse(e.target.value);E(t.key),p("propertiesGroupBy",t.key)}(e)}}),"property"===N?Object(y.jsx)(Zx,{data:ce,onChange:oe,value:j.cropZones,cropZonesChecked:P,setCropZonesChecked:A,disabled:G}):Object(y.jsx)(Hx,{data:ce,onChange:oe,value:j.cropZones,cropZonesChecked:P,setCropZonesChecked:A,disabled:G})]})]})}),Object(y.jsx)("div",{className:"flex flex-col w-3/4",children:Object(y.jsxs)("div",{className:"flex flex-col h-full",children:[Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsxs)(m.Table.Cell,{width:"30%",children:["Fields (",null===j||void 0===j||null===(r=j.cropZones)||void 0===r?void 0:r.length,")"]}),Object(y.jsx)(m.Table.Cell,{children:"Crops"}),Object(y.jsx)(m.Table.Cell,{children:"Area"}),Object(y.jsx)(m.Table.Cell,{children:"Coverage %"}),Object(y.jsx)(m.Table.Cell,{})]}),null===(c=j.cropZones)||void 0===c?void 0:c.map((function(e){var t,n,a=null!==e&&void 0!==e&&null!==(t=e.features)&&void 0!==t&&t[0]?[Ej(e.features[0])]:void 0,r=-1!==Q.indexOf(e.cropZoneIdValue);return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)(Kp,{id:"field-card-icon",features:a}),Object(y.jsxs)("div",{className:"flex flex-col justify-start leading-5 text-left",children:[Object(y.jsxs)("span",{className:"font-bold text-neutral-1000",children:[null===e||void 0===e?void 0:e.fieldName,r?" (archived) ":""]}),Object(y.jsx)("span",{style:{color:"#707374"},children:null===e||void 0===e?void 0:e.name})]})]})}),Object(y.jsx)(m.Table.Cell,{children:null===e||void 0===e||null===(n=e.crop)||void 0===n?void 0:n.name}),Object(y.jsxs)(m.Table.Cell,{children:[null===e||void 0===e?void 0:e.areaValue," ",null===e||void 0===e?void 0:e.areaUnit]}),Object(y.jsx)(m.Table.Cell,{children:null===e||void 0===e?void 0:e.coveragePct}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(Wo,{onAction:function(t){return function(e,t){({edit:function(){return z(t)},remove:function(){return oe((function(e){return e.filter((function(e){return e!==(null===t||void 0===t?void 0:t.cropZoneIdValue)}))}))}})[e]()}(t,e)},options:ds})})]},"property-row-".concat((null===e||void 0===e?void 0:e.farmId)||Object(cc.generate)()))}))]}),!(null!==j&&void 0!==j&&null!==(i=j.cropZones)&&void 0!==i&&i.length)&&Object(y.jsxs)("div",{className:"flex flex-col items-center self-stretch justify-center h-full py-32 border border-t-0",children:[Object(y.jsx)("img",{src:Of,alt:"No properties illustration"}),Object(y.jsx)("p",{children:"Select one or more fields from the list to add it to this Plan"})]})]})})]}),Object(y.jsx)(y.Fragment,{children:U&&Object(y.jsx)(Zi.c,{name:"cropZones",children:function(e){var t,n=e.replace;return Object(y.jsx)(m.SimpleModal,{confirmLabel:"Save",open:U,onConfirm:function(){n(j.cropZones.map((function(e){return e.cropZoneIdValue})).indexOf(null===U||void 0===U?void 0:U.cropZoneIdValue),U),z(null)},close:function(){return z(null)},children:Object(y.jsxs)("div",{className:"ml-6",children:[Object(y.jsxs)("div",{className:"mb-6",children:[Object(y.jsx)("div",{className:"text-xl font-bold",children:null===U||void 0===U?void 0:U.fieldName}),Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:null===U||void 0===U?void 0:U.name})]}),Object(y.jsxs)("div",{className:"flex mb-6",children:[Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Area"}),Object(y.jsxs)("div",{className:"text-xl",children:[null===U||void 0===U?void 0:U.areaValue," ac"]})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Crop"}),Object(y.jsx)("div",{className:"text-xl ",children:null===U||void 0===U||null===(t=U.crop)||void 0===t?void 0:t.name})]})]}),Object(y.jsx)("div",{className:"mb-12",children:Object(y.jsxs)(Qi,{control:m.RadioButtonGroup,name:"areaReported",selected:null===U||void 0===U?void 0:U.areaType,onChange:function(e){var t="boundary"===e?null===U||void 0===U?void 0:U.boundaryArea:null===U||void 0===U?void 0:U.reportedArea;z(Object(I.a)(Object(I.a)({},U),{},{areaType:e,areaValue:t,coveragePct:iF(t,null===U||void 0===U?void 0:U.originalAcres)}))},children:[Object(y.jsx)(Qi,{value:"reported",id:"reported",name:"areaReported",control:Z,children:Object(y.jsxs)("span",{className:"truncate w-48",children:["Reported Area (",null===U||void 0===U?void 0:U.reportedArea," ac)"]})}),Object(y.jsx)(Qi,{value:"boundary",id:"boundary",name:"areaReported",control:Z,children:Object(y.jsxs)("span",{className:"truncate w-48",children:["Boundary Area (",null===U||void 0===U?void 0:U.boundaryArea," ac)"]})})]})}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(Qi,{label:"Area Applied",control:m.Input,value:null===U||void 0===U?void 0:U.areaValue,onBlur:function(e){var t=Number(e.target.value);z(Object(I.a)(Object(I.a)({},U),{},{areaValue:t,coveragePct:iF(t,null===U||void 0===U?void 0:U.originalAcres)}))},name:"zoneAcres",imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,signed:!1,thousandsSeparator:"",padFractionalZeros:!1,normalizeZeros:!0,radix:".",mapToRadix:[","],min:0}}}})}),Object(y.jsx)(Qi,{label:"Coverage %",control:m.Input,name:"zoneCoveragePercent",value:null===U||void 0===U?void 0:U.coveragePct,onBlur:function(e){var t=Number(e.target.value);z(Object(I.a)(Object(I.a)({},U),{},{coveragePct:t,areaValue:cF(t,null===U||void 0===U?void 0:U.originalAcres)}))},imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,signed:!1,thousandsSeparator:"",padFractionalZeros:!1,normalizeZeros:!1,radix:".",mapToRadix:[","],min:0}}}})]})]})})}})})]})},dF=function(){return Object(y.jsxs)("svg",{width:"166",height:"128",viewBox:"0 0 166 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M74.6387 110.975H91.9899L105.595 127.164H88.2435L74.6387 110.975ZM79.9197 113.438L89.3846 124.701H100.314L90.8487 113.438H79.9197Z",fill:"#73DC78"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.455078 0.491623L34.8691 14.4748H131.131L165.545 0.494863V99.7757L145.062 108.181V127.161H45.0461L33.8786 113.231L0.455078 99.785V0.491623ZM37.1951 113.438L46.2219 124.698H140.465L131.421 113.438L37.1951 113.438ZM133.998 112.721L142.608 123.44V109.189L133.998 112.721ZM130.784 110.975V30.5715L48.7885 30.5715L48.7884 110.973L130.784 110.975ZM46.3335 110.972L46.3336 29.8323L35.8574 18.787V110.972L46.3335 110.972ZM33.4025 16.5363V110.386L2.90995 98.1188V4.14655L33.4025 16.5363ZM37.4925 16.9379L48.0874 28.1084L130.784 28.1084V16.9379H37.4925ZM133.239 16.2759V110.371L163.09 98.1219V4.14948L133.239 16.2759Z",fill:"#00004B"})]})},uF=function(){return Object(y.jsxs)("div",{id:"empty-products-display",className:"w-full h-full mt-24 flex flex-col items-center justify-center",children:[Object(y.jsx)(dF,{}),Object(y.jsx)("span",{className:"mt-6 text-xl",children:"Select a product from the list to add it to this task"})]})},bF=function(e){var t,n=e.removeProduct,r=e.noBlank,c=e.memberRole,i=e.memberFinancialAccess,o=e.setCustomProductCreated,s=e.customProductCreated,l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],f=Object(a.useState)(null),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)({key:"ratearea",value:"ratePerAreaValue",unit:"ratePerAreaUnit",title:"Rate"}),g=Object(b.a)(x,2),C=(g[0],g[1]),P=Object(a.useState)(),A=Object(b.a)(P,1)[0],S=Object(a.useState)(null),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(Zi.h)().values,_=Object(p.j)().id,R=[{key:"totalproduct",value:"totalProductValue",unit:"totalProductUnit",title:"Total Product"},{key:"productcost",value:"productCostValue",unit:"productCostUnit",title:"Product Cost"},{key:"ratearea",value:"ratePerAreaValue",unit:"ratePerAreaUnit",title:"Rate"}];Object(a.useEffect)((function(){C(R.find((function(e){return e.key===w.applicationStrategy})))}),[w.applicationStrategy]),Object(a.useEffect)((function(){var e;if((null===(e=w.planProductEntries)||void 0===e?void 0:e.length)>0){var t=w.planProductEntries.length-1,n=w.planProductEntries[t];n.custom&&s&&(E(n),h("".concat(t)),j(!0),o(!1))}}),[w.planProductEntries,s]);var I=function(){},D=function(){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(m.Table.Cell,{sort:A,onClick:I,children:"Rate/Area"}),Object(y.jsx)(m.Table.Cell,{sort:A,onClick:I,children:"Price"}),Object(y.jsx)(m.Table.Cell,{sort:A,onClick:I,children:"Applied Area"}),Object(y.jsx)(m.Table.Cell,{sort:A,onClick:I,children:"Applied Area %"}),Object(y.jsx)(m.Table.Cell,{sort:A,onClick:I,children:"Total Product"}),Object(y.jsx)(m.Table.Cell,{sort:A,onClick:I,children:"Total Cost"})]})},k=function(){return"Full control"===c&&"none"===i||"Full control"===c&&"READ"===i&&"plan"!==_};return Object(y.jsxs)("div",{className:"mt-8",children:[N&&Object(y.jsx)(pR,{open:u,product:N,onClose:function(){j(!1),E(null)},isEdit:!0,rowIndex:O,memberRole:c,memberFinancialAccess:i}),null!==(t=w.planProductEntries)&&void 0!==t&&t.length?Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{sort:A,onClick:I,children:"Products (".concat(w.planProductEntries.length,")")}),D()]}),w.planProductEntries.map((function(e,t){return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"text-left",children:[Object(y.jsx)("div",{className:"font-bold",children:e.productName}),Object(y.jsx)("div",{className:"mt-2 text-neutral-300",children:e.manufacturerName})]})}),Object(y.jsxs)(m.Table.Cell,{children:[e.productRateValue||"--"," ",Object(va.g)(e.productRateUnit)]}),k()?Object(y.jsx)(m.Table.Cell,{}):Object(y.jsx)(m.Table.Cell,{children:e.specificCostValue?Object(y.jsx)(yf,{roundedTo:2,unit:"usCurrency",children:e.specificCostValue}):Object(y.jsx)("div",{children:"--"})}),Object(y.jsxs)(m.Table.Cell,{children:[e.areaValue||"-- "," ac"]}),Object(y.jsxs)(m.Table.Cell,{children:[e.coveragePercent.toFixed(2)||"-- ","%"]}),Object(y.jsxs)(m.Table.Cell,{children:[e.totalProductValue.toFixed(2)||"--"," ",Object(va.g)(null===e||void 0===e?void 0:e.stdpackageunit)]}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex w-28 items-center justify-around",children:[k()?Object(y.jsx)("div",{className:"ml-2"}):Object(y.jsx)("div",{children:e.totalProductCost?Object(y.jsx)(yf,{roundedTo:2,unit:"usCurrency",children:e.totalProductCost}):Object(y.jsx)("div",{children:"--"})}),Object(y.jsx)("div",{"data-testid":"plan-table-options-menu",children:Object(y.jsx)(Wo,{onAction:function(a){return function(e,t,a){switch(e){case"edit":h(a),E(t),j(!0);break;case"remove":n(a);break;default:j(!1)}}(a,e,t)},options:As})})]})})]},e.trackingId)}))]}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(m.Table,{children:Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{sort:A,onClick:I,children:"Products(0)"}),D()]})}),r?Object(y.jsx)(y.Fragment,{}):Object(y.jsx)(uF,{})]})]})};bF.defaultProps={product:null};var jF,pF=bF,fF=function(e){var t=e.plan,n=e.memberRole,r=e.memberFinancialAccess,c=hR(),i=c.products,o=c.loading,s=Object(Zi.h)(),l=s.values,d=s.setFieldValue,u=s.setFieldTouched,j=Object(a.useState)(null),p=Object(b.a)(j,2),f=p[0],v=(p[1],Object(a.useState)(!0)),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(null===i||void 0===i?void 0:i.slice(0,2)),T=Object(b.a)(S,2),N=T[0],E=T[1],w=function(){var e=[];return i&&N&&i.forEach((function(t){N.findIndex((function(e){return t._id===e._id}))<0&&e.push(t)})),e}();Object(a.useEffect)((function(){E(null===i||void 0===i?void 0:i.slice(0,2))}),[i]);return Object(y.jsx)(y.Fragment,{children:o?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{className:"flex justify-between h-full",children:[h?Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){x(!1)},children:f}):null,Object(y.jsx)("div",{className:"w-3/12 mt-8",children:Object(y.jsx)(OR,{products:w,memberRole:n,memberFinancialAccess:r,setCustomProductCreated:A,productFieldName:"planProductEntries"})}),Object(y.jsx)("div",{className:"ml-4 flex-grow",children:Object(y.jsx)(pF,{className:"mt-8",products:null===t||void 0===t?void 0:t.planProductEntries,removeProduct:function(e){u("deleted product");var t=Object(ne.cloneDeep)(null===l||void 0===l?void 0:l.planProductEntries);t.splice(e,1),E(t),d("planProductEntries",t)},memberRole:n,memberFinancialAccess:r,setCustomProductCreated:A,customProductCreated:P})})]})})},mF=function(e){var t=e.children;return Object(y.jsx)("div",{"data-testid":"tabs-content",className:"h-full",children:t})},vF=Object(a.createContext)({}),OF=["_id","reportedArea","calculatedArea"],hF=["_id","areas","reportedArea","calculatedArea"],xF=function(e,t){var n=function(e){return e.map((function(e){var t,n=e._id,a=e.areas,r=e.reportedArea,c=void 0===r?{}:r,i=e.calculatedArea,o=void 0===i?0:i,s=Object(te.a)(e,hF);return Object(I.a)({id:n,$nestedItems:(t=a,t.map((function(e){var t=e._id,n=e.reportedArea,a=void 0===n?{}:n,r=e.calculatedArea,c=void 0===r?0:r,i=Object(te.a)(e,OF);return Object(I.a)({id:t,acres:a.value?a.value:c},i)}))),acres:c.value?c.value:o},s)}))}(e);return function(e,t){var n=t.name,a=t.id;return[{acres:e.reduce((function(e,t){return e+t.acres}),0),id:a,name:n,$nestedItems:e,$defaultOpen:!0}]}(function(e){return Object.values(e.reduce((function(e,t){if(t.farm){var n=t.farm.tagValue;if(e[n]){var a=e[n];a.$nestedItems.push(t),a.acres+=t.acres}else e[n]={id:t.farm._id,name:n,acres:t.acres,$nestedItems:[t]}}return e}),{}))}(n),t)},gF=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].organization,n=nF(),r=n.fields,c=n.loading,i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1];return Object(a.useEffect)((function(){c||l(xF(r,t))}),[c,t]),s},CF="checked",yF="indeterminate",PF="unchecked",AF=(jF={},Object(et.a)(jF,PF,CF),Object(et.a)(jF,yF,CF),Object(et.a)(jF,CF,PF),jF),SF=function e(t,n,a){var r=n.id,c="undefined"===typeof t[r]?Object(et.a)({},r,PF):Object(et.a)({},r,t[r]);return a&&a.forEach((function(n){c=Object(I.a)(Object(I.a)({},c),e(t,n,n.$nestedItems))})),c},TF=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return t.reduce((function(t,a){var r=a.id,c=a.$nestedItems,i=void 0===c?[]:c;return Object(I.a)(Object(I.a)({},t),{},Object(et.a)({},r,{parentId:n,childrenIds:i.map((function(e){return e.id}))}),i.length?e(i,r):null)}),{})},NF=function(e,t){return e.reduce((function(e,t){return Object(I.a)(Object(I.a)({},e),SF(e,t,t.$nestedItems))}),t)},EF=function e(t,n,a){var r={},c=a[t].childrenIds;return c.length&&(r=c.reduce((function(t,r){return Object(I.a)(Object(I.a)({},t),{},Object(et.a)({},r,n),e(r,n,a))}),{})),r},wF=function(e){return e===CF},_F=function(e){return e===PF},RF=function(e){return e===yF},IF=function e(t,n,a,r,c){var i,o={},s=function(e){return function(e,t,n,a){var r=n[t].childrenIds.filter((function(t){return t!==e}));return!(r.length>0)||r.every((function(e){return _F(a[e])}))}(t,e,a,r)},l=function(e){return function(e,t,n,a){var r=n[t].childrenIds.filter((function(t){return t!==e}));return!(r.length>0)||r.every((function(e){return wF(a[e])}))}(t,e,a,r)},d=function(e){return e?CF:yF},u=function(e){return e?PF:yF},b=a[t].parentId;if(b){var j,p=r[b],f=yF;f=wF(n)&&!RF(c)?u(s(b)):_F(n)&&!RF(c)?d(l(b)):(j={},Object(et.a)(j,CF,(function(){return d(l(b))})),Object(et.a)(j,PF,(function(){return u(s(b))})),Object(et.a)(j,yF,(function(){return yF})),j)[c||yF](),(RF(p)||RF(f))&&(i=f),o=Object(I.a)(Object(et.a)({},b,f),e(b,p,a,r,i))}return o},DF=function(e,t,n){var a=t[e];return Object(I.a)(Object(I.a)({},IF(e,a,n,t)),EF(e,AF[a],n))},kF=function(e){var t=Object(a.useState)({}),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)({}),o=Object(b.a)(i,2),s=o[0],l=o[1];Object(a.useEffect)((function(){c((function(t){return NF(e,t)})),l(TF(e))}),[e,c,l]);return{selectionMap:r,onSelectRow:function(e){var t=r[e],n=DF(e,r,s);c(Object(I.a)(Object(I.a)(Object(I.a)({},r),n),{},Object(et.a)({},e,AF[t])))}}},LF=function e(t,n){var a=n.id,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],c=arguments.length>3?arguments[3]:void 0,i=Object(et.a)({},a,Object(ne.isUndefined)(t[a])?c:t[a]);return r.length&&r.forEach((function(n){i=Object(I.a)(Object(I.a)({},i),e(t,n,n.$nestedItems,c))})),i},FF=function e(t,n){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3?arguments[3]:void 0,c=n.id,i=Object(et.a)({},c,Object(ne.isUndefined)(t[c])?n[r]:t[c]);return a.length&&a.forEach((function(n){i=Object(I.a)(Object(I.a)({},i),e(t,n,n.$nestedItems,r))})),i},MF=function(e){return e.reduce((function(e,t){return Object(I.a)(Object(I.a)({},e),FF(e,t,t.$nestedItems,"acres"))}),{})},VF=function(e,t){var n=Object(Zi.f)("totalSelectedArea"),r=Object(b.a)(n,3),c=r[0],i=r[2],o=c.value,s=i.setValue,l=Object(Zi.f)("coverage"),d=Object(b.a)(l,3),u=d[0].value,j=d[2].setValue,p=Object(a.useState)(!1),f=Object(b.a)(p,2),m=f[0],v=f[1],O=Object(a.useState)(!0),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)({}),y=Object(b.a)(C,2),P=y[0],A=y[1],S=Object(a.useState)({}),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)({}),_=Object(b.a)(w,2),R=_[0],D=_[1],k=Object(a.useState)({}),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Object(a.useState)({}),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=function(e){return t[e]===PF},Y=function(e){return!!U[e]},H=function(e){return!Z(e)&&Y(e)},G=e[0]?e[0].id:null;Object(a.useEffect)((function(){G&&(s(P[G]),j(100))}),[P,G]),Object(a.useEffect)((function(){D(function(e){return e.reduce((function(e,t){return Object(I.a)(Object(I.a)({},e),LF(e,t,t.$nestedItems,0))}),{})}(e)),M(function(e){return e.reduce((function(e,t){return Object(I.a)(Object(I.a)({},e),LF(e,t,t.$nestedItems,0))}),{})}(e)),E(TF(e)),z(MF(e))}),[D,M,E,e]),Object(a.useEffect)((function(){x||A(Object(I.a)({},R))}),[R,x]);var W=function e(t,n,a,r){var c=arguments.length>4&&void 0!==arguments[4]&&arguments[4],i={},o=N[t].parentId;if(o){var s=N[o].childrenIds,l=s.filter((function(e){return(c&&e===t||!Z(e))&&Y(e)})),d=l.map((function(e){return e===t?n:a[e]})),u=r(d,o);i=Object(I.a)(Object(et.a)({},o,u),e(o,u,a,r,c))}return i},q=function e(t,n,a){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],c=N[t].childrenIds,i=c.filter((function(e){return(r||!Z(e))&&Y(t)}));return i.reduce((function(t,c){var o=a(n,i);return Object(I.a)(Object(I.a)({},t),{},Object(et.a)({},c,o),e(c,o,a,r))}),{})},J=function e(t,n){var a="function"===typeof n?n(t):n;return N[t].childrenIds.reduce((function(t,r){return Object(I.a)(Object(I.a)({},t),{},Object(et.a)({},r,a),e(r,n))}),{})},K=function(e,t,n){return J(e,t===CF?n:0)};return{appliedAreaMap:R,applyHeaderCoverage:function(e){g(!0);var t=Object(ne.mapValues)(F,(function(t){return t*e})),n=Object(ne.mapValues)(P,(function(t){return t*e}));M(t),D(n)},baseAppliedAreaMap:P,coverageMap:F,defaultRowAreaFields:function(e){if(v(!0),0!==U[e]){g(!1);var n=AF[t[e]],a=U[e],r=n!==PF?a:0,c=Object(I.a)(Object(I.a)(Object(I.a)({},R),{},Object(et.a)({},e,n!==PF?a:0),W(e,r,R,ne.sum,!0)),K(e,n,(function(e){return U[e]})));D(c);var i=n!==PF?100:0;M(Object(I.a)(Object(I.a)(Object(I.a)({},F),{},Object(et.a)({},e,i),W(e,i,F,(function(e,t){return c[t]/U[t]*100}),!0)),K(e,n,100)))}},headerCoverage:u,rowTouched:m,setHeaderCoverage:j,setRowAppliedArea:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];v(!0),g(n);var a=function(e,t){return e/t.length},r=W(e,t,R,ne.sum),c=q(e,t,a);D(Object(I.a)(Object(I.a)(Object(I.a)(Object(I.a)({},R),r),c),H(e)?Object(et.a)({},e,t):null))},setRowCoverage:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];v(!0),g(n);var a=W(e,t,F,ne.mean),r=q(e,t,ne.identity);M(Object(I.a)(Object(I.a)(Object(I.a)(Object(I.a)({},F),a),r),H(e)?Object(et.a)({},e,t):null))},setTotalSelectedArea:s,totalSelectedArea:o}},BF=function(e){var t=e.children,n=gF(),a=kF(n),r=VF(n,a.selectionMap),c=Object(I.a)(Object(I.a)({landItems:n},a),r);return Object(y.jsx)(vF.Provider,{value:c,children:t})};BF.defaultProps={children:null};var UF=BF,zF=Object(ne.reduce)(EL,(function(e,t,n){return Object(I.a)(Object(I.a)({},e),t.reduce((function(e,t){return Object(I.a)(Object(I.a)({},e),{},Object(et.a)({},t,n))}),{}))}),{}),ZF=function(e){var t=e.onSubmit,n=e.plan,r=e.isSaving,c=e.readOnly,i=e.selectedview,o=e.propertiesSortedData,s=e.selectedCropSeasonIds,l=e.propertiesLoading,d=e.fieldsAndAreasGeoJSONCollection,u=e.reloadData,j=Object(a.useContext)(ac),p=Object(b.a)(j,2)[1],f=Object(a.useState)(null),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)(),g=Object(b.a)(x,2),C=g[0],P=g[1],A=We().user,S=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Jt.fetch(),n=t.promise,e.next=3,n.then((function(e){var t,n=e.data,a=null===n||void 0===n||null===(t=n.members)||void 0===t?void 0:t.filter((function(e){return e.email===A.email}))[0];h(a)})).catch(Ae.default).catch((function(e){uc(p)(e)}));case 3:case"end":return e.stop()}}),e)}))),[p,A.email]);Object(a.useEffect)((function(){O||S(),"Full control"!==(null===O||void 0===O?void 0:O.role)||Object.prototype.hasOwnProperty.call(O,"financialAccess")?P(null===O||void 0===O?void 0:O.financialAccess):P("none")}),[O,S]),Object(a.useEffect)((function(){u()}),[]);var T=Object(a.useState)(0),N=Object(b.a)(T,2),E=N[0],w=N[1],_=function(e){var t,n,a,r,c,i,o;return(Number((null===e||void 0===e||null===(t=e.fixedCost)||void 0===t?void 0:t.equipment_PerAc)||0)+Number((null===e||void 0===e||null===(n=e.fixedCost)||void 0===n?void 0:n.insurance_PerAc)||0)+Number((null===e||void 0===e||null===(a=e.fixedCost)||void 0===a?void 0:a.labor_PerAc)||0)+Number((null===e||void 0===e||null===(r=e.fixedCost)||void 0===r?void 0:r.landRent_PerAc)||0)+Number((null===e||void 0===e||null===(c=e.fixedCost)||void 0===c?void 0:c.repairs_PerAc)||0)+Number((null===e||void 0===e||null===(i=e.fixedCost)||void 0===i?void 0:i.returnToMgt_PerAc)||0)+Number((null===e||void 0===e||null===(o=e.fixedCost)||void 0===o?void 0:o.taxes_PerAc)||0))*(null===e||void 0===e?void 0:e.area)},R=function(e){var t,n,a;return((Number(null===e||void 0===e||null===(t=e.projectedRevenue)||void 0===t?void 0:t.yieldTotal)||0)+(Number(null===e||void 0===e||null===(n=e.projectedRevenue)||void 0===n?void 0:n.fsaPayment)||0))*(Number(null===e||void 0===e||null===(a=e.projectedRevenue)||void 0===a?void 0:a.cropSharePercent)/100||1)},I=function(e){var t;return null===(t=e.planProductEntries)||void 0===t?void 0:t.reduce((function(e,t){return e+t.totalProductCost}),0)},D=function(e){return(R(e)||0)-(_(e)||0)-(I(e)||0)},k=function(e){return((R(e)||0)-(_(e)||0)-(I(e)||0))/(null===e||void 0===e?void 0:e.estimatedAreaValue)},L=function(e){var t=Object.keys(e).shift(),n=zF[t];w(n)};return Object(y.jsx)("div",{"data-testid":"plan-form",className:"h-full flex-1 -mx-4",children:O&&C?Object(y.jsx)(Zi.e,{onSubmit:t,initialValues:n,validationSchema:NL,enableReinitialize:!0,children:function(e){var t=e.errors,a=e.values,u=e.handleChange,b=e.handleBlur,j=e.submitForm,p=e.setFieldValue;return Object(y.jsxs)(UF,{children:[Object(y.jsx)(Sm,{"data-testid":"nav-guard",onValidationError:L}),Object(y.jsx)(DL,{isSaving:r,onSubmit:j,fixedCost:_(a),variableCost:I(a),totalProjectedNetRevenue:D(a),perAcreProjectedNetRevenue:k(a),selectedview:i,values:a,memberRole:null===O||void 0===O?void 0:O.role,memberFinancialAccess:C}),Object(y.jsx)("div",{className:"px-6 pt-4 -mx-4 bg-white",style:{height:"calc(100% - 100px)"},children:Object(y.jsx)(mF,{children:Object(y.jsx)("fieldset",{"data-testid":"plan-fieldset",disabled:c,children:Object(y.jsxs)(m.Tabs,{activeTab:E,children:[Object(y.jsx)(m.Tabs.Tab,{label:"Details",children:Object(y.jsx)(eF,{values:a,errors:t,handleChange:u,handleBlur:b,setFieldValue:p,memberRole:null===O||void 0===O?void 0:O.role,memberFinancialAccess:C})}),Object(y.jsx)(m.Tabs.Tab,{label:"Properties",children:Object(y.jsx)(lF,{errors:t,handleChange:u,handleBlur:b,propertyLandingPageData:o,loading:l,fieldsAndAreasGeoJSONCollection:d,selectedCropSeasonIds:s})}),Object(y.jsx)(m.Tabs.Tab,{label:"Products",children:Object(y.jsx)(fF,{plan:n,values:a,errors:t,handleChange:u,handleBlur:b,setFieldValue:p,memberRole:null===O||void 0===O?void 0:O.role,memberFinancialAccess:C})})]})})})})]})}}):Object(y.jsx)(m.Spinner,{})})};ZF.defaultProps={onSubmit:function(){},plan:{},isSaving:!1,readOnly:!1,selectedview:"",fieldsAndAreasGeoJSONCollection:{}};var YF=ZF,HF=["id"],GF=function(e){var t=Au("plan"),n=Object(a.useContext)(ac),r=Object(b.a)(n,2)[1],c=Object(a.useState)({}),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!0),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(!1),f=Object(b.a)(p,2),m=f[0],v=f[1];Object(a.useEffect)((function(){var n;if("plan"===e)j(!1);else{var a=t.fetch(e),c=a.promise,i=a.cancel;n=i,c.then((function(e){var t=e.data;s(t)})).catch(Ae.default).catch(uc(r)).finally((function(){return j(!1)}))}return function(){return n&&n()}}),[r,e,t]);return{plan:o,loading:u,saving:m,savePlan:function(n,a){if("plan"===e||"edit-dup"===a){var c,i,o=Object(I.a)({},n);return delete o.organizationId,o.cropZones=null===(c=o.cropZones)||void 0===c?void 0:c.map((function(e){e.id;return Object(te.a)(e,HF)})),o.planProductEntries=null===o||void 0===o||null===(i=o.planProductEntries)||void 0===i?void 0:i.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{trackingId:"",productRateValue:e.productRateValue.toString()})})),v(!0),t.create(o).promise.catch(Ae.default).catch(uc(r)).finally((function(){v(!1)}))}return v(!0),t.update(e,n).promise.catch(Ae.default).catch(uc(r)).finally((function(){v(!1)}))},setPlan:s}},WF=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2)[1],n=Object(a.useState)([]),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(!0),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useCallback)((function(){var e=Gt.fetch(),n=e.promise,a=e.cancel;return n.then((function(e){var t=e.data;i(t.results)})).catch(Ae.default).catch((function(e){uc(t)(e)})).finally((function(){return d(!1)})),a}),[t]);return Object(a.useEffect)((function(){var e=u();return function(){e()}}),[u]),{tags:c,loading:l,getTags:u}},qF=function(e){var t=Object(a.useContext)(ac),n=Object(b.a)(t,2)[1],r=Object(a.useState)({}),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(!0),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(!1),p=Object(b.a)(j,2),f=p[0],m=p[1];Object(a.useEffect)((function(){var t;if(!("season"===e)&&e){var a=$t.fetch(e),r=a.promise,c=a.cancel;t=c,r.then((function(e){var t=e.data;o(t)})).catch(Ae.default).catch((function(e){uc(n)(e)})).finally((function(){return u(!1)}))}else u(!1);return function(){return t&&t()}}),[n,e]);return{cropSeason:i,loading:d,saving:f,saveCropSeason:function(t){var a="season"===e;m(!0);var r=t;return(a?$t.create(r):$t.update(e,r)).promise.catch(Ae.default).catch(uc(n)).finally((function(){m(!1)}))}}},JF=function(e){var t=e.cropseasonId,n=qF(t),a=n.cropSeason,r=n.loading;return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Crop Seasons",className:"w-1/3",text:"text-lg"}),r?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)("span",{className:"text-2xl w-1/3",children:(null===a||void 0===a?void 0:a.name)||"--"})]})})},KF=function(e){var t=e.cropId,n=e.cropStyle,r=e.setCrop,c=Du(t),i=c.crops,o=c.loading;return Object(a.useEffect)((function(){i&&r(i)}),[i,r]),Object(y.jsx)(y.Fragment,{children:o?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)("span",{className:n,children:null===i||void 0===i?void 0:i.name})})};KF.defaultProps={setCrop:function(){},cropStyle:""};var QF=KF,XF=function(e){var t=e.plan,n=e.displayTagsObject,a=e.switchingTags,r=t.name,c=t.estimatedAreaValue,i=t.estimatedAreaUnit,o=t.cropId,s=t.cropSeasonIds,l=t.flagIds,d=Object(y.jsx)("span",{className:"text-2xl w-1/3","data-testid":"without-tags",children:"--"});return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Plan Name",className:"w-1/3",text:"text-lg"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:r||"--"})]}),Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Planned Area",className:"w-1/3",text:"text-lg"}),c&&i?Object(y.jsxs)("span",{className:"text-2xl w-1/3",children:[c," ",i]}):d]}),Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Crop",className:"w-1/3",text:"text-lg"}),o?Object(y.jsx)(QF,{cropId:o,cropStyle:"text-2xl w-1/3"}):d]})]}),Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsx)(JF,{cropseasonId:s[0]}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsxs)("div",{"data-testid":"flags",children:[Object(y.jsx)("div",{className:"text-gray-600",children:"Tags"}),a?Object(y.jsx)(m.Spinner,{size:"sm"}):(null===l||void 0===l?void 0:l.length)>0?Object(y.jsx)("div",{className:"text-2xl",children:Object(y.jsx)("div",{className:"mt-1",children:n.extraTagsNames.length>0?Object(y.jsx)(fu,{position:"bottom",ariaLabel:"Task Tags",top:"1.5rem",msg:Object(y.jsx)(Pf,{extraTagsNames:n.extraTagsNames}),component:Object(y.jsx)(Sf,{displayTagsObject:n,isLandingPage:"view",viewKey:ud})}):Object(y.jsx)(Sf,{displayTagsObject:n,isLandingPage:"view",viewKey:ud})})}):d]})})]}),Object(y.jsx)("br",{})]})};XF.defaultProps={switchingTags:!1};var $F=XF,eM=function(e){var t,n,a,r,c,i,o,s,l,d,u,b,j,p,f=e.plan,m=e.displayFinancials,v=function(e,t){var n=t*e;return n>0&&n!==1/0?Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:n})}):0};return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Land Rent",className:"w-1/3",text:"text-lg"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:m&&v(null===f||void 0===f||null===(t=f.fixedCost)||void 0===t?void 0:t.landRent,null===f||void 0===f?void 0:f.estimatedAreaValue)}),Object(y.jsx)("br",{}),m&&Object(y.jsxs)("span",{className:"gr-text-sm",children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===f||void 0===f||null===(n=f.fixedCost)||void 0===n?void 0:n.landRent}),"/",null===f||void 0===f?void 0:f.estimatedAreaUnit]})]}),Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Equipment",className:"w-1/3",text:"text-lg"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:m&&v(null===f||void 0===f||null===(a=f.fixedCost)||void 0===a?void 0:a.equipment,null===f||void 0===f?void 0:f.estimatedAreaValue)}),Object(y.jsx)("br",{}),m&&Object(y.jsxs)("span",{className:"gr-text-sm",children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===f||void 0===f||null===(r=f.fixedCost)||void 0===r?void 0:r.equipment}),"/",null===f||void 0===f?void 0:f.estimatedAreaUnit]})]}),Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Labor",className:"w-1/3",text:"text-lg"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:m&&v(null===f||void 0===f||null===(c=f.fixedCost)||void 0===c?void 0:c.labor,null===f||void 0===f?void 0:f.estimatedAreaValue)}),Object(y.jsx)("br",{}),m&&Object(y.jsxs)("span",{className:"gr-text-sm",children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===f||void 0===f||null===(i=f.fixedCost)||void 0===i?void 0:i.labor}),"/",null===f||void 0===f?void 0:f.estimatedAreaUnit]})]})]}),Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Repairs",className:"w-1/3",text:"text-lg"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:m&&v(null===f||void 0===f||null===(o=f.fixedCost)||void 0===o?void 0:o.repairs,null===f||void 0===f?void 0:f.estimatedAreaValue)}),Object(y.jsx)("br",{}),m&&Object(y.jsxs)("span",{className:"gr-text-sm",children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===f||void 0===f||null===(s=f.fixedCost)||void 0===s?void 0:s.repairs}),"/",null===f||void 0===f?void 0:f.estimatedAreaUnit]})]}),Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Taxes",className:"w-1/3",text:"text-lg"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:m&&v(null===f||void 0===f||null===(l=f.fixedCost)||void 0===l?void 0:l.taxes,null===f||void 0===f?void 0:f.estimatedAreaValue)}),Object(y.jsx)("br",{}),m&&Object(y.jsxs)("span",{className:"gr-text-sm",children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===f||void 0===f||null===(d=f.fixedCost)||void 0===d?void 0:d.taxes}),"/",null===f||void 0===f?void 0:f.estimatedAreaUnit]})]}),Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Insurance",className:"w-1/3",text:"text-lg"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:m&&v(null===f||void 0===f||null===(u=f.fixedCost)||void 0===u?void 0:u.insurance,null===f||void 0===f?void 0:f.estimatedAreaValue)}),Object(y.jsx)("br",{}),m&&Object(y.jsxs)("span",{className:"gr-text-sm",children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===f||void 0===f||null===(b=f.fixedCost)||void 0===b?void 0:b.insurance}),"/",null===f||void 0===f?void 0:f.estimatedAreaUnit]})]})]}),Object(y.jsx)("div",{className:"flex py-5",children:Object(y.jsxs)("div",{className:"w-1/2",children:[Object(y.jsx)(Fl,{header:"Return to Managment",className:"w-1/3",text:"text-lg"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:m&&v(null===f||void 0===f||null===(j=f.fixedCost)||void 0===j?void 0:j.returnToMgt,null===f||void 0===f?void 0:f.estimatedAreaValue)}),Object(y.jsx)("br",{}),m&&Object(y.jsxs)("span",{className:"gr-text-sm",children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===f||void 0===f||null===(p=f.fixedCost)||void 0===p?void 0:p.returnToMgt}),"/",null===f||void 0===f?void 0:f.estimatedAreaUnit]})]})})]})};eM.defaultProps={displayFinancials:!0};var tM=eM,nM=function(e){var t,n,a,r,c=e.plan,i=e.displayFinancials;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Yield Total",className:"w-1/3",text:"text-lg"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:i&&Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:dL(c)})}),Object(y.jsx)("br",{}),i&&Object(y.jsxs)("span",{className:"gr-text-sm",children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:uL(c)}),"/",null===c||void 0===c?void 0:c.estimatedAreaUnit]})]}),Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Price per Unit",className:"w-1/2",text:"text-lg"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:i&&Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===c||void 0===c||null===(t=c.projectedRevenue)||void 0===t?void 0:t.pricePerUnit})}),Object(y.jsx)("br",{})]})]}),Object(y.jsxs)("div",{className:"flex py-5",children:[Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"FSA Payment",className:"w-1/3",text:"text-lg"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:i&&Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===c||void 0===c||null===(n=c.projectedRevenue)||void 0===n?void 0:n.fsaPayment})}),Object(y.jsx)("br",{}),i&&Object(y.jsxs)("span",{className:"gr-text-sm",children:[function(e,t){var n=t/e;return n>0&&n!==1/0?Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:n})}):0}(null===c||void 0===c?void 0:c.estimatedAreaValue,null===c||void 0===c||null===(a=c.projectedRevenue)||void 0===a?void 0:a.fsaPayment),"/",null===c||void 0===c?void 0:c.estimatedAreaUnit]})]}),Object(y.jsxs)("div",{className:"w-1/3",children:[Object(y.jsx)(Fl,{header:"Crop Share",className:"w-1/2",text:"text-lg"}),i&&Object(y.jsxs)("span",{className:"text-2xl w-1/3",children:[100*(null===c||void 0===c||null===(r=c.projectedRevenue)||void 0===r?void 0:r.cropSharePercent),"%"]}),Object(y.jsx)("br",{})]})]})]})};nM.defaultProps={displayFinancials:!0};var aM=nM,rM=function(e){var t=e.variableCost,n=e.fixedCost,a=e.totalProjectedNetRevenue,r=e.perAcreProjectedNetRevenue,c=e.displayByFinancialAccess;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex flex-col mr-4",children:[Object(y.jsx)("div",{className:"text-neutral-300 opacity-60",children:"Variable Cost"}),Object(y.jsx)("div",{"data-testid":"variable-cost",className:"text-neutral-300",children:c&&Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:t})})})]}),Object(y.jsxs)("div",{className:"flex flex-col mr-4",children:[Object(y.jsx)("div",{className:"text-neutral-300 opacity-60",children:"Fixed Cost"}),Object(y.jsx)("div",{"data-testid":"variable-cost",className:"text-neutral-300",children:c&&Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:n})})})]}),Object(y.jsxs)("div",{className:"flex flex-col mr-4",children:[Object(y.jsx)("div",{className:"text-neutral-300 opacity-60",children:"Proj. Net Revenue"}),Object(y.jsx)("div",{"data-testid":"net-revenue",className:"text-neutral-300",children:c&&Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:a})})})]}),Object(y.jsxs)("div",{className:"flex flex-col mr-4",children:[Object(y.jsx)("div",{className:"text-neutral-300 opacity-60",children:"Proj. Net Revenue Per Area"}),Object(y.jsx)("div",{"data-testid":"net-revenue-per-acre",className:"text-neutral-300",children:isFinite(r)&&c&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:r})," ","per Acre"]})})]})]})},cM=function(e){var t=e.fixedCost,n=e.variableCost,a=e.totalProjectedNetRevenue,r=e.perAcreProjectedNetRevenue,c=e.onAction,i=e.displayByFinancialAccess,o=e.processing;return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)("div",{className:"w-full",children:Object(y.jsxs)(m.Columns,{children:[Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsx)("div",{className:"flex justify-left ml-4",children:Object(y.jsx)(rM,{fixedCost:t||0,variableCost:n||0,totalProjectedNetRevenue:a||0,perAcreProjectedNetRevenue:r||0,displayByFinancialAccess:i})})}),Object(y.jsx)(m.Column,{children:Object(y.jsx)("div",{className:"flex justify-end mr-6","data-html2canvas-ignore":!0,children:o?Object(y.jsx)(m.Spinner,{size:"sm"}):Object(y.jsx)(Wo,{onAction:c,options:Ss})})})]})})})};cM.defaultProps={variableCost:null,processing:!1,loggedInUserOrgPermission:void 0};var iM=Object(p.l)(cM),oM=function(e){var t=e.open,n=e.onClose,a=e.property;return Object(y.jsx)(m.SimpleModal,{open:t,close:n,onConfirm:n,size:"sm",children:Object(y.jsxs)("div",{className:"ml-6",children:[Object(y.jsxs)("div",{className:"mb-6",children:[Object(y.jsx)("div",{className:"text-xl font-bold",children:null===a||void 0===a?void 0:a.fieldName}),Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:null===a||void 0===a?void 0:a.cropZoneName})]}),Object(y.jsxs)("div",{className:"flex mb-6",children:[Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Area"}),Object(y.jsxs)("div",{className:"text-xl",children:[null===a||void 0===a?void 0:a.areaValue," ac"]})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Crop"}),Object(y.jsx)("div",{className:"text-xl ",children:null===a||void 0===a?void 0:a.cropName})]})]}),Object(y.jsx)("div",{className:"mb-12",children:Object(y.jsxs)(m.RadioButtonGroup,{children:[Object(y.jsxs)(m.RadioButtonGroup.RadioButton,{disabled:!0,selected:!0,children:["Reported Area (",function(e){return e&&0!==e?"".concat(e," ac"):" "}(a.reportedArea),")"]}),Object(y.jsxs)(m.RadioButtonGroup.RadioButton,{disabled:!0,children:["Boundary Area (",a.boundaryArea," ac)"]})]})}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(m.Input,{disabled:!0,label:"Applied Area",value:"".concat(a.areaValue," ac")})}),Object(y.jsx)(m.Input,{disabled:!0,label:"Coverage %",value:"".concat(a.coveragePercent,"%")})]})]})})};oM.defaultProps={open:!1,onClose:function(){}};var sM=oM,lM=function(e){var t=e.property,n=rv({fetchType:xm}),r=n.dataSorted,c=n.fieldsAndAreasGeoJSONCollection,i=n.fieldsLoading,o=n.reloadData,s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(),p=Object(b.a)(j,2),f=p[0],v=p[1],O=Object(a.useState)(),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)([]),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Ov(f).cropZone,R=Pv(x).field;Object(a.useEffect)((function(){if(!i){var e=Fh(null===r||void 0===r?void 0:r.properties);S(e)}}),[i,r.properties]);var I=function(e,t){if(e&&t.length>0){var n=null===t||void 0===t?void 0:t.find((function(t){return(null===t||void 0===t?void 0:t.id)===(null===e||void 0===e?void 0:e.cropZoneIdValue)}));return 0===(null===n||void 0===n?void 0:n.reportedArea)?Math.round(100*((null===e||void 0===e?void 0:e.areaValue)/(null===n||void 0===n?void 0:n.boundaryArea)+Number.EPSILON)):Math.round(100*((null===e||void 0===e?void 0:e.areaValue)/(null===n||void 0===n?void 0:n.reportedArea)+Number.EPSILON))}return!1};return Object(a.useEffect)((function(){v(null===t||void 0===t?void 0:t.cropZoneIdValue)}),[t]),Object(a.useEffect)((function(){R||g(null===_||void 0===_?void 0:_.fieldId)}),[R,_]),Object(a.useEffect)((function(){o()}),[]),R&&_&&!i?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(sM,{open:d,onClose:function(){u(!1)},property:{cropZoneName:null===_||void 0===_?void 0:_.name,cropName:null===E||void 0===E?void 0:E.name,fieldName:null===R||void 0===R?void 0:R.name,areaValue:null===t||void 0===t?void 0:t.areaValue,areaUnit:null===t||void 0===t?void 0:t.areaUnit,boundaryArea:Math.round(100*((null===_||void 0===_?void 0:_.boundaryArea)+Number.EPSILON))/100,reportedArea:Math.round(100*((null===_||void 0===_?void 0:_.reportedArea)+Number.EPSILON))/100,coveragePercent:I(t,A)||""}}),Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{width:"5rem",children:Object(y.jsx)(Kp,{id:"view-plan-card-icon",features:function(){if(c.features.length>0){var e=[];return c.features.forEach((function(n){t.cropZoneIdValue===n.properties.id&&e.push(Ej(n))})),e}return""}()})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex flex-col justify-start leading-5 text-left",children:[Object(y.jsx)("span",{className:"font-bold text-neutral-1000",children:null===R||void 0===R?void 0:R.name}),Object(y.jsx)("span",{style:{color:"#707374"},children:null===_||void 0===_?void 0:_.name})]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(QF,{cropId:_.cropId,setCrop:w})}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:2,children:null===t||void 0===t?void 0:t.areaValue})," ac"]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsxs)("div",{className:"mr-6",children:[I(t,A)," %"]}),Object(y.jsx)("div",{"data-testid":"product-table-view-button",className:"mr-8 absolute right-0 flex-none w-10","data-html2canvas-ignore":!0,children:Object(y.jsx)(m.Button,{type:"link-default",onClick:function(){return u(!0)},children:"View"})})]})]})]}):Object(y.jsx)(m.Spinner,{})},dM=function(e){var t=e.cropZones,n=function(){},a={};return Object(y.jsx)(y.Fragment,{children:t?Object(y.jsx)("div",{className:"flex-grow",children:Object(y.jsx)("div",{className:"flex flex-col h-full justify-end",children:Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{}),Object(y.jsx)(m.Table.Cell,{sort:a,onClick:n,children:"Fields (".concat(null===t||void 0===t?void 0:t.length,")")}),Object(y.jsx)(m.Table.Cell,{sort:a,onClick:n,children:"Crops"}),Object(y.jsx)(m.Table.Cell,{sort:a,onClick:n,children:"Area"}),Object(y.jsx)(m.Table.Cell,{sort:a,onClick:n,children:"Coverage %"})]}),t.map((function(e){return Object(y.jsx)(lM,{property:e},null===e||void 0===e?void 0:e.cropZoneIdValue)}))]})})}):Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{sort:a,onClick:n,children:"Fields (0)"}),Object(y.jsx)(m.Table.Cell,{sort:a,onClick:n,children:"Crops"}),Object(y.jsx)(m.Table.Cell,{sort:a,onClick:n,children:"Area"}),Object(y.jsx)(m.Table.Cell,{sort:a,onClick:n,children:"Coverage %"})]}),Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsx)("div",{className:"flex flex-col justify-start leading-5 text-left",children:Object(y.jsx)("span",{className:"font-bold text-neutral-1000",children:"No Properties Selected"})})}),Object(y.jsx)(m.Table.Cell,{}),Object(y.jsx)(m.Table.Cell,{}),Object(y.jsx)(m.Table.Cell,{})]})]})})})};dM.defaultProps={cropZones:[]};var uM=dM,bM=function(e){var t=e.products,n=e.displayFinancials,a=e.handleProductModal,r=function(){},c={};return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{sort:c,onClick:r,children:"Products (".concat(t.length,")")}),Object(y.jsx)(m.Table.Cell,{sort:c,onClick:r,children:"Rate/Area"}),Object(y.jsx)(m.Table.Cell,{sort:c,onClick:r,children:"Applied Area"}),Object(y.jsx)(m.Table.Cell,{sort:c,onClick:r,children:"Applied Area %"}),Object(y.jsx)(m.Table.Cell,{sort:c,onClick:r,children:"Total Product"}),Object(y.jsx)(m.Table.Cell,{sort:c,onClick:r,children:"Total Cost"})]}),t.map((function(e,t){var r;return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"text-left",children:[Object(y.jsx)("div",{className:"font-bold",children:(null===e||void 0===e?void 0:e.productName)||"No Products Selected"}),Object(y.jsx)("div",{className:"mt-2 text-neutral-300",children:(null===e||void 0===e?void 0:e.manufacturerName)||"--"})]})}),Object(y.jsx)(m.Table.Cell,{children:xR(null===e||void 0===e?void 0:e.productRateValue,Object(va.g)(null===e||void 0===e?void 0:e.productRateUnit))}),Object(y.jsxs)(m.Table.Cell,{children:[(null===e||void 0===e?void 0:e.areaValue)||"0"," ac"]}),Object(y.jsxs)(m.Table.Cell,{children:[100*(null===e||void 0===e?void 0:e.coveragePercent),"%"]}),Object(y.jsx)(m.Table.Cell,{children:xR(null===e||void 0===e?void 0:e.totalProductValue,Object(va.g)(null===e||void 0===e?void 0:e.specificCostUnit))}),Object(y.jsxs)(m.Table.Cell,{children:[n&&null!==e&&void 0!==e&&e.totalProductCost?Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===e||void 0===e?void 0:e.totalProductCost}):"",Object(y.jsx)("div",{"data-testid":"product-table-view-button",className:"mr-8 absolute right-0 flex-none w-10","data-html2canvas-ignore":!0,children:Object(y.jsx)(m.Button,{type:"link-default",onClick:function(){a(e)},children:"View"})})]})]},null!==(r=null===e||void 0===e?void 0:e.id)&&void 0!==r?r:"product-row-".concat(t))}))]})})},jM=function(e){var t=e.open,n=e.handleClose,a=e.product,r=e.displayFinancial;return Object(y.jsxs)(m.SimpleModal,{close:n,onConfirm:n,open:t,children:[Object(y.jsxs)("div",{className:"mb-6",children:[Object(y.jsx)("div",{className:"flex w-full justify-between",children:Object(y.jsx)("div",{className:"text-xl font-bold",children:null===a||void 0===a?void 0:a.productName})}),Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:null===a||void 0===a?void 0:a.manufacturerName})]}),Object(y.jsxs)("div",{className:"flex mb-6",children:[Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Total Product"}),r&&Object(y.jsx)("div",{children:Object(y.jsxs)("div",{className:"text-xl",children:[Object(y.jsx)(yf,{roundedTo:2,children:null===a||void 0===a?void 0:a.totalProductValue})," ",null===a||void 0===a?void 0:a.specificCostUnit,(null===a||void 0===a?void 0:a.specificCostUnit)>1?"s":""]})})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Product Cost"}),r&&Object(y.jsx)("div",{className:"text-xl ",children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null===a||void 0===a?void 0:a.totalProductCost})})]})]}),Object(y.jsx)("br",{}),Object(y.jsx)("br",{}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(m.Input,{disabled:!0,className:"w-1/4",label:"Rate",id:"rate",value:null===a||void 0===a?void 0:a.productRateValue})}),Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(m.Input,{style:{whiteSpace:"nowrap"},disabled:!0,className:"w-1/4",label:"Unit",id:"unit",value:null===a||void 0===a?void 0:a.productRateUnit})}),Object(y.jsx)(m.Input,{disabled:!0,className:"w-1/4",label:"Price/Unit",id:"priceUnit",value:r?function(){var e="";return e+="$",e+=null===a||void 0===a?void 0:a.specificCostValue,e+="/",e+=null===a||void 0===a?void 0:a.totalProductUnit}():""})]}),Object(y.jsx)("br",{}),Object(y.jsx)("br",{}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(m.Input,{disabled:!0,className:"w-1/4",label:"Applied Area",id:"appliedArea",value:function(){var e="";return e+=null===a||void 0===a?void 0:a.areaValue,e+=" ac"}()})}),Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(m.Input,{disabled:!0,className:"w-1/4",label:"Applied Area %",id:"appliedAreaPercent",value:"".concat(100*(null===a||void 0===a?void 0:a.coveragePercent),"%")})}),Object(y.jsx)(m.Input,{disabled:!0,className:"w-1/4",label:"# of Applications",id:"numOfApps",value:null===a||void 0===a?void 0:a.applicationCount})]}),Object(y.jsx)("br",{}),Object(y.jsx)("br",{}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(m.Input,{disabled:!0,className:"w-1/4",label:"Timing",id:"timing",value:null===a||void 0===a?void 0:a.timingEvent})}),Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(m.Input,{disabled:!0,className:"w-1/4",label:"Timing Tag",id:"timingTag",value:null===a||void 0===a?void 0:a.timingEventTag})}),Object(y.jsx)(m.Input,{disabled:!0,className:"w-1/4",label:"Target Date",id:"targetDate",value:null===a||void 0===a?void 0:a.targetDate}),Object(y.jsx)("br",{}),Object(y.jsx)("br",{})]})]})};jM.defaultProps={product:null};var pM=jM,fM=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2),n=t[0].loggedInUserOrgPermission,r=t[1],c=Object(p.j)().id,i=GF(c),o=i.plan,s=i.loading,l=i.setPlan,d=vL(o),u=d.handleAction,j=d.currentOpenModal,f=d.setCurrentOpenModal,v=d.downloadingPDF,O=d.setLoadingTags,h=d.loadingTags,x=Object(a.useState)(),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)([]),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Au("plan"),w=Object(a.useState)(null),_=Object(b.a)(w,2)[1],R=WF().tags,D=Object(a.useState)(T||[]),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)({extraTagsCount:0,extraTagsNames:[],tagsToDisplay:[]}),V=Object(b.a)(M,2),B=V[0],U=V[1];Object(a.useEffect)((function(){var e;if((null===R||void 0===R?void 0:R.length)>0&&(null===o||void 0===o||null===(e=o.flagIds)||void 0===e?void 0:e.length)>0){var t=null===R||void 0===R?void 0:R.filter((function(e){var t;return null===o||void 0===o||null===(t=o.flagIds)||void 0===t?void 0:t.find((function(t){return e.id===t}))}));F(t)}else F(T||[])}),[R,o.flagIds]),Object(a.useEffect)((function(){F(T||[])}),[T]),Object(a.useEffect)((function(){U(Af(L,30))}),[L]);var z=function(){f(null)},Z=function(){return or(n,{minAllowedRole:"View Only",minFinancialAccess:"READ"})};return Object(y.jsx)(y.Fragment,{children:s?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{id:"plan-view",children:[Object(y.jsx)(l_,{open:"tag"===j,close:z,name:o.name,selectedTags:null===L||void 0===L?void 0:L.reduce((function(e,t){return"".concat(e,",").concat(t.id)}),""),returnSelectedTags:function(e){O(!0);var t=Object(I.a)(Object(I.a)({},o),{},{flagIds:(null===e||void 0===e?void 0:e.map((function(e){return e.id})))||[]});E.update(o.id,t).promise.then((function(t){var n=t.data;N(e||[]),l(n)})).catch(Ae.default).catch((function(e){var t,n,a,c;null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.validationErrors?_("Error saving task: ".concat(e.response.data.message)):null!==(a=e.response)&&void 0!==a&&null!==(c=a.data)&&void 0!==c&&c.displayErrorMessage?_(e.response.data.displayErrorMessage):uc(r)(e)})).finally((function(){return O(!1)}))}}),Object(y.jsx)(Yk,{open:"convertToTask"===j,close:z,currentPlan:o}),Object(y.jsx)(Kk,{open:"convertToRec"===j,close:z,currentPlan:o}),Object(y.jsx)(pM,{open:"product"===j,product:C,handleClose:z,displayFinancial:Z()}),Object(y.jsx)(xL,{open:"delete"===j,close:z,planName:null===o||void 0===o?void 0:o.name,planId:null===o||void 0===o?void 0:o.id}),Object(y.jsxs)(lo,{disabled:!0,children:[Object(y.jsx)(lo.Item,{title:"Plans",value:"All Plans",to:Cc.plans}),Object(y.jsx)(lo.Item,{title:"Plan",value:o.name||"View Plan",isLast:!0})]}),Object(y.jsx)("div",{className:"flex",children:Object(y.jsx)(iM,{onAction:function(e){return u(e,o.id)},fixedCost:lL(o),variableCost:bL(o),totalProjectedNetRevenue:jL(o),perAcreProjectedNetRevenue:pL(o),displayByFinancialAccess:Z(),processing:v})}),Object(y.jsxs)(ll,{children:[Object(y.jsx)("div",{className:"flex py-5",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold",children:"Plan Details"})})}),Object(y.jsx)($F,{plan:o,displayTagsObject:B,switchingTags:h}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]})}),Object(y.jsx)("div",{className:"py-5",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold",children:"Fixed Cost"})})}),Object(y.jsx)(tM,{plan:o,displayFinancials:Z()}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]})}),Object(y.jsx)("div",{className:"py-5",id:"pagebreaker-1",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold",children:"Projected Revenue"})})}),Object(y.jsx)(aM,{plan:o,displayFinancials:Z()}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]})}),Object(y.jsx)("div",{className:"py-5",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsxs)(m.Column,{width:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold",children:"Properties"}),Object(y.jsx)("br",{})]})}),Object(y.jsx)(uM,{cropZones:o.cropZones}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]})}),Object(y.jsx)("div",{className:"py-5",id:"pagebreaker-2",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsxs)(m.Column,{width:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold",children:"Products & Services"}),Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-sm",children:"By Rate Application"}),Object(y.jsx)("br",{})]})}),Object(y.jsx)(bM,{products:o.planProductEntries,handleProductModal:function(e){P(e),f("product")},displayFinancials:Z()}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]})}),Object(y.jsx)("div",{className:"py-5",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsxs)(m.Column,{width:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold",children:"Notes"}),Object(y.jsx)("br",{})]})}),Object(y.jsx)(m.TextArea,{"data-testid":"plan-notes",className:"h-64 overscroll-auto",resizeDisabled:!0,disabled:!0,value:o.notes}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]})})]})]})})},mM=["notes"],vM=function(){var e,t=Object(p.i)(),n=null===t||void 0===t||null===(e=t.state)||void 0===e?void 0:e.selectedView,r=Object(a.useState)(null),c=Object(b.a)(r,2),i=(c[0],c[1]),o=Object(a.useState)(!1),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(p.j)(),j=u.id,f=u.view,v=GF(j),O=v.plan,h=v.loading,x=v.saving,g=v.savePlan,C=dd().cropSeasons,P=Object(p.h)(),A=null===O||void 0===O?void 0:O.name,S=n,T=Object(a.useContext)(we);"edit-dup"===S&&(A="");var N=Object(a.useState)(null),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(!0),D=Object(b.a)(R,2),k=D[0],L=D[1],F=Object(a.useState)(JSON.parse(localStorage.getItem("selectedCropSeasons"))||null),M=Object(b.a)(F,2),V=M[0],B=M[1],U=rv({fetchType:xm}),z=U.dataSorted,Z=U.loading,H=U.fieldsAndAreasGeoJSONCollection,W=U.reloadData;Object(a.useEffect)((function(){var e,t,n,a,r,c,i,o,s,d,u,b,p,f,m,v,x,g,C,y,P,S,T,N,E,w;!h&&O&&V&&k&&(_(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:wL;return Object(I.a)(Object(I.a)({},e),{},{_planMeta:t})}(Object(I.a)(Object(I.a)({},l&&"plan"!==j&&{id:j}),{},{crops:(null===O||void 0===O||null===(e=O.name)||void 0===e?void 0:e.crops)||"none",productApplications:(null===O||void 0===O||null===(t=O.name)||void 0===t?void 0:t.productApplications)||[],revenue:(null===O||void 0===O||null===(n=O.name)||void 0===n?void 0:n.revenue)||{cropShare:100,salePricePerUnit:0,yieldPerArea:0,fsaPayment:0},costs:(null===O||void 0===O||null===(a=O.name)||void 0===a?void 0:a.costs)||Sk.map((function(e){return{costType:null===e||void 0===e?void 0:e.type,costValue:0,costStructure:"total"}})),totalSelectedArea:0,coverage:0,yield:wk(O),name:A,estimatedAreaUnit:(null===O||void 0===O?void 0:O.estimatedAreaUnit)||"acre",estimatedAreaValue:(null===O||void 0===O?void 0:O.estimatedAreaValue)||1,fixedCost:{landRent:(null===O||void 0===O||null===(r=O.fixedCost)||void 0===r?void 0:r.landRent)*(null===O||void 0===O?void 0:O.estimatedAreaValue),landRent_PerAc:null===O||void 0===O||null===(c=O.fixedCost)||void 0===c?void 0:c.landRent,equipment:(null===O||void 0===O||null===(i=O.fixedCost)||void 0===i?void 0:i.equipment)*(null===O||void 0===O?void 0:O.estimatedAreaValue),equipment_PerAc:null===O||void 0===O||null===(o=O.fixedCost)||void 0===o?void 0:o.equipment,insurance:(null===O||void 0===O||null===(s=O.fixedCost)||void 0===s?void 0:s.insurance)*(null===O||void 0===O?void 0:O.estimatedAreaValue),insurance_PerAc:null===O||void 0===O||null===(d=O.fixedCost)||void 0===d?void 0:d.insurance,labor:(null===O||void 0===O||null===(u=O.fixedCost)||void 0===u?void 0:u.labor)*(null===O||void 0===O?void 0:O.estimatedAreaValue),labor_PerAc:null===O||void 0===O||null===(b=O.fixedCost)||void 0===b?void 0:b.labor,repairs:(null===O||void 0===O||null===(p=O.fixedCost)||void 0===p?void 0:p.repairs)*(null===O||void 0===O?void 0:O.estimatedAreaValue),repairs_PerAc:null===O||void 0===O||null===(f=O.fixedCost)||void 0===f?void 0:f.repairs,taxes:(null===O||void 0===O||null===(m=O.fixedCost)||void 0===m?void 0:m.taxes)*(null===O||void 0===O?void 0:O.estimatedAreaValue),taxes_PerAc:null===O||void 0===O||null===(v=O.fixedCost)||void 0===v?void 0:v.taxes,returnToMgt:(null===O||void 0===O||null===(x=O.fixedCost)||void 0===x?void 0:x.returnToMgt)*(null===O||void 0===O?void 0:O.estimatedAreaValue),returnToMgt_PerAc:null===O||void 0===O||null===(g=O.fixedCost)||void 0===g?void 0:g.returnToMgt},projectedRevenue:{yieldPerArea:null===O||void 0===O||null===(C=O.projectedRevenue)||void 0===C?void 0:C.yieldPerArea,fsaPayment:null===O||void 0===O||null===(y=O.projectedRevenue)||void 0===y?void 0:y.fsaPayment,yieldTotal:(null===O||void 0===O||null===(P=O.projectedRevenue)||void 0===P?void 0:P.yieldPerArea)*(null===O||void 0===O?void 0:O.estimatedAreaValue)*(null===O||void 0===O||null===(S=O.projectedRevenue)||void 0===S?void 0:S.pricePerUnit),fsaPaymentPerAc:(null===O||void 0===O||null===(T=O.projectedRevenue)||void 0===T?void 0:T.fsaPayment)/(null===O||void 0===O?void 0:O.estimatedAreaValue),cropSharePercent:100*(null===O||void 0===O||null===(N=O.projectedRevenue)||void 0===N?void 0:N.cropSharePercent)||100,pricePerUnit:null===O||void 0===O||null===(E=O.projectedRevenue)||void 0===E?void 0:E.pricePerUnit},notes:null===O||void 0===O?void 0:O.notes,cropSeasonIds:(null===O||void 0===O?void 0:O.cropSeasonIds)||V,flagIds:null===O||void 0===O?void 0:O.flagIds,planProductEntries:(w=(null===O||void 0===O?void 0:O.planProductEntries)||[],null===w||void 0===w?void 0:w.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{coveragePercent:100*Number.parseFloat(e.coveragePercent)})}))),cropZones:(null===O||void 0===O?void 0:O.cropZones)||[],cropId:null===O||void 0===O?void 0:O.cropId,currency:(null===O||void 0===O?void 0:O.currency)||"USD",totalApplied:(null===O||void 0===O?void 0:O.totalApplied)||0,totalAreaValue:(null===O||void 0===O?void 0:O.totalAreaValue)||0,coveragePercent:(null===O||void 0===O?void 0:O.coveragePercent)||100,propertiesGroupBy:"property"}))),L(!1))}),[h,O,l,j,A,V,k]);var q=function(e){return C.filter((function(t){return t.cropZoneIds.includes(e)&&V.includes(t.id)}))},J=function(e){var t,n=[];return null===e||void 0===e||null===(t=e.cropZones)||void 0===t||t.forEach((function(e){n.push({id:(null===e||void 0===e?void 0:e.id)||"",cropSeasonId:q(e.cropZoneIdValue)[0].id||"",cropZoneIdValue:(null===e||void 0===e?void 0:e.cropZoneIdValue)||"",areaValue:(null===e||void 0===e?void 0:e.areaValue)||0,areaUnit:(null===e||void 0===e?void 0:e.areaUnit)||"acre"})})),n},K=function(e){var t,n,a,r,c,i,o,s,d,u,b,p,f,m,v="",h=Object(ne.cloneDeep)(e),x=null===h||void 0===h||null===(t=h.planProductEntries)||void 0===t?void 0:t.map((function(e){var t=e;return null===t||void 0===t||delete t.stdpackageunit,null===t||void 0===t||delete t.stdunit,null===t||void 0===t||delete t.stdfactor,null===t||void 0===t||delete t.density,delete t.productName,delete t.shareOwnerInformation,t.coveragePercent=Number.parseFloat(e.coveragePercent)/100,t}));void 0===(null===e||void 0===e||null===(n=e.cropId)||void 0===n?void 0:n.$id)?v=e.cropId:v=null===e||void 0===e||null===(m=e.cropId)||void 0===m?void 0:m.$id;return Object(I.a)(Object(I.a)({},l&&"plan"!==j&&{id:j}),{},{name:(null===e||void 0===e?void 0:e.name)||"",estimatedAreaUnit:(null===e||void 0===e?void 0:e.estimatedAreaUnit)||"acre",estimatedAreaValue:(null===e||void 0===e?void 0:e.estimatedAreaValue)||1,fixedCost:{landRent:Ek((null===e||void 0===e||null===(a=e.fixedCost)||void 0===a?void 0:a.landRent_PerAc)||0),equipment:Ek((null===e||void 0===e||null===(r=e.fixedCost)||void 0===r?void 0:r.equipment_PerAc)||0),insurance:Ek((null===e||void 0===e||null===(c=e.fixedCost)||void 0===c?void 0:c.insurance_PerAc)||0),labor:Ek((null===e||void 0===e||null===(i=e.fixedCost)||void 0===i?void 0:i.labor_PerAc)||0),repairs:Ek((null===e||void 0===e||null===(o=e.fixedCost)||void 0===o?void 0:o.repairs_PerAc)||0),taxes:Ek((null===e||void 0===e||null===(s=e.fixedCost)||void 0===s?void 0:s.taxes_PerAc)||0),returnToMgt:Ek((null===e||void 0===e||null===(d=e.fixedCost)||void 0===d?void 0:d.returnToMgt_PerAc)||0)},projectedRevenue:{yieldPerArea:Ek((null===e||void 0===e||null===(u=e.projectedRevenue)||void 0===u?void 0:u.yieldPerArea)||0),fsaPayment:Ek((null===e||void 0===e||null===(b=e.projectedRevenue)||void 0===b?void 0:b.fsaPayment)||0),cropSharePercent:(null===e||void 0===e||null===(p=e.projectedRevenue)||void 0===p?void 0:p.cropSharePercent)/100||1,pricePerUnit:Ek((null===e||void 0===e||null===(f=e.projectedRevenue)||void 0===f?void 0:f.pricePerUnit)||"0")},notes:(null===e||void 0===e?void 0:e.notes)||"",cropSeasonIds:V||[],flagIds:(null===e||void 0===e?void 0:e.flagIds)||[],planProductEntries:x||[],cropZones:J(e)||[],organizationId:O.organizationId,cropId:v,currency:(null===e||void 0===e?void 0:e.currency)||"USD",coveragePercent:null===e||void 0===e?void 0:e.coveragePercent})},Q=function(){var e=Object(Y.a)(G.a.mark((function e(a){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"plan"===(null===a||void 0===a?void 0:a.id)?d(!0):d(!1),e.next=3,g(a,S);case 3:e.sent&&(i("Save Succeeded"),"edit-fromView"===n?P.push("".concat(Cc.plans,"/").concat(j,"/view")):P.push(Cc.plans),t.reload());case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),X=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return T.sendEventToAmplitude(T.events.epic.Plans.createPlan),n=K(t),r=(a=n).notes,c=Object(te.a)(a,mM),n=r?n:c,e.next=6,Q(n);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"plan-form-container",children:[Object(y.jsx)(lo,{disabled:"plan"===j||j.length>0,hideCropSeasonDropdown:!1,onCropSeasonSelect:function(){W(),B(JSON.parse(localStorage.getItem("selectedCropSeasons"))||null)},children:"view"===f?Object(y.jsx)(lo.Item,{title:"Plans",value:w.name,to:Cc.plans,isLast:!0}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(lo.Item,{title:"Plans",value:"All Plans",to:Cc.plans}),Object(y.jsx)(lo.Item,{title:"Plan",value:"plan"===j?"Create Plan":"Edit Plan",isLast:!0})]})}),false,h?Object(y.jsx)(m.Spinner,{}):"view"===f?Object(y.jsx)(fM,{plan:w}):Object(y.jsx)(YF,{onSubmit:X,plan:w,isSaving:x,selectedview:n,selectedCropSeasonIds:V,propertiesSortedData:z,propertiesLoading:Z,fieldsAndAreasGeoJSONCollection:H,reloadData:W})]})};vM.defaultProps={location:{reload:function(){},selectedView:""}};var OM=vM,hM=[{id:"plans",key:"plans",label:"Plans",path:Cc.plans,exact:!0,secure:!0,disabled:!1,component:TL,icon:Xl,nav:"leftNav"},{id:"planEntry",key:"planEntry",path:"".concat(Cc.plans,"/:id"),exact:!0,secure:!0,disabled:!1,component:OM,minPermissions:{minAllowedRole:$a}},{id:"planView",key:"planView",path:"".concat(Cc.plans,"/:id/view"),exact:!0,secure:!0,disabled:!1,component:fM}],xM=n(2840),gM=n(2850),CM=function(e){var t=e.color;return Object(y.jsx)("svg",{"data-testid":"edit-icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("g",{id:"edit",children:Object(y.jsx)("path",{id:"icon/image/edit_24px",fillRule:"evenodd",clipRule:"evenodd",d:"M17.659 3C17.409 3 17.149 3.1 16.959 3.29L15.129 5.12L18.879 8.87L20.709 7.04C21.099 6.65 21.099 6.02 20.709 5.63L18.369 3.29C18.169 3.09 17.919 3 17.659 3ZM14.059 9.02L14.979 9.94L5.91902 19H4.99902V18.08L14.059 9.02ZM2.99902 17.2514L14.059 6.19141L17.809 9.94141L6.74902 21.0014H2.99902V17.2514Z",fill:t})})})};CM.defaultProps={color:"#696F88"};var yM=CM,PM=function(e){var t=e.color;return Object(y.jsx)("svg",{"data-testid":"remove-circle-icon",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 1.5C4.86 1.5 1.5 4.86 1.5 9C1.5 13.14 4.86 16.5 9 16.5C13.14 16.5 16.5 13.14 16.5 9C16.5 4.86 13.14 1.5 9 1.5ZM3 9C3 12.3075 5.6925 15 9 15C12.3075 15 15 12.3075 15 9C15 5.6925 12.3075 3 9 3C5.6925 3 3 5.6925 3 9ZM5.25 8.25V9.75H12.75V8.25H5.25Z",fill:t})})};PM.defaultProps={color:"#696F88"};var AM=PM,SM="None",TM="---",NM=[{key:"CustomProduct",value:"Custom Product"},{key:"CropwiseList",value:"Cropwise List"}],EM=[{key:"CropProtection",value:"Crop Protection"},{key:"Fertilizer",value:"Fertilizer"},{key:"Seed",value:"Seed"},{key:"Service",value:"Service"}],wM=n(69).getConvertUnitFromTo,_M=function(e,t,n,a){try{return wM(e,t,n,a)}catch(r){return null}},RM=function(e){var t={density:e.density,productDensity:e.productDensity,stdfactor:e.stdFactor,stdunit:e.stdUnit,stdpackageunit:e.stdPackageUnit},n=_M(e.productQuantityValue,e.productQuantityUnit,e.stdPackageUnit,t),a=_M(e.purchased,e.purchasedUnit,e.stdPackageUnit,t),r=TM;return(null!==n&&void 0!==n&&n.Value||null!==a&&void 0!==a&&a.Value)&&(r=((null===a||void 0===a?void 0:a.Value)-(null===n||void 0===n?void 0:n.Value)).toFixed(2)),e.productQuantityValue||e.purchased?r:(0).toFixed(0)},IM=function(e){var t=e.open,n=e.close,a=e.handleRemove,r=e.isRemoveLoading,c=e.setToastHasNotBeenClosed,i=e.toastHasNotBeenClosed,o=e.toastRenderContents,s=function(){c(!1),n()};return Object(y.jsxs)(ao,{open:t,title:"Remove Product?",close:s,cancelLabel:"Cancel",confirmLabel:"Remove",onCancel:s,type:"error",onConfirm:a,isRemoveLoading:r,children:[Object(y.jsxs)("div",{testId:"product-removeModal",className:"pr-6",children:[Object(y.jsx)("p",{children:"Are you sure you want to remove this product from your Product List?"}),Object(y.jsx)("br",{}),Object(y.jsx)("p",{children:"Removing a product will not affect any associated records. Products can be re-added to your list by selecting \u201cAdd Product\u201d."})]}),i&&Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){c(!1)},children:o})]})},DM=Object(a.createContext)(),kM=function(e){var t=e.children,n=Object(a.useState)(!1),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)([]),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(!1),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useState)(!1),v=Object(b.a)(m,2),O=v[0],h=v[1],x=function(){i(!1),d([])},g=Object(a.useMemo)((function(){return function(e,t){var n=e.map((function(e){return e[t]}));d(n)}}),[]),C=Object(a.useMemo)((function(){return{isUpdateListPrice:c,setIsUpdateListPrice:i,selectedTaskIds:l,setSelectedTaskIds:d,resetValues:x,selectAllRows:g,isInfoRow:O,setIsInfoRow:h,showInfoRow:p,setShowInfoRow:f}}),[c,g,l,O,p]);return Object(y.jsx)(DM.Provider,{value:C,children:t})};kM.defaultProps={children:null};var LM=function(e){var t,n=e.product,r=e.onEdit,c=e.setProductToRemove,i=e.setShowRemoveModal,o=e.showRemoveModal,s=e.handleRemove,l=e.toastHasNotBeenClosed,d=e.toastRenderContents,u=e.setToastHasNotBeenClosed,j=wS().isRemoveLoading,v=Object(a.useContext)(DM),O=v.isUpdateListPrice,h=v.selectedTaskIds,x=Object(a.useContext)(ac),g=Object(b.a)(x,1)[0],C=Object(f.useFlags)(),P=C.feProductListRemoveProduct,A=C.feProductListRemoveProductButtonByOrgId,S=Object(p.h)();return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"w-full flex items-center justify-between p-4 bg-white border-b",children:[Object(y.jsxs)("div",{className:"flex items-center gap-6",children:[Object(y.jsx)(m.Button,{onClick:function(){O&&h.length?xM.a.confirm({title:"Cancel price update?",icon:Object(y.jsx)(gM.a,{}),content:"The selected records will not be updated with the list price.",okText:"Cancel update",cancelText:"Continue selecting",okButtonProps:{style:{backgroundColor:"#14803C"}},onOk:function(){S.push(Cc.products)}}):S.push(Cc.products)},icon:Object(y.jsx)(ui.a,{icon:di.e,size:"xs",style:{marginRight:"4px"}}),type:"outline",children:"Back"}),Object(y.jsx)("h1",{className:"text-2xl font-semibold",children:n.productName})]}),Object(y.jsxs)("div",{className:"flex items-center gap-2",children:[Object(y.jsx)(m.Button,{icon:Object(y.jsx)(yM,{color:O?"#C2C7D0":"#696F88"}),onClick:function(){return r(n)},tabIndex:0,type:"outline",disabled:O,children:"Edit"}),P||null!==A&&void 0!==A&&A.includes(null===g||void 0===g||null===(t=g.organization)||void 0===t?void 0:t.id)?Object(y.jsx)(m.Button,{icon:Object(y.jsx)(AM,{color:O?"#C2C7D0":"#696F88"}),type:"outline",disabled:O,onClick:function(){var e;e=n.productId,c(e),i(!0)},children:"Remove"}):null,Object(y.jsx)(IM,{open:o,itemType:"Product",close:function(){i(!1)},handleRemove:s,isRemoveLoading:j,setToastHasNotBeenClosed:u,toastHasNotBeenClosed:l,toastRenderContents:d})]})]}),Object(y.jsx)("section",{className:"w-full p-4",children:Object(y.jsxs)("div",{className:"flex gap-4",children:[Object(y.jsx)("div",{className:"grid items-center w-56 px-4 py-3 bg-white rounded-lg shadow-sm-card",children:Object(y.jsxs)("div",{children:[Object(y.jsxs)("span",{className:"text-2xl font-semibold",children:[RM(n),Object(y.jsx)("span",{className:"ml-1 text-base font-normal",children:Object(va.g)(n.stdPackageUnit)})]}),Object(y.jsx)("p",{className:"text-base text-neutral-60 overflow-hidden whitespace-no-wrap",children:"Total available quantity"})]})}),Object(y.jsx)("div",{className:"flex-1 px-4 py-4 bg-white rounded-lg shadow-lg",children:Object(y.jsxs)("div",{className:"flex flex-row gap-x-9 items-start",children:[Object(y.jsxs)("div",{className:"flex flex-col ",children:[Object(y.jsx)("span",{className:"flex text-sm text-neutral-60",children:"Manufacturer"}),Object(y.jsxs)("span",{className:"text-base text-wrap   flex-wrap break-words",children:[n.custom?Object(y.jsx)("span",{children:"Custom \u2022 "}):null,n.manufacturerName]})]}),Object(y.jsxs)("div",{className:"flex flex-col ",children:[Object(y.jsx)("span",{className:"flex text-sm text-neutral-60 whitespace-no-wrap",children:"Product Type"}),Object(y.jsx)("div",{className:"flex items-start text-base whitespace-no-wrap",children:Object(y.jsx)(uT,{productType:n.productType,iconSize:24})})]}),Object(y.jsxs)("div",{className:"flex flex-col ",children:[Object(y.jsx)("span",{className:"flex text-sm text-neutral-60 whitespace-no-wrap",children:"List Price"}),Object(y.jsx)("span",{className:"flex text-base whitespace-no-wrap",children:n.averagePricePerUnit?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:n.averagePricePerUnit})," ","/",Object(va.g)(n.stdUnit)]}):SM})]}),Object(y.jsxs)("div",{className:"flex flex-col ",children:[Object(y.jsx)("span",{className:"flex text-sm text-neutral-60 whitespace-no-wrap",children:"EPA Number"}),Object(y.jsx)("span",{className:"flex text-base whitespace-no-wrap",children:n.registrationNumber?k_(n.registrationNumber):SM})]}),!(null===n||void 0===n||!n.packageWeight)&&Object(y.jsxs)("div",{className:"flex flex-col ",children:[Object(y.jsx)("span",{className:"flex text-sm text-neutral",children:"Package Weight"}),Object(y.jsxs)("span",{className:"flex text-base",children:[Object(y.jsx)(yf,{roundedTo:2,children:n.packageWeight})," / lbs per ".concat(n.stdPackageUnit)]})]})]})})]})})]})},FM=n.p+"static/media/open_in_new.7553f2d7.svg",MM=function(e,t,n){return t&&t===e?"ascend"===n?"sort-asc":"sort-desc":""},VM=function(e,t,n){if(!n)return e;var a=e.map((function(e){return Object(ne.cloneDeep)(e)}));return Object(ne.orderBy)(a,[function(e){var n=null===e||void 0===e?void 0:e[t];return"string"===typeof n?n.trim().toLowerCase():n}],function(e){return"ascend"===e?"asc":"descend"===e?"desc":null}(n))},BM={invoice:"/app/invoices/invoice",task:"/app/tasks/create"},UM=function(e){if(!e)return 0;var t={density:e.density,productDensity:e.productDensity,stdfactor:e.stdFactor,stdunit:e.stdUnit,stdpackageunit:e.stdPackageUnit},n=_M(e.purchased,e.purchasedUnit,e.stdPackageUnit,t);return e.purchased?null===n||void 0===n?void 0:n.Value:0},zM=n.p+"static/media/empty_inventory_table.5b3995a0.svg",ZM=n.p+"static/media/plus.e09b6258.svg",YM=function(e){var t=e.totalItemCount,n=e.type,a=e.onButtonClick,r=t>0,c={title:"No Invoices Found",desc:"We were unable to find any invoices including this product.",action:"Create Invoice"};switch(n){case"invoices":default:break;case"completed_tasks":c={title:"No Completed Tasks Found",desc:"We were unable to find any completed tasks including this product.",action:"Create Task"}}return Object(y.jsx)("div",{className:"grid place-items-center w-full h-full",children:Object(y.jsx)("div",{className:"flex flex-col items-center",children:r?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("img",{width:260,src:fw,alt:"no results found for filter"}),Object(y.jsx)("h3",{className:"max-w-md text-center break-words",children:"We were unable to find any products using the selected filters. Try a different crop season and/or date range selection."})]}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("img",{width:260,src:zM,alt:"no results found for filter"}),Object(y.jsxs)("span",{className:"max-w-lg text-center break-words",children:[Object(y.jsx)("h3",{className:"font-semibold text-sm ",children:c.title}),Object(y.jsx)("p",{className:"text-sm mt-2",children:c.desc})]}),Object(y.jsx)("div",{className:"mt-4",children:Object(y.jsx)(m.Button,{onClick:a,icon:Object(y.jsx)("img",{alt:"plus icon",src:ZM,width:18}),type:"primary",children:c.action})})]})})})};YM.defaultProps={type:"invoices",onButtonClick:function(){}};var HM=YM,GM=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),WM=function(e){var t=e.cropSeasons,n=e.dateRange,r=Object(a.useContext)(we),c=Object(p.j)().id,i=Object(p.h)(),o=Object(a.useState)(0),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)("invoiceDate"),f=Object(b.a)(u,2),O=f[0],h=f[1],x=Object(a.useState)("desc"),g=Object(b.a)(x,2),C=g[0],P=g[1],A=JR(),S=A.isLoading,T=A.getProduct,N=A.selectedProduct,E=bI(c),w=E.invoices,_=E.invsLoading;Object(a.useEffect)((function(){c&&T(c)}),[c]);var R=Object(a.useMemo)((function(){if(!N||!w)return{rows:[],totalProductCount:0};var e=0;return{rows:w.map((function(t){var n=t.invoiceProducts.filter((function(e){return e.productId===N.productId})),a=0,r=0,c=Object(v.a)(new Set(n.map((function(e){return e.totalQuantityUnit}))));return n.forEach((function(t){a+=t.totalCostValue,1===c.length?r+=t.totalQuantityValue:r+=t.totalQuantityValueInStandardPackageUnit,e+=t.totalQuantityValue})),{id:t.id,invoiceName:t.invoiceNumber,invoiceDate:t.invoiceDate,invoiceCropSeasons:t.cropSeasons,totalCost:a,costPerUnit:FS.b.divide(a,r),invoiceQuantity:r,unit:1===c.length?c[0]:N.stdPackageUnit}})),totalProductCount:e}}),[N,w]),I=R.rows,D=R.totalProductCount,k=Object(a.useMemo)((function(){var e=I.filter((function(e){var a=new Date(e.invoiceDate),r=0===t.length||e.invoiceCropSeasons.some((function(e){return t.includes(e.seasonId)})),c=!n||a>new Date(n[0])&&a<new Date(n[1]);return r&&c}));return VM(e,O,C)}),[I,O,C,t,n]),L=[{field:"invoiceName",sortable:!0,title:"Invoice Name (".concat(k.length,")")},{field:"invoiceDate",sortable:!0,title:"Invoice Date"},{field:"totalCost",sortable:!0,title:"Total Cost"},{field:"costPerUnit",sortable:!0,title:"Cost per unit"},{field:"invoiceQuantity",sortable:!0,title:"Invoice Quantity"},{field:"actions"}],F=k.slice(20*l,20*(l+1)),M=!N||_||S,V=0===F.length,B=UM(N);return B=0===B?D:B,Object(y.jsx)("div",{className:"flex",style:{height:"calc(100% - 3rem)"},children:Object(y.jsxs)("div",{className:"flex-1 overflow-scroll",children:[Object(y.jsx)(ol,{items:F,isLoading:M,isEmpty:V,emptyState:function(){return null},tableColumns:L,onSort:function(e,t){var n=t||"asc";h(e),P(n)},sortBy:O,sortDir:C,wrapperClassName:"flex-1 h-fit",children:function(e){return e.rows.map((function(e){return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{width:"auto",children:e.invoiceName}),Object(y.jsx)(m.Table.Cell,{width:"auto",children:Object(ya.a)(new Date(e.invoiceDate),"MMM dd, u")}),Object(y.jsx)(m.Table.Cell,{width:"auto",children:GM.format(e.totalCost)}),Object(y.jsx)(m.Table.Cell,{width:"auto",children:"".concat(GM.format(e.costPerUnit)," / ").concat(Object(va.g)(e.unit))}),Object(y.jsx)(m.Table.Cell,{width:"auto",children:xR(e.invoiceQuantity,Object(va.g)(e.unit))}),Object(y.jsx)(m.Table.Cell,{width:"auto",children:Object(y.jsx)("div",{className:"w-full flex flex-row justify-end",children:Object(y.jsxs)(j.b,{to:"".concat(Cc.invoices,"/").concat(e.id,"/view"),className:"flex flex-row product-list-table-action",onClick:function(){return r.sendEventToAmplitude(r.events.epic.ProductList.viewInvoice,{productId:e.id})},children:[Object(y.jsx)("img",{className:"mr-1",src:FM,alt:"view icon"}),Object(y.jsx)("span",{children:"View"})]})})})]},e.id)}))}}),!M&&k.length>0?Object(y.jsx)("div",{className:"w-full px-6 border-1 border-t-0 border-neutral-20",children:Ho(k.length,l,d,(function(){return Object(y.jsxs)("div",{className:"bg-banner-alert-blue-10 rounded py-1 px-3",children:[Object(y.jsx)("span",{children:"Total Invoiced Quantity: "}),Object(y.jsx)("span",{className:"font-semibold",children:xR(B,Object(va.g)(null===N||void 0===N?void 0:N.purchasedUnit))})]})}))}):null,!M&&V&&Object(y.jsx)(HM,{type:"invoices",totalItemCount:I.length,onButtonClick:function(){return i.push(BM.invoice)}})]})})};WM.defaultProps={dateRange:null};var qM=WM,JM=n(2825),KM=["showTotal"],QM=function(e){var t=e.pageSize,n=void 0===t?50:t,r=e.defaultSortBy,c=void 0===r?"name":r,i=e.defaultSortDir,o=void 0===i?"ascend":i,s=e.pagination,l=(s=void 0===s?{}:s).showTotal,d=void 0===l?function(e,t){return Object(y.jsxs)("span",{className:"text-neutral-60",children:[t[0],"-",t[1]," of ",e]})}:l,u=Object(te.a)(s,KM),j=Object(a.useState)(0),p=Object(b.a)(j,2),f=p[0],m=p[1],v=Object(a.useState)(1),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(n),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(c),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)(o),_=Object(b.a)(w,2),R=_[0],D=_[1],k=Object(a.useMemo)((function(){return Object(I.a)(Object(I.a)({defaultCurrent:1,current:h,defaultPageSize:n,pageSize:P,total:f,showTotal:d,showSizeChanger:!1,position:["bottomRight"]},u),{},{onChange:function(e,t){x(e),A(t),u.onChange&&u.onChange(e-1,t)}})}),[h,P,f,n,d,u]),L=Object(a.useCallback)((function(e,t,n){var a=n.order,r=n.field;a?(E(r),D(a)):(E(c),D(o))}),[c,o]);return Object(a.useEffect)((function(){x(1),u.onChange&&u.onChange(0,P)}),[N,R]),{totalItemsCount:f,setTotalItemsCount:m,page:h,setPage:x,pageSize:P,setPageSize:A,sortBy:N,setSortBy:E,sortDir:R,setSortDir:D,reactUiKitTablePaginationProp:k,reactUiKitTableOnChange:L}},XM=function(e,t){var n=Object(a.useRef)(0),r=Object(a.useState)([]),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)([]),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(null),p=Object(b.a)(j,2),f=p[0],m=p[1],v=Object(a.useState)(!1),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(0),C=Object(b.a)(g,2),y=C[0],P=C[1],A=Object(a.useState)(Object(I.a)({pageNo:y,size:-1},t)),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useCallback)(function(){var t=Object(Y.a)(G.a.mark((function t(a){var r,c;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:x(!0),n.current+=1,r=Object(I.a)(Object(I.a)(Object(I.a)({},T),a),{},{sortBy:void 0,sortDir:void 0,pageNo:void 0}),c=In.fetch("".concat(e,"/applications"),r),c.promise.then((function(e){var t=e.data.results;u(e.data.totalElements),o(t)})).catch((function(e){m(e)})).catch(Ae.default).finally((function(){return x(!1)}));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[T,x,e]),w=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:E();case 1:case"end":return e.stop()}}),e)}))),[E]);Object(a.useEffect)((function(){w()}),[w,T]);var _=Object(a.useCallback)((function(e,t){P(e),N((function(n){return Object(I.a)(Object(I.a)(Object(I.a)({},n),t),{},{pageNo:e})}))}),[N]),R=Object(a.useCallback)((function(e,t){N((function(n){return Object(I.a)(Object(I.a)({},n),{},{pageNo:0,sortBy:e,sortDir:t})}))}),[N]);return{getProductApplications:E,tasks:i,totalTasks:d,tasksError:f,isLoading:h,pageNo:T.pageNo,goToPage:_,reset:function(){N(Object(I.a)(Object(I.a)({},T),{},{pageNo:y,totalPages:0}))},reload:w,sort:R,sortBy:T.sortBy,sortDir:T.sortDir}},$M=function(e){var t=ni(),n=Object(a.useContext)(ac),r=Object(b.a)(n,1)[0].organization,c=Object(a.useState)(null),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),j=d[0],p=d[1],f=Object(a.useState)(),m=Object(b.a)(f,2),O=m[0],h=m[1];return{submit:function(n){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},c=[];p(!0),n.allTasks||(c=Object(v.a)(new Set(n.taskIds.map((function(e){return e.split("_")[0]}))))),J.a.post("".concat(u.e,"/tasks/products/").concat(e,"/submissions"),Object(I.a)(Object(I.a)({},n),{},{taskIds:c}),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:r.id}),Authorization:"Bearer ".concat(Ve())}}).then((function(e){h("success"),s(e.data),t.success("Processing record update.",{timeout:1e4,content:"The selected records will be updated within [max time frame]. You can return to this page for confirmation once the update is complete."}),a()})).catch((function(){h("error"),t.error("Unable to update records.",{timeout:1e4,content:"An error prevented your records from being updated. Please try again.",supportButton:!0})})).finally((function(){p(!1)}))},data:o,loading:j,status:O}},eV=function(e){var t=e.rowKey,n=e.columns,r=e.dataSource,c=e.pagination,i=e.onChange,o=e.tableLayout,s=Object(a.useContext)(DM),l=s.isUpdateListPrice,d=s.selectedTaskIds,u=s.setSelectedTaskIds,b=s.isInfoRow,j=s.setIsInfoRow,p=s.setShowInfoRow,f=c.current;Object(a.useEffect)((function(){var e=r.map((function(e){return e[t]})).every((function(e){return d.includes(e)}));j((function(t){return Object(I.a)(Object(I.a)({},t),{},Object(et.a)({},f,e))}))}),[d,f,r]);var m={columnWidth:60,preserveSelectedRowKeys:!0,selectedRowKeys:d,type:"checkbox",onChange:function(e){!function(e){u(e)}(e)},getCheckboxProps:function(e){return{disabled:null===e||void 0===e?void 0:e.isInfoRow,style:null!==e&&void 0!==e&&e.isInfoRow?{display:"none"}:{}}}};return Object(a.useEffect)((function(){p(b[f])}),[f,b]),Object(y.jsx)(Xc.Table,{rowKey:t,bordered:!1,columns:n,dataSource:b[f]?[{id:"info-row",key:"info-row",isInfoRow:!0}].concat(Object(v.a)(r)):Object(v.a)(r),pagination:b[f]?Object(I.a)(Object(I.a)({},c),{},{pageSize:21}):c,rowSelection:l?m:void 0,rowClassName:function(e){return e.isInfoRow?"hide-checkbox":""},onChange:i,scroll:{y:320},tableLayout:o})},tV=function(e,t,n,a,r,c,i){var o=a.totalSelectedRows,s=a.selectedTaskIds,l=r.listPriceAction,d=r.showConfirm,u=r.showConfirmUpdate,b=r.resetValues,j=c.isUpdateListPrice,p=c.hasListPrice,f=i&&!j&&p;return Object(y.jsx)("div",{className:"flex items-center w-full",children:Object(y.jsxs)("div",{style:{bottom:-2},className:"flex flex-row justify-between items-center w-full",children:[Object(y.jsxs)("div",{className:"w-auto absolute",style:{left:f?20:0},children:[!!f&&Object(y.jsxs)(Xc.Button,{className:"text-green-700",type:Xc.ButtonType.primary,onClick:function(){return l((function(e){return!e}))},ghost:!0,children:[Object(y.jsx)(yM,{color:"#14803C"}),"Update Records with List Price"]}),j&&p&&Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)("p",{className:"mr-2 ml-4 text-blue-60 font-semibold",children:"".concat(o," selected")}),Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.primary,className:"ml-2",disabled:!s.length,onClick:u,children:"Update Records"}),Object(y.jsx)(Xc.Button,{className:"mx-4",type:Xc.ButtonType.outline,onClick:function(){s.length>0?d():b()},children:"Cancel"})]})]}),Object(y.jsxs)("div",{className:"flex flex-row flex-end",children:[Object(y.jsxs)("div",{className:"bg-banner-alert-blue-10 rounded py-0.5 px-3 relative","data-testid":"product-detail-total-value",children:[Object(y.jsx)("span",{children:"Total Applied Quantity: "}),Object(y.jsx)("span",{className:"font-semibold",children:e})]}),Object(y.jsxs)("span",{className:"ml-4 text-neutral-60",children:[null===t||void 0===t?void 0:t[0],"-",null===t||void 0===t?void 0:t[1]," of ",n]})]})]})})},nV=function(e,t,n,a){var r=t.isAllInPageRecordsSelected,c=t.selectAllRows,i=t.isAllRecordsSelected,o=n.sortBy,s=n.sortDir,l=a.filteredAndSortedTasks,d=a.reactUiKitTablePaginationProp,u=function(e){return r&&0===e?0:1},b=[{title:"Task Name",dataIndex:"name",key:"name",className:MM("name",o,s),sorter:!0,sortOrder:"name"===o?s:null,onCell:function(e,t){return{colSpan:r&&0===t?7:1}},render:function(e,t){return t.isInfoRow?Object(y.jsx)("div",{className:"text-sm remove-parent-padding bg-blue-10 flex flex-row items-center",colSpan:7,children:Object(y.jsxs)("p",{className:"inline-flex items-center px-5 py-3",children:[Object(y.jsx)("img",{alt:"info",src:B_,className:"mr-2",style:{width:"24px",height:"24px"}}),i?"All records are selected":"All records on this page are selected.",!i&&Object(y.jsx)("span",{className:"text-blue-60 font-semibold cursor-pointer ml-1",children:Object(y.jsx)(pu,{onClick:function(){return c(l,"key")},children:" Select all ".concat(d.total," records")})})]})}):Object(y.jsx)("div",{children:e})}},{title:"Completed Date",dataIndex:"completedDate",key:"completedDate",className:MM("completedDate",o,s),sorter:!0,sortOrder:"completedDate"===o?s:null,onCell:function(e,t){return{colSpan:u(t)}},render:function(e){return Object(y.jsx)("div",{children:new Date(e).toLocaleString("en-US",{year:"numeric",month:"short",day:"2-digit",hour:"numeric",minute:"2-digit",hour12:!0}).replace(/,([^,]*)$/,"$1")})}},{title:"Rate",dataIndex:"ratePerArea",key:"ratePerArea",className:MM("ratePerArea",o,s),sorter:!0,sortOrder:"ratePerArea"===o?s:null,onCell:function(e,t){return{colSpan:u(t)}},render:function(e,t){return Object(y.jsx)("div",{children:"".concat(xR(e,Object(va.g)(t.ratePerAreaUnit)),"/").concat(Object(va.g)(t.appliedAreaUnit))})}},{title:"Applied Quantity",dataIndex:"appliedArea",key:"appliedArea",className:MM("appliedArea",o,s),sorter:!0,sortOrder:"appliedArea"===o?s:null,onCell:function(e,t){return{colSpan:u(t)}},render:function(e,t){return Object(y.jsx)("div",{children:"".concat(xR(e,Object(va.g)(t.appliedAreaUnit)))})}},{title:"Unit Price",dataIndex:"averagePriceAtTimeOfCreation",key:"averagePriceAtTimeOfCreation",className:MM("averagePriceAtTimeOfCreation",o,s),sorter:!0,sortOrder:"averagePriceAtTimeOfCreation"===o?s:null,onCell:function(e,t){return{colSpan:u(t)}},render:function(e,t){var n;return Object(y.jsx)("div",{children:"$".concat(null===(n=xR(e,Object(va.g)(t.averagePriceUnitAtTimeOfCreation)))||void 0===n?void 0:n.replace(" "," / "))})}}];return e||b.push({title:"",dataIndex:"taskId",key:"taskId",className:MM("taskId",o,s),onCell:function(e,t){return{colSpan:u(t)}},render:function(e,t){return Object(y.jsx)("div",{className:"w-full flex flex-row justify-end",children:Object(y.jsxs)(j.b,{to:"".concat(Cc.tasks,"/").concat(t.applicationId,"/view"),className:"flex flex-row",children:[Object(y.jsx)("img",{className:"mr-1",src:FM,alt:"view icon"}),Object(y.jsx)("span",{children:"View"})]})})}}),b},aV=function(e,t){return[{title:"Task Name",dataIndex:"name",key:"name",className:MM("name",e,t),sorter:!0,sortOrder:"name"===e?t:null,render:function(e){return Object(y.jsx)("div",{children:e})}},{title:"Completed Date",dataIndex:"completedDate",key:"completedDate",className:MM("completedDate",e,t),sorter:!0,sortOrder:"completedDate"===e?t:null,render:function(e){return Object(y.jsx)("div",{children:new Date(e).toLocaleDateString()})}},{title:"Rate",dataIndex:"ratePerArea",key:"ratePerArea",className:MM("ratePerArea",e,t),sorter:!0,sortOrder:"ratePerArea"===e?t:null,render:function(e,t){return Object(y.jsx)("div",{children:"".concat(xR(e,Object(va.g)(t.ratePerAreaUnit)),"/").concat(Object(va.g)(t.appliedAreaUnit))})}},{title:"Applied Area",dataIndex:"appliedArea",key:"appliedArea",className:MM("appliedArea",e,t),sorter:!0,sortOrder:"appliedArea"===e?t:null,render:function(e,t){return Object(y.jsx)("div",{children:"".concat(xR(e,Object(va.g)(t.appliedAreaUnit)))})}},{title:"Applied Quantity",dataIndex:"totalProduct",key:"totalProduct",className:MM("totalProduct",e,t),sorter:!0,sortOrder:"totalProduct"===e?t:null,render:function(e,t){return Object(y.jsx)("div",{children:"".concat(xR(e,Object(va.g)(t.totalProductUnit)))})}},{title:"",dataIndex:"taskId",key:"taskId",className:MM("taskId",e,t),render:function(e,t){return Object(y.jsx)("div",{className:"w-full flex flex-row justify-end",children:Object(y.jsxs)(j.b,{to:"".concat(Cc.tasks,"/").concat(t.applicationId,"/view"),className:"flex flex-row",children:[Object(y.jsx)("img",{className:"mr-1",src:FM,alt:"view icon"}),Object(y.jsx)("span",{children:"View"})]})})}}]},rV=function(e,t,n,a,r){var c=function(e){var t=new Date(e);return t.setHours(0,0,0,0),t},i=e.filter((function(e){var t;if(!e.completedDate)return!1;var n=c(e.completedDate),i=!a.length||(null===(t=e.taskCropSeasons)||void 0===t?void 0:t.some((function(e){return a.includes(e.id)}))),o=!0;if(null!==r&&void 0!==r&&r[0]&&r[1]){var s=c(r[0]),l=c(r[1]);o=n>=s&&n<=l}return i&&o}));return Object(v.a)(VM(i,t,n))},cV=function(e){var t=e.cropSeasons,n=e.dateRange,r=e.productDetails,c=r.listPrice,i=r.listPriceUnit,o=r.productName,s=r.stdPackageUnit,l=r.stdUnit,d=Object(a.useState)(""),u=Object(b.a)(d,2),j=u[0],O=u[1],h=Object(a.useContext)(DM),x=h.isUpdateListPrice,g=h.setIsUpdateListPrice,C=h.selectedTaskIds,P=h.setSelectedTaskIds,A=h.resetValues,S=h.showInfoRow,T=h.selectAllRows,N=Object(f.useFlags)(),E=N.releaseFeInventoryTaskListPriceUpdate,w=N.releaseFeInventoryTaskListPriceUpdateByOrg,_=Object(a.useContext)(ac),R=Object(b.a)(_,1)[0].organization,I=Object(p.j)().id,D=Object(p.h)(),k=XM(I),L=k.getProductApplications,F=k.tasks,M=k.isLoading,V=C.length,B=$M(I),U=B.submit,z=B.loading,Z=B.status,Y=xM.a.confirm,H=function(){Y({title:"Cancel price update?",icon:Object(y.jsx)(gM.a,{}),content:"The selected records will not be updated with the list price.",okText:"Cancel update",cancelText:"Continue selecting",okButtonProps:{style:{backgroundColor:"#14803C"}},onOk:function(){A()}})},G=function(){xM.a.confirm({title:"Update records with List Price?",icon:Object(y.jsx)(JM.a,{style:{color:"#14803C"}}),content:"The price of ".concat(o," on the selected records will be updated to $").concat(xR(c)," / ").concat(Object(va.g)(i)," within [time frame]."),okText:"Update records",okButtonProps:{style:{backgroundColor:"#14803C"}},onOk:function(){U({allTasks:F.length===V,unitPrice:c,taskIds:C},A)}})},W=yc(E,w,null===R||void 0===R?void 0:R.id),q=QM({defaultSortBy:"name",defaultSortDir:"ascend",pageSize:20,pagination:{showTotal:function(e,t){return tV(j,t,e,{totalSelectedRows:V,selectedTaskIds:C},{listPriceAction:g,showConfirm:H,showConfirmUpdate:G,resetValues:A},{isUpdateListPrice:x,hasListPrice:c&&"None"!==c,showInfoRow:S},W)}}}),J=q.reactUiKitTableOnChange,K=q.reactUiKitTablePaginationProp,Q=q.sortBy,X=q.sortDir,$=q.page,ee=q.setTotalItemsCount,te=V===K.total,ne=Object(a.useMemo)((function(){return F.map((function(e,t){return{id:e.applicationId,key:"".concat(e.applicationId,"_").concat(e.trackingId,"_").concat(t),name:e.applicationName,applicationId:e.applicationId,completedDate:new Date(e.completedDateTime),taskCropSeasons:e.cropSeasonIds,ratePerArea:e.ratePerAreaValue,ratePerAreaUnit:e.ratePerAreaUnit,appliedArea:e.appliedAreaValue,appliedAreaUnit:e.appliedAreaUnit,totalProduct:e.productQuantityValue,totalProductUnit:e.productQuantityUnit,cropSeasonIds:e.cropSeasonIds,averagePriceAtTimeOfCreation:e.averagePriceAtTimeOfCreation,averagePriceUnitAtTimeOfCreation:Object(va.g)(null!==s&&void 0!==s?s:l)}}))}),[F]),ae=Object(a.useMemo)((function(){return rV(ne,Q,X,t,n)}),[ne,Q,X,t,n]);Object(a.useEffect)((function(){var e,t,n=ae.reduce((function(e,t){return e+t.totalProduct}),0);O("".concat(n.toFixed(2)," ").concat(null!==(e=Object(va.g)(null===(t=ae[0])||void 0===t?void 0:t.totalProductUnit))&&void 0!==e?e:""))}),[ae]);var re=Object(a.useMemo)((function(){return ae.slice(20*($-1),20*$)}),[ae,$]),ce=Object(a.useMemo)((function(){return nV(x,{isAllInPageRecordsSelected:S,selectAllRows:T,isAllRecordsSelected:te},{sortBy:Q,sortDir:X},{filteredAndSortedTasks:ae,reactUiKitTablePaginationProp:K})}),[x,te,Q,X,ae,K,S]);Object(a.useEffect)((function(){"success"===Z&&A()}),[Z]),Object(a.useEffect)((function(){L()}),[I]),Object(a.useEffect)((function(){ee(ae.length)}),[ae]),Object(a.useEffect)((function(){document.querySelectorAll(".hide-checkbox").forEach((function(e){var t=e;t.children[0]&&(t.children[0].style.display="none"),t.children[1]&&(t.children[1].style.padding="0")}))}),[S,Z]);var ie=0===re.length;return Object(a.useEffect)((function(){var e=ae.map((function(e){return e.key})),t=C.filter((function(t){return e.includes(t)}));t.length!==C.length&&P(t)}),[ae,C,"key"]),Object(y.jsxs)("div",{className:"flex",style:{height:"calc(100% - 3rem)"},children:[z&&Object(y.jsxs)("div",{className:"h-full w-full flex flex-col justify-center items-center",children:[Object(y.jsx)("div",{children:Object(y.jsx)(m.Spinner,{size:"lg"})}),Object(y.jsx)("span",{className:"mt-4 text-base font-semibold",children:"Submitting request..."})]}),!M&&ie&&Object(y.jsx)(HM,{type:"completed_tasks",totalItemCount:ne.length,onButtonClick:function(){return D.push(BM.task)}}),Object(y.jsx)("div",{className:"".concat(W?"flex-shrink":"flex-1 overflow-scroll"," max-w-full"),children:!z&&Object(y.jsx)(y.Fragment,{children:!ie&&(W?Object(y.jsx)(eV,{"data-testid":"loads-table",rowKey:"key",columns:ce,dataSource:re,fullDataSource:ae,pagination:K,onChange:J,tableLayout:"fix"}):Object(y.jsx)(Xc.Table,{"data-testid":"loads-table",rowKey:"id",columns:aV(Q,X),dataSource:Object(v.a)(re),pagination:K,onChange:J,tableLayout:"auto"}))})})]})};cV.defaultProps={dateRange:null};var iV=function(e){var t=e.seasons,n=e.ids,r=e.onRemove,c=Object(a.useMemo)((function(){return n.map((function(e){var n=t.find((function(t){return t.id===e}));return{id:e,name:n.name}}))}),[t,n]),i=c.length;return Object(y.jsxs)("div",{className:"w-full flex gap-2 flex-no-wrap",children:[c.slice(0,3).map((function(e){return Object(y.jsxs)("div",{className:"flex justify-between items-center gap-1 bg-neutral-100 rounded px-2 py-3px ".concat(i<4?"max-w-85px":"max-w-70px"),children:[Object(y.jsx)("div",{className:"flex-1 font-semibold text-neutral-60 text-xs text-center truncate",children:Object(y.jsx)("span",{title:e.name,children:e.name})}),Object(y.jsx)("button",{className:"w-4 h-4",type:"button",onClick:function(t){t.stopPropagation(),r(e.id)},children:Object(y.jsx)("img",{className:"h-full w-full",alt:"remove crop season",src:kS})})]},"label_".concat(e.id))})),i>3?Object(y.jsx)("div",{className:"bg-neutral-100 rounded px-2 py-x",children:Object(y.jsxs)("span",{className:"font-semibold text-neutral-60 text-xs",children:["+ ",i-3]})}):null]})},oV=function(){return Object(y.jsx)("div",{className:"w-full my-2 h-px bg-neutral-30"})},sV=function(e){var t=e.onChange,n=e.values,r=e.selectValue,c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(""),d=Object(b.a)(l,2),u=d[0],j=d[1],p=dd().cropSeasons,f=Object(a.useMemo)((function(){var e;return null!==(e=null===p||void 0===p?void 0:p.map((function(e){var t="active",n=new Date,a=new Date(e.startDate);return!e.active&&a>n?t="future":e.active||(t="past"),{key:e.id,value:e.name,type:t}})))&&void 0!==e?e:[]}),[p]),O=Object(a.useMemo)((function(){return f.filter((function(e){return e.value.toLowerCase().indexOf(u.toLowerCase())>-1}))}),[f,u]),h=function(e){return n.includes(e)},x=function(e){if(t){var a=Object(v.a)(n);h(e)?a=a.filter((function(t){return t!==e})):a.push(e),t(a)}},g=Object(y.jsx)("div",{children:"Completed Tasks"!==r?Object(y.jsx)("button",{className:"w-full h-8 py-1 px-2 rounded border border-neutral-30 overflow-hidden","aria-label":"crop season",type:"button",onClick:function(){return s((function(e){return!e}))},children:Object(y.jsxs)("div",{className:"flex w-full h-full items-center justify-between",children:[0===n.length?Object(y.jsx)("span",{className:"text-neutral-60",children:"Filter by season"}):Object(y.jsx)(iV,{ids:n,seasons:null!==p&&void 0!==p?p:[],onRemove:x}),Object(y.jsx)("img",{width:18,height:18,alt:"chevron down",src:Di})]})}):null}),C=function(e){var t=h(e.key);return Object(y.jsxs)("li",{className:"flex items-center gap-2 px-4 py-1 hover:bg-neutral-100 select-none ".concat(t?"bg-banner-alert-blue-10":""),children:[Object(y.jsx)(Xc.Checkbox,{id:"checkbox_".concat(e.key),checked:t,onChange:function(){return x(e.key)}}),Object(y.jsx)("label",{htmlFor:"checkbox_".concat(e.key),children:e.value})]},e.key)},P="text-xs text-neutral-60 font-semibold text-left px-3 mb-1",A="text-normal text-neutral-60 text-left px-3",S=O.filter((function(e){return"active"===e.type})),T=O.filter((function(e){return"future"===e.type})),N=O.filter((function(e){return"past"===e.type}));return Object(y.jsx)(m.Popup,{containerClasses:"w-full",position:"bottom",align:"right",trigger:g,open:o,onClose:function(){return s(!1)},children:Object(y.jsxs)("div",{className:"max-h-330px flex flex-col gap-4 px-2 py-2",children:[Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(m.Input,{id:"search",name:"search",placeholder:"Search crop seasons",value:u,onChange:function(e){return j(e.target.value)}})}),Object(y.jsxs)("div",{className:"flex-1 rounded border border-neutral-30 overflow-auto py-3",children:[Object(y.jsx)("p",{className:P,children:"Active Seasons"}),S.length>0?Object(y.jsx)("ul",{children:S.map((function(e){return C(e)}))}):Object(y.jsx)("p",{className:A,children:"There are no active seasons for this organization."}),Object(y.jsx)(oV,{}),Object(y.jsx)("p",{className:P,children:"Upcoming Seasons"}),T.length>0?Object(y.jsx)("ul",{children:T.map((function(e){return C(e)}))}):Object(y.jsx)("p",{className:A,children:"There are no upcoming seasons for this organization."}),Object(y.jsx)(oV,{}),Object(y.jsx)("p",{className:P,children:"Past Seasons"}),N.length>0?Object(y.jsx)("ul",{children:N.map((function(e){return C(e)}))}):Object(y.jsx)("p",{className:A,children:"There are no past seasons for this organization."})]})]})})},lV={invoices:qM,completedTasks:cV,ready_tasks:function(){return Object(y.jsx)("h1",{children:"Ready Tasks"})}},dV=[{key:"invoices",value:"Invoices"},{key:"completedTasks",value:"Completed Tasks"}],uV=function(e){var t=e.cropSeasons,n=e.onChangeCropSeasons,r=e.onChangeDateRange,c=e.dateRange,i=Object(p.h)(),o=Object(p.i)(),s=Object(a.useContext)(DM).isUpdateListPrice,l=Object(a.useMemo)((function(){return new URLSearchParams(o.search)}),[o]),d=Object(a.useMemo)((function(){var e,t=dV.find((function(e){return e.key===l.get("table")}));return null!==(e=null===t||void 0===t?void 0:t.value)&&void 0!==e?e:"Invoices"}),[l]),u=Object(a.useCallback)((function(e,t){var n=new URLSearchParams({table:t.key});i.replace({pathname:o.pathname,search:n.toString()})}),[i,o]);return Object(y.jsxs)("section",{className:"flex justify-between mb-4",children:[Object(y.jsxs)("div",{className:"flex items-center gap-4",children:[Object(y.jsx)("h2",{className:"text-xl font-semibold ml-4",children:"Production Records"}),Object(y.jsx)("div",{className:"w-52",children:Object(y.jsx)(Xc.Select,{style:{width:180},name:"table",value:d,disabled:s,onChange:u,suffixIcon:Object(y.jsx)("img",{width:18,height:18,alt:"chevron down",src:Di}),children:dV.map((function(e){var t=e.key,n=e.value;return Object(y.jsx)(Xc.Select.Option,{value:n,children:n},t)}))})})]}),Object(y.jsxs)("div",{className:"flex items-center gap-4",children:[Object(y.jsx)("div",{className:"w-82",children:Object(y.jsx)(sV,{onChange:n,values:t,selectValue:d})}),Object(y.jsx)(m.DatePicker,{dates:null!==c&&void 0!==c?c:void 0,onChange:function(e){return r(e.target.value)},isRangePicker:!0})]})]})};uV.defaultProps={dateRange:null};var bV=uV,jV=n.p+"static/media/file_present.31bfff50.svg",pV=function(e){var t,n=e.documentation,a=e.openFile;return Object(y.jsx)("div",{className:"h-full grid grid-flow-row grid-cols-5 gap-6 p-2 overflow-y-auto",children:(null===(t=n.documentdescriptions)||void 0===t?void 0:t.length)>0?Object(y.jsx)(y.Fragment,{children:n.documentdescriptions.map((function(e){return Object(y.jsx)("button",{onClick:function(){return a(e.id)},type:"button",className:"h-40 border border-neutral-30 rounded-lg hover:bg-banner-alert-blue-10",children:Object(y.jsxs)("div",{className:"flex flex-col items-center",children:[Object(y.jsx)("img",{src:jV,alt:"File icon"}),Object(y.jsx)("span",{className:"mt-4 text-base",children:e.description}),Object(y.jsx)("span",{className:"text-sm text-neutral-60 px-2 w-full truncate",children:e.filename})]},e.id)},e.id)}))}):null})},fV=n.p+"static/media/plus_green.a7775b3d.svg",mV=function(e){var t=Object(a.useContext)(ac),n=Object(b.a)(t,2)[1],r=Object(a.useContext)(we),c=Object(a.useState)(),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!0),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(!1),f=Object(b.a)(p,2),m=f[0],O=f[1],h=Object(a.useState)(!1),x=Object(b.a)(h,2),g=x[0],C=x[1],y=function(e){return null===o||void 0===o?void 0:o.findIndex((function(t){return t.cropId===e.cropId}))};return Object(a.useEffect)((function(){Fn.fetch(e).promise.then((function(e){s(e.data),j(!1)})).catch(Ae.default).catch((function(e){uc(n)(e),j(!1)}))}),[]),{reiphiData:o,setReiphiData:s,reiphiLoading:u,saveREIPHI:function(e,t,a,c){O(!0);var i=(null===t||void 0===t?void 0:t.cropid)||(null===t||void 0===t?void 0:t.cropId),l={rei:null===t||void 0===t?void 0:t.rei,phi:null===t||void 0===t?void 0:t.phi,reiu:null===t||void 0===t?void 0:t.reiu,phiu:null===t||void 0===t?void 0:t.phiu},d="reiphi/".concat(e,"/").concat(i),u=a&&"CWF"===(null===t||void 0===t?void 0:t.source),b=Fn.createChildApi({action:d});return(u?b.update("",l):b.create(l)).promise.then((function(e){!function(e){var t=Object(v.a)(o),n=y(e);n>-1?t[n]=e:t.push(e),s(t)}(Object(I.a)(Object(I.a)({},e.data),{},{cropName:null===t||void 0===t?void 0:t.cropName,editedOnDateEpoch:Date.now()})),c(),r.sendEventToAmplitude(r.events.epic.ProductList.saveReiPhi,{cropId:i})})).catch(Ae.default).catch((function(e){uc(n)(e)})).finally((function(){return O(!1)}))},deleteREIPHI:function(e,t){C(!0);var a=(null===e||void 0===e?void 0:e.cropid)||e.cropId,r="".concat(e.productId,"/").concat(a),c=Object(I.a)({},e);return delete c.i,Fn.delete(r,c).promise.then((function(){!function(e){var t=Object(v.a)(o),n=y(e);n>-1&&t.splice(n,1),s(t)}(e),t(!0)})).catch(Ae.default).catch((function(e){uc(n)(e)})).finally((function(){return C(!1)}))},saving:m,deleting:g}},vV=function(){var e=Object(p.j)().id,t=Object(a.useState)([]),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)(null),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(!1),u=Object(b.a)(d,2),j=u[0],f=u[1],v=Object(a.useState)(!1),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(null),T=Object(b.a)(S,2),N=T[0],E=T[1],w=mV(e),_=w.reiphiData,R=w.reiphiLoading,I=w.saveREIPHI,D=w.deleteREIPHI,k=dI(e),L=k.dataDocumentation,F=k.isLoading,M=dd().cropSeasons,V=rv({fetchType:gm,isCacheOn:!0}),B=V.dataSorted,U=V.reloadData,z=V.loading;Object(a.useEffect)((function(){if(M){var e=M.map((function(e){return e.id}));U({seasonIds:e})}}),[M]),Object(a.useEffect)((function(){if(_&&null!==L&&void 0!==L&&L.reiphiitems&&!(!(null!==B&&void 0!==B&&B.properties.length)>0)){var e=II(L.reiphiitems,B.properties,_);c(e)}}),[_,L,B]);var Z=function(){A(!1)},Y=function(e,t){l(t),x(e),f(!0)},H=function(){f(!1)},G=function(){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("ul",{className:"list-disc text-m text-neutral-80 leading-7 py-2 mt-2 ml-6",children:[Object(y.jsx)("li",{children:"REI (Restricted Entry Interval): Time limit for access on the field after application of the product. Measured in hours."}),Object(y.jsx)("li",{children:"PHI (Pre-Harvested Interval): Time limit for harvesting after application. Measured in days."}),Object(y.jsx)("li",{children:"REI/PHI: Is indicated on the label of the preparation and/or on the manufacturer's website."})]}),Object(y.jsxs)("span",{className:"text-m text-neutral-1000 leading-10 py-2 flex items-center",children:[Object(y.jsx)("p",{className:"text-m text-neutral-1000",children:"Always check the product label to confirm accuracy. Cropwise is not responsible for inaccurate information."}),Object(y.jsx)("a",{href:"https://login.landdb.com/eula",type:"button",target:"_blank",rel:"noopener noreferrer",children:Object(y.jsx)(m.Button,{type:"link-default",icon:Object(y.jsx)(XC,{fill:"#0071CD"}),children:"VIEW LICENSE AGREEMENT"})})]}),j&&Object(y.jsx)(zI,{openEdit:j,onClose:H,crop:s,isEdit:h,productId:e,saveREIPHI:I})]})};return R||F||z?Object(y.jsx)("div",{"data-testid":"rei-phi-loading",className:"flex justify-center items-center w-full h-full",children:Object(y.jsx)(m.Spinner,{size:"lg"})}):r.length>0?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"grid justify-end py-2 mb-2",children:Object(y.jsx)(m.Button,{type:"primary",ghost:!0,onClick:function(){return Y(!1)},icon:Object(y.jsx)("img",{alt:"plus",src:fV,className:"mr-1"}),children:"Add Crop"})}),Object(y.jsx)("div",{className:"max-h-20 overflow-y-auto",children:Object(y.jsx)(m.Columns,{wrap:!0,children:Object(ne.sortBy)(r,"name").map((function(e){return Object(y.jsx)(m.Column,{width:"gr-w-1/2 p-4",children:Object(y.jsx)(MI,{product:e,editClick:function(){return Y(!0,e)},deleteClick:function(){E(e),A(!0)}})},e.cropId)}))})}),Object(y.jsx)("div",{className:"ml-4",children:G()}),Object(y.jsx)(ao,{open:P,title:"Delete REI/PHI Information?",close:Z,cancelLabel:"Cancel",confirmLabel:"Delete",onCancel:Z,type:"error",onConfirm:function(){D(N,Z)},children:Object(y.jsx)("div",{className:"pr-6",children:"Are you sure you want to delete this information? This action cannot be undone."})})]}):Object(y.jsx)(EI,{setPermission:function(){return!0},openAddEditModal:Y,children:G()})},OV=function(e){var t,n,r,c=e.product,i=Object(p.i)(),o=Object(a.useContext)(DM).isUpdateListPrice,s=Object(p.j)().id,l=dI(s),d=l.dataDocumentation,u=l.isLoading,j=l.openFile,f=l.error,v=Object(a.useState)([]),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(null),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useMemo)((function(){return new URLSearchParams(i.search)}),[i]),T=null!==(t=lV[S.get("table")])&&void 0!==t?t:lV.invoices,N=(null===d||void 0===d||null===(n=d.documentdescriptions)||void 0===n?void 0:n.length)&&!c.custom&&!u&&!f,E={listPrice:null===c||void 0===c?void 0:c.averagePricePerUnit,listPriceUnit:null!==(r=null===c||void 0===c?void 0:c.stdPackageUnit)&&void 0!==r?r:null===c||void 0===c?void 0:c.stdUnit,productName:null===c||void 0===c?void 0:c.productName,stdPackageUnit:null===c||void 0===c?void 0:c.stdPackageUnit,stdUnit:null===c||void 0===c?void 0:c.stdUnit};return Object(y.jsx)("div",{className:"h-full overflow-hidden px-4",children:Object(y.jsxs)(m.Tabs,{pane:!0,className:"flex flex-col h-full w-full",contentClassName:"h-full overflow-hidden pb-4",children:[Object(y.jsxs)(m.Tabs.Tab,{label:"Inventory",children:[Object(y.jsx)(bV,{cropSeasons:h,onChangeCropSeasons:x,onChangeDateRange:A,dateRange:P}),Object(y.jsx)(T,{cropSeasons:h,dateRange:P,productDetails:E})]}),N?Object(y.jsx)(m.Tabs.Tab,{label:"Documentation",disabled:o,children:Object(y.jsx)(pV,{documentation:d,openFile:j})}):null,Object(y.jsx)(m.Tabs.Tab,{label:"REI/PHI",disabled:o,children:Object(y.jsx)(vV,{})})]})})},hV=function(){var e,t=Object(p.j)().id,n=Aw(),r=n.getProduct,c=n.product,i=wS(),o=i.addUpdateListPrice,s=i.updateCustomProduct,l=i.removeProduct,d=i.setRemoveError,u=Object(a.useContext)(ac),j=Object(b.a)(u,2),f=j[0].removeProductFailure,v=j[1],O=Object(a.useState)(null),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)(!1),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(null),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)(null),R=Object(b.a)(_,2),I=R[0],D=R[1],k=Object(a.useState)(!1),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Object(a.useState)(""),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=Object(a.useState)(null),H=Object(b.a)(Z,2),W=H[0],q=H[1],J=Object(a.useState)(!1),K=Object(b.a)(J,2),Q=K[0],X=K[1],$=Object(p.h)(),ee=function(){r(t)},te=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,l(W);case 3:ee();case 4:return e.prev=4,f?(v({type:Zr,payload:"Unable to remove product."}),v({type:zr,payload:"error"}),v({type:Ur,payload:!0})):(v({type:Zr,payload:"Product removed"}),v({type:zr,payload:"success"}),v({type:Ur,payload:!0})),$.goBack(),e.finish(4);case 8:case"end":return e.stop()}}),e,null,[[0,,4,8]])})));return function(){return e.apply(this,arguments)}}(),ne=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.custom?(n=IS(t),a=s):(n=_S(t),a=o),M(!1),a(n).then((function(){w("success"),g("Changes saved.")})).catch((function(){w("error"),g("Unable to save changes")})).finally((function(){S(!0),ee()}));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){r(t)}),[r,t]),Object(y.jsx)(kM,{children:Object(y.jsxs)("div",{className:"h-full w-full flex flex-col","data-testid":"product-view",children:[Object(y.jsx)(lo,{children:Object(y.jsx)(lo.Item,{title:"Products",value:null!==(e=null===c||void 0===c?void 0:c.productName)&&void 0!==e?e:TM,isLast:!0})}),c?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(LM,{setShowRemoveModal:X,setProductToRemove:q,productToRemove:W,showRemoveModal:Q,handleRemove:te,refreshProducts:ee,setShowToast:S,setToastMessage:g,setToastType:w,product:c,onEdit:function(e){D(e),M(!0),c.custom?z("Edit Custom Product"):z("Edit Product")}}),Object(y.jsx)(OV,{product:c})]}):Object(y.jsx)(m.Spinner,{}),Object(y.jsx)(xT,{handleEdit:ne,product:I,visible:F,onClose:function(){return M(!1)},editProductHeader:U}),Object(y.jsx)(Qc,{type:E,isBold:!0,open:A,title:x,timeout:5e3,onClose:function(){S(!1),d(null)}})]})})},xV=function(e){var t=e.sourceFilters,n=e.handleFilterChange,r=JR().products,c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1];return Object(a.useEffect)((function(){if(r){var e=Object(ne.difference)([!0,!1],r.map((function(e){return e.custom})));s(0===e.length)}else s(!1)}),[r]),o?Object(y.jsx)("div",{className:"w-220px ml-4 font-medium max-h-8 whitespace-nowrap",children:Object(y.jsx)(m.Select,{multiple:!0,value:t.join(","),placeholder:"Filter by source",items:NM,onChange:n})}):null},gV=function(e){var t=e.typeFilters,n=e.width,a=e.handleFilterChange,r=e.typeFilterOptions;return Object(y.jsx)("div",{className:"w-".concat(n," font-medium max-h-8 whitespace-nowrap"),children:Object(y.jsx)(m.Select,{multiple:!0,id:"ProductTypeSelector",value:t.join(","),placeholder:"Filter by type",items:r,onChange:a})})},CV=n.p+"static/media/remove_circle_outlined.d65acb19.svg",yV=function(e){var t=e.product,n=RM(t),a=Object(va.g)(t.stdPackageUnit);return Object(y.jsxs)("div",{className:"flex flex-row justify-center",children:[Object(y.jsx)("p",{children:t.productQuantityValue||t.purchased?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("span",{children:n})," ",Object(y.jsx)("span",{children:n!==TM?a:null})]}):SM}),n<0?Object(y.jsx)(m.Popup,{bgColor:"#232630",enableHover:!0,position:"top",align:"left",className:"w-30",hasArrow:!0,trigger:Object(y.jsx)("div",{className:"pl-3",children:Object(y.jsx)($A,{})}),children:Object(y.jsx)("div",{className:"w-356px text-xs text-white",children:"Add product quantity via invoices to resolve negative value"})}):null]})},PV=(n(1554),function(e){var t=e.product,n=e.onEdit,r=e.onRemove,c=Object(a.useContext)(we),i=Object(a.useContext)(ac),o=Object(b.a)(i,2),s=o[0].organization,l=o[1],d=Object(f.useFlags)(),u=d.feProductListRemoveProduct,v=d.feProductListRemoveProductButtonByOrgId,O=Object(p.k)().url;return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{width:"auto",children:Object(y.jsx)("div",{className:"-my-1",children:Object(y.jsxs)("div",{className:"flex flex-col items-start text-sm  ",children:[Object(y.jsx)("span",{children:t.productName}),Object(y.jsx)("span",{className:"font-normal text-neutral-60 text-xs",children:null===t||void 0===t?void 0:t.manufacturerName})]})})}),Object(y.jsx)(m.Table.Cell,{width:"auto",children:Object(y.jsx)(uT,{productType:t.productType})}),Object(y.jsx)(m.Table.Cell,{width:"auto",children:Object(y.jsx)(yV,{product:t})}),Object(y.jsx)(m.Table.Cell,{width:"auto",children:t.averagePricePerUnit?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:t.averagePricePerUnit})," ","/",Object(va.g)(t.stdUnit)]}):SM}),Object(y.jsx)(m.Table.Cell,{width:"auto",children:Object(y.jsxs)("div",{className:"w-full flex flex-row justify-end",children:[Object(y.jsxs)(j.b,{to:"".concat(O,"/").concat(t.productId,"/view"),className:"flex flex-row product-list-table-action",onClick:function(){l({type:Br,payload:t}),c.sendEventToAmplitude(c.events.epic.ProductList.viewProductDetails,{productId:t.productId})},children:[Object(y.jsx)("img",{className:"mr-1",src:FM,alt:"view icon"}),Object(y.jsx)("span",{children:"View"})]}),Object(y.jsx)("span",{className:"mx-1 gr-text-neutral-400",children:"|"}),Object(y.jsxs)("div",{className:"flex flex-row product-list-table-action",role:"button",onClick:function(){return n(t)},onKeyDown:function(e){return"Enter"===e.nativeEvent.key},tabIndex:0,"data-testid":"btn-edit-product",children:[Object(y.jsx)("img",{className:"mr-1",width:18,src:DI,alt:"edit icon"}),Object(y.jsx)("span",{children:"Edit"})]}),u||null!==v&&void 0!==v&&v.includes(null===s||void 0===s?void 0:s.id)?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("span",{className:"mx-1 gr-text-neutral-400",children:"|"}),Object(y.jsxs)("div",{className:"flex flex-row product-list-table-action mr-2",role:"button",onClick:function(){return r(t)},onKeyDown:function(e){return"Enter"===e.nativeEvent.key},tabIndex:0,"data-testid":"btn-remove-product",children:[Object(y.jsx)("img",{className:"mr-1",src:CV,alt:"remove icon"}),Object(y.jsx)("span",{children:"Remove"})]})]}):null]})})]},t.trackingId)}),AV=function(e){var t=e.onClick;return Object(y.jsx)(Xc.Button,{className:"mt-1 px-3",id:"add-product-button",type:Xc.ButtonType.primary,onClick:t,children:Object(y.jsxs)(Xc.Row,{children:[Object(y.jsx)("img",{className:"mr-1",alt:"plus",src:ZM}),Object(y.jsx)("span",{children:"Add Product"})]})})},SV=function(e){var t=e.products,n=e.productsCount,r=e.isLoading,c=e.sortBy,i=e.sortDir,o=e.loadingMessage,s=e.pageNo,l=e.setPageNo,d=e.onSort,u=e.emptyState,j=e.productToEdit,p=e.handleOnEdit,f=e.showEditDrawer,m=e.setShowEditDrawer,v=e.editProductHeader,O=e.editProductSaveText,h=e.handleEdit,x=e.setToastType,g=e.setToastMessage,C=e.setShowToast,P=e.refreshProducts,A=Object(a.useContext)(ac),S=Object(b.a)(A,1)[0],T=S.toastType,N=S.toastMessage,E=S.showToastRemoveProduct,w=S.removeProductFailure,_=wS(),R=_.isRemoveLoading,I=_.removeProduct,D=_.removeError,k=Object(a.useState)(t),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Object(a.useState)(!1),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=Object(a.useState)(null),H=Object(b.a)(Z,2),W=H[0],q=H[1],J=Object(a.useState)(!0),K=Object(b.a)(J,2),Q=K[0],X=K[1],$=[{field:"productName",title:"Products (".concat(n,")"),sortable:!0},{field:"productType",title:"Type",sortable:!0},{field:"available",title:"Available Quantity",sortable:!0},{field:"averagePricePerUnit",title:"List Price",sortable:!0},{field:"productId",title:"",sortable:!1}];Object(a.useEffect)((function(){M(t)}),[t]);var ee=function(e){q(e),z(!0)};Object(a.useEffect)((function(){E&&!w?(x(T),g(N),C(!0)):w&&(x("error"),g("Unable to remove product."),C(!0))}),[E,N,T]);var te=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,I(W.productId);case 3:return e.prev=3,D?(z(!1),x("error"),g("Unable to remove product.")):(z(!1),x("success"),g("Product removed.")),e.finish(3);case 6:C(!0),P();case 8:case"end":return e.stop()}}),e,null,[[0,,3,6]])})));return function(){return e.apply(this,arguments)}}(),ne=!r&&0===(null===t||void 0===t?void 0:t.length);return Object(y.jsxs)("div",{"data-testid":"product-list-table",className:"h-full w-full flex flex-col",children:[Object(y.jsx)("div",{className:"flex-auto overflow-auto",children:Object(y.jsx)(ol,{listType:"Products",routePath:Cc.products,items:F,isLoading:r,loadingMessage:o,isEmpty:ne,emptyState:u,tableColumns:$,onSort:d,sortBy:c,sortDir:i,simpleSortMode:!0,children:function(e){var t=e.rows;return r?null:t.map((function(e){return Object(y.jsx)(PV,{product:e,onEdit:p,onRemove:ee},e.productId)}))}})}),!ne&&Object(y.jsx)("div",{className:"pr-6 border-t-1 border-neutral-20 ".concat(r?"pointer-events-none cursor-not-allowed":""),children:Ho(n,s,(function(e){l(e)}))}),Object(y.jsx)(xT,{handleEdit:h,product:j,visible:f,onClose:function(){return m(!1)},saveText:O,editProductHeader:v}),Object(y.jsx)(IM,{open:U,itemType:"Product",close:function(){z(!1)},handleRemove:te,isRemoveLoading:R,setToastHasNotBeenClosed:X,toastHasNotBeenClosed:Q,toastRenderContents:null})]})};SV.defaultProps={sortBy:"",sortDir:"",onSort:function(){return!1},loadingMessage:""};var TV=SV,NV="PRODUCTS_IN_USE",EV="SEARCH_TEXT",wV="SEARCHED_PRODUCTS",_V="LOADING_PRODUCT_SEARCH",RV="IS_LOADING_PRODUCT_IN_USE",IV="TABLE_SEARCH_TEXT",DV=function(e,t){switch(t.type){case NV:return Object(I.a)(Object(I.a)({},e),{},{productsInUse:t.payload});case EV:return Object(I.a)(Object(I.a)({},e),{},{searchText:t.payload});case wV:return Object(I.a)(Object(I.a)({},e),{},{searchedProducts:t.payload});case _V:return Object(I.a)(Object(I.a)({},e),{},{loadingProductSearch:t.payload});case RV:return Object(I.a)(Object(I.a)({},e),{},{isLoadingProductInUse:t.payload});case IV:return Object(I.a)(Object(I.a)({},e),{},{tableSearchText:t.payload});default:return e}},kV={productsInUse:[{}],searchText:"",tableSearchText:"",filterValue:null,searchedProducts:[{}],loadingProductSearch:!1,isLoadingProductInUse:void 0},LV=Object(a.createContext)(kV),FV=function(e){var t=e.children,n=Object(a.useReducer)(DV,kV),r=Object(b.a)(n,2),c=r[0],i=r[1],o=function(e,t){i({type:e,payload:t})},s=function(e){o(NV,e)},l=c.productsInUse,d=function(e){o(EV,e)},u=c.searchText,j=function(e){o(wV,e)},p=c.searchedProducts,f=function(e){o(_V,e)},m=c.loadingProductSearch,v=function(e){o(RV,e)},O=c.isLoadingProductInUse,h=function(e){o(IV,e)},x=c.tableSearchText,g=function(){d(""),j([]),s([])},C=Object(a.useMemo)((function(){return{setProductsInUse:s,productsInUse:l,setSearchText:d,searchText:u,setSearchedProducts:j,searchedProducts:p,setLoadingProductSearch:f,loadingProductSearch:m,setIsLoadingProductInUse:v,isLoadingProductInUse:O,clearAddProduct:g,setTableSearchText:h,tableSearchText:x}}),[l,u,p,m,O,x]);return Object(y.jsx)(LV.Provider,{value:C,children:t})};FV.defaultProps={children:null};var MV=FV,VV=function(){var e=Object(a.useContext)(LV),t=e.setSearchedProducts,n=e.setLoadingProductSearch,r=e.setSearchText,c=e.searchText,i=zi(c,300),o=zi(null,300),s=yw(i,o),l=s.filteredProducts,d=s.loading;return Object(a.useEffect)((function(){t(l)}),[l]),Object(a.useEffect)((function(){n(d)}),[d,c]),Object(y.jsx)(Xc.Input,{style:{margin:"0"},type:"default",prefix:Object(y.jsx)("img",{alt:"search",src:Fi}),placeholder:"Search products",allowClear:!0,size:"middle",onChange:function(e){r(e.target.value)},value:c.length?c:""})},BV=n.p+"static/media/search_state.ac0fc836.svg",UV=function(e,t,n){var a=new Set(null===e||void 0===e?void 0:e.map((function(e){return null===e||void 0===e?void 0:e.productId})),null===n||void 0===n?void 0:n.map((function(e){return null===e||void 0===e?void 0:e.productId})));return null===t||void 0===t?void 0:t.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{isInUse:a.has(e.id)})}))},zV=n.p+"static/media/add_circle.c43c6e69.svg",ZV=n.p+"static/media/check_circle_outline_outlined.313d289c.svg",YV=function(e){var t=e.product,n=e.handleOnEdit;return Object(y.jsxs)(Xc.Col,{span:24,className:"flex flex-row h-60px items-center border-opacity-50",style:{border:"0.5px solid #D8D8DA"},children:[Object(y.jsx)(Xc.Col,{span:4,className:"flex flex-row justify-center items-center h-full",children:null!==t&&void 0!==t&&t.isInUse?Object(y.jsx)("img",{className:"mr-1",src:ZV,alt:"check icon"}):Object(y.jsx)(pu,{onClick:function(){return n(t)},children:Object(y.jsx)("img",{className:"mr-1",src:zV,alt:"circle icon"})})}),Object(y.jsxs)(Xc.Col,{span:10,className:"flex flex-col justify-center h-full",children:[Object(y.jsx)("p",{className:"text-sm font-bold",children:null===t||void 0===t?void 0:t.name}),Object(y.jsx)("p",{children:null===t||void 0===t?void 0:t.manufacturer})]}),Object(y.jsx)(Xc.Col,{span:10,className:"flex flex-row justify-start items-center h-full",children:Object(y.jsx)(uT,{productType:t.producttype||"-"})})]})},HV=n.p+"static/media/remove_circle.206d552d.svg",GV=function(e){var t,n=e.product,a=e.handleOnEdit,r=e.handleOnRemove;return Object(y.jsxs)(Xc.Col,{span:24,className:"flex hover:bg-info-light-blue flex-row h-60px items-center border-opacity-50",style:{border:"0.5px solid #D8D8DA"},children:[Object(y.jsx)(Xc.Col,{span:4,className:"flex flex-row justify-center items-center h-full",children:Object(y.jsx)(pu,{onClick:function(){return r(n)},children:Object(y.jsx)("img",{className:"mr-1",src:HV,alt:"remove icon"})})}),Object(y.jsxs)(Xc.Col,{span:10,className:"flex flex-col justify-center h-full cursor-pointer",onClick:function(){return a(n)},children:[Object(y.jsx)("p",{className:"text-sm font-bold",children:null===n||void 0===n?void 0:n.name}),Object(y.jsx)("p",{children:null===n||void 0===n?void 0:n.manufacturer})]}),Object(y.jsx)(Xc.Col,{span:10,className:"flex flex-row justify-start items-center h-full cursor-pointer",onClick:function(){return a(n)},children:Object(y.jsx)(uT,{productType:null!==(t=n.producttype)&&void 0!==t?t:n.type})})]})},WV=function(e){var t=e.setSelectedProductsList,n=e.selectedProductsList,r=e.handleOnEdit,c=e.typeFilters,i=[],o=Object(a.useState)([]),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(!1),j=Object(b.a)(u,2),p=j[0],f=j[1],v=Object(a.useContext)(LV),O=v.productsInUse,h=v.searchedProducts,x=v.loadingProductSearch,g=v.isLoadingProductInUse,C=v.searchText,P=C.length>=3?qR(n,C,[]):n;Object(a.useEffect)((function(){if(C.length>=3&&f(!0),C.length<3||g||x)d([]);else{var e=qR(UV(O,h,i),C);null!==c&&void 0!==c&&c.includes("CustomProduct")?e=e.filter((function(e){return!0===e.custom})):null!==c&&void 0!==c&&c.length&&(e=e.filter((function(e){var t;return c.map((function(e){return null===e||void 0===e?void 0:e.toUpperCase()})).includes(null===(t=e.producttype)||void 0===t?void 0:t.toUpperCase())}))),null!==n&&void 0!==n&&n.length&&(e=e.filter((function(e){return!n.find((function(t){return t.id===e.id}))}))),d(e),f(!1)}}),[h,p,O,g,C,n,x,c]);var A=function(e){var a=null===n||void 0===n?void 0:n.filter((function(t){return t.id!==e.id}));t(a)};return Object(y.jsxs)(Xc.Layout,{children:[Object(y.jsx)(Xc.Layout.Header,{children:Object(y.jsx)(Xc.Row,{className:"h-44px bg-neutral-20 items-center",children:Object(y.jsx)(Xc.Col,{span:24,children:Object(y.jsxs)(Xc.Row,{children:[Object(y.jsx)(Xc.Col,{span:11,className:"text-center font-semibold",children:"Product Name"}),Object(y.jsx)(Xc.Col,{span:9,className:"text-center font-semibold",children:"Product Type"})]})})})}),P.length?Object(y.jsxs)("div",{children:[Object(y.jsx)(Xc.Layout.Header,{children:Object(y.jsx)(Xc.Row,{className:"h-28px px-4 bg-blue-70 text-base text-white font-semibold items-center",children:"Selected Products"})}),Object(y.jsx)(Xc.Layout.Content,{children:Object(y.jsx)("div",{className:"justify-content",children:null===P||void 0===P?void 0:P.map((function(e){var t;return Object(y.jsx)(GV,{product:e,handleOnEdit:r,handleOnRemove:A},null!==(t=e.id)&&void 0!==t?t:e.name)}))})})]}):null,Object(y.jsx)(Xc.Layout.Header,{children:Object(y.jsx)(Xc.Row,{className:"h-28px px-4 bg-blue-70 text-base text-white font-semibold items-center",children:0===P.length&&0===l.length&&C.length<3?"Selected Products":"All Products"})}),Object(y.jsxs)(Xc.Layout.Content,{children:[Object(y.jsxs)(Xc.Row,{className:"items-center",children:[p?C.length>=3&&Object(y.jsx)(Xc.Col,{span:24,children:Object(y.jsx)("div",{className:"mt-10 ",children:Object(y.jsx)(m.Spinner,{size:"lg"})})}):null===l||void 0===l?void 0:l.map((function(e){return Object(y.jsx)(YV,{product:e,handleOnEdit:r},e.id)})),C.length>=3&&!l.length&&!P.length&&!x&&!p&&Object(y.jsx)(jw,{overlayIcon:fw,title:"No Products Found",message:"Please try a different search or filter."})]}),C.length<3&&!l.length&&!x&&Object(y.jsx)(jw,{overlayIcon:BV,title:"Search for Products",message:"Enter at least three characters to see a list of products from the master list"})]})]})},qV=function(e){var t=e.visible,n=e.onClose,r=e.setProductToEdit,c=e.selectedProductsList,i=e.setSelectedProductsList,o=e.handleOnAddCustomProduct,s=e.handleOnEdit,l=e.handleAddProductsSubmit,d=Object(a.useState)([]),u=Object(b.a)(d,2),j=u[0],p=u[1];return Object(y.jsx)(Xc.Drawer,{className:"add-product-drawer",open:t,placement:"right",closable:!1,maskClosable:!1,onClose:n,width:"50%",footer:Object(y.jsxs)(Xc.Row,{justify:"end",children:[Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.outline,className:"mr-10px",onClick:n,children:"Cancel"}),c?Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.primary,onClick:l,children:"Add to Product List"}):Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.primary,disabled:!0,children:"Add to Product List"})]}),children:Object(y.jsxs)("div",{className:"h-full",children:[Object(y.jsxs)("div",{className:"pt-4 pr-4 pb-5 pl-8",children:[Object(y.jsx)(Xc.Row,{justify:"end",children:Object(y.jsx)("button",{type:"button",onClick:n,children:Object(y.jsx)("img",{alt:"close",src:kS})})}),Object(y.jsx)("div",{className:"ml-2 mb-5 text-xl font-semibold",children:"Add Products to Product List"}),Object(y.jsxs)(Xc.Row,{gutter:16,children:[Object(y.jsx)(Xc.Col,{span:12,children:Object(y.jsx)(VV,{typeFilters:j})}),Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(gV,{typeFilters:j,handleFilterChange:function(e,t,n){var a=n.map((function(e){return e.key}));if(0===a.length||1===a.length)p(a);else{var r=a.filter((function(e){return-1===j.indexOf(e)}));p(r)}},width:"",typeFilterOptions:EM})}),Object(y.jsx)(Xc.Col,{span:6,children:Object(y.jsx)(Xc.Button,{ghost:!0,type:Xc.ButtonType.primary,className:"px-3",onClick:o,children:Object(y.jsxs)(Xc.Row,{children:[Object(y.jsx)("img",{alt:"plus",src:fV,className:"mr-1"}),Object(y.jsx)("span",{children:"Create Custom"})]})})})]})]}),Object(y.jsx)(Xc.Row,{flex:"auto",children:Object(y.jsx)(WV,{selectedProductsList:c,setSelectedProductsList:i,setProductToEdit:r,handleOnEdit:s,typeFilters:j})})]})})},JV=function(e){var t=e.setSearchText,n=Object(a.useRef)(Object(ne.debounce)(t,300)),r=Object(a.useState)(""),c=Object(b.a)(r,2),i=c[0],o=c[1];return Object(y.jsx)(Xc.Input,{style:{margin:"0"},type:"default",prefix:Object(y.jsx)("img",{alt:"search",src:Fi}),placeholder:"Search products",allowClear:!0,size:"middle",onChange:function(e){o(e.target.value),n.current(e.target.value)},value:i})},KV=(n(1555),function(){var e=Object(a.useContext)(LV),t=e.setProductsInUse,n=e.setIsLoadingProductInUse,r=e.clearAddProduct,c=e.tableSearchText,i=Object(a.useContext)(we),o=JR({sortBy:"productName",sortDir:"asc"}),s=o.products,l=o.getProducts,d=o.productsCount,u=o.isLoading,j=o.pageNo,p=o.goToPage,f=o.sort,m=o.getAllUseProducts,O=o.allProducts,h=o.isLoadingAllProducts,x=o.filterByNameQuery,g=o.sortBy,C=o.sortDir,P=wS(),A=P.addUpdateListPrice,S=P.addProducts,T=P.updateCustomProduct,N=P.updateError,E=Object(a.useState)(null),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)(!1),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)(null),V=Object(b.a)(M,2),B=V[0],U=V[1],z=Object(a.useState)(null),Z=Object(b.a)(z,2),H=Z[0],W=Z[1],q=Object(a.useState)(!1),J=Object(b.a)(q,2),K=J[0],Q=J[1],X=Object(a.useState)(s),$=Object(b.a)(X,2),ee=$[0],te=$[1],ne=Object(a.useState)([]),ae=Object(b.a)(ne,2),re=ae[0],ce=ae[1],ie=Object(a.useState)([]),oe=Object(b.a)(ie,2),se=oe[0],le=oe[1],de=!!re.length||!!se.length,ue=Object(a.useState)(!1),be=Object(b.a)(ue,2),je=be[0],pe=be[1],fe=Object(a.useState)(""),me=Object(b.a)(fe,2),ve=me[0],Oe=me[1],he=Object(a.useState)("Save"),xe=Object(b.a)(he,2),ge=xe[0],Ce=xe[1],ye=Object(a.useState)([]),Pe=Object(b.a)(ye,2),Ae=Pe[0],Se=Pe[1],Te=Object(a.useContext)(ac),Ne=Object(b.a)(Te,2)[1],Ee=function(){l()},_e=function(){r(),m(),pe(!0)},Re=function(e){var t;Ce("Save"),W(e),(null!==(t=e.custom)&&void 0!==t?t:e.isNew)?Oe("Edit Custom Product"):je||e.custom?Oe("Add to Product List"):Oe("Edit Product"),je&&Ae.find((function(t){return t.id===e.id}))&&!e.isNew&&Oe("Edit Product"),Q(!0)},Ie=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,o,s,l,d;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!je){e.next=5;break}Ae.find((function(e){var n,a;return(null!==(n=e.id)&&void 0!==n?n:e.productId)===(null!==(a=t.id)&&void 0!==a?a:t.productId)}))?H.isNew||t.custom?((c=IS(t)).isNew=!0,c.producttype=t.type,c.productId=H.productId,o=Ae.findIndex((function(e){return e.productId===H.productId})),(s=Object(v.a)(Ae)).splice(o,1,c),Se(s),i.sendEventToAmplitude(i.events.epic.ProductList.editCustomProductCart,{productId:c.productId})):(n=Ae.findIndex((function(e){return e.productId===H.productId})),(a=Object(I.a)({},Ae[n])).averagePricePerUnit=t.averagePricePerUnit,a.packageWeight=null===t||void 0===t?void 0:t.packageWeight,(r=Object(v.a)(Ae)).splice(n,1,a),Se(r)):Se([].concat(Object(v.a)(Ae),[t])),e.next=17;break;case 5:if(!t.custom){e.next=11;break}return l=IS(t),e.next=9,T(l);case 9:e.next=14;break;case 11:return d=_S(t),e.next=14,A(d);case 14:N?(U("error"),R("Unable to save changes")):(U("success"),R("Changes saved.")),F(!0),Ee();case 17:Q(!1),W();case 19:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();Object(a.useEffect)((function(){n(h)}),[h]),Object(a.useEffect)((function(){l()}),[]),Object(a.useEffect)((function(){t(O)}),[O]),Object(a.useEffect)((function(){te(s)}),[s]),Object(a.useEffect)((function(){if(null!==s&&void 0!==s&&s.length){var e=s;se.length&&(e=s.filter((function(e){return se.map((function(e){return"CustomProduct"===e})).includes(e.custom)}))),re.length&&(e=e.filter((function(e){return re.map((function(e){return e.toUpperCase()})).includes(e.productType.toUpperCase())}))),te(e)}}),[re,se]);var De=function(){Ne({type:Zr,payload:"null"}),Ne({type:zr,payload:"null"}),Ne({type:Ur,payload:!1}),Ne({type:Yr,payload:!1}),F(!1)};return Object(y.jsxs)("div",{className:"h-full w-full p-4 flex flex-col","data-testid":"products",children:[Object(y.jsx)(lo,{hideCropSeasonDropdown:!0,children:Object(y.jsx)(lo.Item,{title:"Products",value:"All Products",isLast:!0})}),Object(y.jsxs)("div",{className:"flex items-center justify-between mb-4 h-8",children:[Object(y.jsxs)("div",{className:"flex py-2px h-full",children:[Object(y.jsx)("span",{className:"text-xl font-semibold mr-5",children:"Product List"}),Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(JV,{setSearchText:x})}),Object(y.jsx)(gV,{typeFilters:re,handleFilterChange:function(e,t,n){var a=n.map((function(e){return e.key}));ce(a)},typeFilterOptions:EM}),Object(y.jsx)(xV,{sourceFilters:se,handleFilterChange:function(e,t,n){var a=n.map((function(e){return e.key}));le(a)}})]}),Object(y.jsx)(AV,{onClick:_e}),Object(y.jsx)(qV,{visible:je,onClose:function(){r(),pe(!1),Se([])},setShowEditDrawer:Q,selectedProductsList:Ae,setSelectedProductsList:Se,handleOnEdit:Re,handleAddProductsSubmit:function(){if(Ae&&je){var e=[];Ae.filter((function(e){return!e.isNew})).forEach((function(t){var n;e.push(Object(I.a)({productId:t.id,averagePricePerUnit:null!==(n=t.averagePricePerUnit)&&void 0!==n?n:0},null!==t&&void 0!==t&&t.packageWeight?{packageWeight:parseFloat(null===t||void 0===t?void 0:t.packageWeight)}:{}))}));var t=Ae.filter((function(e){return e.isNew})).map((function(e){return{name:e.name,manufacturer:e.manufacturer,standardUnit:e.standardUnit,type:e.type,makeUp:e.makeUp,density:e.density,stdFactor:e.stdFactor,stdPackageUnit:e.stdPackageUnit,formulation:RS(e.formulation),averagePricePerUnit:e.averagePricePerUnit,organizationId:e.organizationId}}));S({itemsToUpdate:e,itemsToCreate:t}).then((function(){F(!0),R("Products added to list."),U("success"),pe(!1),r(),Se([]),Ee()})).catch((function(){F(!0),U("error"),R("Product not added.")}))}},handleOnAddCustomProduct:function(){var e={productId:Object(Wu.a)(),isNew:!0,custom:!0,formulation:{}};W(e),Oe("Add Custom Product"),Ce("Create Product"),Q(!0)}})]}),Object(y.jsx)(xT,{handleEdit:Ie,product:H,visible:K,onClose:function(){return Q(!1)},editProductHeader:ve,saveText:ge}),Object(y.jsx)("div",{className:"flex flex-auto justify-center",style:{maxHeight:"calc(100% - 3rem)"},children:Object(y.jsxs)("div",{className:"bg-white flex flex-col justify-center items-center ".concat(s.length||u?"flex-auto":"h-half"," w-full rounded-lg shadow-sm-card overflow-hidden border-1 border-neutral-30"),children:[Object(y.jsx)(TV,{products:ee,productsCount:de?ee.length:d,isLoading:u,loadingMessage:c.length?"Searching Products...":null,pageNo:j,setPageNo:p,onSort:f,sortBy:g,sortDir:C,getProducts:l,productToEdit:H,setProductToEdit:W,showEditDrawer:K,setShowEditDrawer:Q,handleOnEdit:Re,editProductHeader:ve,editProductSaveText:ge,handleEdit:Ie,setToastType:U,setToastMessage:R,setShowToast:F,refreshProducts:Ee,emptyState:de||c.length?Object(y.jsx)(jw,{overlayIcon:fw,message:"We were unable to find any products using the search & filter criteria. Try a different search and/or filter."}):Object(y.jsx)(jw,{overlayIcon:kP,title:"No Products Found",message:"To view your products, either create a production record or manually add a product.",button:Object(y.jsx)(AV,{onClick:_e})})}),function(){var e=null;return"Unable to remove product."===_?e="An error prevented your product(s) from being removed from your list. Please try again.":"Product not added."===_&&(e="An error prevented your product(s) from being added to your list. Please try again."),e?Object(y.jsxs)(Qc,{type:B,isBold:!0,open:L,title:_,onClose:De,timeout:-1,children:[Object(y.jsx)("div",{children:e}),Object(y.jsx)("div",{className:"flex flex-col",children:Object(y.jsx)(Xc.Button,{style:{alignSelf:"end",marginTop:"8px"},type:Xc.ButtonType.primary,onClick:function(){location.href="https://www.syngentadigital.com/us-en"},children:"Contact Support"})})]}):Object(y.jsx)(Qc,{type:B,isBold:!0,open:L,title:_,timeout:5e3,onClose:De})}()]})})]})}),QV=[{id:"products",key:"products",path:Cc.products,exact:!0,secure:!0,disabled:!1,component:function(){return Object(y.jsx)(MV,{children:Object(y.jsx)(KV,{})})},icon:cd,nav:"leftNav"},{id:"productdetails",key:"productdetails",path:"".concat(Cc.products,"/:id/view"),exact:!0,secure:!0,disabled:!1,component:hV}],XV=function(e){var t=e.profilePicture;return Object(a.useEffect)((function(){}),[t]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex","data-testid":"profile-fields",children:[Object(y.jsx)("div",{className:"w-1/2 pr-5",children:Object(y.jsx)(m.Form.Field,{label:"First Name",children:Object(y.jsx)(m.Input,{name:"firstName",value:""})})}),Object(y.jsx)("div",{className:"w-1/2 pl-5",children:Object(y.jsx)(m.Form.Field,{label:"Last Name",children:Object(y.jsx)(m.Input,{name:"lastName",value:""})})})]}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{className:"w-1/2 pr-5",children:Object(y.jsx)(m.Form.Field,{label:"Display Name",children:Object(y.jsx)(m.Input,{name:"displayName",value:""})})}),Object(y.jsx)("div",{className:"w-1/2 pl-5 ",children:Object(y.jsxs)("label",{htmlFor:"profilePicture",className:"hover:bg-gray-100 hover:cursor-pointer p-2 h-full w-full h-16 block transition duration-200 rounded",children:[Object(y.jsx)("div",{className:"w-16 h-16 rounded-full bg-gray-400 mr-5 inline-block align-middle",children:t&&Object(y.jsx)("img",{src:t.src,alt:"upload preview",className:"h-full object-cover"})}),Object(y.jsx)("input",{type:"file",className:"absolute invisible",name:"profilePicture",id:"profilePicture"}),Object(y.jsx)("div",{className:"inline-block align-middle pointer pointer-events-none",children:Object(y.jsx)("div",{className:"text-gray-600 font-bold",children:t?t.name:"Profile Picture"})})]})})]})]})};XV.defaultProps={profilePicture:null};var $V,eB=XV,tB=function(){return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.Columns,{wrap:!0,children:[Object(y.jsx)(m.Column,{width:"w-1/2 pr-5",children:Object(y.jsx)(m.Form.Field,{label:"Email",children:Object(y.jsx)(m.Input,{name:"email",value:""})})}),Object(y.jsx)(m.Column,{width:"w-1/2 pl-5",children:Object(y.jsx)(m.Form.Field,{label:"Phone Number",children:Object(y.jsx)(m.Input,{name:"phoneNumber",value:""})})}),Object(y.jsx)(m.Column,{width:"w-1/2 pr-5",children:Object(y.jsx)(m.Form.Field,{label:"Address Line 1",children:Object(y.jsx)(m.Input,{name:"addressLine1",value:""})})}),Object(y.jsx)(m.Column,{width:"w-1/2 pl-5",children:Object(y.jsx)(m.Form.Field,{label:"Address Line 2",children:Object(y.jsx)(m.Input,{name:"addressLine2",value:""})})}),Object(y.jsx)(m.Column,{width:"w-1/2 pr-5",children:Object(y.jsx)(m.Form.Field,{label:"City",children:Object(y.jsx)(m.Input,{name:"city",value:""})})}),Object(y.jsx)(m.Column,{width:"w-1/2 pl-5",children:Object(y.jsx)(m.Form.Field,{label:"State",children:Object(y.jsx)(m.Input,{name:"state",value:""})})}),Object(y.jsx)(m.Column,{width:"w-1/2 pr-5",children:Object(y.jsx)(m.Form.Field,{label:"Zip / Postcode",children:Object(y.jsx)(m.Input,{name:"postcode",value:""})})}),Object(y.jsx)(m.Column,{width:"w-1/2 pl-5",children:Object(y.jsx)(m.Form.Field,{label:"Country",children:Object(y.jsx)(m.Select,{name:"country"})})})]})})},nB=function(){var e=Object(a.useState)({}),t=Object(b.a)(e,2),n=t[0],r=t[1];return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)("div",{className:"mb-5","data-testid":"profile",children:Object(y.jsx)(m.Card,{children:Object(y.jsxs)("form",{onChange:function(e){return function(e){var t=e.target,n=t.name,a="";a="checkbox"===t.type?t.checked:"file"===t.type?{name:t.files[0].name,src:URL.createObjectURL(t.files[0])}:t.value,r((function(e){return Object(I.a)(Object(I.a)({},e),{},Object(et.a)({},n,a))}))}(e)},children:[Object(y.jsxs)("div",{className:"p-5",children:[Object(y.jsx)("div",{className:"text-2xl font-light text-gray-700",children:"Profile"}),Object(y.jsx)(eB,{profilePicture:n&&n.profilePicture})]}),Object(y.jsxs)("div",{className:"p-5",children:[Object(y.jsx)("div",{className:"text-2xl font-light text-gray-700",children:"Contact Info"}),Object(y.jsx)(tB,{}),Object(y.jsx)("div",{className:"text-right",children:Object(y.jsx)("div",{className:"inline-block pl-4","data-testid":"save",children:Object(y.jsx)(m.Button,{type:"primary",children:" Save"})})})]})]})})})})},aB=[{id:"profile",key:"profile",path:"/app/profile",exact:!0,secure:!0,component:nB}],rB=function(e,t,n){!e.target.value>0||/^\s+$/.test(e.target.value)?(n("Required"),t(e.target.value)):(n(""),t(e.target.value))},cB=function(e){var t=e.open,n=e.onCancel,r=e.onCreate,c=Object(a.useState)(""),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(""),f=Object(b.a)(p,2),v=f[0],O=f[1];Object(a.useEffect)((function(){t||(s(""),O(""))}),[t]);var h=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(j(!0),!o){e.next=4;break}return e.next=4,r(o);case 4:j(!1);case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)(ao,{close:n,open:t,title:"Create New Farm",cancelLabel:"Cancel",onCancel:function(){n(),j(!1)},onConfirm:h,confirmLabel:"Save",isSaving:u,hasError:"Required"===v||""===o,children:Object(y.jsx)("div",{"data-testid":"create-property-modal-body",className:"my-8 pr-8",children:Object(y.jsx)(m.Input,{id:"create-property-modal-name",label:"Farm Name*",value:o||"",onChange:function(e){return rB(e,s,O)},error:v,errorMessage:v,autoFocus:!0})})})},iB=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=Object(a.useState)(),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)([]),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useState)(!0),O=Object(b.a)(m,2),h=O[0],x=O[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),y=C[0],P=C[1],A=Object(a.useState)(ub),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(hv),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useRef)(!1),k=Object(a.useContext)(ac),L=Object(b.a)(k,2),F=L[1],M=Object(a.useCallback)((function(){var e=fn.fetch(null,null,{headers:{"Local-Cache":!0}},null,!1),t=e.promise,n=e.cancel;return t.then((function(e){var t=e.data;return d(t)})).catch(Ae.default).catch(uc(F)).finally((function(){return x(!1)})),{promise:t,cancel:n}}),[F]),V=Object(a.useCallback)((function(){x(!0);var t=pn.fetch(e),n=t.promise,a=t.cancel;return n.then((function(e){var t=e.data;return f(t)})).catch(Ae.default).catch(uc(F)).finally((function(){return x(!1)})),{promise:n,cancel:a}}),[F,e]);Object(a.useEffect)((function(){t&&(Object(ne.isNil)(e)?M():V(e))}),[V,M,e,t]);var B=Object(a.useCallback)((function(e){return D.current?Promise.reject(new Error("save already in progress")):(D.current=!0,pn.create(e).promise.then((function(e){var t=e.data;return d((function(e){return[].concat(Object(v.a)(e),[t])})),t})).catch(Ae.default).catch(uc(F)).finally((function(){D.current=!1})))}),[F]),U=Object(a.useCallback)((function(t){return x(!0),P(!0),D.current?(x(!1),P(!1),Promise.reject(new Error("edit already in progress"))):(D.current=!0,pn.update(e,t).promise.then((function(t){var n=t.data;return d((function(t){return t.map((function(t){return t.id===e?Object(I.a)(Object(I.a)({},t),n):t}))})),i("success"),f(n),n})).catch(Ae.default).catch(uc(F)).catch(i("error")).finally((function(){D.current=!1,x(!1),P(!1)})))}),[F,e]),z=Object(a.useCallback)((function(e){R((function(e){return xv(e)})),pn.createChildApi({action:"farm/".concat(e,"/archive")}).post().promise.then((function(){R((function(e){return Cv(e)}))})).catch(Ae.default).catch((function(e){R((function(t){return gv(t,e)})),uc(F)})).finally((function(){R((function(e){return yv(e)}))}))}),[F]),Z=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:R((function(e){return xv(e)})),n=pn.createChildApi({action:"farm/".concat(t,"/unarchive")}),a=n.post(),a.promise.then((function(){R((function(e){return Cv(e)}))})).catch(Ae.default).catch((function(e){R((function(t){return gv(t,e)})),uc(F)})).finally((function(){R((function(e){return yv(e)}))}));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),H=Object(a.useCallback)((function(){return D.current?Promise.reject(new Error("delete already in progress")):(D.current=!0,pn.delete(e).promise.then((function(t){var n=t.data;return d((function(t){return t.filter((function(t){return t.id!==e}))})),n})).catch(Ae.default).catch(uc(F)).finally((function(){return D.current=!1,D.current})))}),[F,e]);return{state:c,farms:l,farm:p,loading:h,saving:y,createFarm:B,fetchFarms:M,zoom:T,setZoom:N,fetchFarmById:V,editFarm:U,archive:_,archiveFarm:z,unarchiveFarm:Z,deleteFarm:H}},oB=(n(370),n.p+"static/media/filter_outlined.6b3f92bd.svg"),sB=["title","titleId"];function lB(){return lB=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},lB.apply(this,arguments)}function dB(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function uB(e,t){var n=e.title,r=e.titleId,c=dB(e,sB);return a.createElement("svg",lB({width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,$V||($V=a.createElement("path",{d:"M14.25 4.8075L13.1925 3.75L9 7.9425L4.8075 3.75L3.75 4.8075L7.9425 9L3.75 13.1925L4.8075 14.25L9 10.0575L13.1925 14.25L14.25 13.1925L10.0575 9L14.25 4.8075Z",fill:"#696F88"})))}var bB,jB=a.forwardRef(uB),pB=(n.p,["title","titleId"]);function fB(){return fB=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},fB.apply(this,arguments)}function mB(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function vB(e,t){var n=e.title,r=e.titleId,c=mB(e,pB);return a.createElement("svg",fB({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,bB||(bB=a.createElement("path",{d:"M15.7049 16.59L11.1249 12L15.7049 7.41L14.2949 6L8.29492 12L14.2949 18L15.7049 16.59Z",fill:"#696F88"})))}var OB=a.forwardRef(vB),hB=(n.p,function(e){var t=e.title,n=e.showGoBack,r=e.className,c=Object(a.useContext)(ac),i=Object(b.a)(c,2),o=i[0].isMassAssignerActive,s=i[1];return o?null:Object(y.jsxs)(Xc.Row,{className:"flex flex-wrap justify-start ml-1",children:[n&&Object(y.jsx)(m.Button,{ariaLabel:"back",style:{marginRight:"0.5rem"},type:"text",icon:Object(y.jsx)(OB,{}),onClick:function(){s({type:Tr,payload:!0}),s({type:gr,payload:!1}),s({type:Pr,payload:[]}),s({type:Cr,payload:!1})}}),Object(y.jsx)(Xc.Col,{className:"".concat(n?"text-xl":"text-3xl"," font-semibold ").concat(r),children:t})]})});hB.defaultProps={className:""};var xB=hB,gB=function(e){var t=e.onBlur,n=e.onChange,a=e.onFocus,r=e.placeholder,c=e.value,i=e.drawer,o=mo().width;return Object(y.jsx)("div",{"data-testid":"SearchInputLandingProperties",className:i?"":"pr-2",children:Object(y.jsx)(Xc.Input,Object(I.a)(Object(I.a)(Object(I.a)({"data-testid":"search-input",style:{margin:0},prefix:Object(y.jsx)("img",{alt:"Search icon",src:Fi}),allowClear:!0,type:"default",autoComplete:"off",placeholder:o<=386?"Search...":r,onChange:n},a?{onFocus:a}:{}),t?{onBlur:t}:{}),{},{value:c}))})};gB.defaultProps={placeholder:"",value:"",drawer:!1,onBlur:void 0,onFocus:void 0};var CB=gB,yB=function(e){var t,n,r=e.showTools,c=e.title,i=e.showGoBack,o=e.reloadFarmData,s=e.openFilters,l=e.view,d=e.loading,u=e.onChangeView,j=iB(null,!1).createFarm,p=Object(a.useContext)(ac),m=Object(b.a)(p,2),v=m[0],O=v.searchTextValueFFT,h=v.organization,x=v.selectedProperty,g=v.isExportPDFMapsActive,C=v.isExportPDFMapsAlertDismissed,P=m[1],A=Object(a.useState)(!1),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(!1),w=Object(b.a)(E,2),_=w[0],R=w[1],I=av().hasActiveFilters,D=Object(a.useState)((null===O||void 0===O?void 0:O.valueInput)||""),k=Object(b.a)(D,2),L=k[0],F=k[1],M=zi(L,1e3),V=null===ac||void 0===ac||null===(t=ac._currentValue[0])||void 0===t||null===(n=t.organization)||void 0===n?void 0:n.id,B=Object(f.useFlags)(),U=B.feArchiveField,z=B.feArchiveFieldOrgIds,Z=B.feFarmsFilter,H=B.fePropertyDetails,W=B.fePropertyDetailsByOrgId,q=U||-1!==(null===z||void 0===z?void 0:z.indexOf(V)),J=H||(null===W||void 0===W?void 0:W.includes(null===h||void 0===h?void 0:h.id)),K=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,j({name:t,timeZone:"US/Central",referencePoint:{type:"Point",coordinates:[0,0]}});case 2:o(),N(!1);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Q=I&&(M||_);return Object(a.useEffect)((function(){M!==(null===O||void 0===O?void 0:O.valueInput)&&(!M||M.length>=3)&&P({type:_r,payload:{valueInput:M}})}),[M,P,null===O||void 0===O?void 0:O.valueInput]),Object(y.jsxs)("div",{className:"pb-4 sticky top-0 z-4 pt-4 white-bg px-5",children:[Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)(xB,{title:g?"Export PDF Maps":c,showGoBack:g||i})}),r&&Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{"data-testid":"selected-property-toolbar",className:"justify-left w-full selected-property-toolbar ".concat(x.id&&"mt-4"),children:x.id?Object(y.jsx)(Ih,{showPropertyDetails:J,view:l,onChangeView:u,loading:d}):null}),g&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(Xc.Steps,{size:"small",className:"mt-4",children:[Object(y.jsx)(Xc.Steps.Step,{title:"Define area"}),Object(y.jsx)(Xc.Steps.Step,{title:"Customize layout",disabled:!0})]}),!C&&Object(y.jsx)(Xc.Alert,{className:"mt-4 p-2",closeText:Object(y.jsx)(jB,{}),description:"Overlapping properties may not display properly in print.",showIcon:!0,type:"info",onClose:function(){P({type:yr})}})]}),Object(y.jsxs)("div",{className:"flex ".concat(g?"mt-4":"mt-2"),children:[Object(y.jsx)("div",{className:"w-full pt-1",children:Object(y.jsx)(CB,{onBlur:function(){R(!1)},onFocus:function(){R(!0)},onChange:function(e){F(e.target.value.toLowerCase())},placeholder:"Search Properties...",value:L,dispatch:P,drawer:!0})}),Object(y.jsxs)("div",{className:"relative pt-1",children:[(q||Z)&&Object(y.jsx)("button",{"data-testid":"panel-filter-button",type:"button",className:"ml-2 w-10 h-8 flex items-center justify-center rounded-md hover:bg-neutral-100 bg-white",style:{border:"1px solid #C2C7D0"},onClick:s,children:Object(y.jsx)("img",{src:oB,alt:""})}),I&&Object(y.jsx)("div",{className:"w-10px h-10px rounded-full bg-blue-90 absolute",style:{top:0,right:"-4px"}})]})]}),Q&&Object(y.jsxs)("div",{className:"flex px-2 mt-2",children:[Object(y.jsx)("img",{alt:"info",src:B_,className:""}),Object(y.jsx)("span",{className:"text-sm text-gray-700 ml-1",children:"Filter will affect search results."})]})]})]}),Object(y.jsx)(cB,{open:T,onCancel:function(){return N(!1)},onCreate:K})]})};yB.defaultProps={showTools:!1,showGoBack:!1,reloadFarmData:function(){},openFilters:function(){},onChangeView:function(){},view:"map"};var PB=yB,AB=n.p+"static/media/bulk_actions.25470e82.svg";var SB=function(e,t){return null!==e&&void 0!==e&&e.features?e.features.map((function(e){var n,a,r;return Object(ne.set)(e,"properties.$layer",t!==(null===(n=e.properties)||void 0===n?void 0:n.id)&&(t!==(null===(a=e.properties)||void 0===a?void 0:a.propertyId)||null!==(r=e.properties)&&void 0!==r&&r.$parentDuplicated)?"default":"selected"),e})):[]},TB={},NB=Object(a.createContext)(TB),EB=NB,wB=Sd(Od,Sb);function _B(e){var t,n=e.children,r=Object(a.useContext)(we),c=Object(p.h)(),i=Object(f.useFlags)(),o=Object(a.useContext)(ac),s=Object(b.a)(o,2),l=s[0],d=l.organization,u=l.selectedProperty,j=l.loggedInUserOrgPermission,m=l.searchTextValueFFT,v=s[1],O=((null===d||void 0===d?void 0:d.properties)||{}).propertyCount,h=(null===(t=i.configureLargeGrowerConditionals)||void 0===t?void 0:t.propertiesThreshold)&&O>=i.configureLargeGrowerConditionals.propertiesThreshold,x=Object(a.useState)({page:0}),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)(wB.get()),k=Object(b.a)(D,2),L=k[0],F=k[1],M=rv({fetchType:h?hm:xm,isCacheOn:!1}),V=M.loading,B=M.zoom,U=M.setZoom,z=M.dataSorted,Z=M.reloadData,Y=M.fieldsAndAreasGeoJSONCollection,H=M.setGeoJSONCollectionFeatures,G=M.fieldsLoading,W=M.filterFeatureCollectionByParentId,q=M.fetchFarmCosts,J=M.isLoadingPaginatedProperties,K=M.pagination,Q=yc(i.releaseCostAnalysisViewEnable,i.releaseCostAnalysisViewEnableByOrg,d.id),X=yc(i.fePropertyDetails,i.fePropertyDetailsByOrgId,null===d||void 0===d?void 0:d.id),$=Object(a.useCallback)((function(e){F(e),wB.save(e)}),[]),ee=Object(a.useCallback)((function(e,t){var n=Object(I.a)({},e);t&&(n.type=t),jc(v,fr,n)}),[]),te=Object(a.useCallback)((function(e){if(!e||(null===e||void 0===e?void 0:e.id)===(null===u||void 0===u?void 0:u.id))return N(null),ee(),void W(Y);var t="Crop Zone";"fields"in e&&(t="Farm",N(null),q(e.id)),"cropzones"in e&&(t="Field",N(e.id),jc(v,xr,{id:e.id})),null!==e&&void 0!==e&&e.$parentFieldId&&jc(v,xr,{id:e.$parentFieldId}),ee(e,t),H(null!==e&&void 0!==e&&e.isFromMap?SB(Y,e.id):W(Y,e.id))}),[v,u,H,Y.features,W]);Object(a.useEffect)((function(){(null===j||void 0===j?void 0:j.role)!==$a&&(null===j||void 0===j?void 0:j.role)!==er||Object.prototype.hasOwnProperty.call(j,"financialAccess")?R(null===j||void 0===j?void 0:j.financialAccess):R("none")}),[j]),Object(a.useEffect)((function(){P({page:0,textSearch:null===m||void 0===m?void 0:m.valueInput})}),[m]),Object(a.useEffect)((function(){F(wB.get())}),[d]),Object(a.useEffect)((function(){(function(e){var t=e.selectedProperty,n=e.currentView,a=e.isCostAnalysisViewEnabled,r=!(null!==t&&void 0!==t&&t.id)&&n!==Sb,c=(null===t||void 0===t?void 0:t.id)&&n===Nb&&"Farm"===t.type;return r||c||!a&&n===Nb})({selectedProperty:u,currentView:L,isCostAnalysisViewEnabled:Q})&&F(Sb)}),[u,L,Q]),Object(a.useEffect)((function(){h&&r.sendEventToAmplitude(r.events.epic.Organization.paginatedProperties,{organizationId:null===d||void 0===d?void 0:d.id})}),[d.id,h]);var ne="Farm"===(null===u||void 0===u?void 0:u.type),ae="Field"===(null===u||void 0===u?void 0:u.type),re="Crop Zone"===(null===u||void 0===u?void 0:u.type);return Object(y.jsx)(NB.Provider,{value:{params:C,setParams:P,pagination:K,isCostAnalysisViewEnabled:Q,isPropertyDetailsEnabled:X,isFarmSelected:ne,isFieldSelected:ae,isCropZoneSelected:re,isLoadingPaginatedProperties:J,isHugeOrganization:h,selectedProperty:u,selectedField:T,financialAccess:_,viewMode:L,onViewModeChange:$,onDrawFieldsClick:function(e,t){r.sendEventToAmplitude(r.events.epic.Properties.createField);var n=null;if("Farm"===e.type)n=e.id;else if("Field"===e.type){n=(null===t||void 0===t?void 0:t.filter((function(t){var n;return null===t||void 0===t||null===(n=t.fields)||void 0===n?void 0:n.find((function(t){return t.id===e.id}))})).pop()).id}c.push("".concat(Cc.properties,"/create"),{selectedId:n})},isLoadingProperties:V,isLoadingFields:G,propertyZoom:B,propertyLandingPageData:z,fieldsAndAreasGeoJSONCollection:Y,setGeoJSONCollectionFeatures:H,filterFeatureCollectionByParentId:W,fetchFarmCosts:q,fetchProperties:Z,onPropertySetZoom:U,onPropertySelection:te},children:n})}var RB=function(e){var t=e.setOpenFarmModal,n=e.openCreateModal,r=e.setView,c=Object(p.h)(),i=Object(a.useContext)(EB),o=i.propertyLandingPageData,s=i.isFarmSelected,l=Object(a.useContext)(ac),d=Object(b.a)(l,2),u=d[0],j=u.selectedProperty,v=u.selectedFieldRowId,O=u.organization.id,h=d[1],x=Object(f.useFlags)(),g=x.releaseFePropertyLandingBulkActions,C=x.releaseFePropertyLandingBulkActionsByOrg,P=function(){r&&r("map"),h({type:fr,payload:{}}),h({type:gr,payload:!0})},A=function(){var e;return s?null===j||void 0===j?void 0:j.parentPage:null===(e=((null===o||void 0===o?void 0:o.properties)||[]).find((function(e){return e.id===(null===j||void 0===j?void 0:j.farmId)})))||void 0===e?void 0:e.parentPage},S=g||(null===C||void 0===C?void 0:C.includes(O));return Object(y.jsxs)("div",{className:"flex justify-between","data-testid":"properties-actions",children:[S?Object(y.jsx)(m.Popup,{containerClasses:"popup-width mr-2",position:"top",trigger:Object(y.jsx)(Xc.Button,{style:{width:"149px",padding:"0 22px"},icon:Object(y.jsx)("img",{width:18,src:AB,alt:"edit"}),type:Xc.ButtonType.outline,children:"Bulk Actions"}),children:Object(y.jsxs)(m.Menu,{children:[Object(y.jsx)(m.Menu.Item,{onClick:P,selectable:!0,children:Object(y.jsx)("span",{className:"ml-2",children:"Bulk Edit"})}),Object(y.jsx)(m.Menu.Item,{onClick:function(){r&&r("map"),h({type:fr,payload:{}}),h({type:Cr,payload:!0})},selectable:!0,children:Object(y.jsx)("span",{className:"ml-2",children:"Export PDF Maps"})})]})}):Object(y.jsx)(Xc.Button,{style:{width:"149px",padding:"0 32px"},icon:Object(y.jsx)("img",{width:18,src:DI,alt:"edit"}),type:Xc.ButtonType.outline,onClick:P,children:"Bulk Edit"}),Object(y.jsx)(m.Popup,{containerClasses:"popup-width",position:"top",trigger:Object(y.jsx)(Xc.Button,{style:{width:"149px"},icon:Object(y.jsx)(Ii.a,{}),type:Xc.ButtonType.success,ghost:!0,children:"New Property"}),children:Object(y.jsxs)(m.Menu,{children:[Object(y.jsxs)(m.Menu.Item,{onClick:function(){return t(!0)},selectable:!0,children:[Object(y.jsx)(qC,{}),Object(y.jsx)("span",{className:"ml-2",children:"Farm"})]}),Object(y.jsxs)(m.Menu.Item,{onClick:function(){return n(!0)},selectable:!0,children:[Object(y.jsx)(JC,{}),Object(y.jsx)("span",{className:"ml-2",children:"Field"})]}),("Field"===(null===j||void 0===j?void 0:j.type)||"Crop Zone"===(null===j||void 0===j?void 0:j.type))&&Object(y.jsxs)(m.Menu.Item,{onClick:function(){c.push("".concat(Cc.properties,"/create/").concat("Field"===(null===j||void 0===j?void 0:j.type)?j.id:v.id,"/cropzone"),{parentPage:A()})},selectable:!0,children:[Object(y.jsx)(KC,{}),Object(y.jsx)("span",{className:"ml-2",children:"Crop Zone"})]})]})})]})},IB=function(e){var t=e.showTools,n=e.reloadFarmData,r=e.openCreateModal,c=e.setView,i=iB(null,!1).createFarm,o=Object(a.useState)(!1),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useContext)(ac),j=Object(b.a)(u,1)[0],p=j.isMassAssignerActive,f=j.loggedInUserOrgPermission,m=j.isExportPDFMapsActive,v=f.role,O=f.financialAccess,h=Object(a.useMemo)((function(){return!or({role:v,financialAccess:O},{minAllowedRole:$a,minFinancialAccess:ar})}),[v,O]),x=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i({name:t,timeZone:"US/Central",referencePoint:{type:"Point",coordinates:[0,0]}});case 2:n(),d(!1);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return p||m||h?null:Object(y.jsxs)("div",{className:"p-4 sticky top-0 z-4 white-bg border-t-1 border-neutral-20",children:[Object(y.jsx)("div",{children:t&&Object(y.jsx)(RB,{setOpenFarmModal:d,openCreateModal:r,setView:c})}),Object(y.jsx)(cB,{open:l,onCancel:function(){return d(!1)},onCreate:x})]})};IB.defaultProps={showTools:!1,reloadFarmData:function(){}};var DB=IB,kB=n(2826),LB=function(e){var t=e.openCreateModal,n=e.memberRole,r=e.memberFinancialAccess,c=Object(a.useCallback)((function(){return"View Only"!==n||"READ"!==r&&"none"!==r}),[n,r]);return Object(y.jsxs)("div",{className:"flex flex-col justify-center pt-16",children:[Object(y.jsx)("div",{className:"self-center",children:Object(y.jsx)("img",{src:Of,alt:"",width:"80%",style:{marginLeft:"auto",marginRight:"auto"}})}),Object(y.jsxs)("div",{className:"self-center mb-6",children:[Object(y.jsx)("p",{className:"text-sm text-center",children:"We were unable to find any properties"}),Object(y.jsx)("p",{className:"text-sm text-center",children:"under this organization."})]}),Object(y.jsx)("div",{className:"self-center",children:c()&&Object(y.jsxs)(m.Button,{onClick:function(){t(!0)},id:"overlay-create-property-btn",type:"primary",children:[Object(y.jsx)(kB.a,{}),"Create Fields"]})})]})},FB=function(e,t,n){var r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(ae.a.cloneDeep(e)),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(0),p=Object(b.a)(j,2),f=p[0],m=p[1];Object(a.useEffect)((function(){var e=d.reduce((function(e,t){return e+=t.fields.length}),0);m(e)}),[d]),Object(a.useEffect)((function(){t.length>0&&o(f===t.length)}),[t,f]);return{handleSelectedFarm:function(e){e.selected=!e.selected;var a=[];if(e.selected){var r=ae.a.cloneDeep(e.fields).map((function(t){return Object(I.a)(Object(I.a)({},t),{},{farmName:e.name,farmId:e.id})}));ae.a.pullAllWith(t,r,ae.a.isEqual),a=[].concat(Object(v.a)(t),Object(v.a)(r))}else a=t.filter((function(t){var n=Object(I.a)({},t);return delete n.farmName,delete n.farmId,ae.a.findIndex(e.fields,n)<0}));n({type:Pr,payload:a})},handleSelectedField:function(e,a){var r=ae.a.cloneDeep(Object(I.a)(Object(I.a)({},a),{},{farmName:e.name,farmId:e.id})),c=ae.a.findIndex(t,r)>=0,i=t.some((function(e){var t=e.id;return r.id===t})),s=[];c?(s=t.filter((function(e){return e.id!==a.id})),o(!1)):s=i?t.map((function(e){return e.id!==a.id?e:r})):[].concat(Object(v.a)(t),[r]);var l=e.fields.every((function(e){return ae.a.findIndex(s,e)>=0}));e.selected=l,n({type:Pr,payload:s})},isCropzoneSelected:function(e){return t.some((function(t){return t.cropzones.some((function(t){return t.id===e.id}))}))},handleSelectedCropzone:function(e,a,r){var c=t.some((function(e){return e.id===a.id})),i=t.some((function(e){return ae.a.findIndex(e.cropzones,r)>=0})),s=[];if(i)s=(s=t.map((function(e){return a.id===e.id&&(e.cropzones=ae.a.pullAllWith(e.cropzones,[r],ae.a.isEqual)),e}))).filter((function(e){var t;return e.id!==a.id||(null===(t=e.cropzones)||void 0===t?void 0:t.length)>0})),o(!1);else if(c)s=t.map((function(e){return a.id===e.id&&e.cropzones.push(r),e}));else{var l=Object(I.a)(Object(I.a)({},a),{},{farmName:e.name,farmId:e.id,cropzones:[r]});s=[].concat(Object(v.a)(t),[l])}var d=e.fields.every((function(e){return ae.a.findIndex(s,e)>=0}));e.selected=d,n({type:Pr,payload:s})},handleSelectAllProperties:function(){var e=!i;o(e);var t=[];e?(u(d.map((function(e){return e.selected=!0,ae.a.cloneDeep(e)}))),t=ae.a.flatten(d.map((function(e){return e.fields.map((function(t){return Object(I.a)(Object(I.a)({},t),{},{farmName:e.name,farmId:e.id})}))})))):(u(d.map((function(e){return e.selected=!1,ae.a.cloneDeep(e)}))),t=[]);n({type:Pr,payload:t})},selectedAllProperties:i,localProperties:d}},MB=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2),n=t[0].cropSeasons,r=t[1],c=Object(a.useState)({active:[],upcoming:[],past:[]}),i=Object(b.a)(c,2),o=i[0],s=i[1],l=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=$t.fetch(t),a=n.promise,e.abrupt("return",a.then((function(e){return e.data})).catch(Ae.default).catch(uc(r)));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),d=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=$t.update(t,n),c=a.promise,e.abrupt("return",c.then((function(e){return e.data})).catch(Ae.default).catch(uc(r)));case 2:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),u=Object(a.useCallback)((function(){var e=(new Date).getTime(),t={active:[],upcoming:[],past:[]};n.forEach((function(n){e>n.startDateEpoch?e>n.endDateEpoch?t.past.push(n):t.active.push(n):t.upcoming.push(n)})),s(t)}),[n]),j=function(e,t,n){var a={};return a[t]={farmId:t,cropzoneIds:[n]},e.forEach((function(e){var t=e.farmId,n=e.cropzoneId;a[t]?a[t].cropzoneIds.find((function(e){return e===n}))||a[t].cropzoneIds.push(n):a[t]={farmId:t,cropzoneIds:[n]}})),Object.values(a)},p=function(e,t,n){var a={};return a[t]={farmId:t,cropzoneIds:[]},e.forEach((function(e){var t=e.farmId,r=e.cropzoneId;a[t]?r!==n&&a[t].cropzoneIds.push(r):a[t]={farmId:t,cropzoneIds:[r]}})),Object.values(a).filter((function(e){return e.cropzoneIds.length}))};return{getCropSeason:l,updateCropSeason:d,dividedCropSeasons:o,splitCropSeasons:u,prepareCropSeason:function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=e.id,c=e.name,i=e.notes,o=e.startDateEpoch,s=e.endDateEpoch,l=e.cropZones,d=a?p(l,t,n):j(l,t,n);return{id:r,name:c,notes:i,properties:d,endDateEpoch:s,startDateEpoch:o,createdDate:e.createdDate,createdDateEpoch:e.createdDateEpoch}}}},VB=function(e,t,n){var a=""!==t.crop.name,r=t.season.name;("Add"===e&&r&&a||"Add"!==e&&a)&&n()},BB=function(e){return null===e||void 0===e?void 0:e.filter((function(e){return e.cropzones.length>0}))},UB=function(e){return(null===e||void 0===e?void 0:e.map((function(e){return{key:e.id,value:e.name}})))||[]},zB="88888888-8888-8888-8888-888888888888",ZB=function(e){var t,n=e.open,r=e.onClose,c=Object(a.useContext)(ac),i=Object(b.a)(c,2),o=i[0],s=o.fieldsToMassiveAssign,l=o.massiveChangeSummary,d=i[1],u=MB(),j=u.splitCropSeasons,p=u.dividedCropSeasons,f=Du().crops,v=Object(a.useState)(""),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1],S=UB(f),T=JSON.parse(localStorage.getItem("selectedCropSeasons")),N=Object(a.useMemo)((function(){return!T.includes(zB)&&(p.active.length||p.past.length||p.upcoming.length)?function(){var e,t,n,a,r,c,i=p.active,o=p.past,s=p.upcoming,l=[],d=[],u=[];return(null===i||void 0===i?void 0:i.length)>0&&(l=null===(a=UB(i))||void 0===a?void 0:a.filter((function(e){return T.includes(e.key)}))),(null===o||void 0===o?void 0:o.length)>0&&(d=null===(r=UB(o))||void 0===r?void 0:r.filter((function(e){return T.includes(e.key)}))),(null===s||void 0===s?void 0:s.length)>0&&(u=null===(c=UB(s))||void 0===c?void 0:c.filter((function(e){return T.includes(e.key)}))),(null===(e=l)||void 0===e?void 0:e.length)>0?l:(null===(t=d)||void 0===t?void 0:t.length)>0?d:(null===(n=u)||void 0===n?void 0:n.length)>0?u:[]}():[{key:"",value:"+ Create New Crop Season"}]}),[p]),E=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:d({type:Ar,payload:Object(I.a)(Object(I.a)(Object(I.a)({},l),t),{},{fieldsToMassiveAssign:"Changed"===l.action?BB(s):s})}),r();case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();Object(a.useEffect)((function(){j()}),[j]),Object(a.useEffect)((function(){1===T.length&&x(T[0])}),[T]);var w,_=Object(a.useMemo)((function(){return!T.includes(zB)&&1===(null===T||void 0===T?void 0:T.length)&&(p.active.length>0||p.past.length>0||p.upcoming.length>0)}),[p]),R="Added"===l.action?"Add":"Change";return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Zi.e,{initialValues:{season:{id:h,name:null===(t=N.find((function(e){return e.key===h})))||void 0===t?void 0:t.value},crop:{id:"",name:""}},validationSchema:(w=R,"Add"===w?Fu.e().shape({season:Fu.f().required(),crop:Fu.f().required()}):Fu.e().shape({crop:Fu.f().required()})),onSubmit:E,enableReinitialize:!0,children:function(e){var t,a,c=e.submitForm,i=e.setFieldValue,o=e.isSubmitting,s=e.resetForm,l=e.values;return Object(y.jsxs)(m.SimpleModal,{type:"basic",open:n,close:function(){s(),r()},confirmLabel:"Save",isSaving:o,onConfirm:function(){VB(R,l,c)},children:[Object(y.jsxs)("h1",{className:"text-base font-bold",children:[R," Crop Zone(s)"]}),Object(y.jsxs)("div",{className:"flex-col mt-3",children:["Add"===R&&Object(y.jsxs)("div",{className:"mb-4",children:[Object(y.jsx)("label",{htmlFor:"season",className:"text-neutral-600 text-sm inline-block",children:"Crop Season*"}),Object(y.jsx)(Qi,{control:m.Search,name:"season",items:N,placeholder:"Select Crop Season",onSelect:function(e){return function(e,t){e.key?(t("season.name",e.value),t("season.id",e.key)):A(!0)}(e,i)},disabled:_,selectedValue:null===(t=l.season)||void 0===t?void 0:t.id})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("label",{htmlFor:"crop",className:"text-neutral-600 text-sm inline-block",children:"Crop*"}),Object(y.jsx)(Qi,{control:m.Search,name:"crop",items:S,placeholder:"Select Crop",onSelect:function(e){i("crop.id",e.key),i("crop.name",e.value)},selectedValue:null===(a=l.crop)||void 0===a?void 0:a.id})]})]})]})}}),P&&Object(y.jsx)($i,{open:P,onClose:function(){return A(!1)}})]})},YB=function(e){var t=e.reportedArea,n=e.boundaryArea;return t>0?t:n},HB=function(e){return e.reduce((function(e,t){return e+YB(t)}),0)},GB=function(e){var t=e.fill;return Object(y.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13.244 2.25C13.0565 2.25 12.8615 2.325 12.719 2.4675L11.3465 3.84L14.159 6.6525L15.5315 5.28C15.824 4.9875 15.824 4.515 15.5315 4.2225L13.7765 2.4675C13.6265 2.3175 13.439 2.25 13.244 2.25ZM10.544 6.765L11.234 7.455L4.43902 14.25H3.74902V13.56L10.544 6.765ZM2.24902 12.9386L10.544 4.64355L13.3565 7.45605L5.06152 15.7511H2.24902V12.9386Z",fill:t})})},WB=function(e){var t=e.isRowSelected,n=e.onClick,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1];return Object(y.jsx)(Xc.Tooltip,{color:"#232630",title:"Edit",children:Object(y.jsx)("button",{"data-testid":"edit-row-button",type:"button",onMouseEnter:function(){o(!0)},onMouseLeave:function(){o(!1)},children:Object(y.jsx)(Xc.Button,{className:"p-6px ".concat(t?"bg-transparent border-none shadow-none hover:bg-blue-50":"bg-transparent border-none shadow-none hover:bg-neutral-20"),type:Xc.ButtonType.default,onClick:n,icon:Object(y.jsx)(GB,{fill:t&&i?"#FFFFFF":"#4D5165"})})})})},qB=n.p+"static/media/unarchive.15314935.svg",JB=function(e){var t=e.isOnHover,n=e.onUnarchive;return Object(y.jsx)("div",{className:t?"visible":"invisible",children:Object(y.jsx)(Xc.Tooltip,{color:"#232630",title:"Unarchive",children:Object(y.jsx)("button",{"data-testid":"unarchive-button",className:"focus:outline-none",type:"button",onClick:n,children:Object(y.jsx)("img",{src:qB,alt:"unarchive"})})})})},KB=function(e){var t=e.farm,n=e.onSelect,r=e.hasEditAccess,c=e.isSelected,i=e.showUnarchiveButton,o=e.onUnarchive,s=Object(a.useContext)(ac),l=Object(b.a)(s,2)[1],d=Object(a.useState)(0),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(!1),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)(!1),g=Object(b.a)(x,2),C=g[0],P=g[1];return Object(a.useEffect)((function(){var e=HB(t.fields);p(e)}),[t,t.fields]),Object(y.jsxs)(pu,{onMouseEnter:function(){h(!0),P(!0)},onMouseLeave:function(){h(!1),P(!1)},onClick:function(){return n(t)},className:"w-full py-3 pl-8 pr-1 text-left flex justify-between items-center",children:[c&&Object(y.jsx)("div",{className:"absolute left-0 h-50px w-1 bg-blue-50 rounded-r"}),Object(y.jsxs)("div",{"data-testid":"farm-row-".concat(t.id),children:[Object(y.jsx)("p",{className:"font-medium leading-5 ".concat(t.status&&!t.archived?"":"text-neutral-40"," ").concat(c?"font-semibold":""),children:t.name}),t.status?Object(y.jsx)("div",{className:"mt-2px text-xs leading-3",children:Object(y.jsxs)("span",{className:"text-neutral-".concat(t.archived?"40":"60"),children:[Object(y.jsx)(yf,{roundedTo:2,children:j})," ac",Object(y.jsx)("span",{children:" \u2022 "}),t.archived?"Archived":t.fields.length?"".concat(t.fields.length," field").concat(1===t.fields.length?"":"s"):"No fields"]})}):Object(y.jsxs)("div",{className:"flex mt-2",children:[Object(y.jsx)("span",{className:"mr-2",style:{height:"14px"},children:Object(y.jsx)(m.Spinner,{size:"xs",color:"#696F88"})}),Object(y.jsx)("span",{className:"text-gray-700",children:"Loading..."})]})]}),r&&O&&Object(y.jsx)(WB,{isRowSelected:c,onClick:function(e){e.preventDefault(),e.stopPropagation(),l({type:"SELECT_PROPERTY",payload:Object(I.a)(Object(I.a)({},t),{},{isEditing:!0,type:"Farm"})})}}),i&&Object(y.jsx)(JB,{onUnarchive:o,isOnHover:C})]})};KB.defaultProps={farm:{id:"",name:"",fields:[],status:null},onSelect:ne.noop,showUnarchiveButton:!1,onUnarchive:function(){}};var QB=Object(a.memo)(KB),XB=function(e){var t=e.field,n=e.onSelect,r=e.isSelected,c=e.icon,i=e.hasEditAccess,o=e.showUnarchiveButton,s=e.onUnarchive,l=e.parentPage,d=Object(p.h)(),u=Object(a.useState)(c),j=Object(b.a)(u,2),f=j[0],m=j[1],v=Object(a.useState)(!1),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1];Object(a.useEffect)((function(){c&&m(Ej(c))}),[c]);return Object(y.jsxs)(pu,{className:"w-full py-3 pl-8 pr-1  text-left flex items-center justify-between",onMouseEnter:function(){x(!0),A(!0)},onMouseLeave:function(){x(!1),A(!1)},onClick:function(){return n(t)},children:[r&&Object(y.jsx)("div",{className:"absolute left-0 h-50px w-1 bg-blue-50 rounded-r"}),Object(y.jsxs)("div",{"data-testid":"field-row-".concat(t.id),className:"flex items-start",children:[Object(y.jsx)(Kp,{id:t.id,features:[f],color:t.archived?"#DFE2E7":r?"#696F88":"#868CA2",className:"flex-shrink-0"}),Object(y.jsxs)("div",{className:"ml-2",children:[Object(y.jsx)("p",{"data-testid":"archived-field-name",className:"font-medium leading-5 break-all ".concat(t.archived?"text-gray-600":"text-neutral-1000"," ").concat(r?"font-semibold":""),children:t.name}),Object(y.jsxs)("div",{className:"mt-2px text-xs leading-3",children:[Object(y.jsx)("span",{className:t.archived?"text-gray-600":"text-neutral-1000",children:t.cropzones.length?"".concat(t.cropzones.length," crop zone").concat(1===t.cropzones.length?"":"s"):"No crop zones"}),Object(y.jsxs)("span",{className:t.archived?"text-gray-600":"text-neutral-1000",children:[" ","\u2022"," "]}),t.archived?Object(y.jsx)("span",{className:"text-gray-600",children:"Archived"}):Object(y.jsxs)("span",{className:"text-gray-700",children:[Object(y.jsx)(yf,{roundedTo:2,children:YB(t)}),"\xa0ac"]})]})]})]}),i&&h&&Object(y.jsx)(WB,{isRowSelected:r,onClick:function(){n(t),d.push("".concat(Cc.properties,"/edit/").concat(null===t||void 0===t?void 0:t.id),{parentPage:l})}}),o&&Object(y.jsx)(JB,{onUnarchive:s,isOnHover:P})]})};XB.defaultProps={field:{id:"",name:"",boundaryArea:0},onSelect:ne.noop,icon:void 0,showUnarchiveButton:!1,onUnarchive:function(){},parentPage:0};var $B=Object(a.memo)(XB),eU=function(e){var t=e.cropZone,n=e.onSelect,r=e.isSelected,c=e.icon,i=e.fieldId,o=e.isEditable,s=e.parentPage,l=Object(a.useContext)(ac),d=Object(b.a)(l,1)[0].updateCropName,u=Object(p.h)(),j=Object(a.useState)(c),f=Object(b.a)(j,2),m=f[0],v=f[1],O=Object(a.useState)(!1),h=Object(b.a)(O,2),x=h[0],g=h[1];Object(a.useEffect)((function(){c&&v(Ej(c))}),[c]);return Object(y.jsxs)(pu,{onMouseEnter:function(){g(!0)},onMouseLeave:function(){g(!1)},onClick:function(){return n(t)},className:"w-full py-3 pl-16 pr-1 text-left flex items-center justify-between",children:[r&&Object(y.jsx)("div",{className:"absolute left-0 h-50px w-1 bg-blue-50 rounded-r"}),Object(y.jsxs)("div",{"data-testid":"crop-zone-row-".concat(t.id),className:"flex items-start",children:[Object(y.jsx)(Kp,{id:"field-card-icon",features:[m],color:"#DFE2E7",border:t.archived?null:r?"#696F88":"#868CA2",className:"flex-shrink-0"}),Object(y.jsxs)("div",{className:"ml-2",children:[Object(y.jsx)("p",{className:"font-medium leading-5 break-all ".concat(t.archived?"text-gray-600":"text-neutral-1000"," ").concat(r?"font-semibold":""),children:t.name}),Object(y.jsx)("div",{className:"mt-2px text-xs leading-3",children:Object(y.jsxs)("span",{className:t.archived?"text-gray-700":"text-neutral-60",children:[Object(y.jsx)(yf,{roundedTo:2,children:YB(t)}),"\xa0ac \u2022 ",function(){var e;return d&&d.cropZoneId===t.id?null===d||void 0===d?void 0:d.cropName:null===t||void 0===t||null===(e=t.crop)||void 0===e?void 0:e.name}()]})})]})]}),o&&x&&Object(y.jsx)(WB,{isRowSelected:r,onClick:function(){u.push("".concat(Cc.properties,"/edit/").concat(i,"/cropzone/").concat(t.id),{parentPage:s})}})]})};eU.defaultProps={cropZone:{name:"",boundaryArea:0,crop:{name:""}},onSelect:ne.noop,icon:void 0,isEditable:!0,parentPage:0};var tU=Object(a.memo)(eU),nU=function(e){var t=e.fieldsToMassiveAssign,n=e.dispatch,r=e.setOpenAddCropZonesModal,c=Object(a.useState)([]),i=Object(b.a)(c,1)[0],o=Object(a.useState)(!1),s=Object(b.a)(o,2),l=s[0],d=s[1],u=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n({type:Ar,payload:Object(I.a)({action:e},t)})},j=t.some((function(e){return e.cropzones.length}));return Object(y.jsxs)("div",{className:"sticky bottom-0 w-full h-16 bg-white border-t-2 py-3 px-5 flex justify-between items-center z-4",children:[Object(y.jsx)(l_,{open:l,close:function(){d(!1)},name:"Tags",selectedTags:null===i||void 0===i?void 0:i.reduce((function(e,t){return"".concat(e,",").concat(t.id)}),""),returnSelectedTags:function(e){n({type:Ar,payload:{action:"TagsAdded",flags:e,fieldsToMassiveAssign:BB(t)}})}}),Object(y.jsx)("div",{className:"w-1/2 pr-2",children:Object(y.jsx)(m.Popup,{position:"top",containerClasses:"popup-width-mass-assigner",trigger:Object(y.jsx)(m.Button,{type:"outline",size:"lg",disabled:!0,style:{width:"100%"},children:"Edit Tags"}),children:Object(y.jsxs)(m.Menu,{children:[Object(y.jsx)(m.Menu.Item,{onClick:function(){d(!0)},selectable:j,children:Object(y.jsx)("span",{className:"".concat(j?"hover:font-semibold":"pt-1"," w-full h-full flex items-center"),children:"Add Tags"})}),Object(y.jsx)(m.Menu.Item,{onClick:function(){n({type:Ar,payload:{action:"TagsDeleted",flags:i,fieldsToMassiveAssign:BB(t)}})},selectable:j,children:Object(y.jsx)("span",{className:"hover:font-semibold w-full h-full flex items-center",children:"Delete Tags"})})]})})}),Object(y.jsx)("div",{className:"w-1/2 pl-2",children:Object(y.jsx)(m.Popup,{position:"top",containerClasses:"popup-width-mass-assigner",trigger:Object(y.jsx)(m.Button,{type:"primary",ghost:!0,size:"lg",style:{width:"100%"},disabled:!t.length,children:"Edit Crop Zones"}),children:Object(y.jsxs)(m.Menu,{children:[Object(y.jsx)(m.Menu.Item,{onClick:function(){u("Added"),r(!0)},selectable:!0,children:Object(y.jsx)("span",{className:"ml-2 hover:font-semibold w-full h-full flex items-center",children:"Add Crop Zones"})}),Object(y.jsx)(m.Menu.Item,{onClick:function(){u("Changed"),r(!0)},selectable:j,disabled:!j,children:Object(y.jsx)("span",{className:"ml-2 ".concat(j?"hover:font-semibold":"pt-1"," w-full h-full flex items-center"),children:"Change Crop Zones"})}),Object(y.jsx)(m.Menu.Item,{onClick:function(){return u("Deleted",{fieldsToMassiveAssign:BB(t)})},selectable:j,disabled:!j,children:Object(y.jsx)("span",{className:"ml-2 ".concat(j?"hover:font-semibold":"pt-1"," w-full h-full flex items-center"),children:"Delete Crop Zones"})})]})})})]})};nU.defaultProps={fieldsToMassiveAssign:[]};var aU,rU,cU=nU,iU=n(2847),oU=n(2849),sU=["title","titleId"];function lU(){return lU=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},lU.apply(this,arguments)}function dU(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function uU(e,t){var n=e.title,r=e.titleId,c=dU(e,sU);return a.createElement("svg",lU({width:20,height:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,aU||(aU=a.createElement("path",{d:"M7.5 8.33333C7.5 7.8731 7.8731 7.5 8.33333 7.5H11.6667C12.1269 7.5 12.5 7.8731 12.5 8.33333V11.6667C12.5 12.1269 12.1269 12.5 11.6667 12.5H8.33333C7.8731 12.5 7.5 12.1269 7.5 11.6667V8.33333Z",fill:"#0092E4"})),rU||(rU=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.16667 2.5H5.83333V4.16667L14.1667 4.16667V2.5H15.8333V4.16667L17.5 4.16667V5.83333H15.8333V14.1667H17.5V15.8333H15.8333V17.5H14.1667V15.8333L5.83333 15.8333V17.5H4.16667V15.8333H2.5V14.1667H4.16667V5.83333H2.5V4.16667L4.16667 4.16667V2.5ZM5.83333 14.1667V5.83333L14.1667 5.83333V14.1667H5.83333Z",fill:"#0092E4"})))}var bU,jU=a.forwardRef(uU),pU=(n.p,["title","titleId"]);function fU(){return fU=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},fU.apply(this,arguments)}function mU(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function vU(e,t){var n=e.title,r=e.titleId,c=mU(e,pU);return a.createElement("svg",fU({width:19,height:18,viewBox:"0 0 19 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,bU||(bU=a.createElement("path",{d:"M7.77869 4.5L6.72119 5.5575L10.1562 9L6.72119 12.4425L7.77869 13.5L12.2787 9L7.77869 4.5Z",fill:"#14803C"})))}var OU=a.forwardRef(vU),hU=(n.p,function(){var e=Object(a.useState)(),t=Object(b.a)(e,2),n=t[0],r=t[1];return Object(a.useEffect)((function(){Kt.fetch().promise.then((function(e){var t=e.data;r(t)})).catch(Ae.default)}),[]),{isOrgInFF:n}}),xU=function(e,t,n,r){var c,i=hU().isOrgInFF,o=Ov(),s=o.deleteCropZone,l=o.createBulkCropZone,d=o.updateBulkCropZone,u=Object(a.useState)(!1),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useState)(!1),v=Object(b.a)(m,2),O=v[0],h=v[1],x=function(){var t;i&&(t=e.season.id);var n={cropId:e.crop.id,cropSeasonId:t,cropZones:[]};return e.fieldsToMassiveAssign.forEach((function(t,a){n.cropZones.push({name:e.crop.name,propertyId:t.farmId,fieldId:t.id,cropId:e.crop.id,reportedArea:t.reportedArea,geometry:t.geometry,coordinates:Oj([t]).toString()}),i&&(n.cropZones[a].cropSeasonId=e.season.id)})),c=n,[l(n)]},g=function(){return ae.a.flatten(e.fieldsToMassiveAssign.map((function(t){return t.cropzones.map((function(n){var a,r={};if(i){var c=n.cropSeasons;r.cropSeasonId=c[0].id}return Object(I.a)(Object(I.a)({},n),{},{farmName:t.farmName,fieldName:t.name,fieldId:t.id,farmId:t.farmId,tags:(null===e||void 0===e||null===(a=e.flags)||void 0===a?void 0:a.map((function(e){return e.id})))||[]},r)}))})))},C=function(){return(c=function(){var t;i&&(t=$P());var n=[];return t.map((function(t){return n.push({cropId:e.crop.id,cropSeasonId:t,cropZones:[]})})),e.fieldsToMassiveAssign.map((function(t){return t.cropzones.forEach((function(a){var r={};if(i){var c=a.cropSeasons;r.cropSeasonId=c[0].id}n.forEach((function(n){var c,i;n.cropSeasonId===r.cropSeasonId&&n.cropZones.push(Object(I.a)({boundaryArea:a.boundaryArea,geometry:a.geometry,reportedArea:a.reportedArea,id:a.id,name:e.crop.name,farmName:t.farmName,fieldName:t.name,fieldId:t.id,propertyId:t.farmId,tags:null!==(c=null===e||void 0===e||null===(i=e.flags)||void 0===i?void 0:i.map((function(e){return e.id})))&&void 0!==c?c:[]},r))}))}))})),n.filter((function(e){return e.cropZones.length}))}()).map((function(e){return d(e)}))},y=function(t,n){var a="";a="TagsAdded"===e.action?"Tags Added":"TagsDeleted"===e.action?"Crop Zone(s) Updated":"Crop Zone(s) ".concat(e.action);var r=function(t,n){return"Added"===e.action?"".concat(t.length," of ").concat(n.length," crop zone(s) have been created"):"Changed"===e.action?"".concat(t.length," of ").concat(n.length," crop zone(s) have been updated"):"TagsAdded"===e.action||"TagsDeleted"===e.action?"".concat(t.length," crop zone(s) have been updated"):"".concat(t.length," of ").concat(n.length," crop zone(s) have been deleted")}(t,n);return{toastTitle:a,toastDescription:r,toastType:t.length===n.length?"success":t.length>0&&t.length<n.length?"warning":"error"}},P=function(){var t=Object(Y.a)(G.a.mark((function t(){var a,i,o,l,d,u,b,j,p;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return f(!0),i={Added:function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.allSettled(x()));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Deleted:function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.allSettled((c=g()).map(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.id,e.abrupt("return",s(n));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Changed:function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.allSettled(C()));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),TagsAdded:function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.allSettled(C()));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),TagsDeleted:function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.allSettled(C()));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()},t.next=4,i[e.action]();case 4:return o=t.sent,l=function(e){return ae.a.flatMap(e.map((function(e){var t;return null===e||void 0===e||null===(t=e.value)||void 0===t?void 0:t.data})))}(o.filter((function(e){return"fulfilled"===e.status}))),a="Deleted"===e.action?c:null!==(d=c)&&void 0!==d&&d.length?ae.a.flatMap(c.map((function(e){return e.cropZones.map((function(e){return e}))}))):c.cropZones.map((function(e){return e})),u=y(l,a),b=u.toastTitle,j=u.toastDescription,p=u.toastType,r({type:Ym}),n(),r({type:Nr,payload:{toastTitle:b,toastDescription:j,toastType:p,action:e.action}}),r({type:Sr}),t.abrupt("return",o);case 14:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return{handleCancel:function(){r({type:Sr})},isSaving:p,checkDeleteAction:function(){"Added"!==e.action?h(!0):P()},getTotalCropZones:function(){var e=t.flatMap((function(e){return e.cropzones}));return(null===e||void 0===e?void 0:e.length)||0},getTotalCropZoneArea:function(){return t.flatMap((function(e){return e.cropzones})).reduce((function(e,t){return e+(t.reportedArea||t.boundaryArea)}),0)||0},openConfirmModal:O,handleComplete:P,setOpenConfirmModal:h,cropZonesToModify:g}},gU=function(e){var t=e.selectedFields,n=Object(a.useContext)(ac),r=Object(b.a)(n,2),c=r[0],i=c.massiveChangeSummary,o=c.fieldsToMassiveAssign,s=c.fetchProperties,l=r[1],d=xU(i,o,s,l),u=d.getTotalCropZones,j=d.getTotalCropZoneArea,p=!t.length,f=u();return Object(y.jsxs)("div",{className:"sticky bottom-0 w-full bg-white border-t-2 p-4 pt-10px items-center z-4",children:[Object(y.jsxs)(iU.a,{gutter:16,className:"text-blue-60",children:[Object(y.jsxs)(oU.a,{children:[f," crop zone",1!==f?"s":""," selected"]}),Object(y.jsx)(oU.a,{children:Object(y.jsxs)(iU.a,{children:[Object(y.jsx)(jU,{className:"mr-1"}),Object(y.jsxs)("span",{children:[xR(j())," total ac"]})]})})]}),Object(y.jsx)(iU.a,{className:"mt-4",children:Object(y.jsx)(Xc.Button,{name:"next",type:Xc.ButtonType.success,className:p?"border-neutral-20":"",ghost:!0,disabled:p,style:{width:"100%"},children:Object(y.jsxs)(iU.a,{className:"w-full",justify:"center",children:[Object(y.jsx)("span",{children:"Next"}),Object(y.jsx)(OU,{className:"mt-2px ml-1 ".concat(p?"chevron-disabled":"")})]})})})]})},CU=function(e){var t=e.properties,n=e.fieldsAndAreasGeoJSONCollection,r=e.propertiesFilter,c=Object(a.useContext)(ac),i=Object(b.a)(c,2),o=i[0],s=o.fieldsToMassiveAssign,l=o.searchTextValueFFT,d=o.isExportPDFMapsActive,u=i[1],j=FB(t,s,u),p=j.handleSelectedFarm,f=j.handleSelectedField,v=j.isCropzoneSelected,O=j.handleSelectedCropzone,h=j.handleSelectAllProperties,x=j.selectedAllProperties,g=j.localProperties,C=Object(a.useState)(!1),P=Object(b.a)(C,2),A=P[0],S=P[1];return Object(y.jsxs)("div",{"data-tree":!0,className:"relative flex-grow flex flex-col","data-testid":"mass-assigner-tree",children:[Object(y.jsx)("div",{className:"px-1 overflow-y-auto",children:Object(y.jsxs)(m.Table,{children:[Object(y.jsx)(m.Table.Row,{onClick:h,selectable:!0,selected:x,children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"font-semibold text-sm",children:"Select All Properties"})})}),r(g,l).map((function(e){return Object(y.jsxs)(m.Table.RowGroup,{arrowIcon:!0,onClick:function(){return p(e)},selectable:!!e.fields.length,selected:e.selected,children:[Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(QB,{farm:e})})}),e.fields.map((function(t){var a=wj(n,t);return Object(y.jsxs)(m.Table.RowGroup,{arrowIcon:!0,onClick:function(){return f(e,t)},selectable:!!e.fields.length,selected:ae.a.findIndex(s,t)>=0,children:[Object(y.jsx)(m.Table.Row,{children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)($B,{field:t,icon:a})})}),t.cropzones.map((function(a){var r=wj(n,a);return Object(y.jsx)(m.Table.Row,{onClick:function(){return O(e,t,a)},selectable:!!e.fields.length,selected:v(a),children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(tU,{cropZone:a,icon:r,fieldId:t.id,isEditable:!1})})})}))]})}))]})}))]})}),d?Object(y.jsx)(gU,{selectedFields:s}):Object(y.jsx)(cU,{dispatch:u,fieldsToMassiveAssign:s,setOpenAddCropZonesModal:S}),A&&Object(y.jsx)(ZB,{open:A,onClose:function(){return S(!1)}})]})};CU.defaultProps={properties:[],fieldsAndAreasGeoJSONCollection:{}};var yU=CU,PU=function(e){var t=e.open,n=e.close,r=e.propertyId,c=e.propertyName,i=e.propertyType,o=e.reloadData,s=Object(a.useContext)(we),l=ni(),d=Object(et.a)({},i,r),u=iB(d[kh]),b=Pv(d[Dh]),j=i===kh?u:b,p=i===kh?j.unarchiveFarm:j.unarchiveField,f=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i===kh?s.events.epic.Properties.unarchiveFarm:s.events.epic.Properties.unarchiveField,s.sendEventToAmplitude(t),p(r);case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){j.archive.isLoading||(j.archive.isSuccess&&(l.success("".concat(c," unarchived"),{content:"You have unarchived your ".concat(i," and all associated ").concat(i===kh?"fields and ":"","crop zones")}),o(),n()),j.archive.isError&&(l.error("".concat(c," was not unarchived"),{content:"An error prevented your ".concat(i," from being unarchived. Please try again."),supportButton:!0}),n()))}),[j.archive]),Object(y.jsx)(ao,{open:t,title:"Unarchive ".concat(c,"?"),close:n,type:"warningConfirmation",cancelLabel:"Cancel",confirmLabel:"Unarchive ".concat(i),onCancel:n,onConfirm:f,isSaving:j.archive.isLoading,children:Object(y.jsxs)("div",{"data-testid":"unarchive-field-modal",className:"pr-6",children:["This ",i," will be unarchived along with all associated"," ",i===kh?"fields and":""," crop zones. Would you like to continue?"]})})};PU.defaultProps={reloadData:function(){}};var AU=Object(p.l)(PU),SU=(n(1556),function(e){var t=e.properties,n=e.propertiesFilter,r=Object(a.useContext)(ac),c=Object(b.a)(r,2),i=c[0],o=i.selectedProperty,s=i.expandedPropertyIds,l=i.loggedInUserOrgPermission,d=i.searchTextValueFFT,u=c[1],j=Object(a.useContext)(EB),p=j.pagination,f=j.isHugeOrganization,O=j.isLoadingPaginatedProperties,h=j.params,x=j.setParams,g=j.isLoadingFields,C=j.fetchProperties,P=j.onPropertySelection,A=j.fieldsAndAreasGeoJSONCollection,S=l.role,T=Object(a.useState)(!1),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)("bottom"),R=Object(b.a)(_,2),D=R[0],k=R[1],L=Object(a.useState)({}),F=Object(b.a)(L,2),M=F[0],V=F[1],B=Object(a.useState)(kh),U=Object(b.a)(B,2),z=U[0],Z=U[1],Y=Object(a.useRef)(0),H=Object(a.useRef)(0),G=Object(a.useRef)(null),W=Object(a.useRef)(0),q=Object(a.useRef)(null),J=Object(a.useCallback)((function(e){var t=e.target,n=t.scrollTop,a=t.scrollHeight,r=t.clientHeight;H.current=n;var c,i=O||g,o=0===n,s=function(e,t){W.current=a,x((function(t){return Object(I.a)(Object(I.a)({},t),{},{page:e})})),k(t)};n+r>=a-120&&!i&&s((null!==p&&void 0!==p&&null!==(c=p.preLoadedPages)&&void 0!==c&&c.length?Math.max.apply(Math,Object(v.a)(p.preLoadedPages)):0)+1,"bottom");if(o&&(!i||"bottom"===D)){var l,d=null!==p&&void 0!==p&&null!==(l=p.preLoadedPages)&&void 0!==l&&l.length?Math.min.apply(Math,Object(v.a)(p.preLoadedPages)):0;if(d>0){var u=document.querySelector("[data-tree]");u&&(u.scrollTop=400),s(d-1,"top")}}return Y.current=n,function(){x((function(e){return Object(I.a)(Object(I.a)({},e),{},{page:0})}))}}),[O,h,x,p]);Object(a.useEffect)((function(){var e=document.querySelector("[data-tree]");return e&&f&&e.addEventListener("scroll",J),function(){e&&f&&e.removeEventListener("scroll",J)}}),[J,f]),Object(a.useEffect)((function(){if(f){var e=G.current;if(e&&W.current){if("bottom"===D){var t=e.scrollHeight-W.current;e.scrollTop+=t}W.current=0}}}),[h.page,O,g,D,f]),Object(a.useEffect)((function(){if(!(!f||O||g||null===t||void 0===t||!t.length||null!==d&&void 0!==d&&d.valueInput)){var e,n=!0,a=function(){var e=G.current;if(e)if(e.scrollHeight<=e.clientHeight&&n){var t,a=null!==p&&void 0!==p&&null!==(t=p.preLoadedPages)&&void 0!==t&&t.length?Math.max.apply(Math,Object(v.a)(p.preLoadedPages)):0;x((function(e){return Object(I.a)(Object(I.a)({},e),{},{page:a+1})}))}else n=!1,q.current&&G.current&&q.current.disconnect()};return e=setTimeout(a,500),q.current=new MutationObserver((function(){clearTimeout(e),e=setTimeout(a,500)})),null!==G&&void 0!==G&&G.current&&q.current.observe(G.current,{childList:!0,subtree:!0}),function(){clearTimeout(e),null!==q&&void 0!==q&&q.current&&null!==G&&void 0!==G&&G.current&&q.current.disconnect()}}}),[null===t||void 0===t?void 0:t.length,f,g,O,null===p||void 0===p?void 0:p.preLoadedPages,x,null===d||void 0===d?void 0:d.valueInput]);var K=Object(a.useCallback)((function(e){return(null===o||void 0===o?void 0:o.id)===e.id}),[null===o||void 0===o?void 0:o.id]),Q=Object(a.useMemo)((function(){return cr(S,$a)}),[S]),X=Object(a.useCallback)((function(e,t){jc(u,e?mr:vr,t)}),[]),$=Object(a.useCallback)((function(e,t){var n,a=null!==(n=e[0])&&void 0!==n?n:t.node.key;X(!!e[0],a)}),[X]),ee=Object(a.useCallback)((function(e,t){var n=t.expanded,a=t.node;X(n,a.key)}),[X]),te=function(e){V(e),Z(e.fields?kh:Dh),w(!0)},ne=Object(a.useCallback)((function(e){e.archived||P(e)}),[P]),ae=n(t,d).sort((function(e,t){return e.parentPage-t.parentPage})).map((function(e){return{title:Object(y.jsx)(QB,{farm:e,onSelect:P,isSelected:K(e),hasEditAccess:!e.archived&&Q,showUnarchiveButton:e.archived&&Q,onUnarchive:function(){return te(e)}}),key:e.id,children:e.fields.map((function(t){var n=wj(A,t),a=Object(I.a)(Object(I.a)({},t),{},{farmId:e.id});return{title:Object(y.jsx)($B,{field:a,onSelect:P,isSelected:K(t),icon:n,hasEditAccess:!t.archived&&Q,showUnarchiveButton:t.archived&&Q,onUnarchive:function(){return te(a)},parentPage:null===e||void 0===e?void 0:e.parentPage}),key:t.id,children:t.cropzones.map((function(n){var a=wj(A,n),r=Object(I.a)(Object(I.a)({},n),{},{fieldId:t.id,farmId:e.id,archived:t.archived});return{title:Object(y.jsx)(tU,{onSelect:ne,isSelected:K(n),cropZone:r,icon:a,fieldId:t.id,isEditable:Q&&!t.archived,parentPage:null===e||void 0===e?void 0:e.parentPage}),key:n.id}}))}}))}}));return Object(y.jsxs)(y.Fragment,{children:[O&&"top"===D&&Object(y.jsxs)("div",{"data-testid":"top-loading",className:"bg-neutral-100 border-b border-t border-neutral-20 py-4 flex items-center justify-center gap-2",children:[Object(y.jsx)("div",{className:"w-30px",children:Object(y.jsx)(m.Spinner,{size:"sm"})}),Object(y.jsx)("p",{className:"test-sm",children:"Loading previous farms..."})]}),Object(y.jsxs)("div",{ref:G,"data-tree":!0,className:"default-fft h-full w-full",children:[Object(y.jsx)(Xc.Tree,{selectedKeys:null!==o&&void 0!==o&&o.id?[null===o||void 0===o?void 0:o.id]:[],treeData:ae,onSelect:$,onExpand:ee,expandedKeys:s,virtual:!0}),M.id&&Object(y.jsx)(AU,{open:E,propertyId:M.id,propertyName:M.name,propertyType:z,reloadData:C,close:function(){return w(!1)}})]}),O&&"bottom"===D&&Object(y.jsxs)("div",{"data-testid":"bottom-loading",className:"bg-neutral-100 border-t border-b border-neutral-20 py-4 flex items-center justify-center gap-2",children:[Object(y.jsx)("div",{className:"w-30px",children:Object(y.jsx)(m.Spinner,{size:"sm"})}),Object(y.jsx)("p",{className:"test-sm",children:"Loading ".concat(null!==d&&void 0!==d&&d.valueInput?"":"additional"," farms...")})]})]})});SU.defaultProps={properties:[]};var TU=Object(a.memo)(SU),NU=function(e){var t=e.properties,n=e.rawProperties,r=Object(a.useContext)(EB),c=r.isHugeOrganization,i=r.fieldsAndAreasGeoJSONCollection,o=Object(a.useContext)(ac),s=Object(b.a)(o,1)[0],l=s.isMassAssignerActive,d=s.isExportPDFMapsActive,u=Object(a.useCallback)((function(e,t){return c||""===t.valueInput||void 0===t.valueInput?e:e.filter((function(e){return e.name.toLowerCase().includes(t.valueInput)||e.fields.some((function(e){return e.name.toLowerCase().includes(t.valueInput)}))}))}),[c]);return l||d?Object(y.jsx)(yU,{properties:t,fieldsAndAreasGeoJSONCollection:i,propertiesFilter:u}):Object(y.jsx)(TU,{properties:t,rawProperties:n,propertiesFilter:u})};NU.defaultProps={properties:[],rawProperties:[]};var EU=NU,wU=function(e,t){e.style.height=t?"".concat(e.scrollHeight,"px"):"0px"},_U=function(e){return Object(y.jsx)(m.Icon,{icon:e?"chevron-up":"chevron-down",color:"#515253"})},RU=function(e){var t=e.title,n=e.options,r=e.showOptions,c=Object(a.useState)(r),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(_U(r)),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useRef)();return Object(a.useEffect)((function(){j(_U(o)),wU(p.current,o)}),[o]),Object(y.jsxs)("div",{className:"my-3",children:[Object(y.jsxs)(pu,{className:"flex justify-between items-center mb-4 px-5",onClick:function(){return s(!o)},children:[Object(y.jsx)("span",{className:"text-black font-semibold",children:t}),u]}),Object(y.jsx)("div",{className:"transition-all duration-200 overflow-y-hidden border-b border-neutral-100",ref:p,"data-testid":"collapsible-options",children:Object(y.jsx)("ul",{className:"text-black px-5 pt-2 pb-4 gap-y-4",children:null===n||void 0===n?void 0:n.map((function(e){return Object(y.jsxs)("div",{className:"flex flex-row items-center justify-between pb-2",children:[Object(y.jsx)("span",{className:"text-neutral-1000 font-light",children:e.name}),Object(y.jsx)(zo,{id:"collapsible-toggle-option-".concat(e.name),name:"collapsible-toggle-option-".concat(e.name),defaultChecked:e.value,onChange:function(t){return e.onChange(t.target.checked)},color:"#0071CD",big:!0})]},Object(cc.generate)())}))})})]})};RU.defaultProps={showOptions:!1};var IU=RU,DU=function(e){var t=e.farms,n=e.selectedFarmIds,r=e.onFarmSelect,c=e.showArchived,i=Object(a.useState)(n.length>0),o=Object(b.a)(i,2),s=o[0],l=o[1],d=t.some((function(e){return e.archived}));return Object(y.jsxs)("div",{children:[Object(y.jsxs)(pu,{className:"flex justify-between items-center mb-4 px-5",onClick:function(){return l((function(e){return!e}))},children:[Object(y.jsx)("span",{className:"text-black font-semibold",children:"Farms"}),Object(y.jsx)(m.Icon,{icon:s?"chevron-up":"chevron-down",color:"#515253"})]}),s?Object(y.jsxs)("div",{className:"transition-all duration-200 overflow-y-hidden border-b border-neutral-100 flex flex-col px-5 pb-20px",children:[t.filter((function(e){return!e.archived})).map((function(e){return Object(y.jsx)("div",{className:"p-1",children:Object(y.jsx)(m.Checkbox,{checked:n.includes(null===e||void 0===e?void 0:e.id),onChange:r(null===e||void 0===e?void 0:e.id),label:null===e||void 0===e?void 0:e.name})},null===e||void 0===e?void 0:e.id)})),c&&d&&Object(y.jsxs)("div",{className:"mt-5",children:[Object(y.jsx)("p",{className:"text-neutral-60 mb-2",children:"Archived Farms"}),null===t||void 0===t?void 0:t.filter((function(e){return e.archived})).map((function(e){return Object(y.jsx)("div",{className:"p-1",children:Object(y.jsx)(m.Checkbox,{checked:n.includes(null===e||void 0===e?void 0:e.id),onChange:r(null===e||void 0===e?void 0:e.id),label:null===e||void 0===e?void 0:e.name})},null===e||void 0===e?void 0:e.id)}))]})]}):null]})};DU.defaultProps={farms:[],selectedFarmIds:[],showArchived:!1};var kU=DU,LU=function(e){var t=e.properties,n=e.onClose,r=Object(a.useContext)(ac),c=Object(b.a)(r,1)[0],i=c.organization,o=c.propertyFilters,s=Object(f.useFlags)(),l=s.feArchiveField||s.feArchiveFieldOrgIds&&-1!==s.feArchiveFieldOrgIds.indexOf(null===i||void 0===i?void 0:i.id),d=Object(a.useContext)(we),u=av(),j=u.showArchivedProperties,p=u.hasFilterChanges,m=u.applyFilters,O=Object(a.useState)(j),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)((null===o||void 0===o?void 0:o.showFarmWithIds)||[]),P=Object(b.a)(C,2),A=P[0],S=P[1];return Object(y.jsx)("div",{"data-tree":!0,className:"relative flex-grow flex flex-col h-full bg-white","data-testid":"mass-assigner-tree",children:Object(y.jsxs)("div",{className:"flex-1 flex flex-col h-full",children:[Object(y.jsxs)("div",{className:"w-full px-5 flex flex-row justify-between items-center sticky top-0 bg-white pt-6 pb-10",children:[Object(y.jsx)("h1",{className:"text-3xl font-semibold",children:"Filter"}),Object(y.jsx)(Xc.Button,{"data-testid":"clear-all-filters-button",type:Xc.ButtonType.outline,size:"small",onClick:function(){S([]),g(!1)},disabled:!(x||A.length),children:"Clear All"})]}),Object(y.jsxs)("div",{className:"mb-16 overflow-y-auto",children:[Object(y.jsx)(kU,{farms:t,selectedFarmIds:A,onFarmSelect:function(e){return function(){A.includes(e)?S(A.filter((function(t){return t!==e}))):S([].concat(Object(v.a)(A),[e]))}},showArchived:x}),l&&Object(y.jsx)(IU,{options:[{name:"Show archived properties in field list",onChange:function(e){if(!e){var n=t.filter((function(e){return e.archived})).map((function(e){return e.id}));S(ae.a.difference(A,n))}g(e)},value:x}],title:"Archived"})]}),Object(y.jsxs)("div",{className:"flex flex-row w-full gap-x-2 py-6 px-6 justify-between absolute left-0 bottom-0 bg-white border-t-1 border-neutral-20",children:[Object(y.jsx)(Xc.Button,{onClick:function(){n()},type:Xc.ButtonType.outline,children:"Cancel"}),Object(y.jsx)(Xc.Button,{"data-testid":"apply-fft-filters-button",onClick:function(){m({showLocalArchivedProperties:x,selectedFarmIds:A}),d.sendEventToAmplitude(d.events.epic.Properties.filters.toggleArchivedProperties,{localArchivedProperties:x}),n()},type:Xc.ButtonType.primary,disabled:!p({selectedFarmIds:A,showLocalArchivedProperties:x}),children:"Apply"})]})]})})};LU.defaultProps={properties:[]};var FU=LU,MU=function(e){var t=e.properties,n=e.rawProperties,r=e.openCreateModal,c=e.memberRole,i=Object(a.useContext)(EB),o=i.isLoadingProperties,s=i.viewMode,l=i.financialAccess,d=i.fetchProperties,u=i.onViewModeChange,j=Object(a.useState)(!1),p=Object(b.a)(j,2),f=p[0],v=p[1];return Object(y.jsx)("div",{"data-testid":"property-landing-property-tree",className:"h-full bg-white cursor-default flex flex-col outline-r outline-neutral-20 border-r border-neutral-20",children:f?Object(y.jsx)(FU,{properties:n,onClose:function(){return v(!1)}}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(PB,{showTools:!(null===t||void 0===t||!t.length),title:"Properties",reloadFarmData:d,openCreateModal:r,openFilters:function(){return v(!0)},loading:o,onChangeView:u,view:s}),Object(y.jsxs)("div",{className:"w-full flex flex-grow overflow-scroll",children:[o&&Object(y.jsx)(m.Spinner,{}),!o&&(null===t||void 0===t?void 0:t.length)>0&&Object(y.jsx)(EU,{properties:t}),!o&&!(null!==t&&void 0!==t&&t.length)&&Object(y.jsx)(LB,{openCreateModal:r,memberRole:c,memberFinancialAccess:l})]}),Object(y.jsx)(DB,{showTools:!(null===t||void 0===t||!t.length),reloadFarmData:d,openCreateModal:r,setView:u})]})})};MU.defaultProps={properties:[],rawProperties:[]};var VU=MU,BU=function(e){var t=e.properties,n=e.onSetShowSummaryPanel,r=Object(a.useContext)(EB),c=r.selectedProperty,i=r.selectedField,o=r.propertyZoom,s=r.onPropertySetZoom,l=r.isLoadingFields,d=r.fieldsAndAreasGeoJSONCollection,u=Object(a.useState)(Object(tF.c)(localStorage.getItem(Ab))),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useMemo)((function(){return JSON.stringify(vj(d,t))}),[d,t]),v=Object(a.useMemo)((function(){var e,t;return p||(null===(e=JSON.parse(m))||void 0===e||null===(t=e.geometry)||void 0===t?void 0:t.coordinates)}),[m,p]);Object(a.useEffect)((function(){(null===i||void 0===i?void 0:i.length)>0&&n(!0)()}),[i,n]);var O=((null===c||void 0===c?void 0:c.type)||"org").toLowerCase().replace(/\s+/g,"");return Object(y.jsx)("div",{className:"relative w-full h-full",children:Object(y.jsx)(mm,{fieldsLoading:l,zoom:o,setZoom:s,currentCoordinates:v,setCurrentCoordinates:f,displayOnly:!0,geoJSONCollection:d,labelName:O,selectedField:i})})};BU.defaultProps={properties:null,onSetShowSummaryPanel:function(){return function(){}}};var UU=BU,zU=function(e){var t=e.selectedProperty,n=e.showEditToast,a=e.setShowEditToast,r=e.state;return Object(y.jsx)(Qc,{type:r,title:function(e){var n;return"success"===e&&(n="".concat(t.type," Information Saved")),"error"===e&&(n="".concat(t.type," information was not saved")),n}(r),open:n,onClose:function(){a(!1)},timeout:5500,children:"error"===r?Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"text-sm font-normal mb-2",children:"An error prevented your information from being saved. Please try again."}),Object(y.jsx)(m.Button,{size:"lg",type:"primary",onClick:function(){return window.open("https://agconnections.zendesk.com/hc/en-us/categories/7419295252627-Cropwise-Financials","_blank","noopener")},style:{marginLeft:"auto"},children:"Contact Support"})]}):null})},ZU=n.p+"static/media/no_documents_found.4a4d455e.svg",YU={location:{state:"State",county:"County"},FSA:"Farm Number",regulatoryPermit:"Permit ID",Notes:"Notes"},HU=n.p+"static/media/farm_icon.04979a52.svg",GU=n(2827),WU=function(e){var t,n=e.title,a=e.description,r=e.icon,c=e.setEnableEdit;return Object(y.jsx)("div",{children:Object(y.jsxs)("div",{className:"flex flex-row items-center justify-between mb-6",children:[Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"h-10 w-10 bg-neutral-100 rounded flex flex-row justify-center p-2",children:Object(y.jsx)("img",{alt:"".concat(Object(ne.capitalize)(n)," Icon"),src:r})}),Object(y.jsxs)("div",{"data-testid":"".concat(null===(t=Object(ne.kebabCase)(n))||void 0===t?void 0:t.toLowerCase(),"-info"),className:"flex flex-col pl-2",children:[Object(y.jsx)("span",{className:"text-base font-semibold",children:n}),Object(y.jsx)("p",{className:"text-xs font-normal",children:a})]})]}),c&&Object(y.jsx)(m.Button,{style:{marginRight:"1rem"},type:"text",icon:Object(y.jsx)(GU.a,{}),onClick:function(){return c((function(e){return!e}))}})]})})};WU.defaultProps={setEnableEdit:void 0};var qU=WU,JU=function(e){var t=e.id,n=e.setEnableEdit,r=iB(t),c=r.farm,i=r.loading,o=Object(Zi.h)().setValues;return Object(a.useEffect)((function(){c&&o(c)}),[c]),Object(y.jsx)(y.Fragment,{children:i?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{children:[Object(y.jsx)(qU,{title:"Farm Information",description:"Specific property boundary relevant content not contained within any crop season",icon:HU,setEnableEdit:n}),Object(y.jsxs)(m.Tabs,{children:[Object(y.jsxs)(m.Tabs.Tab,{label:"Location",children:[Object(y.jsx)(oE,{label:YU.location.state,value:c.state}),Object(y.jsx)(oE,{label:YU.location.county,value:c.county})]}),Object(y.jsx)(m.Tabs.Tab,{label:"FSA",children:Object(y.jsx)(oE,{"data-testid":"farm-FSA",label:YU.FSA,value:c.farmNumber})}),Object(y.jsx)(m.Tabs.Tab,{"data-testid":"farm-regulatory-permit",label:"Regulatory Permit",children:Object(y.jsx)(oE,{label:YU.regulatoryPermit,value:c.permitId})}),Object(y.jsx)(m.Tabs.Tab,{label:"Notes",children:null!==c&&void 0!==c&&c.notes?Object(y.jsx)("p",{className:"text-sm font-normal",children:c.notes}):Object(y.jsx)("div",{className:"mt-10",children:Object(y.jsx)(jw,{title:"No Notes Found",overlayIcon:ZU,message:"Edit your farm information to add notes.",button:Object(y.jsx)(m.Button,{type:"primary",onClick:function(){return n((function(e){return!e}))},children:"Edit Farm Information"})})})})]})]})})};JU.defaultProps={id:""};var KU=JU,QU=n.p+"static/media/field_icon.a1fb7046.svg",XU=function(e){var t=e.id,n=e.setEnableEdit,r=Pv(t),c=r.field,i=r.loading,o=uE(),s=o.people,l=o.loading,d=Object(a.useState)(null),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(!0),v=Object(b.a)(f,2),O=v[0],h=v[1];Object(a.useEffect)((function(){c&&pn.fetch(c.propertyId).promise.then((function(e){var t=e.data;return p(t)})).catch(Ae.default).finally((function(){return h(!1)}))}),[c,p,t]);return c?Object(y.jsxs)("div",{children:[Object(y.jsx)(qU,{title:"Field Information",description:"Specific property boundary relevant content not contained within any crop season",icon:QU,setEnableEdit:n}),i||l||O?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(m.Tabs,{children:[Object(y.jsxs)(m.Tabs.Tab,{label:"Location",children:[Object(y.jsx)(oE,{label:"Center Latitude Longitude Point",value:c.coordinates}),Object(y.jsx)(oE,{label:"State",value:function(e){var t;return null===(t=Nl.find((function(t){return t.key===e})))||void 0===t?void 0:t.value}(c.state)}),Object(y.jsx)(oE,{label:"County",value:c.county}),Object(y.jsx)(oE,{label:"Land Owner",value:function(e){var t;return null===(t=s.find((function(t){return t.id===e})))||void 0===t?void 0:t.name}(c.landOwnerName),icon:vE})]}),Object(y.jsxs)(m.Tabs.Tab,{label:"FSA",children:[Object(y.jsx)(oE,{label:"Farm Number",value:c.farmNumber||j.farmNumber}),Object(y.jsx)(oE,{label:"Field Number",value:c.fieldNumber}),Object(y.jsx)(oE,{label:"Tract Number",value:c.tractNumber}),Object(y.jsx)(oE,{label:"FSA Area",value:c.fsaArea}),Object(y.jsx)(oE,{label:"CLU ID",value:c.cluID}),Object(y.jsx)(oE,{label:"Rent Type",value:c.rentType}),Object(y.jsx)(oE,{label:"Land Owner Percentage",value:c.ownerPercentage}),Object(y.jsx)(oE,{label:"Tenant Percentage",value:c.tenantPercentage})]}),Object(y.jsxs)(m.Tabs.Tab,{label:"Regulatory Permit",children:[Object(y.jsx)(oE,{label:"Permit ID",value:c.permitId||j.permitId}),Object(y.jsx)(oE,{label:"Site ID",value:c.siteId})]}),Object(y.jsxs)(m.Tabs.Tab,{label:"Legal",children:[Object(y.jsx)(oE,{label:"Township",value:[c.township,c.townshipDirection]}),Object(y.jsx)(oE,{label:"Range",value:[c.range,c.rangeDirection]}),Object(y.jsx)(oE,{label:"Section",value:c.section}),Object(y.jsx)(oE,{label:"Meridian",value:c.meridian}),Object(y.jsx)(oE,{label:"Tax ID",value:c.propertyTaxId}),Object(y.jsx)(oE,{label:"Parcel Number",value:c.parcelNumber}),Object(y.jsx)(oE,{label:"Short Description",value:c.shortDescription}),Object(y.jsx)(oE,{label:"Legal Description",value:c.legalName})]}),Object(y.jsxs)(m.Tabs.Tab,{label:"Land",children:[Object(y.jsx)(oE,{label:"Slope Percentage",value:c.slope}),Object(y.jsx)(oE,{label:"Slope Length",value:c.slopeLength}),Object(y.jsx)(oE,{label:"Soil Type",value:c.soil}),Object(y.jsx)(oE,{label:"Hydrology Group",value:c.hydrologyGroup})]}),Object(y.jsxs)(m.Tabs.Tab,{label:"Water",children:[Object(y.jsx)(oE,{label:"Irrigated",value:c.irrigated}),Object(y.jsx)(oE,{label:"Water Source",value:c.waterSource}),Object(y.jsx)(oE,{label:"Water Origin",value:c.waterOrigin}),Object(y.jsx)(oE,{label:"Irrigation System",value:c.irrigationSystem}),Object(y.jsx)(oE,{label:"Pump Pressure",value:c.pumpPressure}),Object(y.jsx)(oE,{label:"Pump Lift",value:c.pumpLift}),Object(y.jsx)(oE,{label:"Pump Energy Source",value:c.energySource}),Object(y.jsx)(oE,{label:"Use Polyacrylamide (PAM)",value:c.usePolyacrylamide})]}),Object(y.jsx)(m.Tabs.Tab,{label:"Notes",children:null!==c&&void 0!==c&&c.notes?Object(y.jsx)("p",{className:"text-sm font-normal",children:c.notes}):Object(y.jsx)("div",{className:"mt-10",children:Object(y.jsx)(jw,{title:"No Notes Found",overlayIcon:ZU,message:"Edit your field information to add notes.",button:Object(y.jsx)(m.Button,{type:"primary",size:"lg",onClick:function(){return n((function(e){return!e}))},children:"Edit Field Information"})})})})]})]}):null},$U=n.p+"static/media/property_cropzone_icon.a124a546.svg",ez=n.p+"static/media/crop.48106cf7.svg",tz=function(e){var t,n,a,r,c,i,o,s,l,d,u=e.id,b=e.farmId,j=e.fieldId,p=e.setEnableEdit,f=dE(),v=f.companies,O=f.loading,h=Ov(u),x=h.cropZone,g=h.loading,C=Du(),P=C.crops,A=C.loading,S=iB(b),T=S.farm,N=S.loading,E=Pv(j),w=E.field,_=E.loading;return Object(y.jsxs)("div",{children:[Object(y.jsx)(qU,{title:"Crop Zone Information",description:"Specific property boundary relevant content not contained within any crop season",icon:$U,setEnableEdit:p}),g||_||N||A||O?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(m.Tabs,{children:[Object(y.jsx)(m.Tabs.Tab,{label:"Location",children:Object(y.jsx)(oE,{label:"Center Latitude Longitude Point",value:Bb(x.coordinates)})}),Object(y.jsxs)(m.Tabs.Tab,{label:"Crop",children:[Object(y.jsx)(oE,{label:"Crop",value:function(){var e;return null===(e=P.find((function(e){return e.id===x.cropId})))||void 0===e?void 0:e.name}(),icon:ez}),Object(y.jsx)(oE,{label:"Seed source",value:function(){var e;return null===(e=v.find((function(e){return e.id===x.seedSource})))||void 0===e?void 0:e.name}(),icon:mE}),Object(y.jsx)(oE,{label:"Insurance ID",value:x.insuranceId}),Object(y.jsx)(oE,{label:"Seed Lot ID",value:x.seedLotId})]}),Object(y.jsx)(m.Tabs.Tab,{label:"FSA",children:Object(y.jsx)(oE,{label:"FSA Area",value:x.fsaArea})}),Object(y.jsxs)(m.Tabs.Tab,{label:"Regulatory Permit",children:[Object(y.jsx)(oE,{label:"Permit ID",value:null!==(t=null!==(n=x.permitId)&&void 0!==n?n:w.permitId)&&void 0!==t?t:T.permitId}),Object(y.jsx)(oE,{label:"Site ID",value:null!==(a=x.siteId)&&void 0!==a?a:w.siteId}),Object(y.jsx)(oE,{label:"Crop Zone Block ID",value:x.cropZonePermitId})]}),Object(y.jsx)(m.Tabs.Tab,{label:"Land",children:Object(y.jsx)(oE,{label:"Tillage System",value:x.tillage})}),Object(y.jsxs)(m.Tabs.Tab,{label:"Water",children:[Object(y.jsx)(oE,{label:"Irrigated",value:null!==(r=x.irrigated)&&void 0!==r?r:w.irrigated}),Object(y.jsx)(oE,{label:"Water Source",value:null!==(c=x.waterSource)&&void 0!==c?c:w.waterSource}),Object(y.jsx)(oE,{label:"Water Origin",value:null!==(i=x.waterOrigin)&&void 0!==i?i:w.waterOrigin}),Object(y.jsx)(oE,{label:"Irrigation System",value:null!==(o=x.tileDrainage)&&void 0!==o?o:w.tileDrainage}),Object(y.jsx)(oE,{label:"Pump Pressure",value:null!==(s=x.pumpPressure)&&void 0!==s?s:w.pumpPressure}),Object(y.jsx)(oE,{label:"Pump Lift",value:null!==(l=x.pumplife)&&void 0!==l?l:w.pumpLift}),Object(y.jsx)(oE,{label:"Pump Energy Source",value:null!==(d=x.energySource)&&void 0!==d?d:w.energySource}),Object(y.jsx)(oE,{label:"Use Polyacrylamide (PAM)",value:x.usePolyacrylamide})]}),Object(y.jsx)(m.Tabs.Tab,{label:"Notes",children:null!==x&&void 0!==x&&x.notes?Object(y.jsx)("p",{className:"text-sm font-normal",children:x.notes}):Object(y.jsx)("div",{className:"mt-10",children:Object(y.jsx)(jw,{title:"No Notes Found",overlayIcon:ZU,message:"Edit your crop zone information to add notes.",button:Object(y.jsx)(m.Button,{type:"primary",onClick:function(){return p((function(e){return!e}))},children:"Edit Crop Zone Information"})})})})]})]})},nz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit,n=Object(Zi.h)().values;return Object(y.jsx)(Qi,{value:n.farmNumber,placeholder:"Enter farm number",control:m.Input,type:"text",name:"farmNumber",label:"Farm Number",disabled:!t})},az=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit,n=Object(Zi.h)().values;return Object(y.jsx)(Qi,{value:n.notes,control:m.TextArea,id:"notes",name:"notes",className:"h-32 overscroll-auto",disabled:!t,placeholder:"Enter notes"})},rz=function(e){var t=e.header,n=e.children,r=Object(a.useState)(!0),c=Object(b.a)(r,2),i=c[0],o=c[1];return Object(y.jsxs)("div",{className:"bg-white rounded mb-4",style:{boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.15)"},children:[Object(y.jsx)("div",{className:"py-6",children:Object(y.jsxs)("button",{className:"flex flex-row items-center focus:outline-none justify-between w-full",type:"button",onClick:function(){o(!i)},children:[Object(y.jsx)("span",{className:"ml-4 text-xl font-semibold",children:t}),Object(y.jsx)("img",{className:"pr-16px",src:i?Di:aA,alt:"expand collapse accordion"})]})}),i&&Object(y.jsx)("div",{className:"px-4 pb-4 grid grid-cols-2 col-gap-5 relative",children:n})]})},cz=function(e){var t=e.farm,n=e.setEdited,r=Object(Zi.h)(),c=r.values,i=r.setValues;return Object(a.useEffect)((function(){t&&i(t)}),[t,i]),Object(a.useEffect)((function(){ae.a.isEqual(t,c)?n(!1):n(!0)}),[t,c]),t?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(rz,{header:"Location",children:[Object(y.jsx)(MN,{label:"State",children:Object(y.jsx)(NN,{})}),Object(y.jsx)(MN,{label:"County",children:Object(y.jsx)(wN,{})})]}),Object(y.jsx)(rz,{header:"FSA",children:Object(y.jsx)(MN,{children:Object(y.jsx)(nz,{})})}),Object(y.jsx)(rz,{header:"Regulatory Permit",children:Object(y.jsx)(MN,{children:Object(y.jsx)(kN,{})})}),Object(y.jsx)(rz,{header:"Notes",children:Object(y.jsx)(MN,{children:Object(y.jsx)(az,{})})})]}):Object(y.jsx)(y.Fragment,{})},iz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Input,placeholder:"Enter CLU ID",type:"text",name:"cluID",label:"CLU ID",disabled:!t})},oz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Input,placeholder:"Enter field number",type:"text",id:"fieldNumber",name:"fieldNumber",label:"Field Number",disabled:!t})},sz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Input,placeholder:"Enter tract number",type:"text",id:"tractNumber",name:"tractNumber",label:"Tract Number",disabled:!t})},lz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Input,placeholder:"Enter area",type:"text",name:"fsaArea",label:"FSA Area",disabled:!t})},dz=function(e){var t=e.landOwnerList,n=Object(a.useContext)(ac),r=Object(b.a)(n,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Search,id:"landOwnerName",name:"landOwnerName",label:"Land Owner",items:t,placeholder:"Select Land Owner",type:"text",disabled:!r})},uz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{placeholder:"Enter land owner percentage",control:m.Input,type:"text",id:"ownerPercentage",name:"ownerPercentage",label:"Land Owner Percentage",disabled:!t})},bz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{placeholder:"Enter tenant percentage",control:m.Input,type:"text",id:"tenantPercentage",name:"tenantPercentage",label:"Tenant Percentage",disabled:!t})},jz=[{value:"None",key:"None"},{value:"Black Hills",key:"Black Hills"},{value:"Fifth Principal",key:"Fifth Principal"},{value:"Boise",key:"Boise"},{value:"Chickasaw",key:"Chickasaw"},{value:"Choctaw",key:"Choctaw"},{value:"Cimarron",key:"Cimarron"},{value:"Copper River",key:"Copper River"},{value:"Fairbanks",key:"Fairbanks"},{value:"First Principal",key:"First Principal"},{value:"Fourth Principal Extended",key:"Fourth Principal Extended"},{value:"Fourth Principal",key:"Fourth Principal"},{value:"Gila and Salt River ",key:"Gila and Salt River"},{value:"Humboldt",key:"Humboldt"},{value:"Huntsville",key:"Huntsville"},{value:"Indian",key:"Indian"},{value:"Kateel River",key:"Kateel River"},{value:"Louisiana",key:"Louisiana"},{value:"Michigan",key:"Michigan"},{value:"Montana Principal",key:"Montana Principal"},{value:"Mount Diablo",key:"Mount Diablo"},{value:"Navajo",key:"Navajo"},{value:"New Mexico Principal",key:"New Mexico Principal"},{value:"Saint Helena",key:"Saint Helena"},{value:"Saint Stephens",key:"Saint Stephens Stephens"},{value:"Salt Lake",key:"Salt Lake"},{value:"San Bernardino",key:"San Bernardino"},{value:"Second Principal",key:"Second Principal"},{value:"Seward",key:"Seward"},{value:"Sixth Principal",key:"Sixth Principal"},{value:"Tallahassee",key:"Tallahassee"},{value:"Third Principal",key:"Third Principal"},{value:"Uintah",key:"Uintah"},{value:"Umiat",key:"Umiat"},{value:"Ute",key:"Ute"},{value:"Washington",key:"Washington"},{value:"Willamette",key:"Willamette"},{value:"Wind River",key:"Wind River"}],pz=[{key:"None",value:"None"},{key:"Cash Rent",value:"Cash Rent"},{key:"Crop Share",value:"Crop Share"}],fz=[{key:"None",value:"None"},{key:"Clay",value:"Clay"},{key:"Silt",value:"Silt"},{key:"Sand",value:"Sand"},{key:"Loam",value:"Loam"},{key:"Sandy Clay",value:"Sandy Clay"},{key:"Silty Clay",value:"Silty Clay"},{key:"Sandy Clay Loam",value:"Sandy Clay Loam"},{key:"Silty Clay Loam",value:"Silty Clay Loam"},{key:"Clay Loam",value:"Clay Loam"},{key:"Silt Loam",value:"Silt Loam"},{key:"Sandy Loam",value:"Sandy Loam"},{key:"Loamy Sand",value:"Loamy Sand"}],mz=[{key:"None",value:"None"},{key:"A",value:"A"},{key:"B",value:"B"},{key:"C",value:"C"},{key:"D",value:"D"},{key:"A/D",value:"A/D"},{key:"B/D",value:"B/D"},{key:"C/D",value:"C/D"}],vz=[{key:"None",value:"None"},{key:"Irrigation District",value:"Irrigation District"},{key:"Municipal",value:"Municipal"},{key:"On Farm Pond",value:"On Farm Pond"},{key:"Reservoir",value:"Reservoir"},{key:"River",value:"River"},{key:"Stream",value:"Stream"},{key:"Tailwater",value:"Tailwater"},{key:"Well",value:"Well"}],Oz=[{key:"None",value:"None"},{key:"Aquifer",value:"Aquifer"},{key:"Watershed",value:"Watershed"}],hz=[{key:"None",value:"None"},{key:"Basin",value:"Basin"},{key:"Border",value:"Border"},{key:"Drip",value:"Drip"},{key:"Flood",value:"Flood"},{key:"Furrow",value:"Furrow"},{key:"Linear",value:"Linear"},{key:"Micro-sprinkler",value:"Micro-sprinkler"},{key:"Pivot",value:"Pivot"},{key:"Subsurface",value:"Subsurface"},{key:"Traveling Gun",value:"Traveling Gun"},{key:"Wheel Lines",value:"Wheel Lines"}],xz=[{key:"None",value:"None"},{key:"Diesel",value:"Diesel"},{key:"Electric",value:"Electric"},{key:"Natural Gas",value:"Natural Gas"},{key:"Propane",value:"Propane"}],gz=[{key:"None",value:"None"},{key:"conventional-till",value:"Conventional-Till"},{key:"intensive-till",value:"Intensive-Till"},{key:"mulch-till",value:"Mulch-Till"},{key:"no-till",value:"No-Till"},{key:"reduced-till",value:"Reduced-Till"},{key:"strip-till",value:"Strip-Till"}],Cz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{placeholder:"Select rent type",control:m.Select,type:"text",id:"rentType",name:"rentType",items:pz,label:"Rent Type",disabled:!t})},yz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Select,type:"text",id:"meridian",name:"meridian",items:jz,label:"Meridian",placeholder:"Select meridian",disabled:!t})},Pz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Input,type:"text",id:"propertyTaxId",name:"propertyTaxId",label:"Tax ID",placeholder:"Enter tax ID",disabled:!t})},Az=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Input,type:"text",id:"parcelNumber",name:"parcelNumber",label:"Parcel Number",placeholder:"Enter parcel number",disabled:!t})},Sz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.TextArea,type:"text",id:"shortDescription",name:"shortDescription",label:"Short Description",disabled:!t,placeholder:"Enter short description"})},Tz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.TextArea,type:"text",id:"legalName",name:"legalName",label:"Legal Description",disabled:!t,placeholder:"Enter legal description"})},Nz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit,n=Object(Zi.h)().setFieldValue;return Object(y.jsx)(Qi,{control:m.Input,type:"text",id:"slope",name:"slope",label:"Slope Percentage",disabled:!t,placeholder:"Enter slope percentage",onChange:function(e){return n("slope",e.target.value)}})},Ez=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit,n=Object(Zi.h)().setFieldValue;return Object(y.jsx)(Qi,{control:m.Input,type:"text",id:"slopeLength",name:"slopeLength",label:"Slope Length",disabled:!t,placeholder:"Enter slope length",onChange:function(e){return n("slopeLength",e.target.value)}})},wz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Select,type:"text",id:"soil",name:"soil",items:fz,label:"Soil Type",placeholder:"Select soil type",disabled:!t})},_z=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Select,type:"text",id:"hydrologyGroup",name:"hydrologyGroup",items:mz,label:"Hydrology Group",disabled:!t,placeholder:"Select hydrology group"})},Rz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Select,id:"irrigated",name:"irrigated",items:[{key:null,value:"Select irrigation status"},{key:!0,value:"Yes"},{key:!1,value:"No"}],label:"Irrigated",disabled:!t,placeholder:"Select irrigation status"})},Iz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Select,id:"waterSource",name:"waterSource",items:vz,label:"Water Source",disabled:!t,placeholder:"Select water source"})},Dz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Select,id:"waterOrigin",name:"waterOrigin",items:Oz,label:"Water Origin",disabled:!t,placeholder:"Select water origin"})},kz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Input,id:"pumpPressure",name:"pumpPressure",label:"Pump Pressure",disabled:!t,placeholder:"Enter pump pressure"})},Lz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Input,id:"pumpLift",name:"pumpLift",label:"Pump Lift",disabled:!t,placeholder:"Enter pump lift"})},Fz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Select,id:"energySource",name:"energySource",items:xz,label:"Pump Energy Source",disabled:!t,placeholder:"Select pump energy source"})},Mz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Select,id:"irrigationSystem",name:"irrigationSystem",items:hz,label:"Irrigation System",disabled:!t,placeholder:"Select irrigation system"})},Vz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Select,id:"usePolyacrylamide",name:"usePolyacrylamide",items:[{key:null,value:"Select polyacrylamide status"},{key:!0,value:"Yes"},{key:!1,value:"No"}],label:"Use Polyacrylamide (PAM)",disabled:!t,placeholder:"Select polyacrylamide status"})},Bz=function(e){var t=e.field,n=e.farm,r=e.setEdited,c=Object(Zi.h)(),i=c.values,o=c.setValues,s=uE(),l=s.people,d=s.loading,u=dE(),b=u.companies,j=u.loading,p=Object(a.useMemo)((function(){return Object(I.a)(Object(I.a)({},t),{},{permitId:(null===t||void 0===t?void 0:t.permitId)||(null===n||void 0===n?void 0:n.permitId),farmNumber:(null===t||void 0===t?void 0:t.farmNumber)||(null===n||void 0===n?void 0:n.farmNumber)})}),[t,n]);if(Object(a.useEffect)((function(){!t||d||j||o(p)}),[t,p,d,j,o]),Object(a.useEffect)((function(){ae.a.isEqual(p,i)?r(!1):r(!0)}),[p,i]),!t||d||j)return Object(y.jsx)(y.Fragment,{});var f=null===l||void 0===l?void 0:l.map((function(e){return{value:e.name,key:e.id}})),m=null===b||void 0===b?void 0:b.map((function(e){return{value:e.name,key:e.id}}));return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(rz,{header:"Location",children:[Object(y.jsx)(MN,{label:"State",children:Object(y.jsx)(NN,{})}),Object(y.jsx)(MN,{label:"County",children:Object(y.jsx)(wN,{})}),Object(y.jsx)(MN,{label:"Land Owner",children:Object(y.jsx)(dz,{landOwnerList:[{key:"none",value:"None"}].concat(Object(v.a)(f),Object(v.a)(m))})})]}),Object(y.jsxs)(rz,{header:"FSA",children:[Object(y.jsx)(MN,{children:Object(y.jsx)(nz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(oz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(sz,{})}),Object(y.jsx)(MN,{suffix:"ac",children:Object(y.jsx)(lz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(iz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Cz,{})}),Object(y.jsx)(MN,{suffix:"%",children:Object(y.jsx)(uz,{})}),Object(y.jsx)(MN,{suffix:"%",children:Object(y.jsx)(bz,{})})]}),Object(y.jsxs)(rz,{header:"Regulatory Permit",children:[Object(y.jsx)(MN,{children:Object(y.jsx)(kN,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(LN,{})})]}),Object(y.jsxs)(rz,{header:"Legal",children:[Object(y.jsx)(MN,{halfWidth:!0,children:Object(y.jsx)(_N,{})}),Object(y.jsx)(MN,{halfWidth:!0,children:Object(y.jsx)(RN,{})}),Object(y.jsx)(MN,{halfWidth:!0,children:Object(y.jsx)(IN,{})}),Object(y.jsx)(MN,{halfWidth:!0,children:Object(y.jsx)(DN,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(VN,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(yz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Pz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Az,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Sz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Tz,{})})]}),Object(y.jsxs)(rz,{header:"Land",children:[Object(y.jsx)(MN,{suffix:"%",children:Object(y.jsx)(Nz,{})}),Object(y.jsx)(MN,{suffix:"ft",children:Object(y.jsx)(Ez,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(wz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(_z,{})})]}),Object(y.jsxs)(rz,{header:"Water",children:[Object(y.jsx)(MN,{children:Object(y.jsx)(Rz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Iz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Dz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Mz,{})}),Object(y.jsx)(MN,{suffix:"PSI",children:Object(y.jsx)(kz,{})}),Object(y.jsx)(MN,{suffix:"ft",children:Object(y.jsx)(Lz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Fz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Vz,{})})]}),Object(y.jsx)(rz,{header:"Notes",children:Object(y.jsx)(MN,{children:Object(y.jsx)(az,{})})})]})},Uz=function(e){var t=e.companiesList,n=Object(a.useContext)(ac),r=Object(b.a)(n,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Select,id:"seedSource",placeholder:"Select seed source",name:"seedSource",label:"Seed Source",items:t,disabled:!r})},zz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Input,type:"text",name:"insuranceId",placeholder:"Enter insurance ID",label:"Insurance ID",disabled:!t})},Zz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Input,type:"text",name:"seedLotId",placeholder:"Enter seed lot ID",label:"Seed Lot ID",disabled:!t})},Yz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Input,id:"cropZonePermitId",name:"cropZonePermitId",placeholder:"Enter crop zone block ID",label:"Crop Zone Block ID",disabled:!t})},Hz=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].isEnableInfoTabEdit;return Object(y.jsx)(Qi,{control:m.Select,id:"tillage",name:"tillage",placeholder:"Select tillage system",items:gz,label:"Tillage System",disabled:!t})},Gz=function(e){var t=e.cropZone,n=e.farm,r=e.field,c=e.setEdited,i=Object(Zi.h)(),o=i.values,s=i.setValues,l=dE(),d=l.companies,u=l.loading,b=t&&n&&r&&!u,j=Object(a.useMemo)((function(){var e,a,c;return b?Object(I.a)(Object(I.a)({},t),{},{siteId:null!==(e=t.siteId)&&void 0!==e?e:r.siteId,permitId:null!==(a=null!==(c=t.permitId)&&void 0!==c?c:r.permitId)&&void 0!==a?a:n.permitId}):{}}),[b,r,n,t]);Object(a.useEffect)((function(){b&&s(j)}),[j,b,s]);if(Object(a.useEffect)((function(){!function(){var e=Object(I.a)({},j),t=Object(I.a)({},o);return Object.keys(e).forEach((function(n){e[n]=e[n]||"",t[n]=t[n]||""})),Object.keys(o).forEach((function(n){e[n]=e[n]||"",t[n]=t[n]||""})),ae.a.isEqual(e,t)}()&&b?c(!0):c(!1)}),[j,o]),!b)return Object(y.jsx)(y.Fragment,{});var p=null===d||void 0===d?void 0:d.map((function(e){return{value:e.name,key:e.id}}));return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(rz,{header:"Crop",children:[Object(y.jsx)(MN,{children:Object(y.jsx)(Uz,{companiesList:[{key:"none",value:"None"}].concat(Object(v.a)(p))})}),Object(y.jsx)(MN,{children:Object(y.jsx)(zz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Zz,{})})]}),Object(y.jsx)(rz,{header:"FSA",children:Object(y.jsx)(MN,{suffix:"ac",children:Object(y.jsx)(lz,{})})}),Object(y.jsxs)(rz,{header:"Regulatory Permit",children:[Object(y.jsx)(MN,{children:Object(y.jsx)(kN,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(LN,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Yz,{})})]}),Object(y.jsx)(rz,{header:"Land",children:Object(y.jsx)(MN,{children:Object(y.jsx)(Hz,{})})}),Object(y.jsxs)(rz,{header:"Water",children:[Object(y.jsx)(MN,{children:Object(y.jsx)(Rz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Iz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Dz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Mz,{})}),Object(y.jsx)(MN,{suffix:"PSI",children:Object(y.jsx)(kz,{})}),Object(y.jsx)(MN,{suffix:"ft",children:Object(y.jsx)(Lz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Fz,{})}),Object(y.jsx)(MN,{children:Object(y.jsx)(Vz,{})})]}),Object(y.jsx)(rz,{header:"Notes",children:Object(y.jsx)(MN,{children:Object(y.jsx)(az,{})})})]})},Wz=function(e){var t=e.children,n=e.header,a=e.className;return Object(y.jsxs)("div",{className:"bg-white rounded-lg shadow-lg",children:[n,Object(y.jsx)("div",{className:"p-4 ".concat(a),children:t})]})};Wz.defaultProps={className:"",header:null};var qz=Wz,Jz=n.p+"static/media/product-icon.3f08028a.svg",Kz=function(e){var t=e.cropZoneId,n=Object(a.useState)(!1),r=Object(b.a)(n,2),c=r[0],i=r[1];return{getActiveIngredients:Object(a.useCallback)((function(e){var n=Yn(hn,"cropzone/".concat(t,"/activeingredients")).create(e).promise;return i(!0),n.then((function(e){return e})).catch(Ae.default).catch((function(e){return e.response})).finally((function(){return i(!1)}))}),[t]),loading:c,setLoading:i}},Qz=function(){return Object(y.jsxs)("div",{className:"flex flex-col justify-center items-center pb-8",children:[Object(y.jsx)("img",{className:"px-8 py-8",src:kP,alt:"no-product-icon"}),Object(y.jsx)("h2",{className:"font-semibold font-md ",children:"No Products Found"})]})};var Xz=function(e){var t=Object(a.useState)([]),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(0),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(e),m=Object(b.a)(f,2),v=m[0],O=m[1],h=Object(a.useCallback)((function(e){c(e)}),[]),x=Object(a.useCallback)((function(){var e=j*v,t=r.slice(e,e+v);l(t)}),[r,j,v]);Object(a.useEffect)((function(){x()}),[r,j,x]);var g=Object(a.useCallback)((function(e){p(e)}),[]),C=r.length;return{allData:r,currentPageData:s,pageNo:j,pageSize:v,totalItems:C,updateAllData:h,recalculateCurrentPageData:x,handlePageChange:g,setPageSize:O}},$z="lbs / ac",eZ=function(e){var t=e.ingredient,n=Number.isFinite(null===t||void 0===t?void 0:t.totalQuantity)?t.totalQuantity.toFixed(2):0;return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:t.name}),Object(y.jsx)(m.Table.Cell,{children:"".concat(n," \n          ").concat((null===t||void 0===t?void 0:t.totalQuantityUnit)||$z)})]},t.id)},tZ=function(e,t,n){if(null===e||void 0===e||!e.length)return[];if(!n)return e;var a=e.map((function(e){return Object(ne.cloneDeep)(e)}));switch(t){case"name":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.name}],n);case"totalQuantity":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.totalQuantity}],n);default:return a}},nZ=[{field:"name",title:"Active Ingredient",sortable:!0},{field:"totalQuantity",title:"Quantity per Acre",sortable:!0}],aZ={dir:"asc",field:"totalQuantity"},rZ=function(e){var t=e.id,n=Object(a.useState)(aZ.field),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(aZ.dir),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Xz(wo),j=u.currentPageData,p=u.totalItems,f=u.handlePageChange,v=u.updateAllData,O=u.pageNo,h=Kz({cropZoneId:t}),x=h.loading,g=h.getActiveIngredients,C=Object(a.useCallback)((function(e,t){i(e),d(t),v((function(n){return tZ(n,e,t)}))}),[v]);Object(a.useEffect)((function(){var e=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=$P(),e.next=3,g({seasonIds:t});case 3:n=e.sent,a=tZ((null===n||void 0===n?void 0:n.data)||[],aZ.field,aZ.dir),v(a);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}),[g,v]);return x?Object(y.jsx)(m.Spinner,{}):p?Object(y.jsxs)("div",{className:"min-w-content","data-testid":"ingredient-table",style:{minWidth:"min-content"},children:[Object(y.jsx)(ol,{listType:"Ingredients",items:j,tableColumns:nZ,onSort:C,sortBy:c,sortDir:l,wrapperClassName:"overflow-scroll ".concat(j.length<=5?"h-full":"h-330px"),children:function(e){return e.rows.map((function(e){return Object(y.jsx)(eZ,{ingredient:e},e.id)}))}}),Object(y.jsx)("div",{className:"pb-12",children:Ho(p,O,f)})]}):Object(y.jsx)(Qz,{})},cZ=function(e){if(/^\d+/.test(e))return["~",parseInt(e,10)];var t=null===e||void 0===e?void 0:e.match(/(\D+)(\d+)?/);if(!t)return[e,1/0];var n=Object(b.a)(t,3),a=n[1],r=n[2],c=r?parseInt(r,10):-1/0;return[a.trim().toLowerCase(),c]},iZ=function(e){var t=e.items,n=void 0===t?[]:t,a=e.sortBy,r=void 0===a?[]:a,c=e.sortDir,i=void 0===c?[]:c,o=e.sorter,s=void 0===o?function(e,t){return t[e]}:o;if(!r||!i||r.length!==i.length)return n;var l=n.map((function(e){return Object(ne.cloneDeep)(e)}));return Object(ne.orderBy)(l,r.map((function(e){return function(t){return s(e,t)}})),i)},oZ=[{field:"applicationRate",title:"Application Rate",sortable:!0,width:"calc((100% - 85px) / 6)",position:"right"},{field:"costPerAcre",title:"Cost per Acre",sortable:!0,width:"calc((100% - 85px) / 6)",position:"right"},{field:"totalCost",title:"Total Cost",sortable:!0,width:"calc((100% - 85px) / 6)",position:"right"}],sZ={columns:{field:[{field:"productName",title:"Product Name",sortable:!0,width:"calc((100% - 85px) / 6)"},{field:"dateApplied",title:"Date Applied",sortable:!0,width:"calc((100% - 85px) / 6)"},{field:"totalAppliedArea",title:"Applied Area",sortable:!0,width:"calc((100% - 85px) / 6)"}].concat(oZ,[{field:"view",title:"",sortable:!1,width:"85px"}]),cropzone:[{field:"productName",title:"Product Name",sortable:!0,width:"calc((100% - 85px) / 6)"},{field:"dateApplied",title:"Date Applied",sortable:!0,width:"calc((100% - 85px) / 6)"},{field:"totalAppliedArea",title:"Applied Area",sortable:!0,width:"calc((100% - 85px) / 6)",position:"right"}].concat(oZ,[{field:"view",title:"",sortable:!1,width:"85px"}])},defaultSort:{cropzone:{dir:["asc","asc"],by:["dateApplied","productName"]},field:{dir:["asc","asc"],by:["dateApplied","productName"]}}},lZ=function(e){var t,n,r,c,i=e.product,o=Object(p.h)(),s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1];return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{children:null===i||void 0===i?void 0:i.productName}),Object(y.jsx)("div",{className:"text-xs text-neutral-60",children:null===i||void 0===i?void 0:i.productManufacturerName})]})}),Object(y.jsx)(m.Table.Cell,{children:mA(i.dateApplied,"MMM dd, yyyy")}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex w-full justify-end",children:[Object(y.jsx)(yf,{roundedTo:2,children:null===i||void 0===i?void 0:i.totalAppliedArea})," ","ac"]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex w-full justify-end",children:[Object(y.jsx)(yf,{roundedTo:2,children:null!==(t=null===i||void 0===i?void 0:i.applicationRate)&&void 0!==t?t:0})," ",Object(va.g)(null===i||void 0===i?void 0:i.applicationRateUnit)," / ac"]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex w-full justify-end",children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null!==(n=null===i||void 0===i||null===(r=i.costPerAcre)||void 0===r?void 0:r.toFixed(2))&&void 0!==n?n:0})," ","/ ac"]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex w-full justify-end",children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null!==(c=null===i||void 0===i?void 0:i.totalCost)&&void 0!==c?c:0})," ","total"]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("button",{type:"button",className:"flex items-center gap-1 px-2 py-2 rounded cursor-pointer hover:bg-blue-10 hover:text-blue-90",onClick:function(){return o.push("/app/tasks/".concat(null===i||void 0===i?void 0:i.taskId))},onMouseEnter:function(e){e.stopPropagation(),u(!0)},onMouseLeave:function(){return u(!1)},children:[Object(y.jsx)(XC,{fill:d?"#0092E4":"#14151C"})," ","View"]})})]})},dZ=function(e){var t,n,r,c,i,o=e.product,s=Object(p.h)(),l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1];return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{children:null===o||void 0===o?void 0:o.productName}),Object(y.jsx)("div",{className:"text-xs  text-neutral-60",children:null===o||void 0===o?void 0:o.productManufacturerName})]})}),Object(y.jsx)(m.Table.Cell,{children:mA(null===o||void 0===o?void 0:o.dateApplied,"MMM dd, yyyy")}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{children:[null===o||void 0===o||null===(t=o.appliedCropZones)||void 0===t?void 0:t.map((function(e,t){var n;return t<=2?Object(y.jsxs)("div",{className:"flex gap-1 items-start",children:[Object(y.jsx)(Kp,{id:"field-card-icon",width:18,height:18,features:[{geometry:e.geometry,type:"Feature"}]}),Object(y.jsx)("div",{children:e.name})]},null===e||void 0===e?void 0:e.productId):Object(y.jsxs)("div",{children:["+ ",(null===o||void 0===o||null===(n=o.appliedCropZones)||void 0===n?void 0:n.length)-3," more crop zones"]},null===e||void 0===e?void 0:e.productId)})),Object(y.jsxs)("div",{className:"text-xs text-neutral-60 text-left",children:[null!==(n=null===o||void 0===o?void 0:o.totalAppliedArea)&&void 0!==n?n:0," ac"]})]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex w-full justify-end",children:[Object(y.jsx)(yf,{roundedTo:2,children:null!==(r=null===o||void 0===o?void 0:o.applicationRate)&&void 0!==r?r:0})," ",Object(va.g)(null===o||void 0===o?void 0:o.applicationRateUnit)," / ac"]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex w-full justify-end",children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null!==(c=null===o||void 0===o?void 0:o.costPerAcre)&&void 0!==c?c:0})," ","/ ac"]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex w-full justify-end",children:[Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:null!==(i=null===o||void 0===o?void 0:o.totalCost)&&void 0!==i?i:0})," ","total"]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("button",{type:"button",className:"flex items-center gap-1 px-2 py-2 rounded cursor-pointer hover:bg-blue-10 hover:text-blue-90",onClick:function(){return s.push("/app/tasks/".concat(null===o||void 0===o?void 0:o.taskId))},onMouseEnter:function(e){e.stopPropagation(),j(!0)},onMouseLeave:function(){return j(!1)},children:[Object(y.jsx)(XC,{fill:u?"#0092E4":"#14151C"})," ","View"]})})]})},uZ=function(e,t){return"product"===e||"productName"===e?cZ(t[e]):t[e]},bZ=sZ.columns,jZ=sZ.defaultSort,pZ=function(e){var t=e.id,n=e.level,r=void 0===n?"field":n,c="field"===r,i=Object(a.useState)(!0),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(jZ[r].dir),j=Object(b.a)(d,2),p=j[0],f=j[1],v=Object(a.useState)(jZ[r].by),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useContext)(ac),C=Object(b.a)(g,2),P=C[0],A=P.organization,S=P.isSidebarOpen,T=C[1],N=bZ[r],E=Xz(wo),w=E.currentPageData,_=E.totalItems,R=E.handlePageChange,I=E.updateAllData,D=E.pageNo,k=function(){var e=Object(Y.a)(G.a.mark((function e(){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l(!0),n=$P(),a=J.a.post("".concat(u.d,"/v2/base/").concat(r,"/").concat(t,"/appliedproducts"),{seasonIds:n},{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:A.id}),Authorization:"Bearer ".concat(Ve())}}),e.next=5,a.then((function(e){var t=e.data;I(iZ({items:t,sortBy:jZ[r].by,sortDir:jZ[r].dir,sorter:uZ}))})).catch(Ae.default).catch((function(e){uc(T)(e)})).finally((function(){l(!1)}));case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),L=function(){return!s},F=Object(a.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"asc",n=[e],a=[t];x(n),f(a),I((function(e){return iZ({items:e,sortBy:n,sortDir:a,sorter:uZ})}))}),[I]);Object(a.useEffect)((function(){k()}),[t]);var M=Object(y.jsx)(qU,{title:"Applied Products",description:"All products used during the selected crop season",icon:Jz});return L()&&!_?Object(y.jsxs)(y.Fragment,{children:[c&&M,Object(y.jsx)(Qz,{})]}):Object(y.jsxs)("div",{children:[c&&M,L()?Object(y.jsx)(y.Fragment,{children:_>0?Object(y.jsxs)("div",{className:"cwf-property-sticky-table","data-testid":"applied-products-table",children:[Object(y.jsx)(ol,{listType:"Applied Products",items:w,tableColumns:N,onSort:F,sortBy:h[0],sortDir:p[0],children:function(e){return e.rows.map((function(e){return Object(y.jsx)(y.Fragment,{children:c?Object(y.jsx)(dZ,{product:e},Object(Wu.a)()):Object(y.jsx)(lZ,{product:e},Object(Wu.a)())})}))}}),Object(y.jsxs)("div",{className:"flex justify-between pt-12px",children:[c&&Object(y.jsxs)("div",{className:"flex items-center ".concat(S?"":"flex-grow"),children:[Object(y.jsx)("img",{src:B_,alt:"info-icon"}),Object(y.jsx)("span",{className:"pl-8px font-sm text-neutral-1000",children:"To view more product details, select a crop zone from the farm-field-tree on the left."})]}),Object(y.jsx)("div",{className:"".concat(S?"w-full":"w-auto"),children:Ho(_,D,R)})]})]}):Object(y.jsx)(Qz,{})}):Object(y.jsx)(m.Spinner,{})]})},fZ=function(e){var t=e.id,n=Ov(t),r=n.cropZone,c=n.loading,i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(!1),u=Object(b.a)(d,2),j=u[0],p=u[1];Object(a.useEffect)((function(){var e,n;p(!1);var a=null===ac||void 0===ac||null===(e=ac._currentValue[0])||void 0===e||null===(n=e.organization)||void 0===n?void 0:n.id,r=$P();hn.createChildApi({action:"cropzone/".concat(t,"/fertilizers")}).post({seasonIds:r},{headers:{"cwf-context":JSON.stringify({organization_id:a})}}).promise.then((function(e){l([{name:"Nitrogen (N)",value:e.data.n||0},{name:"Phosphorus (P)",value:e.data.p||0},{name:"Potassium (K)",value:e.data.k||0}])})).catch((function(){return p(!0)}))}),[t,r]);return j?"Failed to load fertilizer summation data":Object(y.jsx)("div",{children:c?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{className:"mb-6",children:[Object(y.jsx)("div",{className:"mt-6",children:"MAJOR"}),s.map((function(e){return Object(y.jsx)(oE,{label:e.name,value:"".concat(e.value.toFixed(2)," lbs")},e.name)}))]})})},mZ=function(e){var t=e.id;return Object(y.jsxs)("div",{children:[Object(y.jsx)(qU,{title:"Products",description:"All active and used products during the selected crop season",icon:Jz}),Object(y.jsxs)(m.Tabs,{children:[Object(y.jsx)(m.Tabs.Tab,{label:"All Applied Products",children:Object(y.jsx)(pZ,{level:"cropzone",id:t})}),Object(y.jsx)(m.Tabs.Tab,{label:"Fertilizer Summation",children:Object(y.jsx)(fZ,{id:t})}),Object(y.jsx)(m.Tabs.Tab,{label:"Active Ingredient Summary",children:Object(y.jsx)(rZ,{id:t})})]})]})},vZ=n.p+"static/media/historyIcon.5b70d192.svg",OZ=function(e,t){return"crop"===e||"variety"===e||"cropSeasonName"===e?cZ(t[e]):t[e]},hZ=function(e){return"string"===typeof e?e.trim().toLowerCase():e},xZ=function(e,t){var n=new Map(t.map((function(e){return["".concat(hZ(e.id)),e]})));return e.map((function(e){var t="".concat(hZ(e.cropZoneId)),a=n.get(t);return Object(I.a)({cropseason:e.cropseason,cropname:e.cropname,cropId:e.cropId,cropZoneId:e.cropZoneId},a||{})}))},gZ=function(e){return e.toLowerCase().split(" ").map((function(e,t){return 0===t?e:e.charAt(0).toUpperCase()+e.slice(1)})).join("")},CZ=function(e){var t,n,a,r,c,i=e.data,o=null===i||void 0===i||null===(t=i.appliedArea)||void 0===t?void 0:t.toFixed(2),s="---",l=Object(I.a)(Object(I.a)({},i),{},{name:null===i||void 0===i||null===(n=i.cropname)||void 0===n?void 0:n.replace(/ /g,"")}),d=null!==l&&void 0!==l&&null!==(a=l.name)&&void 0!==a&&a.includes(":")?null===l||void 0===l?void 0:l.name.split(":").map((function(e){return gZ(e.trim())})).join(""):null===l||void 0===l?void 0:l.name;return Object(y.jsxs)(m.Table.Row,{className:"bg-white",children:[Object(y.jsx)(m.Table.Cell,{children:null!==(r=null===i||void 0===i?void 0:i.cropseason)&&void 0!==r?r:s}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex gap-1",children:[d in yg?Object(y.jsx)(Ag,{cropObject:l}):Object(y.jsx)("img",{src:LI.default,alt:"crop"}),null===i||void 0===i?void 0:i.cropname]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{children:null!==(c=null===i||void 0===i?void 0:i.variety)&&void 0!==c?c:s})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{children:i.plantingDate?Object(y.jsx)("div",{children:mA(null===i||void 0===i?void 0:i.plantingDate,"MMM dd, yyyy")}):s})}),Object(y.jsx)(m.Table.Cell,{children:null!==i&&void 0!==i&&i.appliedArea?Object(y.jsxs)("div",{children:[Object(y.jsxs)("div",{className:"flex gap-1 items-start",children:[Object(y.jsx)(Kp,{id:"field-card-icon",width:18,height:18,features:[{geometry:i.geometry,type:"Feature"}]}),Object(y.jsx)("div",{children:null===i||void 0===i?void 0:i.cropname})]}),Object(y.jsx)("div",{className:"text-xs text-neutral-60 text-left",children:"".concat(o," ac")})]}):s})]})},yZ=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2),n=t[0].organization,r=t[1],c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)([]),d=Object(b.a)(l,2),j=d[0],p=d[1],f=Object(a.useState)(!1),m=Object(b.a)(f,2),v=m[0],O=m[1],h=Object(a.useState)([]),x=Object(b.a)(h,2),g=x[0],C=x[1],y=Object(a.useState)(0),P=Object(b.a)(y,2),A=P[0],S=P[1],T=function(e){return J.a.get("".concat(u.d,"/v3/base/cropzone/").concat(e,"/crop-varieties"),{headers:{"cwf-context":JSON.stringify({organization_id:n.id}),Authorization:"Bearer ".concat(Ve())}})},N=function(){var e=Object(Y.a)(G.a.mark((function e(t,a){var c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s(!0),c=J.a.post("".concat(u.d,"/v2/base/field/").concat(a,"/crophistory?pageNo=").concat(t,"&size=").concat(wo),{},{headers:{"cwf-context":JSON.stringify({organization_id:n.id}),Authorization:"Bearer ".concat(Ve())}}),e.next=4,c.then((function(e){var t=e.data;p(t)})).catch(Ae.default).catch((function(e){uc(r)(e)})).finally((function(){s(!1)}));case 4:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();return{isLoadingCropHistory:o,cropHistoryData:j,isLoadingVariety:v,varietyData:g,currentPage:A,setCurrentPage:S,getCropVariety:T,getCropHistory:N,resolvedCropVariety:function(){o||(O(!0),Promise.allSettled(j.results.map((function(e){var t=e.cropZoneId;return T(t)}))).then((function(e){var t=e.map((function(e){return"fulfilled"===e.status?e.value.data:{}}));C(t)})).catch(Ae.default).catch((function(e){uc(r)(e)})).finally((function(){return O(!1)})))},resetVariety:function(){C([{}])}}},PZ=function(e){var t,n,a=e.data,r=Object(I.a)(Object(I.a)({},a),{},{name:null===a||void 0===a||null===(t=a.cropname)||void 0===t?void 0:t.replace(/ /g,"")}),c=null!==r&&void 0!==r&&null!==(n=r.name)&&void 0!==n&&n.includes(":")?null===r||void 0===r?void 0:r.name.split(":").map((function(e){return gZ(e.trim())})).join(""):null===r||void 0===r?void 0:r.name;return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{style:{wordBreak:"break-word",whiteSpace:"normal",overflowWrap:"break-word"},children:Object(y.jsx)("div",{children:null===a||void 0===a?void 0:a.cropseason})})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex gap-1 h-4",children:[c in yg?Object(y.jsx)(Ag,{cropObject:r}):Object(y.jsx)("img",{src:LI.default,alt:""}),null===a||void 0===a?void 0:a.cropname]})})]})},AZ=function(e){return e.flatMap((function(e){var t;return null!==e&&void 0!==e&&null!==(t=e.varieties)&&void 0!==t&&t.length?e.varieties.map((function(t){return{cropname:e.cropname,cropseason:e.cropseason,cropId:e.cropId,cropZoneId:e.cropZoneId,geometry:e.geometry,variety:t.name,plantingDate:t.plantingDate,appliedArea:t.appliedArea}})):[{cropname:e.cropname,cropseason:e.cropseason,cropId:e.cropId,cropZoneId:e.cropZoneId}]}))},SZ=function(e,t,n,a,r,c,i,o){var s=[e],l=[t],d={sortBy:s,sortDir:l,sorter:o};c(s),i(l),(n?a:r)((function(e){return iZ(Object(I.a)({items:e},d))}))},TZ={by:["cropseason","cropname"],dir:["asc","asc"]},NZ={by:["cropseason","cropname","variety","plantingDate","appliedArea"],dir:["asc","asc","asc","asc"]},EZ=[{field:"cropseason",title:"Crop Season",sortable:!0,width:"197px"},{field:"cropname",title:"Crop",sortable:!0,width:"197px"}],wZ=[{field:"cropseason",title:"Crop Season",sortable:!0,width:"197px"},{field:"cropname",title:"Crop",sortable:!0,width:"197px"},{field:"variety",title:"Variety",sortable:!0,width:"197px"},{field:"plantingDate",title:"Date Planted",sortable:!0,width:"197px"},{field:"appliedArea",title:"Area",sortable:!0,width:"197px"}],_Z=function(e){var t=e.id,n=e.level,r="field"===(void 0===n?"field":n),c=Object(a.useState)(TZ.by),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(TZ.dir),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Pv(t).field,f=Object(a.useState)([]),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)([]),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(!1),S=Object(b.a)(A,2),T=S[0],N=S[1],E=yZ(),w=E.isLoadingCropHistory,_=E.cropHistoryData,R=E.isLoadingVariety,I=E.varietyData,D=E.resetVariety,k=E.currentPage,L=E.setCurrentPage,F=E.getCropHistory,M=E.resolvedCropVariety,V=function(e){N(!1),D(),L(e)};Object(a.useEffect)((function(){T&&M()}),[T]),Object(a.useEffect)((function(){null!==I&&void 0!==I&&I.length&&!R&&P(iZ({items:AZ(xZ(null===_||void 0===_?void 0:_.results,I)),sortBy:NZ.by,sortDir:wZ.dir,sorter:OZ}))}),[R]),Object(a.useEffect)((function(){var e;null!==_&&void 0!==_&&null!==(e=_.results)&&void 0!==e&&e.length&&!w&&h(iZ({items:null===_||void 0===_?void 0:_.results,sortBy:TZ.by,sortDir:TZ.dir,sorter:OZ}))}),[w]);var B=Object(a.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"asc";SZ(e,t,T,P,h,s,j,OZ)}),[T]);Object(a.useEffect)((function(){F(k,t)}),[t,k]);var U=function(){return T},z=function(){return R?Object(y.jsxs)("div",{className:"flex flex-col",children:[Object(y.jsx)("p",{className:"",children:Object(y.jsx)(m.Spinner,{})}),Object(y.jsx)("span",{className:"text-center font-semibold text-base pt-4",children:"Loading..."})]}):U()?Object(y.jsx)("div",{style:{width:"100%"},children:Object(y.jsx)(ol,{"data-testid":"crop-history-table-full",listType:"Crop History",items:C||[],tableColumns:wZ,onSort:B,sortBy:o[0],sortDir:u[0],wrapperClassName:C.length<=5?"h-full":"h-330px",children:function(e){return e.rows.map((function(e){return Object(y.jsx)(CZ,{data:e,isField:r},Object(Wu.a)())}))}},k)}):Object(y.jsx)(ol,{"data-testid":"crop-history-table-summary",listType:"Crop History",items:O||[],tableColumns:EZ,onSort:B,sortBy:o[0],sortDir:u[0],wrapperClassName:O.length<=5?"h-full":"h-330px",children:function(e){return e.rows.map((function(e){return Object(y.jsx)(PZ,{data:e,isField:r},Object(Wu.a)())}))}},k)};return Object(y.jsxs)("div",{children:[Object(y.jsx)(qU,{title:"Crop History",description:"All crops ever planted on field ".concat(null===p||void 0===p?void 0:p.name),icon:vZ}),w?Object(y.jsx)(m.Spinner,{}):O.length>0?Object(y.jsxs)("div",{className:"".concat(U()?"cwf-property-sticky-table":"cwf-property-not-sticky"," min-w-content"),children:[z(),Ho(_.totalElements,k,V,void 0,void 0,T,N)]}):Object(y.jsx)(jw,{title:"No Crop History Found",overlayIcon:ZU})]})},RZ=n.p+"static/media/property_yield_icon.f07002e8.svg",IZ=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,c,i,o;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.fieldId,a=t.cropZoneId,r(!0),c=localStorage.getItem("selectedOrganizationId"),i=n?JSON.parse(localStorage.getItem("selectedCropSeasons")):void 0,o=a?"cropzone/".concat(a):"field/".concat(n),e.abrupt("return",J.a.get("".concat(u.e,"/yield/summary/").concat(o,"/crop-overview"),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:c}),Authorization:"Bearer ".concat(Ve())},params:{cropSeasonIds:i}}).then((function(e){return e.data})).catch(Ae.default).catch((function(e){uc(e)})).finally((function(){r(!1)})));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{getYieldCropOverview:c,loading:n}},DZ={Alfalfa:60,"Alfalfa : Alfalfa Seed":60,Barley:48,"Bean : Snap Beans":25,"Clover : ALL":60,Corn:56,"Corn : White":56,"Corn : Yellow":56,"Corn : Earlage":56,"Corn : Indian":56,"Corn : Popcorn":56,"Corn : Sweet":70,"Corn : Sweet, Fresh":70,"Corn : Sweet, Processed":70,"Cotton : ALL":32,Flax:60,"Tall Fescue : ALL":14,"Orchard Grass":14,Timothy:45,Millet:50,Rape:60,Oats:32,Soybeans:60,"Grain Sorghum":56,Rye:56,Rice:45,"Rice : Hybrid":45,"Rice : Wild":45,Sunflower:24,"Sweet Potato":50,"Sweet Potato : Commercial":50,"Sweet Potato : Plant Bed":50,Vetch:60,Wheat:60,"Wheat : Club":60,"Wheat : Dark Northern Spring":60,"Wheat : Durum":60,"Wheat : Hard Red":60,"Wheat : Hard Red Spring":60,"Wheat : Hard Red Winter":60,"Wheat : Hard White":60,"Wheat : Hard White Spring":60,"Wheat : Hard White Winter":60,"Wheat : Soft Red":60,"Wheat : Soft Red Winter":60,"Wheat : Soft White Spring":60,"Wheat : Soft White Winter":60};function kZ(e){if(e){var t=e.split(" : ",2),n=Object(b.a)(t,2),a=n[0],r=n[1],c=a;if(r&&(c+=" : ".concat(r)),void 0!==DZ[c])return DZ[c];var i="".concat(a," : ALL");return void 0!==DZ[i]?DZ[i]:void 0}}function LZ(e,t){try{var n=kZ(t);return n?{value:FS.b.divideSafeRound(e,n),unit:va.a.BUSHEL}:{value:new Z_.a(e).toNumber(),unit:va.a.POUND}}catch(a){return}}var FZ=function(e){var t=e.data,n=Object(a.useContext)(ac),r=Object(b.a)(n,1)[0].cropSeasons,c=function(e,t){var n=LZ(e,t);if(n)return"".concat(xR(n.value,Object(va.g)(n.unit))," / ac")},i=function(e,t){var n=LZ(e,t);if(n)return xR(n.value,Object(va.g)(n.unit))},o=ae.a.compact(ae.a.flatten(r.map((function(e){return e.crops})))),s=ae.a.flatten([t]).map((function(e){return Object(I.a)(Object(I.a)({},e),{},{crop:o.find((function(t){return t.id===e.cropId}))})})).sort((function(e,t){return e.crop.name.localeCompare(t.crop.name)})).map((function(e,t){return Object(y.jsxs)("div",{className:t>0?"mt-8":null,children:[Object(y.jsxs)(Xc.Row,{prefixCls:"syt-antd-row",children:[Object(y.jsx)(Ag,{cropObject:e.crop,size:18}),Object(y.jsx)("span",{className:"ml-1",children:e.crop.name.toUpperCase()})]}),Object(y.jsx)(oE,{label:"Avg. Yield per Acre",value:c(e.avgYieldPerAcre,e.crop.name)}),Object(y.jsx)(oE,{label:"Total Harvested Yield",value:i(e.totalHarvestedYield,e.crop.name),unit:"bu"}),Object(y.jsx)(oE,{label:"Total Number of Harvested Loads",value:e.numYieldLoads})]},e.crop.id)}));return Object(y.jsx)("div",{className:"pb-4",children:s})},MZ=n.p+"static/media/equipment.878147bf.svg",VZ=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,c,i,o,s,l,d,b,j,p,f,m,v,O,h,x,g,C,y;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.limit,a=void 0===n?50:n,c=t.page,i=void 0===c?0:c,o=t.sortBy,s=void 0===o?"name":o,l=t.sortDir,d=void 0===l?"asc":l,b=t.seasonIds,j=void 0===b?[]:b,p=t.cropIds,f=t.searchQuery,m=t.startDate,v=t.endDate,O=t.loadTypes,h=t.cropZoneIds,x=t.storageIds,g=t.saleIds,r(!0),C=localStorage.getItem("selectedOrganizationId"),y={seasonIds:j,cropIds:null!==p&&void 0!==p&&p.length?p:void 0,searchQuery:f||void 0,startDate:m||void 0,endDate:v||void 0,loadTypes:null!==O&&void 0!==O&&O.length?O:void 0,storageIds:null!==x&&void 0!==x&&x.length?x:void 0,saleIds:null!==g&&void 0!==g&&g.length?g:void 0,cropZoneIds:null!==h&&void 0!==h&&h.length?h:void 0},e.abrupt("return",J.a.post("".concat(u.e,"/yield/list"),y,{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:C}),Authorization:"Bearer ".concat(Ve())},params:{limit:a,page:i,sortBy:s,sortDir:d}}).then((function(e){return e.data})).catch(Ae.default).catch((function(){return{}})).finally((function(){r(!1)})));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i=Object(a.useCallback)((function(e){r(!0);var t=localStorage.getItem("selectedOrganizationId");return J.a.get("".concat(u.e,"/yield/").concat(e),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:t}),Authorization:"Bearer ".concat(Ve())}}).then((function(e){return e.data})).catch(Ae.default).catch((function(){})).finally((function(){return r(!1)}))}),[]),o=Object(a.useCallback)((function(e){var t=e.id;r(!0);var n=localStorage.getItem("selectedOrganizationId");return J.a.delete("".concat(u.e,"/yield/").concat(t),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:n}),Authorization:"Bearer ".concat(Ve())}}).then((function(e){return e.status})).catch(Ae.default).catch((function(){})).finally((function(){return r(!1)}))}),[]),s=Object(a.useState)(),l=Object(b.a)(s,2),d=l[0],j=l[1],p=Object(a.useState)(null),f=Object(b.a)(p,2),m=f[0],v=f[1],O=Object(a.useCallback)((function(e){var t=localStorage.getItem("selectedOrganizationId"),n={"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:t}),Authorization:"Bearer ".concat(Ve())};J.a.get("".concat(u.e,"/yield/").concat(e),{headers:n}).then((function(e){var t=e.data;j(t)})).catch(Ae.default)}),[]),h=Object(a.useCallback)((function(e,t){r(!0);var n=localStorage.getItem("selectedOrganizationId"),a={"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:n}),Authorization:"Bearer ".concat(Ve())};return J.a.put("".concat(u.e,"/yield/").concat(e),t,{headers:a}).then((function(e){var t=e.data;j(t)})).catch(Ae.default).catch((function(e){throw v(e),e})).finally((function(){r(!1)}))}),[]),x=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=localStorage.getItem("selectedOrganizationId"),a={"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:n}),Authorization:"Bearer ".concat(Ve())},r=J.a.post("".concat(u.e,"/yield/bulk"),t,{headers:a}),e.abrupt("return",r.then((function(e){return e.data})).catch(Ae.default).catch((function(){})));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[]);return{getLoadDetails:i,deleteLoad:o,getLoads:c,loading:n,getLoadById:O,yieldLoad:d,submitError:m,updateLoadById:h,saveAllLoads:x}},BZ=n.p+"static/media/crop_zone.bc6345cc.svg",UZ=n.p+"static/media/sale.53f82a1e.svg",zZ=n.p+"static/media/storage.cc443d13.svg",ZZ=function(e,t){if(e&&t){var n=CR(e);return n?"".concat(n," / ").concat(t):void 0}};n(1557);function YZ(e){var t=e.icon,n=e.onClick,a=e.text,r=e.compact,c=r?"compact-action-button hover:text-blue-90 py-6px px-2 rounded":"action-button hover:text-cucumber-green-700";return Object(y.jsxs)("button",{className:"flex gap-1 items-center ".concat(c),onClick:n,onKeyDown:function(e){return"Enter"===e.nativeEvent.key&&n(e)},tabIndex:r?void 0:0,type:"button",children:[Object(y.jsx)(Xc.Tooltip,{className:"xl:hidden",title:a,children:t}),Object(y.jsx)("div",{className:"hidden xl:block",children:t}),Object(y.jsx)("span",{className:"hidden xl:block",children:a})]})}function HZ(e){var t=e.onRecordView,n=e.onRecordDelete,a=e.onRecordEdit,r=e.compact;return Object(y.jsxs)("div",{"data-testid":"action-table-cell",className:"flex justify-end gap-1",children:[Object(y.jsx)(YZ,{icon:Object(y.jsx)("img",{src:FM,className:"min-w-1rem",alt:"View yield load icon button"}),onClick:t,text:"View",compact:r}),!r&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"text-neutral-60",children:"|"}),Object(y.jsx)(YZ,{icon:Object(y.jsx)("img",{src:DI,className:"min-w-1rem",alt:"Edit yield load icon button"}),onClick:a,text:"Edit"})]}),!r&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"text-neutral-60",children:"|"}),Object(y.jsx)(YZ,{icon:Object(y.jsx)("img",{src:kI,className:"min-w-1rem",alt:"Delete yield load icon button"}),onClick:n,text:"Delete"})]})]})}YZ.defaultProps={icon:Object(y.jsx)("div",{children:"icon"}),text:"",onClick:function(){},compact:!1},HZ.defaultProps={onRecordView:function(){},onRecordEdit:function(){},onRecordDelete:function(){},compact:!1};n(1558);function GZ(e){var t=e.tableData,n=e.onRecordView,r=e.onRecordDelete,c=e.onRecordEdit,i=e.pagination,o=e.onChange,s=e.sortBy,l=e.sortDir,d=e.compact,u=e.isCropSortable,j=e.renderTruckColumn,p=e.renderDriverColumn,f=Object(a.useRef)(null),m=Object(a.useState)(0),v=Object(b.a)(m,2),O=v[0],h=v[1];Object(a.useEffect)((function(){var e=function(){return h(f.current.clientHeight)};return e(),f.current&&window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[f,t]);var x=[{title:"Load Info",dataIndex:"date",key:"date",fixed:d?"left":void 0,sorter:!0,sortOrder:"date"===s&&l,className:MM("date",s,l),render:function(e,t){return Object(y.jsxs)("div",{className:d?"w-197px":void 0,children:[Object(y.jsx)("div",{children:t.name}),Object(y.jsx)("div",{className:"text-xs text-neutral-60",children:mA(e,"MMM d, yyyy, hh:mm a")})]})}},{title:"Crop",dataIndex:"cropName",key:"cropName",sorter:u,sortOrder:u?"cropName"===s&&l:void 0,className:MM("cropName",s,l),render:function(e){return Object(y.jsxs)("div",{className:"flex items-start gap-1 ".concat(d?"w-197px":""),children:[e?Object(y.jsx)(Ag,{cropObject:{name:e}}):"",e||"---"]})}},{title:"Yield Quantity",dataIndex:"load",key:"load",sorter:!0,sortOrder:"load"===s&&l,className:MM("load",s,l),align:"right",render:function(e,t){return Object(y.jsx)("div",{className:d?"w-180px":void 0,children:e?xR(e,Object(va.g)(t.loadUnit)):"---"})}},{title:"Sale Info",dataIndex:"grossRevenue",key:"grossRevenue",sorter:!0,sortOrder:"grossRevenue"===s&&l,className:MM("grossRevenue",s,l),align:"right",render:function(e,t){return Object(y.jsxs)("div",{className:"min-w-80px ".concat(d?"w-197px":""),children:[Object(y.jsx)("div",{children:isNaN(e)||null===e?"---":CR(e)}),Object(y.jsx)("div",{className:"text-xs text-neutral-60",children:e&&t.salePrice?ZZ(t.salePrice,Object(va.g)(t.loadUnit)):"---"})]})}},{title:"Source",dataIndex:"sources",key:"sources",render:function(e,t){return null!==e&&void 0!==e&&e.length?"CROP_ZONE"===t.sourceType?Object(y.jsxs)("div",{className:d?"w-197px":void 0,children:[Object(y.jsxs)("div",{className:"flex items-start gap-1",children:[Object(y.jsx)("img",{src:BZ,alt:"Crop zone icon"}),1===e.length?"1 crop zone":"".concat(e.length," crop zones")]}),Object(y.jsx)("div",{className:"text-xs text-neutral-60",children:Boolean(t.totalArea)&&"".concat(Number(t.totalArea).toFixed(2)," ac")})]}):"STORAGE"===t.sourceType?Object(y.jsxs)("div",{className:"flex items-center gap-2",children:[Object(y.jsx)("img",{src:zZ,alt:"Storage icon",className:"h-15px"}),e[0].name]}):"---":"---"}},{title:"Destination",dataIndex:"destination",key:"destination",render:function(e,t){return e?"STORAGE"===t.destinationType?Object(y.jsxs)("div",{className:"flex items-center gap-2 ".concat(d?"w-197px":""),children:[Object(y.jsx)("img",{src:zZ,alt:"Storage icon",className:"h-15px"}),e.name]}):"SALE"===t.destinationType?Object(y.jsxs)("div",{className:"flex items-center gap-2 ".concat(d?"w-197px":""),children:[Object(y.jsx)("img",{src:UZ,alt:"Sale icon"}),e.name]}):"---":"---"}}];p&&x.push({title:"Driver",dataIndex:"driverId",key:"driver",render:function(e){return Object(y.jsx)("div",{className:d?"w-197px":void 0,children:p(e)})}}),j&&x.push({title:"Truck",dataIndex:"truckId",key:"truck",render:function(e){return Object(y.jsx)("div",{className:d?"w-197px":void 0,children:j(e)})}}),x.push({key:"actions",render:function(e,t){return Object(y.jsx)(HZ,{onRecordView:function(){return n(t.id)},onRecordEdit:function(e){e.stopPropagation(),c(t.id)},onRecordDelete:function(e){e.stopPropagation(),r(t.id)},compact:d})}});var g=Object(a.useMemo)((function(){return i.total<=i.pageSize}),[i]),C=Object(a.useCallback)((function(e){return{onClick:function(t){t.stopPropagation(),d||n(e.id)}}}),[n,d]);return Object(y.jsx)("div",{className:"flex flex-col loads-table ".concat(g?"one-page-table":""),style:d?{maxHeight:"384px",height:"384px",minHeight:"384px"}:{height:"calc(100vh - 10rem)",maxHeight:"calc(100vh - 10rem)",minHeight:"calc(100vh - 10rem)"},ref:f,children:Object(y.jsx)(Xc.Table,{"data-testid":"loads-table",rowKey:"id",columns:x,dataSource:t,pagination:i,onChange:o,scroll:{y:"calc(".concat(O,"px").concat(d?" - 5.5rem":" - 9rem",")")},tableLayout:"auto",onRow:function(e){return C(e)}})})}GZ.defaultProps={tableData:[],onRecordView:function(){},onRecordDelete:function(){},onRecordEdit:function(){},sortBy:"",sortDir:"",compact:!1,isCropSortable:!0,renderTruckColumn:void 0,renderDriverColumn:void 0};var WZ=function(e,t){return Object(y.jsxs)(Xc.Row,{className:"bg-white w-full mt-1 ml-4",justify:"space-between",prefixCls:"syt-antd-row",children:[Object(y.jsx)(Xc.Col,{children:Object(y.jsxs)(Xc.Row,{children:[Object(y.jsx)(Xc.Col,{className:"pt-2px",children:Object(y.jsx)("img",{src:B_,alt:"info-icon"})}),Object(y.jsx)(Xc.Col,{children:Object(y.jsx)("div",{className:"w-292px ml-2 text-xs leading-5 text-neutral-1000",children:"Individual loads may contain information that apply to crop zones outside of your selection."})})]})}),Object(y.jsxs)(Xc.Col,{className:"text-neutral-60",children:[t[0],"-",t[1]," of ",e]})]})},qZ={ascend:"asc",descend:"desc"},JZ=function(e){var t=e.cropZones,n=e.type,r=VZ(),c=r.getLoads,i=r.loading,o=uE(),s=o.people,l=o.loading,d=Ro("equipments",["name","equipmentType"],"name",-1),u=d.items,j=!d.loaded,f=QM({pagination:{showTotal:WZ},defaultSortBy:"date",defaultSortDir:"descend"}),v=f.reactUiKitTableOnChange,O=f.reactUiKitTablePaginationProp,h=f.page,x=f.pageSize,g=f.sortBy,C=f.sortDir,P=f.setTotalItemsCount,A=Object(p.h)(),S=Object(a.useState)([]),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useCallback)((function(e){A.push("".concat(Cc.yieldV2,"/loads/").concat(e,"/view"))}),[A]),_=function(e){if(n.toLowerCase()===Lh)return t[0].reportedArea||t[0].boundaryArea;var a=ae.a.compact(e.map((function(e){return t.find((function(t){return t.id===e.id}))})));return ae.a.sumBy(a,(function(e){return e.reportedArea||e.boundaryArea}))};return Object(a.useEffect)((function(){c({limit:x,page:h-1,sortBy:g,sortDir:qZ[C],seasonIds:JSON.parse(localStorage.getItem("selectedCropSeasons")),cropZoneIds:t.map((function(e){return e.id}))}).then((function(e){var t=e.data,n=e.elements,a=t.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{totalArea:_(e.sources)})}));E(a),P(n)}))}),[t,g,C,h,x,P]),!N&&i||j||l?Object(y.jsx)(m.Spinner,{}):null!==N&&void 0!==N&&N.length||i?Object(y.jsx)(GZ,{tableData:N,onRecordView:w,pagination:O,onChange:v,sortBy:g,sortDir:C,compact:!0,isCropSortable:n.toLowerCase()===Dh,renderDriverColumn:function(e){if(!e||null===s||void 0===s||!s.length)return Object(y.jsx)(y.Fragment,{children:"---"});var t=s.find((function(t){return t.id===e}));return t?Object(y.jsxs)(Xc.Row,{children:[Object(y.jsx)("img",{className:"mr-1",src:vE,alt:"driver-icon"}),t.name]}):Object(y.jsx)(y.Fragment,{children:"---"})},renderTruckColumn:function(e){if(!e||null===u||void 0===u||!u.length)return Object(y.jsx)(y.Fragment,{children:"---"});var t=u.find((function(t){return t.id===e}));return t?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(Xc.Row,{children:[Object(y.jsx)("img",{className:"mr-1",src:MZ,alt:"driver-icon"}),t.name]}),Object(y.jsxs)(Xc.Row,{className:"text-xs text-neutral-60",children:[t.year," ",t.make," ",t.model]})]}):Object(y.jsx)(y.Fragment,{children:"---"})}}):Object(y.jsx)(jw,{title:"No Yield Loads Found",overlayIcon:ZU})},KZ=function(e){var t=e.selectedProperty,n=IZ(),r=n.getYieldCropOverview,c=n.loading,i=Object(a.useState)(),o=Object(b.a)(i,2),s=o[0],l=o[1],d=t.id,u=t.type,j=t.cropzones;Object(a.useEffect)((function(){var e={};u.toLowerCase()===Dh?e.fieldId=d:u.toLowerCase()===Lh&&(e.cropZoneId=d),r(e).then((function(e){return l(e)}))}),[d,u]);var p=Object(y.jsx)(qU,{title:"Yield",description:"All harvested yield for the selected crop season",icon:RZ});return c?Object(y.jsxs)(y.Fragment,{children:[p,Object(y.jsx)(m.Spinner,{})]}):Object(y.jsxs)(y.Fragment,{children:[p,s?Object(y.jsxs)(m.Tabs,{children:[Object(y.jsx)(m.Tabs.Tab,{label:"Overview",children:Object(y.jsx)(FZ,{data:s})}),Object(y.jsx)(m.Tabs.Tab,{label:"Loads",children:Object(y.jsx)(JZ,{cropZones:null!==j&&void 0!==j?j:[t],type:u})})]}):Object(y.jsx)(jw,{title:"No Yield Loads Found",overlayIcon:ZU})]})},QZ=function(e){var t,n,a,r;if(void 0===e.id)return{};var c=Object(I.a)(Object(I.a)({},e),{},{geometry:null!==(t=null===e||void 0===e?void 0:e.geometry)&&void 0!==t?t:{},reportedArea:null!==(n=null===e||void 0===e?void 0:e.reportedArea)&&void 0!==n?n:0,slope:null!==(a=null===e||void 0===e?void 0:e.slope)&&void 0!==a?a:0,slopeLength:null!==(r=null===e||void 0===e?void 0:e.slopeLength)&&void 0!==r?r:0});return delete c.dateEpoch,c},XZ=function(e){var t,n;if(void 0===e.id)return{};var a=Object(I.a)(Object(I.a)({},e),{},{cropSeasonId:JSON.parse(localStorage.getItem("selectedCropSeasons"))[0],geometry:null!==(t=null===e||void 0===e?void 0:e.geometry)&&void 0!==t?t:{},reportedArea:null!==(n=null===e||void 0===e?void 0:e.reportedArea)&&void 0!==n?n:0});return delete a.dateEpoch,a},$Z=Fu.e().shape({}),eY=Fu.e().shape({fsaArea:Fu.d().min(0,"FSA Area must be greater or equal to 0").typeError("A positive number is required"),pumpLift:Fu.d().min(0,"Pump Lift must be greater or equal to 0").typeError("A positive number is required")}),tY=Fu.e().shape({fsaArea:Fu.d().min(0,"FSA Area must be greater or equal to 0").typeError("A positive number is required"),ownerPercentage:Fu.d().min(0,"Land Owner Percentage must be greater or equal to 0").typeError("A positive number is required"),tenantPercentage:Fu.d().min(0,"Tenant Percentage must be greater or equal to 0").typeError("A positive number is required"),slope:Fu.d().typeError("A number is required").min(0,"Slope Percentage must be greater or equal to 0").max(100,"Slope Percentage must be less or equal to 100"),slopeLength:Fu.d().typeError("A number is required").min(0,"Slope Length must be greater or equal to 0"),pumpPressure:Fu.d().min(0,"Pump Pressure must be greater or equal to 0").typeError("A positive number is required"),pumpLift:Fu.d().min(0,"Pump Lift must be greater or equal to 0").typeError("A positive number is required")}),nY=function(e){var t=e.enableEdit,n=e.setEnableEdit,r=e.edited,c=e.setEdited,i=e.setCancelEditModalVisible,o=Object(a.useContext)(ac),s=Object(b.a)(o,2),l=s[0],d=l.selectedProperty,u=l.organization,j=s[1],p=Object(a.useState)({editSessionNumber:null,id:null}),v=Object(b.a)(p,2),O=v[0],h=v[1],x=Object(f.useFlags)(),g=x.releaseFePropertyDetailsYieldCard,C=x.releaseFePropertyDetailsYieldCardEnableByOrg,P="Farm"===d.type?d.id:d.farmId,A="Field"===d.type?d.id:d.fieldId,S="Crop Zone"===d.type?d.id:void 0,T=iB(P),N=Pv(A),E=Ov(S),w={Farm:T,Field:N,"Crop Zone":E}[d.type],_={Farm:$Z,Field:tY,"Crop Zone":eY}[d.type],R=Object(a.useState)(!1),D=Object(b.a)(R,2),k=D[0],L=D[1],F=Object(a.useState)(0),M=Object(b.a)(F,2),V=M[0],B=M[1];Object(a.useEffect)((function(){j({type:"IS_ENABLE_INFO_TAB_EDIT",payload:t})}),[t,j]);var U=function(){var e=Object(Y.a)(G.a.mark((function e(t){var a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("Farm"!==d.type){e.next=12;break}return delete(a=Object(I.a)({},t)).dateEpoch,e.prev=3,e.next=6,w.editFarm(a);case 6:e.next=10;break;case 8:e.prev=8,e.t0=e.catch(3);case 10:h({editSessionNumber:V,id:d.id}),L(!0);case 12:if("Field"!==d.type){e.next=23;break}return r=QZ(t),e.prev=14,e.next=17,w.editField(r);case 17:e.next=21;break;case 19:e.prev=19,e.t1=e.catch(14);case 21:h({editSessionNumber:V,id:d.id}),L(!0);case 23:if("Crop Zone"!==d.type){e.next=34;break}return c=XZ(t),e.prev=25,e.next=28,w.editCropZone(c);case 28:e.next=32;break;case 30:e.prev=30,e.t2=e.catch(25);case 32:h({editSessionNumber:V,id:d.id}),L(!0);case 34:n((function(e){return!e}));case 35:case"end":return e.stop()}}),e,null,[[3,8],[14,19],[25,30]])})));return function(t){return e.apply(this,arguments)}}(),z=function(e){n(e),B(V+1)};Object(a.useEffect)((function(){O.id&&O.id!==d.id&&L(!1)}),[O,d,L]);var Z=function(e,a){return t?Object(y.jsxs)("div",{className:"bottom-0 left-0 flex flex-row w-full p-4 bg-white border border-solid border-neutral-100 justify-between",children:[Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.outline,onClick:function(){r?i((function(e){return!e})):n(!1)},children:"Cancel"}),Object(y.jsx)(Xc.Button,{disabled:!r,type:Xc.ButtonType.primary,onClick:function(){e(a,d.type)},children:w.saving?Object(y.jsx)(m.Spinner,{size:"xs"}):"Save"})]}):null},H=function(){var e=g||(null===C||void 0===C?void 0:C.includes(u.id));switch(null===d||void 0===d?void 0:d.type){case"Farm":return t?Object(y.jsx)(qz,{children:Object(y.jsx)(cz,{setEdited:c,farm:w.farm})}):Object(y.jsx)(qz,{children:Object(y.jsx)(KU,{id:d.id,setEnableEdit:z})});case"Field":return t?Object(y.jsx)(qz,{children:Object(y.jsx)(Bz,{setEdited:c,field:N.field,farm:T.farm})}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(qz,{children:Object(y.jsx)(XU,{id:d.id,setEnableEdit:z})}),Object(y.jsx)(qz,{children:Object(y.jsx)(pZ,{id:d.id})}),e&&Object(y.jsx)(qz,{children:Object(y.jsx)(KZ,{selectedProperty:d})}),Object(y.jsx)(qz,{children:Object(y.jsx)(_Z,{id:d.id,level:"field"})})]});case"Crop Zone":return t?Object(y.jsx)(qz,{children:Object(y.jsx)(Gz,{setEdited:c,field:N.field,farm:T.farm,cropZone:E.cropZone})}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(qz,{children:Object(y.jsx)(tz,{id:d.id,farmId:d.farmId,fieldId:d.fieldId,setEnableEdit:z})}),Object(y.jsx)(qz,{children:Object(y.jsx)(mZ,{id:d.id})}),e&&Object(y.jsx)(qz,{children:Object(y.jsx)(KZ,{selectedProperty:d})})]});default:return null}},W=O.editSessionNumber===V&&O.id===d.id;return Object(y.jsxs)("div",{className:"w-full h-full flex flex-col flex-1 overflow-y-auto","data-testid":"property-table",children:[Object(y.jsx)(Zi.e,{validationSchema:_,onSubmit:U,initialValues:{},children:function(e){var n=e.handleSubmit,a=e.values;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"".concat(t?"bg-neutral-100":"bg-white"," w-full flex-1 flex flex-col gap-y-4 overflow-y-auto p-2 bg-neutral-100"),children:H()}),Z(n,a)]})}},"edit-".concat(V,"-").concat(d.id)),W&&Object(y.jsx)(zU,{state:null===w||void 0===w?void 0:w.state,selectedProperty:d,showEditToast:k,setShowEditToast:L})]})};nY.defaultProps={};var aY=nY,rY=n.p+"static/media/new-area.2af966b6.svg",cY=n.p+"static/media/drive_folder_upload.fd5f05c7.svg",iY=function(e){var t=e.title,n=e.subtitle,a=e.imageSource,r=e.buttonClickEvent,c=e.onKeyDown;return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)("div",{className:"w-full h-full border rounded-xl text-center shadow-lg",onClick:r,onKeyDown:c,role:"button",tabIndex:0,children:Object(y.jsxs)("div",{className:"mt-8 mb-4 ml-6 mr-6",children:[Object(y.jsx)("div",{className:"mb-8",children:Object(y.jsx)("img",{className:"block m-auto",src:a,alt:""})}),Object(y.jsx)("div",{className:"text-xl font-semibold leading-7",children:t}),Object(y.jsx)("div",{className:"text-lg leading-7",children:n})]})})})};iY.defaultProps={imageSource:""};var oY=iY,sY=function(e){var t=e.open,n=e.closeModal,r=e.drawFieldsClick,c=e.uploadFilesClick,i=Object(a.useContext)(ac),o=Object(b.a)(i,1)[0].selectedProperty,s=function(){r(o)},l=function(){c(),n(!1)},d=[[{title:"Draw your fields",subTitle:"Draw your farm's fields with the drawing tools",imageSource:rY,buttonClickEvent:s,onKeyDown:s,classname:"w-92 h-56 mr-4",testId:"create-property-modal-draw-button"},{title:"Upload field files",subTitle:"Add multiple fields at a time by uploading shapefiles",imageSource:cY,buttonClickEvent:l,onKeyDown:l,classname:"w-92 h-56",testId:"create-property-modal-upload-button"}]],u=function(e){var t;return Object(y.jsx)(y.Fragment,{children:null===e||void 0===e||null===(t=e.buttonArray)||void 0===t?void 0:t.map((function(e,t){var n=""!==e.title;return Object(y.jsxs)(y.Fragment,{children:[n&&Object(y.jsx)("button",{className:e.classname,type:"button","data-testid":e.testId,children:Object(y.jsx)(oY,{title:e.title,subtitle:e.subTitle,imageSource:e.imageSource,buttonClickEvent:e.buttonClickEvent,onKeyDown:e.onKeyDown})},t),!n&&Object(y.jsx)("div",{className:"w-1/2"})]})}))})},j=function(e){return e.rows.map((function(e){return Object(y.jsx)("div",{className:"flex mr-4 ml-4 mb-6",children:Object(y.jsx)(u,{buttonArray:e})})}))};return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(m.Modal,{open:t,"data-testid":"create-property-modal",fixedSize:"75px",hideClose:!0,children:Object(y.jsxs)("div",{className:"ml-4 pt-4 mb-4 pb-4 pr-4",children:[Object(y.jsxs)("div",{className:"flex mr-4 ml-4 mt-4",children:[Object(y.jsx)("div",{className:"w-1/2 text-left text-2xl mb-12 font-semibold","data-testid":"create-property-modal-title",children:Object(y.jsx)("div",{className:"leading-7",children:"Create New Fields"})}),Object(y.jsx)("div",{className:"w-1/2 text-right",children:Object(y.jsx)("button",{type:"button",onClick:function(){n(!1)},children:Object(y.jsx)(ui.a,{icon:di.t,size:"2x",stle:{visibility:"visible"}})})})]}),Object(y.jsx)(j,{rows:d})]})})})};sY.defaultProps={open:!0};var lY=sY,dY=n(2829),uY=n(807),bY=n.n(uY),jY=n.p+"static/media/property_org.6142db8e.svg",pY=n.p+"static/media/property_farm_icon.76b609fc.svg",fY=n.p+"static/media/property_field_icon.75444017.svg",mY=n.p+"static/media/property_cropzone_icon_24px.3b4719b2.svg",vY=n(2828);n(1559);function OY(e){var t=e.selectedCrop,n=e.setSelectedCrop,r=Object(a.useContext)(ac),c=Object(b.a)(r,1)[0],i=c.organization,o=c.cropSeasons,s=c.isGlobalCropSeasonLoading,l=c.selectedProperty,d=Object(a.useState)(!1),u=Object(b.a)(d,2),j=u[0],p=u[1],f=function(){var e="Crop Zone"===l.type;if(!l.cropzones)return e;var t=l.cropzones.map((function(e){return e.crop.id})),n=Object(v.a)(new Set(t));return e||1===n.length};Object(a.useEffect)((function(){n(null)}),[null===i||void 0===i?void 0:i.id,null===l||void 0===l?void 0:l.id]);var m=Object(a.useMemo)((function(){if(f())return[];if(s)return[];var e=JSON.parse(localStorage.getItem("selectedCropSeasons"))||[];return function(e,t){return null!==e&&void 0!==e&&e.length?null===e||void 0===e?void 0:e.filter((function(e){return((null===t||void 0===t?void 0:t.cropzones)||[]).some((function(t){return t.crop.id===e.id}))})).sort((function(e,t){return e.name.localeCompare(t.name)})):[]}(function(e,t){if(null===e||void 0===e||!e.length)return[];var n=[];return null===e||void 0===e?void 0:e.filter((function(e){return t.includes(e.id)})).map((function(e){return e.crops})).flat().filter((function(e){return!(null===e||void 0===e||!e.id||n.includes(e.id))&&(n.push(e.id),!0)})).sort((function(e,t){return e.name.localeCompare(t.name)}))}(o,e),l)}),[o,l,null===i||void 0===i?void 0:i.id]),O=function(e){return j?t===e||!t&&!e?Object(y.jsx)("div",{className:"selected-icon w-30px",children:Object(y.jsx)(vY.a,{})}):Object(y.jsx)("span",{className:"selected-icon inline-block w-30px"}):null};if(f()){var h,x=null!==(h=l.crop)&&void 0!==h?h:l.cropzones[0].crop;return Object(y.jsxs)("div",{className:"flex align-items-center",children:[Object(y.jsx)(Ag,{cropObject:x,size:18}),Object(y.jsx)("div",{className:"ml-1",children:x.name})]})}return Object(y.jsx)("div",{className:"crop-select-container whitespace-nowrap inline-block",children:Object(y.jsxs)(Xc.Select,{defaultActiveFirstOption:!0,"data-testid":"filter-by-crops-select",id:"type-filter-select",placeholder:"Filter by crop",value:t,onChange:n,defaultValue:"all",notFoundContent:s?Object(y.jsx)(Xc.Spin,{size:"small","data-testid":"loading-spinner"}):"No data",listHeight:340,suffixIcon:Object(y.jsx)("img",{src:aA,style:{transform:j?"rotate(270deg)":null},height:18,width:18,alt:"Select dropdown icon"}),popupClassName:"property-crop-selection-dropdown",open:j,onDropdownVisibleChange:p,dropdownRender:function(e){return Object(y.jsx)("div",{children:e})},placement:"bottomRight",children:[m.length>0&&Object(y.jsx)(Xc.Select.Option,{children:Object(y.jsxs)("div",{className:"flex align-items-center",children:[O(),Object(y.jsx)("span",{children:"All Crops"})]})}),m.map((function(e){return Object(y.jsx)(Xc.Select.Option,{value:e.id,children:Object(y.jsxs)("div",{className:"flex align-items-center",children:[O(e.id),Object(y.jsx)(Ag,{cropObject:e,size:16}),Object(y.jsx)("div",{className:"ml-2",children:e.name})]})},e.id)}))]})})}OY.defaultProps={selectedCrop:null,setSelectedCrop:function(){}};var hY=function(e){var t,n=e.enableEdit,r=e.setEnableEdit,c=e.setCancelEditModalVisible,i=e.edited,o=e.properties,s=e.selectedCrop,l=e.setSelectedCrop,d=Object(a.useContext)(EB),u=d.viewMode,j=d.isCostAnalysisViewEnabled,p=d.isFarmSelected,f=d.isHugeOrganization,v=Object(a.useContext)(ac),O=Object(b.a)(v,1)[0],h=O.organization,x=O.selectedProperty,g=Object(a.useState)(null),C=Object(b.a)(g,2),P=C[0],A=C[1],S=j&&!p&&u===Nb||"Crop Zone"===x.type&&u===Sb;Object(a.useEffect)((function(){if(x.id)if(x.reportedArea>0)A(x.reportedArea);else if(x.fields){var e=HB(x.fields);A(e)}else A(x.boundaryArea);else{if(f)return;A(HB(ae.a.flatten(o.map((function(e){return e.fields})))))}}),[x,o,f]);return Object(y.jsx)(Xc.AntdConfigProvider,{prefixCls:"syt-antd",children:n?Object(y.jsxs)("div",{className:"flex flex-row w-full p-4 bg-white justify-between",children:[Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"bg-neutral-100 w-10 h-10 flex mr-3 rounded",children:Object(y.jsx)("div",{className:"m-auto",style:{height:"24px",width:"24px"},children:Object(y.jsx)(bY.a,{})})}),Object(y.jsxs)("div",{className:"flex flex-col",children:[Object(y.jsxs)("span",{className:"font-semibold",children:["Edit ",x.type," Information: ",x.name," "]}),Object(y.jsx)("span",{children:"Specific property boundary relevant content not contained within any crop season"})]})]}),Object(y.jsx)(m.Button,{style:{alignSelf:"end"},type:"text",icon:Object(y.jsx)(dY.a,{}),onClick:function(){i?c((function(e){return!e})):r(!1)}})]}):Object(y.jsxs)(Xc.Row,{className:"p-4 border-b flex-no-wrap","data-testid":"property-top-header",children:[Object(y.jsx)(Xc.Col,{className:"content-center",children:Object(y.jsx)("img",{src:function(){switch(x.type){case"Farm":return pY;case"Field":return fY;case"Crop Zone":return mY;default:return jY}}(),alt:"property-icon"})}),Object(y.jsx)(Xc.Col,{className:"ml-2 h-8 content-center text-xl font-semibold truncate","data-testid":"selected-property-name",children:null!==(t=x.name)&&void 0!==t?t:h.name}),Object(y.jsx)(Xc.Col,{className:"ml-4 content-center text-sm text-gray-900 whitespace-nowrap flex-shrink-0",children:null!==x&&void 0!==x&&x.id||!f?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(yf,{roundedTo:2,children:P})," ac"]}):null}),Object(y.jsx)(Xc.Col,{flex:"auto"}),Object(y.jsx)(Xc.Col,{className:"content-center ml-4 flex-shrink-0",children:S&&Object(y.jsx)(OY,{selectedCrop:s,setSelectedCrop:l})})]})})};hY.defaultProps={properties:[],selectedCrop:null,setSelectedCrop:function(){}};var xY=hY,gY=n(808),CY=n.n(gY),yY=function(e){var t=e.files,n=e.errors,a=e.onDeleteFile;return Object(y.jsxs)("div",{className:"flex flex-col p-3 mb-3 border rounded-lg border-dashed border-neutral-300",children:[Object(y.jsx)("h1",{className:"text-black mb-1",children:"Uploaded files:"}),Object(y.jsxs)("div",{className:"text-green-600",children:[t.map((function(e){var t=e.name;return Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsx)("span",{className:n.find((function(e){return e.file===t}))?"text-red-600":"",children:t}),Object(y.jsx)("button",{type:"button","aria-label":t,onClick:function(){a(t)},children:Object(y.jsx)(CY.a,{fontSize:"small",className:"text-red-600",style:{height:12}})})]},t)})),n.length>0&&Object(y.jsxs)("div",{className:"text-red-500 text-xs italic",children:[Object(y.jsx)("hr",{className:"my-2"}),n.map((function(e){var t=e.file,n=e.message;return Object(y.jsx)("div",{children:"- ".concat(n)},t)}))]})]})]})},PY=function(){return Object(y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"22",viewBox:"0 0 16 22",fill:"none","data-testid":"reload-icon",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 0V3C12.42 3 16 6.58 16 11C16 12.57 15.54 14.03 14.76 15.26L13.3 13.8C13.75 12.97 14 12.01 14 11C14 7.69 11.31 5 8 5V8L4 4L8 0ZM2 10.9983C2 14.3083 4.69 16.9983 8 16.9983V13.9983L12 17.9983L8 21.9983V18.9983C3.58 18.9983 0 15.4183 0 10.9983C0 9.42828 0.46 7.96828 1.24 6.73828L2.7 8.19828C2.25 9.02828 2 9.98828 2 10.9983Z",fill:"#696F88"})})},AY="#C2C7D0",SY=function(){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("path",{d:"M6.47059 0C2.89698 0 0 2.89698 0 6.47059V18.92L7.93419 0H6.47059Z",fill:AY}),Object(y.jsx)("path",{d:"M9.12645 0L0 25.4206V37.5294C0 40.6324 2.1842 43.2252 5.099 43.8543L14.7045 0H9.12645Z",fill:AY}),Object(y.jsx)("path",{d:"M15.8963 0L8.58659 44H20.3672L21.4034 0H15.8963Z",fill:AY}),Object(y.jsx)("path",{d:"M22.5957 0L23.646 44H35.4551L28.0176 0H22.5957Z",fill:AY}),Object(y.jsx)("path",{d:"M29.196 0L38.6971 43.8949C41.6984 43.3479 43.9773 40.7304 43.9998 37.5765V25.8606L34.6747 0H29.196Z",fill:AY}),Object(y.jsx)("path",{d:"M35.8672 0L44 19.4733V6.47059C44 2.89698 41.103 0 37.5294 0H35.8672Z",fill:AY})]})},TY=function(e){var t=e.id,n=e.features,r=e.color,c=Object(a.useRef)();return Object(a.useEffect)((function(){c.current&&0!==n.length&&Gp(n,c.current,{color:r,extent:[[4,4],[40,40]]})}),[n,r]),Object(y.jsxs)("svg",{"data-testid":"field-shapes-icon",id:t,ref:function(e){return c.current=e},width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("g",{className:n.length?"":"hidden"}),0===n.length&&Object(y.jsx)(SY,{})]})};TY.defaultProps={features:[],color:AY};var NY=TY,EY=function(e){var t=e.fields,n=e.onSelectedField,r=e.onDeleteField,c=e.onEditField,i=e.onReloadField,o=Object(a.useState)(new Map),s=Object(b.a)(o,2),l=s[0],d=s[1],u=function(){var e=0;l.forEach((function(t){var n=t.selected;e+=n}));var n=t.reduce((function(e,t){return e+(t.imported?1:0)}),0);return e===t.length-n};Object(a.useEffect)((function(){var e=new Map;t.forEach((function(t){t.imported||e.set("".concat(t.farm,"-").concat(t.name),{field:t,selected:!1})})),d(e),n([])}),[t,n]),Object(a.useEffect)((function(){var e=[];l.forEach((function(t){var n=t.selected,a=t.field;n&&e.push(a)})),n(e)}),[l,n]);return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"flex justify-end",children:Object(y.jsx)(m.Button,{onClick:function(){return function(){var e=new Map;t.forEach((function(t){t.imported||e.set("".concat(t.farm,"-").concat(t.name),{field:t,selected:!u()})})),d(e)}()},ariaLabel:"select all",type:"primary",children:u()?"Deselect All":"Select all"})}),t.filter((function(e){return e.error})).length>0&&Object(y.jsxs)("div",{className:"bg-red-100 mt-4 p-3 flex",children:[Object(y.jsx)(ZC,{}),Object(y.jsxs)("div",{className:"ml-2",children:[t.filter((function(e){return e.error})).length," Field",t.filter((function(e){return e.error})).length>1?"s":""," failed to upload. Contact Syngenta Digital Customer Support for assistance."]})]}),Object(y.jsx)("div",{className:"overflow-auto my-8",style:{maxHeight:"25rem"},children:Object(y.jsx)(m.Table,{children:t.map((function(e,t){var n=e.name,a=e.farm,o=e.imported,s=e.error,u="".concat(a,"-").concat(n),b=!!l.get(u)&&l.get(u).selected,j="text-neutral-1000";return o&&(j="text-green-600"),s&&(j="text-red-600"),Object(y.jsx)(m.Table.Row,{children:Object(y.jsxs)("div",{className:"flex justify-between items-center p-2 text-gray-600 hover:bg-gray-100 focus:outline-none",children:[Object(y.jsxs)("div",{className:"flex flex-1 items-center ml-2",children:[o?Object(y.jsx)(m.Checkbox,{checked:!1,readOnly:!0,disabled:!0}):Object(y.jsx)(m.Checkbox,{checked:b,ariaLabel:u,onChange:function(){!function(e,t){var n=new Map(l);n.set(e,{field:t,selected:!l.get(e).selected}),d(n)}(u,e)}}),Object(y.jsxs)("div",{className:"ml-2 flex",children:[Object(y.jsx)(NY,{id:"svg-field-icon-".concat(t),features:[lP(e)],color:"#696F88"}),Object(y.jsxs)("div",{className:"flex flex-col justify-center ml-2",children:[Object(y.jsxs)("div",{className:"text-neutral-1000",children:[n,o?Object(y.jsx)("span",{className:j,children:" (IMPORTED) "}):""]}),!s&&a&&Object(y.jsx)("div",{style:{color:"#707374"},children:a}),s&&Object(y.jsx)("div",{className:"mb-2 text-xs text-red-600",children:s})]})]})]}),Object(y.jsxs)("div",{className:"flex justify-center",children:[!s&&Object(y.jsx)(hu,{units:"ac.",children:oP([e])}),s&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(m.Button,{type:"text",ariaLabel:"edit-button",icon:Object(y.jsx)(mg,{}),onClick:function(){c(e)}}),Object(y.jsx)(m.Button,{type:"text",ariaLabel:"reload-button",icon:Object(y.jsx)(PY,{}),onClick:function(){i(e,t)}}),Object(y.jsx)(m.Button,{type:"text",ariaLabel:"delete-button",icon:Object(y.jsx)(Uh,{color:"#696F88",width:"24",height:"24",widthBox:"5",heightBox:"6"}),onClick:function(){return r(t)}})]})]})]})},u)}))})})]})};EY.defaultProps={onEditField:function(){},onReloadField:function(){}};var wY=EY,_Y=function(e){var t=e.onSelect;return Object(y.jsx)("div",{className:"h-64 mb-24",children:Object(y.jsx)(Bp,{title:"Click or drag file to this area to upload",subtitle:"Upload a .zip that contains .shp, .shx, and .dbf",multiple:!0,fileTypes:[".zip"],onSelect:function(e,n){n.preventDefault(),t(e)}})})},RY=function(e){var t=e.open,n=e.close,r=e.reload,c=e.importedFields,i=void 0===c?[]:c,o=Object(a.useRef)(!1),s=Object(p.h)(),l=Object(a.useContext)(ac),d=Object(b.a)(l,2),u=d[0].uploadedFiles,j=d[1],f=Object(a.useState)(u||[]),O=Object(b.a)(f,2),h=O[0],x=O[1],g=Object(a.useState)(i||[]),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)([]),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)([]),_=Object(b.a)(w,2),R=_[0],D=_[1],k=Object(a.useState)(!1),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Pv().createField,B=Object(a.useRef)([]),U=iB(),z=U.farms,Z=U.createFarm,H=U.loading;Object(a.useEffect)((function(){if(0===h.length)return A([]),D([]),void E([]);M(!0),iP(h).then((function(e){var t=e.fields,n=e.errors;A(i.length>0?i:t),D(n),M(!1)}))}),[h]);var W=Object(a.useCallback)((function(e){x(e),j({type:Dr,payload:e})}),[x]),q=Object(a.useCallback)((function(e){var t=h.findIndex((function(t){var n=t.name;return e===n})),n=Object(v.a)(h);n.splice(t,1),x(n),A([]),D([]),E([]),j({type:Dr,payload:n}),j({type:Ir,payload:[]}),j({type:Rr,payload:!1})}),[h]),J=Object(a.useCallback)((function(e){E(e)}),[E]),K=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Z({name:t,timeZone:"US/Central",referencePoint:{type:"Point",coordinates:[0,0]}}));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Q=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=z.find((function(e){return e.name===t})))||(n=B.current.find((function(e){return e.name===t}))),n){e.next=7;break}return e.next=5,K(t);case 5:n=e.sent,B.current.push(n);case 7:return e.abrupt("return",n);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),X=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=lP(t),e.next=3,V({name:t.name,propertyId:n.id,coordinates:Oj([a]).toString(),geometry:sP(a),reportedArea:0,reportedAreaUnit:"acre"});case 3:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),$=function(e){for(var t=Object(v.a)(P),n=function(n){var a=e[n],r=a.field,c=a.error,i=a.imported,o=P.findIndex((function(e){return e.name===r.name&&e.farm===r.farm}));t[o]=Object(I.a)(Object(I.a)({},P[o]),{},{error:c,imported:i})},a=0;a<e.length;a+=1)n(a);j({type:Ir,payload:t.filter((function(e){return!0!==e.imported}))}),A(t.filter((function(e){return!0!==e.imported})))},ee=function(){x([]),A([]),D([]),E([]),M(!1),j({type:Dr,payload:[]}),j({type:Ir,payload:[]}),j({type:Rr,payload:!1}),n(),o.current&&(o.current=!1,r())},te=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n,a,r,c,i,s,l,d,u;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=!1,n=[],M(!0),a=0;case 4:if(!(a<N.length)){e.next=38;break}return r=N[a],e.prev=6,c=void 0,e.prev=8,e.next=11,Q(r.farm);case 11:c=e.sent,e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(8),l=(null===e.t0||void 0===e.t0||null===(i=e.t0.response)||void 0===i||null===(s=i.data)||void 0===s?void 0:s.displayErrorMessage)||(null===e.t0||void 0===e.t0?void 0:e.t0.message),new Error("[Create Farm] Error: ".concat(l));case 18:return e.prev=18,e.next=21,X(r,c);case 21:e.next=27;break;case 23:throw e.prev=23,e.t1=e.catch(18),(null===e.t1||void 0===e.t1||null===(d=e.t1.response)||void 0===d||null===(u=d.data)||void 0===u?void 0:u.displayErrorMessage)||(null===e.t1||void 0===e.t1?void 0:e.t1.message),new Error("Upload Error");case 27:n.push({field:r,imported:!0}),e.next=34;break;case 30:e.prev=30,e.t2=e.catch(6),n.push({field:r,error:e.t2.message}),t=!0;case 34:o.current=!0;case 35:a+=1,e.next=4;break;case 38:if(!o.current||t){e.next=41;break}return ee(),e.abrupt("return");case 41:$(n),M(!1);case 43:case"end":return e.stop()}}),e,null,[[6,30],[8,14],[18,23]])})));return function(){return e.apply(this,arguments)}}(),ne=Object(a.useCallback)((function(e){var t=P.filter((function(t,n){return n!==e}));A(t)}),[P]),ae=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,r,c,i,s,l,d,u;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=!1,r=P.filter((function(e,t){return t!==n})),M(!0),e.prev=3,e.prev=4,e.next=7,Q(t.farm);case 7:c=e.sent,e.next=14;break;case 10:throw e.prev=10,e.t0=e.catch(4),l=(null===e.t0||void 0===e.t0||null===(i=e.t0.response)||void 0===i||null===(s=i.data)||void 0===s?void 0:s.displayErrorMessage)||(null===e.t0||void 0===e.t0?void 0:e.t0.message),new Error("[Create Farm] Error: ".concat(l));case 14:return e.prev=14,e.next=17,X(t,c);case 17:e.next=23;break;case 19:throw e.prev=19,e.t1=e.catch(14),(null===e.t1||void 0===e.t1||null===(d=e.t1.response)||void 0===d||null===(u=d.data)||void 0===u?void 0:u.displayErrorMessage)||(null===e.t1||void 0===e.t1?void 0:e.t1.message),new Error("Upload Error");case 23:r.splice(n,0,{field:t,imported:!0}),e.next=30;break;case 26:e.prev=26,e.t2=e.catch(3),r.splice(n,0,{field:t,error:e.t2.message}),a=!0;case 30:if(o.current=!0,!o.current||a){e.next=34;break}return ee(),e.abrupt("return");case 34:$(r),M(!1);case 36:case"end":return e.stop()}}),e,null,[[3,26],[4,10],[14,19]])})));return function(t,n){return e.apply(this,arguments)}}();return Object(y.jsx)(ao,{title:"Import Properties",open:t,type:"buttonless",close:ee,children:Object(y.jsxs)("div",{className:"mr-12",children:[F||H?Object(y.jsx)(m.Spinner,{ariaLabel:"spinner"}):Object(y.jsxs)(y.Fragment,{children:[0===h.length&&Object(y.jsx)(_Y,{onSelect:W}),h.length>0&&Object(y.jsx)(yY,{files:h,errors:R,onDeleteField:ne,onDeleteFile:q}),P.length>0&&Object(y.jsx)(wY,{fields:P,onDeleteField:ne,onSelectedField:J,onEditField:function(e){s.push({pathname:"".concat(Cc.properties,"/edit/").concat(null===e||void 0===e?void 0:e.fieldId),state:{label:"FROM_IMPORT_FIELD",selectedField:e}})},onReloadField:ae})]}),Object(y.jsx)("div",{className:"flex justify-end",children:Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsx)("div",{className:"px-1",children:Object(y.jsx)(m.Button,{disabled:F||H,type:"outline",onClick:function(){return ee()},ariaLabel:"cancel",children:"Cancel"})}),Object(y.jsx)("div",{className:"px-1",children:Object(y.jsx)(m.Button,{ariaLabel:"import",type:"primary",disabled:!(null!==N&&void 0!==N&&N.length)||F||H,onClick:te,children:"Import"})})]})})]})})};RY.defaultProps={importedFields:[]};var IY=RY,DY=Object(p.l)((function(e){var t=e.open,n=e.close,r=e.farmName,c=e.farmId,i=e.setReRenderProperties,o=Object(a.useState)(null),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(!0),j=Object(b.a)(u,2),p=j[0],f=j[1],v=Object(a.useState)(!1),O=Object(b.a)(v,2),h=O[0],x=O[1],g=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return x(!0),t=pn.delete(c),n=t.promise,e.next=4,n.then((function(){i(!0)})).catch(Ae.default).catch((function(e){var t;x(!1),t=e.response.data.message,d(t),f(!0)}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(ao,{"data-testid":"delete-farm-modal",open:t,title:r&&"Delete this Farm?",close:n,cancelLabel:"Cancel",confirmLabel:"Delete",onCancel:function(){return n()},type:"error",onConfirm:function(){return g()},isSaving:h,children:[p?Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){f(!1)},children:l}):null,Object(y.jsxs)("div",{className:"pr-6",children:["Are you sure you want to delete the Farm ",r,"?"]}),Object(y.jsx)("div",{className:"pr-6",children:"Alert: To delete a farm you must ensure all attached fields and cropzones are deleted first."})]})})})),kY=function(e){var t=e.open,n=e.handleCancel,a=e.handleClose,r=e.handleConfirm,c=e.cancelLabel,i=e.confirmationLabel,o=e.children;return Object(y.jsx)(m.SimpleModal,{open:t,title:"Confirm Changes",close:a,onCancel:n,onConfirm:r,confirmLabel:i,cancelLabel:c,children:Object(y.jsx)("div",{className:"pr-6",children:o})})};kY.defaultProps={open:!1,cancelLabel:"No",confirmationLabel:"Yes"};var LY=kY,FY=function(e){var t=e.title,n=e.onPress,r=e.options,c=e.saveButtonDisabled,i=e.chkSubmitStatus,o=Object(a.useState)(!1),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useRef)(null);Object(a.useEffect)((function(){var e=function(e){u.current&&!u.current.contains(e.target)&&d(!1)};return l&&document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[l]);var j=Object(y.jsx)("button",{"data-testid":"dropdown-button",type:"button",className:"h-full border-l border-neutral-30 px-3 py-2 flex items-center "+"justify-center focus:outline-none  ".concat(c||i?"button-background":""),onClick:function(e){e.preventDefault(),e.stopPropagation(),l||d(!0)},children:Object(y.jsx)(m.Icon,{size:14,icon:"chevron-down",color:"#696F88"})});return Object(y.jsxs)("button",{type:"button",className:"bg-white rounded-md border outline-none border-neutral-30 items-center flex flex-row",disabled:c||i,onClick:function(e){e.preventDefault(),e.stopPropagation(),n(),d(!1)},children:[Object(y.jsx)("div",{className:"relative py-1 rounded-l-md w-full h-full flex items-center justify-center bg-white hover:bg-neutral-20   ".concat(c||i?"button-background":""),children:Object(y.jsx)("span",{className:"px-3 text-sm",children:t})}),Object(y.jsx)("div",{className:"relative rounded-r-md w-full h-full flex items-center justify-center ".concat(l?"bg-neutral-20":"bg-white hover:bg-neutral-20"),children:Object(y.jsx)(m.Popup,{trigger:j,position:"top",align:"right",open:l,onClose:function(){return d(!1)},children:Object(y.jsx)("div",{ref:u,className:"absolute right-0 bottom-0 py-2 border rounded-md bg-white shadow flex justify-center items-center",children:r.map((function(e){return Object(y.jsx)("button",{type:"button",className:"px-1 w-28 items-center justify-center rounded-md cursor-pointer",onClick:function(t){t.stopPropagation(),e.onClick(),d(!1)},children:Object(y.jsx)("p",{className:"text-base hover:opacity-80 w-full line-clamp-1 ".concat(e.danger&&"text-remove"),children:e.label})},Object(cc.generate)())}))})})})]})};FY.defaultProps={title:"",onPress:function(){},options:[],saveButtonDisabled:!1,chkSubmitStatus:!1};var MY=FY,VY=function(e){var t=e.open,n=e.farm,r=e.onConfirm,c=e.onCancel,i=ni(),o=iB(n.id),s=o.archive,l=o.archiveFarm;Object(a.useEffect)((function(){s.isLoading||(s.isSuccess&&(i.success("".concat(n.name," archived."),{content:"You have archived your farm along with all associated fields and crop zones."}),r()),s.isError&&(i.error("".concat(n.name," not archived."),{content:"An error prevented your farm from being archived.  Please try again.",supportButton:!0}),c()))}),[s]);return Object(y.jsx)(ao,{open:t,title:"Archive ".concat(null===n||void 0===n?void 0:n.name,"?"),close:c,cancelLabel:"Cancel",confirmLabel:"Archive farm",type:"warningConfirmation",onConfirm:function(){l(n.id)},isSaving:s.isLoading,children:Object(y.jsx)("div",{className:"pr-6",children:"This farm will be archived along with all associated fields and crop zones. You can unarchive this farm later. Do you want to continue?"})})},BY=Fu.e().shape({farmName:Fu.f().required("Farm Name is required")}),UY=function(e){var t=e.farmId,n=e.farmName,r=e.reloadFarmData,c=e.setView,i=Object(a.useContext)(ac),o=Object(b.a)(i,2),s=o[0],l=s.selectedProperty,d=s.isFarmEdited,u=s.organization,j=o[1],p=iB(t,!1).editFarm,v=Object(a.useState)({}),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(!1),T=Object(b.a)(S,2),N=T[0],E=T[1],w=function(){return A(!0)},_=Object(a.useState)(!1),R=Object(b.a)(_,2),D=R[0],k=R[1],L=Object(f.useFlags)(),F=L.releaseFeArchiveFarmEnable,M=L.releaseFeArchiveFarmEnableByOrg,V=yc(F,M,u.id),B={farmName:n};Object(a.useEffect)((function(){D&&(j({type:Ym}),j({type:"SELECT_PROPERTY",payload:{}}),r(),k(!1))}),[D,r,j]);var U=function(){j({type:"SELECT_PROPERTY",payload:Object(I.a)(Object(I.a)({},l),{},{isEditing:!1})}),r()},z=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,p({name:t.farmName});case 2:j({type:"SELECT_PROPERTY",payload:{}}),r();case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Z=function(){j({type:"IS_FARM_EDITED",payload:!1})};return Object(y.jsxs)("div",{className:"h-full relative w-full","data-testid":"property-edit-farm",children:[Object(y.jsx)(PB,{showTools:!1,title:"Edit Farm",showGoBack:!0,setView:c}),Object(y.jsx)("div",{className:"p-4 h-full",children:Object(y.jsx)(Zi.e,{initialValues:B,validationSchema:BY,onSubmit:z,children:function(e){var t=e.errors,n=e.handleSubmit,a=e.isSubmitting;return x(t),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(LY,{open:d,handleCancel:function(){return Z()},handleConfirm:function(){return j({type:"SELECT_PROPERTY",payload:Object(I.a)(Object(I.a)({},l),{},{isEditing:!1})}),j({type:"IS_FARM_EDITED",payload:!1}),void r()},handleClose:function(){return Z()},children:"Are you sure you want to leave this page?"}),Object(y.jsx)("div",{className:"py-6",children:Object(y.jsx)(Qi,{control:m.Input,name:"farmName",label:"Farm Name*",required:!0})}),Object(y.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 border-t px-4 py-3 flex justify-between items-center",children:[V?Object(y.jsx)(MY,{title:"Archive",onPress:function(){return E(!0)},options:[{label:"Delete Farm",danger:!0,onClick:w}]}):Object(y.jsx)(m.Button,{danger:!0,type:"text",icon:Object(y.jsx)(Uh,{}),onClick:w,children:"Delete Farm"}),Object(y.jsxs)("div",{className:"w-1/2 flex justify-end",children:[Object(y.jsx)(m.Button,{type:"text",style:{marginRight:"0.5rem"},onClick:U,children:"Cancel"}),Object(y.jsx)(m.Button,{type:"primary",disabled:!!h.farmName||a,onClick:n,children:"Save"})]})]})]})}})}),Object(y.jsx)(DY,{open:P,close:function(){return A(!1)},farmName:n,farmId:t,setReRenderProperties:k}),Object(y.jsx)(VY,{farm:{id:t,name:n},open:N,onCancel:function(){return E(!1)},onConfirm:function(){E(!1),k(!0)}})]})};UY.defaultProps={farmId:"",farmName:""};var zY=UY,ZY=function(e,t){return null!==e&&void 0!==e&&e.features?e.features.map((function(e){var n,a,r;return Object(ne.set)(e,"properties.$layer",t!==(null===(n=e.properties)||void 0===n?void 0:n.id)&&(t!==(null===(a=e.properties)||void 0===a?void 0:a.propertyId)||null!==(r=e.properties)&&void 0!==r&&r.$parentDuplicated)?"default":"focused"),e})):[]},YY=function(e){var t,n,r,c,i=e.properties,o=e.title,s=e.onSetShowSummaryPanel,l=e.disabledOrgChange,d=e.disabledPropertyChange,u=Object(a.useContext)(ac),f=Object(b.a)(u,1)[0],m=f.shouldResetPropertyName,v=f.selectedProperty,O=Object(a.useContext)(EB),h=O.isCropZoneSelected,x=O.isLoadingProperties,g=O.setParams,C=O.selectedField,P=O.fetchProperties,A=O.setGeoJSONCollectionFeatures,S=O.onPropertySelection,T=null===v||void 0===v?void 0:v.id,N=h?null===v||void 0===v?void 0:v.id:null,E=Pv(C),w=Object(a.useState)(null===E||void 0===E||null===(t=E.field)||void 0===t?void 0:t.propertyId),_=Object(b.a)(w,2),R=_[0],D=_[1],k=Object(a.useState)(C),L=Object(b.a)(k,2),F=L[0],M=L[1];Object(a.useEffect)((function(){(null===F||void 0===F?void 0:F.id)!==C&&M(C)}),[F,C]);var V=Object(a.useState)(null),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=Object(p.h)(),Y=Object(p.h)().location,H=Object(a.useCallback)((function(){return i?i.sort((function(e,t){return e.name<t.name?-1:1})):[]}),[i]);Object(a.useEffect)((function(){m&&P()}),[m,P]);var G=Object(a.useCallback)((function(e){var t;return null!==(t=null===e||void 0===e?void 0:e.fields)&&void 0!==t?t:(i||[]).flatMap((function(e){var t=e.fields,n=e.id;return t.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{propertyId:n})}))}))}),[i]),W=Object(a.useCallback)((function(e){var t;return null!==(t=null===e||void 0===e?void 0:e.cropzones)&&void 0!==t?t:(i||[]).flatMap((function(e){var t=e.fields,n=e.id;return(t||[]).flatMap((function(e){var t=e.cropzones,a=e.id;return t.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{fieldId:a,propertyId:n})}))}))}))}),[i]);Object(a.useEffect)((function(){if(T){var e=N?W().find((function(e){return e.id===N})):null,t=C||e?G().find((function(t){return t.id===C||t.id===(null===e||void 0===e?void 0:e.fieldId)})):null,n=T||t?H().find((function(n){return n.id===T||n.id===(null===t||void 0===t?void 0:t.propertyId)||n.id===(null===e||void 0===e?void 0:e.propertyId)})):null;D(n),M(t),z(e)}}),[H,G,W,o,T,C,N]);var q={name:function(e){return e.name},isActive:function(e){return[T,null===R||void 0===R?void 0:R.id].includes(e.id)}},J={name:function(e){return e.name},isActive:function(e){return[P,null===F||void 0===F?void 0:F.id].includes(e.id)}},K={name:function(e){return e.name},isActive:function(e){return[N,null===U||void 0===U?void 0:U.id].includes(e.id)}},Q=function(e){D(null),M(null),z(null),S(),g({page:0,orgId:null===e||void 0===e?void 0:e.id})};return Object(a.useEffect)((function(){if((null===i||void 0===i?void 0:i.length)>0&&(null===C||void 0===C?void 0:C.length)>0){var e={},t={};null===i||void 0===i||i.forEach((function(n){var a;null===n||void 0===n||null===(a=n.fields)||void 0===a||a.forEach((function(a){a.id===C&&(e=n,t=a)}))})),D(e),M(t)}}),[i,C]),Object(y.jsxs)(lo,{onOrganizationSelect:Q,disabled:l,disabledCropSeasons:x,hideCropSeasonDropdown:!1,onCropSeasonSelect:Q,children:[d&&Object(y.jsx)(lo.Item,{title:"Properties",value:o,isLast:!0}),!d&&(R||o)&&Object(y.jsx)(lo.Item,{dropDownItemProps:q,getData:H,isLast:!R&&!C,onSelect:function(e,t){if(S&&e)S(e);else if(e){if(e){var n,a;A(ZY(null===Y||void 0===Y||null===(n=Y.state)||void 0===n?void 0:n.geoJsonData,e.id)),Z.push({pathname:"/app/property/farms/".concat(e.id),state:{properties:e,geoJsonData:null===Y||void 0===Y||null===(a=Y.state)||void 0===a?void 0:a.geoJsonData},label:"farm"})}}else P({seasonIds:JSON.parse(localStorage.getItem("selectedCropSeasons"))}),t.preventDefault();D(e),M(null),z(null)},searchPlaceholder:"Search Properties",title:"Properties",value:null!==(n=null===R||void 0===R?void 0:R.name)&&void 0!==n?n:o,dropDownFooter:function(e){return Object(y.jsx)(j.c,Object(I.a)(Object(I.a)({exact:!0,to:"/app/property"},e),{},{onClick:function(){(!N&&null===C||null===N&&!C)&&s(!1)(),P()},children:Object(y.jsx)("div",{className:"text-cucumber-green-700 hover:text-cucumber-green-500",children:Object(y.jsx)("div",{children:"All Properties"})})}))}}),((T||R)&&!F||F)&&Object(y.jsx)(lo.Item,{dropDownItemProps:J,getData:function(){return G(R)},isLast:!0,onSelect:function(e,t){if(S&&e)S(e);else if(S&&!e)S(R),t.preventDefault();else if(e){var n,a;A(ZY(null===Y||void 0===Y||null===(n=Y.state)||void 0===n?void 0:n.geoJsonData,e.id));var r=[];setTimeout((function(){null===i||void 0===i||i.forEach((function(t){var n;null===t||void 0===t||null===(n=t.fields)||void 0===n||n.forEach((function(n){(null===n||void 0===n?void 0:n.id)===e.id&&r.push(t)}))}))}),2e3),Z.push({pathname:"/app/property/fields/".concat(e.id),state:{properties:r,geoJsonData:null===Y||void 0===Y||null===(a=Y.state)||void 0===a?void 0:a.geoJsonData},label:"field"})}M(e),z(null)},searchPlaceholder:"Search Fields",title:"Field",value:null!==(r=null===F||void 0===F?void 0:F.name)&&void 0!==r?r:"All Fields",dropDownFooter:function(e){return Object(y.jsx)(j.c,Object(I.a)(Object(I.a)({to:"/app/property/farms/".concat(null===R||void 0===R?void 0:R.id)},e),{},{children:Object(y.jsx)("div",{className:"text-cucumber-green-700 hover:text-cucumber-green-500",children:Object(y.jsx)("div",{children:"All Fields"})})}))}}),((C||F)&&!U||U)&&Object(y.jsx)(lo.Item,{dropDownItemProps:K,getData:function(){return W(F)},isLast:!0,onSelect:function(e,t){if(S&&e)S(e);else if(S&&!e)S(F),t.preventDefault();else if(e){var n,a;A(ZY(null===Y||void 0===Y||null===(n=Y.state)||void 0===n?void 0:n.geoJsonData,e.id));var r=[];setTimeout((function(){null===i||void 0===i||i.forEach((function(t){var n;null===t||void 0===t||null===(n=t.fields)||void 0===n||n.forEach((function(n){var a;return null===n||void 0===n||null===(a=n.cropzones)||void 0===a?void 0:a.forEach((function(n){(null===n||void 0===n?void 0:n.id)===e.id&&r.push(t)}))}))}))}),2e3),Z.push({pathname:"/app/property/fields/".concat(F.id,"/cropzones/").concat(e.id),state:{properties:r,geoJsonData:null===Y||void 0===Y||null===(a=Y.state)||void 0===a?void 0:a.geoJsonData},label:"cropzone"})}z(e)},searchPlaceholder:"Search Crop Zones",title:"Crop Zone",value:null!==(c=null===U||void 0===U?void 0:U.name)&&void 0!==c?c:"All Crop Zones",dropDownFooter:function(e){return Object(y.jsx)(j.c,Object(I.a)(Object(I.a)({to:"/app/property/fields/".concat(null===F||void 0===F?void 0:F.id)},e),{},{children:Object(y.jsx)("div",{className:"text-cucumber-green-700 hover:text-cucumber-green-500",children:Object(y.jsx)("div",{children:"All Crop Zones"})})}))}})]})};YY.defaultProps={properties:[],title:null,onSetShowSummaryPanel:function(){},disabledOrgChange:!1,disabledPropertyChange:!1};var HY=YY,GY=(n(1560),function(e){var t=e.open,n=e.onClose,a=e.cropzonesToDelete;return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.SimpleModal,{open:t,onCancel:n,onClose:n,onConfirm:n,close:n,type:"basic",title:"Delete CropZones",children:[Object(y.jsx)("h1",{className:"mt-3 font-body",children:"The following selected crop zones cannot be deleted due to associated records:"}),Object(y.jsx)("div",{className:"table-layout mt-4",children:Object(y.jsx)(m.Table,{children:a.map((function(e){return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("p",{className:"font-body",children:e.farmName})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("p",{className:"font-body",children:e.fieldName})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"w-full font-body",children:[Object(y.jsx)("p",{className:"text-left",children:e.name}),Object(y.jsxs)("p",{className:"text-neutral-600 text-sm text-left mt-2",children:[Object(y.jsx)(yf,{roundedTo:2,children:e.boundaryArea})," \u2022 ".concat(e.crop.name)]})]})})]})}))})})]})})}),WY=n(809),qY=n.n(WY),JY=function(e){var t=e.open,n=e.onClose,a=e.onConfirm,r=e.relatedSeasons,c=function(){return r.reduce((function(e,t,n){return 0===n?t.name:"".concat(e,", ").concat(t.name)}),"")},i="Deleted"===e.action?"Delete":"Update",o="Delete"===i?"Some of which will be deleted. Are you sure you want to continue?":"Are you sure you want to continue?";return Object(y.jsx)(m.SimpleModal,{open:t,title:"".concat(i," Crop Zone(s)?"),close:n,cancelLabel:"Cancel",confirmLabel:"".concat(i," Crop Zone(s)?"),onCancel:n,type:"basic",onConfirm:a,icon:Object(y.jsx)(qY.a,{}),children:Object(y.jsx)("div",{className:"pr-6",children:Object(y.jsxs)("p",{children:["You are about to ",i.toLowerCase()," crop zone(s)"," ",c()&&"for"," ",Object(y.jsx)("span",{className:"font-bold",children:c()}),"."," ",o]})})})},KY=function(e){var t,n=e.reloadData,r=Object(a.useContext)(ac),c=Object(b.a)(r,2),i=c[0],o=i.massiveChangeSummary,s=i.fieldsToMassiveAssign,l=i.massAssignerRejections,d=c[1],u=xU(o,s,n,d),j=u.handleCancel,p=u.isSaving,f=u.checkDeleteAction,v=u.getTotalCropZones,O=u.openConfirmModal,h=u.handleComplete,x=u.setOpenConfirmModal,g=u.cropZonesToModify,C=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return x(!1),e.next=3,h();case 3:t=e.sent,n=g(),a=t.reduce((function(e,t,n){return"rejected"===t.status&&e.push(n),e}),[]),(r=n.filter((function(e,t){return a.includes(t)&&e}))).length>0&&"Deleted"===o.action&&(d({type:Er,payload:r}),d({type:Sr,payload:!0}));case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),P=[];return s.forEach((function(e){return e.cropzones.forEach((function(e){return e.cropSeasons.forEach((function(e){return P.push(e)}))}))})),Object(y.jsxs)("div",{className:"px-6 py-3 bg-gray-100 flex justify-between items-center",id:"mass-assigner-header","data-testid":"mass-assigner-header",children:[Object(y.jsxs)("div",{className:"h-full flex",children:[Object(y.jsxs)("div",{className:"flex flex-col justify-between",children:[Object(y.jsx)("span",{className:"text-gray-800 font-body",children:"Selected Fields"}),Object(y.jsx)("span",{className:"text-3xl font-body",children:s.length})]}),Object(y.jsxs)("div",{className:"flex flex-col justify-between ml-12",children:[Object(y.jsx)("span",{className:"text-gray-800 font-body",children:"Selected Crop Zones"}),Object(y.jsx)("span",{className:"text-3xl font-body",children:v()})]})]}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)(m.Button,{type:"outline",size:"lg",onClick:j,disabled:p,children:"Cancel"}),Object(y.jsx)("div",{className:"ml-5",children:Object(y.jsx)(m.Button,{type:"primary",size:"lg",onClick:f,disabled:!(null!==(t=o.fieldsToMassiveAssign)&&void 0!==t&&t.length)||p,loading:p,children:"Complete"})})]}),Object(y.jsx)(GY,{open:!!l.length,onClose:function(){d({type:Er,payload:[]})},cropzonesToDelete:l}),Object(y.jsx)(JY,{open:O,onClose:function(){return x(!1)},onConfirm:C,relatedSeasons:ae.a.uniqBy(P,"name"),action:o.action})]})},QY=n.p+"static/media/price.3ba28dca.svg",XY=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,c,i;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.id,r(!0),a=hn.createChildApi({action:"cropzone/".concat(n,"/cost")}),c=a.fetch(),i=c.promise,e.abrupt("return",i.then((function(e){var t=e.data;return r(!1),t})).catch(Ae.default).catch((function(){return r(!1),[]})));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{getCropZoneCost:c,loading:n,setLoading:r}},$Y=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,c,i,o,s;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.id,a=t.seasonIds,r(!0),c=pn.createChildApi({action:"farm/".concat(n,"/cost")}),i={seasonIds:a},o=c.post(i),s=o.promise,e.abrupt("return",s.then((function(e){var t=e.data;return r(!1),t})).catch(Ae.default).catch((function(){return r(!1),[]})));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{getFarmCost:c,loading:n,setLoading:r}},eH=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,c,i,o,s;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.id,a=t.seasonIds,r(!0),c=vn.createChildApi({action:"field/".concat(n,"/cost")}),i={seasonIds:a},o=c.post(i),s=o.promise,e.abrupt("return",s.then((function(e){var t=e.data;return r(!1),t})).catch(Ae.default).catch((function(){return r(!1),[]})));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{getFieldCost:c,loading:n,setLoading:r}},tH=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].selectedProperty,n=Object(a.useState)(0),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(0),s=Object(b.a)(o,2),l=s[0],d=s[1],u=XY().getCropZoneCost,j=$Y().getFarmCost,p=eH().getFieldCost,f=function(){var e=Object(Y.a)(G.a.mark((function e(){var n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c=$P(),"farm"===(null===t||void 0===t||null===(n=t.type)||void 0===n?void 0:n.toLowerCase())&&j({id:null===t||void 0===t?void 0:t.id,seasonIds:c}).then((function(e){i(null===e||void 0===e?void 0:e.totalCost),d(null===e||void 0===e?void 0:e.costPerAcre)})),"field"===(null===t||void 0===t||null===(a=t.type)||void 0===a?void 0:a.toLowerCase())&&p({id:null===t||void 0===t?void 0:t.id,seasonIds:c}).then((function(e){i(null===e||void 0===e?void 0:e.totalCost),d(null===e||void 0===e?void 0:e.costPerAcre)})),"crop zone"===(null===t||void 0===t||null===(r=t.type)||void 0===r?void 0:r.toLowerCase())&&u({id:null===t||void 0===t?void 0:t.id}).then((function(e){i(null===e||void 0===e?void 0:e.totalCost),d(null===e||void 0===e?void 0:e.costPerAcre)}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){f()}),[t]),Object(y.jsx)("div",{style:{top:"64px"},className:"absolute w-full z-50 box-border",children:Object(y.jsxs)("div",{className:"flex-1 rounded-lg p-4 m-2 bg-white rounded",children:[Object(y.jsxs)("div",{className:"flex pb-4 items-center",children:[Object(y.jsx)("div",{style:{width:"40px",height:"40px"},className:"rounded bg-neutral-100 flex items-center justify-center",children:Object(y.jsx)("img",{alt:"priceIcon",src:QY})}),Object(y.jsxs)("div",{style:{marginLeft:"12px"},className:"flex-1",children:[Object(y.jsx)("h1",{className:"text-base font-semibold",children:"Contribution Margin"}),Object(y.jsx)("p",{className:"text-xs",children:"An overview of your profits for the selected crop season"})]})]}),Object(y.jsxs)("div",{className:"flex text-sm flex-1 border-b border-neutral-20 py-2",children:[Object(y.jsx)("div",{className:"flex-1",children:"Input Costs"}),Object(y.jsxs)("div",{className:"flex-1 flex justify-end gap-x-1 items-end",children:[Object(y.jsx)("span",{className:"text-neutral-1000",children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:l})}),Object(y.jsx)("span",{className:"text-xs text-neutral-60",children:"/ac"})]}),Object(y.jsxs)("div",{className:"flex-1 flex justify-end gap-x-1 items-end",children:[Object(y.jsx)("span",{className:"text-neutral-1000",children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:c})}),Object(y.jsx)("span",{className:"text-xs text-neutral-60",children:"total"})]})]})]})})},nH=n.p+"static/media/analysis.59626f33.svg",aH=n.p+"static/media/help_outline.9e911cf7.svg",rH=function(e){var t=e.title,n=e.perAcre,r=e.totalValue,c=e.isResult,i=e.tooltip,o="";r<0&&(o="text-red-60"),r>0&&(o="text-green-60"),c&&(o+=" font-bold");var s=Object(a.useContext)(ac),l=Object(b.a)(s,1)[0].isSidebarOpen;return Object(y.jsxs)("div",{className:"flex text-sm flex-1 border-b border-neutral-20 py-3 px-4 ".concat(c?"bg-neutral-20":""),children:[Object(y.jsxs)("div",{className:"flex-1 flex gap-1 ".concat(c?"font-semibold":""),children:[t,!!i&&Object(y.jsx)(Xc.Tooltip,{title:i,trigger:"hover",color:"#232630",children:Object(y.jsxs)("div",{className:"flex flex-row items-center",children:[Object(y.jsx)("img",{src:aH,alt:"help outline icon"}),!l&&Object(y.jsx)("div",{"data-testid":"tooltip-description",className:"ml-px text-xs text-blue-60 tracking-tighter",children:"How is this calculated?"})]})})]}),Object(y.jsxs)("div",{className:"flex-1 flex justify-end gap-x-1 items-end",children:[Object(y.jsx)("span",{className:o,children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:n})}),Object(y.jsx)("span",{className:"text-xs text-neutral-80",children:"/ac"})]}),Object(y.jsx)("div",{className:"flex-1 flex justify-end gap-x-1 items-end",children:Object(y.jsx)("span",{className:o,children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:r})})})]})};rH.defaultProps={tooltip:null,perAcre:0,totalValue:0};var cH=rH;function iH(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e-t}var oH=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2),n=t[0].organization,r=t[1],c=Object(a.useState)(hv),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){var t,a,c,i,o,l,d,j,p,f,m,v,O,h,x,g=arguments;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=g.length>0&&void 0!==g[0]?g[0]:{},a=t.resourceId,c=t.level,i=void 0===c?Pb:c,o=t.seasonIds,l=t.cropId,d=void 0===l?null:l,s((function(e){return xv(e)})),j=i===yb,p=d?"?cropId=".concat(d):"",f=j?vn.createChildApi({action:"field/".concat(a,"/cost").concat(p)}).post({seasonIds:o}):hn.createChildApi({action:"cropzone/".concat(a,"/cost")}).fetch(),m=f.promise,v=o.map((function(e){return"cropSeasonIds[]=".concat(e)})).join("&"),O=d?"&cropId=".concat(d):"",h=j?"?".concat(v).concat(O):"",x=J.a.get("".concat(u.e,"/yield/summary/").concat(i.toLowerCase(),"/").concat(a,"/revenue").concat(h),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:null===n||void 0===n?void 0:n.id}),Authorization:"Bearer ".concat(Ve())}}),Promise.allSettled([m,x]).then((function(e){var t=Object(b.a)(e,2),n=t[0],a=t[1];if("rejected"===n.status&&"rejected"===a.status)throw new Error("Unable to obtain contribution margin.");var r="fulfilled"===n.status&&"totalCost"in n.value.data?n.value.data:{totalCost:0,costPerAcre:0},c="fulfilled"===a.status&&"totalRevenue"in a.value.data?a.value.data:{totalRevenue:0,avgRevenuePerAcre:0};s((function(e){return Cv(e,{cost:r,revenue:c})}))})).catch(Ae.default).catch((function(e){s((function(t){return gv(t,e)})),uc(r)})).finally((function(){s((function(e){return yv(e)}))}));case 11:case"end":return e.stop()}}),e)}))),[r,null===n||void 0===n?void 0:n.id]);return{contributionMargin:o,getContributionMargin:l}},sH=(n(1561),function(e){var t,n,r,c,i,o,s,l,d,u,j=e.selectedCrop,p=Object(a.useContext)(ac),f=Object(b.a)(p,1)[0].selectedProperty,v=Object(a.useContext)(EB).isFieldSelected,O=oH(),h=O.contributionMargin,x=O.getContributionMargin,g=h.data,C=h.isLoading,P=JSON.parse(localStorage.getItem("selectedCropSeasons"))||[],A=P.length>1;return Object(a.useEffect)((function(){var e=v?yb:Pb;x({resourceId:f.id,cropId:j,level:e,seasonIds:P})}),[f,j]),Object(y.jsx)("div",{className:"w-full box-border",children:Object(y.jsxs)("div",{className:"flex-1 rounded-lg p-4 m-2 bg-white rounded shadow-lg",children:[Object(y.jsxs)("div",{className:"flex pb-4 items-center",children:[Object(y.jsx)("div",{style:{width:"40px",height:"40px"},className:"rounded bg-neutral-100 flex items-center justify-center",children:Object(y.jsx)("img",{alt:"analysisIcon",src:nH})}),Object(y.jsxs)("div",{style:{marginLeft:"12px"},className:"flex-1",children:[Object(y.jsx)("h1",{className:"text-base font-semibold",children:"Contribution Margin"}),Object(y.jsx)("p",{className:"text-xs",children:"An overview of your profits for the selected crop season"})]})]}),C?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex text-sm flex-1 bg-neutral-100 py-2 px-4",children:[Object(y.jsx)("div",{className:"flex-1"}),Object(y.jsx)("div",{className:"flex-1 flex justify-end gap-x-1 items-end",children:Object(y.jsx)("span",{className:"text-xs text-neutral-600 font-semibold",children:"Per Acre"})}),Object(y.jsx)("div",{className:"flex-1 flex justify-end gap-x-1 items-end",children:Object(y.jsx)("span",{className:"text-xs text-neutral-600 font-semibold",children:"Total"})})]}),Object(y.jsx)(cH,{title:"Yield Revenue",perAcre:null===g||void 0===g||null===(t=g.revenue)||void 0===t?void 0:t.avgRevenuePerAcre,totalValue:null===g||void 0===g||null===(n=g.revenue)||void 0===n?void 0:n.totalRevenue,tooltip:"Revenue is the sum of all yield loads delivered to sale locations."}),Object(y.jsx)(cH,{title:"Input Costs",perAcre:null!==g&&void 0!==g&&null!==(r=g.cost)&&void 0!==r&&r.costPerAcre?-(null===g||void 0===g||null===(c=g.cost)||void 0===c?void 0:c.costPerAcre):0,totalValue:null!==g&&void 0!==g&&null!==(i=g.cost)&&void 0!==i&&i.totalCost?-(null===g||void 0===g||null===(o=g.cost)||void 0===o?void 0:o.totalCost):0,tooltip:"Input Costs are the sum of all Application costs."}),Object(y.jsx)(cH,{isResult:!0,title:"Net Revenue",perAcre:iH(null===g||void 0===g||null===(s=g.revenue)||void 0===s?void 0:s.avgRevenuePerAcre,null===g||void 0===g||null===(l=g.cost)||void 0===l?void 0:l.costPerAcre),totalValue:iH(null===g||void 0===g||null===(d=g.revenue)||void 0===d?void 0:d.totalRevenue,null===g||void 0===g||null===(u=g.cost)||void 0===u?void 0:u.totalCost)}),A&&v&&Object(y.jsx)("div",{className:"mt-4 text-subtext-sm",children:Object(y.jsx)(Xc.Alert,{showIcon:!0,description:"Contribution Margin calculation is based on all selected crop seasons.",message:"Multiple active crop seasons are selected",type:"warning"})})]})]})})});sH.defaultProps={selectedCrop:null};var lH=sH,dH=function(e){var t=e.selectedCrop;return Object(y.jsx)(lH,{selectedCrop:t})};dH.defaultProps={selectedCrop:null};var uH=dH,bH="338px",jH=function(){return Object(y.jsx)(_B,{children:Object(y.jsx)(pH,{})})},pH=function(){var e,t,n=Object(a.useContext)(EB),r=n.params,c=n.isFarmSelected,i=n.isFieldSelected,o=n.isCostAnalysisViewEnabled,s=n.isPropertyDetailsEnabled,l=n.isHugeOrganization,d=n.selectedProperty,u=n.viewMode,j=n.onViewModeChange,p=n.onDrawFieldsClick,f=n.isLoadingFields,v=n.propertyLandingPageData,O=n.fieldsAndAreasGeoJSONCollection,h=n.setGeoJSONCollectionFeatures,x=n.filterFeatureCollectionByParentId,g=n.fetchProperties,C=Object(a.useContext)(ac),P=Object(b.a)(C,2),A=P[0],S=A.isMassAssignerActive,T=A.isGlobalCropSeasonLoading,N=A.isFieldImportedSuccessful,E=A.isEnableInfoTabEdit,w=A.isLoadingOrg,_=A.fieldsToMassiveAssign,R=A.importedFields,I=A.loggedInUserOrgPermission,D=A.massAssignerSuccessCounter,k=A.organization,L=P[1],F=Du().crops,M=av(l),V=M.filteredProperties,B=M.setPropertiesToFilter,U=ni(),z=Object(a.useState)([V]),Z=Object(b.a)(z,2),Y=Z[0],H=Z[1],G=Object(a.useState)(!1),W=Object(b.a)(G,2),q=W[0],J=W[1],K=Object(a.useState)(!1),Q=Object(b.a)(K,2),X=Q[0],$=Q[1],ee=Object(a.useState)(!1),te=Object(b.a)(ee,2),ne=te[0],ae=te[1],re=Object(a.useState)(),ce=Object(b.a)(re,2),ie=ce[0],oe=ce[1],se=Object(a.useState)(!1),le=Object(b.a)(se,2),de=le[0],ue=le[1],be=Object(a.useState)(!!N),je=Object(b.a)(be,2),pe=je[0],fe=je[1];jH.zoomPropertyOut=function(){h(x(O,d.id,_))};var me={Farm:Object(y.jsx)(zY,{farmName:d.name,farmId:d.id,reloadFarmData:g,setView:j})},ve=function(){return fe((function(e){return!e}))},Oe=Object(a.useCallback)((function(){return ue(!0)}),[]);Object(a.useEffect)((function(){jH.zoomPropertyOut()}),[d.id,S,_]);var he=!(null!==d&&void 0!==d&&d.isEditing);return Object(a.useEffect)((function(){!T&&null!==k&&void 0!==k&&k.id&&g({seasonIds:JSON.parse(localStorage.getItem("selectedCropSeasons"))},r)}),[r,null===k||void 0===k?void 0:k.id,T]),Object(a.useEffect)((function(){return function(){L({type:Sr}),localStorage.removeItem(Ab)}}),[L]),Object(a.useEffect)((function(){B(null===v||void 0===v?void 0:v.properties),H(V)}),[null===v||void 0===v?void 0:v.properties,V,B]),Object(a.useEffect)((function(){H(V)}),[V]),Object(a.useEffect)((function(){if(Object.keys(D).length){var e=D.toastType,t=D.toastTitle,n=D.toastDescription;U[e](t,{content:n}),setTimeout((function(){L({type:Nr,payload:{}})}),5e3)}}),[D]),Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{className:"w-full h-full overflow-hidden",children:[Object(y.jsx)(HY,{title:function(){var e;if(E){if(c)return"Edit Farm";if(i)return"Edit Field info: ".concat(null===d||void 0===d?void 0:d.name)}return null!==d&&void 0!==d&&d.id?c?null===d||void 0===d?void 0:d.name:(null===(e=V.find((function(e){return e.id===d.farmId})))||void 0===e?void 0:e.name)||(null===d||void 0===d?void 0:d.name):"All Properties"}(),properties:V,disabledPropertyChange:!0}),de&&Object(y.jsx)(lY,{open:de,closeModal:ue,drawFieldsClick:function(e){return p(e,V)},uploadFilesClick:ve}),w||T?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{className:"w-full h-full",children:[S&&Object(y.jsx)(KY,{reloadData:g}),Object(y.jsxs)("div",{className:"flex flex-row w-full ".concat(S?"-h-24":"h-full"),children:[Object(y.jsx)("div",{className:"w-".concat(bH," h-full"),children:null!==d&&void 0!==d&&d.isEditing?me[d.type]:Object(y.jsx)(VU,{openCreateModal:Oe,properties:V,rawProperties:null!==(e=null===v||void 0===v?void 0:v.properties)&&void 0!==e?e:[],memberRole:null===I||void 0===I?void 0:I.role})}),Object(y.jsxs)("div",{className:"h-full relative flex flex-col",style:{width:"calc(100% - ".concat(bH,")")},children:[he&&Object(y.jsx)("div",{className:u!==Sb?"w-full":"absolute z-40 bg-white w-full",children:Object(y.jsx)(xY,{viewMode:u,edited:q,setCancelEditModalVisible:ae,enableEdit:X,setEnableEdit:$,properties:V,selectedCrop:ie,setSelectedCrop:oe})}),o&&u===Nb&&Object(y.jsx)(uH,{selectedCrop:ie}),u===Sb&&Object(y.jsxs)("div",{className:"relative",children:[he&&!o&&s&&Object(y.jsx)(tH,{}),Object(y.jsx)(UU,{properties:Y,fieldsLoading:f,propertyCount:null===(t=k.properties)||void 0===t?void 0:t.propertyCount,crops:F})]}),u===Tb&&Object(y.jsx)(aY,{setCancelEditModalVisible:ae,edited:q,setEdited:J,enableEdit:X,setEnableEdit:$})]}),Object(y.jsx)(IY,{open:pe,close:ve,reload:g,importedFields:R})]})]}),Object(y.jsx)(m.SimpleModal,{open:ne,close:function(){return ae(!1)},confirmLabel:"Exit Form",onCancel:function(){ae(!1)},onConfirm:function(){$(!1),ae(!1)},title:"Leaving Form",type:"error",children:Object(y.jsx)("span",{children:"Navigating away from this form will discard all unsaved changes."})})]})})},fH=jH,mH=n.p+"static/media/edit_field.05e200d4.svg",vH=n.p+"static/media/crop_cycle.fc3cf698.svg",OH=n(801),hH=function(e,t){var n;return!t.titleQuery||(null===(n=e.title)||void 0===n?void 0:n.toLowerCase().match(t.titleQuery.toLowerCase()))},xH=function(e,t){return!t.dateRange.length||new Date(t.dateRange[0])<=new Date(e.proposedDateEpoch)&&new Date(Object(OH.a)(t.dateRange[1],1))>=new Date(e.expirationDateEpoch)},gH=n(78),CH=n.n(gH);function yH(e){var t=e.seasons,n=e.seasonIds;return Object(ne.isNil)(t)?"":Object(ne.compact)(n.map((function(e){var n=t.find((function(t){return t.id===e}));return Object(ne.isNil)(n)?null:n.name}))).join(", ")}function PH(e){var t=e.expirationDateEpoch,n=e.proposedDateEpoch;if(Object(ne.isNil)(t)&&Object(ne.isNil)(n))return"";var a=new Date(n),r=new Date(t);if(Object(ne.isNil)(t))return fA(a);if(Object(ne.isNil)(n))return fA(r);var c=fA(a),i=fA(r);if(c===i)return c;if(a.getFullYear()===r.getFullYear()){var o=a.toLocaleDateString("en-US",{month:"2-digit",day:"2-digit"});return"".concat(o," - ").concat(i)}return"".concat(c," - ").concat(i)}var AH=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2)[1],n=Object(a.useContext)(we),r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)([]),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(0),f=Object(b.a)(j,2),m=f[0],v=f[1],O=Object(a.useState)(),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)({page:x||0,size:wo,dateRange:[],titleQuery:"",sortBy:"",sortDir:"",cropSeasonIds:JSON.parse(localStorage.getItem("selectedCropSeasons"))}),y=Object(b.a)(C,2),P=y[0],A=y[1],S=ni(),T=Object(p.h)(),N=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(n,a,r){var c,i;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o(!0),!n){e.next=5;break}u(n),e.next=8;break;case 5:return c=nn.fetch(null,{pageNo:a,seasonIdsCommaSeparated:r||JSON.parse(localStorage.getItem("selectedCropSeasons")).join(","),includeExtended:!0},{},null,!1),i=c.promise,e.next=8,i.then((function(e){var t=e.data,n=t.results.filter((function(e){return hH(e,P)})).filter((function(e){return xH(e,P)}));u(Object(ne.orderBy)(n,"proposedDate","desc")),v(t.totalElements)})).catch(Ae.default).catch((function(e){uc(t)(e)})).finally((function(){return setTimeout((function(){o(!1)}),700)}));case 8:o(!1);case 9:case"end":return e.stop()}}),e)})));return function(t,n,a){return e.apply(this,arguments)}}(),[t,P]),E=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){var t,n=arguments;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=n.length>0&&void 0!==n[0]?n[0]:null,N(t),g();case 3:case"end":return e.stop()}}),e)}))),[N]);Object(a.useEffect)((function(){return function(){null}}),[]),Object(a.useEffect)((function(){E()}),[E,P]);var w=Object(a.useCallback)((function(e){N(null,e),A((function(t){return Object(I.a)(Object(I.a)({},t),{},{page:e})})),g(e)}),[A,N]),_=Object(a.useCallback)((function(e){2!==e.length&&0!==e.length||A((function(t){return Object(I.a)(Object(I.a)({},t),{},{page:0,dateRange:e})}))}),[A]),R=Object(a.useCallback)((function(e){A((function(t){return Object(I.a)(Object(I.a)({},t),{},{page:0,titleQuery:e})}))}),[A]),D=Object(a.useCallback)((function(e,t){A((function(n){return Object(I.a)(Object(I.a)({},n),{},{page:0,sortBy:e,sortDir:t})}))}),[A]),k=function(){var e=Object(Y.a)(G.a.mark((function e(t){var a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o(!0),a=nn.createChildApi({action:"recommendation/".concat(t.id,"/task")}).create(null,{headers:{"cwf-context":JSON.stringify({organization_id:t.orgId})}}),r=a.promise,e.next=4,r.then((function(e){var a=e.data;n.sendEventToAmplitude(n.events.epic.Tasks.saveTaskFromRecSuccess),S.success("Task created",{content:"Recommendation ".concat(t.title," successfully converted into a Task"),actionButton:function(){n.sendEventToAmplitude(n.events.epic.Tasks.viewTask),T.push("".concat(Cc.tasks,"/").concat(a,"/view"))}})})).catch(Ae.default).catch((function(e){var t=dc({},e);S.error("Error while creating task",{content:t.displayMessage,supportButton:!0,timeout:3e4})})).finally((function(){return setTimeout((function(){o(!1)}),700)}));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{isLoading:i,recommendations:d,recommendationsCount:m,page:P.page,goToPage:w,dateRange:P.dateRange,filterByDateRange:_,titleQuery:P.titleQuery,filterByTitleQuery:R,sort:D,sortBy:P.sortBy,sortDir:P.sortDir,reload:E,reset:function(){A(Object(I.a)(Object(I.a)({},P),{},{page:x||0,totalPages:0,size:wo,cropSeasonIds:JSON.parse(localStorage.getItem("selectedCropSeasons"))}))},getRecommendations:N,convertToTask:k}},SH=function(e){var t=Object(a.useContext)(ac),n=Object(b.a)(t,2)[1],r=Object(a.useState)([]),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(!0),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(Object(I.a)({pageNo:0,size:wo,seasonIdsCommaSeparated:JSON.parse(localStorage.getItem("selectedCropSeasons")).join(",")},e)),p=Object(b.a)(j,1)[0],f=Object(a.useCallback)((function(e){var t=xn.fetch(null,Object(I.a)(Object(I.a)({},p),e),{},null,!1),a=t.promise,r=t.cancel;return a.then((function(e){var t=e.data;o(t.results)})).catch(Ae.default).catch((function(e){uc(n)(e)})).finally((function(){return u(!1)})),r}),[p,n]);return Object(a.useEffect)((function(){var e=f();return function(){e()}}),[f]),{tasks:i,loading:d,loadTasks:f}},TH=function(e){var t=e.open,n=e.close,r=e.cropzoneName,c=e.cropzoneId,i=e.setReRenderProperties,o=e.onDelete,s=Su().plans,l=AH().recommendations,d=SH().tasks,u=ni(),j=Object(a.useState)(!1),p=Object(b.a)(j,2),f=p[0],m=p[1],v=function(e){u.error("Unable to delete Crop Zone.",{content:e}),n()},O=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=[],(null===s||void 0===s?void 0:s.some((function(e){var t;return null===(t=e.cropZones)||void 0===t?void 0:t.some((function(e){return c===e.cropZoneIdValue}))})))&&t.push("a plan"),(null===d||void 0===d?void 0:d.flatMap((function(e){return e.properties})).some((function(e){return(null===e||void 0===e?void 0:e.cropZoneId)===c})))&&t.push("a task"),(null===l||void 0===l?void 0:l.flatMap((function(e){return e.cropZones})).some((function(e){return e.cropZoneIdValue===c})))&&t.push("a recommendation"),!(t.length>0)){e.next=8;break}return n=t.join(", ").replace(/, (a \w+)$/," and $1"),v("This Crop Zone cannot be deleted as it belongs to ".concat(n)),e.abrupt("return");case 8:return m(!0),a=On.delete(c),r=a.promise,e.next=12,r.then((function(){i(!0),o()})).catch(Ae.default).catch((function(e){m(!1),v(e.response.data.message)}));case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)(y.Fragment,{children:Object(y.jsx)(ao,{"data-testid":"delete-cropzone-modal",open:t,title:r&&"Delete this Crop Zone?",close:n,cancelLabel:"Cancel",confirmLabel:"Delete",onCancel:n,type:"error",onConfirm:O,isSaving:f,children:Object(y.jsxs)("div",{className:"pr-6",children:["Are you sure you want to delete the Crop Zone ",r,"?"]})})})};TH.defaultProps={setReRenderProperties:function(){},onDelete:function(){}};var NH=Object(p.l)(TH),EH=function(){var e=Object(p.j)().action,t=Object(p.h)(),n="edit"===e?"Edit":"Add";return Object(y.jsxs)("div",{className:"flex mb-2",children:[Object(y.jsx)("div",{className:"mt-1 mr-2",children:Object(y.jsx)("button",{type:"button",onClick:function(){return t.push(Cc.properties)},children:Object(y.jsx)(ui.a,{icon:di.e,size:"lg",style:{visibility:"visible"}})})}),Object(y.jsx)("div",{className:"flex-1 flex-col mx-2",children:Object(y.jsxs)("div",{className:"text-3xl font-semibold leading-none",children:[n," Crop Zone"]})})]})},wH=function(e){var t=e.children,n=e.onClick,a=e.disabled;return Object(y.jsx)("button",{type:"button",onClick:n,disabled:a,className:"py-2 pl-2 focus:outline-none whitespace-no-wrap",children:Object(y.jsx)("div",{className:"flex justify-start",children:t})})};wH.defaultProps={disabled:!1,onClick:function(){}};var _H=wH,RH=function(e){var t=e.children,n=e.onSave,r=e.disabled,c=e.canDelete,i=Object(p.h)(),o=Object(p.j)().action,s=Object(Zi.h)().isSubmitting,l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],f="edit"===o,v=f?{}:{borderTopRightRadius:"0",borderBottomRightRadius:"0",borderRight:"none"};return Object(y.jsxs)(y.Fragment,{children:[f&&Object(y.jsx)("div",{className:"absolute left-0",children:Object(y.jsx)(m.Button,{danger:!0,type:"text",icon:Object(y.jsx)(Uh,{}),onClick:function(){return j(!0)},disabled:!c,children:"Delete"})}),Object(y.jsxs)("div",{className:"flex space-x-3",children:[Object(y.jsx)(m.Button,{onClick:function(){return i.push(Cc.properties)},children:"Cancel"}),Object(y.jsxs)("div",{className:"flex top-0 white-bg",children:[Object(y.jsx)(m.Button,{type:"primary",className:"w-full",disabled:r,loading:s,style:v,onClick:function(){return n()},children:"Save"}),f?t({deleteModalOpen:u,setDeleteModalOpen:j}):Object(y.jsx)(m.Popup,{align:"right",position:"top",trigger:Object(y.jsx)(m.Button,{className:"",type:"primary",disabled:r,style:{borderTopLeftRadius:"0",borderBottomLeftRadius:"0",borderLeft:"none"},children:Object(y.jsx)(Ux.a,{})}),children:Object(y.jsx)("div",{className:"flex flex-col font-normal text-gray-700",style:{minWidth:"300px"},children:t})})]})]})]})};RH.defaultProps={disabled:!1,canDelete:!1};var IH=RH,DH=function(e){var t=e.name,n=Object(Zi.h)().setFieldValue;return Object(a.useEffect)((function(){n("name",t)}),[t]),Object(y.jsx)(Qi,{control:m.Input,name:"name",label:"Crop Zone Name*"})};DH.defaultProps={name:""};var kH=DH,LH=function(e){var t=e.boundaryArea,n=e.reportedArea,r=Object(Zi.h)().setFieldValue;return Object(a.useEffect)((function(){if(0!==n){var e=(Math.round(100*n)/100).toFixed(2);r("reportedArea",e)}}),[n]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Qi,{control:m.Input,name:"boundaryArea",label:"Estimated Boundary Area",value:"".concat(t," acres"),disabled:!0}),Object(y.jsx)(Qi,{control:m.Input,name:"reportedArea",label:"Reported Area",placeholder:"--"})]})};LH.defaultProps={boundaryArea:0,reportedArea:""};var FH=LH,MH=function(e){var t=e.cropId,n=Du().crops,r=Object(Zi.h)().setFieldValue,c=Object(a.useMemo)((function(){return(null===n||void 0===n?void 0:n.map((function(e){return{key:e.id,value:e.name}})))||[]}),[n]);return Object(a.useEffect)((function(){r("crop",t)}),[t]),Object(y.jsxs)("div",{className:"-mt-8",children:[Object(y.jsx)("label",{htmlFor:"crop",className:"text-neutral-600 text-sm inline-block mb-1 ",children:"Crop*"}),Object(y.jsx)(Qi,{name:"crop",items:c,control:m.Search,placeholder:"Select Crop",onSelect:function(e){var t=e.key,n=e.value;r("crop",t),r("name",n)}})]})};MH.defaultProps={cropId:""};var VH=MH,BH="__CREATE__",UH={key:BH,value:"+ Create New Crop Season"},zH=function(e){var t=e.cropSeasonId,n=dd().cropSeasons,r=Object(Zi.h)().setFieldValue,c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(null),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useMemo)((function(){return[UH].concat(Object(v.a)((null===n||void 0===n?void 0:n.map((function(e){return{key:e.id,value:e.name}})))||[]))}),[n]);Object(a.useEffect)((function(){r("cropSeasonId",t)}),[t]),Object(a.useEffect)((function(){var e=p.find((function(e){return e.key===(null===u||void 0===u?void 0:u.id)}));e&&r("cropSeasonId",e.key)}),[u,p,r]);return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)($i,{open:o,onClose:function(){s(!1)},onSuccess:function(e){j(e)}}),Object(y.jsxs)("div",{className:"-mt-8",children:[Object(y.jsx)("label",{htmlFor:"cropSeasonId",className:"text-neutral-600 text-sm inline-block mb-1 ",children:"Crop Season*"}),Object(y.jsx)(Qi,{name:"cropSeasonId",items:p,control:m.Search,placeholder:"Select Season",onSelect:function(e){e.key===BH?(r("cropSeasonId",null),s(!0)):r("cropSeasonId",e.key)}})]})]})};zH.defaultProps={cropSeasonId:""};var ZH=zH,YH=Fu.e().shape({name:Fu.f().trim().required("Required")}),HH=function(){return Object(y.jsx)("div",{className:"border-b mb-2 mt-2 -ml-10 -mr-6"})},GH=function(e){var t,n=e.field,r=e.features,c=e.isSaving,i=e.cropzone,o=hU().isOrgInFF,s=Object(p.h)(),l=Object(p.j)(),d=l.action,u=l.cropzoneId,j=Object(a.useState)(null),m=Object(b.a)(j,2),v=m[0],O=m[1],h=Object(a.useState)(!1),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useState)(!1),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useRef)(""),E=Object(a.useRef)(!1),w=Object(a.useContext)(ac),_=Object(b.a)(w,2),R=_[0].organization,D=_[1],k=Ov(u),L=k.cropZone,F=k.createCropZone,M=k.updateCropZone,V=MB(),B=V.getCropSeason,U=V.updateCropSeason,z=V.prepareCropSeason,Z=Object(f.useFlags)(),H=Z.releaseFeCondensedCropSeasons,W=Z.releaseFeCondensedCropSeasonsByOrg,q=yc(H,W,null===R||void 0===R?void 0:R.id),J="edit"===d,K=null!==i&&void 0!==i&&i.cropSeasons?null===i||void 0===i||null===(t=i.cropSeasons[0])||void 0===t?void 0:t.id:"",Q=function(){var e=Object(Y.a)(G.a.mark((function e(t){var a,i,l,d,u,b,j;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=t.crop,i=t.name,l=t.reportedArea,d=t.cropSeasonId,c(!0),u=r.map((function(e){return"Polygon"===e.geometry.type?Object(I.a)(Object(I.a)({},e),{},{geometry:{type:"MultiPolygon",coordinates:[e.geometry.coordinates]}}):e})),(b=Nj(u)).coordinates=ae.a.flatten(b.coordinates),e.prev=5,j={id:null!==L&&void 0!==L&&L.id?L.id:"",name:i,cropId:a,reportedArea:l?parseFloat(l):0,fieldId:null===n||void 0===n?void 0:n.id,propertyId:null===n||void 0===n?void 0:n.propertyId,geometry:b,coordinates:Oj(u).toString()},o&&(j.cropSeasonId=d),J){e.next=13;break}return e.next=11,F(j);case 11:e.next=15;break;case 13:return e.next=15,M(j);case 15:if(E.current=!0,C(!0),!j.cropSeasonId){e.next=20;break}return e.next=20,mc(D,[j.cropSeasonId],q);case 20:o&&(c(!1),"reload"===N.current?window.location.reload():s.push(N.current)),e.next=27;break;case 23:e.prev=23,e.t0=e.catch(5),C(!1),c(!1);case 27:case"end":return e.stop()}}),e,null,[[5,23]])})));return function(t){return e.apply(this,arguments)}}(),X=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,a,r,i;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,K===v){e.next=15;break}if(!K){e.next=9;break}return e.next=5,B(K);case 5:return t=e.sent,a=z(t,null===n||void 0===n?void 0:n.propertyId,null===L||void 0===L?void 0:L.id,!0),e.next=9,U(K,a);case 9:return e.next=11,B(v);case 11:return r=e.sent,i=z(r,null===n||void 0===n?void 0:n.propertyId,null===L||void 0===L?void 0:L.id),e.next=15,U(v,i);case 15:"reload"===N.current?window.location.reload():s.push(N.current),e.next=22;break;case 18:e.prev=18,e.t0=e.catch(0),C(!1),c(!1);case 22:case"end":return e.stop()}}),e,null,[[0,18]])})));return function(){return e.apply(this,arguments)}}();Object(a.useEffect)((function(){var e=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!L||!g){e.next=3;break}return e.next=3,X();case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();o||e()}),[L,g]),Object(a.useEffect)((function(){O(K)}),[K]);var $=Object(a.useMemo)((function(){var e=r.length?Tj(r):0;return ae.a.round(e,2).toFixed(2)}),[r]),ee=function(){T(!0),E.current=!0,s.push(Cc.properties)};return Object(y.jsx)(Zi.e,{initialValues:{crop:"",name:"",reportedArea:"",cropSeasonId:""},onSubmit:function(e){O(null===e||void 0===e?void 0:e.cropSeasonId),Q(e)},validationSchema:YH,children:function(e){var t,a=e.submitForm,c=e.values,o=!e.isSubmitting&&function(e){var t=e.cropSeasonId,a=e.crop,c=e.name,i=e.reportedArea;return!!a&&!(!c||!ae.a.trim(c))&&!!n&&!!r.length&&!!t&&(!i||!isNaN(parseFloat(i)))}(c);return Object(y.jsxs)("div",{className:"flex flex-col h-full",children:[Object(y.jsx)(Sm,{disabled:E.current,isDeleting:S,alwaysShow:!0}),Object(y.jsx)(EH,{}),Object(y.jsx)(HH,{}),Object(y.jsxs)("div",{className:"flex-1 mt-12 flex flex-col gap-12",children:[Object(y.jsx)(ZH,{cropSeasonId:K}),Object(y.jsx)(VH,{cropId:(null===L||void 0===L?void 0:L.cropId)||(null===i||void 0===i||null===(t=i.crop)||void 0===t?void 0:t.id)}),Object(y.jsx)(kH,{name:null===i||void 0===i?void 0:i.name}),Object(y.jsx)(FH,{boundaryArea:$,reportedArea:null===i||void 0===i?void 0:i.reportedArea})]}),Object(y.jsx)(HH,{}),Object(y.jsx)("div",{className:"flex justify-end mt-3 relative",children:Object(y.jsx)(IH,{disabled:!o,onSave:function(){N.current=Cc.properties,a()},canDelete:!!i,children:J?function(e){var t=e.deleteModalOpen,n=e.setDeleteModalOpen;return Object(y.jsx)(NH,{open:t,close:function(){return n(!1)},cropzoneId:null===i||void 0===i?void 0:i.id,cropzoneName:null===i||void 0===i?void 0:i.name,onDelete:ee})}:Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(_H,{disabled:!o,onClick:function(){N.current="reload",a()},children:[Object(y.jsx)("img",{src:vH,alt:"",className:"mr-2"}),"Save and Add another Crop zone"]}),Object(y.jsxs)(_H,{disabled:!o,onClick:function(){N.current="".concat(Cc.properties,"/create"),a()},children:[Object(y.jsx)("img",{src:mH,alt:"",className:"mr-2"}),"Save and Draw a new Field"]})]})})})]})}})};GH.defaultProps={field:null,features:[],isSaving:function(){},cropzone:null};var WH=GH,qH=function(){var e=Object(p.j)(),t=e.fieldId,n=e.action,r=e.cropzoneId,c=Pv(null,!1),i=c.fieldGeoJSONCollection,o=c.loading,s=c.zoom,l=void 0===s?ub:s,d=c.setZoom,u=c.loadField,j="edit"===n?"Edit":"New",f=Object(a.useState)(!1),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)([]),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)([]),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)(null),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)(null),V=Object(b.a)(M,2),B=V[0],U=V[1],z=Object(a.useState)({}),Z=Object(b.a)(z,2),Y=Z[0],H=Z[1],G=Object(a.useRef)(Object(Wu.a)()),W=Object(a.useRef)((function(e){return 1===e.geometry.coordinates.length?Ej(e):e})),q=Object(a.useMemo)((function(){return Y.features?mj(Y):null}),[Y]),J=Object(a.useMemo)((function(){var e;return null===q||void 0===q||null===(e=q.geometry)||void 0===e?void 0:e.coordinates}),[q]);Object(a.useEffect)((function(){t&&u(t,!1,!0)}),[]),Object(a.useEffect)((function(){if(!o&&i){var e=[],n=i.features.find((function(e){return e.properties.id===t}));if(n){n.properties.$layer="default",n.id=t,U(n.properties),e.push(W.current(n)),n.properties.cropzones.forEach((function(t){var n=i.features.find((function(e){return e.properties.id===t.id})),a="default";n.properties.id===r&&(a="selected",n.id=r,F(n.properties)),n.properties.$layer=a,e.push(W.current(n))})),r||e.push(W.current(Object(I.a)(Object(I.a)({},n),{},{id:G.current,properties:Object(I.a)(Object(I.a)({},n.properties),{},{$layer:"selected"})})));var a={type:"FeatureCollection",features:e},c=_j(void 0,a,!1),s=Rj(c);d([s-1]),P(e),R(r||G.current),H(a)}}}),[null===i||void 0===i?void 0:i.features,r,t,o]);var K=Object(a.useCallback)((function(e){return P(ae.a.uniqBy(e,"id"))}),[P]),Q=Object(a.useCallback)((function(e){var t=C.filter((function(t){return e.includes(t.id)}));N(t)}),[C]);return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(lo,{disabled:!0,children:Object(y.jsx)(lo.Item,{title:"Properties",value:"".concat(j," Crop Zone"),isLast:!0})}),Object(y.jsxs)("div",{className:"flex h-full w-full",children:[Object(y.jsx)("div",{className:"flex flex-col w-1/3 h-auto m-4",children:Object(y.jsx)(WH,{field:B,features:T,isSaving:h,cropzone:L})}),Object(y.jsx)("div",{className:"relative w-full",id:"map-wrapper-container",children:o||O||!J?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(mm,{zoom:l,setZoom:d,currentCoordinates:J,shapeIdSelected:_,geoJSONCollection:Y,onSelectFeatures:Q,onFeaturesChange:K,setNewFieldFeatures:N})})]})]})},JH=Object(p.l)((function(e){var t=e.open,n=e.close,r=e.fieldId,c=e.setReRenderProperties,i=Object(a.useState)(null),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(!0),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(!1),v=Object(b.a)(f,2),O=v[0],h=v[1],x=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h(!0),t=mn.delete(r),n=t.promise,e.next=4,n.then((function(){c(!0)})).catch(Ae.default).catch((function(e){var t;h(!1),t=e.response.data.message,l(t),p(!0)}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(ao,{"data-testid":"delete-field-modal",open:t,title:"Delete this Field?",close:n,cancelLabel:"Cancel",confirmLabel:"Delete",onCancel:function(){return n()},type:"error",onConfirm:function(){return x()},isSaving:O,children:[Object(y.jsx)("div",{className:"pr-6",children:"Are you sure you want to delete this field? This action cannot be undone."}),j?Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){p(!1)},children:s}):null]})})})),KH={borderTopRightRadius:"0",borderBottomRightRadius:"0",height:"50px",borderRight:"none"},QH=function(e){var t=e.saveButtonDisabled,n=e.saveDrawAgain,r=e.saveCreateCZ,c=e.saveDirectToProp,i=e.label,o=e.chkSubmitStatus,s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1];return Object(y.jsx)("div",{className:"top-0 white-bg",children:Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)(m.Button,{disabled:t||o,loading:o,type:"primary",onClick:function(){return c()},className:"w-full",style:"create"===i?KH:{height:"50px",borderRight:"none"},children:"Save Field"}),"create"===i?Object(y.jsx)(m.Popup,{position:"top",align:"right",trigger:Object(y.jsx)(m.Button,{className:"",type:"primary",onClick:function(){return u(!0)},disabled:t,style:{height:"50px",borderTopLeftRadius:"0",borderBottomLeftRadius:"0",borderLeft:"none"},children:Object(y.jsx)(Ux.a,{})}),open:d,children:Object(y.jsx)("div",{style:{minWidth:"250px"},className:"mb-3 max-w-full text-left flex flex-wrap justify-between",children:Object(y.jsxs)("ul",{className:"font-normal text-gray-700 text-left",children:[Object(y.jsx)("li",{className:"cursor-pointer hover:bg-gray-200 hover:bg-text-800",children:Object(y.jsx)("button",{onClick:function(){n(),u(!1)},"data-testid":"field-btn",type:"button",className:"w-full py-2 pl-2 text-left focus:outline-none",children:Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("img",{src:mH,alt:"",className:"mr-2"}),"Save and draw a new field"]})})}),Object(y.jsx)("li",{className:"cursor-pointer hover:bg-gray-200 hover:bg-text-800",children:Object(y.jsx)("button",{onClick:function(){r(),u(!1)},"data-testid":"crop-zone-btn",type:"button",className:"w-full py-2 pl-2 text-left focus:outline-none",children:Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("img",{src:vH,alt:"",className:"mr-2"}),"Save and add a crop zone"]})})})]})})}):Object(y.jsx)(y.Fragment,{})]})})};QH.defaultProps={saveButtonDisabled:!1,chkSubmitStatus:!1};var XH=QH,$H=Object(p.l)((function(e){var t=e.open,n=e.close,r=e.fieldId,c=e.onSuccess,i=e.onError,o=Pv(r),s=o.archiveField,l=o.field,d=Object(a.useState)(!1),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useContext)(we),m=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f.sendEventToAmplitude(f.events.epic.Properties.archiveField),p(!0),t=s(r),e.next=5,t.then((function(){p(!1),n(),c(null===l||void 0===l?void 0:l.name)})).catch(Ae.default).catch((function(){p(!1),n(),i(null===l||void 0===l?void 0:l.name)}));case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)(ao,{"data-testid":"archive-field-modal",open:t,title:"Archive ".concat(null===l||void 0===l?void 0:l.name,"?"),close:n,cancelLabel:"Cancel",confirmLabel:"Archive field",onCancel:function(){return n()},type:"warningConfirmation",onConfirm:function(){return m()},isSaving:j,children:Object(y.jsx)("div",{className:"pr-6",children:"This field will be archived along with all associated crop zones. You can unarchive this field later. Do you want to continue?"})})})),eG=function(e){var t,n,r,c,i=e.saveButtonDisabled,o=e.cancelClick,s=e.saveFieldCreateZone,l=e.saveFieldDirectToProperties,d=e.label,u=e.chkSubmitStatus,j=e.fieldId,v=e.setChkNavGuardDisabled,O=Object(a.useState)(""),h=Object(b.a)(O,2),x=h[0],g=h[1],C=null===ac||void 0===ac||null===(t=ac._currentValue[0])||void 0===t||null===(n=t.organization)||void 0===n?void 0:n.id,P=Object(f.useFlags)(),A=P.feArchiveField||P.feArchiveFieldOrgIds&&-1!==P.feArchiveFieldOrgIds.indexOf(C),S=Object(p.h)(),T=Object(Zi.h)(),N=T.values,E=T.submitForm,w=Object(a.useState)(!1),_=Object(b.a)(w,2),R=_[0],I=_[1],D=Object(a.useState)(!1),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)(!1),V=Object(b.a)(M,2),B=V[0],U=V[1],z=Object(a.useState)(!1),Z=Object(b.a)(z,2),Y=Z[0],H=Z[1],G=Object(a.useState)(!1),W=Object(b.a)(G,2),q=W[0],J=W[1];return Object(a.useEffect)((function(){R&&(v(!0),S.goBack(),I(!1))}),[R,v,S]),Object(y.jsxs)("div",{"data-testid":"property-create-toolbar",className:"flex w-full ".concat("create"===d?"justify-end":"-ml-2"),style:{alignItems:"center"},children:["create"!==d&&Object(y.jsxs)("div",{className:"flex-col flex-1",children:[Object(y.jsx)("div",{className:"text-sm text-neutral-600"}),Object(y.jsx)("div",{"data-testid":"property-create-total-area",className:"text-2xl",children:A?Object(y.jsx)(MY,{title:"Archive",saveButtonDisabled:i,chkSubmitStatus:u,onPress:function(){return U(!0)},options:[{label:"Delete Field",danger:!0,onClick:function(){return F(!0)}}]}):Object(y.jsx)(m.Button,{danger:!0,type:"text",icon:Object(y.jsx)(Uh,{}),onClick:function(){return F(!0)},style:{padding:0},children:"Delete Field"})})]}),Object(y.jsxs)("div",{"data-testid":"property-create-buttons",className:"flex space-x-3 justify-between align-center",children:[Object(y.jsx)(m.Button,{style:{height:"50px",padding:0},onClick:o,type:"",children:"Cancel"}),Object(y.jsx)(XH,{saveButtonDisabled:i,saveDrawAgain:function(){return E()},saveCreateCZ:function(){return s()},saveDirectToProp:function(){return l()},label:d,chkSubmitStatus:u})]}),Object(y.jsx)($H,{open:B,close:function(){return U(!1)},fieldName:null===N||void 0===N||null===(r=N.field)||void 0===r?void 0:r.name,fieldId:j,setReRenderProperties:I,onSuccess:function(e){var t;g(e||(null===N||void 0===N||null===(t=N.field)||void 0===t?void 0:t.name)),J(!0)},onError:function(e){var t;g(e||(null===N||void 0===N||null===(t=N.field)||void 0===t?void 0:t.name)),H(!0)}}),Object(y.jsx)(JH,{open:L,close:function(){return F(!1)},fieldName:null===N||void 0===N||null===(c=N.field)||void 0===c?void 0:c.name,fieldId:j,setReRenderProperties:I}),Object(y.jsx)(Qc,{type:"error",title:"".concat(x," was not archived"),open:Y,onClose:function(){H(!1)},children:Object(y.jsxs)("div",{className:"flex flex-col gap-4",children:[Object(y.jsx)("p",{children:"An error prevented your field from being archived. Please try again."}),Object(y.jsx)("div",{className:"self-end w-fit font-normal text-center",children:Object(y.jsx)(m.Button,{onClick:function(){window.open("https://www.syngentadigital.com/us-en","_blank","noopener")},type:"primary",children:"Contact Support"})})]})}),Object(y.jsx)(Qc,{type:"success",title:"".concat(x," archived"),open:q,timeout:2e3,onClose:function(){J(!1),I(!0)},children:"You have archived your field and all associated crop zones"})]})};eG.defaultProps={saveButtonDisabled:!1,chkSubmitStatus:!1};var tG=eG,nG=function(e){var t=e.features,n=e.children,a=e.saveAndCreateCZ,r=e.saveAndDirectToProperties,c=e.canSave,i=e.cancelBackButton,o=e.label,s=e.chkSubmitStatus,l=e.fieldId,d=e.setChkNavGuardDisabled,u=e.setIsBackArrowClicked,b=t.length>0?Object(K.roundValue)(Tj(t)):0;return Object(y.jsxs)("div",{className:"h-full pb-16","data-testid":"property-create-left-panel-field",children:[Object(y.jsxs)("div",{"data-testid":"property-create-field-card",className:"h-full cursor-default",children:[Object(y.jsxs)("div",{"data-testid":"property-create-field-header",className:"flex mb-2 pb-2",children:[Object(y.jsx)("div",{className:"mt-1 mr-2",children:Object(y.jsx)("button",{type:"button",onClick:function(){d(!0),u(!0)},children:Object(y.jsx)(ui.a,{icon:di.e,size:"lg",style:{visibility:"visible"}})})}),Object(y.jsx)("div",{className:"flex-1 flex-col mx-2",children:Object(y.jsx)("div",{className:"text-3xl font-semibold leading-none",children:"create"===o?"Create New Field":"Edit Field"})})]}),Object(y.jsx)("div",{className:"border-b mb-2 mt-2 -ml-10 -mr-6"}),Object(y.jsx)("div",{"data-testid":"property-create-field-property",className:"mt-12",children:n}),Object(y.jsx)("div",{"data-testid":"property-create-field-name",className:"mt-16",children:Object(y.jsx)(Qi,{control:m.Input,placeholder:"Type the name of your field here",name:"name",label:"Field Name*"})}),Object(y.jsx)("div",{"data-testid":"property-create-field-boundry",className:"mt-16",children:Object(y.jsx)(Qi,{control:m.Input,placeholder:"--",disabled:!0,label:"Boundary Area",name:"boundry",value:b})}),Object(y.jsx)("div",{"data-testid":"property-create-field-reported",className:"mt-16",children:Object(y.jsx)(Qi,{control:m.Input,placeholder:"--",label:"Reported Area",name:"reportedArea"})})]}),Object(y.jsx)("div",{className:"border-b mb-2 mt-2 -ml-10 -mr-6"}),Object(y.jsx)(tG,{saveButtonDisabled:!c,cancelClick:function(){return i()},saveFieldCreateZone:function(){return a()},saveFieldDirectToProperties:function(){return r()},label:o,chkSubmitStatus:s,fieldId:l,setChkNavGuardDisabled:d})]})};nG.defaultProps={features:[],canSave:!1,fieldId:null};var aG=nG,rG=function(e){var t=e.open,n=e.onCancel,r=e.onCreate,c=e.setIsSaving,i=e.isSaving,o=Object(a.useState)(""),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(""),j=Object(b.a)(u,2),p=j[0],f=j[1];Object(a.useEffect)((function(){t||(d(""),f(""))}),[t]);return Object(y.jsx)(ao,{close:n,open:t,title:"Create New Farm",cancelLabel:"Cancel",onCancel:function(){n()},onConfirm:function(){l&&r(l),c(!0)},confirmLabel:"Save",isSaving:i,hasError:"Required"===p||""===l,children:Object(y.jsx)("div",{"data-testid":"create-property-modal-body",className:"my-8",children:Object(y.jsx)(m.Input,{id:"create-property-modal-name",label:"Farm Name*",value:l||"",onChange:function(e){return rB(e,d,f)},error:p,errorMessage:p,autoFocus:!0})})})},cG=function(e){return{key:e.id,value:e.name}},iG="_ADD_",oG=function(e){var t=e.items,n=e.onCreate,r=e.selectedValue,c=e.isDisabled,i=void 0!==c&&c,o=e.fieldsAndAreasGeoJSONCollection,s=Object(a.useContext)(we),l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(!1),f=Object(b.a)(p,2),v=f[0],O=f[1],h=Object(Zi.f)("propertyId"),x=Object(b.a)(h,3)[2].setValue;Object(a.useEffect)((function(){x(r||"")}),[r]);var g,C=function(e){var t;return null===e||void 0===e||null===(t=e.features)||void 0===t?void 0:t.map((function(e){return Object.prototype.hasOwnProperty.call(e.properties,"$layer")?(delete e.properties.$layer,e.properties.$layer="focused"):e.properties.$layer="focused"}))},P=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s.sendEventToAmplitude(s.events.epic.Properties.createProperty),e.next=3,n(t).then((function(e){x(e.id),C(o)}));case 3:e.sent||(j(!1),O(!1));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(y.jsxs)("div",{"data-testid":"property-create-selector",children:[Object(y.jsx)(rG,{open:u,onCancel:function(){return j(!1)},onCreate:P,setIsSaving:O,isSaving:v}),Object(y.jsx)(Qi,{style:{overflow:"hidden"},control:m.Select,name:"propertyId",label:"Farm*",placeholder:"Select a Farm",items:(g=t,[{key:iG,value:"+ Create New Farm"}].concat(g.map(cG))),onSelect:function(e){e.key===iG&&(j(!0),x(""))},disabled:i})]})};oG.defaultProps={selectedValue:null,isDisabled:!1};var sG,lG=oG,dG={GETTING_STARTED:Symbol("getting started"),DRAWING_MODE:Symbol("drawing mode"),FIELD_ACTIVE:Symbol("field active"),CROP_ZONE_ACTIVE:Symbol("crop zone active"),SAVING:Symbol("saving")},uG=Fu.e().shape({name:Fu.f().required("Required"),propertyId:Fu.f().required("Required"),reportedArea:Fu.f()}),bG=function e(){var t=Object(a.useRef)(!1),n=Object(a.useRef)(!1),r=Object(a.useRef)(!1),c=Object(p.h)(),i=Object(p.i)().state,o=iB(),s=o.farms,l=o.createFarm,d=o.loading,u=Object(p.j)(),j=u.fieldId,f=u.action,O="edit"===f,h=Pv(null,!1,O),x=h.fieldGeoJSONCollection,g=h.loading,C=h.zoom,P=h.setZoom,A=h.loadField,S=h.createField,T=h.updateField,N=Object(a.useContext)(ac),E=Object(b.a)(N,2),w=E[0].importedFields,_=E[1],R=Object(a.useState)({name:"",reportedArea:"",propertyId:""}),D=Object(b.a)(R,2),k=D[0],L=D[1],F=Object(a.useState)(x),M=Object(b.a)(F,2),V=M[0],B=M[1],U=Object(a.useState)([]),z=Object(b.a)(U,2),Z=z[0],H=z[1],W=Object(a.useState)(!1),q=Object(b.a)(W,2),J=q[0],Q=q[1],X=Object(a.useState)(j?null:[]),$=Object(b.a)(X,2),ee=$[0],te=$[1],ae=Object(a.useState)(j?"Edit Field":"New Field"),re=Object(b.a)(ae,2)[1],ce=Object(a.useState)(!!j),ie=Object(b.a)(ce,2),oe=ie[0],se=ie[1],le=Object(a.useState)(dG.DRAWING_MODE),de=Object(b.a)(le,2),ue=de[0],be=de[1],je=Object(a.useState)(null),pe=Object(b.a)(je,2),fe=pe[0],me=pe[1],ve=Object(a.useState)(),Oe=Object(b.a)(ve,2),he=Oe[0],xe=Oe[1],ge=Object(a.useState)(),Ce=Object(b.a)(ge,2),ye=Ce[0],Pe=Ce[1],Ae=Object(a.useState)(!1),Se=Object(b.a)(Ae,2),Te=Se[0],Ne=Se[1],Ee=Object(a.useState)(!1),we=Object(b.a)(Ee,2),_e=we[0],Re=we[1],Ie=Object(a.useState)(!1),De=Object(b.a)(Ie,2),ke=De[0],Le=De[1],Fe=Object(a.useState)(!1),Me=Object(b.a)(Fe,2),Ve=Me[0],Be=Me[1];Object(a.useEffect)((function(){O&&j&&!t.current&&A(j)}),[]),Object(a.useEffect)((function(){if(!j){if(!i)return;var e=i.selectedId;e&&L((function(t){return Object(I.a)(Object(I.a)({},t),{},{propertyId:e})}))}}),[]);var Ue=Object(a.useMemo)((function(){return!g&&(j?ke:!V.features.length||(!Object(ne.isEqual)(C,[4])||!!V.features.length))}),[j,ke,C,V.features,g]),ze=Object(a.useMemo)((function(){return _j(void 0,V,!1)}),[V]),Ze=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,o,s;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Object(I.a)({},t),(a=he.map((function(e){return"Polygon"===e.geometry.type?Object(I.a)(Object(I.a)({},e),{},{geometry:{type:"MultiPolygon",coordinates:[e.geometry.coordinates]}}):e}))).length&&(n.coordinates=Oj(a).toString()),n.geometry=Nj(a),n.geometry.coordinates=Object(ne.flatten)(n.geometry.coordinates),n.geometry.coordinates=Ij(n.geometry.coordinates),n.reportedArea=n.reportedArea||0,n.reportedAreaUnit="acre",j&&"FROM_IMPORT_FIELD"!==(null===i||void 0===i?void 0:i.label)){e.next=14;break}return e.next=11,S(n);case 11:return r=e.sent,c=r.data,e.abrupt("return",c);case 14:return e.next=16,T(n,j);case 16:return o=e.sent,s=o.data,e.abrupt("return",s);case 19:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();e.saveProperty=function(){var e=Object(Y.a)(G.a.mark((function e(t,n,a){var r,c,o,s;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return be(dG.SAVING),r=null,c=Cc.properties,e.prev=3,e.next=6,Ze(t);case 6:r=e.sent,n&&(c="".concat(Cc.properties,"/create/").concat(r.id,"/cropzone"),me(c)),oe?("FROM_IMPORT_FIELD"===(null===i||void 0===i?void 0:i.label)&&((s=w.filter((function(e){return e.fieldId!==j}))).length>0?_({type:Rr,payload:!0}):(_({type:Rr,payload:!1}),_({type:Dr,payload:s})),_({type:Ir,payload:s})),me(c)):oe||null!==(o=c)&&void 0!==o&&o.includes("cropzone")||window.location.reload(!1),e.next=16;break;case 11:e.prev=11,e.t0=e.catch(3),Be(!0),a(!1),be(dG.GETTING_STARTED);case 16:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t,n,a){return e.apply(this,arguments)}}();var Ye=Object(a.useCallback)(function(){var t=Object(Y.a)(G.a.mark((function t(n,a){return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a(!0),Q(!1),t.next=4,e.saveProperty(n,null,a);case 4:a(!1);case 5:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),[]),He=Object(a.useCallback)((function(t,a){a(!0),n.current=!0,e.saveProperty(t,!0,a)}),[]),Ge=Object(a.useCallback)((function(e){Q(!1),e(!1)}),[]),We=Object(a.useCallback)((function(t,n){n(!0),se(!1),e.saveProperty(t,!0,n)}),[]),qe=Object(a.useCallback)((function(t,n){n(!0),se(!0),j?e.saveProperty(t,!1,n):Q(!0)}),[]),Je=Object(a.useCallback)((function(e){return l({name:e,timeZone:"US/Central",referencePoint:{type:"Point",coordinates:[0,0]}})}),[l]),Ke=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.properties.farmName,a=s.find((function(e){return e.name===n})),e.prev=2,!n||a){e.next=9;break}return e.next=6,Je(n);case 6:e.t0=e.sent,e.next=10;break;case 9:e.t0=a;case 10:return r=e.t0,L((function(e){return Object(I.a)(Object(I.a)({},e),{},{name:t.properties.fieldName||e.name,propertyId:(null===r||void 0===r?void 0:r.id)||e.propertyId})})),e.abrupt("return",!0);case 15:return e.prev=15,e.t1=e.catch(2),e.abrupt("return",!1);case 18:case"end":return e.stop()}}),e,null,[[2,15]])})));return function(t){return e.apply(this,arguments)}}(),[s,Je]),Qe=Object(a.useCallback)((function(e){var t=e.find((function(e){var t=e.properties;return(null===t||void 0===t?void 0:t.farmName)||(null===t||void 0===t?void 0:t.fieldName)||(null===t||void 0===t?void 0:t.cropZoneName)}));t&&Ke(t);var n=lj(e);H(Object(ne.uniqBy)(n,"id"))}),[Ke]);e.filterFields=function(){var e,t,n,a=[];if("FROM_IMPORT_FIELD"===(null===i||void 0===i?void 0:i.label)){var r,c=i.selectedField;a=lP(c),L({propertyId:null===(r=s.find((function(e){return e.name===(null===c||void 0===c?void 0:c.farm)})))||void 0===r?void 0:r.id,name:null===c||void 0===c?void 0:c.name,reportedArea:""})}else{var o,l,d,u,b,p,f;a=null===x||void 0===x||null===(o=x.features)||void 0===o?void 0:o.find((function(e){return e.properties.id===j})),L({propertyId:null===(l=a)||void 0===l||null===(d=l.properties)||void 0===d?void 0:d.propertyId,name:null===(u=a)||void 0===u||null===(b=u.properties)||void 0===b?void 0:b.name,reportedArea:Object(K.roundValue)(null===(p=a)||void 0===p||null===(f=p.properties)||void 0===f?void 0:f.reportedArea)})}var m=Object(ne.cloneDeep)(a);m.properties.$layer="default",a.properties.$layer="selected",a.id=j,1===a.geometry.coordinates.length&&(a=Ej(a));var v=[m,a],O=_j(void 0,{type:"FeatureCollection",features:v},!1),h=Rj(O);P([h-1]),Pe(null===(e=a)||void 0===e?void 0:e.properties),re(null===(t=a)||void 0===t||null===(n=t.properties)||void 0===n?void 0:n.name),B({type:"FeatureCollection",features:v}),xe([a]),te(j),H(v),Le(!0)},Object(a.useEffect)((function(){j&&!g&&!d&&s.length>0&&(t.current=!0,e.filterFields())}),[j,g,s,d]),Object(a.useEffect)((function(){if(!r.current&&!j){var e=Rj(ze);Number.isNaN(e)||(r.current=!0,P([e-1]))}}),[ze,j]);var Xe=Object(a.useCallback)((function(e){var t=Z.filter((function(t){return e.includes(t.id)})),n=Object(ne.uniqBy)(t,"id");if(xe(n),(null===e||void 0===e||!e.length)&&(null===ee||void 0===ee?void 0:ee.length)>0)te([]);else if(null!==e&&void 0!==e&&e.length){var a=e.filter((function(e){return!ee.includes(e)}));if(null!==a&&void 0!==a&&a.length)te((function(e){return[].concat(Object(v.a)(e),Object(v.a)(a))}));else if(0===(null===a||void 0===a?void 0:a.length)){var r=e.filter((function(e){return ee.includes(e)}));te(Object(v.a)(r))}}}),[Z,ee]),$e=function(){Re(!1),Ne(!1)},et=function(){j?(Ne(!0),c.goBack()):me(Cc.properties)},tt="create"===f;return Object(y.jsxs)(y.Fragment,{children:[fe&&Object(y.jsx)(p.b,{push:!0,to:"".concat(fe)}),Object(y.jsxs)(lo,{disabled:!0,hideCropSeasonDropdown:!tt,children:[Object(y.jsx)(lo.Item,{title:"Property",value:"All Properties",to:Cc.properties}),Object(y.jsx)(lo.Item,{title:"Field",value:j?"Edit Field":"New Field",isLast:!0})]}),Object(y.jsxs)("div",{"data-testid":"property-create-screen",children:[Object(y.jsx)(Zi.e,{initialValues:k,enableReinitialize:!0,onSubmit:function(t){return e.saveProperty(t,!!j)},validationSchema:uG,validateOnChange:!0,validateOnMount:!0,children:function(e){var t=e.values,a=e.setSubmitting,r=e.isValid,c=e.isSubmitting,i=ue!==dG.SAVING&&r&&(null===he||void 0===he?void 0:he.length)>0;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(LY,{open:J,handleCancel:function(){return He(t,a)},handleClose:function(){return Ge(a)},handleConfirm:function(){return Ye(t,a)},children:"Are you sure you want to create just a field and not a crop zone with it?"}),Object(y.jsx)(LY,{open:_e,handleCancel:$e,handleConfirm:function(){return me(Cc.properties)},handleClose:$e,children:"Are you sure you want to leave this page?"}),Object(y.jsx)(Sm,{customText:j?"Are you sure you do not want to create a cropzone also?":null,disabled:Te||n.current,alwaysShow:!!j}),Object(y.jsxs)("div",{className:"bg-white flex w-full h-full",children:[Object(y.jsx)("div",{"data-testid":"property-create-left-panel",className:"flex flex-col w-1/3 h-auto m-4 relative",children:Object(y.jsx)(pu,{className:"flex-1 h-full",children:Object(y.jsx)(aG,{features:he,saveAndCreateCZ:function(){return We(t,a)},saveAndDirectToProperties:function(){return qe(t,a)},canSave:i,cancelBackButton:et,label:f,fieldId:j,setChkNavGuardDisabled:Ne,setIsBackArrowClicked:Re,chkSubmitStatus:c,children:Object(y.jsx)(lG,{onCreate:Je,items:s,isDisabled:!tt,selectedValue:null===ye||void 0===ye?void 0:ye.propertyId,fieldsAndAreasGeoJSONCollection:V})})})}),Object(y.jsx)("div",{"data-testid":"property-create-right-panel",className:"relative w-full",id:"map-wrapper-container",children:Ue?Object(y.jsx)(mm,{shapeIdSelected:ee,geoJSONCollection:V,onFeaturesChange:Qe,onSelectFeatures:Xe,liveUpdate:!1,zoom:C,setZoom:P,isCreate:!j,setNewFieldFeatures:xe}):Object(y.jsx)(m.Spinner,{})})]})]})}}),Ve&&Object(y.jsx)(zU,{state:"error",selectedProperty:{type:null===ye||void 0===ye?void 0:ye.$landType},showEditToast:Ve,setShowEditToast:Be})]})]})},jG=[{id:"properties",key:"properties",path:Cc.properties,exact:!0,secure:!0,disabled:!1,component:fH,icon:$l,nav:"leftNav"},{id:"propertiesCreate",key:"propertiesCreate",path:"".concat(Cc.properties,"/:action(create|edit)/:fieldId?"),exact:!0,secure:!0,disabled:!1,component:bG,minPermissions:{minAllowedRole:$a}},{id:"propertiesCreateCropZone",key:"propertiesCreateCropZone",path:"".concat(Cc.properties,"/:action(create|edit)/:fieldId/cropzone/:cropzoneId?"),exact:!0,secure:!0,disabled:!1,component:qH,minPermissions:{minAllowedRole:$a}}],pG={agrian:"AGRIAN",landdb:"LANDDB"},fG=(sG={},Object(et.a)(sG,pG.landdb,"Cropwise Financials Recommendations"),Object(et.a)(sG,pG.agrian,"Agrian Recommendations"),sG),mG=pG,vG=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].organization,n=dE().companies,r=uE().people,c=hx(),i=c.downloadPDFV2,o=c.downloading,s=c.setDownloading,l=Object(a.useState)(),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(O.usePDF)({document:Object(y.jsx)(za,{rec:u})}),m=Object(b.a)(p,2),h=m[0],x=m[1],g=Object(a.useRef)(void 0),C=Object(f.useFlags)(),P=C.releaseFeAgrianRecommendationIntegration,A=C.releaseFeAgrianRecommendationIntegrationByOrgs,S=yc(P,A,null===t||void 0===t?void 0:t.id);Object(a.useEffect)((function(){u&&x()}),[u]),Object(a.useEffect)((function(){!h.loading&&h.url&&g.current!==h.url&&u&&(g.current=h.url,i(g.current,"Rec - ".concat(u.title,".pdf")),j(null),s(!1))}),[h]);var T=function(e){var t,a;return null!==n&&void 0!==n&&n.length&&e&&null!==(t=null===(a=n.find((function(t){return t.id===e})))||void 0===a?void 0:a.name)&&void 0!==t?t:"--"},N=function(){var e=Object(Y.a)(G.a.mark((function e(n){var a,c,i,o,l,d,u,b,p,f,m,O,h,x,g,C,y,P,A,S,N,E;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s(!0),a=tn.fetch(n),c=a.promise,e.next=4,c.catch((function(){return{}}));case 4:if(i=e.sent,!(o=i.data)){e.next=31;break}return d=[],u=o.cropZones.map(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,i,o;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ca(t.cropZoneIdValue);case 2:return n=e.sent,a=n.cropZone,r=n.field,c=n.farm,i=n.crop,o=n.centroId.geometry,a&&d.push(na(a.geometry)),e.abrupt("return",Object(I.a)(Object(I.a)({},t),{},{farmName:c.name,fieldName:r.name,cropZoneName:a.name,cropName:i.name,latlong:null===o||void 0===o?void 0:o.coordinates}));case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),b=o.recommendationProductEntries.map(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ia(t.id);case 2:return n=e.sent,a=n.masterProduct.registrationnumber,r=n.activeIngredients,e.abrupt("return",Object(I.a)(Object(I.a)({},t),{},{registrationnumber:a?k_(a):"-",activeIngredients:r}));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),p=o.cropSeasonIds.map(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=$t.fetch(t),a=n.promise,e.next=3,a.catch((function(){return{}}));case 3:return r=e.sent,c=r.data,e.abrupt("return",c);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),e.next=13,Promise.allSettled([].concat(Object(v.a)(u),Object(v.a)(b),Object(v.a)(p)));case 13:return f=e.sent,m=u.length,O=b.length,h=m+O,x=f.slice(0,m),g=f.slice(m,h),C=f.slice(h),y=Da(o.cropZones),P=new Date,A=Object(ya.a)(P,"yyyy"),S=Object(ya.a)(P,"MM/dd/yyyy h:mm aaa"),e.next=26,ta(d);case 26:N=e.sent,E=null===(l=o.applicators)||void 0===l?void 0:l.map((function(e){var t=T(e.companyId),n=r.find((function(t){return t.id===e.personId}));return Object(I.a)(Object(I.a)({},e),{},{companyName:t,applicatorLicenseNumber:(null===n||void 0===n?void 0:n.licenseNumber)||"",applicatorLicenseExpirationDate:null!==n&&void 0!==n&&n.expirationDate?fA(n.expirationDate):"",personName:n.name})})),j(Object(I.a)(Object(I.a)({},o),{},{applicators:E||[],cropZones:(_=x.filter((function(e){return"fulfilled"===e.status})).map((function(e){return e.value})),_.map((function(e){return[Ia(e.farmName,{width:"".concat(La,"%")}),Ia(e.fieldName,{width:"".concat(La,"%")}),Ia(e.cropZoneName,{width:"".concat(La,"%")}),Ia(e.cropName,{width:"".concat(La,"%")}),Ia("".concat(e.latlong[1],", ").concat(e.latlong[0]),{width:"".concat(19,"%")}),Ia(ee(e.areaValue,"fixed"),{width:"".concat(9,"%")})]}))),organizationName:t.name,cropSeasons:C.filter((function(e){return"fulfilled"===e.status})).map((function(e){return e.value.name})),recommendationProductEntries:(w=g.filter((function(e){return"fulfilled"===e.status})).map((function(e){return e.value})),w.map((function(e){return[Ia(e.productName,{width:"".concat(19,"%")}),Ia("".concat(ee(e.productAppliedAreaValue,"fixed")," ").concat(Object(va.g)(e.areaUnit)),{width:"".concat(14,"%")}),Ia(ee(e.coveragePercent,"percent"),{width:"".concat(11,"%")}),Ia(e.registrationnumber,{width:"".concat(13,"%")}),Ia("-",{width:"".concat(8,"%")}),Ia("-",{width:"".concat(8,"%")}),Ia("".concat(ee(e.productRatePerAreaValue,"fixed")," ").concat(Object(va.g)(e.productRatePerAreaUnit)," / ac"),{width:"".concat(15,"%")}),Ia("".concat(ee(e.totalProductValue,"fixed")," ").concat(Object(va.g)(e.totalProductUnit)),{width:"".concat(12,"%")})]}))),totalFieldsArea:y,year:A,fullDate:S,mapImage:N})),e.next=32;break;case 31:s(!1);case 32:case"end":return e.stop()}var w,_}),e)})));return function(t){return e.apply(this,arguments)}}();return{downloadingPDF:o,shareOrPrint:N,filterMenuItems:function(e){return S?e:Jo(e,"convertTask")}}};function OG(e){var t,n=e.recommendation,a=e.cropSeasons,r=e.tags,c=e.onAction,i=e.runningProcesses,o=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,a=e.reduce((function(e,n){var a=t.find((function(e){return e.id===n}));return a?e.concat([a]):e}),[]),r=a.slice(0,n);return a.length>n&&r.push({id:"additional-tag",name:"+".concat(a.length-n)}),r}(null!==(t=n.flagIds)&&void 0!==t?t:[],r);null!==n&&void 0!==n&&n.taskCreated&&o.unshift({id:"task-created",name:"Task Created",color:"#73DB78"});var s=vG().filterMenuItems;return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex flex-col items-start ",children:[Object(y.jsx)("span",{className:"text-sm font-bold",children:Object(y.jsx)(j.b,{to:"".concat(Cc.recommendations,"/").concat(n.id,"/view"),children:n.title})}),o.length>0&&Object(y.jsx)(m.TagCloud,{children:o.map((function(e){return Object(y.jsx)(m.Tag,{color:e.color,children:e.name},e.id)}))})]})}),Object(y.jsx)(m.Table.Cell,{children:n.cropZones.length}),Object(y.jsx)(m.Table.Cell,{children:n.cropZones.reduce((function(e,t){return e+(null===t||void 0===t?void 0:t.areaValue)}),0).toFixed(2)}),Object(y.jsx)(m.Table.Cell,{children:n.recommendationProductEntries.length}),Object(y.jsx)(m.Table.Cell,{children:PH(n)}),Object(y.jsx)(m.Table.Cell,{children:yH({seasons:a,seasonIds:n.cropSeasonIds})}),Object(y.jsx)(m.Table.Cell,{children:n.type===mG.agrian?Object(y.jsxs)("div",{className:"flex flex-col justify-center items-start",children:[Object(y.jsx)("span",{children:fG[mG.agrian]}),Object(y.jsx)("span",{className:"text-chili-red",children:"Unresolved"})]}):null}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{"data-testid":"recommendation-table-options-menu",className:"absolute right-0 flex-none w-10 mr-2",children:i?Object(y.jsx)(m.Spinner,{size:"sm"}):Object(y.jsx)(Wo,{onAction:function(e){return c(e)},options:s(us)})})})]})}OG.defaultProps={runningProcesses:!1};var hG=OG,xG=[{field:"name",title:"Recommendation",sortable:!0},{field:"fields",title:"Fields",sortable:!0},{field:"totalAcres",title:"Total Acres",sortable:!0},{field:"products",title:"Products",sortable:!0},{field:"validFrom",title:"Valid From",sortable:!0},{field:"seasons",title:"Seasons",sortable:!0},{field:"type",title:"",sortable:!1},{field:"unknown",title:"",sortable:!1}];function gG(e){var t=e.recommendations,n=e.tags,r=e.pageNo,c=e.setPageNo,i=e.totalRecommendations,o=e.onAction,s=e.downloadingPDF,l=e.cropSeasons,d=Object(a.useState)(),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(),m=Object(b.a)(f,2),v=m[0],O=m[1],h=Object(a.useState)(t),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useState)(-1),A=Object(b.a)(P,2),S=A[0],T=A[1];return Object(y.jsx)("div",{className:"mx-2 my-4 min-w-content","data-testid":"recommendations-table",style:{minWidth:"min-content"},children:Object(y.jsxs)(ll,{children:[Ho(i,r,c),Object(y.jsx)(ol,{listType:"Recommendations",routePath:"/app/recommendation",items:g,tableColumns:xG,onSort:function(e,t){p(e),O(t),C(function(e,t,n){if(!n)return e;var a=Object(ne.cloneDeep)(e);switch(t){case"name":return Object(ne.orderBy)(a,[function(e){var t;return null===e||void 0===e||null===(t=e.title)||void 0===t?void 0:t.toLowerCase()}],n);case"fields":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.cropZones.length}],n);case"totalAcres":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.cropZones.reduce((function(e,t){return e+(null===t||void 0===t?void 0:t.areaValue)}),0)}],n);case"products":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.recommendationProductEntries.length}],n);case"validFrom":return Object(ne.orderBy)(a,[function(e){return new Date(null===e||void 0===e?void 0:e.proposedDateEpoch)}],n);case"seasons":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.cropSeasonIds.length}],n);default:return a}}(g,e,t))},sortBy:j,sortDir:v,children:function(e){return e.rows.map((function(e,t){return Object(y.jsx)(hG,{recommendation:e,cropSeasons:null!==l&&void 0!==l?l:[],tags:n,onAction:function(n){T(t),o(n,e)},runningProcesses:s&&S===t},e.id)}))}}),Object(y.jsx)("div",{style:{minHeight:"35px"},children:Ho(i,r,c)})]})})}gG.defaultProps={recommendations:[],downloadingPDF:!1};var CG=gG;var yG={groupRecommendationsByType:function(e){var t,n=(t={},Object(et.a)(t,mG.landdb,{id:mG.landdb,title:fG[mG.landdb],recommendations:[],showStatus:!1}),Object(et.a)(t,mG.agrian,{id:mG.agrian,title:fG[mG.agrian],recommendations:[],showStatus:!0}),t);return e.forEach((function(e){var t;null===(t=n[e.type])||void 0===t||t.recommendations.push(e)})),n}},PG=function(e){var t=e.recommendations,n=e.tags,r=e.pageNo,c=e.setPageNo,i=e.totalRecommendations,o=e.onAction,s=e.downloadingPDF,l=e.cropSeasons,d=yG.groupRecommendationsByType(t),u=vG().filterMenuItems,j=Object(a.useState)(-1),p=Object(b.a)(j,2),f=p[0],v=p[1],O=Object(a.useState)(-1),h=Object(b.a)(O,2),x=h[0],g=h[1];return Object(y.jsx)("div",{"data-testid":"recommendations-board",children:Object(y.jsxs)(ll,{children:[Ho(i,r,c),Object.values(d).map((function(e,t){return e.recommendations.length>0?Object(y.jsx)(Xd,{title:e.title,totalItems:e.recommendations.length,textId:"recommendations",children:e.recommendations.map((function(e,a){var r,c=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,a=e.reduce((function(e,n){var a=t.find((function(e){return e.id===n}));return a?e.concat([a]):e}),[]),r=a.slice(0,n);return a.length>n&&r.push({id:"additional-tag",name:"+".concat(a.length-n)}),r}(null!==(r=e.flagIds)&&void 0!==r?r:[],n);return null!==e&&void 0!==e&&e.taskCreated&&c.unshift({id:"task-created",name:"Task Created",color:"#73DB78"}),Object(y.jsxs)(lu,{testId:"recommendation",title:e.title,subtitle:PH(e),linkTo:"".concat(Cc.recommendations,"/").concat(e.id,"/view"),onAction:function(n){v(t),g(a),o(n,e)},menuItems:u(us),runningProcesses:s&&f===t&&x===a,children:[c.length>0&&Object(y.jsx)(m.TagCloud,{children:c.map((function(e){return Object(y.jsx)(m.Tag,{color:e.color,children:e.name},e.id)}))}),Object(y.jsxs)("div",{className:"flex flex-wrap w-full",children:[Object(y.jsx)(uu,{id:"field-count",title:"Field Count",value:e.cropZones.length,testId:"recommendation-field-count"}),Object(y.jsx)(uu,{id:"total-acres",title:"Total Acres",value:e.cropZones.reduce((function(e,t){return e+t.areaValue}),0).toFixed(2),testId:"recommendation-total-acres"}),Object(y.jsx)(uu,{id:"product-count",title:"Product Count",value:e.recommendationProductEntries.length,testId:"recommendation-product-count"}),Object(y.jsx)(uu,{id:"seasons",title:"Seasons",value:yH({seasons:l,seasonIds:e.cropSeasonIds}),testId:"recommendation-seasons"})]})]},e.id)}))},e.id):null})),Object(y.jsx)("div",{style:{minHeight:"35px"},children:Ho(i,r,c)})]})})};PG.defaultProps={downloadingPDF:!1};var AG=PG,SG={key:"recommendationType",value:"Recommendation Type",nestedItems:[{key:mG.landdb,value:fG[mG.landdb],property:"type"},{key:mG.agrian,value:fG[mG.agrian],property:"type"}]},TG={key:"seasons",value:"Seasons"},NG={key:"source",value:"Used as a source record",nestedItems:[{key:"Not used",value:"Not used",property:"source"},{key:"Used in task",value:"Used in task",property:"source"},{key:"Used in recommendation",value:"Used in recommendation",property:"source"},{key:"Unknown",value:"Unknown",property:"source"}]};var EG=function(e){var t=Object(a.useState)([SG,TG,NG]),n=Object(b.a)(t,2),r=n[0],c=n[1];return Object(a.useEffect)((function(){if(e&&0!==e.length){var t=Object(I.a)(Object(I.a)({},TG),{},{nestedItems:(null!==e&&void 0!==e?e:[]).map((function(e){return{key:e.id,value:e.name,property:"cropSeasonIds"}}))});c([SG,t,NG])}}),[e]),r},wG=Sd(md,"tile"),_G=function(){var e=AH(),t=e.isLoading,n=e.recommendations,r=e.recommendationsCount,c=e.page,i=e.goToPage,o=e.filterByDateRange,s=e.filterByTitleQuery,l=e.reload,d=e.convertToTask,u=wG.get(),j=Object(a.useState)(null),f=Object(b.a)(j,2),O=f[0],h=f[1],x=zi(O,300),g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(u),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(p.h)(),_=WF(),R=_.tags,D=_.loading,k=_.getTags,L=Object(a.useState)(!1),F=Object(b.a)(L,2),M=F[0],V=F[1],B=Object(a.useState)([]),U=Object(b.a)(B,2),z=U[0],Z=U[1],H=Object(a.useState)(!1),W=Object(b.a)(H,2),q=W[0],J=W[1],K=Object(a.useState)({open:!1,id:null}),Q=Object(b.a)(K,2),X=Q[0],$=Q[1],ee=Object(a.useContext)(ac),te=Object(b.a)(ee,2),ae=te[0],re=ae.loggedInUserOrgPermission,ce=ae.loadingOrg,ie=ae.isGlobalCropSeasonLoading,oe=te[1],se=Object(a.useState)(),le=Object(b.a)(se,2),de=le[0],ue=le[1],be=dd().cropSeasons,je=EG(be),pe=Object(a.useContext)(we),fe=Object(a.useState)(null),me=Object(b.a)(fe,2)[1],ve=Object(a.useState)(""),Oe=Object(b.a)(ve,2),he=Oe[0],xe=Oe[1],ge=Object(a.useState)(),Ce=Object(b.a)(ge,2),ye=Ce[0],Pe=Ce[1],Se=vG(),Te=Se.shareOrPrint,Ne=Se.downloadingPDF,Ee=function(){l(),k()},_e=function(e,t){var n,a=(null===(n=t.flagIds)||void 0===n?void 0:n.length)>0&&void 0!==t.flagIds&&t.flagIds.map((function(e){return R.find((function(t){return t.id===e}))})),r={view:function(){w.push({pathname:"".concat(Cc.recommendations,"/").concat(t.id,"/view")})},edit:function(){w.push({pathname:"".concat(Cc.recommendations,"/").concat(t.id)})},tag:function(){var e;xe(t.title),Pe(t.id),Z((null===(e=t.flagIds)||void 0===e?void 0:e.length)>0||void 0!==t.flagIds?a:[]),V(!0)},convertTask:function(){pe.sendEventToAmplitude(pe.events.epic.Tasks.saveTaskFromRec),d(t)},duplicate:function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,oe({type:"SET_CONVERT_PLAN",payload:{id:t.id}});case 2:w.push("".concat(Cc.recommendations,"/duplicate"));case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),shareOrPrint:Te,delete:function(){$({id:t.id,open:!0})}};r[e](t.id)},Re=function(){var e=Object(Y.a)(G.a.mark((function e(t){var a,r,c,i;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return J(!0),a=n.find((function(e){return e.id===ye})),r=Object(I.a)(Object(I.a)({},a),{},{flagIds:t.map((function(e){return e.id}))}),e.next=5,tn.update(ye,r);case 5:return c=e.sent,i=c.promise,e.next=9,i.then((function(e){var a=n.map((function(t){return t.id===e.data.id?e.data:t}));l(a),Z(t),k(),J(!1)})).catch(Ae.default).catch((function(e){var t,n,a,r;null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.validationErrors?me("Error saving task: ".concat(e.response.data.message)):null!==(a=e.response)&&void 0!==a&&null!==(r=a.data)&&void 0!==r&&r.displayErrorMessage?me(e.response.data.displayErrorMessage):uc(oe)(e)}));case 9:J(!1);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ie=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return pe.sendEventToAmplitude(pe.events.epic.Recommendations.deleteRecommendations),t=tn.delete(X.id),n=t.promise,e.next=4,n.then((function(){w.go(Cc.recommendations)}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();Object(a.useEffect)((function(){s(x)}),[x,s]),Object(a.useEffect)((function(){"View Only"===(null===re||void 0===re?void 0:re.role)||"Full control"===(null===re||void 0===re?void 0:re.role)&&!Object.prototype.hasOwnProperty.call(re,"financialAccess")?ue("none"):ue(null===re||void 0===re?void 0:re.financialAccess)}),[re]),Object(a.useEffect)((function(){Object(ne.isEmpty)(re)?A(!1):A(!0)}),[re]);var De=Object(a.useCallback)((function(){return"View Only"!==(null===re||void 0===re?void 0:re.role)||"READ"!==de&&"none"!==de}),[re.role,de]);return Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"recommendations",children:[Object(y.jsx)(lo,{hideCropSeasonDropdown:!1,onCropSeasonSelect:Ee,onOrganizationSelect:Ee,children:Object(y.jsx)(lo.Item,{title:"Recommendations",value:"All Recommendations",isLast:!0})}),Object(y.jsxs)("div",{className:"flex items-center justify-between",children:[Object(y.jsx)(To,{id:"recommendations-search-input",name:"search_recommendations",placeholder:"Search recommendations",filterItems:je,selectedItems:[],searchText:O,onChange:function(e){h(e.target.value)},onFilterChange:ne.noop,onChangeLabel:ne.noop,onChangeProductType:ne.noop,onChangeTaskType:ne.noop,onDateRangeChange:function(e){o(Object(v.a)(e.target.value))},showCropSeason:!1}),Object(y.jsx)("div",{className:"flex items-center",children:Object(y.jsx)(Rd,{changeView:function(e){E(e),wG.save(e)},onChangeProductType:ne.noop,onChangeTaskType:ne.noop,onFilterChange:ne.noop,testId:"recommendations-view-toggle",view:N})}),Object(y.jsx)("div",{className:"pl-2 whitespace-no-wrap",children:De()&&Object(y.jsx)(m.Button,{id:"add-plan-button",type:"primary",onClick:function(e){e.stopPropagation(),w.push("".concat(Cc.recommendations,"/create"))},icon:Object(y.jsx)(Eo.a,{}),children:"Create Rec."})})]}),t||D||ce||!P||q||ie?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(y.Fragment,{children:n&&n.length?Object(y.jsxs)("div",{children:[Object(y.jsx)(ib,{open:X.open,itemType:"Recommendation",onCancel:function(){return $({open:!1,id:null})},onDelete:Ie}),Object(y.jsx)(l_,{open:M,close:function(){V(!1)},name:he,selectedTags:z.length>0?null===z||void 0===z?void 0:z.reduce((function(e,t){return"".concat(e,",").concat(t.id)}),""):"",returnSelectedTags:function(e){Re(e)}}),"tile"===N?Object(y.jsx)(AG,{recommendations:n,tags:R,pageNo:c,setPageNo:i,totalRecommendations:r,onAction:_e,memberFinancialAccess:de,downloadingPDF:Ne,cropSeasons:be}):Object(y.jsx)(CG,{recommendations:Object(ne.orderBy)(n,"title","asc"),tags:R,pageNo:c,setPageNo:i,totalRecommendations:r,onAction:_e,downloadingPDF:Ne,cropSeasons:be})]}):Object(y.jsx)(Vd,{buttonText:"Create Recommendation",onClick:function(){return w.push("".concat(Cc.recommendations,"/create"))},subtitle:"We were unable to find any Recommendations under this organization.",setPermission:De})})]})},RG=function(){var e=Object(a.useContext)(we),t=void 0,n=Object(a.useContext)(ac),r=Object(b.a)(n,2)[1],c=Object(a.useState)([]),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(0),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(!0),f=Object(b.a)(p,2),m=f[0],v=f[1],O=Object(a.useState)({}),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.page,a=void 0===n?0:n,c=e.searchText,i=void 0===c?"":c,o=e.daterange,l=void 0===o?null:o;v(!0);var d=H_(l),u=d.since,b=d.until,p=JSON.parse(localStorage.getItem("selectedCropSeasons")),f=[];Array.isArray(p)?f=p:f.push(p);var m=xn.createChildApi({action:"tasks/landing"}),O=m.fetch(t,{pageNo:a,size:wo,seasonIdsCommaSeparated:f.join(","),searchText:i,since:u,until:b}),h=O.promise;h.then((function(e){var t=e.data;t.results&&(s(t.results),j(t.totalElements)),v(!1)})).catch(Ae.default).catch((function(e){uc(r)(e),v(!1)}))}),[t,r]),y=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,gn.fetch(t);case 3:return n=e.sent,a=n.promise,e.next=7,a;case 7:return c=e.sent,e.abrupt("return",(null===c||void 0===c?void 0:c.data)||[]);case 11:return e.prev=11,e.t0=e.catch(0),uc(r)(e.t0),e.abrupt("return",[]);case 15:case"end":return e.stop()}}),e,null,[[0,11]])})));return function(t){return e.apply(this,arguments)}}(),P=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,r,c,i,l;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return g({updating:!0,taskId:t}),a={taskId:t,status:n},r={},r=Object(ne.cloneDeep)(o),c=Object(ne.findIndex)(r,{id:t}),r[c].status=n,s(r),e.next=9,gn.update("status",a);case 9:return i=e.sent,l=i.promise,e.next=13,l;case 13:200!==e.sent.status&&C(),g({updating:!1,taskId:t});case 16:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),A=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return g({updating:!0,taskId:t}),a=(a=Object(ne.cloneDeep)(o)).map((function(e){return e.id===n.id?n:e})),s(a),r={id:n.id,status:n.status},e.next=7,gn.update(null,r);case 7:g({updating:!1,taskId:t});case 8:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),S=function(){var t=Object(Y.a)(G.a.mark((function t(n){var a,r,c,i;return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=gn.delete(n),r=a.promise,t.next=3,r;case 3:c=t.sent,i=o.filter((function(e){var t=e.id;return n!==t})),s(i),j(i.length),200!==c.status&&C(),200===c.status&&e.sendEventToAmplitude(e.events.epic.Tasks.deleteTaskSuccess);case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return Object(a.useEffect)((function(){C()}),[C]),{updateTask:A,deleteTask:S,updateTaskStatus:P,tasks:o,loading:m,loadLandingPageTasks:C,updating:x,totalTasks:u,getTaskById:y}},IG=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2)[1],n=Object(a.useState)([]),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(0),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(!0),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(n){var a,r,c,o;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),a=JSON.parse(localStorage.getItem("selectedCropSeasons")),r=Tn.createChildApi({action:"invoice/summaries"}),c=r.fetch("",{pageNo:n||0,size:wo,seasonIdsCommaSeparated:a.join(",")}),o=c.promise,e.next=6,o.then((function(e){var t=e.data;t.results&&(i(Object(ne.orderBy)(t.results,[function(e){return e.title.toLowerCase()}],"asc")),d(t.totalElements),f(!1))})).catch(Ae.default).catch((function(e){uc(t)(e),f(!1)}));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[t]),v=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(n){var a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),a=Tn.createChildApi({action:"invoice/summaries"}),r=a.fetch("",{seasonIdsCommaSeparated:n}),c=r.promise,e.next=5,c.then((function(e){var t=e.data;t.results&&i(t.results)})).catch(Ae.default).catch((function(e){uc(t)(e)})).finally((function(){f(!1)}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[t]);return Object(a.useEffect)((function(){m()}),[m]),{invoices:c,loading:p,setLoading:f,loadLandingPageInvoiceSummaries:m,totalInvoices:l,getReportInvoices:v}},DG=function(){var e=function(){var e=Fk();return{plans:e.plans,plansLoading:e.isLoading}}(),t=e.plans,n=e.plansLoading,a=function(){var e=RG();return{tasks:e.tasks,taskLoading:e.loading}}(),r=a.tasks,c=a.taskLoading,i=function(){var e=IG();return{invoices:e.invoices,invLoading:e.loading}}(),o=i.invoices,s=i.invLoading,l=function(){var e=AH();return{recommendations:e.recommendations,recsLoading:e.isLoading}}(),d=l.recommendations,u=l.recsLoading;return{plans:t,tasks:r,invoices:o,recommendations:d,isLoading:n||c||s||u}},kG=n(2830),LG=function(e){var t=e.document,n=e.isAdded,a=e.documentClick,r=e.addRemoveDoc,c=e.clickedId,i=t.id===c?"bg-blue-200":"";return Object(y.jsxs)("div",{className:"border p-4 ".concat(i),"data-testid":"source-document-card",children:[Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsx)(pu,{onClick:function(){return a()},className:"text-base font-bold w-full",children:t.name}),Object(y.jsx)("div",{className:"ml-1","data-testid":"add-remove-source-button",children:Object(y.jsx)(m.Button,{style:n?{backgroundColor:"#CF3537"}:{backgroundColor:"#009933"},id:"document-add-button",type:"overlay",circular:!0,size:"sm",onClick:function(){return r(t.id,t.name)},icon:n?Object(y.jsx)(kG.a,{style:{fontSize:16,color:"white"}}):Object(y.jsx)(kB.a,{style:{fontSize:16,color:"white"}})})})]}),Object(y.jsxs)(pu,{onClick:function(){return a()},children:[Object(y.jsx)("div",{className:"text-sm",children:new Date(t.docDate).toLocaleDateString()}),Object(y.jsx)("div",{children:t.numOfFields>=0&&Object(y.jsx)("span",{className:"text-sm",children:"".concat(t.numOfFields," fields")})}),Object(y.jsxs)("div",{className:"text-sm",children:[t.productCount," products"]}),Object(y.jsx)("div",{className:"text-sm",children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:t.amount})})]})]})};LG.defaultProps={isAdded:!1,documentClick:function(){},addRemoveDoc:function(){},clickedId:null};var FG=LG,MG=function(e){var t=e.property,n=e.coveragePercent,r=rv({fetchType:gm,cropSeasonsId:null===t||void 0===t?void 0:t.cropSeasonId}),c=r.fieldsAndAreasGeoJSONCollection,i=r.fieldsLoading,o=r.reloadData;Object(a.useEffect)((function(){o()}),[]);var s=Object(a.useState)(),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(),p=Object(b.a)(j,2),f=p[0],v=p[1],O=Object(a.useState)(),h=Object(b.a)(O,2),x=(h[0],h[1]),g=Ov(d).cropZone,C=Pv(f).field;return Object(a.useEffect)((function(){u(null===t||void 0===t?void 0:t.cropZoneIdValue)}),[t]),Object(a.useEffect)((function(){C||v(null===g||void 0===g?void 0:g.fieldId)}),[C,g]),C&&g&&!i?Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(Kp,{id:"view-plan-card-icon",features:function(){if(c.features.length>0){var e=[];return c.features.forEach((function(n){t.cropZoneIdValue===n.properties.id&&e.push(Ej(n))})),e}return""}()})}),Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsxs)("div",{className:"flex flex-col justify-start leading-5 text-left",children:[Object(y.jsx)("span",{className:"font-bold text-neutral-1000",children:null===C||void 0===C?void 0:C.name}),Object(y.jsx)("span",{style:{color:"#707374"},children:null===g||void 0===g?void 0:g.name})]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(QF,{cropId:g.cropId,setCrop:x})}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:null===t||void 0===t?void 0:t.areaValue})," ac"]}),Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsxs)("div",{className:"mr-6",children:[100*n||""," %"]})})]},null===t||void 0===t?void 0:t.cropZoneIdValue)}):Object(y.jsx)(m.Spinner,{})};MG.defaultProps={coveragePercent:""};var VG=MG,BG=function(e){var t=e.cropZones,n=e.coveragePercent,a=function(){},r={};return Object(y.jsx)(y.Fragment,{children:t?Object(y.jsx)("div",{className:"flex-grow",children:Object(y.jsx)("div",{className:"flex flex-col h-full justify-end",children:Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{}),Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Fields (".concat(null===t||void 0===t?void 0:t.length,")")}),Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Crops"}),Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Area"}),Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Coverage %"})]}),t.map((function(e){return Object(y.jsx)(VG,{property:e,coveragePercent:n})}))]})})}):Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Fields (0)"}),Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Crops"}),Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Area"}),Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Coverage %"})]}),Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsx)("div",{className:"flex flex-col justify-start leading-5 text-left",children:Object(y.jsx)("span",{className:"font-bold text-neutral-1000",children:"No Properties Selected"})})}),Object(y.jsx)(m.Table.Cell,{}),Object(y.jsx)(m.Table.Cell,{}),Object(y.jsx)(m.Table.Cell,{})]})]})})})};BG.defaultProps={cropZones:[],coveragePercent:""};var UG=BG,zG=function(e){var t=e.products,n=e.displayFinancials,a=function(){},r={};return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Products (".concat(t.length,")")}),Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Rate/Area"}),Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Applied Area"}),Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Applied Area %"}),Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Total Product"}),Object(y.jsx)(m.Table.Cell,{sort:r,onClick:a,children:"Total Cost"})]}),t.map((function(e){return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"text-left",children:[Object(y.jsx)("div",{className:"font-bold",children:(null===e||void 0===e?void 0:e.productName)||"No Products Selected"}),Object(y.jsx)("div",{className:"mt-2 text-neutral-300",children:(null===e||void 0===e?void 0:e.manufacturerName)||"--"})]})}),Object(y.jsxs)(m.Table.Cell,{children:[null===e||void 0===e?void 0:e.productRateValue," ",null===e||void 0===e?void 0:e.productRateUnit]}),Object(y.jsxs)(m.Table.Cell,{children:[(null===e||void 0===e?void 0:e.areaValue)||"0"," ac"]}),Object(y.jsxs)(m.Table.Cell,{children:[100*(null===e||void 0===e?void 0:e.coveragePercent),"%"]}),Object(y.jsxs)(m.Table.Cell,{children:[fL(null===e||void 0===e?void 0:e.productRateValue,null===e||void 0===e?void 0:e.areaValue,e)," ",null!==e&&void 0!==e&&e.totalProductUnit?"".concat(null===e||void 0===e?void 0:e.totalProductUnit,"s"):""]}),Object(y.jsx)(m.Table.Cell,{children:n&&null!==e&&void 0!==e&&e.totalProductCost?Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:"2",children:null===e||void 0===e?void 0:e.totalProductCost}):""})]})}))]})})},ZG=function(e){var t,n=e.id,r=Object(a.useContext)(ac),c=Object(b.a)(r,1)[0].loggedInUserOrgPermission,i=GF(n),o=i.plan,s=i.loading,l=Object(a.useState)(),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(null),f=Object(b.a)(p,2),v=f[0],O=f[1],h=Object(a.useState)([]),x=Object(b.a)(h,2),g=x[0],C=(x[1],WF().tags),P=Object(a.useState)(g||[]),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)({extraTagsCount:0,extraTagsNames:[],tagsToDisplay:[]}),E=Object(b.a)(N,2),w=E[0],_=E[1];Object(a.useEffect)((function(){var e;if((null===C||void 0===C?void 0:C.length)>0&&(null===o||void 0===o||null===(e=o.flagIds)||void 0===e?void 0:e.length)>0){var t=null===C||void 0===C?void 0:C.filter((function(e){var t;return null===o||void 0===o||null===(t=o.flagIds)||void 0===t?void 0:t.find((function(t){return e.id===t}))}));T(t)}else T(g||[])}),[C,o.flagIds]),Object(a.useEffect)((function(){T(g||[])}),[g]),Object(a.useEffect)((function(){_(Af(S,30))}),[S]);var R=function(){return or(c,{minAllowedRole:"View Only",minFinancialAccess:"READ"})};return Object(y.jsx)(y.Fragment,{children:s?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{children:[Object(y.jsx)(pM,{open:"product"===v,product:u,handleClose:function(){O(null)},displayFinancial:R()}),Object(y.jsxs)("div",{className:"border rounded overscroll-y-contain p-4","data-testid":"source-document-plan-view",children:[Object(y.jsx)("div",{className:"flex py-5",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold",children:"Plan Details"})})}),Object(y.jsx)($F,{plan:o,displayTagsObject:w}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]})}),Object(y.jsx)("div",{className:"py-5",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold",children:"Fixed Cost"})})}),Object(y.jsx)(tM,{plan:o,displayFinancials:R()}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]})}),Object(y.jsx)("div",{className:"py-5",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold",children:"Projected Revenue"})})}),Object(y.jsx)(aM,{plan:o,displayFinancials:R()}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]})}),Object(y.jsx)("div",{className:"py-5",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsxs)(m.Column,{width:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold",children:"Properties"}),Object(y.jsx)("br",{})]})}),Object(y.jsx)(UG,{cropZones:o.cropZones,coveragePercent:null===o||void 0===o||null===(t=o.planProductEntries[0])||void 0===t?void 0:t.coveragePercent}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]})}),Object(y.jsx)("div",{className:"py-5",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsxs)(m.Column,{width:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold",children:"Products & Services"}),Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-sm",children:"By Rate Application"}),Object(y.jsx)("br",{})]})}),Object(y.jsx)(zG,{products:o.planProductEntries,handleProductModal:function(e){j(e),O("product")},displayFinancials:R()}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]})}),Object(y.jsx)("div",{className:"py-5",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsxs)(m.Column,{width:"w-full",children:[Object(y.jsx)("div",{"data-testid":"more-info-title",className:"text-2xl font-bold",children:"Notes"}),Object(y.jsx)("br",{})]})}),Object(y.jsx)(m.TextArea,{"data-testid":"plan-notes",className:"h-64 overscroll-auto",resizeDisabled:!0,disabled:!0,value:o.notes}),Object(y.jsx)("div",{className:"w-full border-b py-5"})]})})]})]})})},YG=function(e){var t=e.windSpeed,n=e.windDirection,a=e.speedUnit;return Object(y.jsxs)("div",{className:"mt-4 flex justify-center relative",children:[Object(y.jsxs)("svg",{width:"256",height:"256",viewBox:"0 0 256 256",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:"rotate(".concat(n,"deg)")},className:"absolute",children:[Object(y.jsx)("g",{clipPath:"url(#clipA)",children:Object(y.jsx)("g",{clipPath:"url(#clipB)",children:Object(y.jsx)("path",{d:"M127.5 39.9999L128.5 39.9999L138 63.9999H118L122.75 51.9999L127.5 39.9999Z",fill:"#0080FF"})})}),Object(y.jsxs)("defs",{children:[Object(y.jsx)("clipPath",{id:"clipA",children:Object(y.jsx)("rect",{width:"256",height:"256",fill:"none"})}),Object(y.jsx)("clipPath",{id:"clipB",children:Object(y.jsx)("rect",{width:"24",height:"24",fill:"white",transform:"translate(116 39.9999)"})})]})]}),Object(y.jsxs)("svg",{width:"256",height:"256",viewBox:"0 0 256 256",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M126.5 130.598C127.935 131.426 129.77 130.935 130.598 129.5C131.427 128.065 130.935 126.23 129.5 125.402C128.065 124.573 126.23 125.065 125.402 126.5C124.574 127.935 125.065 129.77 126.5 130.598ZM126 131.464C127.913 132.569 130.36 131.913 131.464 130C132.569 128.087 131.913 125.64 130 124.536C128.087 123.431 125.64 124.087 124.536 126C123.431 127.913 124.087 130.36 126 131.464Z",fill:"#999999"}),Object(y.jsx)("circle",{cx:"128",cy:"128",r:"56.5",stroke:"white",strokeWidth:"7"}),Object(y.jsx)("circle",{cx:"128",cy:"128",r:"59.5",stroke:"#E5E5E5"}),Object(y.jsxs)("g",{clipPath:"url(#clip0)",children:[Object(y.jsx)("path",{d:"M128 128V216",stroke:"#E5E5E5"}),Object(y.jsx)("path",{d:"M128 40V128",stroke:"#E5E5E5"}),Object(y.jsx)("path",{d:"M128 128L40 128",stroke:"#E5E5E5"}),Object(y.jsx)("path",{d:"M216 128L128 128",stroke:"#E5E5E5"}),Object(y.jsx)("circle",{cx:"128",cy:"128",r:"96",stroke:"white",strokeWidth:"16"}),Object(y.jsx)("circle",{cx:"128",cy:"128",r:"88.5",stroke:"#E5E5E5"}),Object(y.jsx)("circle",{cx:"128",cy:"128",r:"104.5",stroke:"#E5E5E5"}),Object(y.jsxs)("g",{clipPath:"url(#clip1)",children:[Object(y.jsx)("path",{d:"M128 24L128 32",stroke:"#999999"}),Object(y.jsx)("path",{d:"M128 224L128 232",stroke:"#999999"}),Object(y.jsx)("path",{d:"M24 128L32 128",stroke:"#999999"}),Object(y.jsx)("path",{d:"M224 128L232 128",stroke:"#999999"}),Object(y.jsxs)("g",{clipPath:"url(#clip2)",children:[Object(y.jsx)("path",{d:"M118.936 24.3958L119.633 32.3653",stroke:"#999999"}),Object(y.jsx)("path",{d:"M136.367 223.635L137.064 231.604",stroke:"#999999"}),Object(y.jsx)("path",{d:"M24.3957 137.064L32.3653 136.367",stroke:"#999999"}),Object(y.jsx)("path",{d:"M223.635 119.633L231.604 118.936",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip3)",children:[Object(y.jsx)("path",{d:"M109.941 25.58L111.33 33.4584",stroke:"#999999"}),Object(y.jsx)("path",{d:"M144.67 222.542L146.059 230.42",stroke:"#999999"}),Object(y.jsx)("path",{d:"M25.5801 146.059L33.4585 144.67",stroke:"#999999"}),Object(y.jsx)("path",{d:"M222.542 111.33L230.42 109.941",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip4)",children:[Object(y.jsx)("path",{d:"M101.083 27.5437L103.153 35.2711",stroke:"#999999"}),Object(y.jsx)("path",{d:"M152.847 220.729L154.917 228.456",stroke:"#999999"}),Object(y.jsx)("path",{d:"M27.5437 154.917L35.2711 152.847",stroke:"#999999"}),Object(y.jsx)("path",{d:"M220.729 103.153L228.456 101.083",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip5)",children:[Object(y.jsx)("path",{d:"M92.4297 30.272L95.1659 37.7895",stroke:"#999999"}),Object(y.jsx)("path",{d:"M160.834 218.21L163.57 225.728",stroke:"#999999"}),Object(y.jsx)("path",{d:"M30.2718 163.57L37.7893 160.834",stroke:"#999999"}),Object(y.jsx)("path",{d:"M218.21 95.1661L225.728 92.4299",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip6)",children:[Object(y.jsx)("path",{d:"M84.0475 33.744L87.4285 40.9945",stroke:"#999999"}),Object(y.jsx)("path",{d:"M168.571 215.006L171.952 222.256",stroke:"#999999"}),Object(y.jsx)("path",{d:"M33.7438 171.952L40.9943 168.571",stroke:"#999999"}),Object(y.jsx)("path",{d:"M215.005 87.4286L222.256 84.0477",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip7)",children:[Object(y.jsx)("path",{d:"M75.9998 37.9333L79.9998 44.8616",stroke:"#999999"}),Object(y.jsx)("path",{d:"M176 211.138L180 218.067",stroke:"#999999"}),Object(y.jsx)("path",{d:"M37.9332 180L44.8614 176",stroke:"#999999"}),Object(y.jsx)("path",{d:"M211.138 80L218.066 76",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip8)",children:[Object(y.jsx)("path",{d:"M68.3478 42.8082L72.9364 49.3614",stroke:"#999999"}),Object(y.jsx)("path",{d:"M183.063 206.639L187.652 213.192",stroke:"#999999"}),Object(y.jsx)("path",{d:"M42.8079 187.652L49.3611 183.063",stroke:"#999999"}),Object(y.jsx)("path",{d:"M206.638 72.9366L213.192 68.348",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip9)",children:[Object(y.jsx)("path",{d:"M61.1499 48.3314L66.2922 54.4598",stroke:"#999999"}),Object(y.jsx)("path",{d:"M189.707 201.54L194.85 207.669",stroke:"#999999"}),Object(y.jsx)("path",{d:"M48.3311 194.85L54.4595 189.708",stroke:"#999999"}),Object(y.jsx)("path",{d:"M201.54 66.2924L207.668 61.1501",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip10)",children:[Object(y.jsx)("path",{d:"M54.4606 54.4609L60.1175 60.1178",stroke:"#999999"}),Object(y.jsx)("path",{d:"M195.882 195.882L201.539 201.539",stroke:"#999999"}),Object(y.jsx)("path",{d:"M54.4606 201.539L60.1175 195.882",stroke:"#999999"}),Object(y.jsx)("path",{d:"M195.882 60.1177L201.539 54.4609",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip11)",children:[Object(y.jsx)("path",{d:"M48.3312 61.15L54.4596 66.2923",stroke:"#999999"}),Object(y.jsx)("path",{d:"M201.54 189.708L207.668 194.85",stroke:"#999999"}),Object(y.jsx)("path",{d:"M61.1499 207.669L66.2922 201.54",stroke:"#999999"}),Object(y.jsx)("path",{d:"M189.707 54.4597L194.85 48.3314",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip12)",children:[Object(y.jsx)("path",{d:"M42.8079 68.348L49.3611 72.9366",stroke:"#999999"}),Object(y.jsx)("path",{d:"M206.638 183.063L213.192 187.652",stroke:"#999999"}),Object(y.jsx)("path",{d:"M68.3478 213.192L72.9364 206.639",stroke:"#999999"}),Object(y.jsx)("path",{d:"M183.063 49.3613L187.652 42.8081",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip13)",children:[Object(y.jsx)("path",{d:"M37.9331 76L44.8613 80",stroke:"#999999"}),Object(y.jsx)("path",{d:"M211.138 176L218.066 180",stroke:"#999999"}),Object(y.jsx)("path",{d:"M75.9998 218.067L79.9998 211.138",stroke:"#999999"}),Object(y.jsx)("path",{d:"M176 44.8616L180 37.9334",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip14)",children:[Object(y.jsx)("path",{d:"M33.7437 84.0477L40.9942 87.4286",stroke:"#999999"}),Object(y.jsx)("path",{d:"M215.005 168.571L222.256 171.952",stroke:"#999999"}),Object(y.jsx)("path",{d:"M84.0475 222.256L87.4284 215.005",stroke:"#999999"}),Object(y.jsx)("path",{d:"M168.571 40.9944L171.952 33.7439",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip15)",children:[Object(y.jsx)("path",{d:"M30.2718 92.4299L37.7893 95.166",stroke:"#999999"}),Object(y.jsx)("path",{d:"M218.21 160.834L225.728 163.57",stroke:"#999999"}),Object(y.jsx)("path",{d:"M92.4297 225.728L95.1659 218.21",stroke:"#999999"}),Object(y.jsx)("path",{d:"M160.834 37.7894L163.57 30.2719",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip16)",children:[Object(y.jsx)("path",{d:"M27.5436 101.083L35.271 103.153",stroke:"#999999"}),Object(y.jsx)("path",{d:"M220.729 152.847L228.456 154.917",stroke:"#999999"}),Object(y.jsx)("path",{d:"M101.083 228.456L103.153 220.729",stroke:"#999999"}),Object(y.jsx)("path",{d:"M152.847 35.2711L154.917 27.5437",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip17)",children:[Object(y.jsx)("path",{d:"M25.5798 109.941L33.4583 111.33",stroke:"#999999"}),Object(y.jsx)("path",{d:"M222.541 144.67L230.42 146.059",stroke:"#999999"}),Object(y.jsx)("path",{d:"M109.94 230.42L111.33 222.542",stroke:"#999999"}),Object(y.jsx)("path",{d:"M144.67 33.4585L146.059 25.58",stroke:"#999999"})]}),Object(y.jsxs)("g",{clipPath:"url(#clip18)",children:[Object(y.jsx)("path",{d:"M24.3957 118.936L32.3653 119.633",stroke:"#999999"}),Object(y.jsx)("path",{d:"M223.635 136.367L231.604 137.064",stroke:"#999999"}),Object(y.jsx)("path",{d:"M118.936 231.604L119.633 223.635",stroke:"#999999"}),Object(y.jsx)("path",{d:"M136.367 32.3652L137.064 24.3957",stroke:"#999999"})]})]}),Object(y.jsxs)("g",{clipPath:"url(#clip19)",children:[Object(y.jsx)("path",{d:"M54.4609 54.4609L65.7746 65.7746",stroke:"#333333"}),Object(y.jsx)("path",{d:"M190.225 190.225L201.539 201.539",stroke:"#333333"}),Object(y.jsx)("path",{d:"M54.4609 201.539L65.7746 190.225",stroke:"#333333"}),Object(y.jsx)("path",{d:"M190.225 65.7746L201.539 54.4609",stroke:"#333333"})]}),Object(y.jsx)("path",{d:"M128 24L128 40",stroke:"#333333"}),Object(y.jsx)("path",{d:"M128 216L128 232",stroke:"#333333"}),Object(y.jsx)("path",{d:"M24 128L40 128",stroke:"#333333"}),Object(y.jsx)("path",{d:"M216 128L232 128",stroke:"#333333"}),Object(y.jsx)("path",{d:"M44.2666 50.9756H43.1299L38.4482 43.7861H38.4014C38.4639 44.6299 38.4951 45.4033 38.4951 46.1064V50.9756H37.5752V42.4092H38.7002L43.3701 49.5693H43.417C43.4092 49.4639 43.3916 49.126 43.3643 48.5557C43.3369 47.9814 43.3271 47.5713 43.335 47.3252V42.4092H44.2666V50.9756ZM54.0986 50.9756H53.1143L51.3857 45.2393C51.3037 44.9854 51.2119 44.665 51.1104 44.2783C51.0088 43.8916 50.9561 43.6592 50.9521 43.5811C50.8662 44.0967 50.7295 44.6611 50.542 45.2744L48.8662 50.9756H47.8818L45.6025 42.4092H46.6572L48.0107 47.7002C48.1982 48.4424 48.335 49.1143 48.4209 49.7158C48.5264 49.001 48.6826 48.3018 48.8896 47.6182L50.4248 42.4092H51.4795L53.0908 47.665C53.2783 48.2705 53.4365 48.9541 53.5654 49.7158C53.6396 49.1611 53.7803 48.4854 53.9873 47.6885L55.335 42.4092H56.3896L54.0986 50.9756Z",fill:"#333333"}),Object(y.jsx)("path",{d:"M209.403 212.745C209.403 213.499 209.13 214.087 208.583 214.509C208.036 214.931 207.294 215.142 206.356 215.142C205.341 215.142 204.56 215.011 204.013 214.749V213.788C204.364 213.936 204.747 214.054 205.161 214.14C205.575 214.226 205.985 214.268 206.392 214.268C207.056 214.268 207.556 214.143 207.892 213.893C208.228 213.64 208.395 213.288 208.395 212.839C208.395 212.542 208.335 212.3 208.214 212.112C208.097 211.921 207.897 211.745 207.616 211.585C207.339 211.425 206.915 211.243 206.345 211.04C205.548 210.755 204.978 210.417 204.634 210.026C204.294 209.636 204.124 209.126 204.124 208.497C204.124 207.837 204.372 207.311 204.868 206.921C205.364 206.53 206.021 206.335 206.837 206.335C207.688 206.335 208.472 206.491 209.187 206.804L208.876 207.671C208.169 207.374 207.481 207.226 206.813 207.226C206.286 207.226 205.874 207.339 205.577 207.565C205.28 207.792 205.132 208.106 205.132 208.509C205.132 208.806 205.187 209.05 205.296 209.241C205.405 209.429 205.589 209.602 205.847 209.763C206.108 209.919 206.507 210.093 207.042 210.284C207.94 210.604 208.558 210.948 208.894 211.315C209.233 211.683 209.403 212.159 209.403 212.745ZM215.931 215.024H211.155V206.458H215.931V207.343H212.151V210.102H215.702V210.981H212.151V214.134H215.931V215.024Z",fill:"#333333"}),Object(y.jsx)("path",{d:"M210.03 50.9756H208.894L204.212 43.7861H204.165C204.228 44.6299 204.259 45.4033 204.259 46.1064V50.9756H203.339V42.4092H204.464L209.134 49.5693H209.181C209.173 49.4639 209.155 49.126 209.128 48.5557C209.101 47.9814 209.091 47.5713 209.099 47.3252V42.4092H210.03V50.9756ZM217.161 50.9756H212.386V42.4092H217.161V43.2939H213.382V46.0537H216.933V46.9326H213.382V50.085H217.161V50.9756Z",fill:"#333333"}),Object(y.jsx)("path",{d:"M43.1396 212.745C43.1396 213.499 42.8662 214.087 42.3193 214.509C41.7725 214.931 41.0303 215.142 40.0928 215.142C39.0771 215.142 38.2959 215.011 37.749 214.749V213.788C38.1006 213.936 38.4834 214.054 38.8975 214.14C39.3115 214.226 39.7217 214.268 40.1279 214.268C40.792 214.268 41.292 214.143 41.6279 213.893C41.9639 213.64 42.1318 213.288 42.1318 212.839C42.1318 212.542 42.0713 212.3 41.9502 212.112C41.833 211.921 41.6338 211.745 41.3525 211.585C41.0752 211.425 40.6514 211.243 40.081 211.04C39.2842 210.755 38.7139 210.417 38.3701 210.026C38.0303 209.636 37.8603 209.126 37.8603 208.497C37.8603 207.837 38.1084 207.311 38.6045 206.921C39.1006 206.53 39.7568 206.335 40.5732 206.335C41.4248 206.335 42.208 206.491 42.9228 206.804L42.6123 207.671C41.9053 207.374 41.2178 207.226 40.5498 207.226C40.0225 207.226 39.6103 207.339 39.3135 207.565C39.0166 207.792 38.8682 208.106 38.8682 208.509C38.8682 208.806 38.9228 209.05 39.0322 209.241C39.1416 209.429 39.3252 209.602 39.583 209.763C39.8447 209.919 40.2432 210.093 40.7783 210.284C41.6767 210.604 42.2939 210.948 42.6299 211.315C42.9697 211.683 43.1396 212.159 43.1396 212.745ZM52.3682 215.024H51.3838L49.6553 209.288C49.5732 209.034 49.4814 208.714 49.3799 208.327C49.2783 207.94 49.2256 207.708 49.2217 207.63C49.1357 208.145 48.999 208.71 48.8115 209.323L47.1357 215.024H46.1514L43.8721 206.458H44.9267L46.2803 211.749C46.4678 212.491 46.6045 213.163 46.6904 213.765C46.7959 213.05 46.9521 212.351 47.1592 211.667L48.6943 206.458H49.749L51.3603 211.714C51.5478 212.319 51.706 213.003 51.835 213.765C51.9092 213.21 52.0498 212.534 52.2568 211.737L53.6045 206.458H54.6592L52.3682 215.024Z",fill:"#333333"}),Object(y.jsx)("path",{d:"M131.797 17H129.488L125.762 10.5195H125.709C125.783 11.6641 125.82 12.4805 125.82 12.9688V17H124.197V8.43359H126.488L130.209 14.8496H130.25C130.191 13.7363 130.162 12.9492 130.162 12.4883V8.43359H131.797V17Z",fill:"#333333"}),Object(y.jsx)("path",{d:"M131.33 246.621C131.33 247.395 131.051 248.004 130.492 248.449C129.938 248.895 129.164 249.117 128.172 249.117C127.258 249.117 126.449 248.945 125.746 248.602V246.914C126.324 247.172 126.812 247.354 127.211 247.459C127.613 247.564 127.98 247.617 128.312 247.617C128.711 247.617 129.016 247.541 129.227 247.389C129.441 247.236 129.549 247.01 129.549 246.709C129.549 246.541 129.502 246.393 129.408 246.264C129.314 246.131 129.176 246.004 128.992 245.883C128.812 245.762 128.443 245.568 127.885 245.303C127.361 245.057 126.969 244.82 126.707 244.594C126.445 244.367 126.236 244.104 126.08 243.803C125.924 243.502 125.846 243.15 125.846 242.748C125.846 241.99 126.102 241.395 126.613 240.961C127.129 240.527 127.84 240.311 128.746 240.311C129.191 240.311 129.615 240.363 130.018 240.469C130.424 240.574 130.848 240.723 131.289 240.914L130.703 242.326C130.246 242.139 129.867 242.008 129.566 241.934C129.27 241.859 128.977 241.822 128.688 241.822C128.344 241.822 128.08 241.902 127.896 242.062C127.713 242.223 127.621 242.432 127.621 242.689C127.621 242.85 127.658 242.99 127.732 243.111C127.807 243.229 127.924 243.344 128.084 243.457C128.248 243.566 128.633 243.766 129.238 244.055C130.039 244.438 130.588 244.822 130.885 245.209C131.182 245.592 131.33 246.062 131.33 246.621Z",fill:"#333333"}),Object(y.jsx)("path",{d:"M247.148 133H242.215V124.434H247.148V125.922H244.031V127.803H246.932V129.291H244.031V131.5H247.148V133Z",fill:"#333333"}),Object(y.jsx)("path",{d:"M15.6211 133H13.5527L12.3926 128.5C12.3496 128.34 12.2754 128.01 12.1699 127.51C12.0684 127.006 12.0098 126.668 11.9941 126.496C11.9707 126.707 11.9121 127.047 11.8184 127.516C11.7246 127.98 11.6523 128.312 11.6016 128.512L10.4473 133H8.38477L6.19922 124.434H7.98633L9.08203 129.109C9.27344 129.973 9.41211 130.721 9.49805 131.354C9.52148 131.131 9.57422 130.787 9.65625 130.322C9.74219 129.854 9.82227 129.49 9.89648 129.232L11.1445 124.434H12.8613L14.1094 129.232C14.1641 129.447 14.2324 129.775 14.3145 130.217C14.3965 130.658 14.459 131.037 14.502 131.354C14.541 131.049 14.6035 130.67 14.6895 130.217C14.7754 129.76 14.8535 129.391 14.9238 129.109L16.0137 124.434H17.8008L15.6211 133Z",fill:"#333333"}),Object(y.jsx)("path",{d:"M127.792 30H128.208L132.167 40H123.833L125.813 35L127.792 30Z",fill:"#333333"})]}),Object(y.jsx)("circle",{cx:"128",cy:"128",r:"59.5",fill:"white",stroke:"#D7DAE0"}),Object(y.jsx)("text",{x:"128",y:"120",dominantBaseline:"middle",textAnchor:"middle",fill:"#2F3031",fontSize:"2.125em",fontWeight:"bolder",children:t}),Object(y.jsx)("text",{x:"128",y:"146",dominantBaseline:"middle",textAnchor:"middle",fill:"#2F3031",fontSize:"1em",children:a}),Object(y.jsxs)("defs",{children:[Object(y.jsx)("clipPath",{id:"clip0",children:Object(y.jsx)("rect",{width:"256",height:"256",fill:"white"})}),Object(y.jsx)("clipPath",{id:"clip1",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(24 24)"})}),Object(y.jsx)("clipPath",{id:"clip2",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(15.3316 33.46) rotate(-5)"})}),Object(y.jsx)("clipPath",{id:"clip3",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(7.52068 43.6394) rotate(-10)"})}),Object(y.jsx)("clipPath",{id:"clip4",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(0.62648 54.4609) rotate(-15)"})}),Object(y.jsx)("clipPath",{id:"clip5",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(-5.29831 65.842) rotate(-20)"})}),Object(y.jsx)("clipPath",{id:"clip6",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(-10.2085 77.6963) rotate(-25)"})}),Object(y.jsx)("clipPath",{id:"clip7",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(-14.0668 89.9333) rotate(-30)"})}),Object(y.jsx)("clipPath",{id:"clip8",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(-16.844 102.46) rotate(-35)"})}),Object(y.jsx)("clipPath",{id:"clip9",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(-18.5188 115.181) rotate(-40)"})}),Object(y.jsx)("clipPath",{id:"clip10",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(-19.0785 128) rotate(-45)"})}),Object(y.jsx)("clipPath",{id:"clip11",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(-18.5187 140.819) rotate(-50)"})}),Object(y.jsx)("clipPath",{id:"clip12",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(-16.8441 153.54) rotate(-55)"})}),Object(y.jsx)("clipPath",{id:"clip13",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(-14.0669 166.067) rotate(-60)"})}),Object(y.jsx)("clipPath",{id:"clip14",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(-10.2086 178.304) rotate(-65)"})}),Object(y.jsx)("clipPath",{id:"clip15",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(-5.29829 190.158) rotate(-70)"})}),Object(y.jsx)("clipPath",{id:"clip16",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(0.626419 201.539) rotate(-75)"})}),Object(y.jsx)("clipPath",{id:"clip17",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(7.52039 212.361) rotate(-80)"})}),Object(y.jsx)("clipPath",{id:"clip18",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(15.3315 222.54) rotate(-85)"})}),Object(y.jsx)("clipPath",{id:"clip19",children:Object(y.jsx)("rect",{width:"208",height:"208",fill:"white",transform:"translate(-19.0782 128) rotate(-45)"})})]})]})]})};YG.defaultProps={windSpeed:0,windDirection:0,speedUnit:"mph"};var HG=YG,GG=function(e){var t=e.isStart,n=e.date,a=e.time,r=e.windSpeed,c=e.windDirection,i=e.speedUnit,o=e.skyCondition,s=e.temperature,l=e.tempUnit,d=e.soilMoisture,u=e.humidity;return Object(y.jsxs)("div",{className:"mt-3 bg-white border rounded pl-4",style:{width:"347px"},children:[Object(y.jsxs)(m.Columns,{children:[Object(y.jsx)(m.Column,{width:"w-1/2",children:Object(y.jsx)("div",{className:"my-4 ml-4",children:Object(y.jsx)(Fl,{header:"".concat(t?"Start":"End"," Date"),data:n})})}),Object(y.jsx)(m.Column,{width:"w-1/2",children:Object(y.jsx)("div",{className:"my-4 ml-10",children:Object(y.jsx)(Fl,{header:"".concat(t?"Start":"End"," Time"),data:a})})})]}),Object(y.jsx)(HG,{windSpeed:r,windDirection:c,speedUnit:i}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsxs)(m.Column,{width:"w-1/2",children:[Object(y.jsx)("div",{className:"my-4 ml-4 flex flex-wrap",children:Object(y.jsx)(Fl,{header:"Sky Condition",data:Object(ne.startCase)(o)})}),Object(y.jsx)("div",{className:"my-4 ml-4",children:Object(y.jsx)(Fl,{header:"Temp",data:"".concat(s,"\xb0 ").concat(l)})})]}),Object(y.jsxs)(m.Column,{width:"w-1/2",children:[Object(y.jsx)("div",{className:"my-4 ml-10",children:Object(y.jsx)(Fl,{header:"Soil Moisture",data:d})}),Object(y.jsx)("div",{className:"my-4 ml-10",children:Object(y.jsx)(Fl,{header:"Humidity",data:"".concat(u,"%")})})]})]})]})};GG.defaultProps={isStart:!0,date:"",time:"",windSpeed:0,windDirection:0,speedUnit:"mph",skyCondition:"",temperature:0,tempUnit:"F",soilMoisture:"unknown",humidity:0};var WG=GG,qG=function(e){var t=e.status,n=Object(a.useState)({name:"Ready",color:"#E99921"}),r=Object(b.a)(n,2),c=r[0],i=r[1];return Object(a.useEffect)((function(){"inprogress"===t?i({name:"In Progress",color:"#5FD2C8"}):"complete"===t&&i({name:"Complete",color:"#0071CD"})}),[t]),Object(y.jsx)(m.Tag,{color:c.color,children:Object(y.jsx)("span",{className:"w-32 text-lg",children:c.name})})},JG=function(e){var t=e.product,n=e.applicationType,a=e.memberRole,r=e.memberFinancialAccess;return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsxs)("span",{className:"flex flex-col",children:[Object(y.jsx)("span",{className:"w-64 pb-2 text-sm font-bold text-left truncate","data-testid":"product-name",children:t.productName}),Object(y.jsxs)("span",{className:"w-64 text-sm text-left text-gray-600 truncate","data-testid":"product-manufacturer",children:[t.isCustom&&Object(y.jsx)(y.Fragment,{children:"Custom"}),t.isCustom&&t.manufacturerName&&Object(y.jsx)(y.Fragment,{children:" \u2022 "}),t.manufacturerName]})]})}),Object(y.jsxs)(m.Table.Cell,{children:[null===t||void 0===t?void 0:t[n]," ",t.ratePerAreaUnit]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:t.appliedAreaValue})," ",t.appliedAreaUnit]}),Object(y.jsxs)(m.Table.Cell,{children:[100*t.coveragePercent," %"]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:t.totalProductValue})," ",t.totalProductUnit]}),Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsx)("div",{className:"mr-6",children:"Full control"!==a&&"View Only"!==a||"none"!==r?Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:"2",children:t.totalCostAtTimeOfCreation}):null})})]},t.id)})},KG=function(e){var t,n=e.property,a=null!==n&&void 0!==n&&null!==(t=n.features)&&void 0!==t&&t[0]?[Ej(n.features[0])]:void 0;return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(Kp,{id:"view-field-card-icon",features:a})}),Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsxs)("div",{className:"flex flex-col justify-start leading-5 text-left",children:[Object(y.jsx)("span",{className:"font-bold text-neutral-1000",children:null===n||void 0===n?void 0:n.fieldName}),Object(y.jsx)("span",{style:{color:"#707374"},children:null===n||void 0===n?void 0:n.cropZoneName})]})}),Object(y.jsx)(m.Table.Cell,{children:null===n||void 0===n?void 0:n.cropName}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:null===n||void 0===n?void 0:n.areaValue})," ac"]}),Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsx)("div",{className:"mr-6",children:Object(y.jsx)(yf,{roundedTo:"2",children:100*(null===n||void 0===n?void 0:n.coveragePercent)})})})]},null===n||void 0===n?void 0:n.cropZoneId)})},QG=[{key:"N",value:0},{key:"NNE",value:22.5},{key:"NE",value:45},{key:"ENE",value:67.5},{key:"E",value:90},{key:"ESE",value:112.5},{key:"SE",value:135},{key:"SSE",value:157.5},{key:"S",value:180},{key:"SSW",value:202.5},{key:"SW",value:225},{key:"WSW",value:247.5},{key:"W",value:270},{key:"WNW",value:292.5},{key:"NW",value:315},{key:"NNW",value:337.5}],XG=function(e){var t,n,r,c,i=e.location,o=e.id,s=i.cropSeasons.map((function(e){return e.id})),l=rv({fetchType:gm,cropSeasonsId:s}),d=l.dataSorted,u=l.fieldsAndAreasGeoJSONCollection,j=l.reloadData;Object(a.useEffect)((function(){j()}),[]);var p=d,f=Object(a.useContext)(ac),v=Object(b.a)(f,2),O=v[0].loggedInUserOrgPermission,h=O.role,x=O.financialAccess,g=void 0===x?"none":x,C=v[1],P=Object(a.useState)({}),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)(!0),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)(null),I=Object(b.a)(R,2),D=I[0],k=I[1],L=Object(a.useState)([]),F=Object(b.a)(L,2),M=F[0],V=F[1],B=Object(a.useState)(),U=Object(b.a)(B,2),z=U[0],Z=U[1],H=Object(a.useState)(null),W=Object(b.a)(H,2),q=W[0],J=(W[1],Object(a.useState)(!0)),K=Object(b.a)(J,2),Q=K[0],X=K[1],$=Object(a.useState)({extraTagsCount:0,extraTagsNames:[],tagsToDisplay:[]}),ee=Object(b.a)($,2),te=ee[0],ne=ee[1];Object(a.useEffect)((function(){ne(Af(M,20))}),[M]);var ae=go((function(e,t){k(t)}),xo),re=[{key:"ratePerAreaValue",value:"By Rate/Area Application",display:"ByRatePerArea"},{key:"totalProductValue",value:"By Total Product Application",display:"ByTotalProduct"},{key:"ratePerTankValue",value:"By Rate/Tank Application",display:"ByRatePerTank"}];Object(a.useEffect)((function(){gn.fetch(o).promise.then((function(e){var t,n=e.data;n&&(T(n),V(n.flags),k((t=n.applicationStrategy)===re[0].display?re[0].key:t===re[1].display?re[1].key:t===re[2].display?re[2].key:re[0].key)),_(!1)})).catch(Ae.default).catch((function(e){uc(C)(e),_(!1)}))}),[C,o]);var ce=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],null===p||void 0===p||null===(t=p.properties)||void 0===t||t.forEach((function(e){var t;null===e||void 0===e||null===(t=e.fields)||void 0===t||t.forEach((function(e){var t;null===e||void 0===e||null===(t=e.cropzones)||void 0===t||t.forEach((function(t){var a;null===S||void 0===S||null===(a=S.properties)||void 0===a||a.forEach((function(a){if((null===t||void 0===t?void 0:t.id)===(null===a||void 0===a?void 0:a.cropZoneId)){var r,c,i={farmId:null===a||void 0===a?void 0:a.farmId,cropZoneId:null===t||void 0===t?void 0:t.id,fieldName:null===e||void 0===e?void 0:e.name,cropZoneName:null===t||void 0===t?void 0:t.name,cropName:null===t||void 0===t||null===(r=t.crop)||void 0===r?void 0:r.name,areaValue:null===a||void 0===a?void 0:a.areaValue,areaUnit:null===a||void 0===a?void 0:a.areaUnit,boundaryArea:null===t||void 0===t?void 0:t.boundaryArea,reportedArea:null===t||void 0===t?void 0:t.reportedArea,coveragePercent:null===a||void 0===a?void 0:a.coveragePct,features:null===(c=u.features)||void 0===c?void 0:c.filter((function(t){return e.id===t.properties.id}))};n.push(i)}}))}))}))})),e.abrupt("return",n);case 3:case"end":return e.stop()}}),e)}))),[null===p||void 0===p?void 0:p.properties,null===S||void 0===S?void 0:S.properties,null===u||void 0===u?void 0:u.features]);Object(a.useEffect)((function(){var e,t;(null===p||void 0===p||null===(e=p.properties)||void 0===e?void 0:e.length)>0&&(null===S||void 0===S||null===(t=S.taskId)||void 0===t?void 0:t.length)>0&&ce().then((function(e){Z(e)}))}),[ce,p,S]);var ie=function(){return Q?Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){X(!1)},children:q}):null};return w||!z?Object(y.jsxs)(y.Fragment,{children:[ie(),Object(y.jsx)(m.Spinner,{})]}):Object(y.jsxs)(y.Fragment,{children:[ie(),Object(y.jsx)(y.Fragment,{children:Object(y.jsx)("div",{className:"min-w-content border rounded","data-testid":"tasks-table",children:Object(y.jsx)("div",{children:Object(y.jsxs)("div",{className:"m-4",children:[Object(y.jsxs)("div",{"data-testid":"task-details",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Task Details"})}),Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{children:Object(y.jsxs)("div",{className:"mb-6",children:[Object(y.jsx)(Fl,{header:"Task ID",data:S.name,testId:"taskId"}),Object(y.jsx)("div",{className:"w-32 text-center",children:Object(y.jsx)(qG,{status:S.status})})]})})}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsx)(m.Column,{width:"w-120",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Start Date/Time",data:hA(S.startDate),testId:"startDateTime"})})}),Object(y.jsx)(m.Column,{width:"w-56",children:Object(y.jsx)("div",{className:"flex items-center w-full h-full",children:Object(y.jsx)("svg",{width:"53",height:"16",viewBox:"0 0 53 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M52.7071 8.7071C53.0976 8.31658 53.0976 7.68341 52.7071 7.29289L46.3431 0.928928C45.9526 0.538404 45.3195 0.538404 44.9289 0.928928C44.5384 1.31945 44.5384 1.95262 44.9289 2.34314L50.5858 8L44.9289 13.6569C44.5384 14.0474 44.5384 14.6805 44.9289 15.0711C45.3195 15.4616 45.9526 15.4616 46.3431 15.0711L52.7071 8.7071ZM8.74228e-08 9L52 9L52 7L-8.74228e-08 7L8.74228e-08 9Z",fill:"#696F88"})})})}),Object(y.jsx)(m.Column,{width:"w-120",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"End Date/Time",data:hA(S.dueDate),testId:"endDateTime"})})})]}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsxs)(m.Column,{width:"w-1/3",children:[Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Authorization By",data:S.authorizedBy,testId:"authorizedBy"})}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Timing Event",data:S.timingEvent,testId:"timingEvent"})}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsxs)("div",{"data-testid":"cropSeason",children:[Object(y.jsx)("div",{className:"text-gray-600",children:"Crop Season"}),Object(y.jsx)("div",{className:"text-2xl",children:Object(y.jsx)(m.TagCloud,{children:S.cropSeasonIds.map((function(e){return Object(y.jsx)(m.Tag,{children:e.name})}))})})]})})]}),Object(y.jsxs)(m.Column,{width:"w-1/3",children:[Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Authorization Date/Time",data:S.authorizedDate?hA(S.authorizedDate):"-",testId:"authorizationDateTime"})}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Duration",data:S.duration?"".concat(S.duration," hours"):"",testId:"duration"})}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsxs)("div",{"data-testid":"flags",children:[Object(y.jsx)("div",{className:"text-gray-600",children:"Tags"}),Object(y.jsx)("div",{className:"mt-1",children:te.extraTagsNames.length>0?Object(y.jsx)(fu,{position:"bottom",ariaLabel:"Task Tags",top:"1.5rem",msg:Object(y.jsx)(Pf,{extraTagsNames:te.extraTagsNames}),component:Object(y.jsx)(Sf,{displayTagsObject:te,isLandingPage:"view",viewKey:fd})}):Object(y.jsx)(Sf,{displayTagsObject:te,isLandingPage:"view",viewKey:fd})})]})})]}),Object(y.jsxs)(m.Column,{width:"w-1/3",children:[Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Task Type",data:S.type,testId:"taskType"})}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Created on",data:hA(S.createdAt),testId:"createdOn"})}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsxs)("div",{"data-testid":"source",children:[Object(y.jsx)("div",{className:"text-gray-600",children:"Source"}),Object(y.jsx)("div",{className:"text-2xl",children:(null===S||void 0===S?void 0:S.sources)&&Object(y.jsx)(m.TagCloud,{children:null===S||void 0===S?void 0:S.sources.map((function(e){return Object(y.jsx)(m.Tag,{children:e.name})}))})})]})})]})]})]}),Object(y.jsx)("hr",{className:"my-6"}),Object(y.jsxs)("div",{"data-testid":"applicator-section",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Applicator(s)"})}),Object(y.jsxs)(m.Columns,{wrap:!0,children:[(null===S||void 0===S?void 0:S.applicators)&&(null===S||void 0===S||null===(t=S.applicators)||void 0===t?void 0:t.map((function(e,t){return Object(y.jsx)(m.Column,{width:"w-full ".concat(t>0?"mt-6":""),children:Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"w-4/12",children:[Object(y.jsx)(Fl,{data:e.personName}),Object(y.jsx)("div",{className:"text-gray-600",children:"".concat(e.licenseNumber?e.licenseNumber:""," ").concat(e.expiresDate?"Exp. ".concat(fA(e.expiresDate)):""," ")})]}),Object(y.jsx)(Fl,{header:"Company",data:e.companyName})]})})}))),Object(y.jsx)("div",{className:"w-4/12 mt-6",children:Object(y.jsx)(Fl,{header:"Buffer Zone",data:S.bufferZone?"".concat(S.bufferZone," FT"):null,testId:"bufferZone"})}),Object(y.jsx)("div",{className:"mt-6",children:Object(y.jsx)(Fl,{header:"Buffer Reason",data:S.bufferReason,testId:"pollenDrift"})})]})]}),Object(y.jsx)("hr",{className:"my-6"}),Object(y.jsxs)("div",{"data-testid":"properties-section",className:"mb-6",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Properties"})}),Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{width:"10%"}),Object(y.jsxs)(m.Table.Cell,{width:"25%",children:["Fields (",null===S||void 0===S||null===(n=S.properties)||void 0===n?void 0:n.length,")"]}),Object(y.jsx)(m.Table.Cell,{children:"Crops"}),Object(y.jsx)(m.Table.Cell,{children:"Area"}),Object(y.jsx)(m.Table.Cell,{width:"15%",children:"Coverage %"})]}),z.map((function(e){return Object(y.jsx)(KG,{property:e})}))]})]}),Object(y.jsxs)("div",{"data-testid":"products-services-section",className:"mb-6",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Products & Services"}),Object(y.jsx)(m.Select,{value:D,onChange:ae,items:re})]})}),Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{children:"Products (".concat(null===(r=S.products)||void 0===r?void 0:r.length,")")}),Object(y.jsx)(m.Table.Cell,{children:function(e){var t="Rate/Tank";return"ratePerAreaValue"===e?t="Rate/Area":"totalProductValue"===e&&(t="Total Product"),t}(D)}),Object(y.jsx)(m.Table.Cell,{children:"Appl. Area"}),Object(y.jsx)(m.Table.Cell,{children:"Appl. Area %"}),Object(y.jsx)(m.Table.Cell,{children:"Total Product"}),Object(y.jsx)(m.Table.Cell,{children:"Total Cost"})]}),S.products.map((function(e){return Object(y.jsx)(JG,{product:e,applicationType:D,memberRole:h,memberFinancialAccess:g})}))]})]}),Object(y.jsxs)("div",{"data-testid":"weather-section",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Weather"})}),Object(y.jsx)("div",{className:"flex",children:null===S||void 0===S||null===(c=S.weather)||void 0===c?void 0:c.map((function(e){var t,n;return Object(y.jsx)("div",{className:"mr-6",children:Object(y.jsx)(WG,{isStart:"START"===e.type,date:fA(null===e||void 0===e?void 0:e.date),time:gA(null===e||void 0===e?void 0:e.date),windSpeed:null===e||void 0===e?void 0:e.windSpeed,windDirection:null===(n=null===e||void 0===e?void 0:e.windDirection,t=QG.find((function(e){return e.key===n})))||void 0===t?void 0:t.value,skyCondition:null===e||void 0===e?void 0:e.skyCondition,temperature:null===e||void 0===e?void 0:e.temperature,soilMoisture:null===e||void 0===e?void 0:e.soilMoisture,humidity:null===e||void 0===e?void 0:e.humidity,speedUnit:null===e||void 0===e?void 0:e.windSpeedUnit,tempUnit:null===e||void 0===e?void 0:e.temperatureUnit})})}))})]}),Object(y.jsxs)("div",{"data-testid":"notes-section",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Notes"})}),Object(y.jsx)(m.TextArea,{"data-testid":"taskNotes",className:"h-64 overscroll-auto",resizeDisabled:!0,disabled:!0,value:S.notes})]})]})})})})]})};XG.defaultProps={location:null};var $G=XG,eW=function(e){var t,n=e.recommendation,a=dd(),r=a.cropSeasons,c=a.loaded,i=WF(),o=i.tags,s=i.loading;return Object(y.jsxs)("div",{"data-testid":"recommendation-details",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Recommendation Details"})}),Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Recommendation ID",data:n.title,testId:"recommendationId"})})})}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsx)(m.Column,{width:"w-1/3",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Proposed Date",data:Object(y.jsxs)("div",{className:"flex items-center justify-between",children:[Object(y.jsx)("span",{children:xA(n.proposedDateEpoch)}),Object(y.jsx)("svg",{width:"53",height:"16",viewBox:"0 0 53 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M52.7071 8.7071C53.0976 8.31658 53.0976 7.68341 52.7071 7.29289L46.3431 0.928928C45.9526 0.538404 45.3195 0.538404 44.9289 0.928928C44.5384 1.31945 44.5384 1.95262 44.9289 2.34314L50.5858 8L44.9289 13.6569C44.5384 14.0474 44.5384 14.6805 44.9289 15.0711C45.3195 15.4616 45.9526 15.4616 46.3431 15.0711L52.7071 8.7071ZM8.74228e-08 9L52 9L52 7L-8.74228e-08 7L8.74228e-08 9Z",fill:"#696F88"})}),Object(y.jsx)("span",{children:"\xa0"})]}),testId:"proposedDate"})})}),Object(y.jsx)(m.Column,{width:"w-1/3",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Expiration Date",data:xA(n.expirationDateEpoch),testId:"expirationDate"})})})]}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsx)(m.Column,{width:"w-1/3",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Authorization By",data:n.authorisedByName,testId:"authorizedBy"})})}),Object(y.jsx)(m.Column,{width:"w-1/3",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Authorization Date/Time",data:xA(null===n||void 0===n?void 0:n.authorisedOnEpoch),testId:"authorizedOn"})})}),Object(y.jsx)(m.Column,{width:"w-1/3",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Recommendation Number",data:n.number,testId:"number"})})})]}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsx)(m.Column,{width:"w-1/3",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Timing Event",data:n.timingEvent,testId:"timingEvent"})})}),Object(y.jsx)(m.Column,{width:"w-1/3",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Created On",data:xA(n.createdOn),testId:"createdOn"})})})]}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsx)(m.Column,{width:"w-1/3",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Crop Season",data:c&&Object(y.jsx)(m.TagCloud,{children:n.cropSeasonIds.map((function(e){var t=null===r||void 0===r?void 0:r.find((function(t){return t.id===e}));return Object(y.jsx)(m.Tag,{children:(null===t||void 0===t?void 0:t.name)||""},e)}))}),testId:"cropSeasons"})})}),Object(y.jsx)(m.Column,{width:"w-1/3",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Tags",data:s||!(null!==n&&void 0!==n&&n.flagIds||null!==n&&void 0!==n&&n.taskCreated)?null:Object(y.jsx)(m.TagCloud,{children:[].concat(Object(v.a)(null!==n&&void 0!==n&&n.taskCreated?[Object(y.jsx)(m.Tag,{color:"#73DB78",children:"Task Created"},"task-created")]:[]),Object(v.a)(((null===n||void 0===n?void 0:n.flagIds)||[]).map((function(e){var t=o.find((function(t){return t.id===e}));return Object(y.jsx)(m.Tag,{color:null===t||void 0===t?void 0:t.color,children:null===t||void 0===t?void 0:t.name},e)}))))}),testId:"flags"})})}),Object(y.jsx)(m.Column,{width:"w-1/3",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Source",data:(null===n||void 0===n?void 0:n.source)&&Object(y.jsx)(m.TagCloud,{children:null===n||void 0===n||null===(t=n.source)||void 0===t?void 0:t.map((function(e){return Object(y.jsx)(m.Tag,{children:e.name},e.id)}))}),testId:"source"})})})]})]})};var tW=function(e){var t=Object(a.useContext)(ac),n=Object(b.a)(t,2)[1],r=Object(a.useState)(!0),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(void 0),l=Object(b.a)(s,2),d=l[0],u=l[1];return Object(a.useEffect)((function(){o(!0);var t=tn.fetch(e,{includeExtended:!0}),a=t.promise,r=t.cancel;return a.then((function(e){u(e.data)})).catch(Ae.default).catch((function(e){uc(n)(e)})).finally((function(){o(!1)})),function(){return r()}}),[n,e]),{loading:i,recommendation:d,setRecommendation:u}},nW=function(e){var t=e.applicators,n=uE(),a=n.people,r=n.loading,c=dE(),i=c.companies,o=c.loading;return Object(y.jsxs)("div",{"data-testid":"applicator-section",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Applicator(s)"})}),!r&&!o&&t.map((function(e,t){var n,r,c=a.find((function(t){return t.id===e.personId})),o=i.find((function(t){return t.id===e.companyId}));return Object(y.jsxs)(m.Columns,{children:[Object(y.jsx)(m.Column,{width:"w-1/3",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Applicator",data:Object(y.jsxs)("div",{className:"flex flex-col",children:[Object(y.jsx)("span",{children:null!==(n=null===c||void 0===c?void 0:c.name)&&void 0!==n?n:""}),Object(y.jsxs)("span",{className:"text-gray-600 text-base",children:[null!==(r=null===c||void 0===c?void 0:c.licenseNumber)&&void 0!==r?r:""," ",null!==c&&void 0!==c&&c.expirationDate?"Exp. ".concat(fA(c.expirationDate)):""]})]}),testId:"applicator".concat(t)})})}),Object(y.jsx)(m.Column,{width:"w-1/3",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Company",data:null===o||void 0===o?void 0:o.name,testId:"companyName".concat(t)})})})]},e.applicatorId)}))]})},aW=function(e){var t=e.notes;return Object(y.jsxs)("div",{"data-testid":"notes-section",id:"rec-pagebreaker-2",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Notes"})}),Object(y.jsx)(m.TextArea,{"data-testid":"recommendationNotes",className:"h-64 overscroll-auto",resizeDisabled:!0,disabled:!0,value:null!==t&&void 0!==t?t:""})]})},rW=function(e){var t=e.numCells;return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(m.Spinner,{size:"sm"})}),Array.from(Array(Math.max(t-1,0)),(function(e,t){return Object(y.jsx)(m.Table.Cell,{},t)}))]})},cW=function(e){var t,n=e.property,a=null!==n&&void 0!==n&&null!==(t=n.features)&&void 0!==t&&t[0]?[Ej(n.features[0])]:void 0;return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(Kp,{id:"view-rec-card-icon",features:a})}),Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsxs)("div",{className:"flex flex-col justify-start leading-5 text-left",children:[Object(y.jsx)("span",{className:"font-bold text-neutral-1000",children:null===n||void 0===n?void 0:n.fieldName}),Object(y.jsx)("span",{style:{color:"#707374"},children:null===n||void 0===n?void 0:n.cropZoneName})]})}),Object(y.jsx)(m.Table.Cell,{children:null===n||void 0===n?void 0:n.cropName}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:null===n||void 0===n?void 0:n.areaValue})," ",null===n||void 0===n?void 0:n.areaUnit]}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"mr-6",children:[100*(null===n||void 0===n?void 0:n.coveragePercent)," %"]})})]})})},iW={fields:function(e,t){return CH()([function(e){return e.fieldName}],e,t)},crops:function(e,t){return CH()([function(e){return e.cropName}],e,t)},area:function(e,t){return CH()([function(e){return"".concat(e.areaValue,"_").concat(e.areaUnit)}],e,t)},coveragePercent:function(e,t){return CH()([function(e){return e.coveragePercent}],e,t)}},oW=function(e){var t,n=e.recommendation,r=Object(a.useState)([]),c=Object(b.a)(r,2),i=c[0],o=c[1],s=rv({fetchType:gm,cropSeasonsId:null===n||void 0===n?void 0:n.cropSeasonIds}),l=s.dataSorted,d=s.loading,u=s.fieldsAndAreasGeoJSONCollection,j=s.reloadData;Object(a.useEffect)((function(){j()}),[]);var p=Object(a.useState)(),f=Object(b.a)(p,1)[0],v=Object(a.useState)(),O=Object(b.a)(v,1)[0],h=Object(a.useState)([]),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useMemo)((function(){var e,t;return[{field:"icons",title:"",sortable:!1},{field:"fields",title:"Fields (".concat(null!==(e=null===(t=n.cropZones)||void 0===t?void 0:t.length)&&void 0!==e?e:0,")"),sortable:!1},{field:"crops",title:"Crops",sortable:!1},{field:"area",title:"Area",sortable:!1},{field:"coveragePercent",title:"Coverage %",sortable:!1}]}),[null===(t=n.cropZones)||void 0===t?void 0:t.length]);return Object(a.useEffect)((function(){var e;if((null===l||void 0===l||null===(e=l.properties)||void 0===e?void 0:e.length)>0){var t=function(e,t,n){var a,r=[];return null===e||void 0===e||null===(a=e.properties)||void 0===a||a.map((function(e){var a;null===(a=e.fields)||void 0===a||a.map((function(a){var c;null===(c=a.cropzones)||void 0===c||c.map((function(c){var i;null===t||void 0===t||null===(i=t.cropZones)||void 0===i||i.map((function(t){if(c.id===t.cropZoneIdValue){var i,o,s={farmId:e.id,cropZoneId:c.id,fieldName:a.name,cropZoneName:c.name,cropName:null===(i=c.crop)||void 0===i?void 0:i.name,areaValue:t.areaValue,areaUnit:t.areaUnit,boundaryArea:c.boundaryArea,reportedArea:c.reportedArea,coveragePercent:t.coveragePct||1,features:null===(o=n.features)||void 0===o?void 0:o.filter((function(e){return a.id===e.properties.id}))};r.push(s)}}))}))}))})),r}(l,n,u);o(t)}}),[l,n,u]),Object(a.useEffect)((function(){var e=iW[null!==f&&void 0!==f?f:""];C(e&&O?e(O,i):i)}),[i,f,O]),Object(y.jsxs)("div",{"data-testid":"properties-section",className:"mb-6",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Properties"})}),Object(y.jsxs)(m.Table,{children:[Object(y.jsx)(ks,{sortBy:null!==f&&void 0!==f?f:"",tableColumns:P}),d?Object(y.jsx)(rW,{numCells:P.length}):g.map((function(e){return Object(y.jsx)(cW,{property:e},e.cropZoneId)}))]})]})},sW=function(e){var t,n=e.open,a=e.onClose,r=e.product,c=e.pests,i=r.targetPestId?c.find((function(e){return e.pestid===r.targetPestId})):void 0;return Object(y.jsxs)(m.SimpleModal,{open:n,close:a,onConfirm:a,size:"sm",children:[Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"font-bold text-lg",children:null===r||void 0===r?void 0:r.productName})}),Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"text-sm text-neutral-300",children:null===r||void 0===r?void 0:r.manufacturerName})}),Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)("div",{className:"grid grid-cols-3 gap-6 mb-12",children:[Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Rate",value:null===r||void 0===r?void 0:r.productRatePerAreaValue,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Unit",value:null===r||void 0===r?void 0:r.productRatePerAreaUnit,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Applied Area",value:null===r||void 0===r?void 0:r.productAppliedAreaValue,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Total Product",value:null===r||void 0===r?void 0:r.totalProductValue,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Application Method",value:null===r||void 0===r?void 0:r.applicationMethod,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Target Pest",value:null!==(t=null===i||void 0===i?void 0:i.name)&&void 0!==t?t:"",disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Applied Area %",value:100*(null===r||void 0===r?void 0:r.coveragePercent),disabled:!0})})]})})]})};sW.defaultProps={open:!1,onClose:function(){}};var lW=sW,dW=function(e){var t=e.product,n=e.pests,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1];return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(lW,{open:i,onClose:function(){o(!1)},product:t,pests:n}),Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{width:"15rem",children:Object(y.jsxs)("span",{className:"flex flex-col",children:[Object(y.jsx)("span",{className:"w-64 pb-2 text-sm font-bold text-left truncate","data-testid":"product-name",children:t.productName}),Object(y.jsxs)("span",{className:"w-64 text-sm text-left text-gray-600 truncate","data-testid":"product-manufacturer",children:[t.custom&&Object(y.jsx)(y.Fragment,{children:"Custom"}),t.custom&&t.manufacturerName&&Object(y.jsx)(y.Fragment,{children:" \u2022 "}),t.manufacturerName]})]})}),Object(y.jsxs)(m.Table.Cell,{children:[t.productRatePerAreaValue," ",t.productRatePerAreaUnit]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:t.productAppliedAreaValue})," ",t.productAppliedAreaUnit]}),Object(y.jsxs)(m.Table.Cell,{children:[100*t.coveragePercent," %"]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:t.totalProductValue})," ",t.totalProductUnit]})]})]})},uW={name:function(e,t){return CH()([function(e){return e.productName.toLowerCase()}],e,t)},applicationOption:function(e,t){return CH()([function(e){return"".concat(e.productRatePerAreaValue,"_").concat(e.productRatePerAreaUnit)}],e,t)},appliedArea:function(e,t){return CH()([function(e){return"".concat(e.productAppliedAreaValue,"_").concat(e.productAppliedAreaUnit)}],e,t)},appliedAreaPercent:function(e,t){return CH()([function(e){return e.coveragePercent}],e,t)},totalProduct:function(e,t){return CH()([function(e){return"".concat(e.totalProductValue,"_").concat(e.totalProductUnit)}],e,t)}},bW=function(e){var t,n=e.recommendation,r=Object.values(Hk).find((function(e){return e.key===n.applicationStrategy})),c=J_("",0),i=c.pests,o=c.loading,s=Object(a.useState)(),l=Object(b.a)(s,1)[0],d=Object(a.useState)(),u=Object(b.a)(d,1)[0],j=Object(a.useState)([]),p=Object(b.a)(j,2),f=p[0],v=p[1],O=Object(a.useMemo)((function(){var e,t,a;return[{field:"name",title:"Product Name (".concat(null!==(e=null===(t=n.recommendationProductEntries)||void 0===t?void 0:t.length)&&void 0!==e?e:0,")"),sortable:!1},{field:"applicationOption",title:null!==(a=null===r||void 0===r?void 0:r.title)&&void 0!==a?a:"",sortable:!1},{field:"appliedArea",title:"Applied Area",sortable:!1},{field:"appliedAreaPercent",title:"Applied Area %",sortable:!1},{field:"totalProduct",title:"Total Product",sortable:!1},{field:"actions",title:"",sortable:!1}]}),[null===r||void 0===r?void 0:r.title,null===(t=n.recommendationProductEntries)||void 0===t?void 0:t.length]);return Object(a.useEffect)((function(){var e,t,a=uW[null!==l&&void 0!==l?l:""];a&&u?v(a(u,null!==(e=n.recommendationProductEntries)&&void 0!==e?e:[])):v(null!==(t=n.recommendationProductEntries)&&void 0!==t?t:[])}),[n.recommendationProductEntries,l,u]),Object(y.jsxs)("div",{"data-testid":"products-services-section",className:"mb-6",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsxs)("div",{"data-testid":"products-services-section-header",children:[Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Products & Services"}),Object(y.jsx)("div",{className:"text-sm text-neutral-600",children:"".concat(null===r||void 0===r?void 0:r.title," Application")})]})}),Object(y.jsxs)(m.Table,{children:[Object(y.jsx)(ks,{sortBy:null!==l&&void 0!==l?l:"",tableColumns:O}),o?Object(y.jsx)(rW,{numCells:O.length}):null===f||void 0===f?void 0:f.map((function(e,t){return Object(y.jsx)(dW,{product:e,pests:i},"".concat(e.productId,"_").concat(t))}))]})]})},jW=function(e){var t,n=e.id,r=Object(a.useContext)(ac),c=Object(b.a)(r,2),i=(c[0].loggedInUserOrgPermission,c[1],tW(n)),o=i.loading,s=i.recommendation,l=WF(),d=(l.tags,l.loading),u=(l.getTags,Object(a.useState)(!1)),j=Object(b.a)(u,2),p=j[0],f=(j[1],o||d||p);return Object(y.jsx)(y.Fragment,{children:f?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(y.Fragment,{children:Object(y.jsx)("div",{style:{minWidth:"min-content"},children:Object(y.jsx)("div",{className:"border rounded",children:Object(y.jsxs)("div",{className:"m-4","data-testid":"source-document-recommendation",children:[Object(y.jsx)(eW,{recommendation:s}),Object(y.jsx)("hr",{className:"my-6"}),Object(y.jsx)(nW,{applicators:null!==(t=null===s||void 0===s?void 0:s.applicators)&&void 0!==t?t:[]}),Object(y.jsx)("hr",{className:"my-6"}),Object(y.jsx)(oW,{recommendation:s}),Object(y.jsx)(bW,{recommendation:s}),Object(y.jsx)(aW,{notes:null===s||void 0===s?void 0:s.notes})]})})})})})},pW=function(e){var t=e.id,n=Object(a.useRef)(!0),r=Object(a.useContext)(ac),c=Object(b.a)(r,2),i=c[0].loggedInUserOrgPermission,o=i.role,s=i.financialAccess,l=void 0===s?"none":s,d=c[1],u=Object(a.useState)(""),j=Object(b.a)(u,2),p=j[0],f=j[1],v=Object(a.useState)([]),O=Object(b.a)(v,2)[1],h=Object(a.useState)(),x=Object(b.a)(h,2),g=x[0],C=(x[1],Object(a.useState)(null)),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(!0),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)([]),R=Object(b.a)(_,2),I=R[0],D=R[1],k=Object(a.useState)("--"),L=Object(b.a)(k,2),F=L[0],M=L[1],V=MB().cropSeasons,B=dE().companies;Object(a.useEffect)((function(){return function(){n.current=!1}}),[]);var U=function(e){return"Full control"===o&&"none"===l||"View Only"===o&&"none"===l?"":"Admin"===o||"View Only"===o||"Full control"===o&&"WRITE"===l||"Full control"===o&&"READ"===l?(t=e,Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:t})):"";var t},z={year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"},Z=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Gt.fetch(),a=n.promise,e.next=3,a.then((function(e){var n=e.data.results.filter((function(e){var n;return null===t||void 0===t||null===(n=t.flagIds)||void 0===n?void 0:n.includes(e.id)}));O(n),D(n||[])})).catch(Ae.default).catch((function(e){uc(e)}));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){Nn.createChildApi({action:"invoice/".concat(t)}).fetch().promise.then((function(e){var t=e.data;if(n.current){var a;if(S(t),Z(t),f(function(e){var t,n=[];return null===e||void 0===e||null===(t=e.cropSeasons)||void 0===t||t.forEach((function(e){return n.push(e.name)})),n}(t)),(null===B||void 0===B?void 0:B.length)>0&&""!==t.vendor)M(null===(a=B.filter((function(e){return e.id===t.vendor}))[0])||void 0===a?void 0:a.name);w(!1)}})).catch(Ae.default).catch((function(e){uc(d)(e),w(!1)}))}),[V,B,d,t]),Object(y.jsx)(y.Fragment,{children:E?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{className:"border rounded",children:[Object(y.jsx)("div",{className:"flex py-5 ml-4",children:Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)(m.Columns,{children:Object(y.jsxs)(m.Column,{width:"w-full",children:[Object(y.jsx)("div",{className:"text-2xl font-bold ml-4",children:"Invoice Details"}),Object(y.jsx)(Fl,{className:"mx-4 mt-4",header:"Invoice Name/Number",data:null===A||void 0===A?void 0:A.invoiceNumber,testId:"invNumber"})]})}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsx)(m.Column,{width:"w-120",children:Object(y.jsx)(Fl,{className:"mx-4 mt-4",header:"Invoice Date",data:(null===A||void 0===A?void 0:A.invoiceDateEpoch)>0?new Date(null===A||void 0===A?void 0:A.invoiceDateEpoch).toLocaleString("en-us",z):"--",testId:"invDate"})}),Object(y.jsx)(m.Column,{width:"w-56",children:Object(y.jsx)("div",{className:"flex items-center w-full h-full mt-4",children:Object(y.jsx)("svg",{width:"53",height:"16",viewBox:"0 0 53 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M52.7071 8.7071C53.0976 8.31658 53.0976 7.68341 52.7071 7.29289L46.3431 0.928928C45.9526 0.538404 45.3195 0.538404 44.9289 0.928928C44.5384 1.31945 44.5384 1.95262 44.9289 2.34314L50.5858 8L44.9289 13.6569C44.5384 14.0474 44.5384 14.6805 44.9289 15.0711C45.3195 15.4616 45.9526 15.4616 46.3431 15.0711L52.7071 8.7071ZM8.74228e-08 9L52 9L52 7L-8.74228e-08 7L8.74228e-08 9Z",fill:"#696F88"})})})}),Object(y.jsx)(m.Column,{width:"w-120",children:Object(y.jsx)(Fl,{className:"mx-4 mt-4",header:"Due Date",data:(null===A||void 0===A?void 0:A.invoiceDueDateEpoch)>0?new Date(null===A||void 0===A?void 0:A.invoiceDueDateEpoch).toLocaleString("en-us",z):"--",testId:"invDate"})})]}),Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{width:"w-full",children:Object(y.jsx)(Fl,{className:"mx-4 mt-4",header:"Company",data:F,testId:"vendorName"})})}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsxs)(m.Column,{width:"w-120",children:[Object(y.jsx)(Fl,{className:"mx-4 mt-4",header:"Crop Season"}),Object(y.jsx)("div",{className:"ml-3 mt-2",children:p&&Object(y.jsx)(m.TagCloud,{children:null===p||void 0===p?void 0:p.map((function(e){return Object(y.jsx)(m.Tag,{children:e})}))})})]}),Object(y.jsxs)(m.Column,{width:"w-full",children:[Object(y.jsx)(Fl,{className:"mx-4 mt-4",header:"Tags"}),Object(y.jsx)("div",{className:"ml-3 mt-2",children:(null===I||void 0===I?void 0:I.length)>0&&Object(y.jsx)(m.TagCloud,{children:null===I||void 0===I?void 0:I.map((function(e){return Object(y.jsx)(m.Tag,{color:e.color,children:e.name},e.id)}))})})]})]})]})}),Object(y.jsx)("div",{className:"mt-12 py-6 border-t ml-6 mr-6",children:Object(y.jsxs)("div",{className:"mt-12",children:[Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Products & Services"}),Object(y.jsx)("div",{className:"mt-12",children:(null===A||void 0===A?void 0:A.invoiceProducts)&&function(){var e,t,n=function(){};return Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsxs)(m.Table.Cell,{sortable:!0,sort:g,onClick:n,children:["Product Name (",null===A||void 0===A||null===(e=A.invoiceProducts)||void 0===e?void 0:e.length,")"]}),Object(y.jsx)(m.Table.Cell,{sortable:!0,sort:g,onClick:n,children:"Total Product"}),Object(y.jsx)(m.Table.Cell,{sortable:!0,sort:g,onClick:n,children:"Unit Price"}),Object(y.jsx)(m.Table.Cell,{sortable:!0,sort:g,onClick:n,children:"Total Price per Product"})]}),null===A||void 0===A||null===(t=A.invoiceProducts)||void 0===t?void 0:t.map((function(e){return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:e.productName}),Object(y.jsx)(m.Table.Cell,{children:"".concat(e.productDensity," ").concat(e.totalQuantityUnit)}),Object(y.jsx)(m.Table.Cell,{children:U(e.totalQuantityValue)}),Object(y.jsx)(m.Table.Cell,{children:U(e.totalCostValue)})]})}))]})}()})]})}),Object(y.jsxs)("div",{className:"mt-6 py-4 ml-6 mr-4",children:[Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Notes"}),Object(y.jsx)("div",{className:"mt-3 border p-4 h-64 mb-8 overflow-y-scroll",children:null===A||void 0===A?void 0:A.notes})]})]})})})},fW=function(e){var t=e.open,n=e.onClose,r=e.selected,c=e.setSourceDocs,i=e.setFieldTouched,o=Object(a.useState)([]),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(r),j=Object(b.a)(u,2),p=j[0],f=j[1],v=Object(a.useState)([]),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(null),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(!1),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)(!1),_=Object(b.a)(w,2),R=_[0],I=_[1],D=Object(a.useState)(!1),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)(!1),V=Object(b.a)(M,2),B=V[0],U=V[1],z=Object(a.useState)(null),Z=Object(b.a)(z,2),Y=Z[0],H=Z[1],G=Object(a.useState)(null),W=Object(b.a)(G,2),q=W[0],J=W[1],K=Object(a.useState)(null),Q=Object(b.a)(K,2),X=Q[0],$=Q[1],ee=zi(X,300),te=DG(),ae=te.plans,re=te.tasks,ce=te.invoices,ie=te.recommendations,oe=te.isLoading,se=function(e,t,n,a,r,c,i){return{type:e,id:t,name:n,numOfFields:a,docDate:r,productCount:c,amount:i}},le=(Object(a.useMemo)((function(){if(!oe){var e=ae.map((function(e){var t,n;return se("plan",e.id,e.name,null===(t=e.cropZones)||void 0===t?void 0:t.length,e.createdDateEpoch,null===(n=e.planProductEntries)||void 0===n?void 0:n.length,e.projectRevenue)})),t=re.map((function(e){return se("task",null===e||void 0===e?void 0:e.id,null===e||void 0===e?void 0:e.name,null===e||void 0===e?void 0:e.fieldCount,null===e||void 0===e?void 0:e.startDateEpoch,null===e||void 0===e?void 0:e.productCount,null===e||void 0===e?void 0:e.totalTaskCost)})),n=ie.map((function(e){var t,n,a;return se("rec",null===e||void 0===e?void 0:e.id,null===e||void 0===e?void 0:e.title,null===e||void 0===e||null===(t=e.cropZones)||void 0===t?void 0:t.length,new Date(null===e||void 0===e?void 0:e.createdOn).toLocaleDateString(),null===e||void 0===e||null===(n=e.recommendationProductEntries)||void 0===n?void 0:n.length,null===e||void 0===e||null===(a=e.recommendationProductEntries)||void 0===a?void 0:a.reduce((function(e,t){return e+t.totalProductValue}),0))})),a=ce.map((function(e){return se("inv",null===e||void 0===e?void 0:e.invoiceId,null===e||void 0===e?void 0:e.title,-1,null===e||void 0===e?void 0:e.invoiceDateEpoch,null===e||void 0===e?void 0:e.productCount,null===e||void 0===e?void 0:e.totalCost)})),r=e.concat(t.concat(n.concat(a)));d(r),x(r)}}),[oe]),function(e,t){var n=Object(ne.cloneDeep)(p),a=p.findIndex((function(t){return t.id===e}));a>=0?n.splice(a,1):n.push({id:e,name:t}),f(n)}),de=function(e){return ee?e.filter((function(e){return e.name.toLowerCase().includes(ee)||new Date(e.docDate).toLocaleDateString().includes(ee)||e.productCount.toString().includes(ee)||e.amount.toString().includes(ee)})):e};return Object(a.useEffect)((function(){var e=[];e=ee?h.filter((function(e){var t,n,a;return(null===(t=e.name)||void 0===t?void 0:t.toLowerCase().includes(ee.toLowerCase()))||new Date(e.docDate).toLocaleDateString().toString().includes(ee.toLowerCase())||(null===(n=e.productCount)||void 0===n?void 0:n.toString().includes(ee.toLowerCase()))||(null===(a=e.amount)||void 0===a?void 0:a.toString().includes(ee.toLowerCase()))})):P&&"clear"!==P?l.filter((function(e){return e.type===P})):l,x(e)}),[ee]),Object(y.jsx)(m.Modal,{size:"md",open:t,onClose:function(){return n(!1)},hideClose:!0,children:Object(y.jsxs)("div",{className:"h-half w-full py-8 overflow-y-hidden overflow-x-hidden overscroll-contain",children:[Object(y.jsxs)("div",{"data-testid":"source-document-modal",className:"my-6 ml-8",children:[Object(y.jsx)("div",{children:"Sources"}),Object(y.jsx)("div",{className:"flex flex-wrap",children:null===p||void 0===p?void 0:p.map((function(e){return Object(y.jsxs)("div",{className:"flex bg-gray-300 border rounded px-1 mr-2 mt-2","data-testid":"selected-source-document",children:[Object(y.jsx)("div",{className:"mr-2 text-sm",children:null===e||void 0===e?void 0:e.name}),Object(y.jsx)("button",{type:"button",onClick:function(){le(e.id,e.name)},children:Object(y.jsx)(Kx.a,{style:{fontSize:16,marginBottom:"5px"}})})]})}))})]}),Object(y.jsxs)("div",{className:"flex w-full ml-8",children:[Object(y.jsxs)("div",{className:"w-1/4",children:[Object(y.jsx)("div",{className:"mb-4",children:Object(y.jsx)(m.Input,{id:"search",name:"search",onChange:function(e){$(e.target.value)},placeholder:"Search..."})}),Object(y.jsx)("div",{className:"mb-4",children:Object(y.jsx)(m.Select,{id:"filter",items:[{key:"clear",value:"Clear filter"},{key:"plan",value:"Plans"},{key:"task",value:"Tasks"},{key:"rec",value:"Recommendations"},{key:"inv",value:"Invoices"}],placeholder:"Filter by type",value:P,onChange:function(e){var t=JSON.parse(e.target.value).key;A(t),function(e){"clear"===e&&A(null);var t=[];if("clear"===e)t=de(l);else{var n=l.filter((function(t){return t.type===e}));t=de(n)}x(t)}(t)}})}),Object(y.jsx)("div",{className:"h-80 overflow-y-scroll",children:oe?Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsx)(m.Spinner,{})}):Object(y.jsx)("div",{className:"h-auto",children:h.map((function(e){return Object(y.jsx)(FG,{document:e,isAdded:p&&(null===p||void 0===p?void 0:p.find((function(t){return t.id===e.id}))),documentClick:function(){return function(e,t){switch(e){case"plan":var n=ae.filter((function(e){return e.id===t}))[0];H(n),I(!1),F(!1),U(!1),E(!0);break;case"task":var a=re.filter((function(e){return e.id===t}))[0];H(a),E(!1),F(!1),U(!1),I(!0);break;case"rec":var r=ie.filter((function(e){return e.id===t}))[0];H(r),E(!1),I(!1),U(!1),F(!0);break;case"inv":var c=ce.filter((function(e){return e.invoiceId===t}))[0];H(c),E(!1),I(!1),F(!1),U(!0)}J(t)}(e.type,e.id)},addRemoveDoc:le,clickedId:q})}))})})]}),Object(y.jsx)("div",{className:"w-3/4 mr-8 overflow-y-scroll overscroll-contain",children:Object(y.jsxs)("div",{className:"w-full pl-4 pr-8 overscroll-contain",style:{height:"46rem"},children:[N&&Object(y.jsx)(ZG,{id:Y.id}),R&&Object(y.jsx)($G,{location:Y.cropSeasons,id:Y.id}),L&&Object(y.jsx)(jW,{id:Y.id}),B&&Object(y.jsx)(pW,{id:Y.invoiceId})]})})]}),Object(y.jsx)("div",{className:"w-full py-8 border-t",children:Object(y.jsxs)("div",{className:"flex float-right mr-8",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(m.Button,{onClick:function(){return n(!1)},children:"Cancel"})}),Object(y.jsx)(m.Button,{type:"primary",onClick:function(){i("Sources"),c(p),n(!1)},children:"Add"})]})})]})})};fW.defaultProps={selected:[],setSourceDocs:function(){},setFieldTouched:function(){}};var mW=fW,vW=n(810),OW=n.n(vW);function hW(e){return["st","nd","rd"][(((e<0?-e:e)+90)%100-10)%10-1]||"th"}var xW=function(e){var t=e.index,n=e.peopleLoading,a=e.ordinal,r=e.mappedPeopleNames,c=e.getDisabled,i=e.companiesLoaded,o=e.mappedPeopleCompanies,s=e.onButtonClick,l=function(){return Object(y.jsx)("span",{className:"absolute top-0 right-0 block w-12 mt-3 bg-neutral-200",style:{height:"2px",marginRight:"-4.5rem"}})};return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"relative ",children:[Object(y.jsx)(l,{}),n?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(Qi,{label:"".concat(t+1).concat(a(t+1)," Applicator"),control:m.Select,name:"applicators[".concat(t,"].personId"),items:r,disabled:c()})]}),Object(y.jsxs)("div",{className:"relative flex",children:[Object(y.jsx)("div",{className:"w-full",children:i?Object(y.jsx)(Qi,{label:"Company",control:m.Select,name:"applicators[".concat(t,"].companyId"),items:o,disabled:c()}):Object(y.jsx)(m.Spinner,{})}),Object(y.jsx)("div",{className:"ml-2",children:Object(y.jsx)(m.Button,{type:"outline",ghost:!0,onClick:s,icon:Object(y.jsx)(Kx.a,{}),disabled:c()})})]})]})};xW.defaultProps={getDisabled:function(){},onButtonClick:function(){}};var gW=xW,CW=function(e){var t=e.people,n=e.peopleLoading,a=e.companies,r=e.companiesLoaded,c=e.handleRemove,i=e.memberRole,o=e.memberFinancialAccess,s=e.showBufferInfo,l=e.setFieldTouchedParent,d=Object(Zi.h)().values,u=Object(Ru.a)(t?t.map((function(e){var t=e.licenseNumber?"".concat(e.name," (").concat(e.licenseNumber,", Exp. ").concat(e.expirationDate?Object(ya.a)(Date.parse(e.expirationDate),"MM/dd/yyyy"):"",")"):e.name;return{key:e.id,value:t}})):[],"value"),b=Object(Ru.a)(a?a.map((function(e){return{key:e.id,value:e.name}})):[],"value"),j=function(){return"Full control"===i&&("none"===o||"READ"===o)},p=function(e){return Object(y.jsx)(gW,{index:e,companiesLoaded:r,ordinal:hW,getDisabled:j,mappedPeopleCompanies:b,mappedPeopleNames:u,peopleLoading:n,onButtonClick:function(){l("Remove Applicator"),c(e)}},e)};return Object(y.jsxs)(y.Fragment,{children:[d.applicators&&d.applicators.length?d.applicators.map((function(e,t){return p(t)})):p(0),s&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex text-xs font-semibold tracking-tight text-blue-700 uppercase",children:[Object(y.jsx)(OW.a,{style:{fontSize:30},className:"mr-2"}),"Buffer Zone Data serves to instruct applicators and does not affect the total area or product totals of the final task"]}),Object(y.jsx)("div",{}),Object(y.jsx)(Qi,{label:"Buffer Zone (FT)",control:m.Input,name:"bufferZone"}),Object(y.jsx)(Qi,{label:"Buffer Reason",control:m.Select,name:"bufferReason",items:[{key:"Spray Drift",value:"Spray Drift"},{key:"Pollen Drift",value:"Pollen Drift"},{key:"Interim Aquatic",value:"Interim Aquatic"},{key:"Bee Protection",value:"Bee Protection "}]})]})]})};CW.defaultProps={people:[],companies:[],showBufferInfo:!0,setFieldTouchedParent:function(){}};var yW=CW,PW={extraTagsCount:0,extraTagsNames:[],tagsToDisplay:[]};var AW=function(e){var t=e.tags,n=e.selectedCropSeasons,r=Object(Zi.h)(),c=r.values,i=r.setFieldValue,o=r.setFieldTouched,s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)((null===t||void 0===t?void 0:t.filter((function(e){var t;return null===c||void 0===c||null===(t=c.flagIds)||void 0===t?void 0:t.find((function(t){return t===e.id}))})))||[]),p=Object(b.a)(j,2),f=p[0],v=p[1],O=Object(a.useState)(null===c||void 0===c?void 0:c.source),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)(PW),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)(PW),N=Object(b.a)(T,2),E=N[0],w=N[1],_=dE(),R=_.companies,D=_.loading,k=uE(),L=k.people,F=k.loading,M=Object(a.useState)(!1),V=Object(b.a)(M,2),B=V[0],U=V[1],z=Object(Ru.a)(L?L.map((function(e){return{key:e.id,value:e.name}})):[],"value"),Z=function(e,t,n){Object.assign({},t).push(Object(I.a)({},n))},H=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i("flagIds",t.map((function(e){return e.id}))),v(t);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){S(Af(x,42))}),[x]),Object(a.useEffect)((function(){w(Af(f,38))}),[f]),Object(a.useEffect)((function(){i("cropSeasonIds",n)}),[n,i]),Object(y.jsxs)("div",{className:"-mx-6",children:[B&&Object(y.jsx)(mW,{open:B,onClose:U,setSourceDocs:function(e){g(e),i("source",e)},selected:x,setFieldTouched:o}),Object(y.jsx)(l_,{open:d,close:function(){return u(!1)},name:null===c||void 0===c?void 0:c.name,selectedTags:null===f||void 0===f?void 0:f.reduce((function(e,t){return"".concat(e,",").concat(t.id)}),""),returnSelectedTags:H,setFieldTouchedParent:o}),Object(y.jsx)("div",{className:"text-2xl font-semibold mb-12",id:"recommendation-info",children:"Recommendation Info"}),Object(y.jsxs)("div",{className:"grid items-end grid-cols-3 gap-24 mb-12 gap-y-12","data-testid":"recommendation-info-content-1",children:[Object(y.jsx)(Qi,{label:"Recommendation ID *",control:m.Input,name:"name"}),Object(y.jsx)(Qi,{label:"Recommendation Number",control:m.Input,name:"number"}),Object(y.jsx)(Qi,{label:"Timing Event",control:m.Select,name:"timingEvent",items:[{key:"Pre-Plant",value:"Pre-Plant"},{key:"Planting",value:"Planting"},{key:"Growing",value:"Growing"},{key:"Harvest",value:"Harvest"},{key:"Storage",value:"Storage"},{key:"Annual",value:"Annual"}]}),Object(y.jsx)(Qi,{label:"Proposed Date *",control:m.DatePicker,name:"proposedDate",dateFormat:"F j,  Y",onChange:function(e){new Date(e.target.value[0]).valueOf()<=new Date(c.expirationDate).valueOf()&&(o("proposedDate"),i("proposedDate",e.target.value[0]))}}),Object(y.jsx)(Qi,{label:"Expiration Date *",control:m.DatePicker,name:"expirationDate",dateFormat:"F j,  Y",onChange:function(e){o("expirationDate"),i("expirationDate",e.target.value[0])}}),Object(y.jsxs)("div",{children:[Object(y.jsx)(m.Label,{absolute:!0,children:"Sources"}),A.extraTagsNames.length>0?Object(y.jsx)(fu,{position:"botton",ariaLabl:"Recommendation Sources",top:"1.5rem",msg:Object(y.jsx)(Pf,{extraTagsNames:A.extraTagsNames}),component:Object(y.jsx)(Nf,{setOpenTags:U,tags:x,displayTagsObject:A,viewKey:md,disabled:!1,prompt:"Add Sources"})}):Object(y.jsx)(Nf,{setOpenTags:U,tags:x,displayTagsObject:A,viewKey:md,disabled:!1,prompt:"Add Sources"})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)(m.Label,{absolute:!0,children:"Tags"}),E.extraTagsNames.length>0?Object(y.jsx)(fu,{position:"bottom",ariaLabel:"Task Tags",top:"1.5rem",msg:Object(y.jsx)(Pf,{extraTagsNames:E.extraTagsNames}),component:Object(y.jsx)(Nf,{setOpenTags:u,tags:f,displayTagsObject:E,viewKey:md,disabled:!1})}):Object(y.jsx)(Nf,{setOpenTags:u,tags:f,displayTagsObject:E,viewKey:md,disabled:!1})]}),Object(y.jsx)(Qi,{label:"Authorized By",control:m.Select,name:"authorizedBy",items:z,onChange:function(e){o("Authorized By");var t=JSON.parse(e.target.value),n=t.key,a=t.value;i("authorizedBy",n),i("authorizedByName",a)}}),Object(y.jsx)(Qi,{label:"Authorization Date *",control:m.DatePicker,name:"authorizationDate",dateFormat:"F j,  Y",onChange:function(e){o("authorizationDate"),i("authorizationDate",e.target.value[0])}})]}),Object(y.jsx)(Zi.c,{name:"applicators",render:function(e){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex justify-between gap-24 mb-12 gap-y-12",children:[Object(y.jsx)("div",{className:"text-2xl font-semibold",id:"applicators",children:"Applicator(s)"}),Object(y.jsx)("div",{children:Object(y.jsx)(m.Button,{type:"primary",ghost:!0,onClick:function(){o("Applicators"),Z(0,e,{id:"",company:""})},children:"Add Applicator"})})]}),Object(y.jsx)("div",{className:"grid items-end grid-cols-2 gap-24 mb-12 gap-y-12","data-testid":"applicators-content",children:Object(y.jsx)(yW,{people:L,peopleLoading:F,companies:R,companiesLoaded:!D,handleRemove:function(t){o("Applicators"),function(e,t,n){var a=Object.assign({},t);a.remove(n),0===c[e].length&&Z(0,a,"applicators"===e?{id:"",company:""}:{id:""})}("applicators",e,t)},showBufferInfo:!1})})]})}}),Object(y.jsx)("div",{className:"text-2xl font-semibold mb-4",id:"notes",children:"Notes"}),Object(y.jsx)(Qi,{control:m.TextArea,name:"notes"})]})},SW=function(){return Object(y.jsxs)("svg",{width:"166",height:"128",viewBox:"0 0 166 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M74.6387 110.975H91.9899L105.595 127.164H88.2435L74.6387 110.975ZM79.9197 113.438L89.3846 124.701H100.314L90.8487 113.438H79.9197Z",fill:"#73DC78"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.455078 0.491623L34.8691 14.4748H131.131L165.545 0.494863V99.7757L145.062 108.181V127.161H45.0461L33.8786 113.231L0.455078 99.785V0.491623ZM37.1951 113.438L46.2219 124.698H140.465L131.421 113.438L37.1951 113.438ZM133.998 112.721L142.608 123.44V109.189L133.998 112.721ZM130.784 110.975V30.5715L48.7885 30.5715L48.7884 110.973L130.784 110.975ZM46.3335 110.972L46.3336 29.8323L35.8574 18.787V110.972L46.3335 110.972ZM33.4025 16.5363V110.386L2.90995 98.1188V4.14655L33.4025 16.5363ZM37.4925 16.9379L48.0874 28.1084L130.784 28.1084V16.9379H37.4925ZM133.239 16.2759V110.371L163.09 98.1219V4.14948L133.239 16.2759Z",fill:"#00004B"})]})},TW=function(){return Object(y.jsxs)("div",{id:"empty-products-display",className:"w-full h-full mt-24 flex flex-col items-center justify-center",children:[Object(y.jsx)(SW,{}),Object(y.jsx)("span",{className:"mt-6 text-xl",children:"Select a product from the list to add it to this task"})]})},NW=Object.values(Hk),EW=function(e){var t,n,r=e.editProduct,c=e.removeProduct,i=e.setCustomProductCreated,o=e.customProductCreated,s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(null),p=Object(b.a)(j,2),f=p[0],v=p[1],O=Object(a.useState)(null),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)(Hk.byRatePerArea),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(Zi.h)(),N=T.values,E=T.setFieldTouched;Object(a.useEffect)((function(){var e=(null===N||void 0===N?void 0:N.applicationStrategy)===Hk.byRatePerTank.key?Hk.byRatePerTank.key:Hk.byRatePerArea.key;S(NW.find((function(t){return t.key===e})))}),[N.applicationStrategy]);Object(a.useEffect)((function(){var e;if((null===(e=N.products)||void 0===e?void 0:e.length)>0){var t=N.products.length-1,n=N.products[t];n.custom&&o&&(v(Object(I.a)(Object(I.a)({},n),{},{name:n.productName,manufacturer:n.manufacturerName,id:n.productId})),g(t),u(!0),i(!1))}}),[N.products,o]);var w=0;return Object(y.jsxs)("div",{className:"mt-8",children:[f&&Object(y.jsx)(uR,{open:d,product:f,onClose:function(){u(!1),r(f)},isEdit:!0,prodIndex:x}),Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{children:"Products (".concat(N.products.length,")")}),Object(y.jsx)(m.Table.Cell,{children:null===A||void 0===A?void 0:A.title}),Object(y.jsx)(m.Table.Cell,{children:"Applied Area"}),Object(y.jsx)(m.Table.Cell,{children:"Applied Area %"}),Object(y.jsx)(m.Table.Cell,{children:"Total Product"}),Object(y.jsx)(m.Table.Cell,{})]}),null===(t=N.products)||void 0===t?void 0:t.map((function(e,t){var n,a,r,i,o;return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"text-left",children:[Object(y.jsx)("div",{className:"font-bold",children:e.productName}),Object(y.jsx)("div",{className:"mt-2 text-neutral-300",children:e.manufacturerName})]})}),Object(y.jsx)(m.Table.Cell,{children:"Rate/Tank"===(null===A||void 0===A?void 0:A.title)?Object(y.jsxs)("div",{"data-testid":"cell-application-strategy",children:[Object(y.jsx)(yf,{roundedTo:2,children:e.ratePerTankValue||(r=null===N||void 0===N||null===(n=N.tankInformation)||void 0===n?void 0:n.tankCount,i=null===e||void 0===e?void 0:e.appliedAreaValue,o=null===e||void 0===e?void 0:e.ratePerAreaValue,w=r?(void 0===o?0:i*o)/r:0)})," ",Object(va.g)(null===e||void 0===e?void 0:e.ratePerTankUnit)]}):Object(y.jsxs)("div",{"data-testid":"cell-application-strategy",children:[Object(y.jsx)(yf,{roundedTo:2,children:void 0===e[A.value]?0:e[A.value]})," ",Object(va.g)(e[A.unit]||(null===e||void 0===e?void 0:e.ratePerTankUnit))]})}),Object(y.jsx)(m.Table.Cell,{children:"".concat(e.appliedAreaValue," ac")}),Object(y.jsx)(m.Table.Cell,{children:"".concat(e.coveragePercent,"%")}),Object(y.jsx)(m.Table.Cell,{children:"Rate/Tank"===(null===A||void 0===A?void 0:A.title)?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(yf,{roundedTo:2,children:(null===N||void 0===N||null===(a=N.tankInformation)||void 0===a?void 0:a.tankCount)*(e.ratePerTankValue||w)})," ",Object(va.g)(null===e||void 0===e?void 0:e.ratePerTankUnit)]}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(yf,{roundedTo:2,children:e.totalProductValue?e.totalProductValue:0})," ",Object(va.g)(e.totalProductUnit||(null===e||void 0===e?void 0:e.ratePerTankUnit))]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"pr-2 ",children:Object(y.jsx)(Wo,{onAction:function(n){return function(e,t,n){"edit"===e&&(v(Object(I.a)(Object(I.a)({},t),{},{name:t.productName,manufacturer:t.manufacturerName,id:t.productId})),g(n),u(!0)),"remove"===e&&(E("Removed Product"),c(t))}(n,e,t)},options:As})})})]})}))]}),!(null!==(n=N.products)&&void 0!==n&&n.length)&&Object(y.jsx)(TW,{})]})},wW=Object.values(Hk).map((function(e){return{key:e.key,value:e.title}})),_W={gallon:"num g\\al"},RW=["bag","box","bulk","bushel","can","crate","dispenser","kernal","kernel","load","package","plant","roll","seed","tablet","pound"],IW=function(e){var t,n,a,r,c,i,o,s=e.values,l=e.setFieldValue,d=e.setFieldTouched,u=function(e){return Math.round(100*(e+Number.EPSILON))/100},b=function(e){var t,n=[];null===s||void 0===s||null===(t=s.products)||void 0===t||t.forEach((function(t){var a=Object(ne.cloneDeep)(t);a.ratePerTankValue=u(function(e,t){var n=RW.includes(null===t||void 0===t?void 0:t.totalProductUnit),a=0;if(e>0){var r=(null===t||void 0===t?void 0:t.ratePerTankUnit)===(null===t||void 0===t?void 0:t.totalProductUnit),c=r?1:null===t||void 0===t?void 0:t.productDensity;if(n&&(a=r?(null===t||void 0===t?void 0:t.totalProductValue)/e:(null===t||void 0===t?void 0:t.totalProductValue)/c/e),!r){var i=(null===t||void 0===t?void 0:t.totalProductValue)/e;a=Object(K.getConvertUnitFromTo)(Number.parseFloat(i),null===t||void 0===t?void 0:t.totalProductUnit,null===t||void 0===t?void 0:t.ratePerTankUnit,t).Value}}return a}(e,t)),n.push(a)})),l("products",n)};return Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"w-1/4",children:[Object(y.jsx)("span",{className:"flex items-center text-neutral-600",style:{fontSize:"0.88vw"},"data-testid":"application-options-select",children:"Application Options"}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(Qi,{control:m.Select,name:"applicationStrategy",items:wW})})]}),Object(y.jsxs)("div",{className:"w-3/4 flex justify-between",children:[Object(y.jsxs)("div",{className:"",style:{paddingLeft:"2.5%"},children:[Object(y.jsx)("span",{className:"flex items-center text-neutral-600",style:{fontSize:"0.88vw"},"data-testid":"tank-size-input",children:"Tank Size"}),Object(y.jsx)(Qi,{control:m.Input,name:"tankInformation.tankSizeValue",value:null===s||void 0===s||null===(t=s.tankInformation)||void 0===t?void 0:t.tankSizeValue,onChange:function(e){return function(e){var t,n=0;if(Number.parseFloat(e)&&(n=Number(e)*Number(null===s||void 0===s||null===(t=s.tankInformation)||void 0===t?void 0:t.tankCount),l("tankInformation.totalCarrierValue",u(n))),Number.parseFloat(null===s||void 0===s?void 0:s.totalAreaValue)>0){var a=n/(null===s||void 0===s?void 0:s.totalAreaValue);l("tankInformation.carrierPerAreaValue",u(a))}l("tankInformation.tankSizeValue",e)}(e.target.value||0)},onBlur:function(){d("Tank Size")},disabled:0===(null===s||void 0===s?void 0:s.totalAreaValue),imask:{mask:_W[null===s||void 0===s||null===(n=s.tankInformation)||void 0===n?void 0:n.tankSizeUnit]||"num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})]}),Object(y.jsxs)("div",{className:"",style:{paddingLeft:"2.5%"},children:[Object(y.jsx)("span",{className:"flex items-center text-neutral-600",style:{fontSize:"0.88vw"},"data-testid":"tank-count-input",children:"Tank Count"}),Object(y.jsx)(Qi,{control:m.Input,name:"tankInformation.tankCount",value:null===s||void 0===s||null===(a=s.tankInformation)||void 0===a?void 0:a.tankCount,onChange:function(e){return function(e){var t=0;if(""!==e&&"0"!==e){var n,a;if(Number.parseFloat(null===s||void 0===s||null===(n=s.tankInformation)||void 0===n?void 0:n.tankSizeValue)&&(t=Number(null===s||void 0===s||null===(a=s.tankInformation)||void 0===a?void 0:a.tankSizeValue)*Number(e),l("tankInformation.totalCarrierValue",u(t))),Number.parseFloat(null===s||void 0===s?void 0:s.totalAreaValue)>0){var r=t/(null===s||void 0===s?void 0:s.totalAreaValue);l("tankInformation.carrierPerAreaValue",u(r))}}l("tankInformation.tankCount",e),b(e)}(e.target.value||0)},onBlur:function(){d("Tank Count Input")},disabled:0===(null===s||void 0===s?void 0:s.totalAreaValue),imask:{mask:"num t\\anks",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})]}),Object(y.jsxs)("div",{className:"",style:{paddingLeft:"2.5%"},children:[Object(y.jsx)("span",{className:"flex items-center text-neutral-600",style:{fontSize:"0.88vw"},"data-testid":"total-carrier-input",children:"Total Carrier"}),Object(y.jsx)(Qi,{control:m.Input,name:"tankInformation.totalCarrierValue",value:null===s||void 0===s||null===(r=s.tankInformation)||void 0===r?void 0:r.totalCarrierValue,onChange:function(e){return function(e){var t;if(Number.parseFloat(null===s||void 0===s||null===(t=s.tankInformation)||void 0===t?void 0:t.tankSizeValue)>0){var n,a=Number(e)/Number(null===s||void 0===s||null===(n=s.tankInformation)||void 0===n?void 0:n.tankSizeValue);l("tankInformation.tankCount",u(a)),b(a)}if(Number.parseFloat(null===s||void 0===s?void 0:s.totalAreaValue)){var r=Number(e)/Number(null===s||void 0===s?void 0:s.totalAreaValue);l("tankInformation.carrierPerAreaValue",u(r))}l("tankInformation.totalCarrierValue",e)}(e.target.value||0)},onBlur:function(){d("Total Carrier Input")},disabled:0===(null===s||void 0===s?void 0:s.totalAreaValue),imask:{mask:_W[null===s||void 0===s||null===(c=s.tankInformation)||void 0===c?void 0:c.totalCarrierUnit]||"num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})]}),Object(y.jsxs)("div",{className:"",style:{paddingLeft:"2.5%"},children:[Object(y.jsx)("span",{className:"flex items-center text-neutral-600",style:{fontSize:"0.88vw"},"data-testid":"carrier-by-area-input",children:"Carrier per Area"}),Object(y.jsx)(Qi,{control:m.Input,name:"tankInformation.carrierPerAreaValue",value:null===s||void 0===s||null===(i=s.tankInformation)||void 0===i?void 0:i.carrierPerAreaValue,onChange:function(e){return function(e){var t,n=0;if(Number.parseFloat(e)&&(n=Number(e)*Number(null===s||void 0===s?void 0:s.totalAreaValue),l("tankInformation.totalCarrierValue",u(n))),Number.parseFloat(null===s||void 0===s||null===(t=s.tankInformation)||void 0===t?void 0:t.tankSizeValue)>0){var a,r=n/Number(null===s||void 0===s||null===(a=s.tankInformation)||void 0===a?void 0:a.tankSizeValue);l("tankInformation.tankCount",u(r)),b(r)}l("tankInformation.carrierPerAreaValue",e)}(e.target.value||0)},onBlur:function(){d("Carrier by Area Input")},disabled:0===(null===s||void 0===s?void 0:s.totalAreaValue),imask:{mask:_W[null===s||void 0===s||null===(o=s.tankInformation)||void 0===o?void 0:o.carrierPerAreaUnit]||"num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}}})]})]})]})};IW.defaultProps={setFieldTouched:function(){}};var DW=IW;var kW=function(e){var t=e.selectedCropseasons,n=Object(Zi.h)(),r=n.setFieldValue,c=n.values,i=n.setFieldTouched,o=Object(a.useContext)(ac),s=Object(b.a)(o,1)[0].loggedInUserOrgPermission,l=s.role,d=s.financialAccess,u=Object(a.useState)(!1),j=Object(b.a)(u,2),p=j[0],f=j[1];return Object(a.useEffect)((function(){r("cropSeasonIds",t)}),[t,r]),Object(y.jsxs)("div",{className:"h-full flex justify-between",children:[Object(y.jsx)("div",{className:"w-3/12 mt-16",children:Object(y.jsx)(OR,{memberRole:l,memberFinancialAccess:d,setCustomProductCreated:f})}),Object(y.jsxs)("div",{className:"ml-4 flex-grow",children:[Object(y.jsx)(DW,{values:c,setFieldValue:r,setFieldTouched:i}),Object(y.jsx)(EW,{editProduct:function(){r(null===c||void 0===c?void 0:c.products,null===c||void 0===c?void 0:c.products)},removeProduct:function(e){var t=null===c||void 0===c?void 0:c.products;t.splice(t.findIndex((function(t){return t.productId===e.productId})),1),r(null===c||void 0===c?void 0:c.products,t)},setCustomProductCreated:f,customProductCreated:p})]})]})},LW=function(e,t){return Math.round(100*(e/t*100+Number.EPSILON))/100},FW=function(e){var t,n=e.property,a=e.readonly,r=e.onAreaReportedChange,c=e.onAreaAppliedChange,i=e.onZoneCoveragePercentChange;return Object(y.jsxs)("div",{className:"ml-6 mb-24",children:[Object(y.jsxs)("div",{className:"mb-6",children:[Object(y.jsx)("div",{className:"text-xl font-bold",children:null===n||void 0===n?void 0:n.fieldName}),Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:null===n||void 0===n?void 0:n.name})]}),Object(y.jsxs)("div",{className:"flex mb-6",children:[Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Area"}),Object(y.jsxs)("div",{className:"text-xl",children:[null===n||void 0===n?void 0:n.originalAcres," ac"]})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Crop"}),Object(y.jsx)("div",{className:"text-xl ",children:null===n||void 0===n||null===(t=n.crop)||void 0===t?void 0:t.name})]})]}),Object(y.jsx)("div",{className:"mb-12",children:Object(y.jsxs)(Qi,{control:m.RadioButtonGroup,name:"areaReported",selected:null===n||void 0===n?void 0:n.areaType,onChange:r,disabled:a,children:[Object(y.jsx)(Qi,{value:"reported",id:"reported",name:"areaReported",control:m.RadioButtonGroup.RadioButton,disabled:a,children:Object(y.jsxs)("span",{className:"truncate w-48",children:["Reported Area (",function(e){return e&&0!==e?"".concat(e," ac"):" "}(null===n||void 0===n?void 0:n.reportedArea),")"]})}),Object(y.jsx)(Qi,{value:"boundary",id:"boundary",name:"areaReported",control:m.RadioButtonGroup.RadioButton,disabled:a,children:Object(y.jsxs)("span",{className:"truncate w-48",children:["Boundary Area (",null===n||void 0===n?void 0:n.boundaryArea," ac)"]})})]})}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(Qi,{label:"Area Applied",control:m.Input,value:null===n||void 0===n?void 0:n.areaValue,onBlur:c,name:"zoneAcres",imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,scale:2,signed:!1,thousandsSeparator:"",padFractionalZeros:!1,normalizeZeros:!0,radix:".",mapToRadix:[","],min:0}}},disabled:a})}),Object(y.jsx)(Qi,{label:"Coverage %",control:m.Input,name:"zoneCoveragePercent",value:null===n||void 0===n?void 0:n.coveragePct,onBlur:i,imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,signed:!1,thousandsSeparator:"",padFractionalZeros:!1,normalizeZeros:!1,radix:".",mapToRadix:[","],min:0}}},disabled:a})]})]})};FW.defaultProps={readonly:!1,onAreaReportedChange:function(){},onAreaAppliedChange:function(){},onZoneCoveragePercentChange:function(){}};var MW=FW;var VW=function(e){var t,n,r,c,i,o,s,l=e.propertyLandingPageData,d=e.loading,u=e.fieldsAndAreasGeoJSONCollection,j=e.selectedCropseasons,p=Object(Zi.h)(),f=p.values,O=p.setFieldValue,h=p.setFieldTouched,x=Object(a.useState)(null===(t=f.properties)||void 0===t?void 0:t.map((function(e){return e.cropZoneId}))),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(null),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(null),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)(!0),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)(!0),V=Object(b.a)(M,2),B=V[0],U=V[1],z=nF(),Z=z.originalTotalArea,Y=z.setProperties,H=Object(a.useState)(null===(n=f.properties)||void 0===n?void 0:n.map((function(e){return e.cropZoneId}))),G=Object(b.a)(H,1)[0],W=Object(a.useState)(null!==(r=aF(l))&&void 0!==r?r:[]),q=Object(b.a)(W,2),J=q[0],Q=q[1],X=Object(a.useState)(null!==(c=rF(l,G))&&void 0!==c?c:[]),$=Object(b.a)(X,2),ee=$[0],te=$[1],ne=Object(a.useState)(f.properties.length),ae=Object(b.a)(ne,1)[0],re=Mh(ee,f.cropSeasonIds);Object(a.useEffect)((function(){te(rF(l,G)),Q(aF(l))}),[l]);var ce=Object(a.useMemo)((function(){var e=[];return(null===re||void 0===re?void 0:re.length)>0&&re.forEach((function(t){t.fields.length>0&&t.fields.forEach((function(n){n.cropzones.forEach((function(a){var r,c=f.properties.find((function(e){return e.cropZoneId===a.id}));null!==C&&void 0!==C&&C.includes(a.id)&&e.push(Object(I.a)(Object(I.a)({},a),{},{farmId:(null===c||void 0===c?void 0:c.farmId)||t.id,fieldName:n.name,features:null===(r=u.features)||void 0===r?void 0:r.filter((function(e){return n.id===e.properties.id})),areaValue:null===c||void 0===c?void 0:c.areaValue,coveragePct:c?f.coveragePercent:100}))}))}))})),e}),[C,d]);Object(a.useEffect)((function(){null!==f&&void 0!==f&&f.cropSeasonIds||(U(!0),R("Please select a cropseason on the Details Tab before selecting a property."),F(!0))}),[]),Object(a.useEffect)((function(){var e=[],t=ce.map((function(e){return e.id})),n=f.properties.filter((function(e){return t.includes(e.cropZoneId)})).filter((function(e){return!0===e.hydrated})),a=n.map((function(e){return e.cropZoneId})).filter((function(e){return t.includes(e)})),r=function(e){var t=Math.round(100*(e.boundaryArea+Number.EPSILON))/100;return e.areaValue?t=e.areaValue:e.reportedArea>0&&(t=Math.round(100*(e.reportedArea+Number.EPSILON))/100),t};ce.filter((function(e){return!a.includes(e.id)})).forEach((function(t){var n,a=null===(n=ce.find((function(e){return e.id===t.id})))||void 0===n?void 0:n.areaValue,c=t.reportedArea||t.boundaryArea,i=t.reportedArea>0?t.reportedArea:t.boundaryArea,o=a||i,s={farmId:t.farmId,cropZoneId:t.id,areaUnit:"acres",originalAcres:Math.round(100*(c+Number.EPSILON))/100,areaValue:r(t),coveragePct:Math.round(o/i*1e4)/100,boundaryArea:Math.round(100*(t.boundaryArea+Number.EPSILON))/100,reportedArea:Math.round(100*(t.reportedArea+Number.EPSILON))/100,areaType:t.areaType||"reported",name:t.name,crop:t.crop,features:t.features,fieldName:t.fieldName,hydrated:!0};e.push(s)}));var c=[].concat(Object(v.a)(n.slice()),e);O("properties",c),Y(c)}),[ce,O]),Object(a.useEffect)((function(){ae!==C.length&&h("FFT Changed"),null!==f&&void 0!==f&&f.cropSeasonIds&&U(!1);var e=f.properties.reduce((function(e,t){return e+t.areaValue}),0);O("totalApplied",Math.round(100*(e+Number.EPSILON))/100),O("totalAreaValue",Math.round(100*(e+Number.EPSILON))/100)}),[f.properties]);var ie=function(e){P(e),0===e.length&&(O("totalApplied",0),O("totalAreaValue",0),O("coveragePercent",100),O("properties",[]))};return Object(a.useEffect)((function(){var e=f.products.map((function(e){var t=(null===f||void 0===f?void 0:f.totalAreaValue)*e.coveragePercent/100,n=t*e.ratePerAreaValue,a=K.specialCaseUnit.includes(e.totalProductUnit),r=Object(K.unitsAreSame)(e.ratePerAreaValue,e.totalProductUnit),c=e.density,i=Object(K.unitsAreSame)(e.ratePerAreaUnit,e.stdpackageunit),o=0;return o=a?Object(K.calcSpecialCase)(r,n,1,c,i):Object(K.calcConversions)(n,e.ratePerAreaUnit,e.totalProductUnit,r,e),Object(I.a)(Object(I.a)({},e),{},{appliedAreaValue:t,totalProductValue:o})}));O("products",e)}),[null===f||void 0===f?void 0:f.totalAreaValue,O]),Object(a.useEffect)((function(){O("cropSeasonIds",j)}),[j,O]),Object(a.useEffect)((function(){var e=LW(f.totalApplied,Z);e!==Number(f.coveragePercent)&&!Number.isNaN(e)&&Number.isFinite(e)&&O("coveragePercent",e)}),[null===f||void 0===f?void 0:f.totalApplied,Z,O,null===f||void 0===f?void 0:f.coveragePercent]),Object(y.jsxs)("div",{className:"-mx-2 -mr-6",children:[L?Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){F(!1)},children:_}):null,Object(y.jsxs)("div",{className:"flex justify-end mb-6",children:[Object(y.jsx)("div",{className:"mr-6",children:Object(y.jsx)(Qi,{label:"Total Applied",control:m.Input,name:"totalApplied",disabled:0===f.properties.length||0===f.coveragePercent,onBlur:function(e){if(h("Total Applied"),O("totalApplied",Number(e.target.value)),Number(e.target.value)!==Number(e.target.defaultValue)){var t=LW(Number(e.target.value),Z);O("properties",Object(tF.a)(t,LW(Number(e.target.defaultValue),Z),f.properties)),O("coveragePercent",t)}},imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,scale:2,signed:!1,thousandsSeparator:"",padFractionalZeros:!1,normalizeZeros:!0,radix:".",mapToRadix:[","],min:0}}}})}),Object(y.jsx)(Qi,{label:"Coverage %",control:m.Input,name:"coveragePercent",disabled:0===f.properties.length,onBlur:function(e){h("Coverage"),O("coveragePercent",Number(e.target.value)),Number(e.target.value)!==Number(e.target.defaultValue)&&O("properties",Object(tF.a)(Number(e.target.value),Number(e.target.defaultValue),f.properties))},imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,scale:2,signed:!1,thousandsSeparator:"",padFractionalZeros:!1,normalizeZeros:!1,radix:".",mapToRadix:[","],min:0}}}})]}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"w-1/4 pr-8",children:[Object(y.jsx)("div",{className:"mb-3",children:Object(y.jsx)(Qi,{style:{whiteSpace:"nowrap"},control:m.Select,name:"propertyFilter",placeholder:"Filter by","data-testid":"propertyFilter",items:[{key:"Farm",value:"Farm"},{key:"Season",value:"Season"},{key:"Crop",value:"Crop"},{key:"Tag",value:"Tag"}]})}),Object(y.jsx)("div",{className:"mb-3",children:Object(y.jsx)(Qi,{control:m.Select,name:"propertiesGroupBy",items:[{key:"property",value:"Group By Farms"},{key:"crop",value:"Group By Crop"}],onChange:function(e){!function(e){var t=JSON.parse(e.target.value);O("propertiesGroupBy",t.key)}(e)}})}),Object(y.jsx)("div",{className:"mb-3",children:d?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(y.Fragment,{children:"property"===f.propertiesGroupBy?Object(y.jsx)(Zx,{data:re,onChange:ie,value:f.properties,cropZonesChecked:C,setCropZonesChecked:P,disabled:d||B}):Object(y.jsx)(Hx,{data:re,onChange:ie,value:f.properties,cropZonesChecked:C,setCropZonesChecked:P,disabled:d||B})})})]}),Object(y.jsx)("div",{className:"flex flex-col w-3/4",children:Object(y.jsxs)("div",{className:"flex flex-col h-full",children:[Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsxs)(m.Table.Cell,{width:"30%",children:["Fields (",null===f||void 0===f||null===(i=f.properties)||void 0===i?void 0:i.length,")"]}),Object(y.jsx)(m.Table.Cell,{children:"Crops"}),Object(y.jsx)(m.Table.Cell,{children:"Area"}),Object(y.jsx)(m.Table.Cell,{children:"Coverage %"}),Object(y.jsx)(m.Table.Cell,{})]}),null===(o=f.properties)||void 0===o?void 0:o.map((function(e){var t,n,a=null!==(t=e.features)&&void 0!==t&&t[0]?[Ej(e.features[0])]:void 0,r=-1!==J.indexOf(e.cropZoneId);return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)(Kp,{id:"field-card-icon",features:a}),Object(y.jsxs)("div",{className:"flex flex-col justify-start leading-5 text-left",children:[Object(y.jsxs)("span",{className:"font-bold text-neutral-1000",children:[e.fieldName,r?" (archived) ":""]}),Object(y.jsx)("span",{style:{color:"#707374"},children:e.name})]})]})}),Object(y.jsx)(m.Table.Cell,{children:null===(n=e.crop)||void 0===n?void 0:n.name}),Object(y.jsxs)(m.Table.Cell,{children:[e.areaValue," ",e.areaUnit]}),Object(y.jsx)(m.Table.Cell,{children:null===e||void 0===e?void 0:e.coveragePct}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(Wo,{onAction:function(t){return function(e,t){({edit:function(){return N(t)},remove:function(){return ie((function(e){return e.filter((function(e){return e!==t.cropZoneId}))}))}})[e]()}(t,e)},options:As})})]})}))]}),!(null!==(s=f.properties)&&void 0!==s&&s.length)&&Object(y.jsxs)("div",{className:"flex flex-col items-center self-stretch justify-center h-full py-32 border border-t-0",children:[Object(y.jsx)("img",{src:Of,alt:"No properties illustration"}),Object(y.jsx)("p",{children:"Select one or more fields from the list to add it to this Recommendation"})]})]})})]}),Object(y.jsx)(y.Fragment,{children:T&&Object(y.jsx)(Zi.c,{name:"properties",children:function(e){var t=e.replace;return Object(y.jsx)(m.SimpleModal,{confirmLabel:"Save",open:T,onConfirm:function(){h("Field"),t(f.properties.map((function(e){return e.cropZoneId})).indexOf(null===T||void 0===T?void 0:T.cropZoneId),T),N(null)},close:function(){return N(null)},children:Object(y.jsx)(MW,{property:T,readonly:!1,onAreaReportedChange:function(e){var t="boundary"===e?null===T||void 0===T?void 0:T.boundaryArea:null===T||void 0===T?void 0:T.reportedArea;N(Object(I.a)(Object(I.a)({},T),{},{areaType:e,areaValue:t,coveragePct:"boundary"===T.areaType?LW(t,null===T||void 0===T?void 0:T.boundaryArea):LW(t,null===T||void 0===T?void 0:T.reportedArea)}))},onAreaAppliedChange:function(e){var t=Number(e.target.value);N(Object(I.a)(Object(I.a)({},T),{},{areaValue:t,coveragePct:"boundary"===T.areaType?LW(t,T.boundaryArea):LW(t,T.reportedArea)}))},onZoneCoveragePercentChange:function(e){var t,n,a=Number(e.target.value);N(Object(I.a)(Object(I.a)({},T),{},{coveragePct:a,areaValue:(t=a,n=null===T||void 0===T?void 0:T.originalAcres,Math.round(100*(t/100*n+Number.EPSILON))/100)}))}})})}})})]})},BW=n(834);function UW(e){var t=e.proposedDate,n=e.numProducts,a=e.totalApplied;return Object(y.jsxs)("div",{className:"flex justify-start",children:[Object(y.jsxs)("div",{className:"mr-12","data-testid":"editViewProposedDate",children:[Object(y.jsx)("div",{className:"text-sm text-gray-600",children:"Proposed Date"}),Object(y.jsx)("div",{className:"text-2xl text-charcoal",children:Object(BW.a)(t)?Object(ya.a)(t,"MMM d, yyyy"):null})]}),Object(y.jsxs)("div",{className:"mr-8","data-testid":"editViewProducts",children:[Object(y.jsx)("div",{className:"text-sm text-gray-600",children:"Products"}),Object(y.jsx)("div",{className:"text-2xl text-charcoal",children:n})]}),Object(y.jsxs)("div",{"data-testid":"editViewAcres",children:[Object(y.jsx)("div",{className:"text-sm text-gray-600",children:"Acres"}),Object(y.jsx)("div",{className:"text-2xl text-charcoal",children:a})]})]})}UW.defaultProps={proposedDate:void 0,numProducts:0,totalApplied:0};var zW=UW;var ZW=function(e){var t,n=e.isSaving,a=e.onSubmit,r=Object(p.h)(),c=Object(Zi.f)("proposedDate"),i=Object(b.a)(c,1)[0].value,o=Object(Zi.f)("products"),s=Object(b.a)(o,1)[0].value,l=void 0===s?[]:s,d=Object(Zi.f)("totalApplied"),u=Object(b.a)(d,1)[0].value,j=void 0===u?0:u;return Object(y.jsxs)("div",{"data-testid":"recommendations-top-header",className:"flex items-center justify-between p-3",children:[Object(y.jsx)(zW,{proposedDate:i,numProducts:null!==(t=null===l||void 0===l?void 0:l.length)&&void 0!==t?t:0,totalApplied:j}),Object(y.jsxs)("div",{className:"flex justify-end flex-1",children:[Object(y.jsx)("div",{children:Object(y.jsx)(m.Button,{type:"primary",ghost:!0,onClick:function(){return r.push(Cc.recommendations)},id:"cancelRecommendation",children:"Cancel"})}),Object(y.jsx)("div",{className:"ml-4",children:Object(y.jsx)(m.Button,{id:"saveRecommendation",onClick:a,type:"primary",ariaLabel:"save",loading:n,disabled:n,children:"Save"})})]}),Object(y.jsx)(Sm,{"data-testid":"navigation-block"})]})};var YW=function(e){var t=Object(a.useState)(zn(e,{urlVersion:"/v1"}));return Object(b.a)(t,1)[0]};var HW=function(e,t){var n=YW("recommendation"),r=Object(a.useContext)(ac),c=Object(b.a)(r,2)[1],i=Object(a.useState)(void 0),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(!0),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(!1),m=Object(b.a)(f,2),v=m[0],O=m[1];return Object(a.useEffect)((function(){var t;if("create"===e||"convert"===e)p(!1);else{var a=n.fetch(e),r=a.promise,i=a.cancel;t=i,r.then((function(e){var t=e.data;l(t)})).catch(Ae.default).catch(uc(c)).finally((function(){return p(!1)}))}return function(){var e;return null===(e=t)||void 0===e?void 0:e()}}),[c,e,n]),{isSaving:v,saveRecommendation:function(a){return O(!0),("create"===e||"convert"===e||"duplicate"===t?n.create(a):n.update(e,a)).promise.catch(Ae.default).catch(uc(c)).finally((function(){O(!1)}))},recommendation:s,isLoading:j}};function GW(e){return WW.apply(this,arguments)}function WW(){return(WW=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.saveRecommendation,a=t.setRedirect,r=t.setToastRenderContents,c=t.values,e.next=3,n(c);case 3:e.sent&&(r("Save Succeeded"),a(Cc.recommendations));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function qW(){return(qW=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.saveRecommendation,a=t.setRedirect,r=t.setToastRenderContents,c=t.values,e.next=3,GW({saveRecommendation:n,setRedirect:a,setToastRenderContents:r,values:Wk.formValuesToApi(c)});case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var JW=function(){var e=Object(a.useState)(),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(0),i=Object(b.a)(c,1)[0],o=Object(a.useState)(null),s=Object(b.a)(o,2)[1],l=Object(a.useContext)(ac),d=Object(b.a)(l,2),u=d[0],j=d[1],f=WF().tags,O=We().user,h=Object(p.j)().id,x=Object(p.h)(),g=Object(a.useState)("duplicate"===h?u.planToConvert.id:h),C=Object(b.a)(g,1)[0],P=Object(a.useState)(JSON.parse(localStorage.getItem("selectedCropSeasons"))||null),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useContext)(we),E=HW(C,h),w=E.isSaving,_=E.saveRecommendation,R=E.isLoading,D=E.recommendation,k=rv({fetchType:xm,isCacheOn:!0}),L=k.dataSorted,F=k.loading,M=k.fieldsAndAreasGeoJSONCollection,V=k.reloadData;Object(a.useEffect)((function(){V()}),[]);var B=function(e,t,n){var a={id:t,name:n};return e&&"function"===typeof e[Symbol.iterator]?[].concat(Object(v.a)(e),[a]):[a]};return Object(a.useEffect)((function(){if(!R)if("convert"===h)r(Object(I.a)({},u.planToConvert));else if("duplicate"===h)r(Object(I.a)(Object(I.a)({},Wk.apiToFormValues(D,O.name)),{},{id:"",name:"",source:B(null===D||void 0===D?void 0:D.source,null===D||void 0===D?void 0:D.id,null===D||void 0===D?void 0:D.title)}));else{var e=Wk.apiToFormValues(D,O.name);r(e)}}),[h,u,R,D,O.name]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(lo,{disabled:"create"===h||h.length>0,hideCropSeasonDropdown:!1,onCropSeasonSelect:function(){V(),T(JSON.parse(localStorage.getItem("selectedCropSeasons"))||null)},children:[Object(y.jsx)(lo.Item,{title:"Recommendations",value:"All Recommendations",to:Cc.recommendations}),Object(y.jsx)(lo.Item,{title:"Recommendations",value:"".concat(function(){switch(h){case"create":case"duplicate":case"convert":return"New";default:return"Edit"}}()," Recommendation"),isLast:!0})]}),n&&Object(y.jsx)(Zi.e,{initialValues:n,validate:function(e){var t={};return null!==e&&void 0!==e&&e.name||(t.name="ID is required"),t},onSubmit:function(e){null!==e&&void 0!==e&&e.name?null!==e&&void 0!==e&&e.cropSeasonIds&&0!==e.cropSeasonIds.length?null!==e&&void 0!==e&&e.products&&0!==e.products.length?("create"===h&&N.sendEventToAmplitude(N.events.epic.Recommendations.createRecommendations),function(e){qW.apply(this,arguments)}({saveRecommendation:_,setRedirect:x.push,setToastRenderContents:s,values:e})):j({type:sr,payload:{type:sc,message:"Cannot create a recommendation without products"}}):j({type:sr,payload:{type:sc,message:"It is necessary to select a Crop Season"}}):j({type:sr,payload:{type:sc,message:"Recommendation ID can not be empty"}})},children:function(e){var t=e.errors,a=e.values,r=e.handleChange,c=e.handleBlur,o=e.submitForm,s=e.setFieldValue;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(ZW,{isSaving:w,onSubmit:o}),R||!n?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)("div",{"data-testid":"tabs-content",className:"px-6 pt-4 -mx-4 bg-white",style:{height:"calc(100% - 96px)"},children:Object(y.jsx)("div",{className:"h-full p-10 mt-3",children:Object(y.jsxs)(m.Tabs,{activeTab:i,children:[Object(y.jsx)(m.Tabs.Tab,{label:"Details",children:Object(y.jsx)(AW,{tags:f,selectedCropSeasons:S})}),Object(y.jsx)(m.Tabs.Tab,{label:"Properties",children:Object(y.jsx)(VW,{propertyLandingPageData:L,loading:F,fieldsAndAreasGeoJSONCollection:M,selectedCropseasons:S})}),Object(y.jsx)(m.Tabs.Tab,{label:"Products",children:Object(y.jsx)(kW,{errors:t,handleChange:r,handleBlur:c,setFieldValue:s,values:a,selectedCropseasons:S})})]})})})]})}})]})},KW=function(e){var t,n=e.property,r=e.allCropZones,c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Math.round(100*((null===n||void 0===n?void 0:n.boundaryArea)+Number.EPSILON))/100,d=Math.round(100*((null===n||void 0===n?void 0:n.reportedArea)+Number.EPSILON))/100,u=function(e,t){if(e&&(null===t||void 0===t?void 0:t.length)>0){var n=null===t||void 0===t?void 0:t.find((function(t){return(null===t||void 0===t?void 0:t.id)===(null===e||void 0===e?void 0:e.cropZoneId)}));return 0===(null===n||void 0===n?void 0:n.reportedArea)?Math.round(100*((null===e||void 0===e?void 0:e.areaValue)/(null===n||void 0===n?void 0:n.boundaryArea)+Number.EPSILON)):Math.round(100*((null===e||void 0===e?void 0:e.areaValue)/(null===n||void 0===n?void 0:n.reportedArea)+Number.EPSILON))}return!1},j=null!==n&&void 0!==n&&n.areaValue||(null===n||void 0===n?void 0:n.reportedArea)>0?d:l,p=null!==n&&void 0!==n&&null!==(t=n.features)&&void 0!==t&&t[0]?[Ej(n.features[0])]:void 0;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(m.SimpleModal,{confirmLabel:"Ok",open:o,onConfirm:function(){s(!1)},close:function(){s(!1)},children:Object(y.jsx)(Zi.e,{children:Object(y.jsx)(MW,{readonly:!0,property:{areaType:null===n||void 0===n?void 0:n.areaType,areaValue:null===n||void 0===n?void 0:n.areaValue,boundaryArea:l,coveragePct:u(n,r)||"",crop:{name:null===n||void 0===n?void 0:n.cropName},fieldName:null===n||void 0===n?void 0:n.fieldName,originalAcres:j,reportedArea:d}})})}),Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{width:"4rem",children:Object(y.jsx)(Kp,{id:"view-rec-card-icon",features:p})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex flex-col justify-start leading-5 text-left",children:[Object(y.jsx)("span",{className:"font-bold text-neutral-1000",children:null===n||void 0===n?void 0:n.fieldName}),Object(y.jsx)("span",{style:{color:"#707374"},children:null===n||void 0===n?void 0:n.cropZoneName})]})}),Object(y.jsx)(m.Table.Cell,{children:null===n||void 0===n?void 0:n.cropName}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:null===n||void 0===n?void 0:n.areaValue})," ",null===n||void 0===n?void 0:n.areaUnit]}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)(yf,{roundedTo:2,className:"mr-6",children:u(n,r)||""})," %"]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{"data-testid":"product-table-view-button",className:"mr-8 absolute right-0 flex-none w-10","data-html2canvas-ignore":!0,children:Object(y.jsx)(m.Button,{type:"link-default",onClick:function(){return s(!0)},children:"View"})})})]})]})};KW.defaultProps={allCropZones:[]};var QW=KW,XW={fields:function(e,t){return CH()([function(e){return e.fieldName}],e,t)},crops:function(e,t){return CH()([function(e){return e.cropName}],e,t)},area:function(e,t){return CH()([function(e){return"".concat(e.areaValue,"_").concat(e.areaUnit)}],e,t)},coveragePercent:function(e,t){return CH()([function(e){return e.coveragePercent}],e,t)}},$W=function(e){var t,n=e.recommendation,r=Object(a.useState)([]),c=Object(b.a)(r,2),i=c[0],o=c[1],s=rv({fetchType:xm,isCacheOn:!0}),l=s.dataSorted,d=s.fieldsAndAreasGeoJSONCollection,u=s.loading,j=s.fieldsLoading,p=s.reloadData,f=Object(a.useState)(),v=Object(b.a)(f,1)[0],O=Object(a.useState)([]),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)(),P=Object(b.a)(C,1)[0],A=Object(a.useState)(null!==i&&void 0!==i?i:[]),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useMemo)((function(){var e,t;return[{field:"icons",title:"",sortable:!1},{field:"fields",title:"Fields (".concat(null!==(e=null===(t=n.cropZones)||void 0===t?void 0:t.length)&&void 0!==e?e:0,")"),sortable:!1},{field:"crops",title:"Crops",sortable:!1},{field:"area",title:"Area",sortable:!1},{field:"coveragePercent",title:"Coverage %",sortable:!1},{field:"actions",title:"",sortable:!1}]}),[null===(t=n.cropZones)||void 0===t?void 0:t.length]);return Object(a.useEffect)((function(){var e;if((null===l||void 0===l||null===(e=l.properties)||void 0===e?void 0:e.length)>0){var t=function(e,t,n){var a,r=[];return null===e||void 0===e||null===(a=e.properties)||void 0===a||a.map((function(e){var a;null===(a=e.fields)||void 0===a||a.map((function(a){var c;null===(c=a.cropzones)||void 0===c||c.map((function(c){var i;null===t||void 0===t||null===(i=t.cropZones)||void 0===i||i.map((function(i){if(c.id===i.cropZoneIdValue){var o,s,l={farmId:e.id,cropZoneId:c.id,fieldName:a.name,cropZoneName:c.name,cropName:null===(o=c.crop)||void 0===o?void 0:o.name,areaValue:i.areaValue,areaUnit:i.areaUnit,boundaryArea:c.boundaryArea,reportedArea:c.reportedArea,coveragePercent:t.coveragePercent/100,features:null===(s=n.features)||void 0===s?void 0:s.filter((function(e){return a.id===e.properties.id}))};r.push(l)}}))}))}))})),r}(l,n,d);g(Fh(null===l||void 0===l?void 0:l.properties)),o(t)}}),[l,n,d,j]),Object(a.useEffect)((function(){p()}),[]),Object(a.useEffect)((function(){var e=XW[null!==v&&void 0!==v?v:""];N(e&&P?e(P,i):i)}),[i,v,P]),Object(y.jsxs)("div",{"data-testid":"properties-section",className:"mb-6",id:"rec-pagebreaker-1",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Properties"})}),Object(y.jsxs)(m.Table,{children:[Object(y.jsx)(ks,{sortBy:null!==v&&void 0!==v?v:"",tableColumns:E}),j&&u?Object(y.jsx)(rW,{numCells:E.length}):T.map((function(e){return Object(y.jsx)(QW,{property:e,allCropZones:x},e.cropZoneId)}))]})]})},eq=function(e){var t,n=e.open,a=e.onClose,r=e.product,c=e.pests,i=r.targetPestId?c.find((function(e){return e.pestid===r.targetPestId})):void 0;return Object(y.jsxs)(m.SimpleModal,{open:n,close:a,onConfirm:a,size:"sm",children:[Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"font-bold text-lg",children:null===r||void 0===r?void 0:r.productName})}),Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"text-sm text-neutral-300",children:null===r||void 0===r?void 0:r.manufacturerName})}),Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)("div",{className:"grid grid-cols-3 gap-6 mb-12",children:[Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Rate",value:null===r||void 0===r?void 0:r.productRatePerAreaValue,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{style:{whiteSpace:"nowrap"},label:"Unit",value:null===r||void 0===r?void 0:r.productRatePerAreaUnit,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Applied Area",value:null===r||void 0===r?void 0:r.productAppliedAreaValue,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Total Product",value:null===r||void 0===r?void 0:r.totalProductValue,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Application Method",value:null===r||void 0===r?void 0:r.applicationMethod,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Target Pest",value:null!==(t=null===i||void 0===i?void 0:i.name)&&void 0!==t?t:"",disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Applied Area %",value:100*(null===r||void 0===r?void 0:r.coveragePercent),disabled:!0})})]})})]})};eq.defaultProps={open:!1,onClose:function(){}};var tq=eq,nq=function(e){var t=e.product,n=e.pests,r=e.applicationOption,c=e.tankInformation,i=Object(a.useState)(!1),o=Object(b.a)(i,2),s=o[0],l=o[1];return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(tq,{open:s,onClose:function(){l(!1)},product:t,pests:n}),Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("span",{className:"flex flex-col",children:[Object(y.jsx)("span",{className:"pb-2 text-sm font-bold text-left truncate","data-testid":"product-name",children:t.productName}),Object(y.jsxs)("span",{className:"text-sm text-left text-gray-600 truncate pb-2","data-testid":"product-manufacturer",children:[t.custom&&Object(y.jsx)(y.Fragment,{children:"Custom"}),t.custom&&t.manufacturerName&&Object(y.jsx)(y.Fragment,{children:" \u2022 "}),t.manufacturerName]})]})}),Object(y.jsx)(m.Table.Cell,{children:"ratePerAreaValue"===r||"totalProductValue"===r?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:t.productRatePerAreaValue})," ",Object(va.g)(null===t||void 0===t?void 0:t.productRatePerAreaUnit)]}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:t.productRatePerTankValue})," ",Object(va.g)(null===t||void 0===t?void 0:t.productRatePerTankUnit)]})}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:t.productAppliedAreaValue})," ",t.productAppliedAreaUnit]}),Object(y.jsxs)(m.Table.Cell,{children:[100*t.coveragePercent," %"]}),Object(y.jsx)(m.Table.Cell,{children:"ratePerTankValue"===r?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:(null===c||void 0===c?void 0:c.tankCount)*(null===t||void 0===t?void 0:t.productRatePerTankValue)})," ",Object(va.g)(null===t||void 0===t?void 0:t.productRatePerTankUnit)]}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(yf,{roundedTo:"2",children:t.totalProductValue})," ",Object(va.g)(null===t||void 0===t?void 0:t.totalProductUnit)]})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{"data-testid":"product-table-view-button",className:"mr-8 absolute right-0 flex-none w-10","data-html2canvas-ignore":!0,children:Object(y.jsx)(m.Button,{type:"link-default",onClick:function(){return l(!0)},children:"View"})})})]})]})},aq={name:function(e,t){return CH()([function(e){return e.productName.toLowerCase()}],e,t)},applicationOption:function(e,t){return CH()([function(e){return"".concat(e.productRatePerAreaValue,"_").concat(e.productRatePerAreaUnit)}],e,t)},appliedArea:function(e,t){return CH()([function(e){return"".concat(e.productAppliedAreaValue,"_").concat(e.productAppliedAreaUnit)}],e,t)},appliedAreaPercent:function(e,t){return CH()([function(e){return e.coveragePercent}],e,t)},totalProduct:function(e,t){return CH()([function(e){return"".concat(e.totalProductValue,"_").concat(e.totalProductUnit)}],e,t)}},rq=function(e){var t,n,r=e.recommendation,c=[{key:"ratePerAreaValue",value:"By Rate/Area Application",display:"ByRatePerArea"},{key:"totalProductValue",value:"By Total Product Application",display:"ByTotalProduct"},{key:"ratePerTankValue",value:"By Rate/Tank Application",display:"ByRatePerTank"}],i=J_("",0),o=i.pests,s=i.loading,l=Object(a.useState)(),d=Object(b.a)(l,1)[0],u=Object(a.useState)((n=r.applicationStrategy)===c[0].display?c[0].key:n===c[1].display?c[1].key:n===c[2].display?c[2].key:c[0].key),j=Object(b.a)(u,2),p=j[0],f=j[1],v=Object(a.useState)(),O=Object(b.a)(v,1)[0],h=Object(a.useState)([]),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useMemo)((function(){var e,t,n;return[{field:"name",title:"Product Name (".concat(null!==(e=null===(t=r.recommendationProductEntries)||void 0===t?void 0:t.length)&&void 0!==e?e:0,")"),sortable:!1},{field:"applicationOption",title:null!==(n="ratePerTankValue"===p?"Rate/Tank":"Rate/Area")&&void 0!==n?n:"",sortable:!1},{field:"appliedArea",title:"Applied Area",sortable:!1},{field:"appliedAreaPercent",title:"Applied Area %",sortable:!1},{field:"totalProduct",title:"Total Product",sortable:!1},{field:"actions",title:"",sortable:!1}]}),[p,null===(t=r.recommendationProductEntries)||void 0===t?void 0:t.length]);Object(a.useEffect)((function(){var e,t,n=aq[null!==d&&void 0!==d?d:""];n&&O?C(n(O,null!==(e=r.recommendationProductEntries)&&void 0!==e?e:[])):C(null!==(t=r.recommendationProductEntries)&&void 0!==t?t:[])}),[r.recommendationProductEntries,d,O]);var A=go((function(e,t){f(t)}),xo);return Object(y.jsxs)("div",{"data-testid":"products-services-section",className:"mb-6",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsxs)("div",{"data-testid":"products-services-section-header",children:[Object(y.jsx)("div",{className:"text-2xl font-bold mb-2",children:"Products & Services"}),Object(y.jsx)("div",{className:"text-sm text-neutral-600",children:Object(y.jsx)(m.Select,{value:p,onChange:A,items:c})})]})}),Object(y.jsxs)(m.Table,{children:[Object(y.jsx)(ks,{sortBy:null!==d&&void 0!==d?d:"",tableColumns:P}),s?Object(y.jsx)(rW,{numCells:P.length}):null===g||void 0===g?void 0:g.map((function(e,t){return Object(y.jsx)(nq,{product:e,pests:o,applicationOption:p,tankInformation:null===r||void 0===r?void 0:r.tankInformation},"".concat(e.productId,"_").concat(t))}))]})]})},cq=function(){var e,t=Object(p.h)(),n=Object(p.j)().id,r=Object(a.useContext)(ac),c=Object(b.a)(r,2)[1],i=tW(n),o=i.loading,s=i.recommendation,l=i.setRecommendation,d=AH(),u=d.convertToTask,j=d.isLoading,f=WF(),v=f.tags,O=f.loading,h=f.getTags,x=Object(a.useState)({open:!1,id:null}),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(!1),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)([]),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)(!1),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)(null),V=Object(b.a)(M,2)[1],B=Object(a.useContext)(we),U=vG(),z=U.shareOrPrint,Z=U.downloadingPDF,H=U.filterMenuItems,W=function(){var e=Object(Y.a)(G.a.mark((function e(n){var a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=(null===(a=s.flagIds)||void 0===a?void 0:a.length)>0&&void 0!==s.flagIds&&s.flagIds.map((function(e){return v.find((function(t){return t.id===e}))})),{edit:function(){t.push({pathname:"".concat(Cc.recommendations,"/").concat(s.id)})},tag:function(){var e;R((null===(e=s.flagIds)||void 0===e?void 0:e.length)>0||void 0!==s.flagIds?r:[]),N(!0)},duplicate:function(){},shareOrPrint:z,convertTask:function(){u(s)},delete:function(){P({id:s.id,open:!0})}}[n](s.id);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),q=function(){var e=Object(Y.a)(G.a.mark((function e(){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return B.sendEventToAmplitude(B.events.epic.Recommendations.deleteRecommendations),n=tn.delete(C.id),a=n.promise,e.next=4,a.then((function(){t.replace(Cc.recommendations)}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),J=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return F(!0),n=Object(I.a)(Object(I.a)({},s),{},{flagIds:t.map((function(e){return e.id}))}),e.next=4,tn.update(s.id,n);case 4:return a=e.sent,r=a.promise,e.next=8,r.then((function(e){l(e.data),R(t),h()})).catch(Ae.default).catch((function(e){var t,n,a,r;null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.validationErrors?V("Error saving task: ".concat(e.response.data.message)):null!==(a=e.response)&&void 0!==a&&null!==(r=a.data)&&void 0!==r&&r.displayErrorMessage?V(e.response.data.displayErrorMessage):uc(c)(e)}));case 8:F(!1);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),K=o||O||L||j;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)(lo,{disabled:!0,children:[Object(y.jsx)(lo.Item,{title:"Recommendations",value:"All Recommendations",to:Cc.recommendations}),Object(y.jsx)(lo.Item,{title:"Recommendation",value:(null===s||void 0===s?void 0:s.title)||"View Recommendation",isLast:!0})]}),K?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{id:"rec-view",children:[Object(y.jsx)("div",{className:"px-5",children:Object(y.jsxs)(m.Columns,{alignVertically:!0,children:[Object(y.jsx)(m.Column,{grow:!0,children:Object(y.jsx)(zW,{proposedDate:new Date(s.proposedDate),numProducts:s.recommendationProductEntries.length,totalApplied:s.cropZones.reduce((function(e,t){return e+t.areaValue}),0).toFixed(2)})}),Object(y.jsx)(m.Column,{children:Object(y.jsx)("div",{className:"flex justify-end",children:Z?Object(y.jsx)(m.Spinner,{size:"sm"}):Object(y.jsx)(Wo,{onAction:W,options:H(Ts)})})})]})}),Object(y.jsxs)("div",{style:{minWidth:"min-content"},children:[Object(y.jsx)(ib,{open:C.open,itemType:"Recommendation",onCancel:function(){return P({open:!1,id:null})},onDelete:q}),Object(y.jsx)(l_,{open:T,close:function(){N(!1)},name:s.title,selectedTags:_.length>0?null===_||void 0===_?void 0:_.reduce((function(e,t){return"".concat(e,",").concat(t.id)}),""):"",returnSelectedTags:function(e){J(e)}}),Object(y.jsx)(ll,{children:Object(y.jsxs)("div",{className:"m-4",children:[Object(y.jsx)(eW,{recommendation:s}),Object(y.jsx)("hr",{className:"my-6"}),Object(y.jsx)(nW,{applicators:null!==(e=s.applicators)&&void 0!==e?e:[]}),Object(y.jsx)("hr",{className:"my-6"}),Object(y.jsx)($W,{recommendation:s}),Object(y.jsx)(rq,{recommendation:s}),Object(y.jsx)(aW,{notes:s.notes})]})})]})]})]})},iq=[{id:"recommendations",key:"recommendations",label:"Recommendations",path:Cc.recommendations,exact:!0,secure:!0,disabled:!1,component:_G,icon:ed,nav:"leftNav"},{id:"recommendation",key:"recommendation",path:"".concat(Cc.recommendations,"/:id"),exact:!0,secure:!0,disabled:!1,component:JW,minPermissions:{minAllowedRole:$a}},{id:"recommendationView",key:"recommendationView",path:"".concat(Cc.recommendations,"/:id/view"),exact:!0,secure:!0,disabled:!1,component:cq}],oq=n(535),sq=n(811),lq=(n.p,n.p,"NAVBAR_OPEN"),dq="SET_ACTIVE_REPORT",uq=function(e,t){switch(t.type){case lq:return Object(I.a)(Object(I.a)({},e),{},{navbarOpen:t.payload});case dq:return Object(I.a)(Object(I.a)({},e),{},{activeReport:t.payload});default:return e}},bq={navbarOpen:!0},jq=Object(a.createContext)(bq),pq=function(e){var t=e.children,n=Object(a.useReducer)(uq,bq),r=Object(b.a)(n,2),c=r[0],i=r[1];return Object(y.jsx)(jq.Provider,{value:{state:c,dispatch:i,toggleNavbar:function(){i({type:lq,payload:!c.navbarOpen})},setActiveReport:function(e){i({type:dq,payload:e})},getActiveReport:function(){return c.activeReport}},children:t})};pq.defaultProps={children:null};var fq=pq,mq=function(e){return Object(y.jsx)(m.Icon,{icon:e?"chevron-up":"chevron-down",color:"#fff"})},vq=function(e,t){return e===t?"border-l-2 border-r-4 rounded-2xl border-white":"ml-2"},Oq=function(e){var t=e.title,n=e.options,r=e.showOptions,c=e.selectedIdx,i=e.handleSelectedItem,o=Object(a.useState)(r),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(mq(r)),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useRef)();return Object(a.useEffect)((function(){f(mq(l)),wU(m.current,l)}),[l]),Object(y.jsxs)("div",{className:"mb-3",children:[Object(y.jsxs)(pu,{className:"flex justify-between items-center mb-3 px-5",onClick:function(){return d(!l)},children:[Object(y.jsx)("span",{className:"text-white",children:t}),p]}),Object(y.jsx)("div",{className:"transition-all duration-200 overflow-y-hidden",ref:m,"data-testid":"collapsible-options",children:Object(y.jsx)("ul",{className:"text-white",children:null===n||void 0===n?void 0:n.map((function(e){return Object(y.jsx)(pu,{onClick:function(){return i(e.key)},children:Object(y.jsxs)("li",{"data-testid":e.key,className:"py-2 flex items-center pl-3 cursor-pointer h-12 transition-all ease-in-out duration-200 ".concat((t=e.key,n=c,t===n?"bg-collapsible-selected-option font-semibold":"hover:bg-collapsible-hovered-option")),children:[Object(y.jsx)("span",{className:"".concat(vq(e.key,c)," inline-block h-8")}),Object(y.jsx)("span",{className:"inline-block px-5",children:e.label})]})},e.key);var t,n}))})})]})};Oq.defaultProps={showOptions:!1,selectedIdx:-1,handleSelectedItem:function(){}};var hq,xq=Oq,gq=function(e){return null!==e&&void 0!==e&&e.includes(",")?e.split(","):e},Cq="Applied Products",yq="Fields",Pq="FSA",Aq="Excel",Sq="Products",Tq="Properties",Nq="Production Records",Eq="Yield and Profitability",wq="By Day",_q="By Field",Rq="By Crop Details",Iq="Crop Layout",Dq="Crop Zone Info",kq="Details",Lq="Dicamba",Fq="Excel Report",Mq="Fertilizer Report",Vq="FSA Report",Bq="Inventory Summary",Uq="Notice of Application",zq="Pesticide Use",Zq="PHI Report",Yq="Plans Summary",Hq="Profitability",Gq="Print Tasks",Wq="Print Recommendations",qq="Print Invoices",Jq="Print Plans",Kq="Regulatory",Qq="REI Report",Xq="Summary",$q="Yield Production",eJ=function(e,t,n){return e.find((function(e){return e.category===t&&e.subType===n}))},tJ=function(){var e=Object(f.useFlags)(),t=e.feReportOptionByField,n=e.feReportOptionAppliedProductsByCropDetails,a=e.feReportOptionAppliedProductsByDay,r=e.feReportOptionAppliedProductsDetails,c=e.feReportOptionAppliedProductsDicamba,i=e.feReportOptionAppliedProductsFertilizerByCrop,o=e.feReportOptionPesticideUsage,s=e.feReportOptionAppliedProductsPhi,l=e.feReportOptionAppliedProductsRei,d=e.feReportOptionAppliedProductsSummary,u=e.feReportOptionCropLayout,b=e.feReportOptionFsa,j=e.feReportOptionInventorySummary,p=e.feReportOptionNoticeOfApplication,m=e.feReportOptionPlansSummary,v=e.feReportOptionPrintInvoices,O=e.feReportOptionPrintPlans,h=e.feReportOptionPrintRecommendations,x=e.feReportOptionPrintTasks,g=e.feReportOptionPropertiesByCropZoneInfo,C=e.feReportOptionRegulatory,y=e.feReportOptionYieldAndProfitabilityByProfitability,P=e.feReportOptionExcelReport,A=e.feReportOptionYieldAndProfitabilityYieldProduction;return[{name:"Applied Products By Field",featureFlag:t,category:Cq,subType:_q,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!0,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("074dc791-d670-4e7c-8162-3fe6f8bdba14"),reportId:gq("db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb")}},{name:"Applied Products By Crop Layout",featureFlag:n,category:Cq,subType:Rq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!0,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("30e84bd7-da03-4427-b925-41568e41af5e"),reportId:gq("b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9")}},{name:"Applied Products By Day",featureFlag:a,category:Cq,subType:wq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!0,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("cfa6afe9-2968-40fa-b872-5ab053d3d0f9"),reportId:gq("20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11")}},{name:"Applied Products Details",featureFlag:r,category:Cq,subType:kq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!0,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("9accfbe8-b383-493d-988a-316b8c8e0f48"),reportId:gq("0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f")}},{name:"Applied Products Dicamba",featureFlag:c,category:Cq,subType:Lq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!0,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("73e5cab0-c5e7-40e1-80a1-28192b8439e6"),reportId:gq("c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f")}},{name:"Fertilizer Report",featureFlag:i,category:Cq,subType:Mq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("be8bba95-88b7-4404-8419-b9cfa38d548d"),reportId:gq("78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58")}},{name:"Pesticide Use",featureFlag:o,category:Cq,subType:zq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!0,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("c478bd25-04f1-49f9-91b1-e38f83a4ec73"),reportId:gq("a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5")}},{name:"PHI Report",featureFlag:s,category:Cq,subType:Zq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!1,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("b0621b3e-fd42-4af0-9f4b-11f6a311de33"),reportId:gq("fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578")}},{name:"Applied Products Regulatory",featureFlag:C,category:Cq,subType:Kq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!0,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("4b60ac54-3c5e-4955-ad33-306aadfc3ed8"),reportId:gq("ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a")}},{name:"Applied Products REI Report",featureFlag:l,category:Cq,subType:Qq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!0,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("58179a3d-155d-4b32-8ce3-08769217d401"),reportId:gq("48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2")}},{name:"Applied Products Summary",featureFlag:d,category:Cq,subType:Xq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!0,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("0e68c788-75bd-486b-8be7-b6aeddd20681"),reportId:gq("03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b")}},{name:"Excel Report",featureFlag:P,category:Aq,subType:Fq,formConfig:{showCropSeasons:!0,showDateRange:!0,showExcelAlert:!0,showProperties:!0,showProducts:!1,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("82564c52-53b2-4c7e-ae34-2056d32557be"),reportId:gq("b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54")}},{name:"Crop Layout",featureFlag:u,category:Tq,subType:Iq,formConfig:{showCropSeasons:!0,showDateRange:!1,showProperties:!0,showProducts:!1},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("20f29a73-5dca-4fa5-9032-55ecef7d2720"),reportId:gq("f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb")}},{name:"FSA Report",featureFlag:b,category:Pq,subType:Vq,formConfig:{showCropSeasons:!0,showDateRange:!1,showProperties:!0,showProducts:!1},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq(Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).REACT_APP_FSA_REPORT_DATASET_ID),reportId:gq(Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).REACT_APP_FSA_REPORT_EMBED_REPORT_ID)}},{name:"Notice of Application",featureFlag:p,category:Cq,subType:Uq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!0,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("e804c2c2-be11-4cc0-8b81-476f6b46bc03"),reportId:gq("98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f")}},{name:"Print Invoices",featureFlag:v,category:Nq,subType:qq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!1,showProducts:!1,showTimezoneOffset:!0,showPrintAlert:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("babdf04e-fccb-4a96-948d-b2f98f3e33f5"),reportId:gq("0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e")}},{name:"Print Plans",featureFlag:O,category:Nq,subType:Jq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!1,showProducts:!1,showTimezoneOffset:!0,showPrintAlert:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("e3dc8556-4438-4683-8709-87ffa8dc7572"),reportId:gq("0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c")}},{name:"Print Recommendations",featureFlag:h,category:Nq,subType:Wq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!1,showProducts:!1,showTimezoneOffset:!0,showPrintAlert:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("adf5b1f8-e73a-4108-810f-394a06910d93"),reportId:gq("3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251")}},{name:"Print Tasks",featureFlag:x,category:Nq,subType:Gq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!1,showProducts:!1,showTimezoneOffset:!0,showPrintAlert:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("a9b0e341-65ff-43e7-8796-90b5c0d57a18"),reportId:gq("e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38")}},{name:"Inventory Summary",featureFlag:j,category:Sq,subType:Bq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!1,showProducts:!0,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("d9236def-f34c-4d10-a236-ed841cc1000e"),reportId:gq("7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7")}},{name:"Products Plan Summary",featureFlag:m,category:Sq,subType:Yq,formConfig:{showCropSeasons:!0,showDateRange:!1,showProperties:!1,showProducts:!1,showPlans:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677"),reportId:gq("40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb")}},{name:"Profitability",featureFlag:y,category:Eq,subType:Hq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!1,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("aefba8c4-d6f1-46cd-874f-beec2aedb266"),reportId:gq("8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b")}},{name:"Crop Zone Info",featureFlag:g,category:Tq,subType:Dq,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!1,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("da9d4f3a-b7ba-41b3-98fb-367a0beaa06b"),reportId:gq("b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca")}},{name:"Yield Production",featureFlag:A,category:Eq,subType:$q,formConfig:{showCropSeasons:!0,showDateRange:!0,showProperties:!0,showProducts:!1,showTimezoneOffset:!0},reportConfig:{isPaginated:!0,groupId:gq("aa609fd5-6c0e-48c7-8203-1a0f9964b4fa"),datasetId:gq("89a2a80f-3bd7-4901-bda6-f342db4cc693"),reportId:gq("4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c")}}]},nJ={position:"fixed",border:"1px solid #0092E4",borderRadius:"50%",height:"24px",width:"24px"},aJ=function(e){var t=e.setActiveReport,n=e.onChange,r=Object(a.useContext)(jq),c=r.toggleNavbar,i=r.setActiveReport,o=r.getActiveReport,s=r.state.navbarOpen,l=o(),d=tJ(),u=eJ(d,Tq,Iq),j=Object(a.useState)("w-0"),p=Object(b.a)(j,2),f=p[0],v=p[1],O=Object(a.useState)("opacity-0"),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)(u.name),P=Object(b.a)(C,2),A=P[0],S=P[1];Object(a.useEffect)((function(){v(s?"w-60":"w-5"),g(s?"opacity-100":"opacity-0")}),[s]),Object(a.useEffect)((function(){i(u),t(u),S(u.name)}),[]);var T=function(e){var a=function(e,t){return e.find((function(e){return e.name===t}))}(d,e);l.category===a.category&&l.subType===a.subType||(n(),S(u),S(e),i(a),t(a))},N=d.reduce((function(e,t){return e[t.category]?e:Object(I.a)(Object(I.a)({},e),{},Object(et.a)({},t.category,function(e,t){return e.filter((function(e){return e.category===t}))}(d,t.category).filter((function(e){return e.featureFlag}))))}),{}),E=Object.keys(N).filter((function(e){return N[e].length})).sort((function(e,t){return e.localeCompare(t)})).map((function(e){return Object(y.jsx)(xq,{title:e,options:N[e].map((function(e){return{key:e.name,label:e.subType.toUpperCase()}})),selectedIdx:A,handleSelectedItem:function(e){return T(e)},showOptions:!0},e)})),w=Object(a.useMemo)((function(){return s?od:sd}),[s]);return Object(y.jsxs)("div",{className:"".concat(f," sticky top-0 transition-width duration-200 overflow-x-hidden overflow-y-auto"),style:{backgroundColor:"#363948"},"data-testid":"sidemenu-container",children:[Object(y.jsx)("div",{className:"w-full h-12 relative",children:Object(y.jsx)("div",{className:"absolute top-3 right-3",children:Object(y.jsx)(m.Button,{icon:w,style:nJ,onClick:c})})}),Object(y.jsxs)("div",{className:"transition-opacity duration-200 w-60 ".concat(x),"data-testid":"sidemenu-content",children:[Object(y.jsx)("h3",{className:"text-xl text-center mt-3 text-white",children:"Reports Navigation"}),Object(y.jsx)("div",{className:"mr-5 ml-5 mt-5",style:{display:"none"},children:Object(y.jsx)(m.Search,{placeholder:"Search"})}),Object(y.jsx)("div",{className:"mt-8",children:E})]})]})},rJ={accessLevel:"View"},cJ=function(e){return e.reportConfig.embedTokenBody?e.reportConfig.embedTokenBody:e.reportConfig.isPaginated?function(e){var t=e.datasetId?Object(ne.flatten)([e.datasetId]):void 0,n=Object(ne.flatten)([e.reportId]);return{datasets:null===t||void 0===t?void 0:t.map((function(e){return{id:e,xmlaPermissions:"ReadOnly"}})),reports:n.map((function(e){return{id:e}}))}}(e.reportConfig):rJ},iJ=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2)[1],n=tJ(),r=Object(a.useState)({}),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(""),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(!0),p=Object(b.a)(j,2),f=p[0],m=p[1],v=Object(a.useState)(eJ(n,yq,Iq)),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useContext)(we),C=function(){if(h){var e="object"===typeof h.reportConfig.reportId?h.reportConfig.reportId[0]:h.reportConfig.reportId,n=Ln.post(Object(I.a)(Object(I.a)({},h.reportConfig),{},{reportId:e})),a=n.promise,r=n.cancel;return a.then((function(e){var n=e.data;o(n),J.a.post(function(e){return e.reportConfig.isPaginated||e.reportConfig.embedTokenBody?"https://api.powerbi.com/v1.0/myorg/GenerateToken":function(e){var t=e.groupId,n=e.reportId;return"https://api.powerbi.com/v1.0/myorg/groups/".concat(t,"/reports/").concat(n,"/GenerateToken")}(e.reportConfig)}(h),cJ(h),{headers:{Authorization:"Bearer ".concat(n.accessToken)}}).then((function(e){g.sendEventToAmplitude(g.events.epic.Reports.reportSuccess,{reportName:n.name}),u(e.data.token)})).catch((function(e){g.sendEventToAmplitude(g.events.epic.Reports.reportFailed,{reportName:i.name}),uc(t)(e)}))})).catch(Ae.default).catch((function(e){g.sendEventToAmplitude(g.events.epic.Reports.reportFailed,{reportName:i.name}),uc(t)(e)})).finally((function(){return m(!1)})),r}};return Object(a.useEffect)((function(){C()}),[h]),{embeddedReport:i,isLoadingReport:f,loadEmbeddedReport:C,embedToken:d,setReportState:x,setEmbedToken:u}},oJ=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2)[1],n=Object(a.useState)({}),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(""),j=Object(b.a)(u,2),p=j[0],f=j[1];return{exportReportToPDF:function(e,n){d(e);var a="https://api.powerbi.com/v1.0/myorg/groups/".concat(e.reportConfig.groupId,"/reports/").concat(e.reportConfig.reportId,"/ExportTo"),r=function(e){var t=[];return e.forEach((function(e){var n,a=e.target.column;e.conditions?(n=e.conditions.map((function(e){var t=e.value;return{name:a,value:t}})),t.push.apply(t,Object(v.a)(n))):e.values&&(n=e.values.map((function(e){return{name:a,value:e}})),t.push.apply(t,Object(v.a)(n)))})),t}(n),c={format:"PDF",paginatedReportConfiguration:{parameterValues:r,formatSettings:{AccessiblePDF:"true",PageHeight:"11in",PageWidth:"8.5in"}}};J.a.post(a,c,{headers:{Authorization:"Bearer ".concat(p)}}).then((function(e){i(e.data)})).catch((function(e){uc(t)(e)}))},pollExportJob:function(){if(c.id&&null!==l&&void 0!==l&&l.reportConfig){var e="https://api.powerbi.com/v1.0/myorg/groups/".concat(l.reportConfig.groupId,"/reports/").concat(l.reportConfig.reportId,"/exports/").concat(c.id);J.a.get(e,{headers:{Authorization:"Bearer ".concat(p)}}).then((function(e){i(e.data)})).catch((function(e){uc(t)(e)}))}},getExportedReport:function(e){J.a.get(e,{headers:{Authorization:"Bearer ".concat(p)},responseType:"blob"}).then((function(e){i({});var t=new Blob([e.data],{type:"application/pdf"}),n=URL.createObjectURL(t);window.open(n)}))},exportJob:c,setExportJob:i,accessToken:p,setAccessToken:f}},sJ={selectedCropSeasons:[],cropSeasonStartDate:void 0,cropSeasonEndDate:void 0,selectedCropzones:[],selectedPlans:[],selectedProducts:[],initialSubmit:!1},lJ=function(e,t,n){return{$schema:"http://powerbi.com/product/schema#advanced",target:{table:e,column:t},logicalOperator:"And",conditions:[{operator:"Is",value:n}]}},dJ=function(e,t,n){return!!ae.a.differenceWith(t[e],n[e],ae.a.isEqual).length||!!ae.a.differenceWith(n[e],t[e],ae.a.isEqual).length},uJ=function(e,t,n){var a,r;return(null===(a=t[e])||void 0===a?void 0:a.getTime())===(null===(r=n[e])||void 0===r?void 0:r.getTime())},bJ=function(e,t){var n,a,r,c;return!e||(e.showCropSeasons&&!(null!==(n=t.selectedCropSeasons)&&void 0!==n&&n.length)||e.showDateRange&&(!t.cropSeasonStartDate||!t.cropSeasonEndDate)||e.showPlans&&!(null!==(a=t.selectedPlans)&&void 0!==a&&a.length)||e.showProperties&&!(null!==(r=t.selectedCropzones)&&void 0!==r&&r.length)||e.showProducts&&!(null!==(c=t.selectedProducts)&&void 0!==c&&c.length))},jJ=["title","titleId"];function pJ(){return pJ=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},pJ.apply(this,arguments)}function fJ(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function mJ(e,t){var n=e.title,r=e.titleId,c=fJ(e,jJ);return a.createElement("svg",pJ({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,hq||(hq=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM11 7V9H13V7H11ZM11 11V17H13V11H11ZM4 12C4 16.41 7.59 20 12 20C16.41 20 20 16.41 20 12C20 7.59 16.41 4 12 4C7.59 4 4 7.59 4 12Z",fill:"#0092E4"})))}var vJ=a.forwardRef(mJ),OJ=(n.p,function e(t){var n=[];return t.forEach((function(t){var a=[];t.children&&(a=e(t.children)),n.push.apply(n,[t.value].concat(Object(v.a)(a)))})),n}),hJ=function(e){var t=Object(a.useContext)(ac),n=Object(b.a)(t,2)[1],r=Object(a.useState)([]),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(!0),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(Object(I.a)({seasonIdsCommaSeparated:JSON.parse(localStorage.getItem("selectedCropSeasons")).join(",")},e)),p=Object(b.a)(j,1)[0],f=Object(a.useCallback)((function(e){var t=Cn.fetch(null,Object(I.a)(Object(I.a)({},p),e),{},null,!1),a=t.promise,r=t.cancel;return a.then((function(e){var t=e.data;o(t)})).catch(Ae.default).catch((function(e){uc(n)(e)})).finally((function(){return u(!1)})),r}),[p,n]);return Object(a.useEffect)((function(){var e=f();return function(){e()}}),[f]),{taskProducts:i,loading:d,loadTaskProducts:f}},xJ=n(829),gJ=n(2831),CJ=n(2832),yJ=n(2833),PJ=n(2845),AJ=Object(xJ.a)({palette:{primary:{main:"#0071cd"}}}),SJ=function(e){switch(e){case"SEED":return"Seed";case"CROPPROTECTION":return"Crop Protection";case"FERTILIZER":return"Fertilizer";case"SERVICE":return"Service";default:return"Custom Product"}},TJ=function(e){var t=e.mappedData,n=e.disabled,r=void 0===n||n,c=e.loading,i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)([]),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(),O=Object(b.a)(f,2),h=O[0],x=O[1],g=Object(a.useState)([]),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(P),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(Zi.h)().setFieldValue;Object(a.useEffect)((function(){var e=[];t&&(e=null===t||void 0===t?void 0:t.map((function(e){var t;return Object(I.a)({value:ae.a.uniqueId("CP_"),label:SJ(e.productType),type:"type"},e.children.length>0?{children:null===(t=e.children)||void 0===t?void 0:t.map((function(e){return{id:e.productId,value:ae.a.uniqueId("PN_"),label:e.productName,type:"name"}}))}:{disabled:!0})}))),A(e)}),[t]);var _=function(e){l(e)};Object(a.useEffect)((function(){var e=Object(ne.flatten)(P.map((function(e){return e.children}))),t=s.filter((function(e){return e.startsWith("PN_")})).map((function(t){return e.find((function(e){return e.value===t}))})).filter((function(e){return!!e})).map((function(e){return e.id}));w("selectedProducts",Object(v.a)(new Set(t)))}),[s]),Object(a.useEffect)((function(){_()}),[P]);var R=Object(a.useCallback)((function(e,t){var n=(t.children||[]).reduce(R,[]);return(t.label.toLocaleLowerCase().indexOf(null===h||void 0===h?void 0:h.toLocaleLowerCase())>-1||n.length)&&e.push(Object(I.a)(Object(I.a)({},t),{},{children:n})),e}),[h]);Object(a.useEffect)((function(){E(h?function(e){return e.reduce(R,[])}:P)}),[h,R,P]),Object(a.useEffect)((function(){l(OJ(P))}),[P]);var D=OJ(P);return Object(y.jsx)("div",{className:"filter-container h-full",children:c?Object(y.jsx)(m.Spinner,{size:"sm"}):Object(y.jsx)(y.Fragment,{children:(null===t||void 0===t?void 0:t.length)>0&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"my-2","data-testid":"product-filter-container",style:{display:"none"},children:Object(y.jsx)(m.Input,{className:"filter-text",placeholder:"Search...",type:"search",onChange:function(e){e.target.value.length>=3?(x(e.target.value),null!==h&&void 0!==h&&h.length?E((function(e){return e.reduce(R,[])})):E(P)):x("")}})}),Object(y.jsx)("div",{className:"mt-2 flex",children:Object(y.jsx)(gJ.a,{children:Object(y.jsx)(CJ.a,{control:Object(y.jsx)(yJ.a,{theme:AJ,children:Object(y.jsx)(PJ.a,{style:{borderColor:"#00000099"},size:"small",color:"primary",onChange:function(){s.length===D.length?l([]):l(D)},checked:(null===s||void 0===s?void 0:s.length)===(null===D||void 0===D?void 0:D.length)})}),label:"Select All"})})}),Object(y.jsx)(Lx.a,{nodes:N,checked:s,showNodeIcon:!1,icons:{halfCheck:Object(y.jsx)(Fx.a,{fontSize:"small"}),uncheck:Object(y.jsx)(Mx.a,{fontSize:"small",className:"text-neutral-600"}),check:Object(y.jsx)(Vx.a,{fontSize:"small"}),expandClose:Object(y.jsx)(Bx.a,{fontSize:"small",className:"text-neutral-600"}),expandOpen:Object(y.jsx)(Ux.a,{fontSize:"small",className:"text-neutral-600"})},css:"text-lg",expanded:j,onCheck:function(e){return _(e)},onExpand:function(e){return p(e)},showNodeTitle:!0,disabled:r,checkModel:"all"})]})})})};TJ.defaultProps={disabled:!1,mappedData:[],loading:!1};var NJ=TJ,EJ=function(e){var t,n=e.cropSeasons,r=Object(a.useState)([]),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)([]),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(Zi.h)().values,p=(0,Object(a.useContext)(jq).getActiveReport)(),f=p.category===Sq&&p.subType===Bq,m=function(){return j.selectedCropSeasons?{seasonIdsCommaSeparated:j.selectedCropSeasons.map((function(e){return e.id})).join(",")}:{}},O=hJ(m()),h=O.taskProducts,x=O.loading,g=O.loadTaskProducts,C=QR(!1),P=C.products,A=C.loading,S=C.getInventoryDetails;return Object(a.useEffect)((function(){j.selectedCropSeasons.length&&p&&(g(m()),f&&S(void 0,2147483647))}),[j.selectedCropSeasons,p]),Object(a.useEffect)((function(){if(j.selectedCropSeasons.length&&h&&!x&&(!f||P&&!A)){var e,t=h;f&&(t=t.concat(P.filter((function(e){var t;return null===(t=e.invoicesIds)||void 0===t?void 0:t.length}))),e=t,t=Object(v.a)(new Map(e.map((function(e){return[e.productId,e]}))).values())),t.sort((function(e,t){return e.productName.localeCompare(t.productName)})),u(t)}}),[h,x,P,A]),Object(a.useEffect)((function(){var e;o((e=d)?ae.a.chain(ae.a.flatMap(e,(function(e){return Object(I.a)(Object(I.a)({},e),{},{productType:e.productType.toUpperCase()})}))).groupBy("productType").map((function(e,t){return{productType:t,productTypeId:ae.a.uniqueId("Type_"),children:e}})).value():{})}),[j.selectedCropSeasons,d]),Object(y.jsx)("div",{className:"flex flex-col items-center bg-white",children:(null===n||void 0===n?void 0:n.length)>0&&Object(y.jsxs)("div",{className:"h-10 w-full",children:[Object(y.jsxs)("h1",{"data-testid":"product-text",className:"font-body font-semibold text-xl",style:{color:"#14151C"},children:["Products (",(t=i,t.reduce((function(e,t){return t.children.length>0?e+t.children.length:e}),0)),")"]}),Object(y.jsx)(NJ,{mappedData:i,loading:x||f&&A})]})})};EJ.defaultProps={cropSeasons:[]};var wJ=EJ,_J=function(e){var t=e.disabled,n=Object(Zi.h)(),a=n.values,r=n.handleSubmit;return Object(y.jsx)("div",{className:"w-full flex justify-end pt-3 pr-3 pb-3 absolute left-0 bottom-0 bg-white",style:{borderTop:"1px solid #A3A9B9",bottom:"-42px"},children:Object(y.jsx)(m.Button,{type:"primary",disabled:t,onClick:function(){r(a)},children:"Update Report"})})},RJ=Object(xJ.a)({palette:{primary:{main:"#0071cd"}}}),IJ=function(e){var t,n=e.mappedData,r=e.disabled,c=void 0===r||r,i=e.loading,o=e.handleCheck,s=e.checked,l=e.setChecked,d=Object(a.useState)([]),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useState)(),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(a.useState)([]),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(C),S=Object(b.a)(A,2),T=S[0],N=S[1];Object(a.useEffect)((function(){var e,t,a=[];!1===i&&n&&(a=null===(t=n.properties)||void 0===t?void 0:t.map((function(e){var t,n;return Object(I.a)({value:e.id,label:e.name,type:"farm"},(null===(t=e.fields)||void 0===t?void 0:t.length)>0?{children:null===(n=e.fields)||void 0===n?void 0:n.map((function(e){var t;return Object(I.a)({value:e.id,label:e.name,type:"field"},(null===(t=e.cropzones)||void 0===t?void 0:t.length)>0?{children:e.cropzones.map((function(e){return{value:e.id,label:e.name,type:"cropzone"}}))}:{disabled:!1})}))}:{disabled:!1})})));null!==(e=n.properties)&&void 0!==e&&e.length&&(a=(a=a.map((function(e){var t;return Object(I.a)(Object(I.a)({},e),{},{children:null===(t=e.children)||void 0===t?void 0:t.filter((function(e){var t;return null===(t=e.children)||void 0===t?void 0:t.length}))})}))).filter((function(e){var t;return null===(t=e.children)||void 0===t?void 0:t.length})),P(a))}),[n,i]),Object(a.useEffect)((function(){o()}),[C]);var E=Object(a.useCallback)((function(e,t){var n=(t.fields||[]).reduce(E,[]);return(t.label.toLocaleLowerCase().indexOf(null===O||void 0===O?void 0:O.toLocaleLowerCase())>-1||n.length)&&e.push(Object(I.a)(Object(I.a)({},t),{},{children:n})),e}),[O]);Object(a.useEffect)((function(){N(O?function(e){return e.reduce(E,[])}:C)}),[O,E,C]),Object(a.useEffect)((function(){l(OJ(C))}),[C]);var w=OJ(C);return Object(y.jsx)("div",{className:"filter-container",children:i?Object(y.jsx)(m.Spinner,{size:"sm"}):Object(y.jsx)(y.Fragment,{children:(null===(t=n.properties)||void 0===t?void 0:t.length)>0&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"my-2","data-testid":"properties-filter-container",style:{display:"none"},children:Object(y.jsx)(m.Input,{className:"filter-text",placeholder:"Search...",type:"search",onChange:function(e){e.target.value.length>=3?(h(e.target.value),null!==O&&void 0!==O&&O.length?N((function(e){return e.reduce(E,[])})):N(C)):h("")}})}),Object(y.jsx)("div",{className:"mt-2 flex",children:Object(y.jsx)(gJ.a,{children:Object(y.jsx)(CJ.a,{control:Object(y.jsx)(yJ.a,{theme:RJ,children:Object(y.jsx)(PJ.a,{style:{borderColor:"#00000099"},size:"small",color:"primary",onChange:function(){s.length===w.length?l([]):l(w)},checked:(null===s||void 0===s?void 0:s.length)===(null===w||void 0===w?void 0:w.length)})}),label:"Select All"})})}),Object(y.jsx)(Lx.a,{nodes:T,checked:s,showNodeIcon:!1,icons:{halfCheck:Object(y.jsx)(Fx.a,{fontSize:"small"}),uncheck:Object(y.jsx)(Mx.a,{fontSize:"small",className:"text-neutral-600"}),check:Object(y.jsx)(Vx.a,{fontSize:"small"}),expandClose:Object(y.jsx)(Bx.a,{fontSize:"small",className:"text-neutral-600"}),expandOpen:Object(y.jsx)(Ux.a,{fontSize:"small",className:"text-neutral-600"})},css:"text-lg",expanded:j,onCheck:function(e){return o(e)},onExpand:function(e){return p(e)},showNodeTitle:!0,disabled:c,checkModel:"all"})]})})})};IJ.defaultProps={disabled:!1,mappedData:[],loading:!1};var DJ=IJ,kJ=function(e){var t,n,r=e.cropSeasons,c=Object(Zi.h)(),i=c.values,o=c.setFieldValue,s=null===(t=i.selectedCropSeasons)||void 0===t?void 0:t.map((function(e){return null===e||void 0===e?void 0:e.id})),l=rv({fetchType:gm}),d=l.dataSorted,u=l.loading,j=l.reloadData,p=Object(a.useState)({}),f=Object(b.a)(p,2),m=f[0],v=f[1],O=Object(a.useState)([]),h=Object(b.a)(O,2),x=h[0],g=h[1];return Object(a.useEffect)((function(){s.length&&j({seasonIds:s})}),[i.selectedCropSeasons]),Object(a.useEffect)((function(){u||v(d)}),[u]),Object(a.useEffect)((function(){var e;if((null===(e=m.properties)||void 0===e?void 0:e.length)>0&&(null===r||void 0===r?void 0:r.length)>0){var t=[];x.forEach((function(e){var n;m.properties.forEach((function(a){a.fields.forEach((function(r){(n=r.cropzones.find((function(t){return t.id===e})))&&t.push(Object(I.a)(Object(I.a)({},n),{},{propertyName:a.name,fieldName:r.name}))}))}))})),o("selectedCropzones",t)}}),[x]),Object(y.jsx)("div",{className:"flex flex-col items-center bg-white",children:(null===(n=m.properties)||void 0===n?void 0:n.length)>0&&(null===r||void 0===r?void 0:r.length)>0&&Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("h1",{className:"font-body font-semibold text-xl",style:{color:"#14151C"},children:"Properties"}),Object(y.jsx)(DJ,{mappedData:m,loading:u,handleCheck:function(e){g(e)},checked:x,setChecked:g})]})})};kJ.defaultProps={cropSeasons:[]};var LJ=kJ,FJ=Object(xJ.a)({palette:{primary:{main:"#0071cd"}}}),MJ=function(e){var t=e.mappedData,n=e.disabled,r=void 0===n||n,c=e.loading,i=e.handleCheck,o=e.checked,s=e.setChecked,l=Object(a.useState)(),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)([]),f=Object(b.a)(p,2),O=f[0],h=f[1],x=Object(a.useState)(O),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(Zi.h)().setFieldValue;Object(a.useEffect)((function(){var e=[];!1===c&&t&&(e=null===t||void 0===t?void 0:t.map((function(e){return{value:e.planId,label:e.name,type:"plan"}}))),null!==t&&void 0!==t&&t.length&&(e=e.map((function(e){return Object(I.a)({},e)})),h(e))}),[t,c]),Object(a.useEffect)((function(){i()}),[O]);var S=Object(a.useCallback)((function(e,t){var n=(t.fields||[]).reduce(S,[]);return(t.label.toLocaleLowerCase().indexOf(null===u||void 0===u?void 0:u.toLocaleLowerCase())>-1||n.length)&&e.push(Object(I.a)(Object(I.a)({},t),{},{children:n})),e}),[u]);Object(a.useEffect)((function(){P(u?function(e){return e.reduce(S,[])}:O)}),[u,S,O]),Object(a.useEffect)((function(){s(OJ(O))}),[O]);var T=OJ(O);return Object(a.useEffect)((function(){A("selectedPlans",Object(v.a)(new Set(o)))}),[o]),Object(y.jsx)("div",{className:"filter-container",children:c?Object(y.jsx)(m.Spinner,{size:"sm"}):Object(y.jsx)(y.Fragment,{children:(null===t||void 0===t?void 0:t.length)>0&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"my-2","data-testid":"plans-filter-container",style:{display:"none"},children:Object(y.jsx)(m.Input,{className:"filter-text",placeholder:"Search...",type:"search",onChange:function(e){e.target.value.length>=3?(j(e.target.value),null!==u&&void 0!==u&&u.length?P((function(e){return e.reduce(S,[])})):P(O)):j("")}})}),Object(y.jsx)("div",{className:"mt-2 flex",children:Object(y.jsx)(gJ.a,{children:Object(y.jsx)(CJ.a,{control:Object(y.jsx)(yJ.a,{theme:FJ,children:Object(y.jsx)(PJ.a,{style:{borderColor:"#00000099"},size:"small",color:"primary",onChange:function(){o.length===T.length?s([]):s(T)},checked:(null===o||void 0===o?void 0:o.length)===(null===T||void 0===T?void 0:T.length)})}),label:"Select All"})})}),Object(y.jsx)(Lx.a,{nodes:C,checked:o,showNodeIcon:!1,expandDisabled:!0,icons:{halfCheck:Object(y.jsx)(Fx.a,{fontSize:"small"}),uncheck:Object(y.jsx)(Mx.a,{fontSize:"small",className:"text-neutral-600"}),expandClose:null,check:Object(y.jsx)(Vx.a,{fontSize:"small"})},css:"text-lg",onCheck:function(e){return i(e)},showNodeTitle:!0,disabled:r,checkModel:"all"})]})})})};MJ.defaultProps={disabled:!1,mappedData:[],loading:!1};var VJ=MJ,BJ=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(Zi.h)().values,i=Fk({size:-1}),o=i.plans,s=i.getPlans,l=i.isLoading,d=Object(a.useState)([]),u=Object(b.a)(d,2),j=u[0],f=u[1],v=Object(a.useState)([]),O=Object(b.a)(v,2),h=O[0],x=O[1];return Object(a.useEffect)((function(){s({size:-1,seasonIdsCommaSeparated:c.selectedCropSeasons.map((function(e){return null===e||void 0===e?void 0:e.id})).join(",")})}),[c.selectedCropSeasons]),Object(a.useEffect)((function(){c.selectedCropSeasons.length&&h!==o&&x(o),c.selectedCropSeasons.length||x([])}),[c.selectedCropSeasons,o]),Object(y.jsxs)("div",{className:"flex flex-col items-center bg-white",children:[l||h.length>0?Object(y.jsxs)("div",{className:"w-full",children:[Object(y.jsx)("h1",{className:"font-body font-semibold text-xl",style:{color:"#14151C"},children:"Plans"}),Object(y.jsx)(VJ,{mappedData:h,loading:l,handleCheck:function(e){f(e)},checked:j,setChecked:f})]}):Object(y.jsx)("div",{children:c.selectedCropSeasons.length?Object(y.jsx)("div",{className:"h-150px w-336px border border-neutral-30 border-solid rounded",children:Object(y.jsxs)("div",{className:"pl-16px pr-16px pt-30px text-sm\ttext-center",children:["You need to create plans for the selected seasons before you can generate this report.",Object(y.jsx)(m.Button,{style:{margin:"auto",marginTop:"12px",marginBottom:"12px"},id:"add-plan-button",type:"primary",onClick:function(e){e.stopPropagation(),r(!0)},icon:Object(y.jsx)(Eo.a,{}),children:"Create Plan"})]})}):""}),n&&Object(y.jsx)(p.b,{push:!0,to:{pathname:"".concat(Cc.calledPlans,"/plan")}})]})};BJ.defaultProps={};var UJ,zJ=BJ,ZJ=["title","titleId"];function YJ(){return YJ=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},YJ.apply(this,arguments)}function HJ(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function GJ(e,t){var n=e.title,r=e.titleId,c=HJ(e,ZJ);return a.createElement("svg",YJ({width:22,height:20,viewBox:"0 0 22 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,UJ||(UJ=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 19.5L11 0.5L0 19.5H22ZM10 16.5V14.5H12V16.5H10ZM10 12.5H12V8.5H10V12.5Z",fill:"#C17E19"})))}var WJ=a.forwardRef(GJ),qJ=(n.p,function(e){var t=e.activeReport,n=e.values,r=t.name.replace("Print",""),c=Object(a.useState)(),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(!1),f=Object(b.a)(p,2),m=f[0],v=f[1],O=Fk({}),h=O.plans,x=O.isLoading,g=O.getPlans,C=SH({}),P=C.loadTasks,A=C.loading,S=C.tasks,T=AH({}),N=T.isLoading,E=T.recommendations,w=T.getRecommendations,_=IG({}),R=_.loading,I=_.invoices,D=_.getReportInvoices;Object(a.useEffect)((function(){var e,t=null===(e=n.selectedCropSeasons)||void 0===e?void 0:e.map((function(e){return null===e||void 0===e?void 0:e.id}));j(t),s(r)}),[t,n.selectedCropSeasons]),Object(a.useEffect)((function(){u&&(u&&t.subType===Jq&&(n.cropSeasonStartDate&&n.cropSeasonEndDate?g({dateRange:[n.cropSeasonStartDate,n.cropSeasonEndDate],size:-1,seasonIdsCommaSeparated:u.join(",")}):g({size:-1,seasonIdsCommaSeparated:u.join(",")})),u&&t.subType===Gq&&P({size:-1,seasonIdsCommaSeparated:u.join(",")}),u&&t.subType===Wq&&w(void 0,void 0,u.join(",")),u&&t.subType===qq&&D(u.join(",")))}),[t,u,n.cropSeasonStartDate,n.cropSeasonEndDate]),Object(a.useEffect)((function(){if(!A){var e=S.filter((function(e){return new Date(null===e||void 0===e?void 0:e.startDate)>=new Date(null===n||void 0===n?void 0:n.cropSeasonStartDate)&&new Date(null===e||void 0===e?void 0:e.startDate)<=new Date(null===n||void 0===n?void 0:n.cropSeasonEndDate)}));v(!(null===e||void 0===e||!e.length))}}),[n.cropSeasonEndDate,n.cropSeasonStartDate,S,A]),Object(a.useEffect)((function(){if(!N){var e=E.filter((function(e){return new Date(null===e||void 0===e?void 0:e.createdOn)>=new Date(null===n||void 0===n?void 0:n.cropSeasonStartDate)&&new Date(null===e||void 0===e?void 0:e.createdOn)<=new Date(null===n||void 0===n?void 0:n.cropSeasonEndDate)}));v(!(null===e||void 0===e||!e.length))}}),[n.cropSeasonEndDate,n.cropSeasonStartDate,E,N]),Object(a.useEffect)((function(){if(!R){var e=I.filter((function(e){return new Date(null===e||void 0===e?void 0:e.invoiceDate)>=new Date(null===n||void 0===n?void 0:n.cropSeasonStartDate)&&new Date(null===e||void 0===e?void 0:e.invoiceDate)<=new Date(null===n||void 0===n?void 0:n.cropSeasonEndDate)}));v(!(null===e||void 0===e||!e.length))}}),[n.cropSeasonEndDate,n.cropSeasonStartDate,I,R]),Object(a.useEffect)((function(){x||v(!!h.length)}),[u,h,x]);return null!==u&&void 0!==u&&u.length?m?Object(y.jsx)("div",{className:"z-10 w-100/100",children:Object(y.jsx)("div",{className:"border-banner-alert-blue-30 border rounded bg-banner-alert-blue-10 mb-32px py-12px px-16px",children:Object(y.jsxs)("div",{className:"flex content-start pb-4px",children:[Object(y.jsx)("div",{className:"h-24px w-24px mt-26px mr-3 ",children:Object(y.jsx)(vJ,{style:{height:"24px",width:"24px"}})}),Object(y.jsxs)("div",{className:"text-md",children:["All ",o," for the selected crop season(s) will be included in the report"]})]})})}):Object(y.jsx)("div",{className:"z-10 285px pl-16px",children:Object(y.jsx)("div",{className:"border-banner-alert-yellow-30 border rounded bg-banner-alert-yellow-10 mb-32px",children:Object(y.jsx)("div",{className:"py-12px px-16px",children:Object(y.jsxs)("div",{className:"flex content-start",children:[Object(y.jsx)("div",{className:"h-24px w-24px mr-3 mt-2",children:Object(y.jsx)(WJ,{style:{height:"24px",width:"24px"}})}),Object(y.jsxs)("div",{className:"text-md",children:["No ",o," found in the selected crop season"]})]})})})}):[]}),JJ=function(e){var t,n,r=e.activeReport,c=e.formConfig,i=e.formTouched,o=e.embedToken,s=e.exportOnly,l=Object(Zi.h)(),d=l.values,u=l.setFieldValue,b=l.submitForm,j=dd(),p=j.cropSeasons,f=j.loaded,m=null===ac||void 0===ac||null===(t=ac._currentValue[0])||void 0===t||null===(n=t.organization)||void 0===n?void 0:n.id,v=!i(d)||bJ(c,d);return Object(a.useEffect)((function(){o&&u("initialSubmit",!1)}),[m,u,o]),Object(a.useEffect)((function(){d.initialSubmit||bJ(c,d)||(b(d),u("initialSubmit",!0))}),[c,d,u,b,o]),Object(y.jsx)("div",{className:"z-10 w-101 pl-16px",children:Object(y.jsx)("div",{className:"w-full px-8 pt-6 bg-white relative",style:{height:"87vh",paddingBottom:"2vh"},children:Object(y.jsxs)("div",{className:"overflow-y-auto w-full h-full","data-testid":"applied-products-by-field-form",children:[Object(y.jsx)("h2",{className:"mb-4 text-xl font-semibold text-neutral-1000",children:"Report Details"}),(null===c||void 0===c?void 0:c.showCropSeasons)&&Object(y.jsxs)("div",{className:"mb-6",children:[Object(y.jsx)(ng,{allCropSeasonsData:p,csLoaded:f,onSelect:function(e){u("selectedCropSeasons",e.filter((function(e){return!!e})))},selectedActive:!0,isRequired:!1}),(null===c||void 0===c?void 0:c.showDateRange)&&Object(y.jsx)(og,{isRequired:!1,className:"flex flex-row pb-6 mt-6 gap-5 justify-between relative"})]}),(null===c||void 0===c?void 0:c.showPlans)&&Object(y.jsx)("div",{className:"mb-12",children:Object(y.jsx)(zJ,{})}),(null===c||void 0===c?void 0:c.showExcelAlert)&&Object(y.jsx)("div",{className:"border-banner-alert-blue-30 border rounded bg-banner-alert-blue-10 mb-32px",children:Object(y.jsxs)("div",{className:"py-12px px-16px",children:[Object(y.jsxs)("div",{className:"flex content-start gap-5 pb-4px",children:[Object(y.jsx)(vJ,{}),Object(y.jsx)("h4",{className:"text-md whitespace-no-wrap",children:"Excel Report Includes:"})]}),Object(y.jsxs)("ul",{className:"text-neutral-60 text-sm ml-36px",children:[Object(y.jsx)("li",{children:"\u2022 Property Information"}),Object(y.jsx)("li",{children:"\u2022 Plans"}),Object(y.jsx)("li",{children:"\u2022 Recommendations"}),Object(y.jsx)("li",{children:"\u2022 Tasks"}),Object(y.jsx)("li",{children:"\u2022 Invoices"})]})]})}),(null===c||void 0===c?void 0:c.showPrintAlert)&&Object(y.jsx)(qJ,{values:d,activeReport:r}),(null===c||void 0===c?void 0:c.showProperties)&&Object(y.jsx)("div",{className:"mb-12",children:Object(y.jsx)(LJ,{cropSeasons:p})}),(null===c||void 0===c?void 0:c.showProducts)&&Object(y.jsx)("div",{className:"mb-12",children:Object(y.jsx)(wJ,{cropSeasons:p})}),!s&&Object(y.jsx)(_J,{disabled:v})]})})})},KJ=[{id:"reports",key:"reports",label:"Reports",path:Cc.reports,exact:!0,secure:!0,disabled:!1,component:function(){var e,t,n=Object(a.useState)({}),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(sJ),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useState)(),O=Object(b.a)(m,2),h=O[0],x=O[1],g=Object(a.useState)(!1),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(!1),T=Object(b.a)(S,2),N=T[0],E=T[1],w=iJ(),_=w.loadEmbeddedReport,R=w.embeddedReport,D=w.embedToken,k=w.setEmbedToken,L=w.setReportState,F=oJ(),M=(F.exportReportToPDF,F.pollExportJob),V=F.getExportedReport,B=F.setAccessToken,U=F.exportJob,z=null===ac||void 0===ac||null===(e=ac._currentValue[0])||void 0===e||null===(t=e.organization)||void 0===t?void 0:t.id;Object(a.useEffect)((function(){l&&L(l)}),[l]),Object(a.useEffect)((function(){_()}),[]),Object(a.useEffect)((function(){D&&R&&(B(R.accessToken),i((function(e){return Object(I.a)(Object(I.a)({},e),{},Object(et.a)({},null===l||void 0===l?void 0:l.name,{type:"report",id:R.id,name:R.name,accessToken:D,tokenType:oq.models.TokenType.Embed,embedUrl:R.embedUrl,settings:{panes:{filters:{expanded:!1,visible:!1}}}}))})))}),[D,R]);var Z=function(){return"NotStarted"===U.status||"Running"===U.status};return Object(a.useEffect)((function(){if(U.status){if(!Z()&&h&&(clearInterval(h),x()),"NotStarted"===U.status&&!h){var e=setInterval((function(){M()}),5e3);x(e)}U.resourceLocation&&(V(U.resourceLocation),A(!0)),U.error&&E(!0)}}),[U]),Object(y.jsxs)("div",{className:"w-full h-full font-body bg-app-background",children:[Object(y.jsx)(lo,{hideCropSeasonDropdown:!0,children:Object(y.jsx)(lo.Item,{title:"Reports",value:null===l||void 0===l?void 0:l.name,isLast:!0})}),Object(y.jsx)(fq,{children:Object(y.jsx)(Zi.e,{initialValues:sJ,onSubmit:function(e){if(l&&c[null===l||void 0===l?void 0:l.name]){var t=function(e,t,n){var a=[],r="filter_params",c="rp_cropseason_ids",i="rp_start_date",o="rp_end_date",s="rp_cropzone_ids",l="rp_product_ids",d="rp_tz_offset",u="rp_plan_ids",b=lJ(r,"rp_org_id",t);if(a.push(b),e.showTimezoneOffset){var j=(new Date).getTimezoneOffset(),p=lJ(r,d,j);a.push(p)}if(e.showCropSeasons){var f,m,O=lJ(r,c,null===(f=n.selectedCropSeasons)||void 0===f||null===(m=f.map((function(e){return e.id})))||void 0===m?void 0:m.join(","));a.push(O)}if(e.showDateRange){var h=lJ(r,i,yA(n.cropSeasonStartDate));a.push(h);var x=lJ(r,o,yA(n.cropSeasonEndDate));a.push(x)}if(e.showPlans){var g,C=lJ(r,u,null===(g=n.selectedPlans)||void 0===g?void 0:g.join(","));a.push(C)}if(e.showProperties){var y,P=lJ(r,s,null===(y=Object(v.a)(new Set(n.selectedCropzones.map((function(e){return e.id})))))||void 0===y?void 0:y.join(","));a.push(P)}if(e.showProducts){var A,S=lJ(r,l,null===(A=n.selectedProducts)||void 0===A?void 0:A.join(","));a.push(S)}return a}(l.formConfig,z,e);i((function(e){return Object(I.a)(Object(I.a)({},e),{},Object(et.a)({},null===l||void 0===l?void 0:l.name,Object(I.a)(Object(I.a)({},e[null===l||void 0===l?void 0:l.name]),{},{filters:t})))})),f(e)}},children:Object(y.jsxs)("div",{className:"flex flex-col h-full",children:[Object(y.jsxs)("div",{className:"flex flex-1 h-full align-items-center",children:[Object(y.jsx)(aJ,{setActiveReport:d,onChange:function(){k()}}),Object(y.jsx)(JJ,{activeReport:l,formConfig:null===l||void 0===l?void 0:l.formConfig,formTouched:function(e){return function(e,t,n){if(!e)return!1;var a=[];return e.showCropSeasons&&a.push(dJ("selectedCropSeasons",t,n)),e.showDateRange&&a.push(!uJ("cropSeasonStartDate",t,n),!uJ("cropSeasonEndDate",t,n)),e.showPlans&&a.push(dJ("selectedPlans",t,n)),e.showProperties&&a.push(dJ("selectedCropzones",t,n)),e.showProducts&&a.push(dJ("selectedProducts",t,n)),!!a.find((function(e){return e}))}(null===l||void 0===l?void 0:l.formConfig,e,p)},embedToken:D,exportOnly:false}),Object(y.jsx)("div",{className:"flex-auto flex flex-col h-full",children:Object(y.jsx)("div",{className:"pl-16px pr-30px flex-auto h-full",children:Object.keys(c).map((function(e){var t;return(null===l||void 0===l?void 0:l.name)===e&&(null===(t=c[e].filters)||void 0===t?void 0:t.length)&&Object(y.jsx)(sq.PowerBIEmbed,{cssClassName:" h-full",embedConfig:c[e]},e)}))})})]}),Object(y.jsx)(si,{open:U.status&&Z(),message:"Generating Excel Report"}),Object(y.jsx)(Qc,{type:"success",title:"Excel Report Exported",isBold:!0,open:P,onClose:function(){return A(!1)},timeout:5e3}),Object(y.jsx)(Qc,{type:"error",title:"Unable to generate Excel",isBold:!0,open:N,onClose:function(){return E(!1)},timeout:5e3,children:Object(y.jsx)("p",{className:"text-sm font-body",children:"There was an issue in downloading the Excel Report, please try again. If issue persists contact support."})})]})})})]})},icon:td,nav:"leftNav"}],QJ=n(284),XJ=n(817),$J=n.n(XJ),eK=function(e){var t=e.children,n=e.innerRef,a=e.isDraggingOver?"bg-blue-100 border border-blue-600 border-t-0":"bg-neutral-150";return Object(y.jsx)("div",{ref:n,className:"py-4 h-full border-l border-r border-b rounded-b ".concat(a),children:t})};eK.defaultProps={children:Object(y.jsx)(y.Fragment,{})};var tK=eK,nK=(n(1643),Object(a.createContext)()),aK=function(e){var t=e.children,n=e.updatingTask,a=e.updatingWeather;return Object(y.jsx)(nK.Provider,{value:{updatingTask:n,updatingWeather:a},children:t})};aK.defaultProps={children:Object(y.jsx)(y.Fragment,{}),updatingTask:{},updatingWeather:!1};var rK=function(e){var t=e.title,n=e.value,a=e.fullWidth,r=e.isCurrencyValue;return Object(y.jsxs)("div",{className:"".concat(a?"w-11/12":"w-48"),children:[Object(y.jsx)("div",{className:"text-xs text-neutral-300",children:t}),Object(y.jsx)("div",{className:"text-lg truncate text-neutral-300",children:r&&null!==n?Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:String(n)}):n})]})},cK=function(e){var t,n,r=e.task,c=e.onContextMenuAction,i=e.flags,o=e.memberRole,s=e.memberFinancialAccess,l=Object(a.useState)({extraTagsCount:0,extraTagsNames:[],tagsToDisplay:[]}),d=Object(b.a)(l,2),u=d[0],p=d[1];Object(a.useEffect)((function(){i.length>0&&p(Af(i,30))}),[i]);var f,v=Object(a.useContext)(nK),O=v.updatingTask,h=v.updatingWeather;return Object(y.jsxs)("div",{className:"flex flex-col justify-center h-64 mx-2",children:[Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsxs)("div",{className:"text-lg font-bold truncate text-syngenta-navy",children:[Object(y.jsx)(j.b,{to:"".concat(Cc.tasks,"/").concat(null===r||void 0===r?void 0:r.id,"/view"),children:null===r||void 0===r?void 0:r.name}),(O.updating&&O.taskId===(null===r||void 0===r?void 0:r.id)||h&&O.taskId===(null===r||void 0===r?void 0:r.id))&&Object(y.jsx)("div",{className:"async-loader",children:Object(y.jsx)(m.Spinner,{size:"xs"})})]}),Object(y.jsx)("div",{className:"flex self-center",children:Object(y.jsx)(Wo,{onAction:c,options:"ready"===r.status?vs:js})})]}),Object(y.jsx)("div",{className:"text-sm text-neutral-300 mb-2",children:vA(null===r||void 0===r?void 0:r.startDate)}),u.extraTagsNames.length>0?Object(y.jsx)(fu,{position:"bottom",ariaLabel:"Task Tags",top:"1.5rem",msg:Object(y.jsx)(Pf,{extraTagsNames:u.extraTagsNames}),component:Object(y.jsx)(Sf,{displayTagsObject:u,isLandingPage:!0,viewKey:fd})}):Object(y.jsx)(Sf,{displayTagsObject:u,isLandingPage:!0,viewKey:fd}),Object(y.jsxs)("div",{className:"mt-3",children:[Object(y.jsxs)("div",{className:"flex justify-between w-64",children:[Object(y.jsx)(rK,{title:"Field Count",value:null===r||void 0===r?void 0:r.fieldCount}),Object(y.jsx)(rK,{title:"Total Acres",value:Math.round(100*(null===r||void 0===r?void 0:r.totalAreaValue))/100})]}),Object(y.jsxs)("div",{className:"flex justify-between w-64 mt-2",children:[Object(y.jsx)(rK,{title:"Product Count",value:null===r||void 0===r?void 0:r.productCount}),"View Only"===o&&void 0===s?"":Object(y.jsx)(rK,{title:"Total Task Cost",value:(f=null===r||void 0===r?void 0:r.totalTaskCost,"Full control"===o&&"none"===s?"":"Admin"===o||"View Only"===o||"Full control"===o&&"WRITE"===s||"Full control"===o&&"READ"===s?f:""),isCurrencyValue:!0})]}),Object(y.jsx)("div",{className:"mt-2",children:Object(y.jsx)(rK,{title:"Crop Season",value:null===r||void 0===r||null===(t=r.cropSeasons)||void 0===t||null===(n=t.cropSeasons)||void 0===n?void 0:n.map((function(e,t){var n;return"".concat(e.name).concat(t===(null===r||void 0===r||null===(n=r.cropSeasons)||void 0===n?void 0:n.cropSeasons.length)-1?"":", ")})),fullWidth:!0})})]})]})};rK.defaultProps={value:"",fullWidth:!1,isCurrencyValue:!1};var iK=function(e){var t=e.index,n=e.task,a=e.onAction,r=e.memberRole,c=e.memberFinancialAccess,i=function(e){return a(e,n)},o=function(e,t){return t.isDragging?t.isDropAnimating?Object(I.a)(Object(I.a)({},e),{},{transitionDuration:"0.001s"}):e:{}};return Object(y.jsx)(QJ.b,{draggableId:null===n||void 0===n?void 0:n.id,index:t,children:function(e,t){var a,s,l,d,u=e.innerRef,b=e.draggableProps,j=e.dragHandleProps;return Object(y.jsx)("div",Object(I.a)(Object(I.a)(Object(I.a)({id:"task-".concat(null===n||void 0===n?void 0:n.id),className:"mx-3 my-3 px-3 py-4 border border-neutral-200 rounded bg-white"},b),j),{},{ref:u,style:o(b.style,t),children:Object(y.jsx)(cK,{task:n,onContextMenuAction:i,flags:void 0!==(null===n||void 0===n||null===(a=n.flags)||void 0===a?void 0:a.flags)||(null===n||void 0===n||null===(s=n.flags)||void 0===s||null===(l=s.flags)||void 0===l?void 0:l.length)>0?null===n||void 0===n||null===(d=n.flags)||void 0===d?void 0:d.flags:[],memberRole:r,memberFinancialAccess:c})}))}})},oK=function(e){var t=e.column,n=e.tasks,a=e.columnIndex,r=e.sort,c=e.handleSortChange,i=e.highlighted,o=function(e){var t="text-yellow-600";return 1===e&&(t="text-blue-400"),2===e&&(t="text-blue-700"),t}(a),s=i?"border-blue-600 border-b-0":"",l=Object(y.jsx)($J.a,{fontSize:"small",m:0});return"asc"===r?l=Object(y.jsx)(eg.a,{fontSize:"small",m:0}):"desc"===r&&(l=Object(y.jsx)(Xx.a,{fontSize:"small",m:0})),Object(y.jsxs)("h3",{className:"bg-white border rounded-t px-2 py-2 flex items-center justify-between ".concat(s),children:[Object(y.jsx)("span",{className:"".concat(o," text-lg font-bold"),children:"".concat(uA(t.title)," (").concat(n.length,")")}),Object(y.jsxs)("button",{onClick:function(){c(t.title)},className:"flex w-24 justify-between",type:"button",children:[Object(y.jsx)("span",{children:"Start Date"}),Object(y.jsx)("div",{children:l})]})]})},sK=function(e){var t=e.column,n=e.columnIndex,r=e.tasks,c=e.onAction,i=e.setDraggingOverTask,o=e.handleSortChange,s=e.sort,l=e.memberRole,d=e.memberFinancialAccess,u=Object(a.useState)(),j=Object(b.a)(u,2),p=j[0],f=j[1];return Object(y.jsxs)("div",{id:"tasks-column-".concat(t.title),className:"bg-neutral-800 rounded w-64 mx-2 flex flex-col flex-grow",children:[Object(y.jsx)(oK,{column:t,tasks:r,columnIndex:n,sort:s,handleSortChange:o,highlighted:p}),Object(y.jsx)(QJ.c,{droppableId:t.id,isDropDisabled:!1,children:function(e,n){var a=n.isDraggingOver;if(n.isDraggingOver){var o=null===n||void 0===n?void 0:n.draggingFromThisWith;if(o){var s=r.find((function(e){return e.id===o}));i(s),t.title===s.status&&(a=!1)}a&&f(!0)}else f&&f(!1);return Object(y.jsxs)(tK,Object(I.a)(Object(I.a)({innerRef:e.innerRef},e.droppableProps),{},{isDraggingOver:a,children:[r.map((function(e,t){return Object(y.jsx)(iK,{task:e,index:t,onAction:c,memberRole:l,memberFinancialAccess:d},null===e||void 0===e?void 0:e.id)})),Object(y.jsx)("span",{style:{display:"none"},children:e.placeholder})]}))}})]})};oK.defaultProps={sort:null,highlighted:!1},sK.defaultProps={sort:null};var lK=sK,dK=function(e,t){var n=e.filter((function(e){return"ready"===e.status})),a=e.filter((function(e){return"inprogress"===e.status})),r=e.filter((function(e){return"complete"===e.status})),c=n.slice().sort((function(e,n){return"desc"===t.ready.sort?new Date(n.startDate)-new Date(e.startDate):"asc"===t.ready.sort?new Date(e.startDate)-new Date(n.startDate):new Date(n.startDate)-new Date(e.startDate)})),i=a.slice().sort((function(e,n){return"desc"===t.inprogress.sort?new Date(n.startDate)-new Date(e.startDate):"asc"===t.inprogress.sort?new Date(e.startDate)-new Date(n.startDate):new Date(n.startDate)-new Date(e.startDate)})),o=r.slice().sort((function(e,n){return"desc"===t.complete.sort?new Date(n.startDate)-new Date(e.startDate):"asc"===t.complete.sort?new Date(e.startDate)-new Date(n.startDate):new Date(n.startDate)-new Date(e.startDate)}));return[{id:ic.a.generate(),title:"ready",tasks:c.filter((function(e){return"ready"===e.status})).map((function(e){return e.id}))},{id:ic.a.generate(),title:"inprogress",tasks:i.filter((function(e){return"inprogress"===e.status})).map((function(e){return e.id}))},{id:ic.a.generate(),title:"complete",tasks:o.filter((function(e){return"complete"===e.status})).map((function(e){return e.id}))}]},uK=function(e,t,n){Object(ne.cloneDeep)(e).status=t,n(e.id,t)},bK=function(e){var t=e.destination,n=e.source,a=(null===t||void 0===t?void 0:t.droppableId)===(null===n||void 0===n?void 0:n.droppableId)&&(null===t||void 0===t?void 0:t.index)===(null===n||void 0===n?void 0:n.index);return!t||!!a},jK=function(e,t,n,a){var r=e.destination,c=e.source,i=e.draggableId,o=Array.from(t.tasks);o.splice(c.index,1);var s=Object(I.a)(Object(I.a)({},t),{},{tasks:o}),l=Array.from(n.tasks);l.splice(r.index,0,i);var d=Object(I.a)(Object(I.a)({},n),{},{tasks:l});a((function(e){var t=Object(ne.cloneDeep)(e),n=t.findIndex((function(e){return e.id===s.id})),a=t.findIndex((function(e){return e.id===d.id}));return t.splice(n,1,s),t.splice(a,1,d),t}))},pK=function(){var e=Object(Y.a)(G.a.mark((function e(t,n,a,r,c,i,o){var s,l,d,u,b;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=t.destination,l=t.source,!bK(t)){e.next=3;break}return e.abrupt("return");case 3:if(d=n.find((function(e){return e.id===l.droppableId})),u=n.find((function(e){return e.id===s.droppableId})),d!==u){e.next=7;break}return e.abrupt("return");case 7:return jK(t,d,u,a),b=n.filter((function(e){return e.id===t.destination.droppableId}))[0].title,e.next=11,i(Object(I.a)({},o),b);case 11:uK(r,b,c);case 12:case"end":return e.stop()}}),e)})));return function(t,n,a,r,c,i,o){return e.apply(this,arguments)}}(),fK=pK,mK=function(e){var t=e.tasks,n=e.updateTask,r=e.memberRole,c=e.memberFinancialAccess,i=e.updateTaskWeather,o=e.handleAction,s=Object(a.useState)({ready:{sort:"desc"},inprogress:{sort:"desc"},complete:{sort:"desc"}}),l=Object(b.a)(s,2),d=l[0],u=l[1],j=dK(t,d),p=Object(a.useState)(j),f=Object(b.a)(p,2),m=f[0],v=f[1],O=Object(a.useState)(),h=Object(b.a)(O,2),x=h[0],g=h[1];Object(a.useEffect)((function(){v(dK(t,d))}),[d,t]);var C=function(e){var t=d[e].sort;u(t?"asc"===t?function(t){var n=Object(ne.cloneDeep)(t);return n[e].sort="desc",n}:function(t){var n=Object(ne.cloneDeep)(t);return n[e].sort=null,n}:function(t){var n=Object(ne.cloneDeep)(t);return n[e].sort="asc",n})};return Object(y.jsx)("div",{className:"my-4","data-testid":"tasks-baord",children:Object(y.jsx)(QJ.a,{onDragEnd:function(e){var a=t.filter((function(e){return e.id===(null===x||void 0===x?void 0:x.id)}));fK(e,m,v,x,n,i,a[0]),g(null)},children:Object(y.jsx)("div",{className:"flex justify-between",children:m.map((function(e,n){var a=e.tasks.map((function(e){return t.find((function(t){return t.id===e}))}));return Object(y.jsx)(lK,{column:e,tasks:a,columnIndex:n,onAction:o,setDraggingOverTask:g,handleSortChange:C,sort:d[e.title].sort,memberRole:r,memberFinancialAccess:c},e.title)}))})})})},vK=function(e){var t,n,r=e.task,c=e.onAction,i=e.flags,o=e.memberRole,s=e.memberFinancialAccess,l=e.runningProcesses,d=Object(f.useFlags)().feTasksSpanishReadyTaskTranslation,u=Object(a.useState)({extraTagsCount:0,extraTagsNames:[],tagsToDisplay:[]}),p=Object(b.a)(u,2),v=p[0],O=p[1];Object(a.useEffect)((function(){i.length>0&&O(Af(i,20))}),[i]);var h;return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsxs)("span",{className:"flex flex-col",children:[Object(y.jsx)("span",{className:"w-64 pb-2 text-sm font-bold text-left truncate","data-testid":"task-name",children:Object(y.jsx)(j.b,{to:"".concat(Cc.tasks,"/").concat(r.id,"/view"),children:r.name})}),v.extraTagsNames.length>0?Object(y.jsx)(fu,{position:"bottom",ariaLabel:"Task Tags",top:"1.5rem",msg:Object(y.jsx)(Pf,{extraTagsNames:v.extraTagsNames}),component:Object(y.jsx)(Sf,{displayTagsObject:v,isLandingPage:!0,viewKey:"tag_1"})}):Object(y.jsx)(Sf,{displayTagsObject:v,isLandingPage:!0,viewKey:"tag_2"})]})}),Object(y.jsx)(m.Table.Cell,{width:"8rem",children:r.fieldCount}),Object(y.jsx)(m.Table.Cell,{width:"12rem",children:Object(y.jsx)(yf,{children:r.totalAreaValue||0})}),Object(y.jsx)(m.Table.Cell,{width:"8rem",children:r.productCount}),"View Only"===o&&void 0===s?Object(y.jsx)(m.Table.Cell,{}):Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:(h=r.totalTaskCost,"Full control"===o&&"none"===s||"View Only"===o&&void 0===s?"":or({role:o,financialAccess:s},{minAllowedRole:"View Only",minFinancialAccess:"READ"})?h:"")})}),Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsx)("span",{className:"w-64 h-full py-1 text-left truncate",children:null===r||void 0===r||null===(t=r.cropSeasons)||void 0===t||null===(n=t.cropSeasons)||void 0===n?void 0:n.map((function(e,t){var n;return"".concat(e.name).concat(t===(null===r||void 0===r||null===(n=r.cropSeasons)||void 0===n?void 0:n.cropSeasons.length)-1?"":", ")}))})}),Object(y.jsx)(m.Table.Cell,{children:vA(r.startDate)}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex justify-between w-full",children:[Object(y.jsx)("div",{className:"mr-6",children:function(e){var t={name:"Ready",color:"#E99921"};return"inprogress"===e?t={name:"In Progress",color:"#5FD2C8"}:"complete"===e&&(t={name:"Complete",color:"#0071CD"}),Object(y.jsx)("div",{children:Object(y.jsx)(m.Tag,{color:t.color,children:Object(y.jsx)("span",{className:"w-32 text-lg",children:t.name})})})}(r.status)}),Object(y.jsx)("div",{"data-testid":"task-table-options-menu",className:"w-10 mr-2",children:l?Object(y.jsx)(m.Spinner,{size:"sm"}):Object(y.jsx)(Wo,{onAction:c,options:"ready"===r.status&&d?ms:bs})})]})})]},r.id)};vK.defaultProps={runningProcesses:!1};var OK=Object(f.withLDConsumer)()(vK),hK=function(e){var t=e.tasks,n=e.memberRole,r=e.memberFinancialAccess,c=e.handleAction,i=e.totalTasks,o=e.taskPageNumber,s=e.setTaskPageNumber,l=e.downloadingPDF,d=e.rowIndexLoading,u=Object(a.useState)(),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useState)(),v=Object(b.a)(m,2),O=v[0],h=v[1],x=Object(a.useState)(t),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(!0),S=Object(b.a)(A,2)[1],T=[{field:"task",title:"Task (".concat(i,")"),sortable:!0},{field:"fields",title:"Fields",sortable:!0},{field:"totalAcres",title:"Total Acres",sortable:!0},{field:"products",title:"Products",sortable:!0},{field:"totalCost",title:"Total Cost",sortable:!0},{field:"cropSeason",title:"Crop Season",sortable:!0},{field:"startDateTime",title:"Start Date/Time",sortable:!0},{field:"status",title:"Status",sortable:!0}];Object(a.useEffect)((function(){S(!1),P(t)}),[t]);return Object(y.jsx)("div",{className:"mb-4 min-w-content","data-testid":"tasks-table",style:{minWidth:"min-content"},children:Object(y.jsxs)(ll,{children:[Ho(i,o,s),Object(y.jsx)(ol,{listType:"Tasks",routePath:Cc.tasks,items:C,tableColumns:T,onSort:function(e,t){f(e),h(t),P(function(e,t,n){if(!n)return e;var a=e.map((function(e){return Object(ne.cloneDeep)(e)}));switch(t){case"task":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.name}],n);case"fields":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.fieldCount}],n);case"totalAcres":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.totalAreaValue}],n);case"products":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.productCount}],n);case"totalCost":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.totalTaskCost}],n);case"cropSeason":return Object(ne.orderBy)(a,[function(e){var t;return null===e||void 0===e||null===(t=e.cropSeasons)||void 0===t?void 0:t.cropSeasons[0]}],n);case"startDateTime":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.startDateEpoch}],n);case"status":return Object(ne.orderBy)(a,[function(e){return null===e||void 0===e?void 0:e.status}],n);default:return a}}(C,e,t))},sortBy:p,sortDir:O,children:function(e){return e.rows.map((function(e,t){var a,i,o,s;return Object(y.jsx)(OK,{task:e,onAction:function(n){return c(n,e,t)},flags:void 0!==(null===e||void 0===e||null===(a=e.flags)||void 0===a?void 0:a.flags)||(null===e||void 0===e||null===(i=e.flags)||void 0===i||null===(o=i.flags)||void 0===o?void 0:o.length)>0?null===e||void 0===e||null===(s=e.flags)||void 0===s?void 0:s.flags:[],memberFinancialAccess:r,memberRole:n,runningProcesses:l&&d===t},e.id)}))}}),Object(y.jsx)("div",{className:"pb-12",children:Ho(i,o,s)})]})})};hK.defaultProps={tasks:[],downloadingPDF:!1,rowIndexLoading:-1};var xK=hK,gK=[{key:"n",value:"N",code:50600},{key:"ne",value:"NE",code:50800},{key:"nne",value:"NNE",code:50700},{key:"nw",value:"NW",code:52e3},{key:"nnw",value:"NNW",code:52100},{key:"s",value:"S",code:51400},{key:"se",value:"SE",code:51200},{key:"sse",value:"SSE",code:51300},{key:"sw",value:"SW",code:51600},{key:"ssw",value:"SSW",code:51500},{key:"e",value:"E",code:51e3},{key:"ene",value:"ENE",code:50900},{key:"ese",value:"ESE",code:51100},{key:"w",value:"W",code:51800},{key:"wnw",value:"WNW",code:51900},{key:"wsw",value:"WSW",code:51700},{key:"unknown",value:"Unknown",code:NaN},{key:"calm",value:"Calm",code:5e4},{key:"lw",value:"LW",code:50100},{key:"lb",value:"LB",code:50200},{key:"windy",value:"Windy",code:50300},{key:"breezy",value:"Breezy",code:50400},{key:"gusty",value:"Gusty",code:50500},{key:"variableWinds",value:"Variable Winds",code:52200}],CK=[{key:"clear",value:"Clear"},{key:"becomingClear",value:"Becoming Clear"},{key:"mostlyClear",value:"Mostly Clear"},{key:"becomingMostlyClear",value:"Becoming Mostly Clear"},{key:"partlyCloudy",value:"Partly Cloudy"},{key:"becomingPartlyCloudy",value:"Becoming Partly Cloudy"},{key:"partlyClear",value:"Partly Clear"},{key:"becomingPartlyClear",value:"Becoming Partly Clear"},{key:"mostlyCloudy",value:"Mostly Cloudy"},{key:"becomingMostlyCloudy",value:"Becoming Mostly Cloudy"},{key:"cloudy",value:"Cloudy"},{key:"becomingCloudy",value:"Becoming Cloudy"},{key:"fair",value:"Fair"},{key:"becomingFair",value:"Becoming Fair"},{key:"fewClouds",value:"Few Clouds"},{key:"fewCloudsDeveloping",value:"Few Clouds Developing"},{key:"scatteredClouds",value:"Scattered Clouds"},{key:"scatteredCloudsDeveloping",value:"Scattered Clouds Developing"},{key:"brokenOvercast",value:"Broken Overcast"},{key:"becomingBrokenOvercast",value:"Becoming Broken Overcast"},{key:"overcast",value:"Overcast"},{key:"becomingOvercast",value:"Becoming Overcast"},{key:"clouds",value:"Clouds"},{key:"decreasingClouds",value:"Decreasing Clouds"},{key:"increasingClouds",value:"Increasing Clouds"},{key:"variableClouds",value:"Variable Clouds"},{key:"numerousClouds",value:"Numerous Clouds"},{key:"numerousCloudsDeveloping",value:"Numerous Clouds Developing"},{key:"sunny",value:"Sunny"},{key:"becomingSunny",value:"Becoming Sunny"},{key:"mostlySunny",value:"Mostly Sunny"},{key:"becomingMostlySunny",value:"Becoming Mostly Sunny"},{key:"partlySunny",value:"Partly Sunny"},{key:"becomingPartlySunny",value:"Becoming Partly Sunny"},{key:"considerableCloudiness",value:"Considerable Cloudiness"},{key:"becomingConsiderableCloudiness",value:"Becoming Considerable Cloudiness"},{key:"considerableCloudinessDeveloping",value:"Considerable Cloudiness Developing"}],yK=[{key:"dry",value:"Dry"},{key:"moist",value:"Moist"},{key:"wet",value:"Wet"},{key:"unknown",value:"Unknown"}],PK=Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}),AK=PK.REACT_APP_AG_CLEAR_APP_ID,SK=PK.REACT_APP_AG_CLEAR_APP_KEY,TK=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2),n=t[0],r=t[1],c=n.weatherAutomaticToggle,i=rv({fetchType:xm}).fieldsAndAreasCentroidCoordinates,o=Object(a.useState)(!1),s=Object(b.a)(o,2),l=s[0],d=s[1],u={date:"",dateEpoch:"",temperature:"",temperatureUnit:"",humidity:"",skyCondition:"",windSpeed:"",windSpeedUnit:"",windDirection:"",soilMoisture:"",type:""},j=function(e){var t,n,a,r=(null===e||void 0===e||null===(t=e.descriptors)||void 0===t?void 0:t.wind_direction_descriptor)||(null===e||void 0===e||null===(n=e.descriptors)||void 0===n?void 0:n.wind_direction),c=gK.filter((function(e){return e.code===(null===r||void 0===r?void 0:r.code)}));return 0===c.length?gK.filter((function(e){return"unknown"===e.key}))[0].value:null===(a=c[0])||void 0===a?void 0:a.value},p=function(e,t,n){var a,r,c,i,o,s,l,d;return{date:new Date(1e3*n),dateEpoch:1e3*n,temperature:(null===t||void 0===t||null===(a=t.air_temp)||void 0===a?void 0:a.value)||"",temperatureUnit:(null===t||void 0===t||null===(r=t.air_temp)||void 0===r?void 0:r.unit)||"",humidity:(null===t||void 0===t||null===(c=t.relative_humidity)||void 0===c?void 0:c.value)||"",skyCondition:(null===t||void 0===t||null===(i=t.descriptors)||void 0===i||null===(o=i.weather_descriptor)||void 0===o?void 0:o.text)||"",windSpeed:(null===t||void 0===t||null===(s=t.wind_speed)||void 0===s?void 0:s.value)||"",windSpeedUnit:(null===t||void 0===t||null===(l=t.wind_speed)||void 0===l||null===(d=l.unit)||void 0===d?void 0:d.toUpperCase())||"",windDirection:j(t)||"",soilMoisture:"unknown",type:0===e?"start":"end"}},f=function(e,t,n,a,r,c){var i;if(function(e){return 0===e}(a))i="create"===r||"convert"===r||"duplicate"===r?(null===e||void 0===e?void 0:e.getTime())/1e3:t/1e3;else{if(!function(e){return 1===e}(a))throw new Error("Unexpected weather index :",a);if("Custom"!==n){var o=3600*Number(n);i=(null===e||void 0===e?void 0:e.getTime())/1e3+o}else i=(null===c||void 0===c?void 0:c.getTime())/1e3}return{hourlyHistoricalPath:Zn,startDateTimeStamp:i,endDateTimeStamp:i+30,index:a}},m=function(){var e=Object(Y.a)(G.a.mark((function e(t,n,a,c){var i,o,s,l,d,u;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=Object(b.a)(n,2),o=i[0],s=i[1],l=a.path,d=a.startDateTimeStamp,u=a.endDateTimeStamp,!((null===t||void 0===t?void 0:t.getTime())<Date.now())){e.next=5;break}return e.next=5,fetch("".concat(l,"?app_id=").concat(AK,"&app_key=").concat(SK,"&end=").concat(u,"&location=[(").concat(s,",").concat(o,")]&start=").concat(d)).then(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t.status>=200&&t.status<=299)){e.next=2;break}return e.abrupt("return",t.json());case 2:return e.next=4,t.text();case 4:throw n=e.sent,new Error(n);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).then((function(e){var t=e["".concat(s,",").concat(o)],n=t[Object.keys(t)[0]];c(n,d)})).catch(Ae.default).catch((function(e){uc(r)(e)}));case 5:case"end":return e.stop()}}),e)})));return function(t,n,a,r){return e.apply(this,arguments)}}(),O=function(){var e=Object(Y.a)(G.a.mark((function e(t,n,a){var c,i,o,s,l,d,u,j,p;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c={},i=Object(b.a)(n,2),o=i[0],s=i[1],l=a.startDateTimeStamp,d=a.endDateTimeStamp,!((null===t||void 0===t?void 0:t.getTime())<Date.now())){e.next=9;break}return u=wn.createChildApi({action:"?app_id=".concat(AK,"&app_key=").concat(SK,"&end=").concat(d,"&location=[(").concat(s,",").concat(o,")]&start=").concat(l)}),j=u.fetch(),p=j.promise,e.next=8,p.then((function(e){var t=e.data["".concat(s,",").concat(o)];return t[Object.keys(t)[0]]})).catch(Ae.default).catch((function(e){uc(r)(e)}));case 8:c=e.sent;case 9:return e.abrupt("return",c);case 10:case"end":return e.stop()}}),e)})));return function(t,n,a){return e.apply(this,arguments)}}(),h=function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,o,s,l,b,j,m,v,h;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("complete"!==n||!c){e.next=23;break}d(!0),a=[],o=[u,u],s=0;case 5:if(!(s<o.length)){e.next=15;break}return l=f(new Date(null===t||void 0===t?void 0:t.startDate),null===t||void 0===t?void 0:t.startDateEpoch,null===t||void 0===t?void 0:t.duration,s,null===t||void 0===t?void 0:t.id,new Date(null===t||void 0===t?void 0:t.dueDate)),e.next=9,O(new Date(l.startDateTimeStamp),i,l);case 9:b=e.sent,j=p(s,b,l.startDateTimeStamp),a.push(j);case 12:s+=1,e.next=5;break;case 15:return m=Object(I.a)(Object(I.a)({},t),{},{applicationStrategy:"ratearea",weather:a}),e.next=18,gn.update(t.taskId,m);case 18:return v=e.sent,h=v.promise,e.next=22,h.catch(Ae.default).catch((function(e){uc(r)(e)}));case 22:d(!1);case 23:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();return{setWeatherObj:p,updateTaskWeather:h,fetchClearAppWeatherData:m,fetchClearAppWeatherDataReturn:O,fetchURLDetails:f,getCoordinates:function(e,t,n){var a,r,c;if(("create"===e||"convert"===e||"duplicate"===e)&&(null===t||void 0===t||null===(a=t.properties)||void 0===a||null===(r=a.features)||void 0===r?void 0:r.length)>0){var i,o=null===t||void 0===t||null===(i=t.properties)||void 0===i?void 0:i.map((function(e){return e.features[0]})),s=Oj(o);c=Object(v.a)(s)}else{var l,d,u=null===t||void 0===t||null===(l=t.properties)||void 0===l?void 0:l.map((function(e){var t;return null===n||void 0===n||null===(t=n.features)||void 0===t?void 0:t.find((function(t){return e.farmId===t.properties.propertyId&&"field"===t.properties.$landType}))}));if(u.length>0&&(null===n||void 0===n||null===(d=n.features)||void 0===d?void 0:d.length)>0){var b=Oj(u);c=Object(v.a)(b)}}return c},getNumericValue:function(e){var t=(e||"").match(/(\d+)/);return t&&(null===t||void 0===t?void 0:t.length)>0?e.match(/(\d+)/)[0]:""},checkForValidWindDirection:j,TaskWeatherObj:u,DefaultWeatherData:[{date:"",temperature:"",temperatureUnit:"F",humidity:"",skyCondition:"",windSpeed:"",windSpeedUnit:"MPH",windDirection:"",soilMoisture:"unknown",type:"start"},{date:"",temperature:"",temperatureUnit:"F",humidity:"",skyCondition:"",windSpeed:"",windSpeedUnit:"MPH",windDirection:"",soilMoisture:"unknown",type:"end"}],updating:l}},NK=O.StyleSheet.create({taskDetailsContainer:{display:"flex",flexDirection:"row",justifyContent:"space-between"},taskDetails:{width:"50%"},imageContainer:{width:270,height:198},title:{fontFamily:"Noto Sans",fontWeight:"medium",fontSize:12,marginBottom:12},row:{display:"flex",flexDirection:"row",justifyContent:"space-between",marginBottom:20},fieldContainer:{width:"50%"},fieldText:{fontFamily:"Noto Sans",fontSize:9},fieldTitle:{color:"#363948",lineHeight:2},fieldValue:{color:"#14151C",fontWeight:"medium"}}),EK=function(e){var t=e.task,n=e.exportLanguage,a=function(e){return e?"english"===n?Object(ya.a)(e,"MM/dd/yyyy h:mm:ss aa"):Object(ya.a)(e,"dd/MM/yyyy h:mm:ss aaaa"):"-"};return Object(y.jsxs)(O.View,{style:NK.taskDetailsContainer,children:[Object(y.jsxs)(O.View,{style:NK.taskDetails,children:[Object(y.jsxs)(O.View,{children:[Object(y.jsx)(O.Text,{style:NK.title,children:k.taskDetails[n]}),Object(y.jsxs)(O.View,{style:NK.row,children:[Object(y.jsxs)(O.View,{style:NK.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[NK.fieldText,NK.fieldTitle],children:k.startTime[n]}),Object(y.jsx)(O.Text,{style:[NK.fieldText,NK.fieldValue],children:a(t.startDateEpoch)})]}),Object(y.jsxs)(O.View,{style:NK.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[NK.fieldText,NK.fieldTitle],children:k.finishTime[n]}),Object(y.jsx)(O.Text,{style:[NK.fieldText,NK.fieldValue],children:a(t.dueDateEpoch)})]})]}),Object(y.jsxs)(O.View,{style:NK.row,children:[Object(y.jsxs)(O.View,{style:NK.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[NK.fieldText,NK.fieldTitle],children:k.authorizedBy[n]}),Object(y.jsx)(O.Text,{style:[NK.fieldText,NK.fieldValue],children:aa(t.authorizedBy)})]}),Object(y.jsxs)(O.View,{style:NK.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[NK.fieldText,NK.fieldTitle],children:k.authorizedOn[n]}),Object(y.jsx)(O.Text,{style:[NK.fieldText,NK.fieldValue],children:a(t.authorizedDateEpoch)})]})]}),Object(y.jsx)(O.View,{style:NK.row,children:Object(y.jsxs)(O.View,{style:NK.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[NK.fieldText,NK.fieldTitle],children:k.timingEvent[n]}),Object(y.jsx)(O.Text,{style:[NK.fieldText,NK.fieldValue],children:aa(t.timingEvent)})]})})]}),Object(y.jsx)(Ta,{applicators:t.applicators})]}),Object(y.jsx)(O.View,{style:NK.imageContainer,children:t.mapImage&&Object(y.jsx)(O.Image,{src:t.mapImage})})]})},wK=O.StyleSheet.create({title:{fontFamily:"Noto Sans",fontWeight:"medium",fontSize:12,marginBottom:12,marginTop:3},row:{display:"flex",flexDirection:"row",justifyContent:"space-between",marginBottom:20},fieldContainer:{width:"25%"},fieldText:{fontFamily:"Noto Sans",fontSize:9},fieldTitle:{color:"#363948",lineHeight:2},fieldValue:{color:"#14151C",fontWeight:"medium"}}),_K=function(e){var t=e.weather,n=e.title,a=e.exportLanguage,r=void 0===a?"english":a;return Object(y.jsx)(O.View,{children:Object(y.jsxs)(O.View,{children:[Object(y.jsx)(O.Text,{style:wK.title,children:n}),Object(y.jsxs)(O.View,{style:wK.row,children:[Object(y.jsxs)(O.View,{style:wK.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[wK.fieldText,wK.fieldTitle],children:F.skyCondition[r]}),Object(y.jsx)(O.Text,{style:[wK.fieldText,wK.fieldValue],children:aa(t.skyCondition)})]}),Object(y.jsxs)(O.View,{style:wK.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[wK.fieldText,wK.fieldTitle],children:F.windSpeed[r]}),Object(y.jsx)(O.Text,{style:[wK.fieldText,wK.fieldValue],children:ra(t.windSpeed)})]}),Object(y.jsxs)(O.View,{style:wK.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[wK.fieldText,wK.fieldTitle],children:F.windDirection[r]}),Object(y.jsx)(O.Text,{style:[wK.fieldText,wK.fieldValue],children:aa(t.windDirection)})]}),Object(y.jsxs)(O.View,{style:wK.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[wK.fieldText,wK.fieldTitle],children:F.soilCondition[r]}),Object(y.jsx)(O.Text,{style:[wK.fieldText,wK.fieldValue],children:aa(t.soilMoisture)})]})]}),Object(y.jsxs)(O.View,{style:[wK.row,{justifyContent:"flex-start"}],children:[Object(y.jsxs)(O.View,{style:wK.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[wK.fieldText,wK.fieldTitle],children:F.temperature[r]}),Object(y.jsx)(O.Text,{style:[wK.fieldText,wK.fieldValue],children:ra(t.temperature)})]}),Object(y.jsxs)(O.View,{style:wK.fieldContainer,children:[Object(y.jsx)(O.Text,{style:[wK.fieldText,wK.fieldTitle],children:F.humidity[r]}),Object(y.jsx)(O.Text,{style:[wK.fieldText,wK.fieldValue],children:ra(t.humidity)})]})]})]})})};_K.defaultProps={weather:{}};var RK=_K,IK={english:[{label:"Name/Active",width:18},{label:"Reg #",width:11},{label:"Pest",width:11},{label:"REI",width:6},{label:"PHI",width:6},{label:"App Method",width:12},{label:"App Area",width:12},{label:"$RATE$",labelRateArea:"Rate/Area",labelRateTank:"Rate/Tank",width:10},{label:"Total",width:14}],LATAMSpanish:[{label:"Nombre/activo",width:18},{label:"N.\xb0 de reg.",width:11},{label:"Peste",width:11},{label:"IER",width:6},{label:"PHI",width:6},{label:"M\xe9todo de aplicaci\xf3n",width:12},{label:"\xc1rea de aplicaci\xf3n",width:10},{label:"$RATE$",labelRateArea:"Tasa aplic./cult.",labelRateTank:"Tasa/tanque",width:10},{label:"Total",width:14}]};function DK(e){var t=e.language,n="ByRatePerTank"===e.applicationStrategy?"labelRateTank":"labelRateArea";return IK[t].map((function(e){return"$RATE$"===e.label?Object(I.a)(Object(I.a)({},e),{},{label:e[n]}):e}))}var kK=18,LK={english:[{label:"Farm",width:kK},{label:"Field",width:kK},{label:"Crop Zone",width:kK},{label:"Crop",width:kK},{label:"Center Lat/Long",width:19},{label:"App Area",width:9}],LATAMSpanish:[{label:"Granja",width:kK},{label:"Campos",width:kK},{label:"Zona de Cultivo",width:kK},{label:"Cultivo",width:kK},{label:"Lat./long. del centro",width:19},{label:"\xc1rea de aplicaci\xf3n",width:9}]},FK=function(e){var t=e.products,n=e.applicationStrategy,a=e.cropNames;return t.map((function(e){var t,r,c=e.activeIngredients.map((function(e){return{label:e.name,styles:{fontSize:8,fontFamily:"Noto Sans",fontWeight:"light",fontStyle:"italic",marginTop:3}}})),i="-",o="-",s=Object(v.a)(new Set(null===a||void 0===a?void 0:a.map((function(e){return e.cropName}))));if(null!==(t=e.reiphisData)&&void 0!==t&&t.length){var l=s.find((function(t){return e.reiphisData.some((function(e){var n;return null===(n=e.cropName)||void 0===n?void 0:n.toLowerCase().includes(t.toLowerCase())}))}));if(l){var d=e.reiphisData.find((function(e){var t;return(null===(t=e.cropName)||void 0===t?void 0:t.toLowerCase())===l.toLowerCase()}));i="".concat(null===d||void 0===d?void 0:d.rei),o="".concat(null===d||void 0===d?void 0:d.phi)}}var u=Ia(e.productName,{width:"".concat(18,"%"),marginBottom:3},c),b=Ia(e.registrationnumber,{width:"".concat(11,"%")}),j=Ia((null===(r=e.targetPest)||void 0===r?void 0:r.name)||"-",{width:"".concat(11,"%")}),p=Ia(i,{width:"".concat(6,"%")}),f=Ia(o,{width:"".concat(6,"%")}),m=Ia(e.applicationMethod||"-",{width:"".concat(12,"%")}),O=Ia("".concat(ee(e.appliedAreaValue,"fixed")," ").concat(Object(va.g)(e.appliedAreaUnit)),{width:"".concat(12,"%")}),h={ByRatePerTank:"ratePerTankUnit",ByRatePerArea:"ratePerAreaUnit",ByTotalProduct:"ratePerAreaUnit"}[n];return[u,b,j,p,f,m,O,Ia("".concat(ee(e[{ByRatePerTank:"ratePerTankValue",ByRatePerArea:"ratePerAreaValue",ByTotalProduct:"ratePerAreaValue"}[n]],"fixed")," ").concat(Object(va.g)(e[h])),{width:"".concat(10,"%")}),Ia("".concat(ee(e.totalProductValue,"fixed")," ").concat(Object(va.g)(e.totalProductUnit)),{width:"".concat(14,"%")})]}))},MK=O.StyleSheet.create({title:{fontFamily:"Noto Sans",fontSize:12,fontWeight:600,marginBottom:12},productName:{fontFamily:"Noto Sans",fontWeight:400,fontSize:12},row:{display:"flex",flexWrap:"wrap",flexDirection:"row",width:532,marginBottom:12},fieldText:{fontFamily:"Noto Sans",fontSize:9},fieldTextWarning:{fontFamily:"Noto Sans",fontWeight:500,fontSize:9},fieldTitle:{color:"#363948",width:64,alignItems:"flex-start",justifySelf:"flex-start",flexDirection:"row",flexGrow:1},fieldValue:{color:"#14151C",width:468,flexDirection:"row",flexGrow:2}}),VK=function(e){var t=e.exportLanguage,n=e.workerProtectionData;return Object(y.jsxs)(O.View,{children:[Object(y.jsx)(O.View,{style:MK.tableHeaderContainer,children:Object(y.jsx)(O.Text,{style:MK.title,children:z.workerProtection[t]})}),n.map((function(e){var t,n;return e?Object(y.jsxs)(O.View,{children:[Object(y.jsx)(O.View,{style:MK.row,children:Object(y.jsxs)(O.Text,{style:[MK.productName],children:[aa(e.productName)," "]})}),Object(y.jsxs)(O.View,{style:MK.row,wrap:!1,children:[Object(y.jsx)(O.Text,{style:[MK.fieldText,MK.fieldTitle],children:"Signal Word"}),Object(y.jsx)(O.Text,{style:[MK.fieldTextWarning,MK.fieldValue],children:aa(null===(t=e.signalword)||void 0===t?void 0:t.toUpperCase())})]}),Object(y.jsxs)(O.View,{style:MK.row,wrap:!1,children:[Object(y.jsx)(O.Text,{style:[MK.fieldText,MK.fieldTitle],children:"RUP"}),Object(y.jsx)(O.Text,{style:[MK.fieldTextWarning,MK.fieldValue],children:aa(null===(n=e.rup)||void 0===n?void 0:n.toUpperCase())})]}),Object(y.jsxs)(O.View,{style:MK.row,wrap:!1,children:[Object(y.jsx)(O.Text,{style:[MK.fieldText,MK.fieldTitle],children:"PPE"}),Object(y.jsx)(O.Text,{style:[MK.fieldText,MK.fieldValue],children:aa(e.ppe)})]}),Object(y.jsxs)(O.View,{style:MK.row,wrap:!1,children:[Object(y.jsx)(O.Text,{style:[MK.fieldText,MK.fieldTitle],children:"ReEntry"}),Object(y.jsx)(O.Text,{style:[MK.fieldText,MK.fieldValue],children:aa(e.ppereentry)})]})]},e.key):null}))]})},BK=O.StyleSheet.create({viewContainer:{marginBottom:27}}),UK=function(e){var t,n,a=e.task;return a?Object(y.jsxs)(wa,{headerTitle:a.name,type:D.task[a._exportLanguage].toString(),orgName:a.organizationName,cropSeasons:a.cropSeasons,generatedYear:a.year,generatedFullDate:a.fullDate,status:a.status,exportLanguage:a._exportLanguage.toString(),children:[Object(y.jsxs)(O.View,{style:BK.viewContainer,children:[Object(y.jsx)(EK,{task:a,exportLanguage:a._exportLanguage}),Object(y.jsx)(RK,{title:F.environmentalStartingConditions[a._exportLanguage],weather:null===(t=a.weather)||void 0===t?void 0:t[0],exportLanguage:a._exportLanguage}),"complete"===a.status&&Object(y.jsx)(RK,{title:"Environmental Ending Conditions",weather:null===(n=a.weather)||void 0===n?void 0:n[1]}),Object(y.jsx)(xa,{tankInformation:a.tankInformation,exportLanguage:a._exportLanguage})]}),Object(y.jsx)(O.View,{style:BK.viewContainer,children:Object(y.jsx)(R,{title:V.products[a._exportLanguage],headerItems:DK({language:a._exportLanguage,applicationStrategy:a.applicationStrategy}),bodyItems:a.products})}),Object(y.jsx)(O.View,{style:BK.viewContainer,children:Object(y.jsx)(R,{title:B.fields[a._exportLanguage],headerItems:LK[a._exportLanguage],bodyItems:a.properties,titleRight:"".concat(B.area[a._exportLanguage]," ").concat(ee(a.totalFieldsArea,"fixed")," ac.")})}),Object(y.jsx)(O.View,{style:BK.viewContainer,children:Object(y.jsx)(ma,{notes:a.notes,exportLanguage:a._exportLanguage})}),Object(y.jsx)(O.View,{style:BK.viewContainer,children:"ready"===a.status&&Object(y.jsx)(VK,{workerProtectionData:a.workerProtection,exportLanguage:a._exportLanguage})}),Object(y.jsx)(O.View,{style:BK.viewContainer,wrap:!1,children:Object(y.jsx)(Ca,{exportLanguage:a._exportLanguage})})]}):null};UK.defaultProps={task:null};var zK=UK,ZK=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,1)[0].organization,n=hx(),r=n.downloadPDFV2,c=n.downloading,i=n.setDownloading,o=Object(a.useState)(),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(O.usePDF)({document:Object(y.jsx)(zK,{task:l})}),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useRef)(void 0),h="english";Object(a.useEffect)((function(){l&&f()}),[l]),Object(a.useEffect)((function(){!p.loading&&p.url&&m.current!==p.url&&l&&(m.current=p.url,r(m.current,"Task - ".concat(l.name,".pdf")),d(null),i(!1))}),[p]);var x=function(){var e=Object(Y.a)(G.a.mark((function e(n){var a,r,c,o,s,l,u,b,j,p,f,m,O,x,g,C,y,P;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i(!0),a=gn.fetch(n),r=a.promise,e.next=4,r.catch((function(){return{}}));case 4:if(c=e.sent,!(o=c.data)){e.next=27;break}return s=[],l=o.properties.map(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,i,o;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ca(t.cropZoneId);case 2:return n=e.sent,a=n.cropZone,r=n.field,c=n.farm,i=n.crop,o=n.centroId.geometry,a&&s.push(na(a.geometry)),e.abrupt("return",Object(I.a)(Object(I.a)({},t),{},{farmName:c.name,fieldName:r.name,cropZoneName:a.name,cropName:i.name,latlong:null===o||void 0===o?void 0:o.coordinates}));case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),u=o.products.map(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c,i;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ia(t.productId);case 2:return n=e.sent,a=n.masterProduct.registrationnumber,r=n.activeIngredients,c=n.reiphisData,i=n.workerProtection,e.abrupt("return",Object(I.a)(Object(I.a)({},t),{},{registrationnumber:a?k_(a):"-",activeIngredients:r,reiphisData:c,workerProtection:i}));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),b=$t.fetch(o.cropSeasonIds[0].id),j=b.promise,e.next=13,Promise.allSettled([].concat(Object(v.a)(l),Object(v.a)(u),[j]));case 13:return p=e.sent,f=p.slice(0,l.length),m=p.slice(l.length,-1),O=p.slice(-1),x=Da(o.properties),g=new Date,C=Object(ya.a)(g,"yyyy"),y={english:Object(ya.a)(g,"MM/dd/yyyy h:mm aaa"),LATAMSpanish:Object(ya.a)(g,"dd/MM/yyyy h:mm aaaa")},e.next=23,ta(s);case 23:P=e.sent,d(Object(I.a)(Object(I.a)({},o),{},{properties:(S=f.filter((function(e){return"fulfilled"===e.status})).map((function(e){return e.value})),S.map((function(e){return[Ia(e.farmName,{width:"".concat(kK,"%")}),Ia(e.fieldName,{width:"".concat(kK,"%")}),Ia(e.cropZoneName,{width:"".concat(kK,"%")}),Ia(e.cropName,{width:"".concat(kK,"%")}),Ia("".concat(e.latlong[1],", ").concat(e.latlong[0]),{width:"".concat(19,"%")}),Ia(ee(e.areaValue,"fixed"),{width:"".concat(9,"%")})]}))),organizationName:t.name,cropSeasons:O.filter((function(e){return"fulfilled"===e.status})).map((function(e){return e.value.data.name})),products:FK({products:m.filter((function(e){return"fulfilled"===e.status})).map((function(e){return e.value})),applicationStrategy:o.applicationStrategy,cropNames:f.filter((function(e){return"fulfilled"===e.status})).map((function(e){return e.value}))}),test:"test",_exportLanguage:h,workerProtection:(A=m.filter((function(e){return"fulfilled"===e.status})).map((function(e){return e.value})),A.map((function(e){return e.workerProtection}))),totalFieldsArea:x,year:C,fullDate:y,mapImage:P})),e.next=28;break;case 27:i(!1);case 28:case"end":return e.stop()}var A,S}),e)})));return function(t){return e.apply(this,arguments)}}();return{downloadingPDF:c,exportPdfEnglish:function(e){h="english",x(e)},exportPdfSpanish:function(e){h="LATAMSpanish",x(e)}}},YK=function(){var e=Object(a.useState)({cancel:function(){},promise:function(){}}),t=Object(b.a)(e,2),n=t[0],r=t[1],c=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={},n=An.fetch(),r(n),e.abrupt("return",n.promise.then((function(e){var n=e.filter((function(e){return"200"===e.status}));return t=n.length?Object(I.a)(Object(I.a)({},t),{},{title:"Tasks imported successfully",message:"".concat(n.length," task").concat(1===n.length?"":"s"," were imported from Cropwise Connect"),type:"success"}):Object(I.a)(Object(I.a)({},t),{},{title:"No tasks found",message:"We were unable to find any tasks within your Cropwise Connect Integration",type:"error"})})).catch((function(e){return"Cancelled johnDeere fetch"===e.message?{}:t=Object(I.a)(Object(I.a)({},t),{},{title:"No integration found",message:"Unable to find a configured integration via Cropwise Connect. Check your integrations to ensure it\u2019s been fully configured",type:"error",buttonFooterText:"Go To Integration Page",buttonFooterType:"INTEGRATION"})})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return{cancelFetchActive:function(){n.cancel()},getTasksByFetchToConnect:c}},HK=n.p+"static/media/cropwise_connect_logo.33554894.svg",GK=function(e){var t=e.isOpen,n=e.onCancel,r=e.onImportFinish,c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=YK(),d=l.cancelFetchActive,u=l.getTasksByFetchToConnect,j=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,s(!0),e.next=4,u();case 4:t=e.sent,Object.keys(t).length&&r(t);case 6:return e.prev=6,s(!1),e.finish(6);case 9:case"end":return e.stop()}}),e,null,[[0,,6,9]])})));return function(){return e.apply(this,arguments)}}();return Object(y.jsx)(m.SimpleModal,{icon:Object(y.jsx)("img",{src:HK,alt:"Cropwise Connect"}),open:t,onCancel:function(){s(!1),d(),n()},onConfirm:j,close:n,confirmLabel:"Import",title:"Import Tasks From Connect",isSaving:o,children:Object(y.jsx)("div",{className:"mt-6",children:o?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(m.Spinner,{"data-testid":"import-modal-spinner"}),Object(y.jsx)("p",{className:"mt-2 mb-8 text-center font-body text-sm",children:"Importing tasks, this may take a minute if you have a lot of data"})]}):Object(y.jsx)("p",{className:"mt-2 mb-8 pl-2 pr-2 font-body text-sm","data-testid":"import-modal-paragraph",children:"If you have set up a machinery integration in Cropwise Connect click here to import tasks and automatically import them into Cropwise Financials"})})})};GK.defaultProps={onCancel:function(){},onImportFinish:function(){}};var WK=GK,qK=Sd(fd,"list"),JK=function(){var e=qK.get(),t=Object(a.useState)(e),n=Object(b.a)(t,1)[0],r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)({title:"",message:"",type:"success"}),l=Object(b.a)(s,2),d=l[0],u=l[1],j=RG(),f=j.tasks,v=j.deleteTask,O=j.updateTaskStatus,h=j.loading,x=j.loadLandingPageTasks,g=j.updating,C=j.totalTasks,P=j.getTaskById,A=TK(),S=A.updateTaskWeather,T=A.updating,N=ZK(),E=N.exportPdfEnglish,w=N.exportPdfSpanish,_=N.downloadingPDF,R=Object(a.useContext)(ac),D=Object(b.a)(R,2),k=D[0],L=k.loggedInUserOrgPermission,F=k.loadingOrg,M=k.isGlobalCropSeasonLoading,V=D[1],B=Object(a.useState)(0),U=Object(b.a)(B,2),z=U[0],Z=U[1],H=Object(a.useState)({}),W=Object(b.a)(H,2),q=W[0],J=W[1],K=Object(a.useState)(null),Q=Object(b.a)(K,2),X=Q[0],$=Q[1],ee=Object(a.useState)(),te=Object(b.a)(ee,2),ae=te[0],re=te[1],ce=zi(X,500),ie=Object(a.useState)({open:!1,id:null}),oe=Object(b.a)(ie,2),se=oe[0],le=oe[1],de=Object(a.useState)(!1),ue=Object(b.a)(de,2),be=ue[0],je=ue[1],pe=Object(a.useState)(""),fe=Object(b.a)(pe,2),me=fe[0],ve=fe[1],Oe=Object(a.useState)(),he=Object(b.a)(Oe,2),xe=he[0],ge=he[1],Ce=Object(a.useState)([]),ye=Object(b.a)(Ce,2),Pe=ye[0],Se=ye[1],Te=Object(a.useState)(null),Ne=Object(b.a)(Te,2)[1],Ee=Object(a.useContext)(we),_e=Object(a.useState)(-1),Re=Object(b.a)(_e,2),Ie=Re[0],De=Re[1],ke=Object(a.useState)(!1),Le=Object(b.a)(ke,2),Fe=Le[0],Me=Le[1],Ve=Object(a.useState)(!1),Be=Object(b.a)(Ve,2),Ue=Be[0],ze=Be[1],Ze=Object(p.h)(),Ye=Object(a.useRef)(),He=Object(a.useRef)();Object(a.useEffect)((function(){var e=JSON.stringify(q),t=(ce!==Ye.current||e!==He.current)&&0!==z;Ye.current=ce,He.current=e,x({page:z,searchText:ce,daterange:null===q||void 0===q?void 0:q.daterange}),t&&Z(0)}),[ce,z,q,x]),Object(a.useEffect)((function(){var e=new URLSearchParams(location.search).get("search");e&&$(e)}),[]),Object(a.useEffect)((function(){!function(){var e=new URLSearchParams;ce&&e.set("search",ce),Ze.replace({search:e.toString()})}()}),[ce,Ze,q]),Object(a.useEffect)((function(){"Full control"!==(null===L||void 0===L?void 0:L.role)||Object.prototype.hasOwnProperty.call(L,"financialAccess")?re(null===L||void 0===L?void 0:L.financialAccess):re("none")}),[L]),Object(a.useEffect)((function(){Ee.sendEventToAmplitude(Ee.events.epic.Tasks.accessTasksSuccess)}),[]);var Ge=function(){x(),Z(0)},We=Object(a.useCallback)((function(e){var t=e.target.value;J((function(e){return 2===t.length?Object(I.a)(Object(I.a)({},e),{},{daterange:t}):0===t.length?Object(I.a)(Object(I.a)({},e),{},{daterange:[]}):e}))}),[]),qe=function(){le({open:!1,id:null})},Je=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:v(se.id),qe();case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Ke=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,P(xe);case 2:return n=e.sent,ze(!0),a=Object(I.a)(Object(I.a)({},n),{},{applicationStrategy:"ratearea",flags:t}),e.next=7,gn.update(xe,a);case 7:return r=e.sent,c=r.promise,e.next=11,c.then((function(){x(),Se(t),ze(!1)})).catch(Ae.default).catch((function(e){var t,n,a,r;null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.validationErrors?Ne("Error saving task: ".concat(e.response.data.message)):null!==(a=e.response)&&void 0!==a&&null!==(r=a.data)&&void 0!==r&&r.displayErrorMessage?Ne(e.response.data.displayErrorMessage):uc(V)(e),ze(!1)}));case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Qe=function(){return o(!1)},Xe=function(e,t,n){De(n);var a={view:function(){Ee.sendEventToAmplitude(Ee.events.epic.Tasks.viewTask),Ze.push("".concat(Cc.tasks,"/").concat(t.id,"/view"),{memberRole:null===L||void 0===L?void 0:L.role,memberFinancialAccess:Object.prototype.hasOwnProperty.call(L,"financialAccess")?null===L||void 0===L?void 0:L.financialAccess:"none"})},edit:function(){Ee.sendEventToAmplitude(Ee.events.epic.Tasks.editTask),Ze.push("".concat(Cc.tasks,"/").concat(t.id))},delete:function(){le({id:t.id,open:!0})},tag:function(){var e;ve(t.name),ge(t.id),Se((null===(e=t.flags.flags)||void 0===e?void 0:e.length)>0||void 0!==t.flags.flags?t.flags.flags:[]),je(!0)},exportPdfEnglish:E,exportPdfSpanish:w,duplicate:function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Ee.sendEventToAmplitude(Ee.events.epic.Tasks.duplicateTask),e.next=3,V({type:"SET_CONVERT_PLAN",payload:{id:t.id}});case 3:Ze.push("".concat(Cc.tasks,"/duplicate"));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()};a[e](t.id)},$e=function(){var e=null===L||void 0===L?void 0:L.role.toLowerCase();return("full control"===e||"admin"===e)&&"WRITE"===nr};return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(lo,{onOrganizationSelect:Ge,hideCropSeasonDropdown:!1,onCropSeasonSelect:Ge,children:Object(y.jsx)(lo.Item,{title:"Tasks",value:"All Tasks",isLast:!0})}),Object(y.jsxs)("div",{className:"flex items-center justify-between",children:[Object(y.jsx)(To,{id:"task-search-input",showCropSeason:!1,name:"search_tasks",placeholder:"Search Tasks",searchValue:X,onChange:function(e){$(e.target.value)},onChangeLabel:ne.noop,onChangeProductType:ne.noop,onChangeTaskType:ne.noop,onDateRangeChange:We}),Object(y.jsx)("div",{className:"flex items-center",children:Object(y.jsx)("div",{className:"pl-2 whitespace-no-wrap",children:$e()&&Object(y.jsx)(m.Button,{id:"add-task-button",type:"primary",icon:Object(y.jsx)(Eo.a,{}),onClick:function(){jc(V,"SET_TASK_CREATION_FROM",Ee.events.epic.Tasks.pages.fromTaskLanding),Ee.sendEventToAmplitude(Ee.events.epic.Tasks.createTask,{page:Ee.events.epic.Tasks.pages.fromTaskLanding}),Ze.push("".concat(Cc.tasks,"/create"))},children:"Create Task"})})})]}),h||Ue||F||M?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(aK,{updatingTask:g,updatingWeather:T,children:Object(y.jsxs)(y.Fragment,{children:[f&&f.length?Object(y.jsxs)("div",{children:[Object(y.jsx)(ib,{open:se.open,itemType:"Task",onCancel:function(){return qe()},onDelete:function(){Ee.sendEventToAmplitude(Ee.events.epic.Tasks.deleteTask),Je()}}),Object(y.jsx)(l_,{open:be,close:function(){je(!1)},name:me,selectedTags:null===Pe||void 0===Pe?void 0:Pe.reduce((function(e,t){return"".concat(e,",").concat(t.id)}),""),returnSelectedTags:function(e){return Ke(e)}}),"board"===n?Object(y.jsx)(mK,{tasks:f,updateTask:O,loadLandingPageTasks:x,setTagsSaving:ze,memberRole:null===L||void 0===L?void 0:L.role,memberFinancialAccess:ae,updateTaskWeather:S,handleAction:Xe}):Object(y.jsx)(xK,{tasks:f,setTagsSaving:ze,memberRole:null===L||void 0===L?void 0:L.role,memberFinancialAccess:ae,handleAction:Xe,totalTasks:C,taskPageNumber:z,setTaskPageNumber:Z,downloadingPDF:_,rowIndexLoading:Ie})]}):Object(y.jsx)(Vd,{buttonText:"Create Task",onClick:function(){jc(V,Qr,Ee.events.epic.Tasks.pages.fromEmptyState),Ee.sendEventToAmplitude(Ee.events.epic.Tasks.createTask,{page:Ee.events.epic.Tasks.pages.fromEmptyState}),Ze.push("".concat(Cc.tasks,"/create"))},subtitle:"We were unable to find any tasks under this organization.",text:"Create a New Task.",setPermission:$e}),Object(y.jsx)(WK,{isOpen:Fe,onCancel:function(){return Me(!1)},onImportFinish:function(e){"success"===e.type&&(Me(!1),Ge()),u((function(t){return Object(I.a)(Object(I.a)({},t),e)})),o(!0)}}),Object(y.jsxs)(Qc,{type:d.type,title:d.title,open:i,onClose:Qe,children:[Object(y.jsx)("p",{className:"text-sm font-body",children:d.message}),Object(y.jsx)("div",{className:"flex mt-4 flex-row-reverse",children:d.buttonFooterType&&"NONE"!==d.buttonFooterType&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"mr-2",children:Object(y.jsx)(m.Button,{onClick:function(){"INTEGRATION"===d.buttonFooterType&&Ze.push(Cc.integrations)},danger:!0,type:"primary",children:d.buttonFooterText})}),Object(y.jsx)("div",{className:"mr-2",children:Object(y.jsx)(m.Button,{onClick:Qe,className:"border-0",type:"outline",style:{border:"none"},children:"Dismiss"})})]})})]})]})})]})},KK=n(2836),QK=function(e,t){var n=Object(a.useContext)(ac),r=Object(b.a)(n,1)[0],c=Object(a.useState)((function(){if("undefined"===typeof window)return t;try{var n=window.localStorage.getItem(e);return n?JSON.parse(n):t}catch(a){return t}})),i=Object(b.a)(c,2),o=i[0],s=i[1];return{storedValue:o,setValue:function(t){try{var n=t instanceof Function?t(o):t;s(n),"undefined"!==typeof window&&window.localStorage.setItem(e,JSON.stringify(n))}catch(a){r(a)}}}},XK=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date,n=e?new Date(e):t;return n instanceof Date&&!isNaN(n)?n:t},$K=Fu.e().shape({tankSizeValue:Fu.d().default(0),tankSizeUnit:Fu.f().default("bag"),tankCount:Fu.d().default(0),carrierPerAreaValue:Fu.d().default(0),carrierPerAreaUnit:Fu.f().default("bag"),totalCarrierValue:Fu.d().default(0),totalCarrierUnit:Fu.f().default("bag"),tankValueTypeEnteredByUser:Fu.f().default("CarrierPerArea")}),eQ=Fu.e().shape({date:Fu.c().nullable(),temperature:Fu.f().default(""),temperatureUnit:Fu.f().default("F"),relativeHumidity:Fu.f().default(""),skyCondition:Fu.f().default(""),windSpeed:Fu.f().default(""),windSpeedUnit:Fu.f().default("MPH"),windDirection:Fu.f().default(""),soilMoisture:Fu.f().default(""),type:Fu.f().default("")}),tQ=Fu.a().nullable().of(eQ),nQ=Fu.a().nullable().of(Fu.e()),aQ=Fu.a().nullable().of(Fu.e()),rQ=Fu.a().nullable().of(Fu.e()),cQ=Fu.a().nullable().of(Fu.e()),iQ=Fu.e().shape({name:Fu.f().trim().required("Name is required"),status:Fu.f().required("Status is a required field"),startDate:Fu.c().required("Start Date & Time is a required field"),duration:Fu.f().default(2).required("Duration is a required field"),type:Fu.f().default("General"),timingEvent:Fu.f().default(""),applicationStrategy:Fu.f().default("ratearea"),flags:Fu.f().default(""),source:Fu.f().default(""),authorizedBy:Fu.f().default(""),authorizedDate:Fu.c().nullable(),bufferZone:Fu.f().default(""),bufferReason:Fu.f().default(""),totalAreaValue:Fu.d().default(0),tankInformation:$K,weather:tQ,applicators:aQ,assigneeIds:nQ,notes:Fu.f().default(""),totalApplied:Fu.d().default(0),coveragePercent:Fu.d().default(100),properties:cQ,products:rQ}),oQ=function(e){var t=e.people,n=e.peopleLoading,a=e.handleRemove,r=Object(Zi.h)().values,c=t?t.map((function(e){return{key:e.id,value:e.name}})):[],i=function(e){return Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"w-full",children:n?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(Qi,{label:"".concat(e+1).concat(hW(e+1)," Assignee"),control:m.Select,name:"assigneeIds[".concat(e,"].id"),items:c})}),Object(y.jsx)("div",{className:"ml-2",children:Object(y.jsx)(m.Button,{type:"outline",ghost:!0,onClick:function(){return a(e)},icon:Object(y.jsx)(Kx.a,{})})})]})};return Object(y.jsxs)(y.Fragment,{children:[r.assigneeIds&&r.assigneeIds.length?r.assigneeIds.map((function(e,t){return i(t)})):i(0),Object(y.jsx)(y.Fragment,{})]})};oQ.defaultProps={people:[]};var sQ=n(2846),lQ=n(2834),dQ=n(2835),uQ=[{key:"ready",value:"Ready"},{key:"inprogress",value:"In Progress"},{key:"complete",value:"Complete"}],bQ=function(e){var t=e.people,n=e.peopleLoading,r=e.weatherAutomaticToggle,c=e.memberRole,i=e.memberFinancialAccess,o=Object(Zi.h)(),s=o.values,l=o.setFieldValue,d=o.setFieldTouched,u=Object(a.useState)(!1),j=Object(b.a)(u,2),p=j[0],f=j[1],v=Object(a.useState)((null===s||void 0===s?void 0:s.flags)||[]),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)({extraTagsCount:0,extraTagsNames:[],tagsToDisplay:[]}),C=Object(b.a)(g,2),P=C[0],A=C[1],S=TK().TaskWeatherObj,T=[{key:"0",value:"0 Hours"},{key:"0.5",value:"0.5 Hours"},{key:"1",value:"1 Hour"},{key:"1.5",value:"1.5 Hours"},{key:"2",value:"2 Hours"},{key:"2.5",value:"2.5 Hours"},{key:"3",value:"3 Hours"},{key:"3.5",value:"3.5 Hours"},{key:"4",value:"4 Hours"},{key:"Custom",value:"Custom Hours"}],N=Object(Ru.a)(t?t.map((function(e){return{key:e.id,value:e.name}})):[],"value"),E=function(){return"Full control"===c&&("none"===i||"READ"===i)},w=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:l("flags",t),x(t);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();Object(a.useEffect)((function(){(null===h||void 0===h?void 0:h.length)>0&&A(Af(h,55)),s.flags&&x(s.flags)}),[h,s.flags]);var _=function(e){return(null===T||void 0===T?void 0:T.find((function(t){return t.key===e.toString()})))||"Custom"};return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(l_,{open:p,close:function(){return f(!1)},name:null===s||void 0===s?void 0:s.name,selectedTags:(null===h||void 0===h?void 0:h.length)>0?h.reduce((function(e,t){return"".concat(e,",").concat(t.id)}),""):"",returnSelectedTags:w,setFieldTouchedParent:d}),Object(y.jsx)(Qi,{label:"Task ID *",control:m.Input,name:"name"}),Object(y.jsx)(Qi,{label:"Task Status *",control:m.Select,name:"status",items:uQ,onChange:function(e){e.target.value.includes(s.status)||d("Task Status");var t=JSON.parse(e.target.value).key;"complete"!==t&&r&&l("weather",[S]),l("status",t)}}),Object(y.jsx)(Qi,{label:"Start Date & Time *",control:m.DatePicker,enableTime:!0,name:"startDate",dateFormat:"F j,  Y, h:i K",onChange:function(e){d("Start Date & Time");var t=e.target.value[0],n=Object(sQ.a)(s.dueDate,t),a=_(n/60);if("Custom"!==s.duration)l("dueDate",Object(vm.a)(t,60*Number(s.duration))),l("authorizedDate",t);else{var r=Object(sQ.a)(s.dueDate,s.startDate);l("startDate",e.target.value[0]),1===Object(lQ.a)(e.target.value[0],s.dueDate)?(l("dueDate",Object(vm.a)(e.target.value[0],r)),l("authorizedDate",t)):l("duration",a.key||a)}l("startDate",t)}}),Object(y.jsxs)("div",{className:"grid items-end grid-cols-2 gap-12",children:[Object(y.jsx)(Qi,{label:"Duration *",control:m.Select,name:"duration",disabled:E(),items:T,onChange:function(e){var t=JSON.parse(e.target.value).key;l("duration",t),"Custom"!==t&&l("dueDate",Object(vm.a)(s.startDate,60*Number(t)))}}),Object(y.jsx)(Qi,{label:"End Date & Time *",control:m.DatePicker,enableTime:!0,name:"dueDate",dateFormat:"F j,  Y, h:i K",onChange:function(e){var t=Object(sQ.a)(e.target.value[0],s.startDate),n=_(t/60);l("dueDate",e.target.value[0]),1===Object(lQ.a)(s.startDate,e.target.value[0])?"Custom"!==s.duration?l("startDate",Object(dQ.a)(e.target.value[0],60*Number(s.duration))):(l("startDate",e.target.value[0]),l("duration","0")):l("duration",n.key||n)}})]}),Object(y.jsx)(Qi,{label:"Task Type",control:m.Select,name:"type",items:[{key:"General",value:"General"},{key:"Irrigation",value:"Irrigation"},{key:"Land prep",value:"Land prep"},{key:"Planting",value:"Planting"},{key:"Spraying",value:"Spraying"},{key:"Spreading",value:"Spreading"}]}),Object(y.jsx)(Qi,{label:"Timing Event",control:m.Select,name:"timingEvent",items:[{key:"Pre-Plant",value:"Pre-Plant"},{key:"Planting",value:"Planting"},{key:"Growing",value:"Growing"},{key:"Harvest",value:"Harvest"},{key:"Storage",value:"Storage"},{key:"Annual",value:"Annual"}]}),Object(y.jsxs)("div",{children:[Object(y.jsx)(m.Label,{absolute:!0,children:"Tags"}),P.extraTagsNames.length>0?Object(y.jsx)(fu,{position:"bottom",ariaLabel:"Task Tags",top:"1.5rem",msg:Object(y.jsx)(Pf,{extraTagsNames:P.extraTagsNames}),component:Object(y.jsx)(Nf,{setOpenTags:f,tags:h,displayTagsObject:P,viewKey:fd,disabled:!1})}):Object(y.jsx)(Nf,{setOpenTags:f,tags:h,displayTagsObject:P,viewKey:fd,disabled:!1})]}),n?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(Qi,{label:"Authorized by",name:"authorizerId",control:m.Select,items:N,disabled:E()}),Object(y.jsx)(Qi,{label:"Authorization Date",control:m.DatePicker,enableTime:!0,name:"authorizedDate",dateFormat:"F j,  Y, h:i K",onChange:function(e){d("Authorization Date"),1===Object(lQ.a)(s.startDate,e.target.value[0])&&("Custom"!==s.duration?l("authorizedDate",Object(dQ.a)(e.target.value[0],60*Number(s.duration))):l("authorizedDate",e.target.value[0])),l("authorizedDate",e.target.value[0])}})]})};bQ.defaultProps={people:[],peopleLoading:!0,weatherAutomaticToggle:!1};var jQ=bQ,pQ=function(e){var t,n,r,c,i,o,s,l,d,u,j,f,O,h,x,g,C=e.index,P=e.fieldsAndAreasGeoJSONCollection,A=Object(Zi.h)(),S=A.values,T=A.setFieldValue,N=A.setFieldTouched,E=Object(p.j)().id,w=m.RadioButtonGroup.RadioButton,_=Object(a.useContext)(ac),R=Object(b.a)(_,1)[0].weatherAutomaticToggle,D=TK(),k=D.fetchClearAppWeatherDataReturn,L=D.fetchURLDetails,F=D.checkForValidWindDirection,M=D.DefaultWeatherData,V=Object(a.useState)(!0===R&&""!==(null===S||void 0===S?void 0:S.startDate)),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=Object(a.useState)([]),H=Object(b.a)(Z,2),W=H[0],q=H[1],J=function(e,t,n,a){var r,c,i,o,s,l,d,u,b,j,p,f,m,v;return{date:new Date(1e3*t),temperature:n||a?null===e||void 0===e||null===(r=e.air_temp)||void 0===r?void 0:r.value:null===S||void 0===S?void 0:S.weather[C].temperature,temperatureUnit:n||a?null===e||void 0===e||null===(c=e.air_temp)||void 0===c?void 0:c.unit:null===S||void 0===S||null===(i=S.weather[C])||void 0===i?void 0:i.temperatureUnit,humidity:n||a?null===e||void 0===e||null===(o=e.relative_humidity)||void 0===o?void 0:o.value:null===S||void 0===S?void 0:S.weather[C].humidity,skyCondition:n||a?null===e||void 0===e||null===(s=e.descriptors)||void 0===s||null===(l=s.weather_descriptor)||void 0===l?void 0:l.text:null===S||void 0===S||null===(d=S.weather[C])||void 0===d?void 0:d.skyCondition,windSpeed:n||a?null===e||void 0===e||null===(u=e.wind_speed)||void 0===u?void 0:u.value:null===S||void 0===S||null===(b=S.weather[C])||void 0===b?void 0:b.windSpeed,windSpeedUnit:n||a?null===e||void 0===e||null===(j=e.wind_speed)||void 0===j||null===(p=j.unit)||void 0===p?void 0:p.toUpperCase():null===S||void 0===S||null===(f=S.weather[C])||void 0===f?void 0:f.windSpeedUnit,windDirection:n||a?F(e):null===S||void 0===S||null===(m=S.weather[C])||void 0===m?void 0:m.windDirection,soilMoisture:null===S||void 0===S||null===(v=S.weather[C])||void 0===v?void 0:v.soilMoisture.toLowerCase(),type:0===C?"start":"end"}},K=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t,n){var a,r,c,i,o,s;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r="complete"===(null===S||void 0===S?void 0:S.status),c=0===C?null===S||void 0===S?void 0:S.startDate:null===S||void 0===S?void 0:S.endDate,i=null===S||void 0===S||null===(a=S.weather[C])||void 0===a?void 0:a.date,o=i&&new Date(i).getTime()!==new Date(c).getTime(),s=t?J(t,n,r,o):Object(I.a)(Object(I.a)({},M[C]),{},{date:new Date(1e3*n)}),T("weather[".concat(C,"]"),Object(I.a)({},s));case 6:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),[]);return Object(a.useEffect)((function(){var e,t;if(("create"===E||"convert"===E||"duplicate"===E)&&(null===S||void 0===S||null===(e=S.properties)||void 0===e||null===(t=e.features)||void 0===t?void 0:t.length)>0){var n,a=null===S||void 0===S||null===(n=S.properties)||void 0===n?void 0:n.map((function(e){return e.features[0]})),r=Oj(a);q(Object(v.a)(r))}else{var c,i,o=null===S||void 0===S||null===(c=S.properties)||void 0===c?void 0:c.map((function(e){var t;return null===P||void 0===P||null===(t=P.features)||void 0===t?void 0:t.find((function(t){return e.farmId===t.properties.propertyId&&"field"===t.properties.$landType}))}));if(o.length>0&&(null===P||void 0===P||null===(i=P.features)||void 0===i?void 0:i.length)>0){var s=Oj(o);q(Object(v.a)(s))}}}),[null===P||void 0===P?void 0:P.features,null===S||void 0===S?void 0:S.properties,E]),Object(a.useEffect)((function(){z(!0===R&&""!==(null===S||void 0===S?void 0:S.startDate))}),[R,null===S||void 0===S?void 0:S.startDate]),Object(a.useEffect)((function(){var e=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n,a,r,c;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=new Date(new Date(Date.now())).getTime(),n=0,n="Custom"===(null===S||void 0===S?void 0:S.duration)?new Date(null===S||void 0===S?void 0:S.dueDate).getTime()||(null===S||void 0===S?void 0:S.dueDateEpoch):new Date(null===S||void 0===S?void 0:S.startDate).getTime()+36e5*(null===S||void 0===S?void 0:S.duration),a=0===C?new Date(null===S||void 0===S?void 0:S.startDate).getTime():n,!(W.length>0&&a<t&&"complete"===(null===S||void 0===S?void 0:S.status)&&R)){e.next=10;break}return r=L(new Date(null===S||void 0===S?void 0:S.startDate),a,null===S||void 0===S?void 0:S.duration,C,E,new Date(null===S||void 0===S?void 0:S.dueDate)),e.next=8,k(new Date(a),W,r);case 8:c=e.sent,K(c,r.startDateTimeStamp);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}),[W,null===S||void 0===S?void 0:S.startDate,null===S||void 0===S?void 0:S.startDateEpoch,null===S||void 0===S?void 0:S.endDate,null===S||void 0===S?void 0:S.endDateEpoch,null===S||void 0===S?void 0:S.duration,null===S||void 0===S?void 0:S.status,R,E,C,K,T]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Qi,{label:"Date & Time",control:m.DatePicker,name:"weather[".concat(C,"].date"),value:(g=null===S||void 0===S||null===(t=S.weather[C])||void 0===t?void 0:t.date,""!==g?new Date(g).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric"}):g),dateFormat:"F j,  Y, h:i K",enableTime:!0}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(Qi,{label:"Temperature",control:m.Input,name:"weather[".concat(C,"].temperature"),value:null===S||void 0===S||null===(n=S.weather[C])||void 0===n?void 0:n.temperature,onChange:function(e){e.target.value.match(/(\d+)/)&&T("weather[".concat(C,"].temperature"),e.target.value.match(/(\d+)/)[0])},imask:{mask:"num{\xb0 ".concat(null===S||void 0===S||null===(r=S.weather[C])||void 0===r?void 0:r.temperatureUnit,"}"),lazy:!1,blocks:{num:{mask:Number,signed:!0,radix:".",mapToRadix:[","],thousandsSeparator:","}}}})}),Object(y.jsx)("div",{className:"flex-1",children:Object(y.jsxs)(Qi,{selected:null===S||void 0===S||null===(c=S.weather[C])||void 0===c?void 0:c.temperatureUnit,control:m.RadioButtonGroup,name:"weather[".concat(C,"].temperatureUnit"),children:[Object(y.jsx)(Qi,{value:"F",id:"{F".concat(C),name:"weather[".concat(C,"].temperatureUnit"),control:w,children:"F"}),Object(y.jsx)(Qi,{value:"C",id:"{C".concat(C),name:"weather[".concat(C,"].temperatureUnit"),control:w,children:"C"})]})})]}),Object(y.jsx)(Qi,{label:"Relative Humidity",control:m.Input,name:"weather[".concat(C,"].humidity"),value:null===S||void 0===S||null===(i=S.weather[C])||void 0===i?void 0:i.humidity,imask:{mask:"num{%}",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:[","],thousandsSeparator:",",min:0,max:100}}}}),Object(y.jsx)(Qi,{label:"Sky Condition",control:m.Select,name:"weather[".concat(C,"].skyCondition"),items:CK,placeholder:U?null===S||void 0===S||null===(o=S.weather[C])||void 0===o?void 0:o.skyCondition:"Select",value:null===S||void 0===S||null===(s=S.weather[C])||void 0===s?void 0:s.skyCondition}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(Qi,{label:"Wind Speed",control:m.Input,name:"weather[".concat(C,"].windSpeed"),value:null===S||void 0===S||null===(l=S.weather[C])||void 0===l?void 0:l.windSpeed,imask:{mask:"num{ ".concat("NONE"!==(null===S||void 0===S||null===(d=S.weather[C])||void 0===d?void 0:d.windSpeedUnit)?null===S||void 0===S||null===(u=S.weather[C])||void 0===u?void 0:u.windSpeedUnit.toLowerCase():"","}"),lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:[","],thousandsSeparator:",",min:0}}}})}),Object(y.jsx)("div",{className:"flex-1",children:Object(y.jsxs)(Qi,{control:m.RadioButtonGroup,selected:null===S||void 0===S||null===(j=S.weather[C])||void 0===j?void 0:j.windSpeedUnit,name:"weather[".concat(C,"].windSpeedUnit"),children:[Object(y.jsx)(Qi,{value:"MPH",id:"{MPH".concat(C),name:"weather[".concat(C,"].windSpeedUnit"),control:w,children:"MPH"}),Object(y.jsx)(Qi,{value:"KMH",id:"{KMH".concat(C),name:"weather[".concat(C,"].windSpeedUnit"),control:w,children:"KMH"}),Object(y.jsx)(Qi,{value:"NONE",id:"{0".concat(C),name:"weather[".concat(C,"].windSpeedUnit"),control:w,children:"None"})]})})]}),Object(y.jsx)(Qi,{label:"Wind Direction",control:m.Select,name:"weather[".concat(C,"].windDirection"),items:gK,value:null===S||void 0===S||null===(f=S.weather[C])||void 0===f?void 0:f.windDirection,placeholder:U?null===S||void 0===S||null===(O=S.weather[C])||void 0===O?void 0:O.windDirection:"Select",onChange:function(e){T("weather[".concat(C,"].windDirection"),JSON.parse(e.target.value).value)}}),Object(y.jsx)(Qi,{label:"Soil Moisture",control:m.Select,name:"weather[".concat(C,"].soilMoisture"),items:yK,placeholder:(null===S||void 0===S||null===(h=S.weather[C])||void 0===h?void 0:h.soilMoisture)||"Select",value:null===S||void 0===S||null===(x=S.weather[C])||void 0===x?void 0:x.soilMoisture,onChange:function(e){e.target.value.includes(S.weather[0].soilMoisture)||N("soilMoisture"),T("weather[".concat(C,"].soilMoisture"),JSON.parse(e.target.value).value)}})]})},fQ=function(e){var t=e.people,n=e.peopleLoading,r=e.companies,c=e.companiesLoaded,i=e.memberRole,o=e.memberFinancialAccess,s=e.setAmplitudeTabSelection,l=Object(Zi.h)(),d=l.values,u=l.setFieldTouched,b=Object(a.useContext)(we),j="flex justify-between mb-6 ",p="text-2xl font-semibold mb-6",f="grid items-end grid-cols-2 gap-24 mb-12 gap-y-12",v="grid items-end grid-cols-2 gap-24 mb-12 gap-y-12",O=function(e,t,n){Object.assign({},t).push(Object(I.a)({},n))};return Object(a.useEffect)((function(){b.sendEventToAmplitude(b.events.epic.Tasks.selectDetailsTab),s("Details")}),[]),Object(y.jsxs)("div",{className:"-mx-6",children:[Object(y.jsx)("div",{className:p,id:"task-info",children:"Task Info"}),Object(y.jsx)("div",{className:v,"data-testid":"task-info-content",children:Object(y.jsx)(jQ,{people:t,peopleLoading:n,memberRole:i,memberFinancialAccess:o})}),Object(y.jsx)(Zi.c,{name:"applicators",render:function(e){return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:j,id:"applicators",children:[Object(y.jsx)("div",{className:p,children:"Applicator(s)"}),Object(y.jsx)("div",{children:Object(y.jsx)(m.Button,{type:"primary",ghost:!0,onClick:function(){u("Add Applicator"),O(0,e,{id:"",company:""})},disabled:"Full control"===i&&("none"===o||"READ"===o),children:"Add Applicator"})})]}),Object(y.jsx)("div",{className:f,"data-testid":"applicators-content",children:Object(y.jsx)(yW,{people:t,peopleLoading:n,companies:r,companiesLoaded:c,handleRemove:function(t){u("Remove Applicator"),function(e,t,n){var a=Object.assign({},t);a.remove(n),0===d[e].length&&O(0,a,"applicators"===e?{id:"",company:""}:{id:""})}("applicators",e,t)},memberRole:i,memberFinancialAccess:o})})]})}}),Object(y.jsx)("div",{className:p,id:"notes",children:"Notes"}),Object(y.jsx)(Qi,{control:m.TextArea,name:"notes"})]})};fQ.defaultProps={people:[],companies:[],memberRole:"",memberFinancialAccess:""};var mQ=fQ,vQ=function(e){var t,n,r,c,i,o=e.propertyLandingPageData,s=e.loading,l=e.fieldsAndAreasGeoJSONCollection,d=e.cropSeasonIds,u=e.selectedApplicationOption,j=e.setAmplitudeTabSelection,p=Object(a.useContext)(we),f=Object(Zi.h)(),O=f.values,h=f.setFieldValue,x=f.setFieldTouched,g=Object(a.useState)(),C=Object(b.a)(g,2),P=C[0],A=C[1],S=kL().getStdUnits,T=Object(a.useState)(null===(t=O.properties)||void 0===t?void 0:t.map((function(e){return e.cropZoneId}))),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)(null),R=Object(b.a)(_,2),D=R[0],k=R[1],L=Object(a.useState)(null===d[0]),F=Object(b.a)(L,2),M=F[0],V=F[1],B=Object(a.useState)(null),U=Object(b.a)(B,2),z=U[0],Z=U[1],H=Object(a.useState)(!0),W=Object(b.a)(H,2),q=W[0],J=W[1],Q=Object(a.useState)(O.properties.length),X=Object(b.a)(Q,1)[0],$=Object(a.useState)(null===(n=O.properties)||void 0===n?void 0:n.map((function(e){return e.cropZoneId}))),ee=Object(b.a)($,1)[0],te=Object(a.useState)(aF(o)),ae=Object(b.a)(te,1)[0],re=Object(a.useState)(rF(o,ee)),ce=Object(b.a)(re,1)[0],ie=nF(),oe=ie.originalTotalArea,se=ie.setProperties,le=m.RadioButtonGroup.RadioButton,de=Mh(ce,d),ue=Object(a.useMemo)((function(){return sF(de,E,l,O)}),[E,s]),be=Object(a.useMemo)((function(){return G_(u)}),[u]);Object(a.useEffect)((function(){null===d[0]?(V(!0),Z("Please select a cropseason before selecting a property."),J(!0)):V(!1),function(e){if(E.length>0&&O){var t=O.properties.filter((function(t){return Object(ne.intersection)(t.cropSeasonIds,e).length>0})).map((function(e){return e.cropZoneId})),n=Object(v.a)(new Set(t));n.length&&w(n)}}(d)}),[d]),Object(a.useEffect)((function(){if(X!==E.length&&x("FFT Changed"),ue){var e=oF(ue,O);null!==e&&(h("properties",e),se(e))}}),[ue,h]);Object(a.useEffect)((function(){var e=function(){var e=O.properties.reduce((function(e,t){return e+t.areaValue}),0);return FS.b.parseFloatRound(e,2,Z_.a.ROUND_HALF_UP)}();h("totalApplied",e),h("totalAreaValue",e),A(e)}),[O.properties]);var je=function(e){return FS.b.parseFloatRound(P*(e.coveragePercent/100),2,Z_.a.ROUND_HALF_UP)};Object(a.useEffect)((function(){var e;Promise.all(null===O||void 0===O||null===(e=O.products)||void 0===e?void 0:e.map(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={changedArea:je(t)},a=t,t.stdunit&&t.stdfactor&&t.stdpackageunit){e.next=6;break}return e.next=5,S(t);case 5:a=e.sent;case 6:return e.abrupt("return",Object(K.calculateProductValues)(be.key,t[be.value],{},n,void 0,a,O));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())).then((function(e){return h("products",e)}))}),[be,P,O.totalApplied,oe]),Object(a.useEffect)((function(){var e=iF(O.totalApplied,oe);e!==Number(O.coveragePercent)&&!Number.isNaN(e)&&Number.isFinite(e)&&h("coveragePercent",e)}),[O.totalApplied,oe,h,O.coveragePercent]),Object(a.useEffect)((function(){j("Properties"),p.sendEventToAmplitude(p.events.epic.Tasks.selectPropertiesTab)}),[]);var pe=function(e){w(e),0===e.length&&(h("totalApplied",0),h("totalAreaValue",0),h("coveragePercent",100),h("properties",[]))};return Object(y.jsxs)("div",{className:"-mx-2 -mr-6",children:[Object(y.jsxs)("div",{className:"flex justify-end mb-6",children:[Object(y.jsxs)("div",{className:"mr-6",children:[q?Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){J(!1)},children:z}):null,Object(y.jsx)(Qi,{label:"Total Applied",control:m.Input,name:"totalApplied",disabled:0===O.properties.length||0===O.coveragePercent,onBlur:function(e){if(x("Total Applied"),h("totalApplied",Number(e.target.value)),Number(e.target.value)!==Number(e.target.defaultValue)){var t=iF(Number(e.target.value),oe);h("properties",Object(tF.a)(t,iF(Number(e.target.defaultValue),oe),O.properties)),h("coveragePercent",t)}},imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,scale:2,signed:!1,thousandsSeparator:"",padFractionalZeros:!1,normalizeZeros:!0,radix:".",mapToRadix:[","],min:0}}}})]}),Object(y.jsx)(Qi,{label:"Coverage %",control:m.Input,name:"coveragePercent",disabled:0===O.properties.length,onBlur:function(e){x("Coverage %"),h("coveragePercent",Number(e.target.value)),Number(e.target.value)!==Number(e.target.defaultValue)&&h("properties",Object(tF.a)(Number(e.target.value),Number(e.target.defaultValue),O.properties))},imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,scale:2,signed:!1,thousandsSeparator:"",padFractionalZeros:!1,normalizeZeros:!1,radix:".",mapToRadix:[","],min:0}}}})]}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"w-1/4 pr-8",children:Object(y.jsx)("div",{className:"mb-3",children:s?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Qi,{control:m.Select,name:"propertiesGroupBy",items:[{key:"property",value:"Group By Farm"},{key:"crop",value:"Group By Crop"}],onChange:function(e){!function(e){var t=JSON.parse(e.target.value);h("propertiesGroupBy",t.key)}(e)}}),"property"===(null===O||void 0===O?void 0:O.propertiesGroupBy)?Object(y.jsx)(Zx,{data:de,onChange:pe,value:O.properties,cropZonesChecked:E,setCropZonesChecked:w,disabled:M}):Object(y.jsx)(Hx,{data:de,onChange:pe,value:O.properties,cropZonesChecked:E,setCropZonesChecked:w,disabled:M})]})})}),Object(y.jsx)("div",{className:"flex flex-col w-3/4",children:Object(y.jsxs)("div",{className:"flex flex-col h-full",children:[Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsxs)(m.Table.Cell,{width:"30%",children:["Fields (",null===O||void 0===O||null===(r=O.properties)||void 0===r?void 0:r.length,")"]}),Object(y.jsx)(m.Table.Cell,{children:"Crops"}),Object(y.jsx)(m.Table.Cell,{children:"Area"}),Object(y.jsx)(m.Table.Cell,{children:"Coverage %"}),Object(y.jsx)(m.Table.Cell,{})]}),null===(c=O.properties)||void 0===c?void 0:c.map((function(e){var t,n,a=null!==(t=e.features)&&void 0!==t&&t[0]?[Ej(e.features[0])]:void 0,r=-1!==ae.indexOf(e.cropZoneId);return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)(Kp,{id:"field-card-icon",features:a}),Object(y.jsxs)("div",{className:"flex flex-col justify-start leading-5 text-left",children:[Object(y.jsxs)("span",{className:"font-bold text-neutral-1000",children:[e.fieldName,r?" (archived) ":""]}),Object(y.jsx)("span",{style:{color:"#707374"},children:e.name})]})]})}),Object(y.jsx)(m.Table.Cell,{children:null===(n=e.crop)||void 0===n?void 0:n.name}),Object(y.jsx)(m.Table.Cell,{children:xR(e.areaValue,e.areaUnit)}),Object(y.jsx)(m.Table.Cell,{children:Math.floor(100*e.coveragePct)/100}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(Wo,{onAction:function(t){return function(e,t){({edit:function(){return k(t)},remove:function(){x("delete cropzone"),pe((function(e){return e.filter((function(e){return e!==t.cropZoneId}))}))}})[e]()}(t,e)},options:As})})]},e.cropZoneId)}))]}),!(null!==(i=O.properties)&&void 0!==i&&i.length)&&Object(y.jsxs)("div",{className:"flex flex-col items-center self-stretch justify-center h-full py-32 border border-t-0",children:[Object(y.jsx)("img",{src:Of,alt:"No properties illustration"}),Object(y.jsx)("p",{children:"Select one or more fields from the list to add it to this Task"})]})]})})]}),Object(y.jsx)(y.Fragment,{children:D&&Object(y.jsx)(Zi.c,{name:"properties",children:function(e){var t,n=e.replace;return Object(y.jsx)(m.SimpleModal,{confirmLabel:"Save",open:D,onConfirm:function(){x("save cropzone"),n(O.properties.map((function(e){return e.cropZoneId})).indexOf(null===D||void 0===D?void 0:D.cropZoneId),D),k(null)},close:function(){return k(null)},children:Object(y.jsxs)("div",{className:"ml-6",children:[Object(y.jsxs)("div",{className:"mb-6",children:[Object(y.jsx)("div",{className:"text-xl font-bold",children:null===D||void 0===D?void 0:D.fieldName}),Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:null===D||void 0===D?void 0:D.name})]}),Object(y.jsxs)("div",{className:"flex mb-6",children:[Object(y.jsxs)("div",{className:"mr-6",children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Area"}),Object(y.jsxs)("div",{className:"text-xl",children:[null===D||void 0===D?void 0:D.originalAcres," ac"]})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("span",{className:"text-sm text-neutral-300",children:"Crop"}),Object(y.jsx)("div",{className:"text-xl ",children:null===D||void 0===D||null===(t=D.crop)||void 0===t?void 0:t.name})]})]}),Object(y.jsx)("div",{className:"mb-12",children:Object(y.jsxs)(Qi,{control:m.RadioButtonGroup,name:"areaReported",selected:D.areaType,onChange:function(e){var t="boundary"===e?null===D||void 0===D?void 0:D.boundaryArea:null===D||void 0===D?void 0:D.reportedArea;k(Object(I.a)(Object(I.a)({},D),{},{areaType:e,areaValue:t,coveragePct:iF(t,"boundary"===e?null===D||void 0===D?void 0:D.boundaryArea:null===D||void 0===D?void 0:D.reportedArea)}))},children:[Object(y.jsx)(Qi,{value:"reported",id:"reported",name:"areaReported",control:le,children:Object(y.jsxs)("span",{className:"truncate w-48",children:["Reported Area (",null===D||void 0===D?void 0:D.reportedArea," ac)"]})}),Object(y.jsx)(Qi,{value:"boundary",id:"boundary",name:"areaReported",control:le,children:Object(y.jsxs)("span",{className:"truncate w-48",children:["Boundary Area (",null===D||void 0===D?void 0:D.boundaryArea," ac)"]})})]})}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)(Qi,{label:"Area Applied",control:m.Input,value:null===D||void 0===D?void 0:D.areaValue,onBlur:function(e){var t=Number(e.target.value);k(Object(I.a)(Object(I.a)({},D),{},{areaValue:t,coveragePct:iF(t,"boundary"===(null===D||void 0===D?void 0:D.areaType)?null===D||void 0===D?void 0:D.boundaryArea:null===D||void 0===D?void 0:D.reportedArea)}))},name:"zoneAcres",imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,scale:2,signed:!1,thousandsSeparator:"",padFractionalZeros:!1,normalizeZeros:!0,radix:".",mapToRadix:[","],min:0}}}})}),Object(y.jsx)(Qi,{label:"Coverage %",control:m.Input,name:"zoneCoveragePercent",value:null===D||void 0===D?void 0:D.coveragePct,onBlur:function(e){var t=Number(e.target.value);k(Object(I.a)(Object(I.a)({},D),{},{coveragePct:t,areaValue:cF(t,"boundary"===(null===D||void 0===D?void 0:D.areaType)?null===D||void 0===D?void 0:D.boundaryArea:null===D||void 0===D?void 0:D.reportedArea)}))},imask:{mask:"num",lazy:!1,blocks:{num:{mask:Number,signed:!1,thousandsSeparator:"",padFractionalZeros:!1,normalizeZeros:!1,radix:".",mapToRadix:[","],min:0}}}})]})]})})}})})]})},OQ=function(e){var t,n,r,c=e.applicationOptions,i=e.setSelectedApplicationOption,o=e.isEditing,s=Object(Zi.h)(),l=s.setFieldValue,d=s.values,u=kL().getStdUnits;i(d.applicationStrategy);var b=function(e){return Math.round(100*(e+Number.EPSILON))/100};Object(a.useEffect)((function(){!function(){var e,t=G_(d.applicationStrategy);Promise.all(null===d||void 0===d||null===(e=d.products)||void 0===e?void 0:e.map(function(){var e=Object(Y.a)(G.a.mark((function e(n){var a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n,n.stdunit&&n.stdfactor&&n.stdpackageunit){e.next=5;break}return e.next=4,u(n);case 4:a=e.sent;case 5:return e.abrupt("return",Object(K.calculateProductValues)(t.key,n[t.value],null,null,null,a,d));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())).then((function(e){return l("products",e)}))}()}),[null===d||void 0===d?void 0:d.tankInformation]);return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex grow",children:[Object(y.jsxs)("div",{className:"w-1/4",children:[Object(y.jsx)("span",{className:"flex items-center text-neutral-600",style:{fontSize:"0.95vw"},"data-testid":"application-options-select",children:"Application Options"}),Object(y.jsx)("div",{className:"w-full",children:Object(y.jsx)(Qi,{control:m.Select,name:"applicationStrategy",items:c,onChange:function(e){return l("applicationStrategy",JSON.parse(e.target.value).key)}})})]}),Object(y.jsxs)("div",{className:"w-3/4 flex justify-between",children:[Object(y.jsxs)("div",{className:"",style:{paddingLeft:"2.5%"},children:[Object(y.jsx)("span",{className:"flex items-center text-neutral-600",style:{fontSize:"0.95vw"},"data-testid":"tank-size-input",children:"Tank Size"}),Object(y.jsx)(Qi,{control:m.Input,name:"tankInformation.tankSizeValue",value:null===d||void 0===d||null===(t=d.tankInformation)||void 0===t?void 0:t.tankSizeValue,onChange:function(e){return function(e){if(o){if(Number(e)){var t,n=Math.round(Number(null===d||void 0===d||null===(t=d.tankInformation)||void 0===t?void 0:t.totalCarrierValue)/Number(e));l("tankInformation.tankSizeValue",e),l("tankInformation.tankCount",n)}}else{var a,r=0;if(Number.parseFloat(e)&&(r=Number(e)*Number(null===d||void 0===d||null===(a=d.tankInformation)||void 0===a?void 0:a.tankCount),l("tankInformation.totalCarrierValue",b(r))),Number.parseFloat(null===d||void 0===d?void 0:d.totalAreaValue)>0){var c=r/(null===d||void 0===d?void 0:d.totalAreaValue);l("tankInformation.carrierPerAreaValue",b(c))}l("tankInformation.tankSizeValue",e)}}(e.target.value)},disabled:0===(null===d||void 0===d?void 0:d.totalAreaValue)})]}),Object(y.jsxs)("div",{className:"",style:{paddingLeft:"2.5%"},children:[Object(y.jsx)("span",{className:"flex items-center text-neutral-600",style:{fontSize:"0.95vw"},"data-testid":"tank-count-input",children:"Tank Count"}),Object(y.jsx)(Qi,{control:m.Input,name:"tankInformation.tankCount",value:null===d||void 0===d?void 0:d.tankInformation.tankCount,onChange:function(e){return function(e){var t=0;if(""!==e&&"0"!==e){var n,a;if(Number.parseFloat(null===d||void 0===d||null===(n=d.tankInformation)||void 0===n?void 0:n.tankSizeValue)&&(t=Number(null===d||void 0===d||null===(a=d.tankInformation)||void 0===a?void 0:a.tankSizeValue)*Number(e),l("tankInformation.totalCarrierValue",b(t))),Number.parseFloat(null===d||void 0===d?void 0:d.totalAreaValue)>0){var r=t/(null===d||void 0===d?void 0:d.totalAreaValue);l("tankInformation.carrierPerAreaValue",b(r))}}l("tankInformation.tankCount",e)}(e.target.value)},disabled:0===(null===d||void 0===d?void 0:d.totalAreaValue)})]}),Object(y.jsxs)("div",{className:"",style:{paddingLeft:"2.5%"},children:[Object(y.jsx)("span",{className:"flex items-center text-neutral-600",style:{fontSize:"0.95vw"},"data-testid":"total-carrier-input",children:"Total Carrier"}),Object(y.jsx)(Qi,{control:m.Input,name:"tankInformation.totalCarrierValue",value:null===d||void 0===d||null===(n=d.tankInformation)||void 0===n?void 0:n.totalCarrierValue,onChange:function(e){return function(e){var t;if(Number.parseFloat(null===d||void 0===d||null===(t=d.tankInformation)||void 0===t?void 0:t.tankSizeValue)>0){var n,a=Number(e)/Number(null===d||void 0===d||null===(n=d.tankInformation)||void 0===n?void 0:n.tankSizeValue);l("tankInformation.tankCount",b(a))}if(Number.parseFloat(null===d||void 0===d?void 0:d.totalAreaValue)){var r=Number(e)/Number(null===d||void 0===d?void 0:d.totalAreaValue);l("tankInformation.carrierPerAreaValue",b(r))}l("tankInformation.totalCarrierValue",e)}(e.target.value)},disabled:0===(null===d||void 0===d?void 0:d.totalAreaValue)})]}),Object(y.jsxs)("div",{className:"",style:{paddingLeft:"2.5%"},children:[Object(y.jsx)("span",{className:"flex items-center text-neutral-600",style:{fontSize:"0.95vw"},"data-testid":"carrier-by-area-input",children:"Carrier per Area"}),Object(y.jsx)(Qi,{control:m.Input,name:"tankInformation.carrierPerAreaValue",valule:null===d||void 0===d||null===(r=d.tankInformation)||void 0===r?void 0:r.carrierPerAreaValue,onChange:function(e){return function(e){var t,n=0;if(Number.parseFloat(e)&&(n=Number(e)*Number(null===d||void 0===d?void 0:d.totalAreaValue),l("tankInformation.totalCarrierValue",b(n))),Number.parseFloat(null===d||void 0===d||null===(t=d.tankInformation)||void 0===t?void 0:t.tankSizeValue)>0){var a,r=n/Number(null===d||void 0===d||null===(a=d.tankInformation)||void 0===a?void 0:a.tankSizeValue);l("tankInformation.tankCount",b(r))}l("tankInformation.carrierPerAreaValue",e)}(e.target.value)},disabled:0===(null===d||void 0===d?void 0:d.totalAreaValue)})]})]})]}),0===(null===d||void 0===d?void 0:d.totalAreaValue)&&Object(y.jsx)("div",{className:"mt-2",children:"You must select a property to edit tank information"})]})},hQ=function(){return Object(y.jsxs)("svg",{width:"166",height:"128",viewBox:"0 0 166 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M74.6387 110.975H91.9899L105.595 127.164H88.2435L74.6387 110.975ZM79.9197 113.438L89.3846 124.701H100.314L90.8487 113.438H79.9197Z",fill:"#73DC78"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.455078 0.491623L34.8691 14.4748H131.131L165.545 0.494863V99.7757L145.062 108.181V127.161H45.0461L33.8786 113.231L0.455078 99.785V0.491623ZM37.1951 113.438L46.2219 124.698H140.465L131.421 113.438L37.1951 113.438ZM133.998 112.721L142.608 123.44V109.189L133.998 112.721ZM130.784 110.975V30.5715L48.7885 30.5715L48.7884 110.973L130.784 110.975ZM46.3335 110.972L46.3336 29.8323L35.8574 18.787V110.972L46.3335 110.972ZM33.4025 16.5363V110.386L2.90995 98.1188V4.14655L33.4025 16.5363ZM37.4925 16.9379L48.0874 28.1084L130.784 28.1084V16.9379H37.4925ZM133.239 16.2759V110.371L163.09 98.1219V4.14948L133.239 16.2759Z",fill:"#00004B"})]})},xQ=function(){return Object(y.jsxs)("div",{id:"empty-products-display",className:"w-full h-full mt-24 flex flex-col items-center justify-center",children:[Object(y.jsx)(hQ,{}),Object(y.jsx)("span",{className:"mt-6 text-xl",children:"Select a product from the list to add it to this task"})]})},gQ=function(e){var t,n=e.editProduct,r=e.removeProduct,c=e.memberRole,i=e.memberFinancialAccess,o=e.selectedApplicationOption,s=e.setCustomProductCreated,l=e.customProductCreated,d=kL().getStdUnits,u=Object(a.useState)(),j=Object(b.a)(u,2),f=j[0],v=(j[1],Object(a.useState)(!1)),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(null),C=Object(b.a)(g,2),P=C[0],A=C[1],S=Object(a.useState)(null),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(p.j)().id,_=Object(a.useState)({key:"ratearea",value:"ratePerAreaValue",unit:"ratePerAreaUnit",title:"Rate/Area"}),R=Object(b.a)(_,2),D=R[0],k=R[1],L=Object(Zi.h)().values;Object(a.useEffect)((function(){k([{key:"ratearea",value:"ratePerAreaValue",unit:"ratePerAreaUnit",title:"Rate/Area"},{key:"totalproduct",value:"totalProductValue",unit:"totalProductUnit",title:"Total Product"},{key:"ratetank",value:"ratePerTankValue",unit:"ratePerTankUnit",title:"Rate/Tank"}].find((function(e){return e.key===("ByRatePerTank"===(null===L||void 0===L?void 0:L.applicationStrategy)?"ratetank":"ratearea")})))}),[L.applicationStrategy]),Object(a.useEffect)((function(){var e;if((null===(e=L.products)||void 0===e?void 0:e.length)>0){var t=L.products.length-1,n=L.products[t];n.custom&&l&&(A(Object(I.a)(Object(I.a)({},n),{},{name:n.productName,manufacturer:n.manufacturerName,id:n.productId})),E(t),x(!0),s(!1))}}),[L.products,l]);var F=function(){},M=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.stdunit&&t.stdfactor&&t.stdpackageunit){e.next=5;break}return e.next=3,d(t);case 3:return n=e.sent,e.abrupt("return",n);case 5:return e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),V=function(e){return e||0},B=function(e){return"Full control"===c&&"none"===i?"":"Admin"===c||"View Only"===c||"Full control"===c&&"WRITE"===i||"Full control"===c&&"READ"===i&&"create"!==w?e:""};return Object(y.jsxs)("div",{className:"mt-8",children:[Object(y.jsx)(nR,{open:h,product:P,onClose:function(){x(!1),n(P),A(null)},isEdit:!0,prodIndex:N,memberRole:c,memberFinancialAccess:i,selectedApplicationOption:o}),null!==(t=L.products)&&void 0!==t&&t.length?Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{sort:f,onClick:F,children:"Products (".concat(L.products.length,")")}),Object(y.jsx)(m.Table.Cell,{sort:f,onClick:F,children:null===D||void 0===D?void 0:D.title}),Object(y.jsx)(m.Table.Cell,{sort:f,onClick:F,children:"Price/Unit"}),Object(y.jsx)(m.Table.Cell,{sort:f,onClick:F,children:"Appl. Area"}),Object(y.jsx)(m.Table.Cell,{sort:f,onClick:F,children:"Appl. Area %"}),Object(y.jsx)(m.Table.Cell,{sort:f,onClick:F,children:"Total Product"}),Object(y.jsx)(m.Table.Cell,{sort:f,onClick:F,children:"Total Cost"}),Object(y.jsx)(m.Table.Cell,{sort:f,onClick:F,children:"Grower Cost"}),Object(y.jsx)(m.Table.Cell,{})]}),L.products.map((function(e,t){var n;return Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsxs)("div",{className:"text-left",children:[Object(y.jsx)("div",{className:"font-bold",children:e.productName}),Object(y.jsx)("div",{className:"mt-2 text-neutral-300",children:e.manufacturerName})]})}),Object(y.jsx)(m.Table.Cell,{children:"".concat(parseFloat(e[D.value]).toFixed(2)," ").concat(Object(va.g)(e[D.unit]))}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:2,unit:"usCurrency",children:B(e.averagePriceAtTimeOfCreation)})," per ".concat(Object(va.g)(e.specificCostUnit))]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:2,children:"".concat(e.appliedAreaValue," ")})," ","ac"]}),Object(y.jsx)(m.Table.Cell,{children:"".concat(Number(e.coveragePercent).toFixed(2),"%")}),Object(y.jsx)(m.Table.Cell,{children:"".concat(Number(e.totalProductValue).toFixed(2)," ").concat(Object(va.g)(e.totalProductUnit))}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(yf,{roundedTo:2,unit:"usCurrency",children:B(e.totalCostAtTimeOfCreation)})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"flex w-28 items-center justify-around",children:Object(y.jsx)("div",{children:Object(y.jsx)(yf,{roundedTo:2,unit:"usCurrency",children:B(e.totalCostAtTimeOfCreation*(V(null===(n=e.shareOwnerInformation)||void 0===n?void 0:n.percentGrowerResponsibility)/100))})})})}),Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)("div",{className:"mr-2",children:Object(y.jsx)(Wo,{onAction:function(n){return function(e,t,n){"edit"===e&&(x(!0),M(t).then((function(e){A(Object(I.a)(Object(I.a)({},e),{},{name:e.productName,manufacturer:e.manufacturerName,id:e.productId,density:e.density})),E(n)}))),"remove"===e&&r(t)}(n,e,t)},options:As})})})]},e.trackingId)}))]}):Object(y.jsx)(xQ,{})]})},CQ=function(e){var t=e.memberRole,n=e.memberFinancialAccess,r=e.applicationOptions,c=e.selectedApplicationOption,i=e.setSelectedApplicationOption,o=e.isEditing,s=e.setAmplitudeTabSelection,l=Object(Zi.h)(),d=l.setFieldValue,u=l.values,j=l.setFieldTouched,p=Object(a.useState)(!1),f=Object(b.a)(p,2),m=f[0],v=f[1],O=Object(a.useContext)(we);return Object(a.useEffect)((function(){O.sendEventToAmplitude(O.events.epic.Tasks.selectProductTab),s("Products")}),[]),Object(y.jsxs)("div",{className:"flex justify-between h-full",children:[Object(y.jsx)("div",{className:"w-3/12 mt-16",children:Object(y.jsx)(OR,{memberRole:t,memberFinancialAccess:n,selectedApplicationOption:c,setCustomProductCreated:v})}),Object(y.jsxs)("div",{className:"ml-4 flex-grow",children:[Object(y.jsx)(OQ,{selectedApplicationOption:c,applicationOptions:r,setSelectedApplicationOption:i,isEditing:o}),Object(y.jsx)(gQ,{editProduct:function(){d(null===u||void 0===u?void 0:u.products,null===u||void 0===u?void 0:u.products)},removeProduct:function(e){j("remove project");var t=null===u||void 0===u?void 0:u.products;t.splice(t.findIndex((function(t){return t.productId===e.productId})),1),d(null===u||void 0===u?void 0:u.products,t)},memberRole:t,memberFinancialAccess:n,selectedApplicationOption:c,setCustomProductCreated:v,customProductCreated:m})]})]})};CQ.defaultProps={memberRole:"",memberFinancialAccess:""};var yQ=CQ,PQ=function(e){var t=e.fieldsAndAreasCentroidCoordinates,n=e.fieldsAndAreasGeoJSONCollection,r=e.setAmplitudeTabSelection,c=Object(a.useContext)(ac),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(Zi.h)().values,d=Object(a.useContext)(we),u=o.weatherAutomaticToggle,j="flex justify-between mb-6 ",p="text-2xl font-semibold mb-6",f="grid items-end grid-cols-2 gap-24 mb-12 gap-y-12",v=Object(a.useState)(null),O=Object(b.a)(v,2),h=O[0],x=O[1],g=Object(a.useState)(!0),C=Object(b.a)(g,2),P=C[0],A=C[1];return Object(a.useEffect)((function(){void 0!==(null===l||void 0===l?void 0:l.properties)&&0!==(null===l||void 0===l?void 0:l.properties.length)||!u||"complete"!==(null===l||void 0===l?void 0:l.status)||(x("Please select a property or properties on the Properties Tab if you are getting weather automatically."),A(!0))}),[u]),Object(a.useEffect)((function(){r("Weather"),d.sendEventToAmplitude(d.events.epic.Tasks.selectWeatherTab)}),[]),Object(y.jsxs)(y.Fragment,{children:[P?Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){A(!1)},children:h}):null,Object(y.jsxs)("div",{className:j,children:[Object(y.jsx)("div",{className:p,children:"Start Weather"}),Object(y.jsxs)("div",{className:"flex justify-between mt-3",children:[Object(y.jsx)("div",{className:"text-xs text-weather_automatic_button",children:"GET WEATHER AUTOMATICALLY"}),Object(y.jsx)("div",{className:"ml-2",children:Object(y.jsx)(zo,{id:"weather-automatic-toggle",name:"weather-automatic-toggle",color:"#0071CD",defaultChecked:u,onChange:function(){return s({type:"SWITCH_WEATHER_TOGGLE"})}})})]})]}),Object(y.jsx)("div",{className:f,"data-testid":"start-weather-content",id:"start-weather",children:Object(y.jsx)(pQ,{index:0,fieldsAndAreasCentroidCoordinates:t,fieldsAndAreasGeoJSONCollection:n})}),"complete"===(null===l||void 0===l?void 0:l.status)&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:j,children:Object(y.jsx)("div",{className:p,children:"End Weather"})}),Object(y.jsx)("div",{className:f,"data-testid":"end-weather-content",id:"end-weather",children:Object(y.jsx)(pQ,{index:1,fieldsAndAreasCentroidCoordinates:t,fieldsAndAreasGeoJSONCollection:n})})]})]})};PQ.defaultProps={fieldsAndAreasCentroidCoordinates:[]};var AQ=PQ,SQ=function(e){return"number"===typeof e?e.toFixed(2):e},TQ=function(){var e=Object(a.useContext)(we).amplitude,t=ix(),n=Object(p.h)(),r=t.get("submission"),c=t.get("vendor");return{isComingFromIntegrations:r&&c,redirectToSubmission:Object(a.useCallback)((function(){n.goBack(),e.sendEventToAmplitude(e.events.epic.Tasks.cancelTaskSuccess)}),[])}},NQ=function(){var e,t=Object(a.useContext)(ac),n=Object(b.a)(t,2),r=n[0],c=n[1],i=r.weatherAutomaticToggle,o=r.taskCreationFrom,s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=We().user,f=Object(a.useState)("Details"),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(p.j)().id,g="create"===x||"convert"===x||"duplicate"===x,C=Object(p.h)(),P=bA(j.name),A=Object(ya.a)(new Date,"yyMMdd"),S=Object(ya.a)(new Date,"kkmm"),T=Object(a.useState)(null),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)(),R=Object(b.a)(_,2),D=R[0],k=R[1],L=uE(),F=L.people,M=L.loading,V=Ro("worker/companies",["company.name","company.legalname"],"company.name"),B=V.loaded,U=V.items,z="Details",Z="Properties",H="Products",W="Weather",q="create",J="duplicate",K="convert",Q=U_("inventory/products-prices"),X=Object(a.useState)(!1),$=Object(b.a)(X,2),ee=$[0],te=$[1],ne=Object(a.useState)(""),ae=Object(b.a)(ne,2),re=ae[0],ce=ae[1],ie=Object(a.useState)(Object(I.a)({},Cm)),oe=Object(b.a)(ie,2),se=oe[0],le=oe[1],de=Object(a.useState)(""),ue=Object(b.a)(de,2),be=ue[0],je=ue[1],pe=Object(a.useState)(!0),fe=Object(b.a)(pe,2),me=fe[0],ve=fe[1],Oe=Object(a.useContext)(we),he=kL().getStdUnits,xe=TK(),ge=xe.fetchClearAppWeatherDataReturn,Ce=xe.fetchURLDetails,ye=xe.setWeatherObj,Pe=xe.getCoordinates,Se=xe.getNumericValue,Te=xe.DefaultWeatherData,Ne=QK("selectedCropSeasons").storedValue,Ee=Object(a.useState)(Ne),_e=Object(b.a)(Ee,2),Re=_e[0],Ie=_e[1],De=Object(a.useState)(!0),ke=Object(b.a)(De,2),Le=ke[0],Fe=ke[1],Me=TQ(),Ve=Me.isComingFromIntegrations,Be=Me.redirectToSubmission,Ue=function(){Ie(Ne)},ze=rv({fetchType:xm,isCacheOn:!0}),Ze=ze.dataSorted,Ye=ze.loading,He=ze.fieldsAndAreasGeoJSONCollection,Ge=ze.fieldsAndAreasCentroidCoordinates,qe=ze.reloadData,Je=(e={},Object(et.a)(e,z,Oe.events.epic.Tasks.selectDetailsTabSuccess),Object(et.a)(e,Z,Oe.events.epic.Tasks.selectPropertiesTabSuccess),Object(et.a)(e,H,Oe.events.epic.Tasks.selectProductTabSuccess),Object(et.a)(e,W,Oe.events.epic.Tasks.selectWeatherTabSuccess),e);Object(a.useEffect)((function(){qe()}),[]),Object(a.useEffect)((function(){if(x===q||x===K)return Oe.sendEventToAmplitude(Oe.events.epic.Tasks.createTaskSuccess,{page:null!==o&&void 0!==o?o:""}),void jc(c,Qr,void 0);x!==J?x!==q&&x!==K&&x!==J&&Oe.sendEventToAmplitude(Oe.events.epic.Tasks.editTaskSuccess):Oe.sendEventToAmplitude(Oe.events.epic.Tasks.duplicateTaskSuccess)}),[]);var Ke=g?"".concat(P," ").concat(A," ").concat(S):"",Qe=Object(a.useState)(""),Xe=Object(b.a)(Qe,2),$e=Xe[0],tt=Xe[1];Object(a.useEffect)((function(){if("convert"===x){var e,t;u(!1);var n=(null===r||void 0===r||null===(e=r.planToConvert)||void 0===e?void 0:e.applicationStrategy)||Om[0].key;Le&&null!==r&&void 0!==r&&null!==(t=r.planToConvert)&&void 0!==t&&t.products&&Promise.all(r.planToConvert.products.map(function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",he(t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())).then((function(e){le(Object(I.a)(Object(I.a)({},r.planToConvert),{},{name:Ke,applicationStrategy:n,products:e,startDate:XK(r.planToConvert.startDate),dueDate:XK(r.planToConvert.dueDate),authorizedDate:XK(r.planToConvert.authorizedDate)}))})),tt(n),Fe(!1),ve(!1)}else if("create"===x)u(!1),Ue(),Le&&le((function(e){return Object(I.a)(Object(I.a)({},e),{},{name:Ke,properties:[],products:[]})})),tt(Om[0].key),Fe(!1);else{u(!0),Ue();var a="duplicate"===x?r.planToConvert.id:x;if(Le)gn.fetch(a).promise.then((function(e){var t,n,a=e.data,r=function(e){var t=e.reduce((function(e,t){var n=t.areaValue/t.coveragePct;return{totalArea:e.totalArea+t.areaValue,originalTotalArea:e.originalTotalArea+n}}),{totalArea:0,originalTotalArea:0});return{totalArea:t.totalArea,originalTotalArea:t.originalTotalArea,coveragePercent:t.totalArea/t.originalTotalArea}}(a.properties),c=[(null===(t=a.weather)||void 0===t?void 0:t.find((function(e){return"START"===e.type})))||Te[0],(null===(n=a.weather)||void 0===n?void 0:n.find((function(e){return"END"===e.type})))||Te[1]],i="duplicate"===x?Object(I.a)(Object(I.a)({},Cm),{},{name:Ke,applicationStrategy:a.applicationStrategy||Om[0].key,tankInformation:a.tankInformation,source:a.source,coveragePercent:100*r.coveragePercent,totalAreaValue:r.totalArea,totalApplied:r.totalArea,startDate:XK(a.startDate),dueDate:XK(a.dueDate),properties:a.properties.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{coveragePct:100*e.coveragePct})})),products:a.products.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{coveragePercent:100*e.coveragePercent})})),weather:c,flags:null===a||void 0===a?void 0:a.flags,timingEvent:a.timingEvent,authorizedByName:a.authorizedBy,authorizerId:a.authorizerId,applicators:a.applicators,notes:a.notes,type:a.type,authorizedDate:XK(a.authorizedDate)}):Object(I.a)(Object(I.a)({},a),{},{applicationStrategy:a.applicationStrategy||Om[0].key,propertiesGroupBy:"property",startDate:XK(a.startDate),dueDate:XK(a.dueDate),authorizedDate:XK(a.authorizedDate),coveragePercent:100*r.coveragePercent,totalApplied:r.totalArea,properties:a.properties.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{coveragePct:100*e.coveragePct})})),products:a.products.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{coveragePercent:100*e.coveragePercent})})),weather:c});tt(i.applicationStrategy),le(Object(I.a)({},i)),Fe(!1)})).catch(Ae.default).catch((function(e){uc(c)(e),ve(!1)}))}}),[Ke,c,x,Le]),Object(a.useEffect)((function(){var e=Je[be];e&&Oe.sendEventToAmplitude(e)}),[be]),Object(a.useEffect)((function(){Ye||ve(!1)}),[Ye]);var nt=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Jt.fetch(),n=t.promise,e.next=3,n.then((function(e){var t,n=e.data,a=null===n||void 0===n||null===(t=n.members)||void 0===t?void 0:t.filter((function(e){return e.email===j.email}))[0];w(a)})).catch(Ae.default).catch((function(e){uc(c)(e)}));case 3:case"end":return e.stop()}}),e)}))),[c,j.email]);Object(a.useEffect)((function(){E||nt(),"Full control"!==(null===E||void 0===E?void 0:E.role)||Object.prototype.hasOwnProperty.call(E,"financialAccess")?k(null===E||void 0===E?void 0:E.financialAccess):k("none")}),[E,nt]);var at=ix();Object(a.useEffect)((function(){var e=at.get("activeTab");e&&e!==O&&h(e)}),[h,O,at]),Object(a.useEffect)((function(){}),[]);var rt=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,c,i,o,s,l;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=[],a=new Date(null===t||void 0===t?void 0:t.startDate).getTime()<Date.now(),"complete"!==(null===t||void 0===t?void 0:t.status)||!a||!r.weatherAutomaticToggle){e.next=17;break}c=0;case 4:if(!(c<2)){e.next=15;break}return i=Pe(x,t,He),o=Ce(new Date(null===t||void 0===t?void 0:t.startDate),new Date(null===t||void 0===t?void 0:t.startDate).getTime(),null===t||void 0===t?void 0:t.duration,c,x,new Date(null===t||void 0===t?void 0:t.dueDate)),e.next=9,ge(new Date(1e3*o.startDateTimeStamp),i,o);case 9:s=e.sent,l=ye(c,s,o.startDateTimeStamp),n.push(l);case 12:c+=1,e.next=4;break;case 15:e.next=18;break;case 17:n=null===t||void 0===t?void 0:t.weather;case 18:return e.abrupt("return",null===t||void 0===t?void 0:t.weather);case 19:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ct=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r,o,s,l,d,u,b,j,p,f,m,v,O,h,y,P,A,S,T,N,E;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return te(!0),"create"!==x&&(d=null===Ze||void 0===Ze||null===(s=Ze.properties)||void 0===s?void 0:s.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{selectedCropSeason:Re})})),u=sF(d,null===(l=t.properties)||void 0===l?void 0:l.map((function(e){return e.cropZoneId})),He,t),null!==(b=oF(u,t))&&(t.properties=b)),j=t.properties.map((function(e){return e.farmId})),p=t.properties.map((function(e){return e.fieldId})),o="create"===x||"duplicate"===x||"convert"===x?Oe.events.epic.Tasks.createTask:Oe.events.epic.Tasks.updateTask,Oe.sendEventToAmplitude(o,{farmIds:j,fieldIds:p}),e.next=8,rt(t);case 8:if(f=e.sent,m=(null===(n=t.properties[0])||void 0===n?void 0:n.areaUnit)||"acres",v=F.find((function(e){return e.id===t.authorizerId})),O=new Set,h=t.properties.map((function(e){return e.cropSeasonIds.forEach((function(e){var t=Re.filter((function(t){return t===e}))[0];O.add(t),O.delete(void 0)})),{farmId:e.farmId,cropZoneId:e.cropZoneId,areaUnit:e.areaUnit,areaValue:e.areaValue,coveragePct:e.coveragePct/100}})),y=t.products.map(W_),P=t.products.filter((function(e){return e.saveAsNewListPriceDate})).map((function(e){return{productId:e.productId,averagePricePerUnit:e.averagePriceAtTimeOfCreation,productDensity:e.productDensity}})),y.forEach((function(e){delete e.saveAsNewListPriceDate})),A=null===(a=t.applicators)||void 0===a?void 0:a.map((function(e){return{personId:e.personId,personName:"",companyName:"",licenseNumber:"",companyId:e.companyId,expiresDate:""}})),S=null===(r=t.assigneeIds)||void 0===r?void 0:r.map((function(e){return{status:0,message:"",id:e.id,name:""}})),T=Array.from(O),N=Object(I.a)(Object(I.a)({},!g),{},{name:t.name,status:t.status,notes:t.notes,bufferReason:t.bufferReason,bufferZone:t.bufferZone,sources:[],type:t.type,duration:t.duration,timingEvent:t.timingEvent,authorizedDateEpoch:Object(KK.a)(new Date(t.authorizedDate)),authorizedBy:(null===v||void 0===v?void 0:v.name)||"",authorizerId:t.authorizerId,cropSeasonIds:T.map((function(e){return{id:e}})),flags:t.flags||[],dueDateEpoch:Object(KK.a)(new Date(t.dueDate)),startDateEpoch:Object(KK.a)(new Date(t.startDate)),dueDate:t.dueDate,applicators:A,assigneeIds:S,properties:h,totalAreaValue:t.totalAreaValue,totalAreaUnit:m,tankInformation:{tankSizeValue:t.tankInformation.tankSizeValue,tankSizeUnit:"gallon",tankCount:t.tankInformation.tankCount,carrierPerAreaValue:t.tankInformation.carrierPerAreaValue,carrierPerAreaUnit:"gallon",totalCarrierValue:t.tankInformation.totalCarrierValue,totalCarrierUnit:"gallon",tankValueTypeEnteredByUser:"CarrierPerArea"},applicationStrategy:t.applicationStrategy,products:y,timingEventTag:"",totalGrowerCost:0,weather:f.map((function(e,t){var n,a,r;return{dateEpoch:Object(KK.a)(new Date(e.date))||"",windSpeed:Se(null===(n=e.windSpeed)||void 0===n?void 0:n.toString()),windDirection:e.windDirection||"",skyCondition:e.skyCondition||"",temperature:Se(null===(a=e.temperature)||void 0===a?void 0:a.toString()),temperatureUnit:e.temperatureUnit||"F",windSpeedUnit:e.windSpeedUnit||"MPH",soilMoisture:e.soilMoisture||"unknown",humidity:Se(null===(r=e.humidity)||void 0===r?void 0:r.toString())||"",type:0===t?"start":"end"}})).filter((function(e){return e.dateEpoch}))}),null!==(E=g?gn.create(N):gn.update(t.taskId,N))&&void 0!==E&&E.promise){e.next=23;break}return e.abrupt("return");case 23:return e.next=25,E.promise.then((function(){return!(P.length>0)||Q.post(P).promise})).then((function(){te(!1),i||c({type:"SWITCH_WEATHER_TOGGLE"}),Ve?Be():(o===Oe.events.epic.Tasks.createTask?o=Oe.events.epic.Tasks.createTaskSuccess:o===Oe.events.epic.Tasks.updateTask&&(o=Oe.events.epic.Tasks.updateTaskSuccess),Oe.sendEventToAmplitude(o,{farmIds:j,fieldIds:p}),Oe.sendEventToAmplitude(Oe.events.epic.Tasks.accessTasks),C.push(Cc.tasks))})).catch(Ae.default).catch((function(e){var t,n,a,r,i,o;(te(!1),null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.validationErrors)?"EARG011"===(null===(i=e.response)||void 0===i||null===(o=i.data)||void 0===o?void 0:o.code)?ce("Please select one or more fields in order to save this Task."):ce("Error saving task: ".concat(e.response.data.message)):null!==(a=e.response)&&void 0!==a&&null!==(r=a.data)&&void 0!==r&&r.displayErrorMessage?ce(e.response.data.displayErrorMessage):uc(c)(e)}));case 25:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),it=function(){Oe.sendEventToAmplitude(Oe.events.epic.Tasks.cancelTask),Ve?Be():(C.push(Cc.tasks),Oe.sendEventToAmplitude(Oe.events.epic.Tasks.cancelTaskSuccess))},ot=function(e){return"Full control"===(null===E||void 0===E?void 0:E.role)&&"none"===D?"":"Admin"===(null===E||void 0===E?void 0:E.role)||"View Only"===(null===E||void 0===E?void 0:E.role)||"Full control"===(null===E||void 0===E?void 0:E.role)&&"WRITE"===D||"Full control"===(null===E||void 0===E?void 0:E.role)&&"READ"===D&&"create"!==x?function(e){return Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:e||0})}(null===e||void 0===e?void 0:e.map((function(e){return null===e||void 0===e?void 0:e.totalCostAtTimeOfCreation})).reduce((function(e,t){return e+t}),0)):(null===E||void 0===E||E.role,"")};return Object(y.jsxs)(y.Fragment,{children:[Ve?Object(y.jsxs)(lo,{disabled:!0,hideCropSeasonDropdown:!1,onCropSeasonSelect:function(){qe()},children:[Object(y.jsx)(lo.Item,{title:"Integrations",value:"".concat(at.get("vendor")," Submission"),isLast:!0}),Object(y.jsx)(lo.Item,{title:"Tasks",value:"Edit Task",isLast:!0})]}):Object(y.jsxs)(lo,{disabled:!0,hideCropSeasonDropdown:!1,onCropSeasonSelect:function(){qe()},children:[Object(y.jsx)(lo.Item,{title:"Tasks",value:"All Tasks",to:Cc.tasks}),Object(y.jsx)(lo.Item,{title:"Task",value:g?"Create Task":"Edit Task",isLast:!0})]}),me?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(y.Fragment,{children:[re&&Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){return ce("")},children:re}),Object(y.jsx)(Zi.e,{enableReinitialize:!0,initialValues:se,validationSchema:iQ,onSubmit:function(e){ct(e)},children:function(e){var t=e.values,n=e.handleSubmit;return Object(y.jsxs)("div",{className:"h-full",children:[Object(y.jsx)(Sm,{}),Object(y.jsxs)("div",{className:"flex justify-between px-2 py-4",children:[Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"mr-12","data-testid":"editViewStartDate",children:[Object(y.jsx)("div",{className:"text-sm leading-4 text-neutral-600 font",children:"Start Date"}),Object(y.jsx)("div",{className:"text-2xl",children:Object(ya.a)(Object(KK.a)(new Date(t.startDate)),"MMM d, yyyy")})]}),Object(y.jsxs)("div",{className:"mr-12 ","data-testid":"editViewAcres",children:[Object(y.jsx)("div",{className:"text-sm leading-4 text-neutral-600 font",children:"Acres"}),Object(y.jsx)("div",{className:"text-2xl",children:SQ(null===t||void 0===t?void 0:t.totalAreaValue)||SQ(null===t||void 0===t?void 0:t.totalApplied)})]}),Object(y.jsxs)("div",{className:"mr-12 ","data-testid":"editViewProducts",children:[Object(y.jsx)("div",{className:"text-sm leading-4 text-neutral-600 font",children:"Total Cost"}),Object(y.jsx)("div",{className:"text-2xl",children:ot(null===t||void 0===t?void 0:t.products)})]})]}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"mr-3",children:Object(y.jsx)(m.Button,{type:"primary",ghost:!0,onClick:it,id:"cancelTask","data-testid":"cancelTask",name:"cancel",children:"Cancel"})}),Object(y.jsx)(m.Button,{type:"primary",onClick:n,id:"saveTask","data-testid":"saveTask",loading:ee,disabled:ee,children:ee?"Saving...":"Save"})]})]}),Object(y.jsx)("div",{className:"px-6 pt-4 -mx-4 bg-white",style:{height:"calc(100% - 84px)"},children:Object(y.jsxs)(m.Tabs,{activeTab:O,children:[Object(y.jsx)(m.Tabs.Tab,{label:"Details",children:Object(y.jsx)(mQ,{people:F,peopleLoading:M,companies:U,companiesLoaded:B,fieldsAndAreasCentroidCoordinates:Ge,fieldsAndAreasGeoJSONCollection:He,weatherAutomaticToggle:r.weatherAutomaticToggle,memberRole:null===E||void 0===E?void 0:E.role,memberFinancialAccess:D,setAmplitudeTabSelection:je})}),Object(y.jsx)(m.Tabs.Tab,{label:"Properties",children:Object(y.jsx)(vQ,{propertyLandingPageData:Ze,loading:Ye,fieldsAndAreasGeoJSONCollection:He,cropSeasonIds:Re,selectedApplicationOption:$e,setAmplitudeTabSelection:je})}),Object(y.jsx)(m.Tabs.Tab,{label:"Products",children:Object(y.jsx)(yQ,{memberRole:null===E||void 0===E?void 0:E.role,memberFinancialAccess:D,applicationOptions:Om,selectedApplicationOption:$e,setSelectedApplicationOption:tt,isEditing:d,setAmplitudeTabSelection:je})}),Object(y.jsx)(m.Tabs.Tab,{label:"Weather",children:Object(y.jsx)(AQ,{fieldsAndAreasCentroidCoordinates:Ge,fieldsAndAreasGeoJSONCollection:He,setAmplitudeTabSelection:je})})]})})]})}})]})]})},EQ=function(e){var t,n,a,r,c=e.open,i=e.onClose,o=e.product,s=e.applicationType,l=e.memberRole,d=e.memberFinancialAccess,u=function(e){return e||0},b=function(){return"View Only"!==l||"none"!==d};return Object(y.jsxs)(m.SimpleModal,{open:c,close:i,onConfirm:i,size:"sm",children:[Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"font-bold text-lg",children:o.productName})}),Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"text-sm text-neutral-300",children:o.manufacturerName})}),Object(y.jsx)("div",{className:"mt-12",children:Object(y.jsxs)("div",{className:"grid grid-cols-3 gap-6 mb-12",children:[Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:function(e){var t="Rate/Tank";return"ratePerAreaValue"===e?t="Rate/Area":"totalProductValue"===e&&(t="Total Product"),t}(s),value:null===o||void 0===o?void 0:o[s],disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{style:{whiteSpace:"nowrap"},label:"Unit",value:Object(ne.startCase)(o.ratePerAreaUnit),disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Applied Area",value:"".concat(o.appliedAreaValue," ac"),disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Applied Area %",value:"".concat(100*o.coveragePercent,"%"),disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Price/Unit",value:b()?"$".concat(o.averagePriceAtTimeOfCreation):null,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Total Grower Cost",value:b()?"$".concat((o.totalCostAtTimeOfCreation*(u(null===(t=o.shareOwnerInformation)||void 0===t?void 0:t.percentGrowerResponsibility)/100)).toFixed(2)):null,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Application Method",value:o.applicationMethod,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Target Pest",value:null===(n=o.targetPest)||void 0===n?void 0:n.name,disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"Grower Share",value:"".concat(u(null===(a=o.shareOwnerInformation)||void 0===a?void 0:a.percentGrowerResponsibility),"%"),disabled:!0})}),Object(y.jsx)("div",{className:"my-2",children:Object(y.jsx)(m.Input,{label:"From Inventory",value:"".concat(u(null===(r=o.shareOwnerInformation)||void 0===r?void 0:r.totalFromGrowerInventoryQuantity),"%"),disabled:!0})})]})})]})};EQ.defaultProps={open:!1,onClose:function(){}};var wQ=EQ,_Q=function(e){return"ratePerTankValue"===e?"ratePerTankValue":"ratePerAreaValue"},RQ=function(e){var t=e.product,n=e.applicationType,r=e.memberRole,c=e.memberFinancialAccess,i=Object(a.useState)(!1),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(_Q(n)),u=Object(b.a)(d,2),j=u[0],p=u[1];return Object(a.useEffect)((function(){var e=_Q(n);p(e)}),[n]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(wQ,{open:s,onClose:function(){l(!1)},product:t,applicationType:n,memberRole:r,memberFinancialAccess:c}),Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsxs)("span",{className:"flex flex-col",children:[Object(y.jsx)("span",{className:"w-64 pb-2 text-sm font-bold text-left truncate","data-testid":"product-name",children:t.productName}),Object(y.jsxs)("span",{className:"w-64 text-sm text-left text-gray-600 truncate pb-2","data-testid":"product-manufacturer",children:[t.isCustom&&Object(y.jsx)(y.Fragment,{children:"Custom"}),t.isCustom&&t.manufacturerName&&Object(y.jsx)(y.Fragment,{children:" \u2022 "}),t.manufacturerName]})]})}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:2,children:null===t||void 0===t?void 0:t[j]})," ",Object(va.g)(null===t||void 0===t?void 0:t.ratePerAreaUnit)]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:2,children:t.appliedAreaValue})," ",t.appliedAreaUnit]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:2,children:100*t.coveragePercent})," ","%"]}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:2,children:t.totalProductValue})," ",Object(va.g)(null===t||void 0===t?void 0:t.totalProductUnit)]}),Object(y.jsxs)(m.Table.Cell,{width:"20rem",children:[Object(y.jsx)("div",{className:"mr-6",children:"Full control"!==r&&"View Only"!==r||"none"!==c?Object(y.jsx)(yf,{unit:"usCurrency",roundedTo:2,children:t.totalCostAtTimeOfCreation}):null}),Object(y.jsx)("div",{"data-testid":"product-table-view-button",className:"mr-8 absolute right-0 flex-none w-10",children:Object(y.jsx)(m.Button,{type:"link-default",onClick:function(){return l(!0)},"data-html2canvas-ignore":!0,children:"View"})})]})]},t.id)]})},IQ=function(e){var t=e.open,n=e.onClose,a=e.property;return Object(y.jsx)(m.SimpleModal,{open:t,close:n,onConfirm:n,size:"sm",children:Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"flex items-center justify-between",children:Object(y.jsx)("div",{className:"font-bold text-lg",children:a.fieldName})}),Object(y.jsx)("div",{className:"text-neutral-300 text-sm -mt-1",children:a.cropZoneName}),Object(y.jsxs)("div",{className:"w-48 mt-4 flex justify-between",children:[Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-neutral-300 text-sm",children:"Area"}),Object(y.jsxs)("div",{className:"font-semibold text-lg",children:[a.areaValue," ac"]})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-neutral-300 text-sm",children:"Crop"}),Object(y.jsx)("div",{className:"font-semibold text-lg",children:a.cropName})]})]}),Object(y.jsx)("div",{className:"mt-8",children:Object(y.jsxs)(m.RadioButtonGroup,{children:[Object(y.jsxs)(m.RadioButtonGroup.RadioButton,{disabled:!0,selected:!0,children:["Reported Area (",function(e){return e&&0!==e?"".concat(e," ac"):" "}(a.reportedArea),")"]}),Object(y.jsxs)(m.RadioButtonGroup.RadioButton,{disabled:!0,children:["Boundary Area (",a.boundaryArea," ac)"]})]})}),Object(y.jsxs)("div",{className:"flex mt-12 mb-24",children:[Object(y.jsx)(m.Input,{disabled:!0,label:"Applied Area",value:"".concat(a.areaValue," ac")}),Object(y.jsx)("div",{className:"ml-4",children:Object(y.jsx)(m.Input,{disabled:!0,label:"Coverage %",value:Math.round((null===a||void 0===a?void 0:a.coveragePercent)+Number.EPSILON)})})]})]})})};IQ.defaultProps={open:!1,onClose:function(){}};var DQ=IQ,kQ=function(e){var t,n=e.property,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=null!==n&&void 0!==n&&null!==(t=n.features)&&void 0!==t&&t[0]?[Ej(n.features[0])]:void 0;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(DQ,{open:i,onClose:function(){o(!1)},property:{cropZoneName:null===n||void 0===n?void 0:n.cropZoneName,cropName:null===n||void 0===n?void 0:n.cropName,fieldName:null===n||void 0===n?void 0:n.fieldName,areaValue:null===n||void 0===n?void 0:n.areaValue,areaUnit:null===n||void 0===n?void 0:n.areaUnit,boundaryArea:Math.round(100*((null===n||void 0===n?void 0:n.boundaryArea)+Number.EPSILON))/100,reportedArea:Math.round(100*((null===n||void 0===n?void 0:n.reportedArea)+Number.EPSILON))/100,coveragePercent:Math.round(100*((null===n||void 0===n?void 0:n.coveragePercent)+Number.EPSILON))},"data-testid":"properties-modal"}),Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(Kp,{id:"view-field-card-icon",features:s})}),Object(y.jsx)(m.Table.Cell,{width:"20rem",children:Object(y.jsxs)("div",{className:"flex flex-col justify-start leading-5 text-left",children:[Object(y.jsx)("span",{className:"font-bold text-neutral-1000",children:null===n||void 0===n?void 0:n.fieldName}),Object(y.jsx)("span",{style:{color:"#707374"},children:null===n||void 0===n?void 0:n.cropZoneName})]})}),Object(y.jsx)(m.Table.Cell,{children:null===n||void 0===n?void 0:n.cropName}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(yf,{roundedTo:2,children:null===n||void 0===n?void 0:n.areaValue})," ac"]}),Object(y.jsxs)(m.Table.Cell,{width:"20rem",children:[Object(y.jsx)("div",{className:"mr-6",children:Object(y.jsx)(yf,{roundedTo:2,children:100*(null===n||void 0===n?void 0:n.coveragePercent)})}),Object(y.jsx)("div",{"data-testid":"property-table-view-button",className:"mr-8 absolute right-0 flex-none w-10",children:Object(y.jsx)(m.Button,{type:"link-default",onClick:function(){return o(!0)},"data-html2canvas-ignore":!0,children:"View"})})]})]},null===n||void 0===n?void 0:n.cropZoneId)]})},LQ=[{key:"N",value:0},{key:"NNE",value:22.5},{key:"NE",value:45},{key:"ENE",value:67.5},{key:"E",value:90},{key:"ESE",value:112.5},{key:"SE",value:135},{key:"SSE",value:157.5},{key:"S",value:180},{key:"SSW",value:202.5},{key:"SW",value:225},{key:"WSW",value:247.5},{key:"W",value:270},{key:"WNW",value:292.5},{key:"NW",value:315},{key:"NNW",value:337.5}],FQ=[{key:"ratePerAreaValue",value:"By Rate/Area Application",display:"ByRatePerArea"},{key:"totalProductValue",value:"By Total Product Application",display:"ByTotalProduct"},{key:"ratePerTankValue",value:"By Rate/Tank Application",display:"ByRatePerTank"}],MQ=function(e){var t,n,r,c,i,o=e.location,s=Object(p.j)().id,l=rv({fetchType:xm}),d=l.dataSorted,u=l.fieldsAndAreasGeoJSONCollection,j=l.reloadData,f=(null===o||void 0===o||null===(t=o.state)||void 0===t?void 0:t.propertyData)||d,v=Object(a.useContext)(ac),O=Object(b.a)(v,2),h=O[0].loggedInUserOrgPermission,x=h.role,g=h.financialAccess,C=void 0===g?"none":g,P=O[1],A=Object(a.useContext)(we),S=Object(a.useState)({}),T=Object(b.a)(S,2),N=T[0],E=T[1],w=Object(a.useState)(!0),_=Object(b.a)(w,2),R=_[0],D=_[1],k=Object(a.useState)(null),L=Object(b.a)(k,2),F=L[0],M=L[1],V=Object(a.useState)([]),B=Object(b.a)(V,2),U=B[0],z=B[1],Z=Object(a.useState)(!1),H=Object(b.a)(Z,2),W=H[0],q=H[1],J=Object(a.useState)(null),K=Object(b.a)(J,2)[1],Q=Object(p.h)(),X=Object(a.useState)(),$=Object(b.a)(X,2),ee=$[0],te=$[1],ne=Object(a.useState)(null),ae=Object(b.a)(ne,2),re=ae[0],ce=ae[1],ie=Object(a.useState)(!0),oe=Object(b.a)(ie,2),se=oe[0],le=oe[1],de=Object(a.useState)({open:!1,id:null}),ue=Object(b.a)(de,2),be=ue[0],je=ue[1],pe=Object(a.useState)({extraTagsCount:0,extraTagsNames:[],tagsToDisplay:[]}),fe=Object(b.a)(pe,2),me=fe[0],ve=fe[1],Oe=ZK(),he=Oe.exportPdfEnglish,xe=Oe.exportPdfSpanish,ge=Oe.downloadingPDF;Object(a.useEffect)((function(){j()}),[]),Object(a.useEffect)((function(){gn.fetch(s).promise.then((function(e){var t,n=e.data;n&&(E(n),z(n.flags),M((t=n.applicationStrategy)===FQ[0].display?FQ[0].key:t===FQ[1].display?FQ[1].key:t===FQ[2].display?FQ[2].key:FQ[0].key)),D(!1)})).catch(Ae.default).catch((function(e){uc(P)(e),D(!1)}))}),[P,s]),Object(a.useEffect)((function(){ee&&A.sendEventToAmplitude(A.events.epic.Tasks.viewTaskSuccess,{farmsSelected:null===ee||void 0===ee?void 0:ee.map((function(e){return e.farmId})),fieldsSelected:null===ee||void 0===ee?void 0:ee.map((function(e){return e.fieldId}))})}),[R,ee]);var Ce=Object(a.useCallback)(Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],null===f||void 0===f||null===(t=f.properties)||void 0===t||t.forEach((function(e){var t;null===e||void 0===e||null===(t=e.fields)||void 0===t||t.forEach((function(e){var t;null===e||void 0===e||null===(t=e.cropzones)||void 0===t||t.forEach((function(t){var a;null===N||void 0===N||null===(a=N.properties)||void 0===a||a.forEach((function(a){if((null===t||void 0===t?void 0:t.id)===(null===a||void 0===a?void 0:a.cropZoneId)){var r,c,i={farmId:null===a||void 0===a?void 0:a.farmId,cropZoneId:null===t||void 0===t?void 0:t.id,fieldName:null===e||void 0===e?void 0:e.name,fieldId:null===e||void 0===e?void 0:e.id,cropZoneName:null===t||void 0===t?void 0:t.name,cropName:null===t||void 0===t||null===(r=t.crop)||void 0===r?void 0:r.name,areaValue:null===a||void 0===a?void 0:a.areaValue,areaUnit:null===a||void 0===a?void 0:a.areaUnit,boundaryArea:null===t||void 0===t?void 0:t.boundaryArea,reportedArea:null===t||void 0===t?void 0:t.reportedArea,coveragePercent:null===a||void 0===a?void 0:a.coveragePct,features:null===(c=u.features)||void 0===c?void 0:c.filter((function(t){return e.id===t.properties.id}))};n.push(i)}}))}))}))})),e.abrupt("return",n);case 3:case"end":return e.stop()}}),e)}))),[null===f||void 0===f?void 0:f.properties,null===N||void 0===N?void 0:N.properties,null===u||void 0===u?void 0:u.features]);Object(a.useEffect)((function(){var e,t;(null===f||void 0===f||null===(e=f.properties)||void 0===e?void 0:e.length)>0&&(null===N||void 0===N||null===(t=N.taskId)||void 0===t?void 0:t.length)>0&&Ce().then((function(e){te(e)}))}),[Ce,f,N]),Object(a.useEffect)((function(){ve(Af(U,20))}),[U]);var ye=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Object(I.a)(Object(I.a)({},N),{},{applicationStrategy:"ratearea",flags:t}),a=gn.update(N.taskId,n),r=a.promise,e.next=4,r.then((function(){return z(t)})).catch(Ae.default).catch((function(e){var t,n,a,r;if(null!==(t=e.response)&&void 0!==t&&null!==(n=t.data)&&void 0!==n&&n.validationErrors)K("Error saving task: ".concat(e.response.data.message));else if(null!==(a=e.response)&&void 0!==a&&null!==(r=a.data)&&void 0!==r&&r.displayErrorMessage){var c,i;ce(null===(c=e.response)||void 0===c||null===(i=c.data)||void 0===i?void 0:i.displayErrorMessage),le(!0),K(e.response.data.displayErrorMessage)}else uc(P)(e)}));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Pe=go((function(e,t){M(t)}),xo),Se=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=gn.delete(be.id),n=t.promise,e.next=3,n.then((function(){A.sendEventToAmplitude(A.events.epic.Tasks.deleteTaskSuccess),Q.replace(Cc.tasks)}));case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Object(y.jsxs)(y.Fragment,{children:[se?Object(y.jsx)(m.Toast,{icon:"error",onClose:function(){le(!1)},children:re}):null,Object(y.jsxs)(lo,{disabled:!0,hideCropSeasonDropdown:!1,children:[Object(y.jsx)(lo.Item,{title:"Tasks",value:"All Tasks",to:Cc.tasks}),Object(y.jsx)(lo.Item,{title:"Task",value:N.name||"View Task",isLast:!0})]}),!R&&ee?Object(y.jsxs)("div",{id:"task-view",children:[Object(y.jsx)("div",{className:"mt-3",children:Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsxs)("div",{className:"flex justify-between w-1/2 mr-16",children:[Object(y.jsx)(Fl,{className:"mx-4",header:"Start Date",data:hA(null===N||void 0===N?void 0:N.startDate),testId:"startDate"}),Object(y.jsx)(Fl,{className:"mx-4",header:"Acres",data:String(N.totalAreaValue),testId:"acres"}),Object(y.jsx)(Fl,{className:"mx-4",header:"Total Cost",data:"Full control"!==x&&"View Only"!==x||"none"!==C?function(e){var t=0;return null===e||void 0===e||e.forEach((function(e){t+=null===e||void 0===e?void 0:e.totalCostAtTimeOfCreation})),function(e){var t=Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}).format;return"$ ".concat(t(e))}(t)}(null===N||void 0===N?void 0:N.products):"",testId:"products"})]}),Object(y.jsx)("div",{className:"flex self-center mr-6",children:ge?Object(y.jsx)(m.Spinner,{size:"sm"}):Object(y.jsx)(Wo,{onAction:function(e){var t={edit:function(){A.sendEventToAmplitude(A.events.epic.Tasks.editTask),Q.push("".concat(Cc.tasks,"/").concat(s))},delete:function(){A.sendEventToAmplitude(A.events.epic.Tasks.taskDelete),je({id:s,open:!0})},tag:function(){q(!0)},duplicate:function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return A.sendEventToAmplitude(A.events.epic.Tasks.duplicateTask),e.next=3,P({type:"SET_CONVERT_PLAN",payload:{id:N.taskId}});case 3:Q.push("".concat(Cc.tasks,"/duplicate"));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),exportPdfEnglish:he,exportPdfSpanish:xe};t[e](s)},options:"ready"===N.status?fs:ps})})]})}),Object(y.jsx)(ib,{open:be.open,itemType:"Task",onCancel:function(){return je({open:!1,id:null})},onDelete:function(){A.sendEventToAmplitude(A.events.epic.Tasks.deleteTask),Se()}}),Object(y.jsx)(l_,{open:W,close:function(){q(!1)},name:N.name,selectedTags:null===U||void 0===U?void 0:U.reduce((function(e,t){return"".concat(e,",").concat(t.id)}),""),returnSelectedTags:ye}),Object(y.jsx)(ll,{className:"mt-6",children:Object(y.jsxs)("div",{className:"m-4",children:[Object(y.jsxs)("div",{"data-testid":"task-details",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Task Details"})}),Object(y.jsx)(m.Columns,{children:Object(y.jsx)(m.Column,{children:Object(y.jsxs)("div",{className:"mb-6",children:[Object(y.jsx)(Fl,{header:"Task ID",data:N.name,testId:"taskId"}),Object(y.jsx)("div",{className:"w-32 text-center my-2",children:Object(y.jsx)(qG,{status:N.status})})]})})}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsx)(m.Column,{width:"w-120",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Start Date/Time",data:hA(N.startDate),testId:"startDateTime"})})}),Object(y.jsx)(m.Column,{width:"w-56",children:Object(y.jsx)("div",{className:"flex items-center w-full h-full",children:Object(y.jsx)("svg",{width:"53",height:"16",viewBox:"0 0 53 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{d:"M52.7071 8.7071C53.0976 8.31658 53.0976 7.68341 52.7071 7.29289L46.3431 0.928928C45.9526 0.538404 45.3195 0.538404 44.9289 0.928928C44.5384 1.31945 44.5384 1.95262 44.9289 2.34314L50.5858 8L44.9289 13.6569C44.5384 14.0474 44.5384 14.6805 44.9289 15.0711C45.3195 15.4616 45.9526 15.4616 46.3431 15.0711L52.7071 8.7071ZM8.74228e-08 9L52 9L52 7L-8.74228e-08 7L8.74228e-08 9Z",fill:"#696F88"})})})}),Object(y.jsx)(m.Column,{width:"w-120",children:Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"End Date/Time",data:hA(N.dueDate),testId:"endDateTime"})})})]}),Object(y.jsxs)(m.Columns,{children:[Object(y.jsxs)(m.Column,{width:"w-1/3",children:[Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Authorization By",data:N.authorizedBy,testId:"authorizedBy"})}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Timing Event",data:N.timingEvent,testId:"timingEvent"})}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsxs)("div",{"data-testid":"cropSeason",children:[Object(y.jsx)("div",{className:"text-gray-600",children:"Crop Season"}),Object(y.jsx)("div",{className:"text-2xl",children:Object(y.jsx)(m.TagCloud,{children:N.cropSeasonIds.map((function(e){return Object(y.jsx)(m.Tag,{children:e.name},e.id)}))})})]})})]}),Object(y.jsxs)(m.Column,{width:"w-1/3",children:[Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Authorization Date/Time",data:N.authorizedDate?hA(N.authorizedDate):"-",testId:"authorizationDateTime"})}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Duration",data:N.duration?"".concat(N.duration," hours"):"",testId:"duration"})}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsxs)("div",{"data-testid":"flags",children:[Object(y.jsx)("div",{className:"text-gray-600",children:"Tags"}),Object(y.jsx)("div",{className:"mt-1",children:me.extraTagsNames.length>0?Object(y.jsx)(fu,{position:"bottom",ariaLabel:"Task Tags",top:"1.5rem",msg:Object(y.jsx)(Pf,{extraTagsNames:me.extraTagsNames}),component:Object(y.jsx)(Sf,{displayTagsObject:me,isLandingPage:!0,viewKey:fd})}):Object(y.jsx)(Sf,{displayTagsObject:me,isLandingPage:!0,viewKey:fd})})]})})]}),Object(y.jsxs)(m.Column,{width:"w-1/3",children:[Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Task Type",data:N.type,testId:"taskType"})}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsx)(Fl,{header:"Created on",data:hA(N.createdAt),testId:"createdOn"})}),Object(y.jsx)("div",{className:"mb-6",children:Object(y.jsxs)("div",{"data-testid":"source",children:[Object(y.jsx)("div",{className:"text-gray-600",children:"Source"}),Object(y.jsx)("div",{className:"text-2xl",children:(null===N||void 0===N?void 0:N.sources)&&Object(y.jsx)(m.TagCloud,{children:null===N||void 0===N?void 0:N.sources.map((function(e){return Object(y.jsx)(m.Tag,{children:e.name})}))})})]})})]})]})]}),Object(y.jsx)("hr",{className:"my-6"}),Object(y.jsxs)("div",{"data-testid":"applicator-section",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Applicator(s)"})}),Object(y.jsxs)(m.Columns,{wrap:!0,children:[(null===N||void 0===N?void 0:N.applicators)&&(null===N||void 0===N||null===(n=N.applicators)||void 0===n?void 0:n.map((function(e,t){return Object(y.jsx)(m.Column,{width:"w-full ".concat(t>0?"mt-6":""),children:Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"w-4/12",children:[Object(y.jsx)(Fl,{data:e.personName}),Object(y.jsx)("div",{className:"text-gray-600",children:"".concat(e.licenseNumber?e.licenseNumber:""," ").concat(e.expiresDate?"Exp. ".concat(fA(e.expiresDate)):""," ")})]}),Object(y.jsx)(Fl,{header:"Company",data:e.companyName})]})},e.personId)}))),Object(y.jsx)("div",{className:"w-4/12 mt-6",children:Object(y.jsx)(Fl,{header:"Buffer Zone",data:N.bufferZone?"".concat(N.bufferZone," FT"):null,testId:"bufferZone"})}),Object(y.jsx)("div",{className:"mt-6",children:Object(y.jsx)(Fl,{header:"Buffer Reason",data:N.bufferReason,testId:"pollenDrift"})})]})]}),Object(y.jsx)("hr",{className:"my-6"}),Object(y.jsxs)("div",{"data-testid":"properties-section",className:"mb-6",id:"task-pagebreaker-1",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Properties"})}),Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{width:"10%"}),Object(y.jsxs)(m.Table.Cell,{width:"25%",children:["Fields (",null===N||void 0===N||null===(r=N.properties)||void 0===r?void 0:r.length,")"]}),Object(y.jsx)(m.Table.Cell,{children:"Crops"}),Object(y.jsx)(m.Table.Cell,{children:"Area"}),Object(y.jsx)(m.Table.Cell,{width:"15%",children:"Coverage %"})]}),ee.map((function(e){return Object(y.jsx)(kQ,{property:e},e.farmId)}))]})]}),Object(y.jsxs)("div",{"data-testid":"products-services-section",className:"mb-6",id:"task-pagebreaker-2",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Products & Services"}),Object(y.jsx)(m.Select,{value:F,onChange:Pe,items:FQ,"data-html2canvas-ignore":!0})]})}),Object(y.jsxs)(m.Table,{children:[Object(y.jsxs)(m.Table.Header,{children:[Object(y.jsx)(m.Table.Cell,{width:"20%",children:"Products (".concat(null===(c=N.products)||void 0===c?void 0:c.length,")")}),Object(y.jsx)(m.Table.Cell,{width:"10%",children:function(e){var t="Rate/Tank";return("ratePerAreaValue"===e||"totalProductValue"===e)&&(t="Rate/Area"),t}(F)}),Object(y.jsx)(m.Table.Cell,{width:"20%",children:"Appl. Area"}),Object(y.jsx)(m.Table.Cell,{width:"10%",children:"Appl. Area %"}),Object(y.jsx)(m.Table.Cell,{width:"20%",children:"Total Product"}),Object(y.jsx)(m.Table.Cell,{width:"20%",children:"Total Cost"})]}),N.products.map((function(e){return Object(y.jsx)(RQ,{id:e.id,product:e,applicationType:F,memberRole:x,memberFinancialAccess:C},e.id)}))]})]}),Object(y.jsxs)("div",{"data-testid":"weather-section",id:"task-pagebreaker-3",className:"my-6",children:[Object(y.jsx)("div",{className:"pt-4 mb-8 text-2xl font-bold",children:"Weather"}),Object(y.jsx)("div",{className:"flex",children:null===N||void 0===N||null===(i=N.weather)||void 0===i?void 0:i.map((function(e){var t,n;return Object(y.jsx)("div",{className:"mr-6",children:Object(y.jsx)(WG,{isStart:"START"===e.type,date:fA(null===e||void 0===e?void 0:e.date),time:gA(null===e||void 0===e?void 0:e.date),windSpeed:null===e||void 0===e?void 0:e.windSpeed,windDirection:null===(n=null===e||void 0===e?void 0:e.windDirection,t=LQ.find((function(e){return e.key===n})))||void 0===t?void 0:t.value,skyCondition:null===e||void 0===e?void 0:e.skyCondition,temperature:null===e||void 0===e?void 0:e.temperature,soilMoisture:null===e||void 0===e?void 0:e.soilMoisture,humidity:null===e||void 0===e?void 0:e.humidity,speedUnit:null===e||void 0===e?void 0:e.windSpeedUnit,tempUnit:null===e||void 0===e?void 0:e.temperatureUnit})})}))})]}),Object(y.jsxs)("div",{"data-testid":"notes-section",children:[Object(y.jsx)("div",{className:"flex justify-between pt-4 mb-8",children:Object(y.jsx)("div",{className:"text-2xl font-bold",children:"Notes"})}),Object(y.jsx)(m.TextArea,{"data-testid":"taskNotes",className:"h-64 overscroll-auto",resizeDisabled:!0,disabled:!0,value:N.notes})]})]})})]}):Object(y.jsx)(m.Spinner,{})]})};MQ.defaultProps={location:void 0};var VQ=MQ,BQ=[{id:"tasks",key:"tasks",path:Cc.tasks,exact:!0,secure:!0,disabled:!1,component:JK,icon:nd,nav:"leftNav"},{id:"taskEntry",key:"taskEntry",path:"".concat(Cc.tasks,"/:id"),exact:!0,secure:!0,component:NQ,minPermissions:{minAllowedRole:$a}},{id:"taskView",key:"taskView",path:"".concat(Cc.tasks,"/:id/view"),exact:!0,secure:!0,component:VQ},{id:"taskConvert",key:"taskConvert",path:"".concat(Cc.tasks,"/:id/convert"),exact:!0,secure:!0,component:NQ,minPermissions:{minAllowedRole:$a}},{id:"taskDuplicate",key:"taskDuplicate",path:"".concat(Cc.tasks,"/:id/duplicate"),exact:!0,secure:!0,component:NQ,minPermissions:{minAllowedRole:$a}}],UQ=Fu.e().shape({name:Fu.f().trim().required("Required"),languageCountry:Fu.f().required("Required"),masterListGroup:Fu.f().required("Required"),timeZone:Fu.f().required("Required"),areaUnit:Fu.f().required("Required")}),zQ=n.p+"static/media/welcome.acfcc2df.jpg",ZQ=function(){var e,t=Object(p.j)().variation,n=Object(a.useState)(!1),r=Object(b.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)(null),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)("new-user"),j=Object(b.a)(u,2),f=j[0],v=j[1],O=Object(a.useContext)(ac),h=Object(b.a)(O,2)[1],x=We(),g=x.fetchUserProfile,C=x.user,P=x.logout,A=ci().filteredOrganizations,S=Object(a.useState)(!1),T=Object(b.a)(S,2)[1],N=null===A||void 0===A||null===(e=A[0])||void 0===e?void 0:e.id;Object(a.useEffect)((function(){v(t)}),[t]);var E=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i(!0),T(!0),c||(n=Jt.create(t),n.promise.then((function(e){var t=e.data;return g(),t})).then((function(e){h({type:"SET_ORGANIZATIONS",payload:[{name:e.name,id:e.id}]}),vc(h,{name:e.name,id:e.id},C),d("".concat(Cc.organizations,"/").concat(e.id))})).catch(Ae.default).catch((function(e){T(!1),i(!1),uc(h)(e)})));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),w=function(){return P()};return Object(y.jsxs)("div",{"data-testid":"welcome",className:"fixed top-0 right-0 z-50 w-full h-screen",children:[l&&Object(y.jsx)(p.b,{push:!0,to:l}),Object(y.jsxs)("div",{className:"flex flex-col-reverse w-full h-full sm:flex-row",children:[Object(y.jsx)("div",{className:"sm:flex-1 bg-neutral-1000 bg-opacity-[.7] h-screen w-full ",children:Object(y.jsx)("img",{src:zQ,alt:"closeup of crop",className:"flex flex-1 object-cover w-full h-full"})}),Object(y.jsx)("div",{className:"flex items-center justify-center h-full bg-white sm:flex-1",children:Object(y.jsxs)("div",{className:"max-w-[70%] ",children:[Object(y.jsx)("img",{src:Ga,alt:"Cropwise Financials Logo",className:"max-w-[300px] block mx-auto mb-4"}),Object(y.jsx)("p",{className:"mb-12",children:"new-user"===f?Object(y.jsx)(y.Fragment,{children:"Welcome! Create a new organziation to get started."}):Object(y.jsx)(y.Fragment,{children:"Looks like you don\u2019t currently belong to an organization. Create a new one to get started."})}),Object(y.jsx)(Zi.e,{validationSchema:UQ,initialValues:{},onSubmit:E,children:function(e){var t=e.handleSubmit,n=e.errors;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"mb-12",children:Object(y.jsx)(Qi,{control:m.Input,label:"Organization Name",name:"name",errors:n.name})}),Object(y.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-6 gap-y-12",children:[Object(y.jsx)("div",{children:Object(y.jsx)(Qi,{control:m.Select,items:[{key:"en-US",value:"en-US"}],label:"Language / Country",name:"languageCountry",errors:n.name})}),Object(y.jsx)("div",{children:Object(y.jsx)(Qi,{control:m.Select,items:[{key:"en-US",value:"en-US"}],label:"Master List Group",name:"masterListGroup",errors:n.name})}),Object(y.jsx)("div",{children:Object(y.jsx)(Qi,{control:m.Select,items:[{value:"Atlantic Standard Time (GMT-4)",key:"(GMT-4)"},{value:"Eastern Standard Time (GMT-5)",key:"(GMT-5)"},{value:"Central Standard Time (GMT-6)",key:"(GMT-6)"},{value:"Mountain Standard Time (GMT-7)",key:"(GMT-7)"},{value:"Pacific Standard Time (GMT-8)",key:"(GMT-8)"},{value:"Alaska Standard Time (GMT-9)",key:"(GMT-9)"},{value:"Hawaii Standard Time (GMT-10)",key:"(GMT-10)"}],label:"Time Zone",name:"timeZone",errors:n.name})}),Object(y.jsx)("div",{children:Object(y.jsx)(Qi,{control:m.Select,items:[{key:"acres",value:"acres"}],label:"Area Unit",name:"areaUnit",errors:n.name})})]}),Object(y.jsxs)("div",{className:"flex justify-end",children:[Object(y.jsx)("div",{className:"mr-2",children:Object(y.jsx)(m.Button,{type:"primary",ghost:!0,disabled:!N,onClick:w,children:"Cancel"})}),Object(y.jsx)(m.Button,{type:"primary",ghost:c,onClick:t,loading:c,children:"Create"})]})]})}})]})})]})]})};ZQ.defaultProps={modalTrigger:null};var YQ=[{id:"welcome",key:"welcome",path:Cc.welcome,exact:!0,secure:!0,component:ZQ},{id:"welcomeVariation",key:"welcomeVariation",path:"/app/welcome/:variation",exact:!0,secure:!0,component:ZQ}],HQ="SET_STEP",GQ="SET_SELECTED_PROPERTIES",WQ="SET_SELECTED_COMMODITY",qQ="SET_SHOW_TOAST",JQ="SET_TOAST_MESSAGE",KQ="SET_LOADING_FETCH",QQ=function(e,t){switch(t.type){case HQ:return Object(I.a)(Object(I.a)({},e),{},{step:t.payload});case GQ:return Object(I.a)(Object(I.a)({},e),{},{cropZones:t.payload});case WQ:return Object(I.a)(Object(I.a)({},e),{},{selectedCommodity:t.payload});case qQ:return Object(I.a)(Object(I.a)({},e),{},{showToast:t.payload});case JQ:return Object(I.a)(Object(I.a)({},e),{},{showToast:t.payload.isToastActive,typeToast:t.payload.typeToast,messageToast:t.payload.messageToast});case KQ:return Object(I.a)(Object(I.a)({},e),{},{isLoading:t.payload});default:return e}},XQ={step:1,selectedCommodity:{id:"",name:""},cropZones:[],showToast:!1,typeToast:"success",messageToast:"Yield data saved.",isLoading:!1},$Q=Object(a.createContext)(XQ),eX=function(e){var t=e.children,n=Object(a.useReducer)(QQ,XQ),r=Object(b.a)(n,2),c=r[0],i=r[1];return Object(y.jsx)($Q.Provider,{value:{state:c,dispatch:i,goBack:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;i({type:HQ,payload:e||c.step-1})},goForward:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;i({type:HQ,payload:e||c.step+1})},updateSelectedCommodity:function(e){i({type:WQ,payload:e})},updateCropZones:function(e){i({type:GQ,payload:e})},setShowToast:function(e){i({type:qQ,payload:e})},setResponseToastMessage:function(e){var t=e.type,n=e.message,a=e.isToastActive;i({type:JQ,payload:{isToastActive:a,typeToast:t,messageToast:n}})},setIsLoading:function(e){i({type:KQ,payload:e})}},children:t})};eX.defaultProps={children:null};var tX=eX,nX=function(){var e,t,n,r=Object(a.useContext)(ac),c=Object(b.a)(r,2)[1],i=Object(a.useContext)($Q).setIsLoading,o=Object(a.useState)([]),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(0),j=Object(b.a)(u,2),p=j[0],f=j[1],m=Object(a.useState)({}),v=Object(b.a)(m,2),O=v[0],h=v[1],x=Object(a.useState)(!1),g=Object(b.a)(x,2),C=g[0],y=g[1],P=Object(a.useState)(!1),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)(!1),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)({}),D=Object(b.a)(R,2),k=D[0],L=D[1],F=null===ac||void 0===ac||null===(e=ac._currentValue[0])||void 0===e||null===(t=e.organization)||void 0===t?void 0:t.id,M=null===ac||void 0===ac||null===(n=ac._currentValue[0])||void 0===n?void 0:n.selectedYieldCommodity.id,V=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y(!0),n=Un.delete(t,{headers:{"cwf-context":JSON.stringify({organization_id:F})}}),a=n.promise,e.abrupt("return",a.then((function(){return!0})).catch((function(){return!1})).finally((function(){y(!1)})));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{yieldEntries:l,yieldEntriesCount:p,isLoadingYieldEntry:S,loadYieldEntries:function(e){var t=e.seasonIds,n=e.commodityId,a=e.fieldToOrder,r=e.orderingType,i=e.page;T(!0);var o=Vn.post({seasonIds:t},{headers:{"cwf-context":JSON.stringify({organization_id:F})},params:{commodityId:n,fieldToOrder:r?a:"entryName",orderingType:null!==r&&void 0!==r?r:"asc",page:i+1}}),s=o.promise,l=o.cancel;return s.then((function(e){var t,n=e.data;d(null===n||void 0===n?void 0:n.data),f(null!==(t=null===n||void 0===n?void 0:n.elements)&&void 0!==t?t:0)})).catch(Ae.default).catch((function(e){uc(c)(e)})).finally((function(){return T(!1)})),l},loadYieldItem:function(e){return Un.fetch(e,void 0,{headers:{"cwf-context":JSON.stringify({organization_id:F})}}).promise.then((function(e){var t=e.data;h(t)})).catch(Ae.default).catch((function(e){uc(c)(e)})).finally((function(){return T(!1)}))},yieldEntry:O,saveYield:function(e,t){return i(!0),t?Un.update(e.id,Object(I.a)(Object(I.a)({},e),{},{commodityId:M}),{headers:{"cwf-context":JSON.stringify({organization_id:F})}}).promise.then((function(){return!0})).catch((function(){return!1})).finally((function(){i(!1)})):Un.post(Object(I.a)(Object(I.a)({},e),{},{commodityId:M}),{headers:{"cwf-context":JSON.stringify({organization_id:F})}}).promise.then((function(){return!0})).catch((function(){return!1})).finally((function(){i(!1)}))},deleteYield:V,isDeleteLoading:C,loadDashboard:function(e){var t=e.seasonIds,n=e.commodityId;_(!0);var a=Bn.post({seasonIds:t},{headers:{"cwf-context":JSON.stringify({organization_id:F})},params:{commodityId:n}}),r=a.promise,i=a.cancel;return r.then((function(e){var t=e.data;L(t)})).catch(Ae.default).catch((function(e){uc(c)(e)})).finally((function(){return _(!1)})),i},isLoadingYieldEntryDashboard:w,yieldDashboardData:k}},aX=n(419),rX=n.n(aX),cX=Intl.NumberFormat("en-US",{currency:"USD",style:"currency",minimumFractionDigits:2,maximumFractionDigits:2}),iX=Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),oX=function(){return(new Date).toLocaleDateString(void 0,{year:"2-digit",month:"2-digit",day:"2-digit",hour:"numeric",minute:"numeric",hour12:!0}).replace(/\//g,"-").replace(/,/g,"").toUpperCase()},sX=[{key:"bushels",value:"bushels",symbol:"bu"},{key:"dryOunces",value:"dry ounces",symbol:"oz"},{key:"grams",value:"grams",symbol:"g"},{key:"kilograms",value:"kilograms",symbol:"kg"},{key:"metricTons",value:"metric tons",symbol:"mt"},{key:"pounds",value:"pounds",symbol:"lb"},{key:"tons",value:"tons",symbol:"T"}],lX=function(e){var t;return null===(t=sX.find((function(t){return t.key===e})))||void 0===t?void 0:t.value},dX=function(e){var t;return null===(t=sX.find((function(t){return t.key===e})))||void 0===t?void 0:t.symbol},uX={mask:"\\$num",lazy:!1,blocks:{num:{mask:Number,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","}}},bX={mask:Number,lazy:!1,radix:".",mapToRadix:["."],normalizeZeros:!1,thousandsSeparator:","},jX=function(e){var t=e.data;return Object(y.jsxs)("div",{className:"flex flex-col flex-1",children:[Object(y.jsxs)("div",{className:"flex flex-row items-center mb-6",children:[Object(y.jsx)(rX.a,{className:"text-neutral-600"}),Object(y.jsx)("span",{className:"ml-2 font-semibold text-xl",children:"Revenue"})]}),Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsxs)("div",{className:"flex-1",children:[Object(y.jsx)("p",{className:"text-4xl font-semibold mb-0",children:cX.format(t.totalGrossRevenue)}),Object(y.jsx)("p",{className:"text-sm",children:"Total gross revenue"})]}),Object(y.jsxs)("div",{className:"flex-1",children:[Object(y.jsx)("p",{className:"ml-2",children:"Avg price/unit"}),Object(y.jsx)("div",{className:"w-50",children:t.units.map((function(e){return Object(y.jsxs)("p",{className:"px-3 py-2 my-2",style:{backgroundColor:"#F9FAFB"},children:[Object(y.jsx)("span",{className:"font-semibold mr-1",children:cX.format(e.avgPricePerUnit)}),"/ ",dX(e.unit)]},dX(e.unit))}))})]})]})]})},pX=function(){return Object(y.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Object(y.jsx)("path",{d:"M6.00711 5.25586C5.45426 5.25586 5.00608 5.70357 5.00608 6.25586V8.25586C5.00608 8.80814 5.45426 9.25586 6.00711 9.25586H8.00915C8.562 9.25586 9.01017 8.80814 9.01017 8.25586V6.25586C9.01017 5.70357 8.562 5.25586 8.00915 5.25586H6.00711Z",fill:"#696F88"}),Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11.0122 1.25586C11.0122 0.703575 11.4604 0.255859 12.0132 0.255859C12.5661 0.255859 13.0143 0.703575 13.0143 1.25586C13.5671 1.25586 14.0153 1.70357 14.0153 2.25586C14.0153 2.80814 13.5671 3.25586 13.0143 3.25586V11.2559C13.5671 11.2559 14.0153 11.7036 14.0153 12.2559C14.0153 12.8081 13.5671 13.2559 13.0143 13.2559C13.0143 13.8081 12.5661 14.2559 12.0132 14.2559C11.4604 14.2559 11.0122 13.8081 11.0122 13.2559H3.00404C3.00404 13.8081 2.55587 14.2559 2.00302 14.2559C1.45017 14.2559 1.002 13.8081 1.002 13.2559C0.44915 13.2559 0.000976562 12.8081 0.000976562 12.2559C0.000976562 11.7036 0.449149 11.2559 1.002 11.2559L1.002 3.25586C0.44915 3.25586 0.000976562 2.80814 0.000976562 2.25586C0.000976562 1.70357 0.449149 1.25586 1.002 1.25586C1.002 0.703575 1.45017 0.255859 2.00302 0.255859C2.55587 0.255859 3.00404 0.703575 3.00404 1.25586L11.0122 1.25586ZM11.0122 11.2559H3.00404V3.25586H11.0122V11.2559Z",fill:"#696F88"})]})},fX=function(){return Object(y.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(y.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11.0122 1.25586C11.0122 0.703575 11.4604 0.255859 12.0132 0.255859C12.5661 0.255859 13.0143 0.703575 13.0143 1.25586C13.5671 1.25586 14.0153 1.70357 14.0153 2.25586C14.0153 2.80814 13.5671 3.25586 13.0143 3.25586V11.2559C13.5671 11.2559 14.0153 11.7036 14.0153 12.2559C14.0153 12.8081 13.5671 13.2559 13.0143 13.2559C13.0143 13.8081 12.5661 14.2559 12.0132 14.2559C11.4604 14.2559 11.0122 13.8081 11.0122 13.2559H3.00404C3.00404 13.8081 2.55587 14.2559 2.00302 14.2559C1.45017 14.2559 1.002 13.8081 1.002 13.2559C0.44915 13.2559 0.000976562 12.8081 0.000976562 12.2559C0.000976562 11.7036 0.449149 11.2559 1.002 11.2559L1.002 3.25586C0.44915 3.25586 0.000976562 2.80814 0.000976562 2.25586C0.000976562 1.70357 0.449149 1.25586 1.002 1.25586C1.002 0.703575 1.45017 0.255859 2.00302 0.255859C2.55587 0.255859 3.00404 0.703575 3.00404 1.25586L11.0122 1.25586ZM11.0122 11.2559H3.00404V3.25586H11.0122V11.2559Z",fill:"#696F88"})})},mX=function(e){var t=e.data;return Object(y.jsxs)("div",{className:"flex flex-col flex-1",children:[Object(y.jsxs)("div",{className:"flex flex-row items-center mb-6",children:[Object(y.jsxs)("div",{className:"flex flex-row items-center mr-6",children:[Object(y.jsx)(KC,{}),Object(y.jsx)("span",{className:"text-xl font-semibold ml-3 mr-1",children:"Yield"})]}),Object(y.jsxs)("div",{className:"flex flex-row items-center mr-3",children:[Object(y.jsx)(fX,{}),Object(y.jsxs)("span",{className:"text-xs ml-1 mr-1",children:[t.totalFields," fields"]})]}),Object(y.jsxs)("div",{className:"flex flex-row items-center",children:[Object(y.jsx)(pX,{}),Object(y.jsxs)("span",{className:"text-xs ml-1 mr-1",children:[t.totalAcreage," ac"]})]})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"ml-2",children:"Total Yield"}),Object(y.jsx)("div",{className:"mt-2 w-92",children:t.units.map((function(e){return Object(y.jsxs)("div",{className:"flex flex-row justify-between px-3 py-2 my-2 w-auto",style:{backgroundColor:"#F9FAFB"},children:[Object(y.jsxs)("span",{children:[Object(y.jsx)("span",{className:"font-semibold mr-1",children:iX.format(e.totalYield)}),dX(e.unit)]}),Object(y.jsx)("span",{style:{width:"2px",height:"auto",backgroundColor:"#696F88"}}),Object(y.jsxs)("span",{children:[Object(y.jsx)("span",{className:"font-semibold mr-1",children:iX.format(e.yieldsPerAcre)}),dX(e.unit),"/ac"]})]},e.unit)}))})]})]})},vX=function(e){var t=e.selectedCommodity,n=e.displayedYieldEntries,r=nX(),c=r.loadDashboard,i=r.isLoadingYieldEntryDashboard,o=r.yieldDashboardData;return Object(a.useEffect)((function(){var e;null!==(e=t.current)&&void 0!==e&&e.id&&c({seasonIds:$P(),commodityId:t.current.id})}),[t.current,n]),Object(y.jsx)("div",{className:"flex flex-row w-full bg-white shadow-documentation-card",style:{borderRadius:"8px",paddingLeft:"34px",paddingRight:"34px",paddingTop:"24px",paddingBottom:"24px"},"data-testid":"yield-summary",children:i||!Object.keys(o).length?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(jX,{data:o}),Object(y.jsx)(mX,{data:o})]})})};vX.defaultProps={selectedCommodity:{current:null}};var OX=vX,hX=function(){var e=Object(p.h)();return Object(y.jsxs)("div",{className:"flex flex-col w-full bg-white shadow-documentation-card items-center justify-center",style:{height:"500px",borderRadius:"8px",paddingLeft:"34px",paddingRight:"34px",paddingTop:"24px",paddingBottom:"24px"},"data-testid":"yield-EmptySummary",children:[Object(y.jsx)("img",{src:Of,alt:"A empty map",className:"w-68",style:{marginTop:"-30px"}}),Object(y.jsx)("p",{className:"mb-5",children:"There are no crop zones for the selected crop season(s)."}),Object(y.jsx)(m.Button,{type:"primary",size:"lg",style:{paddingRight:"30px",paddingLeft:"30px"},onClick:function(){return e.push(Cc.properties)},children:"Go to Properties"})]})},xX=(n(1679),function(e){var t=e.cropzone,n=e.onSelect,a=Ag({cropObject:{name:t.name}});return Object(y.jsxs)(pu,{className:"flex flex-row w-auto text-neutral-1000 yield-option text-sm px-4 py-1 hover:bg-info-light-blue hover:text-info-dark-blue",onClick:function(){n(t.id,t.name)},children:[a,Object(y.jsx)("span",{className:"ml-3",children:t.name})]})}),gX=function(e){var t=e.cropzones,n=e.onSelect,r=e.onBlur;return Object(a.useEffect)((function(){return document.addEventListener("mousedown",r),function(){return document.removeEventListener("mousedown",r)}}),[]),Object(y.jsx)("div",{className:"absolute mt-1 ml-2 w-56 py-2 rounded bg-white shadow z-50",children:t.map((function(e){return Object(y.jsx)(xX,{cropzone:e,onSelect:n},e.id)}))})},CX=function(e){var t,n=e.cropzones,r=e.value,c=e.onChange,i=Object(a.useContext)(ac),o=Object(b.a)(i,2)[1],s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useRef)(),p=Object(Zi.h)().setFieldValue;Object(a.useEffect)((function(){c(n[0])}),[n,c]),Object(a.useEffect)((function(){r||c(n[0])}),[r,c,n]);return Object(y.jsx)("div",{className:"relative flex-1",children:Object(y.jsxs)(pu,{className:"bg-transparent text-info-dark-blue",name:"commodity",id:"commodity",ref:j,onClick:function(){return u((function(e){return!e}))},children:[Object(y.jsxs)("div",{className:"flex flex-row items-center text-2xl font-semibold",children:[Object(y.jsx)("span",{className:"selected-icon",children:Ag({cropObject:r,size:28})}),Object(y.jsx)("span",{className:"ml-2",children:null!==(t=null===r||void 0===r?void 0:r.name)&&void 0!==t?t:"--"}),Object(y.jsx)("span",{className:"yield-select-arrow w-8 h-7 selected-icon"})]}),d&&Object(y.jsx)(gX,{cropzones:n,onSelect:function(e,t){var n={id:e,name:t};o({type:"SELECTED_YIELD_COMMODITY",payload:n}),c(n),p("commodityId",e)},onBlur:function(e){j.current.contains(e.target)||u(!1)}})]})})};CX.defaultProps={value:void 0};var yX=CX,PX=function(e){var t=e.disabled;return Object(y.jsx)(j.b,{to:"yieldV1/create",className:t?"pointer-events-none":"",children:Object(y.jsxs)(m.Button,{type:"primary",size:"md",style:{paddingRight:"40px",paddingLeft:"40px"},disabled:t,children:[Object(y.jsx)("span",{className:"text-2xl",style:{marginRight:"7.75px"},children:"+"}),"Add Yield"]})})};PX.defaultProps={disabled:!1};var AX=PX,SX=function(e){var t=e.disabled,n=e.cropItems,a=e.selectedCommodity,r=e.onSelectCommodity;return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)("div",{className:"flex flex-row justify-between",style:{marginBottom:"28px",marginTop:"31px"},children:[Object(y.jsxs)("div",{className:"flex flex-row items-center flex-1",children:[Object(y.jsx)("span",{className:"mr-2 text-2xl",style:{marginRight:"26.87px"},children:"Commodity Yield"}),!t&&Object(y.jsx)(yX,{cropzones:n,value:a,onChange:r})]}),Object(y.jsx)(AX,{disabled:t})]})})};SX.defaultProps={disabled:!1,selectedCommodity:void 0,onSelectCommodity:function(){}};var TX,NX=SX,EX=[{field:"entryName",title:"Entry Name",sortable:!0},{field:"totalYield",title:"Total Yield",sortable:!0},{field:"salePrice",title:"Sale Price",sortable:!0},{field:"grossRevenue",title:"Gross Revenue",sortable:!0},{field:"totalArea",title:"Total Area",sortable:!0},{field:"grossRevenuePerAcre",title:"Gross Rev / ac",sortable:!0},{field:"source",title:"Source",sortable:!0},{field:"menu",title:"",sortable:!1}],wX=["title","titleId"];function _X(){return _X=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},_X.apply(this,arguments)}function RX(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function IX(e,t){var n=e.title,r=e.titleId,c=RX(e,wX);return a.createElement("svg",_X({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,TX||(TX=a.createElement("g",{id:"edit"},a.createElement("path",{id:"icon/image/edit_24px",fillRule:"evenodd",clipRule:"evenodd",d:"M17.659 3C17.409 3 17.149 3.1 16.959 3.29L15.129 5.12L18.879 8.87L20.709 7.04C21.099 6.65 21.099 6.02 20.709 5.63L18.369 3.29C18.169 3.09 17.919 3 17.659 3ZM14.059 9.02L14.979 9.94L5.91902 19H4.99902V18.08L14.059 9.02ZM2.99902 17.2514L14.059 6.19141L17.809 9.94141L6.74902 21.0014H2.99902V17.2514Z",fill:"#696F88"}))))}var DX,kX=a.forwardRef(IX),LX=(n.p,["title","titleId"]);function FX(){return FX=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},FX.apply(this,arguments)}function MX(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function VX(e,t){var n=e.title,r=e.titleId,c=MX(e,LX);return a.createElement("svg",FX({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,DX||(DX=a.createElement("g",{id:"delete"},a.createElement("path",{id:"icon/action/delete_24px",fillRule:"evenodd",clipRule:"evenodd",d:"M14.5 3H9.5L8.5 4H5V6H19V4H15.5L14.5 3ZM16 9V19H8V9H16ZM6 7H18V19C18 20.1 17.1 21 16 21H8C6.9 21 6 20.1 6 19V7Z",fill:"#696F88"}))))}var BX=a.forwardRef(VX),UX=(n.p,function(e){var t=e.yieldEntry,n=Object(a.useState)({}),r=Object(b.a)(n,2),c=r[0],i=r[1];return Object(a.useEffect)((function(){var e=t.cropZones.map((function(e){return e})),n=Object(ne.mapValues)(Object(ne.groupBy)(e,"farmName"),(function(e){return e.map((function(e){return Object(ne.omit)(e,"farmName")}))}));i(n)}),[]),Object(y.jsx)("div",{className:"overflow-scroll shadow rounded",style:{width:"212px",height:"200px",background:"white",position:"absolute",left:"-209px",top:"-50px",zIndex:1,padding:"0.625rem"},children:Object.keys(c).map((function(e){return Object(y.jsxs)("div",{children:[Object(y.jsx)("h2",{className:"text-left text-neutral-600 text-lg mb-1",children:e}),Object(y.jsx)("ul",{children:c[e].map((function(e){return Object(y.jsx)("li",{className:"pl-3 text-left text-neutral-1000 mb-4",children:e.fieldName},e.fieldName)}))})]},e)}))})}),zX=(wc.a.shape({entryName:wc.a.string,unit:wc.a.string,id:wc.a.string,totalYield:wc.a.number,avgYieldPerAcre:wc.a.number,salePrice:wc.a.number,grossRevenue:wc.a.number,totalArea:wc.a.number,grossRevenuePerAcre:wc.a.number,commodityId:wc.a.string,cropZones:wc.a.arrayOf(wc.a.shape({fieldName:wc.a.string}))}),function(e){var t=e.yieldEntry,n=e.handleDeleteClick,r=Object(p.h)(),c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=function(){var e,n,a=null===t||void 0===t||null===(e=t.cropZones)||void 0===e?void 0:e.map((function(e){return e.fieldName}));return null!==(n=a)&&void 0!==n&&n.length?1===(a=Object(v.a)(new Set(a))).length?a[0]:"".concat(a[0]," + ").concat(a.length-1," more"):"--"},d=function(e){l().includes("+")&&s("CLICK"===e)};return Object(y.jsx)(y.Fragment,{children:Object(y.jsxs)(m.Table.Row,{children:[Object(y.jsx)(m.Table.Cell,{children:null!==t&&void 0!==t&&t.entryName?"".concat(null===t||void 0===t?void 0:t.entryName):"--"}),Object(y.jsx)(m.Table.Cell,{children:null!=(null===t||void 0===t?void 0:t.totalYield)?"".concat(null===t||void 0===t?void 0:t.totalYield.toLocaleString("en")," ").concat(dX(null===t||void 0===t?void 0:t.unit)):"--"}),Object(y.jsx)(m.Table.Cell,{children:null!=(null===t||void 0===t?void 0:t.salePrice)?"$".concat(null===t||void 0===t?void 0:t.salePrice.toLocaleString("en")," / ").concat(dX(null===t||void 0===t?void 0:t.unit)):"--"}),Object(y.jsx)(m.Table.Cell,{children:null!=(null===t||void 0===t?void 0:t.grossRevenue)?"$".concat(null===t||void 0===t?void 0:t.grossRevenue.toLocaleString("en")):"--"}),Object(y.jsx)(m.Table.Cell,{children:null!=(null===t||void 0===t?void 0:t.totalArea)?"".concat(null===t||void 0===t?void 0:t.totalArea.toLocaleString("en")," ac"):"--"}),Object(y.jsx)(m.Table.Cell,{children:null!=(null===t||void 0===t?void 0:t.grossRevenuePerAcre)?"$".concat(null===t||void 0===t?void 0:t.grossRevenuePerAcre.toLocaleString("en")):"--"}),Object(y.jsx)(m.Table.Cell,{style:{position:"relative"},children:Object(y.jsx)(pu,{onClick:function(){return d("CLICK")},onBlur:function(){return d("BLUR")},children:Object(y.jsxs)("span",{className:"".concat(o?"text-cucumber-green-700":""),style:o?{borderBottom:"1px solid #14803C"}:{},children:[o&&Object(y.jsx)(UX,{yieldEntry:t}),l()]})})}),Object(y.jsxs)(m.Table.Cell,{children:[Object(y.jsx)(kX,{className:"mr-14px cursor-pointer",onClick:function(){r.push("".concat(Cc.yield,"/").concat(null===t||void 0===t?void 0:t.id,"/edit"))}}),Object(y.jsx)(BX,{className:"mr-14px cursor-pointer",onClick:function(){return n(null===t||void 0===t?void 0:t.id)}})]})]})})}),ZX=(n(1680),function(e){var t=e.items,n=e.sortField,a=e.sortDir,r=e.handleSort,c=e.handleDeleteClick,i=e.handleCloseDeleteModal,o=e.setDeleteYieldEntryId;return Object(y.jsx)(ol,{listType:"Yield Entries",routePath:Cc.yield,items:t,tableColumns:EX,onSort:r,sortBy:n,sortDir:a,isEmpty:t&&!t.length,emptyState:Object(y.jsx)("div",{className:"pb-8",children:Object(y.jsx)(jw,{overlayIcon:BV,message:"We are unable to find any yield data for this commodity.",button:Object(y.jsx)(AX,{})})}),children:function(e){return e.rows.map((function(e){return Object(y.jsx)(zX,{yieldEntry:e,handleDeleteClick:c,handleCloseDeleteModal:i,setDeleteYieldEntryId:o},null===e||void 0===e?void 0:e.id)}))}})}),YX={id:"",entryName:"",unit:"",avgYieldPerAcre:0,salePrice:0,commodityId:"",cropZoneIds:[],orgId:""},HX=function(e){var t=e.open,n=e.close,a=e.yieldEntryId,r=e.handleDeleteConfirmation,c=e.title,i=e.confirmLabel,o=e.isSaving,s=function(){n()};return Object(y.jsx)(ao,{open:t,title:c,close:s,cancelLabel:"Cancel",confirmLabel:i,onCancel:function(){return s()},type:"error",onConfirm:function(){return r(a)},isSaving:o,children:Object(y.jsx)("div",{testId:"yield-entry-deleteModal",className:"pr-6",children:"Are you sure you want to delete this yield data? All of the data associated with this entry will be lost."})})};HX.defaultProps={yieldEntryId:"",handleDeleteConfirmation:function(){},isSaving:!1,title:"",confirmLabel:""};var GX=Object(p.l)(HX),WX=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(0),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)("entryName"),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)("asc"),f=Object(b.a)(p,2),O=f[0],h=f[1],x=Object(a.useState)(new Set("")),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(null),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)(),w=Object(b.a)(E,2),_=w[0],R=w[1],I=Object(a.useState)(!1),D=Object(b.a)(I,2),k=D[0],L=D[1],F=Object(a.useContext)(ac),M=Object(b.a)(F,1)[0],V=M.loadingOrg,B=M.isGlobalCropSeasonLoading,U=Object(a.useRef)(null),z=nX(),Z=z.yieldEntries,H=z.yieldEntriesCount,W=z.isLoadingYieldEntry,q=z.loadYieldEntries,J=z.isDeleteLoading,K=z.deleteYield,Q=Object(a.useState)(Z),X=Object(b.a)(Q,2),$=X[0],ee=X[1],te=Object(a.useState)(H),ne=Object(b.a)(te,2),ae=ne[0],re=ne[1],ce=dd().cropSeasons,ie=function(){var e=Object(Y.a)(G.a.mark((function e(t){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,K(t);case 2:if(L(!1),(ae-1)%wo!==0){e.next=6;break}return s(o-1),e.abrupt("return");case 6:ee((function(e){return e.filter((function(e){return e.id!==t}))})),re(ae-1);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),oe=function(){return new Set(JSON.parse(localStorage.getItem("selectedCropSeasons")))};Object(a.useEffect)((function(){P(oe())}),[]),Object(a.useEffect)((function(){ee(Z),re(H)}),[Z,H]),Object(a.useEffect)((function(){if(T){var e=$P();e.length&&q({seasonIds:e,commodityId:T.id,fieldToOrder:u,orderingType:O,page:o}),U.current=T}else U.current=T}),[T,ce,u,O,o]);var se=function(){P(oe())},le=Object(a.useMemo)((function(){var e;return Object(v.a)(new Set(null!==(e=null===ce||void 0===ce?void 0:ce.filter((function(e){return C.has(null===e||void 0===e?void 0:e.id)})).map((function(e){return e.crops})).flat().map((function(e){return"".concat(null===e||void 0===e?void 0:e.id,":").concat(null===e||void 0===e?void 0:e.name)})))&&void 0!==e?e:[])).map((function(e){return e.split(":")})).map((function(e){return{id:e[0],name:e[1]}})).filter((function(e){return"undefined"!==e.id}))}),[ce,C]),de=$.length?Object(y.jsx)("div",{className:"mr-20px",children:Ho(ae,o,s)}):null;return Object(a.useEffect)((function(){le.length&&!C.has(ym)?r(!1):r(!0)}),[le]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(lo,{onOrganizationSelect:se,hideCropSeasonDropdown:!1,onCropSeasonSelect:se,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Dashboard",isLast:!0})}),V||B?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Zi.e,{initialValues:YX,children:Object(y.jsxs)("div",{className:"flex flex-col font-body","data-testid":"yield-dashboard",children:[Object(y.jsx)(NX,{disabled:n,cropItems:le,selectedCommodity:T,onSelectCommodity:N}),n?Object(y.jsx)(hX,{}):Object(y.jsx)(OX,{selectedCommodity:U,displayedYieldEntries:$})]})}),!n&&le.length?Object(y.jsx)("div",{className:"bg-white shadow-documentation-card rounded-lg mt-40px py-9px px-10px","data-testid":"yield-table",children:W?Object(y.jsx)("div",{className:"my-40px",children:Object(y.jsx)(m.Spinner,{})}):Object(y.jsxs)(y.Fragment,{children:[de,Object(y.jsx)(ZX,{items:$,sortField:u,sortDir:O,handleSort:function(e,t){j(e),h(t),s(0)},handleDeleteClick:function(e){R(e),L(!0)},setDeleteYieldEntryId:R}),de]})}):Object(y.jsx)("div",{})]}),Object(y.jsx)(GX,{open:k,yieldEntryId:_,close:function(){L(!1)},handleDeleteConfirmation:ie,title:"Delete Yield Data?",confirmLabel:"Delete",isSaving:J})]})},qX=[{caption:"Select Properties"},{caption:"Enter Yield Info"}],JX=function(e){var t=e.property;return Object(y.jsxs)("div",{className:"p-3 first:border-t-2 last:border-b-2 border-l-2 border-r-2","data-testid":"yield-selected-properties-info",children:[Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsx)("span",{className:"font-bold text-sm",children:t.fieldName}),Object(y.jsxs)("span",{className:"font-bold text-sm",children:[Object(y.jsx)(yf,{roundedTo:2,children:t.reportedArea||t.boundaryArea})," ","ac"]})]}),Object(y.jsx)("div",{children:Object(y.jsx)("span",{className:"text-sm",children:t.name})}),Object(y.jsx)("div",{children:Object(y.jsx)("span",{className:"text-sm text-gray-600",children:t.crop.name})})]})},KX=function(e){var t=e.geoJSONCollection,n=e.zoom,r=e.setZoom,c=Object(a.useContext)($Q).state.cropZones,i=0===c.length?"ml-8 border-2":"ml-8 divide-y-2 overflow-auto h-512px";return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"w-2/4 flex h-560px","data-testid":"yield-map-view",children:Object(y.jsx)(mm,{geoJSONCollection:t,zoom:n,setZoom:r,customStyles:c.length>0,stretch:!0})}),Object(y.jsxs)("div",{className:"h-full w-1/4",children:[Object(y.jsxs)("div",{className:"flex flex-row justify-between pl-8 pb-3 font-semibold",children:[Object(y.jsx)("span",{children:"SELECTED PROPERTIES"}),Object(y.jsxs)("span",{children:[Hh(c)," ac"]})]}),Object(y.jsx)("div",{className:i,children:0===c.length?Object(y.jsx)(xf,{baseText:"Select the properties from the left that you would like to submit"}):c.map((function(e){return Object(y.jsx)(JX,{property:e.properties},e.properties.id)}))})]})]})};KX.defaultProps={geoJSONCollection:{type:"FeatureCollection",features:[]}};var QX=KX,XX=["cropZones"],$X=function(e){var t=e.cropZones,n=Object(te.a)(e,XX),a=t.map((function(e){var t;return null===e||void 0===e||null===(t=e.fields)||void 0===t?void 0:t.map((function(t){return t.cropzones.map((function(n){return n.cropSeasons.map((function(a){return{fieldName:t.name,farmName:e.name,cropZoneName:n.name,seasonId:a.id,cropZoneId:n.id,fieldId:t.id,farmId:e.id,acres:n.reportedArea||n.boundaryArea}}))}))}))})).flat(3);return Object(I.a)(Object(I.a)({},n),{},{cropZones:a,grossRevenue:+n.grossRevenue,grossRevenuePerAcre:+(n.grossRevenue/n.totalArea).toFixed(2),salePrice:n.salePrice?n.salePrice:0})},e$=function(e){var t=e.nextButtonDisabled,n=e.onNext,r=e.onBack,c=Object(Zi.h)(),i=c.values,o=c.setFieldValue,s=Object(p.h)(),l=Object(p.i)(),d=nX().saveYield,u="edit"===l.pathname.split("/").slice(-1)[0],b=function(){var e=null===i||void 0===i?void 0:i.entryName,t=/^\d{2}-\d{2}-\d{2} \d{1,}:\d{1,} (AM|PM)$/.test(e)?Object(I.a)(Object(I.a)({},i),{},{entryName:oX()}):i,n=$X(t);return d(n,u)},j=Object(a.useContext)($Q),f=j.state.step,v=j.goForward,O=j.goBack,h=j.setResponseToastMessage,x=function(){n(),v()},g=function(){r(),O()},C=function(){s.goBack()},P=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b();case 2:if(!e.sent){e.next=8;break}return h({type:"success",message:"Yield data saved.",isToastActive:!0}),o("avgYieldPerAcre",0),o("entryName",""),o("grossRevenue",0),o("salePrice","0"),o("totalYield","0"),g(),e.abrupt("return");case 8:h({type:"error",message:"Yield didn't save. Please try later.",isToastActive:!0});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),A=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b();case 2:if(!e.sent){e.next=6;break}return s.goBack(),e.abrupt("return");case 6:h({type:"error",message:"Yield didn't save. Please try later.",isToastActive:!0});case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return function(){switch(f){case 1:return Object(y.jsxs)("div",{className:"flex flex-row border-t border-neutral-20 py-6 justify-end space-x-4","data-testid":"yield-properties-footer",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:C,children:"Cancel"}),Object(y.jsx)(m.Button,{type:"primary",onClick:x,disabled:t,children:"Next"})]});case 2:return Object(y.jsxs)("div",{className:"flex flex-row border-t border-neutral-20 bg-white justify-between py-6","data-testid":"yield-information-entry-footer",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:g,icon:Object(y.jsx)(ui.a,{fixedWidth:!0,size:"1x",icon:di.e}),children:"Back"}),Object(y.jsxs)("div",{className:"flex flex-row gap-6",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:C,children:"Cancel"}),!u&&Object(y.jsx)(m.Button,{type:"primary",ghost:!0,onClick:P,disabled:t,children:"Save & Add Another"}),Object(y.jsx)(m.Button,{type:"primary",onClick:A,disabled:t,children:"Save"})]})]});default:return null}}()};e$.defaultProps={nextButtonDisabled:!0,onNext:function(){},onBack:function(){},onNextValidation:function(){return!0}};var t$=e$,n$=function(e,t){return null===e||void 0===e?void 0:e.flatMap((function(e){var n,a;return null===t||void 0===t||null===(n=t.find((function(t){return(null===t||void 0===t?void 0:t.id)===e})))||void 0===n||null===(a=n.crops)||void 0===a?void 0:a.flatMap((function(e){return[{key:e.id,value:null===e||void 0===e?void 0:e.name}]}))}))},a$=function(e){var t=e.loading,n=e.zoom,r=e.setZoom,c=e.propertyLandingPageData,i=e.fieldsAndAreasGeoJSONCollection,o=e.setGeoJSONCollectionFeatures,s=e.fieldsLoading,l=e.filterFeatureCollectionByParentId,d=e.selectedCropSeasons,u=Object(a.useState)([]),j=Object(b.a)(u,2),p=j[0],f=j[1],v=Object(Zi.h)(),O=v.values,h=v.setFieldValue,x=Object(a.useState)(O.cropZones.map((function(e){return e.cropZoneId}))),g=Object(b.a)(x,2),C=g[0],P=g[1],A=dd(),S=A.cropSeasons,T=A.loaded,N=Object(a.useContext)($Q),E=N.state,w=E.cropZones,_=E.selectedCommodity,R=N.updateSelectedCommodity,I=N.updateCropZones,D=Object(a.useContext)(ac),k=Object(b.a)(D,2),L=k[0].selectedYieldCommodity,F=k[1],M=function(){var e=n$(d,S);return e.some((function(e){return!!e}))?e.filter((function(e){return e})):[{key:"",value:""}]};n$(d,S),Object(a.useEffect)((function(){if(""===L.id){var e=M();R({id:e[0].key,name:e[0].value}),F({type:"SELECTED_YIELD_COMMODITY",payload:{id:e[0].key,name:e[0].value}})}}),[S]);return Object(a.useEffect)((function(){if(c.properties){var e=Mh(c.properties,d);f(e)}}),[c.properties]),Object(a.useEffect)((function(){if(w.length){var e=w.map((function(e){return e.properties.id}));P(e)}}),[w]),!T||s||t?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{className:"px-8 bg-white",children:[Object(y.jsxs)("div",{className:"flex flex-row w-full mb-12 h-560px",children:[Object(y.jsxs)("div",{className:"w-1/4 pr-8",children:[Object(y.jsx)(m.Select,{label:"Select Commodity",items:M(),value:null===L||void 0===L?void 0:L.id,onChange:function(e){var t;t=e,R({id:JSON.parse(t.target.value).key,name:JSON.parse(t.target.value).value}),F({type:"SELECTED_YIELD_COMMODITY",payload:{id:JSON.parse(t.target.value).key,name:JSON.parse(t.target.value).value}})}}),Object(y.jsxs)("div",{className:"mt-6",children:[Object(y.jsx)("div",{children:Object(y.jsx)("h1",{className:"font-semibold mb-2",children:"PROPERTIES"})}),Object(y.jsx)(m.Search,{id:"propertySelect",name:"properties",items:[],onSelect:function(){},placeholder:"Search"}),Object(y.jsx)("div",{className:"pt-2 overflow-auto h-440px",children:Object(y.jsx)(Zx,{data:p,cropZonesChecked:C,setCropZonesChecked:P,onChange:function(e){if(i.features&&e.length!==w.length){o(l(i,void 0,e.map((function(e){return{id:e}}))));var t=e.reduce((function(e,t){var n=i.features.find((function(e){return e.properties.id===t})),a=i.features.find((function(e){return e.properties.id===n.properties.$parentFieldId})).properties;return n.properties.fieldName=a.name,e.push(n),e}),[]);I(t),h("cropZones",t),h("totalAcres",Hh(t))}}})})]})]}),Object(y.jsx)(QX,{properties:c.properties,geoJSONCollection:i,zoom:n,setZoom:r})]}),Object(y.jsx)(t$,{nextButtonDisabled:!w.length||""===_.id,onBack:function(){}})]})},r$=function(){var e=Object(a.useContext)($Q).state.cropZones,t=Object(a.useContext)(ac),n=Object(b.a)(t,1)[0].selectedYieldCommodity;return Object(y.jsxs)("div",{className:"flex py-4 px-8",children:[Object(y.jsxs)("div",{className:"w-1/5","data-testid":"yield-crop-name",children:[Object(y.jsx)(Fl,{header:"Crop",className:"w-1/3",text:"text-lg"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:(null===n||void 0===n?void 0:n.name)||"--"})]}),Object(y.jsxs)("div",{className:"w-1/5","data-testid":"yield-total-acres",children:[Object(y.jsx)(Fl,{header:"Acres",className:"w-1/3"}),Object(y.jsx)("span",{className:"text-2xl w-1/3",children:Hh(e)})]})]})},c$=function(e){var t="string"===typeof e?e:"";return isNaN(t)?parseFloat(t.replace(/[$,]/g,"")):parseFloat(t)},i$=function(){var e=Object(Zi.h)(),t=e.values,n=e.setFieldValue,r=e.setFieldTouched;return Object(a.useEffect)((function(){var e;null!==(e=t.entryName)&&void 0!==e&&e.length||n("entryName",oX())}),[]),Object(y.jsxs)("div",{className:"py-4 px-8 mb-8",children:[Object(y.jsx)("div",{"data-testid":"yield-info-title",className:"text-2xl font-semibold py-2 mb-10",children:"Yield Info"}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{className:"w-1/4 mr-8",children:Object(y.jsx)(Qi,{control:m.Input,name:"entryName",id:"entryName",label:"Entry Name*","data-testid":"yield-entry-name",value:null===t||void 0===t?void 0:t.entryName,onChange:function(e){n("entryName",e.target.value)}})}),Object(y.jsx)("div",{className:"w-1/4 mr-8",children:Object(y.jsx)(Qi,{control:m.Select,name:"unit",label:"Units*","data-testid":"yield-units",items:sX,placeHolder:""})}),Object(y.jsxs)("div",{className:"w-1/4 mr-8",children:[Object(y.jsx)(Qi,{control:m.Input,id:"totalYield",name:"totalYield",label:"Total Yield*",imask:bX,"data-testid":"total-yield",onBlur:function(e){r("totalYield"),n("totalYield",c$(e.target.value)),c$(e.target.value)?n("avgYieldPerAcre",parseFloat(c$(e.target.value)/(null===t||void 0===t?void 0:t.totalAcres.split(" ")[0])).toFixed(2)):n("avgYieldPerAcre",c$(e.target.value))}}),Object(y.jsx)("span",{className:"float-right px-2 -my-7 p-1px relative text-neutral-600 text-sm",children:lX(t.unit)})]}),Object(y.jsxs)("div",{className:"w-1/4 mr-8",children:[Object(y.jsx)(Qi,{control:m.Input,id:"avgYieldPerAcre",name:"avgYieldPerAcre",label:"Avg Yield / ac*","data-testid":"avg-yield-per-acre",imask:bX,onBlur:function(e){r("avgYieldPerAcre"),n("avgYieldPerAcre",c$(e.target.value)),c$(e.target.value)?n("totalYield",parseFloat(c$(e.target.value)*(null===t||void 0===t?void 0:t.totalAcres.split(" ")[0])).toFixed(2)):n("totalYield",c$(e.target.value))}}),Object(y.jsxs)("span",{className:"float-right px-2 -my-7 p-1px relative text-neutral-600 text-sm",children:[lX(t.unit),"/ac"]})]})]})]})},o$=function(){return Object(y.jsx)("div",{className:"w-1/4 mr-8",children:" "})},s$=function(){var e=Object(Zi.h)(),t=e.values,n=e.setFieldValue,r=e.setFieldTouched;return Object(a.useEffect)((function(){if(c$(t.grossRevenue)&&t.totalYield){var e=c$(t.grossRevenue)/t.totalYield;n("salePrice",parseFloat(e.toFixed(2))),n("grossRevenue",parseFloat(e.toFixed(2))*t.totalYield)}}),[t.totalYield]),Object(y.jsxs)("div",{className:"py-4 px-8",children:[Object(y.jsx)("div",{"data-testid":"yield-sale-info-title",className:"text-2xl font-semibold py-2 mb-10",children:"Sale Info"}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsxs)("div",{className:"w-1/4 mr-8",children:[Object(y.jsx)(Qi,{control:m.Input,label:"Sale Price",name:"salePrice",imask:uX,onBlur:function(e){r("salePrice"),n("salePrice",c$(e.target.value||"0")),c$(e.target.value)?n("grossRevenue",parseFloat(c$(e.target.value)*(null===t||void 0===t?void 0:t.totalYield)).toFixed(2)):n("grossRevenue",c$(e.target.value))}}),Object(y.jsxs)("span",{className:"float-right px-2 -my-7 p-1px relative text-neutral-600 text-sm",children:["per ",lX(t.unit)]})]}),Object(y.jsx)("div",{className:"w-1/4 mr-8",children:Object(y.jsx)(Qi,{control:m.Input,name:"grossRevenue",label:"Gross Revenue",imask:uX,onBlur:function(e){r("grossRevenue"),n("grossRevenue",c$(e.target.value)),c$(e.target.value)?n("salePrice",parseFloat(c$(e.target.value)/(null===t||void 0===t?void 0:t.totalYield)).toFixed(2)):n("salePrice",c$(e.target.value))}})}),Object(y.jsx)(o$,{}),Object(y.jsx)(o$,{})]})]})},l$=function(){var e=Object(Zi.h)().values,t=""!==e.entryName&&""!==e.unit&&e.totalYield>0&&e.avgYieldPerAcre>0;return Object(y.jsxs)("div",{className:"px-8 bg-white","data-testid":"yield-information-tab",children:[Object(y.jsx)(r$,{}),Object(y.jsx)("div",{className:"w-full border-b py-2"}),Object(y.jsx)(i$,{}),Object(y.jsx)(s$,{}),Object(y.jsx)("div",{className:"w-full border-b mt-32 py-2"}),Object(y.jsx)(t$,{nextButtonDisabled:!t})]})},d$=function(e){var t=e.loading,n=e.zoom,r=e.setZoom,c=e.propertyLandingPageData,i=e.fieldsAndAreasGeoJSONCollection,o=e.setGeoJSONCollectionFeatures,s=e.fieldsLoading,l=e.filterFeatureCollectionByParentId,d=e.selectedCropSeasons,u=Object(a.useContext)($Q).state,b=u.step,j=u.cropZones,p=Object(Zi.h)().setFieldValue;return Object(a.useEffect)((function(){2===b&&function(){var e=j.reduce((function(e,t){var n=c.properties.find((function(e){return e.id===t.properties.propertyId})),a=n.fields.find((function(e){return e.id===t.properties.$parentFieldId})),r=a.cropzones.find((function(e){return e.id===t.properties.id})),i=e.findIndex((function(e){return e.id===n.id}));if(i>=0){var o=e[i].fields.findIndex((function(e){return e.id===a.id}));o>=0?e[i].fields[o].cropzones.push(r):e[i].fields.push({id:a.id,name:a.name,cropzones:[r]})}else e.push({id:n.id,name:n.name,fields:[{id:a.id,name:a.name,cropzones:[r]}]});return e}),[]);p("cropZones",e)}()}),[b]),Object(y.jsx)(y.Fragment,{children:1===b?Object(y.jsx)(a$,{loading:t,zoom:n,setZoom:r,propertyLandingPageData:c,fieldsAndAreasGeoJSONCollection:i,setGeoJSONCollectionFeatures:o,fieldsLoading:s,filterFeatureCollectionByParentId:l,selectedCropSeasons:d}):Object(y.jsx)(l$,{})})},u$=function(e,t){return 1===t&&e.cropZones.length>0},b$={unit:"",entryName:"",totalYield:0,avgYieldPerAcre:0,salePrice:0,grossRevenue:0,cropZones:[],totalAcres:0},j$=window.screen.width,p$=function(){var e=$P(),t=rv({fetchType:gm}),n=t.loading,r=t.zoom,c=t.setZoom,i=t.dataSorted,o=t.fieldsAndAreasGeoJSONCollection,s=t.setGeoJSONCollectionFeatures,l=t.fieldsLoading,d=t.filterFeatureCollectionByParentId,u=t.reloadData,j=Object(a.useContext)(ac),p=Object(b.a)(j,2)[1],f=Object(a.useContext)($Q).state.isLoading;Object(a.useEffect)((function(){return u({seasonIds:$P()}),function(){p({type:"SELECTED_YIELD_COMMODITY",payload:{id:"",name:""}})}}),[]);var v=function(){u({seasonIds:$P()})},O=Object(a.useContext)($Q),h=O.state,x=h.step,g=h.showToast,C=h.typeToast,P=h.messageToast,A=O.setShowToast,S=O.goBack;return Object(y.jsx)(Zi.e,{initialValues:b$,children:function(t){var a=t.values;return Object(y.jsxs)("div",{children:[Object(y.jsx)(lo,{onOrganizationSelect:v,hideCropSeasonDropdown:!1,onCropSeasonSelect:v,disabled:!0,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Add Yield",isLast:!0})}),n||f?Object(y.jsx)("div",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:Object(y.jsx)(m.Spinner,{})}):Object(y.jsxs)("div",{className:"z-50 h-full bottom-0 top-18","data-testid":"create-yield-progressbar",children:[x>0&&x<4&&Object(y.jsx)("div",{className:"mx-64",children:Object(y.jsx)(Ph,{stepArray:qX,currentStep:x,canGoNext:u$(a,x),className:"pb-5 pt-2",gotoStep:S,style:{margin:"0 auto",width:"".concat(48*j$/1792,"rem")}})}),Object(y.jsx)("div",{className:"bottom-0 w-full h-full",children:Object(y.jsx)(d$,{loading:n,zoom:r,setZoom:c,propertyLandingPageData:i,fieldsAndAreasGeoJSONCollection:o,setGeoJSONCollectionFeatures:s,fieldsLoading:l,filterFeatureCollectionByParentId:d,selectedCropSeasons:e})})]}),g&&Object(y.jsx)(Qc,{type:C,title:P,open:g,timeout:2500,onClose:function(){return A(!1)},isBold:!0,children:Object(y.jsx)(y.Fragment,{})})]})}})},f$=window.screen.width,m$=function(){var e=Object(p.j)().id,t=$P(),n=nX(),r=n.isLoadingYieldEntry,c=n.yieldEntry,i=n.loadYieldItem,o=rv({fetchType:gm}),s=o.loading,l=o.zoom,d=o.setZoom,u=o.dataSorted,b=o.fieldsAndAreasGeoJSONCollection,j=o.setGeoJSONCollectionFeatures,f=o.fieldsLoading,v=o.filterFeatureCollectionByParentId,O=o.reloadData;Object(a.useEffect)((function(){i(e)}),[]),Object(a.useEffect)((function(){localStorage.setItem("selectedCropSeasons",JSON.stringify($P())),O({seasonIds:$P()})}),[]);var h=function(){O({seasonIds:$P()})},x=Object(a.useContext)($Q),g=x.state.step,C=x.goBack;return Object(y.jsx)(y.Fragment,{children:r||!c?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(Zi.e,{initialValues:Object(I.a)(Object(I.a)({},b$),c),enableReinitialize:!0,children:function(e){var n=e.values;return Object(y.jsxs)("div",{children:[Object(y.jsx)(lo,{onOrganizationSelect:h,hideCropSeasonDropdown:!1,onCropSeasonSelect:h,disabled:!0,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Edit Yield",isLast:!0})}),s?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{className:"z-50 h-full bottom-0 top-18","data-testid":"create-yield-progressbar",children:[g>0&&g<4&&Object(y.jsx)("div",{className:"mx-64",children:Object(y.jsx)(Ph,{stepArray:qX,currentStep:g,canGoNext:u$(n,g),gotoStep:C,className:"pb-5 pt-2",style:{margin:"0 auto",width:"".concat(48*f$/1792,"rem")}})}),Object(y.jsx)("div",{className:"bottom-0 h-full",children:Object(y.jsx)(d$,{loading:s,zoom:l,setZoom:d,propertyLandingPageData:u,fieldsAndAreasGeoJSONCollection:b,setGeoJSONCollectionFeatures:j,fieldsLoading:f,filterFeatureCollectionByParentId:v,selectedCropSeasons:t})})]})]})}})})},v$=function(){var e=Object(p.j)().id;return Object(y.jsx)(tX,{children:e?Object(y.jsx)(m$,{}):Object(y.jsx)(p$,{})})},O$=[{id:"yield",key:"yield-v1",label:"Yield",path:Cc.yield,exact:!0,secure:!0,disabled:!1,component:WX,icon:ad,nav:"leftNav"},{id:"create-yield",key:"create-yield-v1",label:"",path:"".concat(Cc.yield,"/create"),exact:!0,secure:!0,disabled:!0,component:v$},{id:"edit-yield",key:"edit-yield-v1",label:"",path:"".concat(Cc.yield,"/:id/edit"),exact:!0,secure:!0,disabled:!0,component:v$}],h$="SET_SELECTED",x$="ATTACH_DETAILS_TO_ITEM",g$="SET_STORAGE_LOCATIONS",C$="SET_LOADING_STATUS",y$="SET_FETCHING_DETAILS_STATUS",P$="SET_SORTED",A$=function(e,t){switch(t.type){case g$:return Object(I.a)(Object(I.a)(Object(I.a)({},e),t.payload),{},{recentFetchIds:[]});case h$:return Object(I.a)(Object(I.a)({},e),{},{selectedId:t.payload});case x$:return Object(I.a)(Object(I.a)({},e),{},{data:e.data.map((function(e){return e.id===t.payload.id?t.payload:e})),recentFetchIds:[].concat(Object(v.a)(e.recentFetchIds),[t.payload.id])});case C$:return Object(I.a)(Object(I.a)({},e),{},{isLoading:t.payload});case y$:return Object(I.a)(Object(I.a)({},e),{},{isFetchingDetails:t.payload});case P$:return Object(I.a)(Object(I.a)({},e),{},{sortBy:t.payload.sortBy,sortDir:t.payload.sortDir});default:return e}},S$={sortBy:"name",sortDir:"asc"},T$=function(){var e=Object(a.useState)(!1),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),j=d[0],p=d[1],f=Object(a.useState)({isLoading:!1,isSuccess:!1,isError:!1}),m=Object(b.a)(f,2),v=m[0],O=m[1],h=Object(a.useContext)(ac),x=Object(b.a)(h,1)[0].organization,g=Object(a.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:S$,t=e.sortBy,n=e.sortDir;r(!0);var a=J.a.get("".concat(u.e,"/yield/storage-location/list?page=0&sortBy=").concat(t,"&sortDir=").concat(n,"&limit=0"),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:x.id}),Authorization:"Bearer ".concat(Ve())}});return a.then((function(e){return e.data})).catch(Ae.default).catch((function(e){return e.response})).finally((function(){return r(!1)}))}),[x]);return{fetchStorageLocations:g,fetchStorageDetails:Object(a.useCallback)((function(e){return s(!0),J.a.get("".concat(u.e,"/yield/storage-location/").concat(e),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:x.id}),Authorization:"Bearer ".concat(Ve())}}).then((function(e){return e.data})).catch(Ae.default).catch((function(e){return e.response})).finally((function(){return s(!1)}))}),[x]),createStorageLocation:Object(a.useCallback)((function(e){return p(!0),J.a.post("".concat(u.e,"/yield/storage-location"),e,{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:x.id}),Authorization:"Bearer ".concat(Ve())}}).then((function(e){var t=e.data;return null===t||void 0===t?void 0:t.id})).catch(Ae.default).catch((function(){return null})).finally((function(){return p(!1)}))}),[x]),updateStorageLocation:Object(a.useCallback)((function(e,t){return p(!0),J.a.put("".concat(u.e,"/yield/storage-location/").concat(e),t,{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:x.id}),Authorization:"Bearer ".concat(Ve())}}).then((function(e){var t=e.data;return null===t||void 0===t?void 0:t.id})).catch(Ae.default).catch((function(){return null})).finally((function(){return p(!1)}))}),[x]),deleteStorageLocation:Object(a.useCallback)((function(e){return O((function(e){return Object(I.a)(Object(I.a)({},e),{},{isLoading:!0})})),J.a.delete("".concat(u.e,"/yield/storage-location/").concat(e),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:x.id}),Authorization:"Bearer ".concat(Ve())}}).then((function(){O((function(e){return Object(I.a)(Object(I.a)({},e),{},{isSuccess:!0})}))})).catch(Ae.default).catch((function(e){return O((function(e){return Object(I.a)(Object(I.a)({},e),{},{isError:!0})})),e.response})).finally((function(){O((function(e){return Object(I.a)(Object(I.a)({},e),{},{isLoading:!1})}))}))}),[x]),loading:n,loadingDetails:o,saving:j,deleting:v,setLoading:r}},N$={data:[],page:1,selectedId:null,sortBy:"name",sortDir:"asc",isLoading:!0,isFetchingDetails:!0,recentFetchIds:[]},E$=Object(a.createContext)({}),w$=function(e){var t=e.children,n=e.initialValues,r=Object(I.a)(Object(I.a)({},N$),{},{selectedId:n.selectedId,sortBy:n.sortBy||N$.sortBy,sortDir:n.sortDir||N$.sortDir}),c=Object(a.useReducer)(A$,r),i=Object(b.a)(c,2),o=i[0],s=i[1],l=T$(),d=l.loading,u=l.loadingDetails,j=l.fetchStorageLocations,p=l.fetchStorageDetails,f=Object(a.useRef)(0),m=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,r=arguments;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.length>1&&void 0!==r[1]&&r[1],o.recentFetchIds.includes(t)&&!n){e.next=6;break}return e.next=4,p(t);case 4:a=e.sent,s({type:x$,payload:a});case 6:s({type:h$,payload:t});case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[p,o.recentFetchIds]),v=Object(a.useCallback)(function(){var e=Object(Y.a)(G.a.mark((function e(t){var n,a,c,i,l;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.skipCache,a=t.initSelected,f.current+=1,c=f.current,e.next=5,j({sortBy:r.sortBy,sortDir:r.sortDir});case 5:(i=e.sent)&&f.current===c&&(s({type:g$,payload:null!==(l=i.data)&&void 0!==l&&l.error?N$:i}),n&&a?m(a,!0):i.data[0]&&!o.selectedId&&m(i.data[0].id));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[j,r.sortBy,r.sortDir]);Object(a.useEffect)((function(){v({skipCache:n.skipCache,initSelected:n.selectedId})}),[v]),Object(a.useEffect)((function(){s({type:C$,payload:d}),s({type:y$,payload:u})}),[d,u]);var O=Object(a.useCallback)((function(){s({type:h$,payload:null})}),[]),h=Object(a.useCallback)((function(e){var t=e.sortBy,n=e.sortDir;s({type:P$,payload:{sortBy:t,sortDir:n}}),f.current+=1;var a=f.current;j({sortBy:t,sortDir:n}).then((function(e){f.current===a&&(s({type:g$,payload:e}),m(o.selectedId,!0))}))}),[j,o.selectedId,m]),x=Object(a.useMemo)((function(){return{state:o,dispatch:s,selectLocation:m,resetLocation:O,applySort:h,refetch:v}}),[o,s,m,O,h,v]);return Object(y.jsx)(E$.Provider,{value:x,children:t})};w$.defaultProps={children:null,initialValues:{sortBy:null,sortKey:null,selectedId:null,skipCache:!1}};var _$=w$,R$=function(e){var t=e.children,n=e.disabled,r=Object(a.useContext)(E$).resetLocation;return Object(y.jsx)(lo,{onOrganizationSelect:function(){r()},disabled:n,children:t})};R$.defaultProps={disabled:!1};var I$=R$,D$=(wc.a.shape({id:wc.a.string,name:wc.a.string,email:wc.a.string,phone:wc.a.string,company:wc.a.string,addressLineOne:wc.a.string,addressLineTwo:wc.a.string,city:wc.a.string,state:wc.a.string,zipCode:wc.a.string,notes:wc.a.string,shape:wc.a.string,diameter:wc.a.number,height:wc.a.number,coneHeight:wc.a.number,volume:wc.a.number,capacity:wc.a.number,coolingSystem:wc.a.string,fillingSystem:wc.a.string,unloadingSystem:wc.a.string,owner:wc.a.string,status:wc.a.string,yearBuilt:wc.a.string,quality:wc.a.string,propertyTaxId:wc.a.string,advancedNotes:wc.a.string,createdAt:wc.a.string,updatedAt:wc.a.string}),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if("number"!==typeof e)return"";var n=Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),a=n.format;return"".concat(a(e)," ").concat(t)});function k$(e,t,n,a){var r=(a-90)*Math.PI/180;return{x:e+n*Math.cos(r),y:t+n*Math.sin(r)}}function L$(e){var t=e.innerRadius,n=e.outerRadius,a=e.startAngle,r=e.endAngle,c=k$(100,100,n,r),i=k$(100,100,n,a),o=k$(100,100,t,r),s=k$(100,100,t,a),l=r-a<=180?"0":"1";return["M",c.x,c.y,"A",n,n,0,l,0,i.x,i.y,"L",s.x,s.y,"A",t,t,0,l,1,o.x,o.y,"Z"].join(" ")}var F$=function(e){var t=e.isLarge,n=e.value,a=Math.max(Math.min(n,99.99999),.01),r="#CF3537";0===n?r="rgb(195, 199, 207)":n<90?r="#19A04B":n<100&&(r="#F0C355");var c,i=[{percentage:a,color:r,key:"used"},{percentage:100-a,color:"rgb(195, 199, 207)",key:"free"}].map((function(e,n){var r=e.percentage,c=e.color,i=e.key,o=0===n?0:3.6*a,s=L$({startAngle:o,endAngle:o+3.6*r,innerRadius:t?50:60,outerRadius:90});return Object(y.jsx)("path",{d:s,fill:c},i)}));return c=t?n<-100||n>1e3?"text-sm":"text-lg":n<-100||n>1e3?"text-xs":"text-sm",Object(y.jsxs)("div",{className:"w-full h-full relative",children:[Object(y.jsx)("svg",{"data-value":n,viewBox:"0 0 200 200",className:"w-full h-full",children:i}),Object(y.jsx)("div",{className:"absolute left-0 top-0 right-0 bottom-0 flex items-center justify-center",children:Object(y.jsxs)("div",{className:c,children:[+n.toFixed(),"%"]})})]})};F$.defaultProps={isLarge:!1};var M$=F$,V$=(n(1681),function(e){var t=e.item,n=e.isSelected,a=e.onClick,r=D$(null===t||void 0===t?void 0:t.totalStoredLoad,"lb"===(null===t||void 0===t?void 0:t.totalStoredLoadUnit)?"lbs":"bu"),c=D$(null===t||void 0===t?void 0:t.capacity,"bu");c&&"lb"!==t.totalStoredLoadUnit&&(r+=" / ".concat(c));var i=null!==t&&void 0!==t&&t.totalStoredLoad?(null===t||void 0===t?void 0:t.totalStoredLoad)/(null===t||void 0===t?void 0:t.capacity)*100:0;return t.capacity||(i=0),Object(y.jsx)(m.Table.Row,{className:"cursor-pointer relative group cwfweb-storage-location-row\n      ".concat(n?"bg-blue-10 hover:bg-blue-30":"bg-white !hover:bg-neutral-10 !active:bg-neutral-10"),onClick:function(){return a(t.id)},children:Object(y.jsxs)(m.Table.Cell,{className:"min-h-88px",children:[n&&Object(y.jsx)("div",{"data-testid":"selected-indicator",className:"w-1 h-90/100 flex-shrink-0 rounded-r-md bg-blue-50 absolute left-0"}),Object(y.jsxs)("div",{className:"w-full text-left flex justify-between items-center",children:[Object(y.jsxs)("div",{className:"flex-1 mr-4",children:[Object(y.jsx)("h4",{className:"text-base storage-name mb-1 ".concat(n?"font-semibold":"font-normal"),children:t.name}),Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"text-neutral-60 text-xs font-normal leading-5 storage-usage-title",children:"Total Stored"}),Object(y.jsx)("p",{className:"storage-usage-value",children:"".concat(r)})]})]}),"lb"!==t.totalStoredLoadUnit&&null!==(null===t||void 0===t?void 0:t.capacity)&&(null===t||void 0===t?void 0:t.capacity)>0&&Object(y.jsx)("div",{className:"h-16 w-16",children:Object(y.jsx)(M$,{value:i})})]})]})})});V$.defaultProps={isSelected:!1};var B$=V$,U$=function(){var e=Object(a.useContext)(E$),t=e.state,n=t.data,r=t.isLoading,c=t.selectedId,i=e.selectLocation;return Object(y.jsx)("div",{"data-testid":"yield-storage-locations-list",className:"h-full bg-white overflow-y-auto",children:r?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(y.Fragment,{children:n.length?Object(y.jsx)(m.Table,{children:n.map((function(e){return Object(y.jsx)(B$,{item:e,isSelected:c===e.id,onClick:i},e.id)}))}):Object(y.jsx)("p",{className:"p-4 text-center",children:"No storage locations found."})})})},z$=function(e){var t=(e||"").replace(/([A-Z])/g," $1").trim();return t.charAt(0).toUpperCase()+t.slice(1)},Z$=function(e){var t=e.label,n=e.value,a=e.wrapperClassName,r=e.labelColWidth,c=e.valueColWidth;return Object(y.jsxs)("div",{"data-testid":"card-info",className:"flex w-full pb-2 mt-4 border-b-1 border-solid-400 ".concat(a),children:[Object(y.jsx)(m.Column,{width:r,children:Object(y.jsx)("span",{className:"text-neutral-60 opacity-60 text-sm font-normal leading-5 tracking-tight",children:t})}),Object(y.jsx)(m.Column,{width:c,children:Object(y.jsx)("div",{className:"text-sm font-normal leading-5 tracking-tight whitespace-pre-line ".concat(n?"text-neutral-1000":"text-neutral-40 opacity-50"),children:n||"None entered"})})]})};Z$.defaultProps={value:null,wrapperClassName:"justify-center",labelColWidth:"w-1/2",valueColWidth:"w-1/2"};var Y$=Z$,H$={Company:mE,People:vE},G$=function(){var e,t,n,r=Object(a.useContext)(E$).state,c=r.selectedId,i=r.data,o=(void 0===i?[]:i).find((function(e){return e.id===c}));return Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"w-1/2 pr-4",children:[Object(y.jsx)(Y$,{label:"Owner",value:(null===o||void 0===o||null===(e=o.owner)||void 0===e?void 0:e.name)&&Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("img",{className:"h-4",alt:"Field Icon",src:H$[null===o||void 0===o||null===(t=o.owner)||void 0===t?void 0:t.type]}),Object(y.jsx)("div",{className:"pl-2",children:null===o||void 0===o||null===(n=o.owner)||void 0===n?void 0:n.name})]})}),Object(y.jsx)(Y$,{label:"Year Built",value:null===o||void 0===o?void 0:o.yearBuilt}),Object(y.jsx)(Y$,{label:"Property Tax ID",value:null===o||void 0===o?void 0:o.propertyTaxId})]}),Object(y.jsxs)("div",{className:"w-1/2 pl-4",children:[Object(y.jsx)(Y$,{label:"Status",value:null===o||void 0===o?void 0:o.status}),Object(y.jsx)(Y$,{label:"Quality",value:null===o||void 0===o?void 0:o.quality})]})]})};function W$(e){var t=[];null!==e&&void 0!==e&&e.addressLineOne&&t.push(e.addressLineOne),null!==e&&void 0!==e&&e.addressLineTwo&&t.push(e.addressLineTwo);var n=Nl.find((function(t){return t.key===(null===e||void 0===e?void 0:e.state)})),a=[null===e||void 0===e?void 0:e.city,null!==e&&void 0!==e&&e.state||null!==e&&void 0!==e&&e.zipCode?[null===n||void 0===n?void 0:n.value,e.zipCode].filter(Boolean).join(" "):null].filter(Boolean).join(", ");return a&&t.push(a),t.join("\n")}var q$=function(){var e=Object(a.useContext)(E$).state,t=e.selectedId,n=e.data,r=(void 0===n?[]:n).find((function(e){return e.id===t}));return Object(y.jsxs)(qz,{className:"py-4 px-8",children:[Object(y.jsx)(Y$,{labelColWidth:"w-2/5",valueColWidth:"w-3/5",label:"Email Address",value:null===r||void 0===r?void 0:r.email}),Object(y.jsx)(Y$,{labelColWidth:"w-2/5",valueColWidth:"w-3/5",label:"Phone Number",value:null===r||void 0===r?void 0:r.phone}),Object(y.jsx)(Y$,{labelColWidth:"w-2/5",valueColWidth:"w-3/5",label:"Address",value:W$(r)})]})},J$=function(){var e=Object(a.useContext)(E$).state,t=e.selectedId,n=e.data,r=(void 0===n?[]:n).find((function(e){return e.id===t}));return null!==r&&void 0!==r&&r.capacity&&"lb"!==(null===r||void 0===r?void 0:r.totalStoredLoadUnit)?Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"w-1/2 pr-4",children:[Object(y.jsx)(Y$,{label:"Shape",value:null===r||void 0===r?void 0:r.shape}),Object(y.jsx)(Y$,{label:"Height",value:D$(null===r||void 0===r?void 0:r.height,"ft")}),Object(y.jsx)(Y$,{label:"Volume",value:D$(null===r||void 0===r?void 0:r.volume,"cu. ft")})]}),Object(y.jsxs)("div",{className:"w-1/2 pl-4",children:[Object(y.jsx)(Y$,{label:"Diameter",value:D$(null===r||void 0===r?void 0:r.diameter,"ft")}),Object(y.jsx)(Y$,{label:"Cone Height",value:D$(null===r||void 0===r?void 0:r.coneHeight,"ft")})]})]}):Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"w-1/2 pr-4",children:[Object(y.jsx)(Y$,{label:"Shape",value:null===r||void 0===r?void 0:r.shape}),Object(y.jsx)(Y$,{label:"Diameter",value:D$(null===r||void 0===r?void 0:r.diameter,"ft")}),Object(y.jsx)(Y$,{label:"Cone Height",value:D$(null===r||void 0===r?void 0:r.coneHeight,"ft")})]}),Object(y.jsxs)("div",{className:"w-1/2 pl-4",children:[Object(y.jsx)(Y$,{label:"Capacity",value:null!==r&&void 0!==r&&r.capacity?D$(null===r||void 0===r?void 0:r.capacity,"bu"):null}),Object(y.jsx)(Y$,{label:"Height",value:D$(null===r||void 0===r?void 0:r.height,"ft")}),Object(y.jsx)(Y$,{label:"Volume",value:D$(null===r||void 0===r?void 0:r.volume,"cu. ft")})]})]})},K$=function(){var e=Object(a.useContext)(E$).state,t=e.data,n=void 0===t?[]:t,r=e.selectedId,c=n.find((function(e){return e.id===r}));return null!==c&&void 0!==c&&c.capacity&&"lb"!==(null===c||void 0===c?void 0:c.totalStoredLoadUnit)?Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"w-1/2 pr-4",children:[Object(y.jsx)(Y$,{label:"Shape",value:null===c||void 0===c?void 0:c.shape}),Object(y.jsx)(Y$,{label:"Width",value:D$(null===c||void 0===c?void 0:c.width,"ft")}),Object(y.jsx)(Y$,{label:"Volume",value:D$(null===c||void 0===c?void 0:c.volume,"cu. ft")})]}),Object(y.jsxs)("div",{className:"w-1/2 pl-4",children:[Object(y.jsx)(Y$,{label:"Length",value:D$(null===c||void 0===c?void 0:c.length,"ft")}),Object(y.jsx)(Y$,{label:"Height",value:D$(null===c||void 0===c?void 0:c.height,"ft")})]})]}):Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"w-1/2 pr-4",children:[Object(y.jsx)(Y$,{label:"Shape",value:null===c||void 0===c?void 0:c.shape}),Object(y.jsx)(Y$,{label:"Length",value:D$(null===c||void 0===c?void 0:c.length,"ft")}),Object(y.jsx)(Y$,{label:"Height",value:D$(null===c||void 0===c?void 0:c.height,"ft")})]}),Object(y.jsxs)("div",{className:"w-1/2 pl-4",children:[Object(y.jsx)(Y$,{label:"Capacity",value:null!==c&&void 0!==c&&c.capacity?D$(null===c||void 0===c?void 0:c.capacity,"bu"):null}),Object(y.jsx)(Y$,{label:"Width",value:D$(null===c||void 0===c?void 0:c.width,"ft")}),Object(y.jsx)(Y$,{label:"Volume",value:D$(null===c||void 0===c?void 0:c.volume,"cu. ft")})]})]})},Q$=function(){var e=Object(a.useContext)(E$).state,t=e.data,n=void 0===t?[]:t,r=e.selectedId,c=n.find((function(e){return e.id===r}));return Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"w-1/2 pr-4",children:Object(y.jsx)(Y$,{label:"Shape"})}),(!(null!==c&&void 0!==c&&c.capacity)||"lb"===(null===c||void 0===c?void 0:c.totalStoredLoadUnit))&&Object(y.jsx)("div",{className:"w-1/2 pl-4",children:Object(y.jsx)(Y$,{label:"Capacity",value:null!==c&&void 0!==c&&c.capacity?D$(null===c||void 0===c?void 0:c.capacity,"bu"):null})})]})},X$={Round:Object(y.jsx)(J$,{}),Flat:Object(y.jsx)(K$,{})},$$=function(){var e=Object(a.useContext)(E$).state,t=e.selectedId,n=e.data,r=(void 0===n?[]:n).find((function(e){return e.id===t}));return null!==r&&void 0!==r&&r.shape?Object(y.jsx)(y.Fragment,{children:X$[null===r||void 0===r?void 0:r.shape]||Object(y.jsx)(Q$,{})}):Object(y.jsx)(Q$,{})},e0=function(){var e,t,n=Object(a.useContext)(E$).state,r=n.selectedId,c=n.data,i=(void 0===c?[]:c).find((function(e){return e.id===r})),o=null===i||void 0===i||null===(e=i.notes)||void 0===e||null===(t=e.trim())||void 0===t?void 0:t.length;return Object(y.jsx)("p",{className:"font-normal leading-5 tracking-tight whitespace-pre-line ".concat(o?"":"text-neutral-40 opacity-50"),children:o?null===i||void 0===i?void 0:i.notes:"None Entered"})},t0=function(){var e=Object(a.useContext)(E$).state,t=e.selectedId,n=e.data,r=(void 0===n?[]:n).find((function(e){return e.id===t}));return Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"w-1/2 pr-4",children:[Object(y.jsx)(Y$,{label:"Cooling System",value:null===r||void 0===r?void 0:r.coolingSystem}),Object(y.jsx)(Y$,{label:"Unloading System",value:null===r||void 0===r?void 0:r.unloadingSystem})]}),Object(y.jsx)("div",{className:"w-1/2 pl-4",children:Object(y.jsx)(Y$,{label:"Filling System",value:null===r||void 0===r?void 0:r.fillingSystem})})]})},n0=n(2837),a0=n.p+"static/media/silo.604b8afc.svg",r0=function(){var e=Object(p.h)(),t=Object(a.useContext)(we),n=Object(a.useContext)(E$).state,r=n.selectedId,c=n.data,i=(void 0===c?[]:c).find((function(e){return e.id===r})),o=null===i||void 0===i?void 0:i.totalStoredLoad,s=(null===i||void 0===i?void 0:i.capacity)-o,l=o?o/(null===i||void 0===i?void 0:i.capacity)*100:0,d=s<0,u=d?"rounded-md bg-red-100 text-red-600 pl-2 pr-2":"";return Object(y.jsx)(qz,{header:Object(y.jsxs)("div",{className:"flex justify-between items-center px-4 py-3 border-b border-neutral-20 border-solid",children:[Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("img",{className:"mr-2",src:a0,alt:"Icon"}),Object(y.jsx)("h4",{className:"text-neutral-1000 text-base font-normal leading-6 tracking-tight",children:"Stored Quantity"})]}),Object(y.jsx)(m.Popup,{bgColor:"#232630",enableHover:!0,position:"top",align:"center",className:"w-30",hasArrow:!0,trigger:Object(y.jsxs)("div",{className:"pl-3 text-blue-90 text-sm flex items-center",children:[Object(y.jsx)(n0.a,{style:{width:"16px",height:"16px"}}),Object(y.jsx)("span",{className:"ml-1",children:"What is this?"})]}),children:Object(y.jsx)("div",{className:"w-356px text-xs text-white z-50",children:"Stored Quantity includes all loads across all crop seasons"})})]}),className:"",children:null!==i&&void 0!==i&&i.capacity&&"lb"!==(null===i||void 0===i?void 0:i.totalStoredLoadUnit)?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex py-4 pl-8 pr-4 space-x-4",children:[Object(y.jsx)("div",{className:"w-1/2",children:Object(y.jsx)("div",{className:"cwfweb-storage-location-usage h-160px w-160px",children:Object(y.jsx)(M$,{value:l,isLarge:!0})})}),Object(y.jsxs)("div",{className:"w-1/2",children:[Object(y.jsxs)("span",{"data-testid":"capacity",className:"flex flex-col mb-3",children:[Object(y.jsx)("span",{className:"text-neutral-60 text-xs font-normal leading-5 tracking-tight",children:"Capacity"}),Object(y.jsxs)("span",{className:"text-neutral-1000 text-base font-semibold leading-6 tracking-tight",children:[Object(y.jsx)(yf,{roundedTo:2,children:null===i||void 0===i?void 0:i.capacity})," ",Object(y.jsx)("span",{className:"font-normal text-xs",children:"bu"})]})]}),Object(y.jsxs)("span",{"data-testid":"total-currently-stored",className:"flex flex-col mb-3",children:[Object(y.jsx)("span",{className:"text-neutral-60 text-sm mb-1 font-normal leading-5 tracking-tight",children:"Total currently stored"}),Object(y.jsx)("span",{children:Object(y.jsxs)("span",{className:"".concat(d?"":"text-neutral-1000"," text-base font-semibold leading-6 tracking-tight ").concat(u),children:[Object(y.jsx)(yf,{roundedTo:2,children:o})," ",Object(y.jsx)("span",{className:"font-normal text-xs",children:"bu"})]})})]}),Object(y.jsxs)("span",{"data-testid":"currently-available",className:"flex flex-col mb-3",children:[Object(y.jsx)("span",{className:"text-neutral-60 text-xs font-normal leading-5 tracking-tight",children:"Currently available"}),Object(y.jsxs)("span",{className:"text-neutral-1000 text-3xl font-semibold leading-6 tracking-tight",children:[Object(y.jsx)(yf,{roundedTo:2,children:s})," ",Object(y.jsx)("span",{className:"font-normal text-base",children:"bu"})]})]})]})]}),d&&Object(y.jsxs)("div",{className:"flex bg-warning border-yellow-700 border rounded-md p-4 items-center",children:[Object(y.jsx)("div",{className:"mr-4",children:Object(y.jsx)("img",{src:Wa,alt:"CropWise Warning Icon"})}),Object(y.jsx)("span",{className:"text-sm font-normal",children:"Edit loads out of this location"}),Object(y.jsx)("span",{className:"flex-1"}),Object(y.jsx)(Xc.Button,{onClick:function(){t.sendEventToAmplitude(t.events.epic.YieldV2.storageLocations.goToLoads),e.push("".concat(Cc.yieldV2,"/loads?filters=").concat(JSON.stringify({storageIds:[r]})))},type:Xc.ButtonType.outline,size:"small",children:"Go to Loads"})]})]}):Object(y.jsx)("div",{className:"flex py-4 pl-8 pr-4 space-x-4",children:Object(y.jsx)("div",{className:"w-full",children:Object(y.jsxs)("span",{"data-testid":"total-currently-stored",className:"flex flex-col mb-3",children:[Object(y.jsx)("span",{className:"text-neutral-60 text-sm mb-1 font-normal leading-5 tracking-tight",children:"Total currently stored"}),Object(y.jsxs)("span",{className:"text-neutral-1000 text-3xl font-semibold leading-6 tracking-tight",children:[Object(y.jsx)(yf,{roundedTo:2,children:o})," ",Object(y.jsx)("span",{className:"font-normal text-base",children:"lb"===(null===i||void 0===i?void 0:i.totalStoredLoadUnit)?"lbs":"bu"})]})]})})})})},c0=function(){var e=Object(a.useContext)(we),t=ni(),n=Object(a.useContext)(E$),r=n.state,c=r.selectedId,i=r.data,o=void 0===i?[]:i,s=n.refetch,l=n.resetLocation,d=T$(),u=d.deleteStorageLocation,j=d.deleting,p=j.isLoading,f=j.isError,m=j.isSuccess,v=Object(a.useState)(!1),O=Object(b.a)(v,2),h=O[0],x=O[1],g=o.findIndex((function(e){return e.id===c})),C=o[g],P=null===C||void 0===C?void 0:C.hasAssociatedYields,A=function(){return x((function(e){return!e}))},S=function(){var t=Object(Y.a)(G.a.mark((function t(){return G.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e.sendEventToAmplitude(e.events.epic.YieldV2.storageLocations.delete),t.next=3,u(C.id);case 3:A();case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return Object(a.useEffect)((function(){if(!p)if(f)t.error("Unable to delete location.",{content:"An error prevented your location from being deleted. Please try again.",supportButton:!0});else if(m){t.success("Location deleted."),l();var e=(null===o||void 0===o?void 0:o[g+1])||(null===o||void 0===o?void 0:o[0]);s({skipCache:!0,initSelected:null===e||void 0===e?void 0:e.id})}}),[p,m,f]),p?Object(y.jsx)(si,{open:!0,message:"Deleting Location..."}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Xc.Tooltip,{overlayClassName:"max-w-full",title:P?"Locations that are associated with loads cannot be deleted":null,placement:"topRight",children:Object(y.jsx)("div",{children:Object(y.jsx)(Xc.Button,{icon:Object(y.jsx)(BX,{width:18}),disabled:P,type:Xc.ButtonType.outline,onClick:A,children:"Delete"})})}),Object(y.jsx)(ao,{title:Object(y.jsx)("span",{className:"font-semibold",children:"Delete Location?"}),type:"error",open:h,close:A,confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:S,children:Object(y.jsx)("div",{className:"pr-6",children:"Are you sure you want to delete this location?"})})]})},i0=function(){var e=Object(p.h)(),t=Object(a.useContext)(E$).state,n=t.selectedId,r=t.data,c=void 0===r?[]:r,i=t.sortBy,o=t.sortDir,s=c.find((function(e){return e.id===n}));return Object(y.jsxs)("div",{className:"flex flex-row items-center bg-white border border-t-0 h-16 justify-between py-6 pl-6 pr-4 sticky top-0 z-1",children:[Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)("img",{className:"mr-2",src:zZ,alt:"Icon"}),Object(y.jsx)("span",{className:"font-semibold text-2xl",children:null===s||void 0===s?void 0:s.name})]}),Object(y.jsxs)("div",{className:"flex space-x-4 flex-row items-center justify-between",children:[Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.outline,icon:Object(y.jsx)(kX,{width:18}),onClick:function(){return e.push("".concat(Cc.yieldV2,"/storage-locations/edit/").concat(null===s||void 0===s?void 0:s.id),{selectedId:n,sortBy:i,sortDir:o})},children:"Edit"}),Object(y.jsx)(c0,{})]})]})},o0={dimensions:Object(y.jsx)($$,{}),systems:Object(y.jsx)(t0,{}),advancedAttributes:Object(y.jsx)(G$,{}),notes:Object(y.jsx)(e0,{})},s0=function(){var e=Object(p.h)(),t=Object(a.useContext)(we),n=Object(a.useContext)(E$).state,r=n.data,c=n.selectedId,i=n.isLoading,o=n.isFetchingDetails,s=n.sortBy,l=n.sortDir,d=null===r||void 0===r?void 0:r.find((function(e){return e.id===c}));return i||o?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{className:"h-full w-full relative flex flex-col",children:[d&&Object(y.jsx)(i0,{}),r.length?Object(y.jsx)("div",{className:"min-w-content h-full flex flex-col flex-1 gap-y-4 p-4",children:d?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"lg:flex lg:space-x-4 space-y-4 lg:space-y-0",children:[Object(y.jsx)("div",{className:"lg:w-1/2 h-auto",children:Object(y.jsx)(r0,{})}),Object(y.jsx)("div",{className:"lg:w-1/2 h-auto",children:Object(y.jsx)(q$,{})})]}),Object(y.jsx)(m.Tabs,{pane:!0,children:Object.entries(o0).map((function(e){var t=Object(b.a)(e,2),n=t[0],a=t[1];return Object(y.jsx)(m.Tabs.Tab,{label:z$(n),children:Object(y.jsx)("div",{className:"pt-4 pr-4 pl-4 pb-8",children:a})},n)}))})]}):Object(y.jsx)(qz,{className:"pt-48px pb-128px",children:Object(y.jsx)(jw,{title:"No Storage Location Selected",overlayIcon:dl})})}):Object(y.jsx)("div",{className:"min-w-content gap-y-4 p-4",children:Object(y.jsx)(qz,{className:"pt-48px pb-128px",children:Object(y.jsx)(jw,{title:"No Storage Locations Found",overlayIcon:pw,button:Object(y.jsx)(m.Button,{type:"primary",onClick:function(){t.sendEventToAmplitude(t.events.epic.YieldV2.storageLocations.createStorageLocation),e.push("".concat(Cc.yieldV2,"/storage-locations/create"),{selectedId:c,sortBy:s,sortDir:l})},children:"+ Create Location"})})})})]})},l0=n.p+"static/media/sort.ce95c2ba.svg",d0=function(e){var t=e.sortItems,n=e.onSort,r=e.selectedItem,c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useRef)(null);Object(a.useEffect)((function(){var e=function(e){l.current&&!l.current.contains(e.target)&&s(!1)};return document.addEventListener("click",e),function(){document.removeEventListener("click",e)}}),[]);var d=r?t.indexOf(t.find((function(e){return e.sortKey===r.sortBy&&e.sortDirection===r.sortDir}))):-1;return Object(y.jsxs)("div",{style:{width:"100%"},ref:l,children:[Object(y.jsxs)(m.Button,{onClick:function(){s(!o)},style:{width:"100%"},type:"outline",ghost:!0,children:[Object(y.jsx)("div",{className:"flex flex-row relative bg-color",children:Object(y.jsx)("img",{className:"mr-1",src:l0,alt:"Sort Icon"})}),"Sort"]}),o&&Object(y.jsx)("div",{className:"h-35 absolute bg-white z-50 mt-2 shadow-card rounded ",children:Object(y.jsx)("div",{className:"w-full h-full flex flex-col justify-center",children:null===t||void 0===t?void 0:t.map((function(e,t){return Object(y.jsx)(pu,{className:"".concat(t===d?"bg-selectedBlue":"",' "h-8 gr-whitespace-nowrap '),onClick:function(){return t=e.sortKey,a=e.sortDirection,n({sortBy:t,sortDir:a}),void s(!1);var t,a},children:Object(y.jsx)("div",{className:"w-full h-full p-2 ".concat(t===d&&"font-semibold"),children:e.sortLabel})},e.sortKey)}))})})]})};d0.defaultProps={selectedItem:""};var u0,b0,j0=d0,p0=[{sortLabel:"Location Name (A \u2192 Z)",sortKey:"name",sortDirection:"asc"},{sortLabel:"Capacity (High \u2192 Low)",sortKey:"capacity",sortDirection:"desc"},{sortLabel:"Available Space (High \u2192 Low)",sortKey:"availableSpace",sortDirection:"desc"}],f0=function(e){var t=e.onCreateNew,n=Object(a.useContext)(E$),r=n.applySort,c=n.state;return Object(y.jsxs)("div",{className:"pb-4 sticky top-0 z-4 pt-5 white-bg px-5 border-b border-neutral-20",children:[Object(y.jsxs)("div",{className:"flex items-center justify-start mb-4",children:[Object(y.jsx)("img",{alt:"Field Icon",src:zZ}),Object(y.jsx)("h4",{className:"text-2xl font-semibold leading-none ml-2",children:"Storage"})]}),Object(y.jsxs)("div",{className:"flex items-center justify-center mb-1 space-x-4",children:[Object(y.jsx)("div",{className:"flex-1",children:Object(y.jsx)(m.Button,{type:"primary",onClick:t,style:{width:"100%"},icon:Object(y.jsx)(Ii.a,{style:{width:"70%"}}),children:Object(y.jsx)("span",{style:{marginLeft:"-4px"},children:"Create New"})})}),Object(y.jsx)("div",{className:"flex-1",children:Object(y.jsx)(j0,{className:"w-full",selectedItem:{sortBy:null===c||void 0===c?void 0:c.sortBy,sortDir:null===c||void 0===c?void 0:c.sortDir},sortItems:p0,onSort:function(e){var t=e.sortBy,n=e.sortDir;r({sortBy:t,sortDir:n})}})})]})]})},m0=function(e){var t=ae.a.cloneDeep(e);for(var n in t){var a=t[n],r="string"===typeof a&&""!==a.trim(),c="number"===typeof a&&""!==String(a).trim();r||c?t[n]="fill":delete t[n]}return t},v0=[{label:"pounds (lbs)",value:va.a.POUND},{label:"dry ounces (oz)",value:va.a.OUNCE},{label:"grams (g)",value:va.a.GRAM},{label:"tons (T)",value:va.a.TON}],O0=15,h0="ALL_CROPS",x0="ROW_CROP",g0="SPECIALTY",C0={BY_QUANTITY:"QUANTITY",BY_PERCENT:"PERCENT"},y0=(u0={},Object(et.a)(u0,h0,[]),Object(et.a)(u0,x0,["damage","foreignMaterial","moisture","testWeight"]),Object(et.a)(u0,g0,["damage","foreignMaterial","quality"]),u0),P0=(b0={},Object(et.a)(b0,h0,{}),Object(et.a)(b0,x0,{shrinkType:C0.BY_QUANTITY,testWeightUnit:va.a.POUND}),Object(et.a)(b0,g0,{}),b0);function A0(e){return Fu.d().required("".concat(e," is required")).typeError("".concat(e," must be a number")).test("is-positive","".concat(e," must be a positive number"),(function(e){return e>0}))}function S0(e){return Fu.d().typeError("".concat(e," must be a number")).nullable().transform((function(e,t){return""===t?null:e})).min(0,"".concat(e," must be a positive number"))}var T0=Fu.e({name:Fu.f().required("Location Name is required"),capacity:S0("Capacity"),length:S0("Length"),width:S0("Width"),height:S0("Height"),volume:S0("Volume"),diameter:S0("Diameter"),coneHeight:S0("Cone Height")}),N0=function(){return Object(y.jsx)("div",{className:"flex justify-center items-center",children:Object(y.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-500"})})},E0=function(e){var t=e.valueRenderer,n=e.children,r=e.onChange,c=e.value,i=e.bottomButtonText,o=e.onBottomButtonClick,s=e.id,l=e.rightOffset,d=e.heightClass,u=e.isInvalid,j=e.isLoading,p=Object(a.useState)(!1),f=Object(b.a)(p,2),v=f[0],O=f[1],h=Object(a.useRef)(null);Object(a.useEffect)((function(){var e=function(e){h.current&&!h.current.contains(e.target)&&O(!1)};return document.addEventListener("click",e),function(){document.removeEventListener("click",e)}}),[]);var x=t(c);return Object(y.jsxs)("div",{className:"w-full mt-1",ref:h,id:s,children:[Object(y.jsx)(m.Button,{onClick:function(){O(!v)},style:{width:"100%"},type:"outline",ghost:!u,danger:u,disabled:j,dataTestId:s,children:Object(y.jsxs)("div",{className:"flex flex-row w-full relative",children:[Object(y.jsx)("div",{style:{whiteSpace:"nowrap"},className:"flex-1 overflow-x-hidden whitespace-nowrap",children:x}),j?Object(y.jsx)(N0,{}):Object(y.jsx)("img",{className:"mr-1",src:Di,alt:"Sort Icon"})]})}),v&&Object(y.jsx)("div",{className:"".concat(d," absolute bg-white z-50 mt-2 shadow-card rounded "),style:{minWidth:"calc(100% - ".concat(l,"px)")},children:Object(y.jsxs)("div",{className:"w-full h-full flex flex-col justify-center",children:[Object(y.jsx)("div",{className:"mt-2 pl-4 flex-1 overflow-x-hidden overflow-y-auto w-full",children:n.flat().map((function(e){var t,n,a;return null!==(t=e.props)&&void 0!==t&&t.onItemClick?Object(y.jsx)(pu,{className:"h-8 gr-whitespace-nowrap",onClick:function(){O(!1),e.props.onItemClick()},children:e},JSON.stringify(e.props.value)):null!==(n=e.props)&&void 0!==n&&n.value?Object(y.jsx)(pu,{className:"".concat((a=e.props.value,JSON.stringify(a)===JSON.stringify(c)?"bg-selectedBlue":"hover:bg-neutral-100")," h-6 gr-whitespace-nowrap pr-4"),onClick:function(){O(!1),r(e.props.value)},children:e},JSON.stringify(e.props.value)):e}))}),i&&o&&Object(y.jsx)("div",{className:"flex justify-center border-t border-solid border-neutral-100",children:Object(y.jsx)("div",{className:"mx-4 my-2 w-full h-full",children:Object(y.jsx)(m.Button,{onClick:function(){O(!1),o()},style:{width:"100%"},type:"outline",ghost:!u,danger:u,children:i})})})]})})]})};E0.defaultProps={value:null,id:"",isInvalid:!1,rightOffset:24,heightClass:"h-100",isLoading:!1,bottomButtonText:null,onBottomButtonClick:null};var w0=E0;E0.ClickableElement=function(e){return e.children};var _0=function(e){var t=e.people,n=e.companies,r=e.onCreateNewOwner,c=e.onChange,i=e.value,o=e.id,s=Object(a.useCallback)((function(){return"People"===(null===i||void 0===i?void 0:i.type)?Object(y.jsxs)("div",{className:"w-full h-full p-2 flex items-center",children:[Object(y.jsx)("img",{className:"h-4",alt:"Field Icon",src:vE}),Object(y.jsx)("div",{className:"pl-2",children:i.name})]}):"Company"===(null===i||void 0===i?void 0:i.type)?Object(y.jsxs)("div",{className:"w-full h-full p-2 flex items-center",children:[Object(y.jsx)("img",{className:"h-4",alt:"Field Icon",src:mE}),Object(y.jsx)("div",{className:"pl-2",children:i.name})]}):null}),[i]);return Object(y.jsxs)(w0,{rightOffset:0,heightClass:"h-64",valueRenderer:s,value:i,bottomButtonText:"Create New Owner",onBottomButtonClick:r,onChange:c,id:o,children:[Object(y.jsx)("div",{className:"text-neutral-60 py-2",children:"COMPANIES"}),n.length>0?n.map((function(e){return Object(y.jsxs)("div",{className:"w-full h-full p-2 flex items-center",value:{type:"Company",id:e.id,name:e.name},children:[Object(y.jsx)("img",{className:"h-4",alt:"Field Icon",src:mE}),Object(y.jsx)("div",{className:"pl-2",children:e.name})]},e.id)})):Object(y.jsx)("div",{className:"pl-2",children:"No companies found"}),Object(y.jsx)("div",{className:"text-neutral-60 py-2",children:"PEOPLE"}),t.length>0?t.map((function(e){return Object(y.jsxs)("div",{className:"w-full h-full p-2 flex items-center",value:{type:"People",id:e.id,name:e.name},children:[Object(y.jsx)("img",{className:"h-4",alt:"Field Icon",src:vE}),Object(y.jsx)("div",{className:"pl-2",children:e.name})]},e.id)})):Object(y.jsx)("div",{className:"pl-2",children:"No people found"})]})};_0.defaultProps={value:null,id:""};var R0=_0,I0=function(e){var t=e.showToast,n=e.setShowToast,a=e.state,r=e.title,c=e.errorMessage,i=e.isBold;return Object(y.jsx)(Qc,{type:a,title:r,open:t,onClose:function(){n(!1)},timeout:5500,isBold:i,children:"error"===a&&c?Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"text-sm font-normal mb-2",children:c}),Object(y.jsx)(m.Button,{size:"lg",type:"primary",onClick:function(){return window.open("https://www.syngentadigital.com/us-en","_blank","noopener")},style:{marginLeft:"auto"},children:"Contact Support"})]}):null})};I0.defaultProps={errorMessage:"",title:"",isBold:!1};var D0=I0,k0=function(e){var t,n=function(e){return"string"===typeof e&&e.trim().length>0?+e:e},a={volume:null,height:null,length:null,width:null,diameter:null,coneHeight:null},r=null===(t=e.shape)||void 0===t?void 0:t.toLowerCase();r&&"none"!==r&&(a.volume=n(e.volume),a.height=n(e.height)),"flat"===r&&(a.length=n(e.length),a.width=n(e.width)),"round"===r&&(a.diameter=n(e.diameter),a.coneHeight=n(e.coneHeight));var c=Object(I.a)(Object(I.a)({},e),{},{capacity:n(e.capacity)},a);return Object(tF.e)(c)},L0=function(e){var t=e.id,n=e.onCancel,r=e.onSubmit,c=Object(a.useState)(null),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(!1),f=Object(b.a)(p,2),v=f[0],O=f[1],h=Object(a.useState)(!1),x=Object(b.a)(h,2),g=x[0],C=x[1],P=Object(a.useContext)(we),A=dE(),S=uE(),T=Object(a.useState)({status:null,shape:null,fillingSystem:null,unloadingSystem:null,notes:null}),N=Object(b.a)(T,2),E=N[0],w=N[1],_=T$(),R=_.saving,I=_.fetchStorageDetails,D=_.createStorageLocation,k=_.updateStorageLocation,L=t&&!g||A.loading||S.loading,F=t?"Saving Changes":"Saving Location",M=t?"Unable to save changes. An error prevented your location from being updated. Please try again.":"An error prevented your location from being saved. Please try again.",V=t?"Location Not Updated.":"Location Not Saved.";Object(a.useEffect)((function(){if(t&&!A.loading&&!S.loading&&!g){var e=function(){var e=Object(Y.a)(G.a.mark((function e(){var n,a,r;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,I(t);case 2:(n=e.sent).owner&&(r="Company"===n.owner.type?A.companies:S.people,n.owner.name=null===(a=r.find((function(e){return e.id===n.owner.id})))||void 0===a?void 0:a.name),w(n),C(!0);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}}),[t,w,I,A.loading,A.companies,g,S.loading,S.people]);var B=function(){var e=Object(Y.a)(G.a.mark((function e(t){var n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!R){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,D(k0(t));case 4:(n=e.sent)?(P.sendEventToAmplitude(P.events.epic.YieldV2.storageLocations.saveStorageLocation,m0(t)),r(n)):O(!0);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),U=function(){var e=Object(Y.a)(G.a.mark((function e(n){var a;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!R){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,k(t,k0(n));case 4:(a=e.sent)?r(a):O(!0);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return L?Object(y.jsx)("div",{className:"px-4 flex items-center justify-center w-full h-full",children:Object(y.jsx)(m.Spinner,{size:"xl"})}):Object(y.jsxs)("div",{className:"px-4 flex items-center justify-center w-full h-full",children:[Object(y.jsx)(D0,{title:V,state:"error",showToast:v,setShowToast:O,errorMessage:M}),Object(y.jsx)(Zi.e,{initialValues:E,validationSchema:T0,children:function(e){var a=e.values,r=e.isValid;return Object(y.jsxs)("div",{className:"bg-white rounded-lg flex flex-col w-full h-full pb-8 shadow-sm-card",style:{height:"calc(100% - 32px)"},children:[!R&&Object(y.jsxs)("div",{className:"flex flex-col flex-1 h-full w-full overflow-y-auto relative",children:[Object(y.jsxs)("div",{className:"py-6 grid gap-1 grid-cols-4 px-8",children:[Object(y.jsx)("h1",{className:"col-span-4 my-4 text-lg font-bold",children:"Basic Info"}),Object(y.jsx)("div",{className:"col-span-2 my-4 mr-4 ",children:Object(y.jsx)(Qi,{value:a.name,placeholder:"",control:m.Input,type:"text",name:"name",label:Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("span",{children:"Name of Location"}),Object(y.jsx)("span",{className:"text-red-600",children:"*"})]})})}),Object(y.jsx)("div",{className:"col-span-1 my-4 mr-4",children:Object(y.jsx)(Qi,{value:a.email,placeholder:"",control:m.Input,type:"text",name:"email",label:"Email Address"})}),Object(y.jsx)("div",{className:"col-span-1 my-4 mr-4",children:Object(y.jsx)(Qi,{value:a.phone,placeholder:"",control:m.Input,type:"text",name:"phone",label:"Phone Number"})}),Object(y.jsx)(OE,{})]}),Object(y.jsxs)("div",{className:"pb-6 grid gap-1 grid-cols-2 px-8",children:[Object(y.jsxs)("div",{className:"",children:[Object(y.jsx)("h1",{className:"col-span-2 text-lg font-bold",children:"Dimensions"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"w-full mr-4",children:[Object(y.jsx)("div",{className:"mt-8 mb-2",children:Object(y.jsx)(Qi,{value:a.shape,placeholder:"",control:m.Select,type:"text",name:"shape",label:"Shape",items:[{key:null,value:"None"},{key:"Round",value:"Round"},{key:"Flat",value:"Flat"}]})}),Object(y.jsx)("div",{className:"mb-8 relative",children:Object(y.jsxs)("div",{className:"flex flex-col weight-input",children:[Object(y.jsx)("label",{htmlFor:"capacity",className:"text-neutral-60 tracking-tighter text-sm",children:"Capacity"}),Object(y.jsx)(US,{fieldName:"capacity",inputSuffix:Object(y.jsx)("span",{className:"text-sm text-gray-600",children:"bu by vol"}),id:"capacity",isRequired:!1,round:O0}),Object(y.jsx)(Zi.a,{name:"capacity",component:"div",className:"text-remove"})]})}),Object(y.jsxs)("div",{className:"-mt-4",children:[Object(y.jsx)("img",{alt:"info",src:B_,className:"mr-1 -mt-1 inline"}),Object(y.jsx)("span",{className:"text-sm mt-1 text-gray-600",children:"bu by vol = 1.24446 cubic ft assuming standard moisture of stored crop"})]})]}),Object(y.jsxs)("div",{className:"w-full mr-8",children:["Flat"===a.shape&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"my-8 relative",children:[Object(y.jsx)(Qi,{value:a.length,placeholder:"",control:m.Input,type:"text",name:"length",label:"Length"}),Object(y.jsx)("div",{className:"text-sm text-gray-600 absolute top-0 right-0 mr-2 mt-1",children:"ft"})]}),Object(y.jsxs)("div",{className:"my-8 relative",children:[Object(y.jsx)(Qi,{value:a.width,placeholder:"",control:m.Input,type:"text",name:"width",label:"Width"}),Object(y.jsx)("div",{className:"text-sm text-gray-600 absolute top-0 right-0 mr-2 mt-1",children:"ft"})]}),Object(y.jsxs)("div",{className:"my-8 relative",children:[Object(y.jsx)(Qi,{value:a.height,placeholder:"",control:m.Input,type:"text",name:"height",label:"Height"}),Object(y.jsx)("div",{className:"text-sm text-gray-600 absolute top-0 right-0 mr-2 mt-1",children:"ft"})]}),Object(y.jsxs)("div",{className:"my-8 relative",children:[Object(y.jsx)(Qi,{value:a.volume,placeholder:"",control:m.Input,type:"text",name:"volume",label:"Volume"}),Object(y.jsx)("div",{className:"text-sm text-gray-600 absolute top-0 right-0 mr-2 mt-1",children:"cu. ft"})]})]}),"Round"===a.shape&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"my-8 relative",children:[Object(y.jsx)(Qi,{value:a.diameter,placeholder:"",control:m.Input,type:"text",name:"diameter",label:"Diameter"}),Object(y.jsx)("div",{className:"text-sm text-gray-600 absolute top-0 right-0 mr-2 mt-1",children:"ft"})]}),Object(y.jsxs)("div",{className:"my-8 relative",children:[Object(y.jsx)(Qi,{value:a.height,placeholder:"",control:m.Input,type:"text",name:"height",label:"Height"}),Object(y.jsx)("div",{className:"text-sm text-gray-600 absolute top-0 right-0 mr-2 mt-1",children:"ft"})]}),Object(y.jsxs)("div",{className:"my-8 relative",children:[Object(y.jsx)(Qi,{value:a.coneHeight,placeholder:"",control:m.Input,type:"text",name:"coneHeight",label:"Cone Height"}),Object(y.jsx)("div",{className:"text-sm text-gray-600 absolute top-0 right-0 mr-2 mt-1",children:"ft"})]}),Object(y.jsxs)("div",{className:"my-8 relative",children:[Object(y.jsx)(Qi,{value:a.volume,placeholder:"",control:m.Input,type:"text",name:"volume",label:"Volume"}),Object(y.jsx)("div",{className:"text-sm text-gray-600 absolute top-0 right-0 mr-2 mt-1",children:"cu. ft"})]})]})]})]})]}),Object(y.jsxs)("div",{className:"",children:[Object(y.jsx)("h1",{className:"text-lg font-bold",children:"Systems"}),Object(y.jsx)("div",{className:"my-8 mr-4",children:Object(y.jsx)(Qi,{value:a.coolingSystem,placeholder:"",control:m.Input,type:"text",name:"coolingSystem",label:"Cooling System"})}),Object(y.jsx)("div",{className:"my-8 mr-4",children:Object(y.jsx)(Qi,{value:a.fillingSystem,placeholder:"",control:m.Select,type:"text",name:"fillingSystem",label:"Filling System",items:[{key:null,value:"Select Filling System"},{key:"Auger",value:"Auger"},{key:"Bucket Elevator",value:"Bucket Elevator"},{key:"Drag Chain",value:"Drag Chain"},{key:"Vacuum System",value:"Vacuum System"}]})}),Object(y.jsx)("div",{className:"my-8 mr-4",children:Object(y.jsx)(Qi,{value:a.unloadingSystem,placeholder:"",control:m.Select,type:"text",name:"unloadingSystem",label:"Unloading System",items:[{key:null,value:"Select Unloading System"},{key:"Auger",value:"Auger"},{key:"Bucket Elevator",value:"Bucket Elevator"},{key:"Drag Chain",value:"Drag Chain"},{key:"Vacuum System",value:"Vacuum System"}]})})]})]}),Object(y.jsxs)("div",{className:"py-6 px-8",children:[Object(y.jsx)("h1",{className:"my-4 text-lg font-bold",children:"Advanced Attributes"}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"mt-2 mb-8 mr-4 w-full relative",children:[Object(y.jsx)("label",{htmlFor:"owner-select",className:"text-neutral-60 tracking-tighter text-sm",children:"Owner"}),Object(y.jsx)(Zi.b,{name:"owner",children:function(e){var t=e.field,n=e.form;return o&&(n.setFieldValue(t.name,o),s(null)),Object(y.jsx)(R0,{id:"owner-select",value:a.owner,onChange:function(e){s(null),n.setFieldValue(t.name,e)},onCreateNewOwner:function(){P.sendEventToAmplitude(P.events.epic.YieldV2.storageLocations.createCompany),j(!0)},people:S.people,companies:A.companies})}})]}),Object(y.jsx)("div",{className:"my-8 mr-4 w-full",children:Object(y.jsx)(Qi,{value:a.status,placeholder:"",control:m.Select,type:"text",name:"status",label:"Status",items:[{key:null,value:"Select Status"},{key:"Owned",value:"Owned"},{key:"Leased",value:"Leased"}]})}),Object(y.jsx)("div",{className:"my-8 mr-4 w-full",children:Object(y.jsx)(Qi,{value:a.yearBuilt,placeholder:"",control:m.Input,type:"text",name:"yearBuilt",label:"Year Built"})}),Object(y.jsx)("div",{className:"my-8 mr-4 w-full",children:Object(y.jsx)(Qi,{value:a.quality,placeholder:"",control:m.Input,type:"text",name:"quality",label:"Quality"})})]}),Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("div",{className:"my-4 mr-4 w-full",children:Object(y.jsx)(Qi,{value:a.propertyTaxId,placeholder:"",control:m.Input,type:"text",name:"propertyTaxId",label:"Property Tax ID"})}),Object(y.jsx)("div",{className:"w-full mr-4"}),Object(y.jsx)("div",{className:"w-full mr-4"}),Object(y.jsx)("div",{className:"w-full mr-4"})]}),Object(y.jsx)("div",{className:"my-8"}),Object(y.jsx)(Qi,{value:a.notes,label:"Notes",control:m.TextArea,id:"notes",name:"notes",className:"h-32 overscroll-auto"})]})]}),R&&Object(y.jsx)("div",{className:"flex h-full w-full relative items-center justify-center",children:Object(y.jsxs)("div",{className:"",children:[Object(y.jsx)(m.Spinner,{size:"lg"}),Object(y.jsx)("div",{className:"text-lg font-bold inline-box ml-1 mb-1",children:F})]})}),Object(y.jsxs)("div",{className:"bottom-0 left-0 flex flex-row w-full space-x-4 p-4 border-t border-solid border-neutral-100 justify-end -mb-8",children:[Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.outline,disabled:R,onClick:n,size:"lg",children:"Cancel"}),Object(y.jsx)(Xc.Button,{disabled:!r||R,type:Xc.ButtonType.primary,onClick:t?function(){return U(a)}:function(){return B(a)},size:"lg",children:"Save Location"})]})]})}}),Object(y.jsx)(yE,{onClose:function(){return j(!1)},onCompanyPeopleAdded:function(e){s(e),A.loadCompanies(),S.loadPeople()},open:u})]})};L0.defaultProps={id:null};var F0=L0,M0=function(){var e=Object(a.useContext)(E$).state,t=Object(p.h)(),n=Object(a.useContext)(we),r=Object(p.i)(),c=Object(p.j)(),i=ni(),o="create"===c.action,s="edit"===c.action;return Object(a.useEffect)((function(){var e,t;(null!==(e=r.state)&&void 0!==e&&e.showToast||null!==(t=r.state)&&void 0!==t&&t.selectedId)&&window.history.replaceState(null)}),[]),Object(y.jsxs)("div",{className:"w-full h-full","data-testid":"yield-storage-locations",children:[o&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(I$,{disabled:!0,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Create Storage Location",isLast:!0})}),Object(y.jsx)(F0,{onSubmit:function(n){i.success("Location created"),t.push("".concat(Cc.yieldV2,"/storage-locations"),{selectedId:n,sortBy:e.sortBy,sortDir:e.sortDir,skipCache:!0})},onCancel:function(){t.push("".concat(Cc.yieldV2,"/storage-locations"),{selectedId:e.selectedId,sortBy:e.sortBy,sortDir:e.sortDir})}})]}),s&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(I$,{disabled:!0,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Edit Storage Location",isLast:!0})}),Object(y.jsx)(F0,{onSubmit:function(){n.sendEventToAmplitude(n.events.epic.YieldV2.storageLocations.editStorageLocation),i.success("Changes saved"),t.push("".concat(Cc.yieldV2,"/storage-locations"),{selectedId:c.locationId,sortBy:e.sortBy,sortDir:e.sortDir,skipCache:!0})},onCancel:function(){t.push("".concat(Cc.yieldV2,"/storage-locations"),{selectedId:e.selectedId,sortBy:e.sortBy,sortDir:e.sortDir})},id:c.locationId})]}),!s&&!o&&Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(I$,{children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Storage locations"})}),Object(y.jsxs)("div",{className:"flex flex-row w-full h-full",children:[Object(y.jsxs)("div",{className:"\nmin-w-332px h-full bg-white overflow-x-visible flex flex-col border ",style:{minWidth:332},children:[Object(y.jsx)(f0,{onCreateNew:function(){n.sendEventToAmplitude(n.events.epic.YieldV2.storageLocations.createStorageLocation),t.push("".concat(Cc.yieldV2,"/storage-locations/create"),{selectedId:e.selectedId,sortBy:e.sortBy,sortDir:e.sortDir})}}),Object(y.jsx)(U$,{})]}),Object(y.jsx)(s0,{})]})]})]})},V0=function(){var e=Object(p.i)().state,t={sortBy:null===e||void 0===e?void 0:e.sortBy,sortDir:null===e||void 0===e?void 0:e.sortDir,selectedId:null===e||void 0===e?void 0:e.selectedId,skipCache:null===e||void 0===e?void 0:e.skipCache};return Object(y.jsx)(_$,{initialValues:t,children:Object(y.jsx)(M0,{})})},B0=function(){var e=Object(a.useRef)(0),t=Object(p.h)(),n=Object(a.useContext)(we),r=Object(a.useContext)(ac),c=Object(b.a)(r,2),i=c[0].organization,o=c[1],s=Object(a.useState)([]),l=Object(b.a)(s,2),d=l[0],j=l[1],f=Object(a.useState)(!1),m=Object(b.a)(f,2),v=m[0],O=m[1],h=Object(a.useState)(!1),x=Object(b.a)(h,2),g=x[0],C=x[1],y=Object(a.useState)(!1),P=Object(b.a)(y,2),A=P[0],S=P[1],T=Object(a.useState)(),N=Object(b.a)(T,2),E=N[0],w=N[1],_=Object(a.useState)(),R=Object(b.a)(_,2),D=R[0],k=R[1],L=Object(a.useState)(),F=Object(b.a)(L,2),M=F[0],V=F[1],B=Object(a.useState)(),U=Object(b.a)(B,2),z=U[0],Z=U[1],Y=Object(a.useState)(),H=Object(b.a)(Y,2),G=H[0],W=H[1],q={page:1,sortBy:"name",sortDir:"ASC",limit:0},K={"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:i.id}),Authorization:"Bearer ".concat(Ve())},Q="success",X="error",$=Object(a.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};O(!0);var n=J.a.get("".concat(u.e,"/yield/sale-location/list"),{headers:Object(I.a)(Object(I.a)({},K),{},{"cwf-context":JSON.stringify({organization_id:e})}),params:Object(I.a)(Object(I.a)({},q),t)});n.then((function(e){var t=e.data;j(t.data)})).catch(Ae.default).catch((function(e){uc(o)(e)})).finally((function(){return O(!1)}))}),[]),ee=Object(a.useCallback)((function(e){C(!0),o({type:Wr,payload:!1}),J.a.post("".concat(u.e,"/yield/sale-location"),e,{headers:K}).then((function(a){var r=a.data;o({type:zr,payload:Q}),o({type:Wr,payload:!0}),jc(o,Jr,r),n.sendEventToAmplitude(n.events.epic.YieldV2.saleLocations.createSaleLocation,m0(e)),t.push("".concat(Cc.yieldV2,"/sale-locations?saleId=").concat(null===r||void 0===r?void 0:r.id))})).catch(Ae.default).catch((function(e){uc(o)(e),o({type:zr,payload:X}),o({type:Wr,payload:!0})})).finally((function(){return C(!1)}))}),[]),te=Object(a.useCallback)((function(t){k(!0),e.current+=1;var n=e.current;J.a.get("".concat(u.e,"/yield/sale-location/").concat(t),{headers:K}).then((function(t){var a=t.data;e.current===n&&w(a)})).catch(Ae.default).catch((function(e){uc(o)(e)})).finally((function(){k(!1)}))}),[i]);return{getSaleLocationList:$,isLoadingSaleLocationList:v,isLoadingCreateSaleLocation:g,saleLocationList:d,setSaleLocationList:j,createSaleLocation:ee,saleLocation:E,editSaleLocation:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};S(!0),o({type:Wr,payload:!1}),W({});var r=J.a.put("".concat(u.e,"/yield/sale-location/").concat(e),a,{headers:K});r.then((function(a){var r=a.data;W(r),o({type:zr,payload:Q}),o({type:Wr,payload:!0}),n.sendEventToAmplitude(n.events.epic.YieldV2.saleLocations.editSaleLocation),t.push("".concat(Cc.yieldV2,"/sale-locations?saleId=").concat(e))})).catch(Ae.default).catch((function(e){uc(o)(e),o({type:zr,payload:X}),o({type:Wr,payload:!0})})).finally((function(){return S(!1)}))},isLoadingEditSaleLocation:A,editSaleLocationData:G,deleteSaleLocation:function(e,n,a,r){V(!0),o({type:Wr,payload:!1}),J.a.delete("".concat(u.e,"/yield/sale-location/").concat(e),{headers:K}).then((function(n){var c=n.data;jc(o,Jr,{}),Z(c);var i=a.findIndex((function(t){return t.id===e})),s=a,l=i+1<s.length,d=a.filter((function(t){return t.id!==e}));if(r(d),-1!==i&&l){var u=s[i+1].id;t.replace("".concat(Cc.yieldV2,"/sale-locations?saleId=").concat(u))}else t.replace("".concat(Cc.yieldV2,"/sale-locations"));o({type:zr,payload:"successDelete"}),o({type:Wr,payload:!0})})).catch(Ae.default).catch((function(e){uc(o)(e),o({type:zr,payload:"failDelete"}),o({type:Wr,payload:!0})})).finally((function(){V(!1),n()}))},isDeletingSaleLocation:M,deletedSaleLocation:z,getSaleLocationById:te,isFetchingSaleLocation:D}},U0=function(e){var t=e.showToast,n=e.setShowToast,a=e.state;return Object(y.jsx)(Qc,{type:function(e){switch(e){case"failDelete":return"error";case"successDelete":return"success";default:return e}}(a),title:function(e){var t;return"error"===e?t="Unable to save changes.":"success"===e?t="Changes saved.":"successDelete"===e?t="Location deleted.":"failDelete"===e&&(t="Unable to delete location."),t}(a),open:t,onClose:function(){n(!1)},timeout:5500,isBold:!0,children:("error"===a||"failDelete"===a)&&Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"text-sm font-normal mb-2",children:"error"===a?"An error prevented your information from being saved. Please try again.":"An error prevented your location from being deleted. Please try again."}),Object(y.jsx)($c,{})]})})},z0={},Z0=Fu.e().shape({name:Fu.f().required(""),email:Fu.f().nullable(),addressLineOne:Fu.f().nullable(),city:Fu.f().nullable(),phone:Fu.f().nullable(),company:Fu.f().nullable(),addressLineTwo:Fu.f().nullable(),state:Fu.f().nullable(),zipCode:Fu.f().nullable(),notes:Fu.f().nullable()}),Y0={name:"Name of Location",company:"Company",phone:"Phone Number",email:"Email",city:"City",State:"State",zipCode:"Zip Code",addressLineOne:"Address Line 1",addressLineTwo:"Address Line 2",notes:"Notes"},H0={name:"name",company:"company",companyId:"companyId",phone:"phone",email:"email",city:"city",State:"state",zipCode:"zipCode",addressLineOne:"addressLineOne",addressLineTwo:"addressLineTwo",notes:"notes"},G0=function(e){var t=e.labelTitles,n=e.LabelInputs,a=e.divider,r=e.setValueSelected,c=e.errorIcon,i=e.setErrortext;return Object(y.jsxs)("div",{className:"flex flex-col w-126",children:[Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsxs)(m.Form.Field,{label:Object(y.jsxs)("div",{className:"flex flex-row",children:[t.name,Object(y.jsx)("div",{className:"text-remove",children:"*"})]}),labelFor:n.name,children:[Object(y.jsx)(Qi,{control:m.Input,id:n.name,name:n.name,onChangeCapture:function(e){return r(e.target.value)},style:c?{background:'url("/static/media/productValidationAlert.1372f4cb.svg") no-repeat right',backgroundSize:"20px",border:"1px solid red"}:{}}),Object(y.jsx)("span",{className:"gr-absolute gr-text-red-600 gr-text-xs gr-my-1 gr-mr-2 gr-whitespace-no-wrap gr-truncate gr-visible",children:i})]}),a("w-6"),Object(y.jsx)(m.Form.Field,{label:t.email,labelFor:n.email,children:Object(y.jsx)(Qi,{control:m.Input,id:n.email,name:n.email})})]}),Object(y.jsx)(m.Form.Field,{label:t.addressLineOne,labelFor:n.addressLineOne,children:Object(y.jsx)(Qi,{control:m.Input,id:n.addressLineOne,name:n.addressLineOne})}),Object(y.jsx)(m.Form.Field,{label:t.city,labelFor:n.city,children:Object(y.jsx)(Qi,{control:m.Input,id:n.city,name:n.city})})]})};G0.defaultProps={errorIcon:!1,setErrortext:""};var W0=G0,q0=n.p+"static/media/build-icon.fdbf56ed.svg",J0=function(e){return e.replace(/\D/g,"").replace(/^(\d{3})(\d{3})(\d{4})$/,"($1) $2-$3")},K0=function(e){var t,n=e.labelTitles,r=e.LabelInputs,c=e.divider,i=e.companies,o=e.isLoadingCompanies,s=Object(Zi.h)(),l=s.values,d=s.setFieldValue,u=Object(a.useState)(),j=Object(b.a)(u,2),p=j[0],f=j[1],v=Object(a.useState)(J0(null!==(t=l.phone)&&void 0!==t?t:"")),O=Object(b.a)(v,2),h=O[0],x=O[1];return Object(a.useEffect)((function(){var e=[{value:"\xa0",key:null}];null===i||void 0===i||i.forEach((function(t){return e.push({value:Object(y.jsxs)("div",{className:"flex flex-row items-center",children:[Object(y.jsx)("img",{src:q0,alt:t.name,style:{width:"24px",marginRight:"8px"}}),null===t||void 0===t?void 0:t.name]}),key:null===t||void 0===t?void 0:t.id})})),f(e)}),[i]),Object(y.jsxs)("div",{className:"flex flex-col w-126",children:[Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)(m.Form.Field,{label:n.phone,labelFor:r.phone,children:Object(y.jsx)(Qi,{control:m.Input,id:r.phone,name:r.phone,value:h,onChange:function(e){x(e.target.value)},onBlur:function(e){var t;x(J0(null!==(t=e.target.value)&&void 0!==t?t:"")),d("phone",e.target.value)}})}),c("w-6"),Object(y.jsx)(m.Form.Field,{label:n.company,labelFor:r.company,children:Object(y.jsx)(Qi,{control:m.Select,id:r.company,name:r.companyId,items:p,placeholder:o?"":"Loading...",type:"search",disabled:!o})})]}),Object(y.jsx)(m.Form.Field,{label:n.addressLineTwo,labelFor:r.addressLineTwo,children:Object(y.jsx)(Qi,{control:m.Input,id:r.addressLineTwo,name:r.addressLineTwo})}),Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)(m.Form.Field,{label:n.State,labelFor:r.State,children:Object(y.jsx)(Qi,{control:m.Select,items:Nl,id:r.State,name:r.State,placeholder:"Select State",type:"text"})}),c("w-6"),Object(y.jsx)(m.Form.Field,{label:n.zipCode,labelFor:r.zipCode,children:Object(y.jsx)(Qi,{control:m.Input,id:r.zipCode,name:r.zipCode})})]})]})},Q0=function(e){var t=e.handleSubmit,n=e.handleCancel,a=e.isDisabled,r=e.divider;return Object(y.jsxs)("div",{className:"h-16 flex flex-row justify-end border-t-2 px-6 items-center",children:[Object(y.jsx)(m.Button,{size:"lg",onClick:n,ghost:!0,children:"Cancel"}),r("w-4"),Object(y.jsx)(m.Button,{type:"primary",size:"lg",onClick:t,disabled:a,children:"Save Location"})]})},X0=function(e){var t=e.formInitialValues,n=e.schemaValidation,a=e._handleSubmit,r=e.handleCancel,c=e.isLoadingForm,i=e.labelSavingForm,o=e.isLoadingCompanies,s=e.companies,l=function(e){return Object(y.jsx)("div",{className:e})},d=!1,u=Object(Ru.a)(s?s.map((function(e){return{key:e.id,id:e.id,name:e.name,value:e.name}})):[],"value"),b="",j=function(e){d=!1,!1===!e?(d=""!==e&&e.length>45,b=d?"Must be 45 characters or less":""):(d=!0,b="Name is required")};return Object(y.jsx)("div",{className:"w-98/100 h-96/100 flex flex-col bg-white m-auto rounded-md shadow-card",children:Object(y.jsx)(Zi.e,{initialValues:t,validationSchema:n,onSubmit:a,children:function(e){var n=e.handleSubmit,a=e.values;return Object(y.jsx)(y.Fragment,{children:c?Object(y.jsxs)("div",{className:"h-full w-full flex flex-col justify-center items-center",children:[Object(y.jsx)("div",{children:Object(y.jsx)(m.Spinner,{size:"lg"})}),Object(y.jsx)("span",{className:"mt-4 text-base font-semibold",children:i})]}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex flex-col p-4 w-full h-full pt-8",children:[Object(y.jsx)("div",{className:"mx-auto w-180",children:Object(y.jsx)("span",{className:"text-3xl font-semibold",children:"Basic Info"})}),Object(y.jsxs)("div",{className:"flex flex-row justify-center",children:[Object(y.jsx)(W0,{labelTitles:Y0,LabelInputs:H0,divider:l,setValueSelected:j,errorIcon:d,setErrortext:b}),l("w-8"),Object(y.jsx)(K0,{labelTitles:Y0,LabelInputs:H0,divider:l,isLoadingCompanies:o,companies:u})]}),Object(y.jsx)("div",{className:"w-full h-10 mx-auto",style:{maxWidth:"96rem"},children:Object(y.jsx)(m.Form.Field,{label:Y0.notes,labelFor:H0.notes,children:Object(y.jsx)(Qi,{control:m.TextArea,id:H0.notes,name:H0.notes,style:{height:"100px",width:"100%"},editable:!0})})})]}),Object(y.jsx)(Q0,{handleSubmit:n,handleCancel:r,initialValues:t,isDisabled:""===a.name||d,divider:l})]})})}})})};X0.defaultProps={formInitialValues:{}};var $0,e1=X0,t1=function(e){var t=function(e){return""===e||"undefined"===typeof e?null:e};return Object(I.a)(Object(I.a)({},e),{},{name:t(e.name),email:t(e.email),addressLineOne:t(e.addressLineOne),city:t(e.city),phone:t(e.phone),company:t(e.company),addressLineTwo:t(e.addressLineTwo),state:t(e.state),zipCode:t(e.zipCode),notes:t(e.notes)})},n1=function(){var e=Object(p.h)(),t=Object(a.useContext)(ac),n=Object(b.a)(t,2),r=n[0],c=r.showToastSaleLocation,i=r.toastType,o=n[1],s=B0(),l=s.createSaleLocation,d=s.isLoadingCreateSaleLocation,u=Ro("worker/companies",["company.name"],0),j=u.loaded,f=u.items,m=u.setReload,v=Object(a.useState)(),O=Object(b.a)(v,2),h=O[0],x=O[1];Object(a.useEffect)((function(){x(c)}),[c]);return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(lo,{onOrganizationSelect:function(){m(!0)},hideCropSeasonDropdown:!0,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Create Sale Location",isLast:!0})}),Object(y.jsx)(e1,{formInitialValues:z0,schemaValidation:Z0,_handleSubmit:function(e){l(t1(e))},labelSavingForm:"Saving Location ...",handleCancel:function(){e.push("".concat(Cc.yieldV2,"/sale-locations"))},isLoadingForm:d,isLoadingCompanies:j,companies:f}),c&&Object(y.jsx)(U0,{showToast:h,setShowToast:function(e){jc(o,Wr,e)},state:i})]})},a1=function(e,t){return e.find((function(e){return e.id===t}))},r1=function(){var e=Object(p.h)(),t=Object(a.useContext)(ac),n=Object(b.a)(t,2),r=n[0],c=r.showToastSaleLocation,i=r.toastType,o=r.organization,s=n[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),u=d[0],j=d[1],f=Object(a.useState)({}),v=Object(b.a)(f,2),O=v[0],h=v[1],x=Object(p.j)().id,g=Object(a.useState)(),C=Object(b.a)(g,2),P=C[0],A=C[1],S=B0(),T=S.editSaleLocation,N=S.isLoadingCreateSaleLocation,E=S.isLoadingEditSaleLocation,w=S.getSaleLocationList,_=S.saleLocationList,R=Ro("worker/companies",["company.name"],0),D=R.loaded,k=R.items,L=R.setReload;Object(a.useEffect)((function(){j(!0);var e=null!==_&&void 0!==_&&_.length&&!N?a1(_,x):void 0;return e?(h((function(t){var n;return Object(I.a)(Object(I.a)(Object(I.a)({},t),e),{},{companyId:null===(n=e.company)||void 0===n?void 0:n.id})})),j(!1),function(){}):function(){}}),[_,x]),Object(a.useEffect)((function(){w(o.id)}),[]),Object(a.useEffect)((function(){A(c)}),[c]);return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(lo,{onOrganizationSelect:function(){L(!0)},hideCropSeasonDropdown:!0,disabled:!0,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Edit Sale Location",isLast:!0})}),u?Object(y.jsx)(m.Spinner,{size:"lg"}):Object(y.jsx)(e1,{formInitialValues:Object(I.a)(Object(I.a)({},z0),O),schemaValidation:Z0,_handleSubmit:function(e){T(x,t1(e))},handleCancel:function(){e.push("".concat(Cc.yieldV2,"/sale-locations"))},isLoadingForm:E,labelSavingForm:"Saving Changes",isLoadingCompanies:D,companies:k}),c&&Object(y.jsx)(U0,{showToast:P,setShowToast:function(e){jc(s,Wr,e)},state:i})]})},c1=function(e,t){return e.name.localeCompare(t.name)},i1=function(e){var t=Object(a.useState)(!1),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)(null),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useCallback)((function(){if(e){c(!0);var t=localStorage.getItem("selectedOrganizationId");J.a.get("".concat(u.e,"/yield/summary/crop-season/").concat(e,"/crops"),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:t}),Authorization:"Bearer ".concat(Ve())}}).then((function(e){var t=e.data;l(t.sort(c1))})).catch(Ae.default).finally((function(){return c(!1)}))}}),[e]);return Object(a.useEffect)((function(){d()}),[d]),{getCropsWithLoads:d,loading:r,crops:s}},o1=n(2838),s1=["title","titleId"];function l1(){return l1=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},l1.apply(this,arguments)}function d1(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function u1(e,t){var n=e.title,r=e.titleId,c=d1(e,s1);return a.createElement("svg",l1({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,$0||($0=a.createElement("path",{d:"M18 9.70498L16.59 8.29498L12 12.875L7.41 8.29498L6 9.70498L12 15.705L18 9.70498Z",fill:"#696F88"})))}var b1=a.forwardRef(u1);n.p;var j1=function(e,t){return e===t.value?t.label.replace(/ \(.*\)/,""):t.label},p1=[{label:"bushels (bu)",value:va.a.BUSHEL},{label:"pounds (lbs)",value:va.a.POUND},{label:"dry ounces (oz)",value:va.a.OUNCE},{label:"grams (g)",value:va.a.GRAM},{label:"hundredweights (cwt)",value:va.a.CWT},{label:"kilograms (kg)",value:va.a.KILOGRAM},{label:"metric tons (mt)",value:va.a.METRIC_TON},{label:"tons (t)",value:va.a.TON}],f1=function(e){var t=e.value,n=e.cropName,r=e.onChange,c=e.className,i=e.isRequired,o=e.minWidth,s=void 0===o?"165px":o,l=Object(a.useMemo)((function(){return kZ(n)}),[n]),d=t===va.a.BUSHEL&&l;return Object(y.jsxs)("div",{"data-testid":"uom-dropdown",className:"relative flex flex-col",style:{minWidth:s},children:[Object(y.jsx)(Xc.Select,{size:"middle",suffixIcon:Object(y.jsx)(b1,{}),onChange:r,value:t,dropdownMatchSelectWidth:!1,className:c,optionLabelProp:"label",required:i,children:p1.filter((function(e){return e.value!==va.a.BUSHEL||void 0!==l})).map((function(e){return Object(y.jsx)(Xc.Select.Option,{value:e.value,label:j1(t,e),children:e.label},e.value)}))}),Object(y.jsxs)("p",{className:"text-neutral text-neutral-60 tracking-tighter text-sm mt-1 ".concat(d?"visible":"invisible"),children:["1.00 bushel = ",l," lbs"]})]})};f1.defaultProps={value:"",cropName:"",className:"",isRequired:!1,minWidth:"165px"};var m1,v1=f1,O1=["title","titleId"];function h1(){return h1=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},h1.apply(this,arguments)}function x1(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function g1(e,t){var n=e.title,r=e.titleId,c=x1(e,O1);return a.createElement("svg",h1({width:18,height:18,viewBox:"0 0 18 18",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,m1||(m1=a.createElement("path",{d:"M4.12312 6.75L9 11.8492L13.8769 6.75L15.375 8.31984L9 15L2.625 8.31984L4.12312 6.75Z",fill:"currentColor"})))}var C1=a.forwardRef(g1),y1=(n.p,n(1682),function(e){var t=e.crops,n=e.value,r=e.onChange,c=e.isLoading,i=Object(a.useContext)(ac),o=Object(b.a)(i,2)[1];return null!==t&&void 0!==t&&t.length?Object(y.jsx)("div",{className:"commodity-dropdown",children:Object(y.jsx)(Xc.Select,{size:"middle",required:!0,suffixIcon:Object(y.jsx)(C1,{className:"text-info-dark-blue"}),onSelect:function(e){o({type:"SELECTED_YIELD_COMMODITY",payload:e}),r(e)},value:n,dropdownMatchSelectWidth:!1,bordered:!1,"data-testid":"commodity-dropdown",popupClassName:"commodity-drowpdown-options",loading:c,children:t.map((function(e){return Object(y.jsx)(Xc.Select.Option,{value:null===e||void 0===e?void 0:e.id,"data-testid":"crop-option-".concat(null===e||void 0===e?void 0:e.id),children:Object(y.jsxs)("div",{className:"flex items-center gap-2",children:[Object(y.jsx)("div",{className:"flex-shrink-0",children:Object(y.jsx)(Ag,{cropObject:e,size:32})}),Object(y.jsx)("div",{className:"crop-name truncate",children:null===e||void 0===e?void 0:e.name})]})},null===e||void 0===e?void 0:e.id)}))})}):null});y1.defaultProps={value:void 0,isLoading:!1};var P1=y1,A1=(n(1683),function(e){var t=e.selectedUOM,n=e.setUOM,r=e.selectedCropId,c=e.crops,i=e.setCropId,o=e.selectedCropName,s=e.isLoading,l=Object(p.h)(),d=Object(a.useContext)(ac),u=Object(b.a)(d,1)[0].isSidebarOpen,j=Object(a.useCallback)((function(e){var t;return void 0!==kZ(null===c||void 0===c||null===(t=c.find((function(t){return t.id===e})))||void 0===t?void 0:t.name)}),[c]),f=Object(a.useContext)(we),v=Object(a.useCallback)((function(e){i(e),localStorage.setItem("selectedCropId",e);var t=j(e);n(t?va.a.BUSHEL:va.a.POUND)}),[j,n,i]);return Object(a.useEffect)((function(){var e=localStorage.getItem("selectedCropId"),t=null===c||void 0===c?void 0:c.some((function(t){return t.id===e}));if(e&&t)v(e);else{var n=null===c||void 0===c?void 0:c[0];n&&v(n.id)}}),[c,v]),Object(y.jsxs)("div",{className:"flex justify-between items-start gap-2 pt-6 ".concat(u?"px-4":"px-14"),children:[Object(y.jsxs)("div",{children:[Object(y.jsxs)("div",{className:"flex flex-1 items-center gap-2 ",children:[Object(y.jsx)("h1",{className:"text-2xl leading-8 whitespace-no-wrap","data-testid":"page-heading",children:"Commodity Summary"}),Object(y.jsx)("div",{className:"flex-1",children:Object(y.jsx)(P1,{crops:c,value:r,onChange:v,withFormik:!1,isLoading:s})})]}),Object(y.jsxs)("div",{className:"flex gap-1 pt-6px",children:[Object(y.jsx)(o1.a,{className:"text-blue-60"}),Object(y.jsx)("p",{className:"text-neutral-1000",children:"Data is based on selected commodity and single crop season."})]})]}),Object(y.jsxs)("div",{className:"uom-btn-container flex gap-2 pt-2 justify-end",children:[Object(y.jsxs)("div",{className:"uom-container flex items-start gap-2",children:[Object(y.jsx)("p",{className:"whitespace-no-wrap mt-1",children:"Display data in"}),Object(y.jsx)(v1,{value:t,onChange:n,cropName:o})]}),Object(y.jsx)(m.Button,{icon:Object(y.jsx)(Ii.a,{}),type:"primary",onClick:function(){f.sendEventToAmplitude(f.events.epic.YieldV2.addYield.createYield),l.push("".concat(Cc.yieldV2,"/create?cropId=").concat(r))},children:Object(y.jsx)("span",{className:"whitespace-no-wrap",children:"Yield Loads"})})]})]})});A1.defaultProps={selectedSeason:void 0,selectedCropName:void 0,isLoading:!1};var S1,T1=A1,N1=["title","titleId"];function E1(){return E1=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},E1.apply(this,arguments)}function w1(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function _1(e,t){var n=e.title,r=e.titleId,c=w1(e,N1);return a.createElement("svg",E1({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,S1||(S1=a.createElement("g",{id:"yield_by"},a.createElement("path",{id:"Union",fillRule:"evenodd",clipRule:"evenodd",d:"M17.29 4.29L15 2H21V8L18.71 5.71L12.41 12L8.41 8L2.41 14L1 12.59L8.41 5.17L12.41 9.17L17.29 4.29ZM18.5782 22C18.3809 22 18.0521 21.9824 17.9494 21.9503L17.9462 21.9487C17.7248 21.8893 17.5772 21.7032 17.5772 21.4867C17.5772 21.4482 17.5821 21.4065 17.5917 21.3728L17.6109 21.2958L17.5355 21.2749C17.1971 21.1835 16.8891 20.999 16.6196 20.7247C16.2025 20.298 15.8849 19.6772 15.6491 18.8286C15.2304 17.3592 14.9545 16.8555 14.5807 16.2572C14.4556 16.0582 14.3513 15.9091 14.2679 15.7904L14.2671 15.7893C14.0784 15.519 14 15.4067 14 15.1936C14 15.0268 14.069 14.8696 14.1957 14.7509C14.3288 14.6257 14.5165 14.5568 14.7235 14.5568C14.916 14.5568 15.309 14.6177 15.8335 14.7878L15.933 14.8198L15.9394 14.7156C16.0244 13.2045 16.3212 11.7928 16.7736 10.7405C17.0094 10.1903 17.2805 9.76197 17.5772 9.46681C17.8868 9.15721 18.2205 9 18.5686 9C18.9167 9 19.2504 9.15721 19.56 9.46681C19.8567 9.76197 20.1262 10.1919 20.3636 10.7405C20.816 11.7928 21.1128 13.2061 21.1978 14.7204L21.2042 14.8247L21.3037 14.791C21.748 14.6434 22.125 14.5648 22.3977 14.5648C22.6463 14.5648 22.8485 14.6289 22.9848 14.7493C23.1051 14.8551 23.1693 15.0011 23.1693 15.1695C23.1693 15.3769 23.0662 15.5239 22.8807 15.7888L22.8773 15.7936L22.8642 15.8123L22.8641 15.8124C22.7719 15.9436 22.6595 16.1035 22.534 16.3101C21.9533 17.2389 21.7528 17.9287 21.4994 18.8013L21.4881 18.8382C21.2267 19.7446 20.9171 20.3525 20.5128 20.7504C20.2514 21.0054 19.961 21.1739 19.6225 21.2653L19.5487 21.2846L19.5648 21.3599C19.5744 21.4017 19.5792 21.4434 19.5792 21.4819C19.5792 21.7097 19.4348 21.8957 19.2103 21.9551L19.2071 21.9567C19.1268 21.9807 18.7707 22 18.5782 22ZM15.4742 15.8497C16.0389 16.7817 16.3164 17.5501 16.6051 18.5623C16.9548 19.7991 17.4265 20.4007 18.0473 20.4007C18.275 20.4007 18.8076 20.3108 18.8076 19.4863C18.8076 18.9762 18.5654 18.0907 17.8836 17.2742C17.4778 16.7865 16.7463 16.124 15.5672 15.731L15.3603 15.662L15.4742 15.8497ZM21.5619 15.7326C20.3989 16.1064 19.5985 16.7416 19.1317 17.2068L19.0867 17.2517L19.1188 17.3063C19.6145 18.1212 19.8471 19.0323 19.7765 19.8729L19.7541 20.1376L19.9193 19.929C20.1551 19.6323 20.354 19.1863 20.5273 18.5639C20.7743 17.6945 21.0294 16.8892 21.6534 15.8513L21.7641 15.6684L21.5619 15.7326ZM17.0703 13.4339C16.9885 14.0033 16.9404 14.6017 16.9308 15.208L16.9292 15.2562L16.9725 15.2786C17.5596 15.5962 18.0489 15.9684 18.429 16.3855L18.4852 16.4464L18.5445 16.3887C18.9456 16.0021 19.5022 15.6187 20.1535 15.2786L20.1968 15.2562V15.208C20.1968 14.9963 20.1872 14.7621 20.1695 14.5118L20.1647 14.4381H19.3482V13.6199H20.0765L20.0637 13.5285C20.0268 13.2558 19.9835 12.9895 19.9337 12.7377L19.9209 12.6719H19.0434V11.8538H19.7236L19.6931 11.7511C19.5407 11.2314 19.361 10.7966 19.1734 10.4919C18.9696 10.1598 18.7627 9.99297 18.5622 9.99297C18.3488 9.99297 18.1227 10.1903 17.9093 10.5624L17.8403 10.6827H18.498V11.3886H17.5468L17.5275 11.4431C17.4281 11.7287 17.3366 12.0671 17.2516 12.4473L17.2307 12.5452H18.097V13.3633H17.08L17.0703 13.4339ZM17.5821 15.1615V14.3434H18.6264V15.1615H17.5821ZM9.538 21.9617C9.61698 21.9864 9.86994 22 10.0217 22C10.1698 22 10.4437 21.9852 10.5054 21.9667L10.5079 21.9655C10.6806 21.9198 10.7917 21.7767 10.7917 21.6014C10.7917 21.5718 10.788 21.5397 10.7806 21.5077L10.7683 21.4497L10.825 21.4348C11.0854 21.3645 11.3087 21.2349 11.5099 21.0387C11.8208 20.7327 12.059 20.2651 12.2601 19.5679L12.2688 19.5395C12.4637 18.8682 12.618 18.3376 13.0647 17.6231C13.1612 17.4642 13.2476 17.3412 13.3186 17.2402L13.3287 17.2258L13.3313 17.2222C13.474 17.0184 13.5533 16.9053 13.5533 16.7458C13.5533 16.6162 13.5039 16.5039 13.4114 16.4225C13.3065 16.33 13.151 16.2806 12.9598 16.2806C12.75 16.2806 12.46 16.3411 12.1182 16.4546L12.0417 16.4805L12.0368 16.4003C11.9714 15.2354 11.7431 14.1483 11.3951 13.3388C11.2125 12.9168 11.0052 12.5861 10.7769 12.3591C10.5387 12.1209 10.2821 12 10.0143 12C9.74654 12 9.48988 12.1209 9.25173 12.3591C9.02344 12.5861 8.8149 12.9156 8.63351 13.3388C8.28554 14.1483 8.05725 15.2342 7.99185 16.3966L7.98692 16.4768L7.91041 16.4521C7.50691 16.3213 7.20459 16.2744 7.05651 16.2744C6.89733 16.2744 6.75296 16.3275 6.65054 16.4237C6.55306 16.5151 6.5 16.636 6.5 16.7643C6.5 16.9282 6.5603 17.0146 6.70549 17.2225L6.70607 17.2233C6.77024 17.3147 6.85044 17.4294 6.94669 17.5824C7.2342 18.0427 7.44644 18.4302 7.76851 19.5605C7.9499 20.2132 8.19422 20.6908 8.51505 21.019C8.72236 21.23 8.95928 21.3719 9.21964 21.4423L9.27764 21.4583L9.26283 21.5175C9.25543 21.5434 9.25173 21.5755 9.25173 21.6051C9.25173 21.7717 9.36525 21.9149 9.53553 21.9605L9.538 21.9617ZM8.50395 19.3556C8.28183 18.577 8.06836 17.9859 7.63401 17.269L7.5464 17.1246L7.70558 17.1777C8.61253 17.48 9.17522 17.9896 9.48741 18.3648C10.0118 18.9928 10.1982 19.674 10.1982 20.0664C10.1982 20.7006 9.7885 20.7697 9.61327 20.7697C9.13573 20.7697 8.77295 20.307 8.50395 19.3556ZM10.4474 18.3129C10.8065 17.9551 11.4223 17.4664 12.3169 17.1789L12.4724 17.1296L12.3872 17.2702C11.9072 18.0686 11.711 18.6881 11.521 19.3569C11.3877 19.8356 11.2347 20.1787 11.0533 20.407L10.9262 20.5674L10.9435 20.3638C10.9978 19.7172 10.8189 19.0163 10.4376 18.3894L10.4129 18.3475L10.4474 18.3129ZM8.75444 16.7754C8.76184 16.309 8.79886 15.8487 8.86179 15.4107L8.8692 15.3564H9.65153V14.727H8.98519L9.00123 14.6518C9.06663 14.3593 9.13697 14.099 9.21347 13.8793L9.22828 13.8374H9.96002V13.2944H9.45409L9.50715 13.2019C9.67127 12.9156 9.84526 12.7638 10.0094 12.7638C10.1636 12.7638 10.3228 12.8922 10.4795 13.1476C10.6239 13.382 10.7621 13.7164 10.8793 14.1162L10.9028 14.1952H10.3796V14.8245H11.0545L11.0644 14.8751C11.1027 15.0689 11.136 15.2737 11.1644 15.4835L11.1742 15.5538H10.614V16.1831H11.2421L11.2458 16.2399C11.2594 16.4324 11.2668 16.6125 11.2668 16.7754V16.8124L11.2335 16.8297C10.7325 17.0913 10.3043 17.3862 9.9958 17.6836L9.95014 17.728L9.90696 17.6811C9.61451 17.3603 9.23815 17.074 8.78652 16.8297L8.75321 16.8124L8.75444 16.7754ZM9.25543 16.1103V16.7396H10.0587V16.1103H9.25543ZM3.1266 21.9732C3.18188 21.9905 3.35896 22 3.4652 22C3.56885 22 3.76061 21.9896 3.8038 21.9767L3.80553 21.9758C3.92645 21.9439 4.00419 21.8437 4.00419 21.721C4.00419 21.7003 4.0016 21.6778 3.99642 21.6554L3.98778 21.6148L4.02751 21.6044C4.20977 21.5552 4.36611 21.4645 4.50691 21.3271C4.72458 21.1129 4.89128 20.7855 5.03208 20.2975L5.03813 20.2776C5.1746 19.8077 5.28257 19.4363 5.59526 18.9362C5.66284 18.8249 5.72334 18.7389 5.77301 18.6682L5.77303 18.6681L5.7801 18.6581L5.7819 18.6555C5.88183 18.5129 5.93731 18.4337 5.93731 18.3221C5.93731 18.2314 5.90276 18.1528 5.83798 18.0958C5.76456 18.031 5.65572 17.9964 5.52184 17.9964C5.375 17.9964 5.17201 18.0387 4.93275 18.1182L4.87919 18.1364L4.87574 18.0802C4.82996 17.2648 4.67016 16.5038 4.42658 15.9372C4.29874 15.6418 4.15362 15.4103 3.99383 15.2514C3.82712 15.0846 3.64746 15 3.46002 15C3.27258 15 3.09292 15.0846 2.92621 15.2514C2.76641 15.4103 2.62043 15.6409 2.49346 15.9372C2.24988 16.5038 2.09008 17.2639 2.0443 18.0776L2.04084 18.1338L1.98729 18.1165C1.70484 18.0249 1.49321 17.9921 1.38956 17.9921C1.27813 17.9921 1.17707 18.0292 1.10538 18.0966C1.03714 18.1605 1 18.2452 1 18.335C1 18.4497 1.04221 18.5102 1.14384 18.6558L1.14425 18.6563C1.18917 18.7203 1.24531 18.8006 1.31268 18.9077C1.51394 19.2299 1.66251 19.5011 1.88796 20.2923C2.01493 20.7493 2.18596 21.0835 2.41054 21.3133C2.55565 21.461 2.72149 21.5603 2.90375 21.6096L2.94435 21.6208L2.93398 21.6623C2.9288 21.6804 2.92621 21.7029 2.92621 21.7236C2.92621 21.8402 3.00567 21.9404 3.12487 21.9724L3.1266 21.9732ZM2.40276 20.1489C2.24728 19.6039 2.09785 19.1902 1.7938 18.6883L1.73248 18.5872L1.8439 18.6244C2.47877 18.836 2.87265 19.1927 3.09119 19.4553C3.45829 19.895 3.58872 20.3718 3.58872 20.6465C3.58872 21.0904 3.30195 21.1388 3.17929 21.1388C2.84501 21.1388 2.59106 20.8149 2.40276 20.1489ZM3.7632 19.4191C4.01456 19.1686 4.44558 18.8265 5.07181 18.6252L5.18065 18.5907L5.12105 18.6892C4.78504 19.248 4.6477 19.6816 4.51468 20.1498C4.42139 20.4849 4.31429 20.7251 4.18731 20.8849L4.09834 20.9972L4.11044 20.8546C4.14844 20.402 4.0232 19.9114 3.75629 19.4726L3.73902 19.4432L3.7632 19.4191ZM2.57811 18.3428C2.58329 18.0163 2.6092 17.6941 2.65326 17.3875L2.65844 17.3495H3.20607V16.9089H2.73963L2.75086 16.8562C2.79664 16.6515 2.84588 16.4693 2.89943 16.3155L2.9098 16.2862H3.42201V15.9061H3.06787L3.10501 15.8413C3.21989 15.6409 3.34168 15.5347 3.45656 15.5347C3.56453 15.5347 3.67596 15.6245 3.78566 15.8033C3.88672 15.9674 3.98346 16.2015 4.06552 16.4814L4.08193 16.5366H3.71569V16.9772H4.18818L4.19509 17.0126C4.22186 17.1482 4.24518 17.2916 4.26505 17.4384L4.27196 17.4877H3.87981V17.9282H4.31947L4.32206 17.9679C4.33156 18.1027 4.33674 18.2288 4.33674 18.3428V18.3687L4.31342 18.3808C3.96273 18.5639 3.663 18.7704 3.44706 18.9785L3.4151 19.0096L3.38487 18.9768C3.18016 18.7522 2.91671 18.5518 2.60057 18.3808L2.57724 18.3687L2.57811 18.3428ZM2.9288 17.8772V18.3177H3.49111V17.8772H2.9288Z",fill:"currentColor"}))))}var R1=a.forwardRef(_1),I1=(n.p,function(e){var t=e.header,n=e.footer,a=e.content,r=e.className,c=e.isLoading;return Object(y.jsxs)("div",{className:"flex flex-col bg-white shadow-card rounded-lg ".concat(r),children:[Object(y.jsx)("div",{className:"border-b border-solid border-neutral-20 h-14 flex flex-col justify-center",children:t}),c?Object(y.jsx)("div",{className:"flex items-center justify-center h-full w-full flex-1",children:Object(y.jsx)(m.Spinner,{size:"lg"})}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"flex-1",children:a}),Object(y.jsx)("div",{className:"border-t border-solid border-neutral-20 h-52px flex-col justify-center",children:n})]})]})});I1.defaultProps={header:null,footer:null,content:null,className:"",isLoading:!1};var D1=I1,k1=function(e){var t=e.cropSeasonId,n=e.cropId,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(null),l=Object(b.a)(s,2),d=l[0],j=l[1],p=Object(a.useCallback)((function(){if(t&&n){o(!0);var e=localStorage.getItem("selectedOrganizationId");J.a.get("".concat(u.e,"/yield/summary/total-yield?cropId=").concat(n,"&cropSeasonId=").concat(t),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:e}),Authorization:"Bearer ".concat(Ve())}}).then((function(e){var t=e.data;j(t)})).catch(Ae.default).finally((function(){return o(!1)}))}}),[t,n]);return Object(a.useEffect)((function(){p()}),[p]),{isLoading:i,totalYieldData:d}},L1=function(e){var t=e.cropId,n=Object(p.h)();return Object(y.jsxs)("div",{className:"flex items-center justify-between px-4 h-full",children:[Object(y.jsxs)("div",{className:"flex items-center gap-2",children:[Object(y.jsx)(R1,{className:"text-neutral-600"}),Object(y.jsx)("span",{className:"text-base leading-6 whitespace-no-wrap",children:"Total Yield"})]}),Object(y.jsx)("div",{className:"flex items-center",children:Object(y.jsx)(m.Button,{onClick:function(){n.push("".concat(Cc.yieldV2,"/loads?cropsFilters=").concat(t))},type:"outline",size:"md",dataTestId:"see-loads-btn",children:"See Loads"})})]})},F1=function(e){var t=e.selectedUOM,n=e.totalQuantity,r=e.area,c=e.selectedCropName,i=Object(a.useMemo)((function(){if(t===va.a.BUSHEL){var e=kZ(c);return n/e}return Object(va.f)(n,va.a.POUND,t)}),[n,t,c]),o=Object(a.useMemo)((function(){if(!r||!n)return 0;var e=n/r;return t===va.a.BUSHEL?e/kZ(c):Object(va.f)(e,va.a.POUND,t)}),[n,r,t,c]),s=i.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),l=o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});return c&&t?Object(y.jsxs)("div",{className:"py-4 px-8 flex items-stretch gap-6",children:[Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"text-neutral-600 whitespace-no-wrap",children:"Total quantity"}),Object(y.jsxs)("p",{className:"text-3xl leading-7 font-semibold whitespace-no-wrap",children:[s,Object(y.jsx)("span",{className:"ml-2px text-sm font-normal",children:Object(va.g)(t)})]})]}),Object(y.jsx)("div",{className:"w-1px bg-neutral-20 self-stretch"}),Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"text-neutral-600 whitespace-no-wrap",children:"Avg. quantity"}),Object(y.jsxs)("p",{className:"text-3xl leading-7 font-semibold whitespace-no-wrap",children:[l,Object(y.jsxs)("span",{className:"ml-2px text-sm font-normal",children:[Object(va.g)(t)," / ac"]})]})]}),Object(y.jsx)("div",{className:"w-1px bg-neutral-20 self-stretch"}),Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"text-neutral-600",children:"Area"}),Object(y.jsxs)("p",{className:"text-3xl leading-7 font-semibold whitespace-no-wrap",children:[r?r.toFixed(2):"0.00",Object(y.jsx)("span",{className:"ml-2px text-sm font-normal",children:"ac"})]})]})]}):null},M1=function(e){var t=e.cropZonesHarvested;return Object(y.jsxs)("div",{className:"flex pr-4 items-center justify-end h-full whitespace-no-wrap",children:[Object(y.jsx)("span",{className:"text-neutral-1000 mr-3",children:"Total boundaries harvested"}),Object(y.jsx)("span",{className:"text-xl font-semibold mr-1",children:t}),Object(y.jsx)("span",{className:"text-neutral-1000",children:"Crop Zones"})]})},V1=function(e){var t=e.selectedUOM,n=e.className,a=e.cropSeasonId,r=e.cropId,c=e.selectedCropName,i=k1({cropSeasonId:a,cropId:r}),o=i.totalYieldData,s=i.isLoading,l=o||{},d=l.totalQuantity,u=l.avgQuantity,b=l.area,j=l.cropZonesHarvested;return t?Object(y.jsx)(D1,{header:Object(y.jsx)(L1,{cropId:r}),content:Object(y.jsx)(F1,{selectedUOM:t,totalQuantity:d,avgQuantity:u,area:b,selectedCropName:c}),footer:Object(y.jsx)(M1,{cropZonesHarvested:j}),className:n,isLoading:s}):null};V1.defaultProps={className:"",cropSeasonId:null,cropId:null},M1.defaultProps={cropZonesHarvested:null},F1.defaultProps={totalQuantity:null,area:null,selectedCropName:null};var B1=V1,U1=n(818),z1=n.n(U1),Z1=function(e){var t=e.cropSeasonId,n=e.cropId,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(null),l=Object(b.a)(s,2),d=l[0],j=l[1],p=Object(a.useCallback)((function(){if(t&&n){o(!0);var e=localStorage.getItem("selectedOrganizationId");J.a.get("".concat(u.e,"/yield/summary/gross-revenue?cropId=").concat(n,"&&cropSeasonId=").concat(t),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:e}),Authorization:"Bearer ".concat(Ve())}}).then((function(e){var t=e.data;j(t)})).catch(Ae.default).finally((function(){return o(!1)}))}}),[t,n]);return Object(a.useEffect)((function(){p()}),[p]),{isLoading:i,revenueData:d}},Y1=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),H1=function(){return Object(y.jsxs)("div",{className:"h-full flex items-center justify-between px-4",children:[Object(y.jsxs)("div",{className:"flex items-center gap-2",children:[Object(y.jsx)(rX.a,{className:"text-neutral-600"}),Object(y.jsx)("span",{className:"text-base leading-6 whitespace-no-wrap",children:"Gross Revenue"})]}),Object(y.jsxs)("div",{className:"flex items-center gap-0.5 space-x-0 text-figma-blue-60 hover:text-figma-blue-70",children:[Object(y.jsx)(z1.a,{className:"cursor-pointer"}),Object(y.jsx)(Xc.Tooltip,{title:"Gross Revenue is the combined revenue for all loads sent to sale locations",trigger:"click",children:Object(y.jsx)("span",{className:"whitespace-no-wrap text-xs cursor-pointer",children:"What is this?"})})]})]})},G1=function(e){var t=e.grossRevenue;return Object(y.jsx)("div",{className:"p-4 text-center",children:Object(y.jsx)("span",{className:"font-semibold text-5xl leading-54px",children:Y1.format(t)})})},W1=function(e){var t=e.avgPrice,n=e.selectedUOM;return Object(y.jsxs)("div",{className:"h-full flex pr-4 items-center justify-end",children:[Object(y.jsx)("span",{className:"text-neutral-1000 mr-3",children:"Avg. price"}),Object(y.jsx)("span",{className:"text-xl font-semibold mr-2px",children:null===t?"---":Y1.format(t)}),Object(y.jsxs)("span",{className:"text-neutral-1000",children:["/ ",n]})]})},q1=function(e){var t=e.selectedUOM,n=e.className,r=e.selectedCropName,c=e.cropSeasonId,i=e.cropId,o=Z1({cropSeasonId:c,cropId:i}),s=o.revenueData,l=o.isLoading,d=s||{grossRevenue:0,avgPrice:null},u=d.grossRevenue,b=d.avgPrice,j=Object(a.useMemo)((function(){if(!b)return null;if("bushel"===t){var e=kZ(r);return e||(console.error("No bushel/lbs conversion found for crop:",r),e=60),b*e}var n=Object(va.f)(1,va.a.POUND,t);return b/n}),[t,b,r]);return r&&t?Object(y.jsx)(D1,{header:Object(y.jsx)(H1,{}),footer:Object(y.jsx)(W1,{avgPrice:j,selectedUOM:Object(va.g)(t)}),content:Object(y.jsx)(G1,{grossRevenue:u}),className:n,isLoading:l}):null};q1.defaultProps={cropSeasonId:null,cropId:null,className:""},W1.defaultProps={avgPrice:null};var J1=q1,K1={highest_quantity:{sortBy:"quantity",sortDir:"desc"},lowest_quantity:{sortBy:"quantity",sortDir:"asc"},highest_revenue:{sortBy:"revenue",sortDir:"desc"},lowest_revenue:{sortBy:"revenue",sortDir:"asc"}},Q1=function(e){var t=e.cropSeasonId,n=e.cropId,r=Object(a.useContext)(ac),c=Object(b.a)(r,2)[1],i=Object(a.useState)(!1),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(null),j=Object(b.a)(d,2),p=j[0],f=j[1],m=Object(a.useState)({sortBy:"quantity",sortDir:"desc"}),v=Object(b.a)(m,2),O=v[0],h=v[1];Object(a.useEffect)((function(){if(n&&t){l(!0);var e=localStorage.getItem("selectedOrganizationId");J.a.get("".concat(u.e,"/yield/summary/sale?cropId=").concat(n,"&cropSeasonId=").concat(t,"&sortBy=").concat(O.sortBy,"&sortDir=").concat(O.sortDir),{headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:e}),Authorization:"Bearer ".concat(Ve())}}).then((function(e){f((null===e||void 0===e?void 0:e.data)||null)})).catch((function(e){return uc(c)(e)})).finally((function(){return l(!1)}))}}),[O,c,t,n]);return{loading:s,onSortChange:function(e){h(K1[e])},salesSummary:p}},X1=[{label:"Highest quantity",value:"highest_quantity"},{label:"Lowest quantity",value:"lowest_quantity"},{label:"Highest revenue",value:"highest_revenue"},{label:"Lowest revenue",value:"lowest_revenue"}],$1=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"});function e2(e){var t=e.cropSeasonId,n=e.cropId,r=e.className,c=e.selectedUOM,i=e.selectedCropName,o=e.selectedCropId,s=Object(p.h)(),l=Object(a.useState)("highest_quantity"),d=Object(b.a)(l,2),u=d[0],f=d[1],v=Q1({cropSeasonId:t,cropId:n}),O=v.loading,h=v.onSortChange,x=v.salesSummary,g=Object(a.useCallback)((function(e){var t;c===va.a.BUSHEL?t=e/kZ(i):t=Object(va.f)(e,va.a.POUND,c);return t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}),[c,i]),C=Object(a.useMemo)((function(){var e;return x?{saleCount:x.saleCount,totalSoldQuantity:g(x.totalSoldQuantity),sales:null===(e=x.sales)||void 0===e?void 0:e.map((function(e){return{id:e.id,name:e.name,soldQuantity:g(e.soldQuantity),grossRevenue:$1.format(e.grossRevenue)}}))}:{saleCount:0,totalSoldQuantity:0,sales:[]}}),[x,g]);return Object(y.jsx)(D1,{className:r,isLoading:O,header:Object(y.jsxs)("div",{className:"flex justify-between py-3 px-4",children:[Object(y.jsxs)("div",{className:"flex gap-2 items-center",children:[Object(y.jsx)("img",{src:UZ,alt:"Sale icon"}),Object(y.jsx)("div",{className:"text-base whitespace-no-wrap",children:"Sale Locations"})]}),Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("div",{className:"text-sm text-neutral mr-2 whitespace-no-wrap",children:"Sort by"}),Object(y.jsx)("div",{className:"mr-6",children:Object(y.jsx)(Xc.Select,{size:"middle",suffixIcon:Object(y.jsx)(b1,{}),onChange:function(e){f(e),h(e)},value:u,className:"w-160px",children:X1.map((function(e){return Object(y.jsx)(Xc.Select.Option,{value:e.value,label:e.label,className:"whitespace-no-wrap",children:e.label},e.value)}))})}),Object(y.jsx)(m.Button,{onClick:function(){s.push("".concat(Cc.yieldV2,"/loads?cropsFilters=").concat(o,"&filters=").concat(JSON.stringify({loadtype:[{sourceType:"CROP_ZONE",destinationType:"SALE"},{sourceType:"STORAGE",destinationType:"SALE"}]})))},type:"outline",size:"md",children:Object(y.jsx)("span",{className:"whitespace-no-wrap",children:"See Loads in Sale"})})]})]}),content:Object(y.jsxs)("div",{className:"flex flex-col px-8 py-4",children:[Object(y.jsxs)("div",{className:"mb-4",children:["You have loads in ",C.saleCount," Sale Locations."]}),Object(y.jsx)("div",{className:"flex gap-6",children:C.sales.map((function(e){var t=e.id,n=e.name,a=e.grossRevenue,r=e.soldQuantity;return Object(y.jsx)(j.b,{to:"".concat(Cc.yieldV2,"/sale-locations?saleId=").concat(t),className:"hover:text-black",children:Object(y.jsxs)("div",{className:"flex flex-col gap-2 border-1 rounded-lg border-neutral-20 p-4 min-w-165px cursor-pointer hover:bg-selectedBlue",children:[Object(y.jsxs)("div",{className:"flex gap-2 items-center",children:[Object(y.jsx)("img",{src:UZ,alt:"Sale icon"}),Object(y.jsx)("div",{className:"text-base",children:n})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-xs text-neutral",children:"Gross Revenue"}),Object(y.jsx)("div",{className:"text-sm",children:a})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"text-xs text-neutral",children:"Sold Quantity"}),Object(y.jsxs)("div",{className:"text-sm ",children:[r," ",Object(va.g)(c)]})]})]},t)},t)}))})]}),footer:Object(y.jsxs)("div",{className:"flex justify-end items-center py-3 px-4",children:[Object(y.jsx)("div",{className:"text-sm mr-3",children:"Total quantity sold"}),Object(y.jsx)("div",{className:"text-lg mr-1 font-semibold",children:C.totalSoldQuantity}),Object(y.jsx)("div",{className:"text-sm",children:Object(va.g)(c)})]})})}e2.defaultProps={className:""};var t2=e2,n2=function(e){var t=e.value,n=Math.max(Math.min(t,99.99999),.01),a=[{percentage:n,color:"#31B4F2",key:"used"},{percentage:100-n,color:"#4D5165",key:"free"}].map((function(e,t){var a=e.percentage,r=e.color,c=e.key,i=0===t?0:3.6*n,o=L$({startAngle:i,endAngle:i+3.6*a,innerRadius:"free"===c?70:60,outerRadius:"free"===c?80:90});return Object(y.jsx)("path",{d:o,fill:r},c)}));return Object(y.jsxs)("div",{className:"w-160px h-160px relative",children:[Object(y.jsx)("svg",{"data-value":t,viewBox:"0 0 200 200",className:"w-full h-full",children:a}),Object(y.jsx)("div",{className:"absolute left-0 top-0 right-0 bottom-0 flex items-center justify-center",children:Object(y.jsxs)("div",{className:"text-2xl",children:[+t.toFixed(),"%"]})})]})},a2=function(e){var t=e.cropName,n=e.chartValue,a=e.totalValue,r=e.totalUnit,c=e.storageLocationsCount,i=e.onSeeLoadsClick,o=e.isLoading,s=e.className;return Object(y.jsx)(D1,{className:s,isLoading:o,header:Object(y.jsxs)("div",{className:"flex justify-between py-3 px-4 items-center",style:{whiteSpace:"nowrap"},children:[Object(y.jsxs)("div",{className:"flex gap-2 items-center",children:[Object(y.jsx)("img",{className:"h-6 w-6",alt:"Field Icon",src:zZ}),Object(y.jsx)("div",{className:"text-base whitespace-no-wrap",children:"Storage Locations"})]}),Object(y.jsx)("div",{className:"flex-1"}),Object(y.jsx)(m.Button,{type:"outline",size:"md",onClick:i,children:Object(y.jsx)("span",{className:"whitespace-no-wrap",children:"See Loads in Storage"})})]}),content:Object(y.jsxs)("div",{className:"flex flex-col",children:[Object(y.jsxs)("div",{className:"mt-4 ml-8",children:["You have loads in ",c," Storage Location",1!==c?"s":"","."]}),c>0&&Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsxs)("div",{className:"ml-8 mt-8",children:[Object(y.jsx)("div",{className:"leading-5 font-semibold text-sm text-neutral",children:"YIELD IN STORAGE"}),Object(y.jsxs)("div",{className:"flex my-2",children:[Object(y.jsx)("div",{className:"w-18px h-18px bg-blue-40 rounded-sm"}),Object(y.jsx)("div",{className:"ml-2 text-sm text-black",children:t})]}),Object(y.jsx)("div",{className:"mt-2"}),Object(y.jsxs)("div",{className:"flex my-2",children:[Object(y.jsx)("div",{className:"w-18px h-18px bg-neutral-70 rounded-sm"}),Object(y.jsx)("div",{className:"ml-2 text-sm text-black",children:"All Other Crops"})]})]}),Object(y.jsx)("div",{className:"flex-1"}),Object(y.jsx)("div",{className:"mr-4 mt-4",children:Object(y.jsx)(n2,{value:n})})]})]}),footer:Object(y.jsxs)("div",{className:"flex items-center py-3 px-4 justify-end",children:[Object(y.jsx)("div",{className:"text-sm mr-3",children:"Total quantity stored"}),Object(y.jsx)("div",{className:"text-lg mr-1 font-semibold",children:a}),Object(y.jsx)("div",{className:"text-sm",children:Object(va.g)(r)})]})})},r2=function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2),n=t[0].organization,r=t[1],c=Object(a.useState)(null),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),j=d[0],p=d[1];return{loading:j,fetchStorageLocationsSummary:Object(a.useCallback)((function(e){var t=e.cropId,a=e.seasonId;p(!0);var c={headers:{"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:n.id}),Authorization:"Bearer ".concat(Ve())},params:{cropSeasonId:a,cropId:t}};J.a.get("".concat(u.e,"/yield/summary/storage"),c).then((function(e){s(e.data),p(!1)})).catch(Ae.default).catch((function(e){uc(r)(e),p(!1)}))}),[r,n.id]),storageLocationsInfo:o}},c2=function(e){var t,n,r,c=e.cropId,i=e.cropName,o=e.seasonId,s=e.unit,l=e.className,d=Object(p.h)(),u=r2();Object(a.useEffect)((function(){c&&o&&u.fetchStorageLocationsSummary({cropId:c,seasonId:o})}),[c,o]);var b=Object(a.useCallback)((function(e){var t;s===va.a.BUSHEL?t=e/kZ(i):t=Object(va.f)(e,va.a.POUND,s);return t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}),[s,i]);return Object(y.jsx)(a2,{className:l,isLoading:u.loading,cropName:i,chartValue:+(100*(null===(t=u.storageLocationsInfo)||void 0===t?void 0:t.cropPercentage)).toFixed(),storageLocationsCount:null===(n=u.storageLocationsInfo)||void 0===n?void 0:n.storageCount,totalValue:b(null===(r=u.storageLocationsInfo)||void 0===r?void 0:r.totalQuantityStored),totalUnit:s,onSeeLoadsClick:function(){d.push("".concat(Cc.yieldV2,"/loads?cropsFilters=").concat(c,"&filters=").concat(JSON.stringify({loadtype:[{sourceType:"CROP_ZONE",destinationType:"STORAGE"},{sourceType:"STORAGE",destinationType:"STORAGE"}]})))}})},i2=n.p+"static/media/no-crop-season-selected.c9dec1ba.svg",o2=function(e){var t=e.hasNoCropsinSelectedSeason,n=e.hasNoLoadsForSelectedCrop,r=e.hasNoCropSeasons,c=Object(p.h)(),i=Object(a.useContext)(we);return t?Object(y.jsx)(jw,{title:"No Crop Zones Found",message:"Create a crop zone to proceed with adding Yield Loads.",overlayIcon:Of,button:Object(y.jsx)(m.Button,{type:"primary",onClick:function(){return c.push(Cc.properties)},children:"Go To Properties"}),dataTestId:"empty-view-no-crop-zones"}):n?Object(y.jsx)(jw,{title:"No Yield Data Found",message:"Add a new Yield Load or change the selected season.",overlayIcon:pw,button:Object(y.jsx)(m.Button,{icon:Object(y.jsx)(Ii.a,{}),type:"primary",onClick:function(){i.sendEventToAmplitude(i.events.epic.YieldV2.addYield.createYield),c.push("".concat(Cc.yieldV2,"/create"))},children:Object(y.jsx)("span",{className:"whitespace-no-wrap",children:"Yield Loads"})}),dataTestId:"empty-view-no-yield-loads"}):r?Object(y.jsx)(jw,{title:"No Crop Seasons Found",message:"Create a crop season and crop zones to proceed with adding Yield Loads.",overlayIcon:i2,button:Object(y.jsx)(m.Button,{type:"primary",onClick:function(){return c.push(Cc.cropSeasons)},children:"Go to Crop Season"}),dataTestId:"empty-view-no-crop-seasons"}):null},s2=function(){var e,t=Object(a.useContext)(ac),n=Object(b.a)(t,2),r=n[0].isSidebarOpen,c=n[1],i=dd().cropSeasons,o=JSON.parse(localStorage.getItem("selectedCropSeasons")),s=null===o||void 0===o?void 0:o[0];Object(a.useEffect)((function(){if((null===o||void 0===o?void 0:o.length)>1&&void 0!==i){var e,t=i.filter((function(e){return o.includes(e.id)})),n=null===t||void 0===t||null===(e=t[0])||void 0===e?void 0:e.id;localStorage.setItem("selectedCropSeasons",JSON.stringify([n]));var a=i.map((function(e){return e.id===n?Object(I.a)(Object(I.a)({},e),{},{active:!0}):Object(I.a)(Object(I.a)({},e),{},{active:!1})}));c({type:Or,payload:a})}}),[o,s,i,c]);var l=Object(a.useMemo)((function(){return(null===i||void 0===i?void 0:i.find((function(e){return(null===e||void 0===e?void 0:e.id)===s})))||(null===i||void 0===i?void 0:i[0])}),[i,s]),d=i1(null===l||void 0===l?void 0:l.id),u=d.crops,j=d.isLoading,p=Object(a.useState)(),f=Object(b.a)(p,2),m=f[0],v=f[1],O=Object(a.useCallback)((function(e){return v(e)}),[]),h=Object(a.useMemo)((function(){var e;return null===u||void 0===u||null===(e=u.find((function(e){return e.id===m})))||void 0===e?void 0:e.name}),[m,u]),x=Object(a.useState)(),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useCallback)((function(e){return P(e)}),[]);return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(lo,{hideCropSeasonDropdown:!1,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Commodity Summary",isLast:!0})}),Object(y.jsx)("div",{className:"h-full xl:max-h-full flex flex-col",children:null!==u&&void 0!==u&&u.length?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(T1,{selectedUOM:C,setUOM:A,selectedCropId:m,crops:u,setCropId:O,selectedCropName:h,isLoading:j}),Object(y.jsxs)("div",{className:"flex flex-col gap-4 ".concat(r?"p-4":"px-14 py-4"),children:[Object(y.jsxs)("div",{className:"flex flex-col gap-4 xl:flex-row",children:[Object(y.jsx)(J1,{selectedUOM:C,className:"min-w-360px w-2/5 h-195px",selectedCropName:h,cropSeasonId:null===l||void 0===l?void 0:l.id,cropId:m}),Object(y.jsx)(B1,{className:"min-w-592px w-3/5 h-195px",selectedUOM:C,selectedCropName:h,cropSeasonId:null===l||void 0===l?void 0:l.id,cropId:m})]}),Object(y.jsxs)("div",{className:"flex flex-col gap-4 xl:flex-row",children:[Object(y.jsx)(c2,{className:"min-w-372px w-1/3 h-330px",cropId:m,cropName:h,seasonId:null===l||void 0===l?void 0:l.id,unit:C}),Object(y.jsx)(t2,{cropSeasonId:s,cropId:m,className:"min-w-580px w-2/3 h-330px",selectedUOM:C,selectedCropName:h,selectedCropId:m})]})]})]}):Object(y.jsx)("div",{"data-testid":"empty-summary",className:"my-6 mx-4 py-20 bg-white rounded-lg shadow-sm-card border-1 border-neutral-30",children:Object(y.jsx)(o2,{hasNoCropsinSelectedSeason:0===(null===l||void 0===l||null===(e=l.cropZoneIds)||void 0===e?void 0:e.length),hasNoLoadsForSelectedCrop:0===(null===u||void 0===u?void 0:u.length),hasNoCropSeasons:0===(null===i||void 0===i?void 0:i.length)})})})]})},l2=function(e){var t=e.crops,n=e.selectedCropId,r=e.onCropChange,c=e.disabled,i=Object(a.useState)(n),o=Object(b.a)(i,2),s=o[0],l=o[1];Object(a.useEffect)((function(){l(n)}),[n]);return t&&n?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("label",{htmlFor:"crop-select",className:"text-neutral-60 tracking-tighter text-sm",children:"Crop"}),Object(y.jsx)(Xc.Select,{id:"crop-select",value:s,onSelect:function(e){r(e)},size:"middle",suffixIcon:Object(y.jsx)(b1,{}),className:"w-full",disabled:c,children:t.map((function(e){return Object(y.jsx)(Xc.Select.Option,{value:e.id,"data-testid":"crop-option-".concat(e.id),children:Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)(Ag,{cropObject:e}),Object(y.jsx)("div",{className:"ml-2",children:e.name})]})},e.id)}))})]}):null};l2.defaultProps={disabled:!1};var d2=l2,u2=function(e){var t=e.text;return Object(y.jsxs)("div",{className:"flex items-center justify-center flex-col gap-8",style:{height:"calc(100vh - 100px)"},children:[Object(y.jsx)("div",{children:Object(y.jsx)(m.Spinner,{})}),Object(y.jsx)("p",{className:"text-base font-semibold tracking-tight",children:t})]})};u2.defaultProps={text:""};var b2=u2,j2=function(){var e=new Date;return e.setHours(8,0,0,0),e},p2=n.p+"static/media/green-circle-check.840dd7c4.svg",f2=n.p+"static/media/warning-red.db39c5a5.svg",m2=(n(1684),function(e){var t,n,a=e.addAndCreateNew,r=e.type,c=e.modalVisible,i=e.setModalVisible,o=e.onSaveAllLoads,s=e.showCreateNewLoadWidget,l=Object(Zi.h)(),d=l.values,u=l.handleSubmit,b=l.validateForm,j=l.setFieldTouched,p=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("saveUnsaved"===r&&o(d),"overdrawnSource"!==r){e.next=14;break}if(!a){e.next=9;break}return u(),e.next=6,b();case 6:j("preventNavigation",!0),e.next=14;break;case 9:return u(),e.next=12,b();case 12:t=e.sent,0===Object.keys(t).length&&(s(),j("preventNavigation",!0));case 14:i(!1);case 15:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),f={saveUnsaved:{className:"save-all-modal",title:"Include Additional Load?",imgSrc:p2,imgAlt:"Check Circle",okText:"Yes, Save All Loads",cancelText:"No, Continue Editing",content:"A load was not added to the Loads List, but all required inputs were completed. Would you like to save this load with your submission?"},overdrawnSource:{className:"save-all-modal overdrawn-source",title:"Not Enough Yield in Storage",imgSrc:f2,imgAlt:"warning",okText:"Save Load",cancelText:"Cancel",content:"There is not enough yield in ".concat(null===d||void 0===d||null===(t=d.sources)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.name," to fulfill this load. Are you sure you want to save this load?")}},m=null===f||void 0===f?void 0:f[r];return m?Object(y.jsx)(Xc.Modal,{className:m.className,centered:!0,closable:!1,title:Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("img",{className:"mr-4",src:m.imgSrc,alt:m.imgAlt}),m.title]}),open:c,okText:m.okText,cancelText:m.cancelText,onOk:p,onCancel:function(){i(!1)},children:Object(y.jsx)("p",{className:"ml-4 font-normal text-sm",children:m.content})}):null});m2.defaultProps={addAndCreateNew:!1,showCreateNewLoadWidget:function(){},onSaveAllLoads:function(){}};var v2=m2,O2=function(e){var t=e.sourceType,n=e.source,a=e.load;return!!("STORAGE"===t&&n&&a&&null!==n&&void 0!==n&&n.capacity)&&Number(a)>Number(null===n||void 0===n?void 0:n.totalStoredLoad)},h2=function(e){var t=e.isDisabled,n=e.showCreateNewLoadWidget,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(Zi.h)(),p=j.handleSubmit,f=j.validateForm,v=j.setFieldValue,O=j.setFieldTouched,h=j.values,x=j.isValid,g=j.dirty,C=O2({sourceType:null===h||void 0===h?void 0:h.sourceType,source:null===h||void 0===h?void 0:h.sources[0],load:null===h||void 0===h?void 0:h.load}),P=function(){var e=Object(Y.a)(G.a.mark((function e(){var t;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!C){e.next=3;break}return o(!0),e.abrupt("return");case 3:return p(),e.next=6,f();case 6:t=e.sent,0===Object.keys(t).length&&(n(),O("preventNavigation",!0));case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),A=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!C){e.next=3;break}return o(!0),e.abrupt("return");case 3:return p(),e.next=6,f();case 6:O("preventNavigation",!0);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),S=t||!x||!g;return Object(y.jsxs)("div",{"data-testid":"add-yield-footer",className:"flex gap-4 py-3 px-6 justify-end w-full border-neutral-20 border-t-1",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:P,disabled:S,children:"Add to List"}),Object(y.jsx)(m.Button,{ghost:!0,type:"primary",onClick:function(){v("preventNavigation",!1),A(),u(!0)},disabled:S,children:"Add to List & Create New"}),Object(y.jsx)(v2,{showCreateNewLoadWidget:n,addAndCreateNew:d,type:"overdrawnSource",setModalVisible:o,modalVisible:i})]})};h2.defaultProps={isDisabled:!1,showCreateNewLoadWidget:function(){}};var x2=h2,g2=n.p+"static/media/source_properties.a94f5de2.svg",C2=function(e){var t=e.storageLocations,n=e.onSelectProperties,a=e.onCreateNewStorage,r=e.onChange,c=e.value,i=e.id,o=e.isLoading,s=Object(Zi.h)(),l=s.errors,d=s.touched,u=s.values;return Object(y.jsxs)(w0,{valueRenderer:function(){if("STORAGE"===u.sourceType)return Object(y.jsxs)("div",{className:"w-full h-full p-2 flex items-center",children:[Object(y.jsx)("img",{className:"h-4",alt:"Field Icon",src:zZ}),Object(y.jsx)("div",{className:"pl-2",children:c.map((function(e){return e.name})).join(" ")})]});if("CROP_ZONE"===u.sourceType){var e=1===c.length?"1 crop zone":"".concat(c.length," crop zones"),t="number"===typeof(null===u||void 0===u?void 0:u.totalArea)?"".concat(null===u||void 0===u?void 0:u.totalArea.toFixed(2)," ac"):null===u||void 0===u?void 0:u.totalArea;return Object(y.jsx)("div",{className:"w-full h-full p-2 flex align-center justify-start",children:Object(y.jsx)("div",{children:"".concat(e," | ").concat(t)})})}return null},value:c,bottomButtonText:"Create New Storage",onBottomButtonClick:a,onChange:r,id:i,isInvalid:void 0!==(null===l||void 0===l?void 0:l.sources)&&void 0!==(null===d||void 0===d?void 0:d.sources),isLoading:o,children:[Object(y.jsx)(w0.ClickableElement,{onItemClick:n,children:Object(y.jsxs)("div",{className:"w-full h-full text-green-600 flex justify-start items-center",children:[Object(y.jsx)("img",{className:"inline-block",alt:"select properties",src:g2}),Object(y.jsx)("span",{className:"inline-block pl-1",children:"Select Properties"})]})}),Object(y.jsx)("div",{className:"text-neutral-60 pb-2",children:"STORAGE"}),(null===t||void 0===t?void 0:t.length)>0?t.map((function(e){return Object(y.jsxs)("div",{className:"w-full h-full p-2 flex items-center",value:{type:"STORAGE",id:e.id,name:e.name,totalStoredLoad:e.totalStoredLoad,capacity:e.capacity},children:[Object(y.jsx)("img",{className:"h-4",alt:"Field Icon",src:zZ}),Object(y.jsx)("div",{className:"pl-2",children:e.name})]},e.id)})):Object(y.jsx)("div",{className:"pl-2",children:"No storage locations found"})]})};C2.defaultProps={value:null,id:"",isLoading:!1,storageLocations:[]};var y2=C2,P2=function(e){var t=e.storageLocations,n=e.saleLocations,a=e.onCreateNewLocation,r=e.onChange,c=e.value,i=e.id,o=e.isLoading,s=Object(Zi.h)(),l=s.errors,d=s.touched;return Object(y.jsxs)(w0,{valueRenderer:function(){return"STORAGE"===(null===c||void 0===c?void 0:c.type)?Object(y.jsxs)("div",{className:"w-full h-full p-2 flex items-center",children:[Object(y.jsx)("img",{className:"h-4",alt:"Field Icon",src:zZ}),Object(y.jsx)("div",{className:"pl-2",children:c.name})]}):"SALE"===(null===c||void 0===c?void 0:c.type)?Object(y.jsxs)("div",{className:"w-full h-full p-2 flex items-center",children:[Object(y.jsx)("img",{className:"h-4",alt:"Field Icon",src:UZ}),Object(y.jsx)("div",{className:"pl-2",children:c.name})]}):null},value:c,bottomButtonText:"Create New Location",onBottomButtonClick:a,onChange:r,id:i,isInvalid:void 0!==(null===l||void 0===l?void 0:l.destination)&&void 0!==(null===d||void 0===d?void 0:d.destination),isLoading:o,children:[Object(y.jsx)("div",{className:"text-neutral-60 py-2",children:"STORAGE"}),(null===t||void 0===t?void 0:t.length)>0?t.map((function(e){return Object(y.jsxs)("div",{className:"w-full h-full p-2 flex items-center",value:{type:"STORAGE",id:e.id,name:e.name},children:[Object(y.jsx)("img",{className:"h-4",alt:"Field Icon",src:zZ}),Object(y.jsx)("div",{className:"pl-2",children:e.name})]},e.id)})):Object(y.jsx)("div",{className:"text-neutral-60 mb-4 mt-2",children:"No storage locations found."}),Object(y.jsx)("div",{className:"text-neutral-60 py-2",children:"SALE"}),(null===n||void 0===n?void 0:n.length)>0?n.map((function(e){return Object(y.jsxs)("div",{className:"w-full h-full p-2 flex items-center",value:{type:"SALE",id:e.id,name:e.name},children:[Object(y.jsx)("img",{className:"h-4",alt:"Field Icon",src:UZ}),Object(y.jsx)("div",{className:"pl-2",children:e.name})]},e.id)})):Object(y.jsx)("div",{className:"text-neutral-60 mb-4 mt-2",children:"No sale locations found."})]})};P2.defaultProps={value:null,id:"",isLoading:!1,storageLocations:[],saleLocations:[]};var A2=P2,S2=(n(1685),function(){var e=Object(a.useContext)(ac),t=Object(b.a)(e,2),n=t[0].organization,r=t[1],c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Object(a.useState)(!1),d=Object(b.a)(l,2),j=d[0],p=d[1],f={"Content-Type":"application/json","cwf-context":JSON.stringify({organization_id:n.id}),Authorization:"Bearer ".concat(Ve())};return{createSaleLocation:function(e){return s(!0),J.a.post("".concat(u.e,"/yield/sale-location"),e,{headers:f}).then((function(e){var t,n;return{id:null===(t=e.data)||void 0===t?void 0:t.id,name:null===(n=e.data)||void 0===n?void 0:n.name}})).catch(Ae.default).catch((function(e){return uc(r)(e),!1})).finally((function(){return s(!1)}))},isCreateSaleLocationLoading:o,createStorageLocation:function(e){return p(!0),J.a.post("".concat(u.e,"/yield/storage-location"),e,{headers:f}).then((function(e){var t,n;return{id:null===(t=e.data)||void 0===t?void 0:t.id,name:null===(n=e.data)||void 0===n?void 0:n.name}})).catch(Ae.default).catch((function(e){return uc(r)(e),!1})).finally((function(){return p(!1)}))},isCreateStorageLocationLoading:j}}),T2=function(e){var t=e.handleChange,n=e.values,a=e.errors;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5",children:[Object(y.jsxs)("label",{htmlFor:"location-name",className:"text-neutral-60 tracking-tighter text-sm",children:["Name of Location",Object(y.jsx)("span",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Xc.Input,{required:!0,name:"name",id:"location-name",type:"default",size:"middle",value:n.name,onChange:t,status:(null===a||void 0===a?void 0:a.name)&&"error",caption:null===a||void 0===a?void 0:a.name})]}),Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-8",children:[Object(y.jsx)("label",{htmlFor:"capacity",className:"text-neutral-60 tracking-tighter text-sm",children:"Capacity"}),Object(y.jsx)(US,{fieldName:"capacity",type:"default",inputSuffix:Object(y.jsx)("span",{className:"text-sm text-gray-600",children:"bu by vol"}),id:"capacity",onControlledChange:t,isRequired:!1,round:O0}),Object(y.jsx)(Zi.a,{name:"capacity",component:"div",className:"text-remove"}),Object(y.jsxs)("div",{className:"flex gap-1 items-start",children:[Object(y.jsx)("img",{src:B_,alt:"Info icon",height:16,width:16,className:"mt-2px"}),Object(y.jsx)("div",{className:"text-xs text-neutral-60",children:"bu by vol = 1.25 cubic ft assuming standard moisture of stored crop"})]})]}),Object(y.jsx)("h3",{className:"text-base font-semibold block mb-4",children:"Basic Info"}),Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5",children:[Object(y.jsx)("label",{htmlFor:"email",className:"text-neutral-60 tracking-tighter text-sm",children:"Email Address"}),Object(y.jsx)(Xc.Input,{type:"default",size:"middle",name:"email",id:"email",value:n.email,onChange:t,status:(null===a||void 0===a?void 0:a.email)&&"error",caption:null===a||void 0===a?void 0:a.email})]}),Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5",children:[Object(y.jsx)("label",{htmlFor:"phone",className:"text-neutral-60 tracking-tighter text-sm",children:"Phone Number"}),Object(y.jsx)(Xc.Input,{type:"default",size:"middle",name:"phone",id:"phone",value:n.phone,onChange:t})]})]})},N2=function(e){var t=e.handleChange,n=e.values,r=e.setValues,c=e.errors,i=Object(a.useState)(!1),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Ro("worker/companies",["company.name"]),u=d.loaded,j=d.items;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-8",children:[Object(y.jsxs)("label",{htmlFor:"location-name",className:"text-neutral-60 tracking-tighter text-sm",children:["Name of Location",Object(y.jsx)("span",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Xc.Input,{required:!0,name:"name",id:"location-name",type:"default",size:"middle",value:n.name,onChange:t,status:(null===c||void 0===c?void 0:c.name)&&"error",caption:null===c||void 0===c?void 0:c.name})]}),Object(y.jsx)("h3",{className:"text-base font-semibold block mb-4",children:"Basic Info"}),Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5",children:[Object(y.jsx)("label",{htmlFor:"email",className:"text-neutral-60 tracking-tighter text-sm",children:"Email Address"}),Object(y.jsx)(Xc.Input,{type:"default",size:"middle",name:"email",id:"email",value:n.email,onChange:t,status:(null===c||void 0===c?void 0:c.email)&&"error",caption:null===c||void 0===c?void 0:c.email})]}),Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5",children:[Object(y.jsx)("label",{htmlFor:"phone",className:"text-neutral-60 tracking-tighter text-sm",children:"Phone Number"}),Object(y.jsx)(Xc.Input,{type:"default",size:"middle",name:"phone",id:"phone",value:n.phone,onChange:t})]}),Object(y.jsxs)("div",{className:"flex flex-col gap-1 mb-5",children:[Object(y.jsx)("label",{htmlFor:"company",className:"text-neutral-60 tracking-tighter text-sm",children:"Company"}),Object(y.jsx)(Xc.Select,{onChange:function(e){return r((function(t){return Object(I.a)(Object(I.a)({},t),{},{companyId:e})}))},onDropdownVisibleChange:function(e){return l(e)},suffixIcon:Object(y.jsx)("img",{src:Di,style:{transform:s?"rotate(180deg)":null},height:18,width:18,alt:"Select dropdown icon"}),loading:!u,children:null===j||void 0===j?void 0:j.map((function(e){return Object(y.jsx)(Xc.Select.Option,{value:e.id,children:e.name},e.id)}))})]})]})},E2=(n(1686),Fu.e().shape({name:Fu.f().required("Location name is required"),email:Fu.f().email("Email must be a valid email").nullable(),phone:Fu.f().nullable(),company:Fu.f().nullable(),capacity:S0("Capacity")})),w2=function(e){var t=e.open,n=e.onClose,r=e.onLocationAdded,c=e.isAddStorageOnly,i=Object(a.useState)(!1),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)("STORAGE"),u=Object(b.a)(d,2),j=u[0],p=u[1],f=S2(),m=f.createSaleLocation,v=f.isCreateSaleLocationLoading,O=f.createStorageLocation,h=f.isCreateStorageLocationLoading,x=Object(Zi.g)({initialValues:{},onSubmit:function(e){if("SALE"===j){var t={name:e.name,email:e.email,phone:e.phone,companyId:e.companyId};m(t).then((function(e){var t=e.id,a=e.name;t&&a&&(r("SALE",t,a),E(),n())}))}else{var a={name:e.name,capacity:e.capacity?Number(e.capacity):void 0,email:e.email,phone:e.phone};O(a).then((function(e){var t=e.id,a=e.name;t&&a&&(r("STORAGE",t,a),E(),n())}))}},validationSchema:E2}),g=x.errors,C=x.handleChange,P=x.values,A=x.setValues,S=x.submitForm,T=x.isValid,N=x.dirty,E=x.resetForm,w=function(){E(),n()},_=!T||!N;return Object(y.jsxs)(Xc.Drawer,{maskClosable:!0,open:t,className:"cwf-add-location-drawer",placement:"right",closable:!1,onClose:n,bodyStyle:{padding:0},footer:Object(y.jsxs)("div",{className:"flex justify-between",children:[Object(y.jsx)(Xc.Button,{type:"outline",onClick:w,children:"Cancel"}),Object(y.jsx)(Xc.Button,{disabled:_,className:"location-add-save-button",type:"primary",onClick:S,children:"Save"})]}),width:"472px",children:[Object(y.jsx)("div",{className:"relative",children:Object(y.jsx)("div",{className:"absolute top-0 right-0 m-3",children:Object(y.jsx)("button",{type:"button",onClick:w,children:Object(y.jsx)("img",{src:kS,alt:"Close icon",width:20,height:20})})})}),Object(y.jsxs)("div",{className:"px-8 py-6",children:[Object(y.jsxs)("div",{className:"flex gap-4 items-center mb-6","data-testid":"add-location-drawer-header",children:[Object(y.jsx)("h1",{className:"text-xl font-semibold block mb-0",children:c?"Quick Add a Storage Location":"Quick Add a Location"}),!c&&Object(y.jsxs)(Xc.Select,{className:"w-32",onChange:p,value:j,onDropdownVisibleChange:l,suffixIcon:Object(y.jsx)("img",{src:Di,style:{transform:s?"rotate(180deg)":null},height:18,width:18,alt:"Select dropdown icon"}),children:[Object(y.jsx)(Xc.Select.Option,{value:"STORAGE",children:Object(y.jsxs)("div",{className:"flex items-center gap-2",children:[Object(y.jsx)("img",{src:zZ,alt:"Storage icon",className:"h-15px"})," ","Storage"]})}),Object(y.jsx)(Xc.Select.Option,{value:"SALE",children:Object(y.jsxs)("div",{className:"flex items-center gap-2",children:[Object(y.jsx)("img",{src:UZ,alt:"Sale icon"})," Sale"]})})]})]}),v||h?Object(y.jsx)("div",{"data-testid":"add-location-loading",className:"flex items-center justify-center h-100",children:Object(y.jsx)(Xc.Spin,{})}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"w-300px mb-8",children:"STORAGE"===j?Object(y.jsx)(T2,{handleChange:C,values:P,errors:g}):Object(y.jsx)(N2,{handleChange:C,values:P,setValues:A,errors:g})}),Object(y.jsx)(Xc.Alert,{className:"items-center custom-info",description:"STORAGE"===j?"Add additional details by visiting Storage Locations after saving your loads.":"Add additional details by visiting Sale Locations after saving your loads.",type:"info",showIcon:!0})]})]})]})};w2.defaultProps={isAddStorageOnly:!1};var _2=w2,R2=n.p+"static/media/field_filled.5e172758.svg",I2=n.p+"static/media/divider.17af91bd.svg";function D2(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return t.map((function(t){return e.features.find((function(e){return e.properties.id===t}))})).filter(Boolean)}var k2=wc.a.shape({type:wc.a.string.isRequired,coordinates:wc.a.arrayOf(wc.a.arrayOf(wc.a.arrayOf(wc.a.number.isRequired))).isRequired}),L2=wc.a.shape({id:wc.a.string.isRequired,name:wc.a.string.isRequired}),F2=wc.a.shape({status:wc.a.number.isRequired,message:wc.a.string.isRequired,id:wc.a.string.isRequired,name:wc.a.string.isRequired,crops:wc.a.arrayOf(L2).isRequired,currency:wc.a.string.isRequired,active:wc.a.bool.isRequired}),M2=wc.a.shape({id:wc.a.string.isRequired,name:wc.a.string.isRequired,reportedArea:wc.a.number.isRequired,boundaryArea:wc.a.number.isRequired,geometry:k2.isRequired,cropSeasons:wc.a.arrayOf(F2).isRequired,crop:L2.isRequired,archived:wc.a.bool}),V2=wc.a.shape({id:wc.a.string.isRequired,name:wc.a.string.isRequired,geometry:k2.isRequired,cropzones:wc.a.arrayOf(M2).isRequired,boundaryArea:wc.a.number.isRequired,reportedArea:wc.a.number.isRequired,archived:wc.a.bool}),B2=(wc.a.shape({status:wc.a.number.isRequired,message:wc.a.string.isRequired,id:wc.a.string.isRequired,name:wc.a.string.isRequired,fields:wc.a.arrayOf(V2).isRequired,archived:wc.a.bool,selectedCropSeason:wc.a.arrayOf(wc.a.string.isRequired)}),wc.a.shape({type:wc.a.string,geometry:k2,properties:wc.a.object})),U2=(wc.a.shape({type:wc.a.string,features:wc.a.arrayOf(B2).isRequired}),function(e){var t=e.properties,n=e.setCropZonesChecked,a=e.cropZonesChecked;return Object(y.jsx)(Zx,{data:t,cropZonesChecked:a,setCropZonesChecked:n,disabled:!1})}),z2=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(""===t||void 0===t)return e;var n=t.toLowerCase();return e.filter((function(e){return e.name.toLowerCase().includes(n)||e.fields.some((function(e){var t;return e.name.toLowerCase().includes(n)||(null===e||void 0===e||null===(t=e.cropzones)||void 0===t?void 0:t.some((function(e){return e.name.toLowerCase().includes(n)})))}))}))},Z2=(n(1687),function(e){var t=e.open,n=e.onClose,r=e.type,c=$P(),i=Object(Zi.h)(),o=i.setFieldValue,s=i.values,l=Object(a.useContext)(ac),d=Object(b.a)(l,2),u=d[0],j=u.cropSeasons,p=u.searchTextValueFFT,f=d[1],O=Object(a.useState)([]),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)((null===s||void 0===s?void 0:s.cropZones)||[]),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useContext)(we),N=Object(a.useState)(Object(tF.c)(localStorage.getItem(Ab))),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Du(null===s||void 0===s?void 0:s.cropId).crops,D=rv({fetchType:gm,cropSeasonsId:c,isCacheOn:!0}),k=D.loading,L=D.dataSorted,F=D.fieldsAndAreasGeoJSONCollection,M=D.setGeoJSONCollectionFeatures,V=D.zoom,B=D.setZoom,U=D.fieldsLoading,z=D.filterFeatureCollectionByParentId,Z=D.reloadData,Y=Object(a.useMemo)((function(){return JSON.stringify(vj(F,x))}),[F,x]),H=Object(a.useMemo)((function(){var e,t;return w||(null===(e=JSON.parse(Y))||void 0===e||null===(t=e.geometry)||void 0===t?void 0:t.coordinates)}),[Y,w]);Object(a.useEffect)((function(){Z({seasonIds:c})}),[]),Object(a.useEffect)((function(){if(!k&&(null===A||void 0===A||!A.length)){var e=null===x||void 0===x?void 0:x.find((function(e){var t;return null===e||void 0===e||null===(t=e.fields)||void 0===t?void 0:t.some((function(e){var t;return(null===e||void 0===e||null===(t=e.cropzones)||void 0===t?void 0:t.length)>0}))}));e&&M(z(F,e.id))}}),[k,A,x]),Object(a.useEffect)((function(){var e=function(e,t,n){var a=function(e){return e.cropzones.filter((function(e){return(!n||e.crop.id===n)&&e.cropSeasons.some((function(e){return t.includes(e.id)}))}))};return e.map((function(e){var t=e.fields.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{cropzones:a(e)})}));return Object(I.a)(Object(I.a)({},e),{},{fields:t.filter((function(e){return e.cropzones.length>0}))})})).filter((function(e){return e.fields.length>0}))}(L.properties,c,null===s||void 0===s?void 0:s.cropId);g(e)}),[L,null===s||void 0===s?void 0:s.cropId]),Object(a.useEffect)((function(){!k&&null!==A&&void 0!==A&&A.length&&M(z(F,void 0,A.map((function(e){return{id:e}}))))}),[k,A]);var G=Object(a.useMemo)((function(){return Yh(D2(F,A))}),[A,F]),W=Object(a.useMemo)((function(){return z2(x,p.valueInput)}),[x,p]),q=Object(a.useCallback)((function(e){((null===e||void 0===e?void 0:e.features)||[]).forEach((function(e){var t;if("field"===(null===e||void 0===e||null===(t=e.properties)||void 0===t?void 0:t.$landType)){var n,a=JSON.parse(null===e||void 0===e||null===(n=e.properties)||void 0===n?void 0:n.cropzones);(null===a||void 0===a?void 0:a.length)>0&&S((function(e){return function(e,t){var n=t.map((function(e){return e.id}));return n.some((function(t){return!e.includes(t)}))?Object(v.a)(new Set([].concat(Object(v.a)(e),Object(v.a)(n)))):e.filter((function(e){return!n.includes(e)}))}(e,a)}))}}))}),[]);return Object(y.jsx)(Xc.Drawer,{width:"80%",open:t,onClose:n,bodyStyle:{overflow:"hidden"},className:"select-properties-drawer",children:k||U?Object(y.jsx)(m.Spinner,{}):Object(y.jsxs)("div",{children:[Object(y.jsxs)("header",{className:"flex flex-row mb-4",children:[Object(y.jsxs)("div",{className:"w-1/3 mr-6",children:[Object(y.jsx)("h1",{className:"font-semibold text-xl mb-1",children:"Select Properties"}),Object(y.jsx)("p",{className:"text-left text-sm font-normal leading-5 tracking-tighter text-neutral-60",children:"(choose from list or map)"})]}),Object(y.jsxs)("div",{className:"w-2/3",children:[Object(y.jsxs)("div",{className:"font-normal text-base",children:["Crop Season: ",j.filter((function(e){return $P().includes(e.id)})).map((function(e){return e.name})).join(", ")]}),Object(y.jsxs)("div",{className:"flex flex-row mt-1",children:[Object(y.jsx)("div",{className:"mr-1",children:"".concat(A.length," crop zone").concat(1===A.length?"":"s"," selected")}),Object(y.jsx)("img",{className:"mx-2",src:I2,alt:"divider icon"}),Object(y.jsx)("img",{className:"mx-1",src:R2,alt:"field icon"}),Object(y.jsxs)("div",{children:["Total area: ",G.toFixed(2)," ac"]})]})]})]}),Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsxs)("section",{className:"flex flex-col w-1/3 mr-6 tree-left-panel",children:["Load"===r&&Object(y.jsxs)("div",{className:"flex flex-col gap-y-2 mb-4",children:[Object(y.jsxs)("div",{className:"text-base flex items-center gap-x-1",children:["Crop: ",Object(y.jsx)(Ag,{cropObject:R}),null===R||void 0===R?void 0:R.name]}),Object(y.jsxs)("div",{className:"flex text-xs",children:[Object(y.jsx)("img",{className:"mr-1",src:B_,alt:"info icon"}),Object(y.jsx)("span",{children:"Only properties matching the selected crop are listed"})]})]}),Object(y.jsx)(CB,{drawer:!0,loadDetailsDrawer:!0,onChange:function(e){var t=e.target.value.toLowerCase();f({type:_r,payload:{valueInput:t}})},value:null===p||void 0===p?void 0:p.valueInput,placeholder:"Search Properties"}),Object(y.jsx)("div",{className:"font-semibold text-base mt-4",children:"PROPERTIES"}),Object(y.jsx)("div",{className:"flex-1 overflow-scroll",children:Object(y.jsx)(U2,{properties:W,cropZonesChecked:A,setCropZonesChecked:S,setGeoJSONCollectionFeatures:M,fieldsAndAreasGeoJSONCollection:F,fieldsLoading:U,filterFeatureCollectionByParentId:z},"selector-".concat(JSON.stringify(W)))})]}),Object(y.jsx)("section",{className:"w-2/3",children:Object(y.jsx)(mm,{fieldsLoading:U,geoJSONCollection:F,zoom:V,setZoom:B,currentCoordinates:H,setCurrentCoordinates:_,onClickShape:q,customStyles:A.length>0,stretch:!0,liveUpdate:!0,displayOnly:!0},"map-".concat(JSON.stringify(W)))}),Object(y.jsxs)("footer",{className:"absolute bottom-0 w-full right-0 left-0 flex justify-end items-center border-t border-neutral-20 p-2 gap-3",children:[Object(y.jsx)(m.Button,{ghost:!0,type:"outline",onClick:n,children:"Cancel"}),Object(y.jsx)(m.Button,{type:"primary",onClick:function(){o("cropZones",A),o("totalArea",G);var e=D2(F,A).map((function(e){return{id:e.properties.id,area:Hh([e])}}));o("sources",e),o("sourceType","CROP_ZONE"),T.sendEventToAmplitude(T.events.epic.YieldV2.addYield.saveProperties,{numberOfCrops:e.length}),n()},disabled:!(null!==A&&void 0!==A&&A.length),children:"Save Selection"})]})]})]})})});Z2.defaultProps={type:""};var Y2=Z2,H2=function(){var e=Object(a.useContext)(we),t=Object(a.useContext)(ac),n=Object(b.a)(t,1)[0].organization,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useState)(!1),p=Object(b.a)(j,2),f=p[0],v=p[1],O=T$(),h=B0(),x=Object(a.useState)(!1),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)([]),S=Object(b.a)(A,2),T=S[0],N=S[1];Object(a.useEffect)((function(){O.fetchStorageLocations().then((function(e){return N(e.data)}))}),[]),Object(a.useEffect)((function(){h.getSaleLocationList(n.id),P(!0)}),[]);var E=T&&C&&!h.isLoadingSaleLocationList,w=Object(Zi.f)("name"),_=Object(b.a)(w,2)[1],R=Object(Zi.h)(),I=R.values,D=R.setFieldValue;Object(a.useEffect)((function(){if(E){var e,t;if("STORAGE"===I.sourceType){var n,a=null===(n=I.sources[0])||void 0===n?void 0:n.id,r=null===T||void 0===T?void 0:T.find((function(e){return e.id===a}));r&&D("sources",[r])}if("CROP_ZONE"===I.sourceType&&I.sources.length){D("sources",I.sources);var c=I.sources.reduce((function(e,t){var n=t.area;return e+Number(void 0===n?0:n)}),0);D("totalArea",c),D("cropZones",I.sources.map((function(e){return e.id})))}if("STORAGE"===I.destinationType&&null!==(e=I.destination)&&void 0!==e&&e.id){var i,o,s=null===(i=I.destination)||void 0===i?void 0:i.id,l=null===T||void 0===T||null===(o=T.find((function(e){return e.id===s})))||void 0===o?void 0:o.name;D("destination",{id:s,name:l,type:"STORAGE"})}if("SALE"===I.destinationType&&null!==(t=I.destination)&&void 0!==t&&t.id){var d,u,b=null===(d=I.destination)||void 0===d?void 0:d.id,j=null===(u=h.saleLocationList.find((function(e){return e.id===b})))||void 0===u?void 0:u.name;D("destination",{id:b,name:j,type:"SALE"})}}}),[E]);var k=null===T||void 0===T?void 0:T.filter((function(e){var t;return!(null!==I&&void 0!==I&&null!==(t=I.sources)&&void 0!==t&&t.some((function(t){return(null===t||void 0===t?void 0:t.id)===e.id})))})),L=null===T||void 0===T?void 0:T.filter((function(e){var t;return e.id!==(null===I||void 0===I||null===(t=I.destination)||void 0===t?void 0:t.id)})),F=function(){u(!0),e.sendEventToAmplitude(e.events.epic.YieldV2.addYield.createNewSourceStorage,{page:"add yield load page"})};return Object(y.jsxs)("div",{children:[i&&Object(y.jsx)(Y2,{open:!0,onClose:function(){return o(!1)},type:"Load"}),Object(y.jsx)("h1",{className:"text-xl leading-7 font-semibold tracking-tight block mb-4",children:"Basic Info"}),Object(y.jsxs)(Xc.Row,{gutter:[24,24],prefixCls:"syt-antd-row",children:[Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsxs)("div",{className:"flex flex-col gap-1",children:[Object(y.jsxs)("label",{htmlFor:"load-name",className:"text-neutral-60 tracking-tighter text-sm",children:["Load Name",Object(y.jsx)("span",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Zi.b,{as:Xc.Input,name:"name",id:"load-name",size:"middle",type:"default",required:!0,className:_.error&&_.touched?"border border-remove":""}),Object(y.jsx)(Zi.a,{name:"name",component:"div",className:"text-remove"})]})}),Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[Object(y.jsxs)("label",{htmlFor:"source-select",className:"text-neutral-60 tracking-tighter text-sm",children:["Source",Object(y.jsx)("span",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Zi.b,{name:"sources",children:function(e){var t=e.field,n=e.form;return Object(y.jsx)(y2,{id:"source-select",value:t.value,storageLocations:L,onChange:function(e){var a=e.id,r=e.name,c=e.type,i=e.totalStoredLoad,o=e.capacity;n.setFieldValue("sourceType",c),n.setFieldValue(t.name,[{id:a,name:r,totalStoredLoad:i,capacity:o}])},onSelectProperties:function(){return o(!0)},isLoading:null===O||void 0===O?void 0:O.loading,onCreateNewStorage:F})}}),Object(y.jsx)(Zi.a,{name:"sources[0].id",component:"div",className:"text-remove"})]})}),Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[Object(y.jsxs)("label",{htmlFor:"destination-select",className:"text-neutral-60 tracking-tighter text-sm",children:["Destination",Object(y.jsx)("span",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Zi.b,{name:"destination",children:function(e){var t=e.field,n=e.form;return Object(y.jsx)(A2,{id:"destination-select",value:t.value,storageLocations:k,saleLocations:h.saleLocationList,onChange:function(e){return n.setFieldValue(t.name,e)},onCreateNewLocation:function(){return v(!0)},isLoading:(null===O||void 0===O?void 0:O.loading)||(null===h||void 0===h?void 0:h.isLoadingSaleLocationList)})}}),Object(y.jsx)(Zi.a,{name:"destination.id",component:"div",className:"text-remove"})]})}),Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[Object(y.jsxs)("label",{htmlFor:"date",className:"text-neutral-60 tracking-tighter text-sm",children:["Date & Time",Object(y.jsx)("span",{className:"text-remove",children:"*"})]}),Object(y.jsx)(Qi,{name:"date",control:m.DatePicker,enableTime:!0,dateFormat:"M j, Y h:i K"})]})})]}),Object(y.jsx)(_2,{open:f,onClose:function(){return v(!1)},onLocationAdded:function(e,t,a){"SALE"===e?(h.getSaleLocationList(n.id),D("destination",{id:t,name:a,type:e})):"STORAGE"===e&&O.fetchStorageLocations().then((function(n){N(n.data),D("destination",{id:t,name:a,type:e})}))}}),Object(y.jsx)(_2,{open:d,onClose:function(){return u(!1)},onLocationAdded:function(e,t,n){O.fetchStorageLocations().then((function(e){var a=e.data;N(a||[]);var r=(null===a||void 0===a?void 0:a.find((function(e){return e.id===t})))||{};D("sourceType","STORAGE"),D("sources",[{id:t,name:n,totalStoredLoad:r.totalStoredLoad||0,capacity:r.capacity||null}])}))},isAddStorageOnly:!0})]})},G2=(n(1688),function(e){var t=e.fieldsToWatch,n=e.updateFn,r=e.fieldToUpdate,c=Object(Zi.h)(),i=c.values,o=c.touched,s=c.setFieldValue,l=t.map((function(e){return i[e]})),d=Object(a.useMemo)((function(){return n(i)}),l);Object(a.useEffect)((function(){var e=t.some((function(e){return o[e]})),n=o[r];e&&!n&&s(r,d)}),[d,o])}),W2=n.p+"static/media/alert-exclamation.1372f4cb.svg",q2=function(e){var t=e.weightUnit,n=void 0===t?"":t,a=e.error;return Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)("span",{className:"text-neutral-60 tracking-tighter text-sm","data-testid":"weight-unit-info",children:n}),a?Object(y.jsx)("img",{className:"ml-1",src:W2,alt:"validation alert","data-testid":"validation-alert"}):null]})};q2.defaultProps={error:""};var J2=q2,K2=function(e){var t=parseFloat(e);return Number.isNaN(t)?null:t},Q2=function(e){var t=e.grossWeight,n=e.tareWeight;if(!t||!n)return null;var a=K2(t),r=K2(n);return null===a||null===r?null:FS.b.minusRound(a,r,O0)},X2=function(e){var t=e.grossWeight,n=e.netWeight;if(!t||!n)return null;var a=K2(t),r=K2(n);return null===a||null===r?null:FS.b.minusRound(a,r,O0)},$2=function(){var e=Object(Zi.h)(),t=e.values,n=e.errors,a=(t||{}).weightUnit;return G2({fieldsToWatch:["grossWeight","tareWeight"],updateFn:Q2,fieldToUpdate:"netWeight"}),G2({fieldsToWatch:["netWeight"],updateFn:X2,fieldToUpdate:"tareWeight"}),Object(y.jsxs)("div",{children:[Object(y.jsxs)("div",{className:"flex items-center gap-4 mb-4",children:[Object(y.jsx)("h1",{"data-testid":"outside-element",className:"text-xl leading-7 font-semibold tracking-tight",children:"Weight"}),Object(y.jsx)("div",{className:"text-info-dark-blue weight-dropdown",children:Object(y.jsx)(Zi.b,{name:"weightUnit",children:function(e){var t=e.field,n=e.form;return Object(y.jsx)(Xc.Select,{size:"middle",onChange:function(e){n.setFieldValue(t.name,e),n.validateField(t.name)},value:t.value,bordered:!1,suffixIcon:Object(y.jsx)(b1,{className:"dark-blue"}),className:"text-info-dark-blue",optionLabelProp:"label",dropdownMatchSelectWidth:!1,"data-testid":"select-weight-unit",children:v0.map((function(e){return Object(y.jsx)(Xc.Select.Option,{value:e.value,label:j1(t.value,e),children:e.label},e.value)}))})}})})]}),Object(y.jsxs)(Xc.Row,{gutter:[24,24],prefixCls:"syt-antd-row",children:[Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsxs)("div",{className:"flex flex-col gap-0.5 weight-input",children:[Object(y.jsx)("label",{htmlFor:"gross-weight",className:"text-neutral-60 tracking-tighter text-sm",children:"Gross Weight"}),Object(y.jsx)(US,{fieldName:"grossWeight",inputSuffix:Object(y.jsx)(J2,{weightUnit:a,error:null===n||void 0===n?void 0:n.grossWeight}),id:"gross-weight",round:O0})]})}),Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsxs)("div",{className:"flex flex-col gap-0.5 weight-input",children:[Object(y.jsx)("label",{htmlFor:"tare-weight",className:"text-neutral-60 tracking-tighter text-sm",children:"Tare Weight"}),Object(y.jsx)(US,{fieldName:"tareWeight",inputSuffix:Object(y.jsx)(J2,{weightUnit:a,error:null===n||void 0===n?void 0:n.tareWeight}),id:"tare-weight",round:O0})]})}),Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsxs)("div",{className:"flex flex-col gap-0.5 weight-input",children:[Object(y.jsx)("label",{htmlFor:"net-weight",className:"text-neutral-60 tracking-tighter text-sm",children:"Net Weight"}),Object(y.jsx)(US,{fieldName:"netWeight",inputSuffix:Object(y.jsx)(J2,{weightUnit:a,error:null===n||void 0===n?void 0:n.netWeight}),id:"net-weight",round:O0})]})}),null!==n&&void 0!==n&&n.netWeight||null!==n&&void 0!==n&&n.grossWeight||null!==n&&void 0!==n&&n.tareWeight?Object(y.jsx)(Xc.Alert,{"data-testid":"error-banner",className:"yield-load-alerts w-full ml-2",message:"Calculation error. Delete one value to reset auto-calculation.",showIcon:!0,type:"error"}):null]})]})},e4=function(e){var t=e.data,n=e.isEquipment,r=e.resetValue,c=e.initialValue,i=Object(a.useState)(c),o=Object(b.a)(i,2),s=o[0],l=o[1],d=Object(a.useState)(!1),u=Object(b.a)(d,2),j=u[0],p=u[1],f=Object(a.useRef)(null),v=Object(Zi.h)().setFieldValue,O=function(){return n?Object(y.jsx)("img",{className:"inline-block",alt:"equipment icon",src:MZ}):Object(y.jsx)("img",{className:"inline-block",alt:"person icon",src:vE})};return Object(a.useEffect)((function(){var e=function(e){f.current&&!f.current.contains(e.target)&&p(!1)};return document.addEventListener("click",e),function(){document.removeEventListener("click",e)}}),[]),Object(a.useEffect)((function(){r&&(l(void 0),v("TruckAndDriverFieldResetValue",!1))}),[r]),Object(y.jsxs)("div",{"data-testid":"drop-down-field",className:"w-full",ref:f,children:[Object(y.jsx)(m.Button,{onClick:function(){p(!j)},style:{width:"100%"},type:"outline",ghost:!0,children:Object(y.jsxs)("div",{className:"flex flex-row justify-between w-full relative bg-color",children:[Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)("div",{"data-testid":"drop-down-item-name",className:"mr-2",children:s?O():null}),null===s||void 0===s?void 0:s.name]}),Object(y.jsx)("img",{src:Di,alt:"Sort Icon"})]})}),j&&Object(y.jsx)("div",{className:" absolute bg-white mt-2 shadow-card rounded",style:{height:"180px",width:"calc(100% - 24px)",zIndex:1e4},children:Object(y.jsx)("div",{className:"w-full h-full flex flex-col justify-center",children:Object(y.jsx)("div",{className:"mt-2 pl-1 overflow-auto flex-1  w-full",children:(null===t||void 0===t?void 0:t.length)>0?t.map((function(e){return Object(y.jsx)(pu,{className:"h-6 gr-whitespace-nowrap",onClick:function(){p(!1),l(e),v(n?"truckId":"driverId",e.id)},children:Object(y.jsxs)("div",{className:"w-full h-full p-2 flex items-center",children:[O(),Object(y.jsx)("div",{"data-testid":"item-name",className:"pl-2",children:e.name})]})},e.id)})):Object(y.jsx)("div",{children:"No data found"})})})})]})};e4.defaultProps={resetValue:!1,initialValue:null,isEquipment:!1};var t4=e4,n4=Xc.Input.TextArea,a4=function(){var e=Object(a.useState)(),t=Object(b.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(),i=Object(b.a)(c,2),o=i[0],s=i[1],l=Ro("equipments",["name","equipmentType"],"name",0),d=l.items,u=l.loaded,j=l.setReload,p=Ro("worker/people",["contactInfo.name.givenName","contactInfo.name.surname"],"contactInfo.name.givenName",0),f=p.items,O=p.loaded,h=Object(Zi.h)().values,x=Object(a.useCallback)((function(){var e=null===d||void 0===d?void 0:d.filter((function(e){return"TRUCK"===(null===e||void 0===e?void 0:e.type)})).sort((function(e,t){return e.name.localeCompare(t.name)})),t=null===d||void 0===d?void 0:d.filter((function(e){return"TRUCK"!==(null===e||void 0===e?void 0:e.type)})).sort((function(e,t){return e.name.localeCompare(t.name)})),n=[].concat(Object(v.a)(e),Object(v.a)(t));r(n)}),[d]),g=Object(a.useCallback)((function(){var e=Object(v.a)(f).sort((function(e,t){return e.name.localeCompare(t.name)}));s(e)}),[f]);return Object(a.useEffect)((function(){j(!0),x(),g()}),[x,g]),Object(y.jsxs)("div",{children:[Object(y.jsxs)("div",{className:"flex flex-col gap-4",children:[Object(y.jsx)("h1",{className:"text-xl leading-7 font-semibold tracking-tight",children:"Other"}),Object(y.jsxs)(Xc.Row,{gutter:[24,24],prefixCls:"syt-antd-row",children:[Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[Object(y.jsx)("label",{htmlFor:"truck-select",className:"text-neutral-60 tracking-tighter text-sm",children:"Truck"}),u?Object(y.jsx)(t4,{data:n,initialValue:d.find((function(e){return e.id===h.truckId})),resetValue:h.TruckAndDriverFieldResetValue,isEquipment:!0}):Object(y.jsx)(m.Button,{style:{width:"100%"},type:"outline",ghost:!0,loading:!0})]})}),Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[Object(y.jsx)("label",{htmlFor:"driver-select",className:"text-neutral-60 tracking-tighter text-sm",children:"Driver"}),O?Object(y.jsx)(t4,{data:o,initialValue:f.find((function(e){return e.id===h.driverId})),resetValue:h.TruckAndDriverFieldResetValue}):Object(y.jsx)(m.Button,{style:{width:"100%"},type:"outline",ghost:!0,loading:!0})]})})]})]}),Object(y.jsx)("div",{className:"mt-8",children:Object(y.jsxs)("div",{className:"w-full flex flex-col gap-0.5",children:[Object(y.jsx)("label",{htmlFor:"notes",className:"text-neutral-60 tracking-tighter text-sm",children:"Notes"}),Object(y.jsx)(Zi.b,{as:n4,id:"notes",autoSize:{minRows:2},name:"notes",size:"middle"})]})})]})},r4=(n(1689),function(e){var t=e.load,n=e.salePrice;if(!t||!n)return null;var a=K2(n),r=K2(t);return null===a||null===r?null:FS.b.multiplyRound(a,r,O0)}),c4=function(e){var t=e.load,n=e.grossRevenue;if(!t||!n)return null;var a=K2(n),r=K2(t);return null===a||null===r?null:FS.b.divideSafeRound(a,r,O0)},i4=function(){var e,t=Object(Zi.h)().values,n=Object(a.useState)(!0),r=Object(b.a)(n,2),c=r[0],i=r[1];return Object(a.useEffect)((function(){i(!function(e){return Number(e)>0}(t.load))}),[t.load]),G2({fieldsToWatch:["grossRevenue"],updateFn:c4,fieldToUpdate:"salePrice"}),G2({fieldsToWatch:["salePrice","load"],updateFn:r4,fieldToUpdate:"grossRevenue"}),Object(y.jsx)("div",{children:"SALE"===(null===(e=t.destination)||void 0===e?void 0:e.type)?Object(y.jsxs)("div",{children:[Object(y.jsx)("h1",{className:"text-xl leading-7 font-semibold tracking-tight mb-4",children:"Sale Info"}),Object(y.jsxs)(Xc.Row,{gutter:[24,24],prefixCls:"syt-antd-row",children:[Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsx)("div",{className:"flex flex-row",children:Object(y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[Object(y.jsxs)("label",{htmlFor:"sale-price",className:"text-neutral-60 tracking-tighter text-sm",children:["Sale Price",Object(y.jsx)("span",{className:"text-remove",children:"*"})]}),Object(y.jsx)("div",{className:"flex w-full items-center",children:Object(y.jsx)(US,{fieldName:"salePrice",isRequired:!0,isDisabled:c,inputSuffix:Object(y.jsxs)("span",{children:["per ",Object(va.g)(t.loadUnit)]}),inputPrefix:"$",id:"sale-price",round:O0})}),Object(y.jsx)(Zi.a,{name:"salePrice",component:"div",className:"text-remove"}),c&&Object(y.jsx)("p",{className:"text-neutral-60 tracking-tighter text-sm",children:"You must first enter a Yield quantity"})]})})}),Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:!c&&Object(y.jsx)("div",{className:"flex flex-row",children:Object(y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[Object(y.jsxs)("label",{htmlFor:"gross-revenue",className:"text-neutral-60 tracking-tighter text-sm",children:["Gross Revenue",Object(y.jsx)("span",{className:"text-remove",children:"*"})]}),Object(y.jsx)("div",{className:"flex w-full items-center",children:Object(y.jsx)(US,{fieldName:"grossRevenue",inputPrefix:"$",isRequired:!0,id:"gross-revenue",round:O0})}),Object(y.jsx)(Zi.a,{name:"grossRevenue",component:"div",className:"text-remove"})]})})})]}),Object(y.jsx)(Xc.Alert,{className:"yield-load-alerts mt-4",message:"All yield delivered to a Sale Location will count towards total gross revenue.",showIcon:!0,type:"info"})]}):null})},o4=function(e){var t=e.label,n=e.fieldName,r=e.selectedCropName,c=Object(a.useContext)(we);return Object(y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[Object(y.jsxs)("label",{htmlFor:n,className:"text-neutral-60 tracking-tighter text-sm",children:[t,Object(y.jsx)("span",{className:"text-remove",children:"*"})]}),Object(y.jsxs)("div",{className:"flex items-start yield-quantity-input",children:[Object(y.jsx)(US,{fieldName:n,isRequired:!0,precision:2,id:n,round:O0}),Object(y.jsx)(Zi.b,{name:"loadUnit",children:function(e){var t=e.field,n=e.form;return Object(y.jsx)(v1,{value:t.value,onChange:function(e){c.sendEventToAmplitude(c.events.epic.YieldV2.addYield.selectUOM,{type:e}),n.setFieldValue(t.name,e)},cropName:r,className:"flex-1",isRequired:!0,minWidth:"50%"})}})]}),Object(y.jsx)("div",{className:"absolute",style:{width:"45%",top:"58px"},children:Object(y.jsx)(Zi.a,{name:"load",component:"div",className:"text-remove text-wrap"})})]})},s4=function(e){var t=e.quantity,n=e.area,a=K2(t),r=K2(n);return a&&r?FS.b.divideSafeRound(a,r,2):0},l4=function(e){var t=e.selectedCropName,n=Object(Zi.h)(),r=n.setFieldValue,c=n.values,i=Object(a.useMemo)((function(){return kZ(t)}),[t]);Object(a.useEffect)((function(){t&&!c.loadUnit&&r("loadUnit",i?va.a.BUSHEL:va.a.POUND)}),[t,r,i,c.loadUnit]);var o=Object(a.useMemo)((function(){var e;return void 0!==c.sources&&"CROP_ZONE"===c.sourceType&&(null===(e=c.sources)||void 0===e?void 0:e.length)>0}),[c.sources,c.sourceType]),s=Object(a.useMemo)((function(){return s4({quantity:c.load,area:c.totalArea})}),[c.load,c.totalArea]);return Object(y.jsxs)(Xc.Row,{gutter:[24,24],prefixCls:"syt-antd-row",children:[Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsx)(o4,{fieldName:"load",selectedCropName:t,label:"Yield Quantity"})}),Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:o&&Object(y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[Object(y.jsx)("p",{className:"text-neutral-60 tracking-tighter text-sm",children:"Average Quantity"}),Object(y.jsxs)("p",{className:"text-base leading-normal",children:[s," ",Object(va.g)(c.loadUnit)," / ac"]})]})})]})},d4=function(e){return 0===e?0:!Object(ne.isNumber)(e)||Object(ne.isNaN)(e)?null:e/100},u4=function(e){var t=e.harvestedQuantity,n=e.shrink,a=e.shrinkType,r=K2(t),c=K2(n);if(!c&&r)return r;if(!r||!c)return 0;var i=c;return a===C0.BY_PERCENT&&(i=FS.b.multiplyRound(d4(c),r)),FS.b.minusRound(r,i,2)},b4=function(e){var t=e.label,n=e.quantity,a=e.unit;return Object(y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[Object(y.jsx)("p",{className:"text-neutral-60 tracking-tighter text-sm",children:t}),Object(y.jsxs)("p",{className:"text-base leading-normal",children:[function(e){return(null===e||void 0===e?void 0:e.toFixed(2))||"--"}(n),"\xa0",a]})]})},j4=function(e){var t=e.value,n=e.onChange,a=e.className,r=e.isRequired,c=e.minWidth,i=Object.values(C0).map((function(e){return{value:e,label:jA(e)}}));return Object(y.jsx)("div",{"data-testid":"shrink-type-dropdown",className:"relative flex flex-col",style:{minWidth:c},children:Object(y.jsx)(Xc.Select,{size:"middle",suffixIcon:Object(y.jsx)(b1,{}),onChange:n,value:t,dropdownMatchSelectWidth:!1,className:a,optionLabelProp:"label",required:r,children:i.map((function(e){return Object(y.jsx)(Xc.Select.Option,{value:e.value,label:e.label,children:e.label},e.value)}))})})};j4.defaultProps={value:"",className:"",isRequired:!1,minWidth:"165px"};var p4=j4,f4=function(){var e,t=Object(Zi.h)(),n=t.errors,a=t.values,r=a.shrinkType===C0.BY_PERCENT?"%":Object(va.g)(a.loadUnit);return Object(y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[Object(y.jsx)("label",{htmlFor:"shrink",className:"text-neutral-60 tracking-tighter text-sm",children:"Shrink"}),Object(y.jsxs)("div",{className:"flex items-center yield-quantity-input",children:[Object(y.jsx)(US,{fieldName:"shrink",inputSuffix:Object(y.jsxs)(y.Fragment,{children:[r,n.shrink?Object(y.jsx)("img",{className:"ml-1",src:W2,alt:"validation alert","data-testid":"validation-alert"}):null]}),precision:2,id:"shrink",round:O0}),Object(y.jsx)(Zi.b,{name:"shrinkType",children:function(e){var t=e.field,n=e.form;return Object(y.jsx)(p4,{value:t.value,onChange:function(e){n.setFieldValue(t.name,e)},className:"flex-1",isRequired:!0,minWidth:"50%"})}})]}),!(null!==n&&void 0!==n&&null!==(e=n.shrink)&&void 0!==e&&e.includes("less than"))&&Object(y.jsx)("div",{className:"absolute",style:{width:"45%",top:"58px"},children:Object(y.jsx)(Zi.a,{name:"shrink",component:"div",className:"text-remove text-wrap"})})]})},m4=function(e){var t,n=e.selectedCropName,r=Object(Zi.h)(),c=r.setFieldValue,i=r.values,o=r.validateForm,s=r.errors,l=Object(a.useState)(),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Object(a.useState)(),f=Object(b.a)(p,2),m=f[0],v=f[1],O=Object(a.useMemo)((function(){return kZ(n)}),[n]),h=Object(a.useMemo)((function(){var e;return void 0!==i.sources&&"CROP_ZONE"===i.sourceType&&(null===(e=i.sources)||void 0===e?void 0:e.length)>0}),[i.sources,i.sourceType]),x=Object(a.useMemo)((function(){return s4({quantity:i.harvestedQuantity,area:i.totalArea})}),[i.harvestedQuantity,i.totalArea]),g=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o();case 2:if(t=e.sent,!i.shrink||!t.shrink){e.next=5;break}return e.abrupt("return");case 5:n=u4({harvestedQuantity:i.harvestedQuantity,shrink:i.shrink,shrinkType:i.shrinkType}),j(n),c("load",n),v(s4({quantity:n,area:i.totalArea}));case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();Object(a.useEffect)((function(){n&&!i.loadUnit&&c("loadUnit",O?va.a.BUSHEL:va.a.POUND)}),[n,c,O,i.loadUnit]),Object(a.useEffect)((function(){g()}),[i.harvestedQuantity,i.shrink,i.shrinkType,i.totalArea]);var C=Object(va.g)(i.loadUnit),P=!(null===s||void 0===s||null===(t=s.shrink)||void 0===t||!t.includes("less than"));return Object(y.jsxs)(Xc.Row,{gutter:[24,24],prefixCls:"syt-antd-row",children:[Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsx)(o4,{fieldName:"harvestedQuantity",selectedCropName:n,label:"Harvested Quantity"})}),h&&Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsx)(b4,{label:"Avg. Harvested Quantity",quantity:x,unit:"".concat(C," / ac")})}),Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsx)(f4,{})}),P&&Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:24,prefixCls:"syt-antd-col",style:null!==s&&void 0!==s&&s.load?{}:{marginTop:"-20px"},children:Object(y.jsx)(Xc.Alert,{"data-testid":"error-banner",className:"w-full px-8",message:Object(y.jsx)("p",{className:"font-normal text-neutral-80",children:s.shrink}),showIcon:!0,type:"error"})}),!h&&!P&&Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col"}),Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsx)(b4,{label:"Final Yield Quantity",quantity:u,unit:C})}),h&&Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:Object(y.jsx)(b4,{label:"Avg. Final Yield Quantity",quantity:m,unit:"".concat(C," / ac")})})]})},v4=(n(1690),"text-xl leading-7 font-semibold tracking-tight mb-4"),O4=function(e){var t=e.selectedCropName,n=e.shrinkEnabled,r=Object(Zi.h)().setFieldValue,c=Object(a.useState)(!0),i=Object(b.a)(c,2),o=i[0],s=i[1];return Object(a.useEffect)((function(){o||(r("shrink"),r("load"))}),[o]),n?Object(y.jsxs)("div",{children:[Object(y.jsxs)("div",{className:"flex gap-8",children:[Object(y.jsx)("h1",{className:v4,children:"Yield"}),Object(y.jsxs)("span",{className:"text-sm",children:[Object(y.jsx)(Xc.Switch,{size:"small",checked:o,onChange:function(){return s((function(e){return!e}))}}),Object(y.jsx)("span",{className:"ml-2",children:"Calculate with Shrink"})]})]}),o?Object(y.jsx)(m4,{selectedCropName:t}):Object(y.jsx)(l4,{selectedCropName:t})]}):Object(y.jsxs)("div",{children:[Object(y.jsx)("h1",{className:v4,children:"Yield"}),Object(y.jsx)(l4,{selectedCropName:t})]})};O4.defaultProps={shrinkEnabled:!1};var h4,x4,g4=O4,C4=function(e){var t=e.selectedCropName;return Object(y.jsxs)("div",{className:"flex flex-col gap-8",children:[Object(y.jsx)(H2,{}),Object(y.jsx)(g4,{selectedCropName:t}),Object(y.jsx)(i4,{}),Object(y.jsx)($2,{}),Object(y.jsx)(a4,{})]})},y4=function(){return Object(y.jsxs)("div",{className:"flex flex-col gap-0.5 weight-input",children:[Object(y.jsx)("label",{htmlFor:"damage",className:"text-neutral-60 tracking-tighter text-sm",children:"Damage"}),Object(y.jsx)(US,{fieldName:"damage",inputSuffix:"%",id:"damage",round:O0})]})},P4=function(){return Object(y.jsxs)("div",{className:"flex flex-col gap-0.5 weight-input",children:[Object(y.jsx)("label",{htmlFor:"foreign-material",className:"text-neutral-60 tracking-tighter text-sm",children:"Foreign Material"}),Object(y.jsx)(US,{fieldName:"foreignMaterial",inputSuffix:"%",id:"foreign-material",round:O0})]})},A4=function(){return Object(y.jsxs)("div",{className:"flex flex-col gap-0.5 weight-input",children:[Object(y.jsx)("label",{htmlFor:"moisture",className:"text-neutral-60 tracking-tighter text-sm",children:"Moisture"}),Object(y.jsx)(US,{fieldName:"moisture",inputSuffix:"%",id:"moisture",round:O0})]})},S4=function(){return Object(y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[Object(y.jsx)("label",{htmlFor:"test-weight",className:"text-neutral-60 tracking-tighter text-sm",children:"Test Weight"}),Object(y.jsxs)("div",{className:"flex items-start yield-quantity-input",children:[Object(y.jsx)(US,{fieldName:"testWeight",precision:2,id:"test-weight",round:O0}),Object(y.jsx)(Zi.b,{name:"testWeightUnit",children:function(e){var t=e.field,n=e.form;return Object(y.jsx)(Xc.Select,{size:"middle",suffixIcon:Object(y.jsx)(b1,{}),onChange:function(e){n.setFieldValue(t.name,e),n.validateField(t.name)},value:t.value,dropdownMatchSelectWidth:!1,optionLabelProp:"label",className:"flex-1","data-testid":"select-weight-unit",children:v0.map((function(e){return Object(y.jsx)(Xc.Select.Option,{value:e.value,label:j1(t.value,e),children:e.label},e.value)}))})}})]})]})},T4=function(){return Object(y.jsxs)("div",{className:"flex flex-col gap-0.5 weight-input",children:[Object(y.jsx)("label",{htmlFor:"quality",className:"text-neutral-60 tracking-tighter text-sm",children:"Quality"}),Object(y.jsx)(Zi.b,{as:Xc.Input,name:"quality",id:"quality",size:"middle",type:"default"})]})},N4={damage:Object(y.jsx)(y4,{}),foreignMaterial:Object(y.jsx)(P4,{}),moisture:Object(y.jsx)(A4,{}),testWeight:Object(y.jsx)(S4,{}),quality:Object(y.jsx)(T4,{})},E4=function(e){var t=e.attributes;return Object(y.jsxs)("div",{children:[Object(y.jsx)("div",{className:"flex items-center gap-4 mb-4",children:Object(y.jsx)("h1",{"data-testid":"outside-element",className:"text-xl leading-7 font-semibold tracking-tight",children:"Load Attributes"})}),Object(y.jsx)(Xc.Row,{gutter:[24,24],prefixCls:"syt-antd-row",children:t.map((function(e){return Object(y.jsx)(Xc.Col,{xs:24,sm:24,md:12,lg:12,xl:8,prefixCls:"syt-antd-col",children:N4[e]},"load-attribute-".concat(e))}))})]})},w4=function(e){var t=e.selectedCropName;return Object(y.jsxs)("div",{className:"flex flex-col gap-8",children:[Object(y.jsx)(H2,{}),Object(y.jsx)(g4,{shrinkEnabled:!0,selectedCropName:t}),Object(y.jsx)(i4,{}),Object(y.jsx)(E4,{attributes:y0[x0]}),Object(y.jsx)($2,{}),Object(y.jsx)(a4,{})]})},_4=function(e){var t=e.selectedCropName;return Object(y.jsxs)("div",{className:"flex flex-col gap-8",children:[Object(y.jsx)(H2,{}),Object(y.jsx)(g4,{selectedCropName:t}),Object(y.jsx)(i4,{}),Object(y.jsx)(E4,{attributes:y0[g0]}),Object(y.jsx)($2,{}),Object(y.jsx)(a4,{})]})},R4={name:Fu.f().required("Load Name is required").max(45,"Name characters must be less or equal than 45"),cropId:Fu.f().required("Crop is required"),sources:Fu.a().of(Fu.e().shape({id:Fu.f().required("Source is required"),name:Fu.f()})),destination:Fu.e().shape({type:Fu.f().oneOf(["STORAGE","SALE"],"Invalid destination type"),id:Fu.f().required("Destination is required"),name:Fu.f()}),date:Fu.c().required("Date is required"),load:A0("Yield Quantity"),loadUnit:Fu.f().required("Yield Load weight unit is required"),salePrice:Fu.d().when("destination.type",{is:"SALE",then:A0("Sale Price"),otherwise:Fu.d().nullable()}),grossRevenue:Fu.d().when("destination.type",{is:"SALE",then:A0("Gross Revenue"),otherwise:Fu.d().nullable()}),weightUnit:Fu.f().nullable(),grossWeight:S0("Gross Weight"),tareWeight:S0("Tare Weight"),netWeight:S0("Net Weight"),truck:Fu.f().nullable(),driver:Fu.f().nullable(),notes:Fu.f().nullable(),capacity:S0("Capacity")},I4=(h4={},Object(et.a)(h4,h0,Fu.e().shape(Object(I.a)({},R4))),Object(et.a)(h4,x0,Fu.e().shape(Object(I.a)(Object(I.a)({},R4),{},{shrink:S0("Shrink").test("is-less-than-load","Shrink should be less than Harvested Quantity",(function(e){if(!e)return!0;var t=this.parent,n=t.harvestedQuantity;return t.shrinkType===C0.BY_PERCENT?e<100:e<n})),shrinkType:Fu.f().nullable().oneOf(Object.values(C0)),harvestedQuantity:A0("Harvested Quantity"),damage:S0("Damage"),foreignMaterial:S0("Foreign Material"),moisture:S0("Moisture"),testWeight:S0("testWeight"),testWeightUnit:Fu.f().nullable()}))),Object(et.a)(h4,g0,Fu.e().shape(Object(I.a)(Object(I.a)({},R4),{},{damage:S0("Damage"),foreignMaterial:S0("Foreign Material"),quality:Fu.f().nullable()}))),h4),D4=I4,k4=n.p+"static/media/check-circle-white.603fe86b.svg",L4=n.p+"static/media/property-to-storage.7779345d.svg",F4=n.p+"static/media/property-to-sale.0315d75d.svg",M4=n.p+"static/media/storage-to-sale.a2933a31.svg",V4=n.p+"static/media/storage-to-storage.63681333.svg",B4="CROP_ZONE",U4="STORAGE",z4="SALE",Z4="STORAGE",Y4="STORAGE_STORAGE",H4="STORAGE_SALE",G4="CROP_ZONE_STORAGE",W4="CROP_ZONE_SALE",q4=(x4={},Object(et.a)(x4,Y4,V4),Object(et.a)(x4,H4,M4),Object(et.a)(x4,G4,L4),Object(et.a)(x4,W4,F4),x4),J4={id:wc.a.string.isRequired,name:wc.a.string,area:wc.a.number},K4=wc.a.shape({acres:wc.a.number,farmId:wc.a.string,farmName:wc.a.string,fieldId:wc.a.string,fieldName:wc.a.string,seasonId:wc.a.string,cropZoneId:wc.a.string,cropZoneName:wc.a.string}),Q4=(wc.a.shape({id:wc.a.string.isRequired,name:wc.a.string,date:wc.a.string,sources:wc.a.arrayOf(wc.a.shape({id:wc.a.string.isRequired,name:wc.a.string})),sourceType:wc.a.string,destination:wc.a.shape(J4),destinationType:wc.a.string,load:wc.a.string,loadUnit:wc.a.string,cropId:wc.a.string,cropName:wc.a.string,grossRevenue:wc.a.number,totalArea:wc.a.number,cropSeason:wc.a.string,salePrice:wc.a.string,entryName:wc.a.string,cropZones:wc.a.arrayOf(K4),unit:wc.a.string,avgYieldPerAcre:wc.a.string,totalYield:wc.a.number,grossRevenuePerAcre:wc.a.number,cropSeasonId:wc.a.string}),wc.a.shape({title:wc.a.string.isRequired,key:wc.a.string.isRequired}));Q4.children=wc.a.arrayOf(Q4);wc.a.arrayOf(Q4);var X4=n.p+"static/media/deleteIcon.f8111507.svg",$4=function(e){var t=e.item,n=e.onDeleteYieldTicket,r=e.className,c=Object(Zi.h)(),i=c.values,o=c.setValues,s=Object(a.useState)(!1),l=Object(b.a)(s,2),d=l[0],u=l[1],j=Object(a.useMemo)((function(){return(null===t||void 0===t?void 0:t.loadTemporaryId)===(null===i||void 0===i?void 0:i.loadTemporaryId)}),[null===t||void 0===t?void 0:t.loadTemporaryId,null===i||void 0===i?void 0:i.loadTemporaryId]),p=t||{},f=p.name,m=p.load,v=p.loadUnit,O=p.date,h=p.sources,x=p.sourceType,g=p.destination;if(!h||!g)return null;var C="".concat(x,"_").concat(null===g||void 0===g?void 0:g.type);return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(ib,{open:d,itemType:"Load",type:"error",onCancel:function(){u(!1)},onDelete:function(){u(!1),n(t)},title:"Delete Load?",message:"Are you sure you want to delete this load from your submission?"}),Object(y.jsxs)("button",{"data-testid":"load-item-button",onClick:function(){o(t)},className:"".concat(j?"bg-selectedBlue":"hover:bg-neutral-20"," cursor-pointer px-4 py-10px flex flex-col gap-2 border-b border-neutral-20 w-full outline-none focus:outline-none ").concat(r),type:"button",children:[Object(y.jsxs)("div",{className:"flex w-full",children:[Object(y.jsxs)("div",{className:"flex-1 flex gap-3 items-center",children:[Object(y.jsx)("div",{className:"h-6",children:Object(y.jsx)("img",{src:q4[C],alt:C,className:"h-full"})}),Object(y.jsx)("p",{className:"text-black text-base leading-7 overflow-hidden truncate whitespace-nowrap",children:f})]}),n&&Object(y.jsx)(Xc.Tooltip,{title:"Delete",placement:"left",children:Object(y.jsx)("button",{className:"flex items-center align-center",type:"button",onClick:function(e){e.preventDefault(),e.stopPropagation(),u(!0)},children:Object(y.jsx)("img",{src:X4,alt:"remove icon"})})})]}),Object(y.jsxs)("div",{className:"flex justify-between w-full text-left",children:[Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"text-xs text-neutral-60",children:"Yield Quantity"}),Object(y.jsxs)("p",{children:[parseFloat(m).toFixed(2)," ",Object(va.g)(v)]})]}),Object(y.jsxs)("div",{children:[Object(y.jsx)("p",{className:"text-xs text-neutral-60",children:"Date & Time"}),Object(y.jsx)("p",{children:Zd(O)})]})]})]})]})};$4.defaultProps={className:"",onDeleteYieldTicket:null};var e5=$4,t5=function(){return Object(y.jsx)("div",{className:"h-full text-center p-12",children:Object(y.jsx)("span",{children:"Select \u201cAdd to List & Create New\u201d to add a completed load to this list and create a new load"})})},n5=function(e){var t=e.list,n=e.onDeleteYieldTicket;return t.length?Object(y.jsx)("div",{className:"h-full overflow-auto",children:t.map((function(e){return Object(y.jsx)(e5,{item:e,onDeleteYieldTicket:n},e.name+e.loadTemporaryId)}))}):Object(y.jsx)(t5,{})},a5=function(e){var t=e.isEditYieldPage,n=e.list,r=e.onDeleteYieldTicket,c=e.popupTitle,i=e.isEditingLoad,o=e.isDisabled,s=e.onSaveAllLoads,l=e.resetSubimissionChange,d=e.setResetSubimissionChange,u=Object(Zi.h)(),j=u.values,f=u.setFieldTouched,v=u.setFieldValue,O=u.submitForm,h=u.dirty,x=u.isValid,g=Object(a.useContext)(we),C=Object(p.h)(),P=Object(a.useState)(!1),A=Object(b.a)(P,2),S=A[0],T=A[1],N=Object(a.useState)(!0),E=Object(b.a)(N,2),w=E[0],_=E[1],R=Object(a.useState)({visible:!1,type:null}),I=Object(b.a)(R,2),D=I[0],k=I[1],L=n.length,F=L?"(".concat(L,")"):"";Object(a.useEffect)((function(){if(n.length>0&&(f("preventNavigation",!0),v("preventNavigation",!0)),!w){if(l)return void d(!1);T(!0),setTimeout((function(){return T(!1)}),2e3)}_(!1)}),[n]);return Object(y.jsxs)("div",{className:"flex flex-col h-full bg-white shadow-elevation-2",children:[Object(y.jsx)(Sm,{hideInstructions:!0,disabled:!(null!==j&&void 0!==j&&j.preventNavigation),title:"Cancel this submission?",customText:Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("p",{children:["You will lose ",Object(y.jsx)("strong",{children:"all data"})," from this submission, including any loads on the loads list."]}),Object(y.jsx)("p",{className:"mt-3",children:"Are you sure you want to continue?"})]}),type:"error",confirmLabel:"Leave Page",cancelLabel:"Cancel"}),Object(y.jsx)("div",{className:"pl-6 pt-6 pb-4 border-b border-neutral-20",children:Object(y.jsxs)("h1",{className:"text-xl leading-7 tracking-tight",children:[t?"Edit Yield Load":"Loads List",!t&&L>0&&Object(y.jsxs)("span",{className:"ml-2",children:["(",L,")"]})]})}),Object(y.jsxs)("div",{className:"duration-400 ease-in-out ".concat(S?"opacity-100 max-h-28px py-1":"opacity-0 max-h-0"," overflow-hidden gap-1 flex justify-center items-center bg-cucumber-green-700 text-white text-sm"),style:{transitionProperty:"opacity, max-height"},children:[Object(y.jsx)("img",{src:k4,alt:"Check Circle",className:"h-20px"}),Object(y.jsx)("span",{children:c})]}),Object(y.jsx)("div",{className:"flex-1",children:t?Object(y.jsx)(e5,{item:j,className:"bg-selectedBlue"}):Object(y.jsx)(n5,{list:n,onDeleteYieldTicket:r})}),Object(y.jsxs)("div",{"data-testid":"loads-manager-footer",className:"flex  gap-4 px-4 py-10px border-t-1 border-neutral-20",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:function(){v("preventNavigation",!0),C.goBack()},size:"lg",disabled:o,children:"Cancel"}),Object(y.jsx)(m.Button,{size:"lg",type:"submit",style:{flex:"1"},onClick:function(e){return e.preventDefault(),t?void(O2({sourceType:null===j||void 0===j?void 0:j.sourceType,source:null===j||void 0===j?void 0:j.sources[0],load:null===j||void 0===j?void 0:j.load})?k({visible:!0,type:"overdrawnSource"}):(g.sendEventToAmplitude(g.events.epic.YieldV2.loads.editYield),O())):void(h&&x?k({visible:!0,type:"saveUnsaved"}):(v("preventNavigation",!1),s()))},disabled:o||i||!t&&0===L,children:t?"Save Load":"Save All Loads ".concat(F)})]}),Object(y.jsx)(v2,{type:D.type,onSaveAllLoads:s,setModalVisible:function(e){return k(e)},modalVisible:D.visible})]})};a5.defaultProps={isDisabled:!1,isEditYieldPage:!1,list:[],onDeleteYieldTicket:function(){},isEditingLoad:!1,resetSubimissionChange:!1,setResetSubimissionChange:function(){}};var r5,c5=a5,i5=n.p+"static/media/illustration-password-ok-a.487ceb7f.svg",o5=["title","titleId"];function s5(){return s5=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},s5.apply(this,arguments)}function l5(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function d5(e,t){var n=e.title,r=e.titleId,c=l5(e,o5);return a.createElement("svg",s5({width:24,height:24,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,r5||(r5=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM11 7V11H7V13H11V17H13V13H17V11H13V7H11ZM4 12C4 16.41 7.59 20 12 20C16.41 20 20 16.41 20 12C20 7.59 16.41 4 12 4C7.59 4 4 7.59 4 12Z"})))}var u5,b5=a.forwardRef(d5),j5=(n.p,["title","titleId"]);function p5(){return p5=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},p5.apply(this,arguments)}function f5(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function m5(e,t){var n=e.title,r=e.titleId,c=f5(e,j5);return a.createElement("svg",p5({width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},n):null,u5||(u5=a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 3H17L21 7V19C21 20.1 20.1 21 19 21H5C3.89 21 3 20.1 3 19V5C3 3.9 3.89 3 5 3ZM19 19V7.83L16.17 5H5V19H19ZM12 12C10.34 12 9 13.34 9 15C9 16.66 10.34 18 12 18C13.66 18 15 16.66 15 15C15 13.34 13.66 12 12 12ZM15 6H6V10H15V6Z"})))}var v5=a.forwardRef(m5),O5=(n.p,function(e){var t=e.unSavedTicketsCount,n=e.closeCreateNewLoadWidget,a=e.onSaveAllLoads,r=e.widgetTitle;return Object(y.jsxs)("div",{className:"flex flex-col items-center pt-8 pb-16",children:[Object(y.jsx)("img",{src:i5,alt:"Yield Load created!"}),Object(y.jsx)("h1",{className:"mt-4 mb-8 text-2xl leading-8 text-black",children:r}),Object(y.jsxs)("div",{className:"flex gap-12",children:[Object(y.jsxs)("button",{onClick:n,type:"button",className:"w-67 group flex flex-col py-6 px-12 items-center text-center rounded shadow-elevation-1 bg-white hover:grayscale hover:border-blue-90 border-1  hover:bg-blue-10",children:[Object(y.jsx)(b5,{className:"text-neutral-60 fill-current group-hover:text-blue-90"}),Object(y.jsx)("p",{className:"mt-4 mb-1 text-base font-semibold leading-6",children:"Create New Load"}),Object(y.jsx)("p",{className:"text-neutral-60 text-sm leading-6",children:"Add a brand new load to this submission"})]}),Object(y.jsxs)("button",{onClick:a,type:"button",className:"w-67 group flex flex-col py-6 px-8 items-center text-center rounded shadow-elevation-1 bg-white hover:grayscale hover:border-blue-90 border-1  hover:bg-blue-10",children:[Object(y.jsx)(v5,{className:"text-neutral-60 fill-current group-hover:text-blue-90"}),Object(y.jsxs)("p",{className:"mt-4 mb-1 text-base font-semibold leading-6",children:["Save All Loads ",Object(y.jsxs)("span",{children:["(",t,")"]})]}),Object(y.jsx)("p",{className:"text-neutral-60 text-sm leading-6",children:"If you\u2019re done adding loads, save all loads on the Loads List"})]})]})]})});O5.defaultProps={onSaveAllLoads:function(){},closeCreateNewLoadWidget:function(){}};var h5=O5,x5=function(e){var t=e.open,n=e.onCancel,a=e.onConfirm;return Object(y.jsx)(ao,{open:t,title:"Change Crop Selection?",close:n,cancelLabel:"Cancel",confirmLabel:"Continue",onCancel:n,type:"error",onConfirm:function(){a(),n()},children:Object(y.jsxs)("div",{className:"pr-6",children:[Object(y.jsxs)("div",{className:"pb-4",children:["Only one crop type can be used per submission. Changing the crop selection will delete ",Object(y.jsx)("b",{children:"all data"})," from this submission, including any loads on the loads list."]}),Object(y.jsx)("div",{children:"Are you sure you want to continue?"})]})})};x5.defaultProps={open:!1};var g5=x5,C5=function(e){var t=e.open,n=e.onCancel,a=e.onConfirm;return Object(y.jsx)(ao,{open:t,title:"Change Template Selection?",close:n,cancelLabel:"Cancel",confirmLabel:"Continue",onCancel:n,type:"error",onConfirm:function(){a(),n()},children:Object(y.jsxs)("div",{className:"pr-6",children:[Object(y.jsxs)("div",{className:"pb-4",children:["Only one template can be used per submission. Changing the template will delete ",Object(y.jsx)("b",{children:"all data"})," from this submission, including any loads on the loads list."]}),Object(y.jsx)("div",{children:"Are you sure you want to continue?"})]})})};C5.defaultProps={open:!1};var y5=C5,P5=function(e){var t=e.toastType,n=e.showToast,a=e.onCloseHandler,r=e.title,c=e.description;return Object(y.jsx)(Qc,{type:t,isBold:!0,open:n,title:r,onClose:a,timeout:5e3,children:"error"===t&&Object(y.jsxs)(y.Fragment,{children:[!!c&&Object(y.jsx)("div",{children:c}),Object(y.jsx)($c,{})]})})};P5.defaultProps={toastType:null,showToast:!1,onCloseHandler:function(){},title:"",description:""};var A5=P5,S5=["sources","destination","load","tareWeight","grossWeight","grossRevenue","netWeight","salePrice","sourceType","templateType","harvestedQuantity"],T5=function(e){return e.map((function(e){var t=e.sources,n=e.destination,a=e.load,r=e.tareWeight,c=e.grossWeight,i=e.grossRevenue,o=e.netWeight,s=e.salePrice,l=e.sourceType,d=e.templateType,u=e.harvestedQuantity,b=Object(te.a)(e,S5),j={};return d===x0&&(j.damage=d4(b.damage),j.foreignMaterial=d4(b.foreignMaterial),j.moisture=d4(b.moisture),b.shrinkType===C0.BY_PERCENT?j.shrink=d4(b.shrink):b.shrinkType===C0.BY_QUANTITY&&(j.shrink=b.shrink?parseFloat(b.shrink):0)),d===g0&&(j.damage=d4(b.damage),j.foreignMaterial=d4(b.foreignMaterial)),Object(I.a)(Object(I.a)({},b),{},{templateType:d,loadTemporaryId:void 0,sources:t.map((function(e){return{id:e.id}})),sourceType:l,destinationId:n.id,destinationType:n.type,load:parseFloat(a),harvestedQuantity:u?parseFloat(u):null,tareWeight:r?parseFloat(r):null,grossWeight:c?parseFloat(c):null,grossRevenue:i?parseFloat(i):null,netWeight:o?parseFloat(o):null,salePrice:s?parseFloat(s):null,cropZones:null,avgYieldPerAcre:0},j)}))},N5=function(e){var t=e.onSave,n=e.onSaveAndCreateNew;return Object(y.jsxs)("div",{className:"flex gap-4 py-3 px-6 justify-end w-full border-neutral-20 border-t-1",children:[Object(y.jsx)(m.Button,{type:"outline",onClick:t,children:"Save Changes"}),Object(y.jsx)(m.Button,{ghost:!0,type:"primary",onClick:n,children:"Save Changes & Create New"})]})};var E5,w5=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=t.trim().split(" ");e=(e=n.length>=2?n[0].charAt(0)+n[1].charAt(0):t.substring(0,2)).toUpperCase();var a=Object(ya.a)(new Date,"yyMMdd-HHmm");return"".concat(e," ").concat(a)},_5=(E5={},Object(et.a)(E5,h0,{component:C4,value:h0,label:"Default All Crops Template",defaultValues:P0[h0],validationSchema:D4[h0]}),Object(et.a)(E5,x0,{component:w4,value:x0,label:"Default Row Crop Template",defaultValues:P0[x0],validationSchema:D4[x0]}),Object(et.a)(E5,g0,{component:_4,value:g0,label:"Default Specialty Crop Template",defaultValues:P0[g0],validationSchema:D4[g0]}),E5),R5={popupTitle:"Changes saved",widgetTitle:"Changes Saved!"},I5={popupTitle:"Load added to list",widgetTitle:"Added to Loads List!"},D5={popupTitle:"Load deleted",widgetTitle:"Load deleted!"},k5=function(){var e,t,n=Object(p.h)(),r=VZ().saveAllLoads,c=dd().cropSeasons,i=Object(p.i)(),o=Object(f.useFlags)(),s=o.releaseYieldTemplates,l=o.releaseYieldTemplatesByOrg,d=o.releaseFeCondensedCropSeasons,u=o.releaseFeCondensedCropSeasonsByOrg,j=Object(a.useState)({popupTitle:"Changes saved",widgetTitle:"Changes Saved!"}),m=Object(b.a)(j,2),O=m[0],h=m[1],x=Object(a.useState)(!1),g=Object(b.a)(x,2),C=g[0],P=g[1],A=Object(a.useState)(_5[h0].value),S=Object(b.a)(A,2),T=S[0],N=S[1],E=Object(a.useState)([]),w=Object(b.a)(E,2),_=w[0],R=w[1],D=Object(a.useState)(!1),k=Object(b.a)(D,2),L=k[0],F=k[1],M=Object(a.useState)(!1),V=Object(b.a)(M,2),B=V[0],U=V[1],z=new URLSearchParams(i.search).get("cropId"),Z=Object(a.useState)(z),H=Object(b.a)(Z,2),W=H[0],q=H[1],J=Object(a.useState)(!1),K=Object(b.a)(J,2),Q=K[0],X=K[1],$=Object(a.useState)(z),ee=Object(b.a)($,2),te=ee[0],ne=ee[1],ae=Object(a.useState)(T),re=Object(b.a)(ae,2),ce=re[0],ie=re[1],oe=JSON.parse(localStorage.getItem("selectedCropSeasons")),se=Object(b.a)(oe,1)[0],le=Object(a.useState)(!1),de=Object(b.a)(le,2),ue=de[0],be=de[1],je=Object(a.useState)(!1),pe=Object(b.a)(je,2),fe=pe[0],me=pe[1],ve=Object(a.useContext)(ac),Oe=Object(b.a)(ve,2),he=Oe[0],xe=he.organization,ge=he.loadingOrg,Ce=he.loggedInUserOrgPermission.name,ye=Oe[1],Pe=Object(a.useMemo)((function(){return null===c||void 0===c?void 0:c.find((function(e){return(null===e||void 0===e?void 0:e.id)===se}))}),[c,se]),Ae=Object(a.useMemo)((function(){var e,t;return null===Pe||void 0===Pe||null===(e=Pe.crops)||void 0===e||null===(t=e.find((function(e){return e.id===W})))||void 0===t?void 0:t.name}),[Pe,W]),Se=yc(d,u,null===xe||void 0===xe?void 0:xe.id);Object(a.useEffect)((function(){mc(ye,[se],Se)}),[ye,se]),Object(a.useEffect)((function(){var e;if(null!==Pe&&void 0!==Pe&&Pe.crops&&!z){var t=(null===Pe||void 0===Pe||null===(e=Pe.crops)||void 0===e?void 0:e.sort((function(e,t){return e.name.localeCompare(t.name)})))||[],n=Object(b.a)(t,1)[0];n&&q(n.id)}}),[null===Pe||void 0===Pe?void 0:Pe.crops,z]);var Te=null===(e=_5[T])||void 0===e?void 0:e.component,Ne=yc(s,l,xe.id);Object(a.useEffect)((function(){if(!Ne){var e=_5[h0].value;T!==e&&N(e)}}),[Ne,T]);var Ee=function(e){return kZ(e)?va.a.BUSHEL:va.a.POUND},_e=Object(a.useMemo)((function(){return Object(I.a)({grossWeight:null,tareWeight:null,netWeight:null,loadUnit:Ee(Ae),weightUnit:va.a.POUND,cropId:W,date:j2(),name:w5(Ce),sources:[{id:""}],destination:{id:""},load:null,loadTemporaryId:Date.now(),salePrice:null,grossRevenue:null,truckId:null,driverId:null,TruckAndDriverFieldResetValue:!0},_5[T].defaultValues)}),[Ae,T,W,Ce]),Re=Object(a.useContext)(we),Ie=function(e){e!==T&&(me(!0),ie(e),Re.sendEventToAmplitude(Re.events.epic.YieldV2.addYield.selectTemplate,{organizationName:null===xe||void 0===xe?void 0:xe.name,organizationId:null===xe||void 0===xe?void 0:xe.id,template:e}))},De=function(e){e!==W&&(be(!0),ne(e))},ke=function(){var e=Object(Y.a)(G.a.mark((function e(t){var a,c,i,o,s;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=_,null!==t&&void 0!==t&&t.name&&null!==t&&void 0!==t&&t.load&&(c=JSON.parse(localStorage.getItem("selectedCropSeasons")),i=Object(b.a)(c,1),o=i[0],a=[].concat(Object(v.a)(a),[Object(I.a)(Object(I.a)({},t),{},{cropSeasonId:o,cropId:W,cropName:Ae})])),F(!0),s=T5(a),Re.sendEventToAmplitude(Re.events.epic.YieldV2.addYield.saveLoads,Object(I.a)({numberOfLoads:s.length,organizationId:null===xe||void 0===xe?void 0:xe.id},s.reduce((function(e,t){return e.grossWeight+=(null===t||void 0===t?void 0:t.grossWeight)||0,e.tareWeight+=(null===t||void 0===t?void 0:t.tareWeight)||0,e.netWeight+=(null===t||void 0===t?void 0:t.netWeight)||0,e}),{grossWeight:0,tareWeight:0,netWeight:0}))),e.next=7,r(s);case 7:e.sent?n.push({pathname:"".concat(Cc.yieldV2,"/loads"),toast:{type:"success",title:"All Loads saved.",message:"",showToast:!0}}):(U(!0),F(!1));case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Le=function(e){return _.some((function(t){return t.loadTemporaryId===e}))},Fe=function(e){R(_.filter((function(t){return t.loadTemporaryId!==e.loadTemporaryId}))),h(D5)},Me=function(){P(!1)};if(Pe&&(null===Pe||void 0===Pe||null===(t=Pe.cropZoneIds)||void 0===t||!t.length))return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(lo,{hideCropSeasonDropdown:!1,disabled:!0,disabledCropSeasons:!0,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Add Yield Loads",isLast:!0})}),Object(y.jsx)("div",{"data-testid":"empty-cropseason",className:"my-6 py-20 bg-white rounded-lg shadow-sm-card border-1 border-neutral-30",children:Object(y.jsx)(o2,{hasNoCropsinSelectedSeason:!0})})]});if(!Pe||!W)return null;var Ve=function(e){return{values:Object(I.a)(Object(I.a)({},_e),e)}};return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(Zi.e,{enableReinitialize:!0,initialValues:_e,validationSchema:_5[T].validationSchema,onSubmit:function(e,t){var n=t.resetForm,a=JSON.parse(localStorage.getItem("selectedCropSeasons")),r=Object(b.a)(a,1)[0],c=Object(I.a)(Object(I.a)({},e),{},{templateType:T,grossRevenue:Number(e.grossRevenue),cropSeasonId:r,cropId:W,cropName:Ae});if(Le(e.loadTemporaryId)){var i=Object(v.a)(_),o=i.findIndex((function(t){return t.loadTemporaryId===e.loadTemporaryId}));i[o]=c,R(i),h(R5)}else R((function(e){return[].concat(Object(v.a)(e),[c])})),h(I5);var s=["weightUnit","loadUnit","sources","sourceType","destination","totalArea","cropId","templateType"].reduce((function(t,n){return Object(I.a)(Object(I.a)({},t),{},Object(et.a)({},n,e[n]))}),{});n({values:Object(I.a)(Object(I.a)({},s),{},{date:j2(),name:w5(Ce),load:null,loadTemporaryId:Date.now()},_5[T].defaultValues)})},validateOnChange:!0,children:function(e){var t=e.resetForm,n=e.values,a=e.handleSubmit,r=e.validateForm;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(y5,{open:fe,onCancel:function(){return me(!1)},onConfirm:function(){me(!1),N(ce),t(Ve(Object(I.a)({},_5[ce].defaultValues))),R([]),X(!0)}}),Object(y.jsx)(g5,{open:ue,onCancel:function(){return be(!1)},onConfirm:function(){var e,n;be(!1),q(te);var a=null===Pe||void 0===Pe||null===(e=Pe.crops)||void 0===e||null===(n=e.find((function(e){return e.id===te})))||void 0===n?void 0:n.name;t(Ve({cropId:te,loadUnit:Ee(a)})),R([]),X(!0)}}),Object(y.jsxs)(Zi.d,{className:"h-full",children:[Object(y.jsx)(lo,{disabled:!0,disabledCropSeasons:!0,hideCropSeasonDropdown:!1,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Add Yield Loads",isLast:!0})}),Object(y.jsxs)("div",{className:"flex h-full",children:[Object(y.jsxs)("div",{className:"px-4 flex-1 ",children:[Object(y.jsxs)("div",{className:"pl-8 pb-4 pt-6 flex gap-6",children:[Ne&&Object(y.jsxs)("div",{className:"min-w-60 flex flex-col gap-0.5",children:[Object(y.jsx)("label",{htmlFor:"template-select",className:"text-neutral-60 tracking-tighter text-sm",children:"Template"}),Object(y.jsx)(Xc.Select,{id:"template-select",options:Object.values(_5),value:T,onSelect:Ie,size:"middle",loading:!1,suffixIcon:Object(y.jsx)(b1,{}),disabled:L})]}),Object(y.jsx)("div",{className:"min-w-60 flex flex-col gap-0.5 items-start",children:Object(y.jsx)(d2,{selectedCropId:W,onCropChange:De,crops:null===Pe||void 0===Pe?void 0:Pe.crops,disabled:L})})]}),Object(y.jsxs)("div",{style:{maxHeight:"calc(100% - 100px)"},className:"shadow-elevation-2 bg-white rounded-lg relative flex-1 flex flex-col overflow-auto",children:[L||ge?Object(y.jsx)(b2,{text:L?"Saving Loads...":""}):Object(y.jsx)("div",{className:"overflow-y-auto p-8 pb-20",children:C&&!Le(n.loadTemporaryId)?Object(y.jsx)(h5,{unSavedTicketsCount:_.length,closeCreateNewLoadWidget:Me,onSaveAllLoads:function(){return ke()},widgetTitle:O.widgetTitle}):Object(y.jsx)(Te,{selectedCropName:Ae})}),Le(n.loadTemporaryId)?Object(y.jsx)("div",{className:"absolute inset-x-0 bottom-0 bg-white",children:Object(y.jsx)(N5,{onSaveAndCreateNew:function(){a(),P(!1)},onSave:function(){return r().then((function(e){0===Object.keys(e).length&&(a(),P(!0))}))}})}):Object(y.jsx)("div",{className:"absolute inset-x-0 bottom-0 bg-white ".concat(C?"hidden":""),children:Object(y.jsx)(x2,{disabled:L,showCreateNewLoadWidget:function(){return P(!0)}})})]})]}),Object(y.jsx)("div",{className:"max-w-80 w-full h-full",children:Object(y.jsx)(c5,{list:_,onDeleteYieldTicket:Fe,onSaveAllLoads:ke,popupTitle:O.popupTitle,isEditingLoad:Le(n.loadTemporaryId),isDisabled:L,resetSubimissionChange:Q,setResetSubimissionChange:X})})]})]})]})}}),Object(y.jsx)(A5,{toastType:"error",showToast:B,onCloseHandler:function(){return U(!1)},title:"Loads not saved.",description:"An error prevented your loads from being saved. Please try again"})]})},L5=["weightUnit"],F5=function(e){var t=e.weightUnit,n=Object(te.a)(e,L5),a=["grossWeight","tareWeight","netWeight","load","salePrice","grossRevenue","testWeight","harvestedQuantity"],r=["damage","foreignMaterial","moisture"];n.shrinkType===C0.BY_PERCENT?r.push("shrink"):a.push("shrink");var c=Object.keys(n).reduce((function(e,t){var c;return a.includes(t)&&null!==n[t]?e[t]=parseFloat(n[t]):r.includes(t)&&null!==n[t]?e[t]=0===(c=parseFloat(n[t]))?0:!Object(ne.isNumber)(c)||Object(ne.isNaN)(c)?null:100*c:e[t]=n[t],e}),{});return Object(I.a)(Object(I.a)({},c),{},{weightUnit:t||va.a.POUND})},M5=function(){var e=Object(p.j)().id,t=Object(p.h)(),n=Object(a.useContext)(ac),r=Object(b.a)(n,2)[1],c=Object(a.useState)(!1),i=Object(b.a)(c,2),o=i[0],s=i[1],l=VZ(),d=l.getLoadById,u=l.updateLoadById,j=l.yieldLoad,f=l.loading,m=l.submitError;Object(a.useEffect)((function(){d(e)}),[d,e]);var v=Object(a.useMemo)((function(){return j?(localStorage.setItem("selectedCropSeasons",JSON.stringify([j.cropSeasonId])),F5(j)):null}),[j]),O=function(){var n=Object(Y.a)(G.a.mark((function n(a){var c,i,o,l;return G.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,c=Object(tF.e)(a),i=T5([Object(I.a)(Object(I.a)({},c),{},{templateType:j.templateType})]),o=Object(b.a)(i,1),l=o[0],n.next=5,u(e,l);case 5:r({type:Kr,payload:!0}),t.push("".concat(Cc.yieldV2,"/loads/").concat(e,"/view")),n.next=12;break;case 9:n.prev=9,n.t0=n.catch(0),s(!0);case 12:case"end":return n.stop()}}),n,null,[[0,9]])})));return function(e){return n.apply(this,arguments)}}();if(!v)return null;var h=_5[j.templateType].component;return Object(y.jsx)(Zi.e,{initialValues:v,validationSchema:D4[j.templateType],onSubmit:O,children:Object(y.jsxs)(Zi.d,{className:"h-full",noValidate:!0,children:[Object(y.jsx)(lo,{hideCropSeasonDropdown:!1,disabledCropSeasons:!0,disabled:!0,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Edit Yield Load",isLast:!0})}),Object(y.jsxs)("div",{className:"flex h-full",children:[Object(y.jsxs)("div",{className:"px-4 flex-1",children:[Object(y.jsx)("div",{className:"pl-8 pb-4 pt-6 flex gap-6",children:Object(y.jsxs)("h1",{className:"text-xl leading-7 tracking-tight flex items-center",children:["Crop:",Object(y.jsx)(Ag,{cropObject:{name:null===j||void 0===j?void 0:j.cropName}}),null===j||void 0===j?void 0:j.cropName]})}),Object(y.jsx)("div",{style:{maxHeight:"calc(100% - 100px)"},className:"shadow-elevation-2 bg-white rounded-lg relative flex-1 flex flex-col overflow-auto h-full",children:f?Object(y.jsx)(b2,{text:"Saving Changes..."}):Object(y.jsx)("div",{className:"overflow-y-auto p-8 ",children:Object(y.jsx)(h,{selectedCropName:null===j||void 0===j?void 0:j.cropName})})})]}),Object(y.jsxs)("div",{className:"max-w-80 w-full h-full",children:[Object(y.jsx)(c5,{isEditYieldPage:!0}),Object(y.jsx)(D0,{title:"Unable to save changes.",state:"error",showToast:null!==m&&o,setShowToast:s,errorMessage:"An error prevented your load from being updated. Please try again.",isBold:!0})]})]})]})})};n(1691);function V5(e){var t=e.value,n=e.onClose,a=e.cropsOfSelectedSeasons,r=e.isGlobalCropSeasonLoading,c=a.find((function(e){return e.id===t}));return Object(y.jsx)("div",{style:{display:"flex",alignItems:"center",marginRight:8},children:r?Object(y.jsx)("div",{"data-testid":"rendertag-loading",className:"flex items-center px-1 rounded border border-neutral-100 bg-neutral-100",children:Object(y.jsx)(Xc.Spin,{size:"small"})}):Object(y.jsxs)("div",{"data-testid":"render-tag",className:"flex items-center px-1 pl-2 gap-1 rounded border border-neutral-100 bg-neutral-100",children:[Object(y.jsx)(Ag,{cropObject:c,size:14}),Object(y.jsx)("div",{className:"text-neutral-60 font-body text-xs font-semibold",children:null===c||void 0===c?void 0:c.name}),Object(y.jsx)("button",{type:"button",onClick:n,children:Object(y.jsx)("img",{src:kS,alt:"close button",width:16,height:16})})]})})}function B5(e){var t=e.omittedValues;return Object(y.jsx)("div",{className:"flex h-full items-center px-1 pl-2  rounded border border-neutral-100 bg-neutral-100",children:Object(y.jsx)("div",{className:"text-neutral-60 font-body text-xs font-semibold",children:"+ ".concat(null===t||void 0===t?void 0:t.length," more")})})}function U5(e){var t=e.cropsFilterValue,n=e.cropsFilterValueChange,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(a.useContext)(ac),l=Object(b.a)(s,1)[0],d=l.cropSeasons,u=l.isGlobalCropSeasonLoading,j=Object(a.useContext)(we),p=Object(a.useMemo)((function(){var e=JSON.parse(localStorage.getItem("selectedCropSeasons"))||[];if(null!==d&&void 0!==d&&d.length){var a=[],r=null===d||void 0===d?void 0:d.filter((function(t){return e.includes(t.id)})).map((function(e){return e.crops})).flat().filter((function(e){return!(null===e||void 0===e||!e.id||a.includes(e.id))&&(a.push(e.id),!0)})).sort((function(e,t){return e.name.localeCompare(t.name)}));if(t.length){var c=null===r||void 0===r?void 0:r.map((function(e){return null===e||void 0===e?void 0:e.id})),i=t.filter((function(e){return c.includes(e)}));n(i)}return r}return[]}),[d]),f=Object(a.useCallback)((function(e){var t=e.value,n=e.onClose;return Object(y.jsx)(V5,{value:t,onClose:n,cropsOfSelectedSeasons:p,isGlobalCropSeasonLoading:u})}),[p,u]),m=Object(a.useCallback)((function(e){return Object(y.jsx)(B5,{omittedValues:e})}),[]);return Object(y.jsx)("div",{className:"select-container",children:Object(y.jsx)(Xc.Select,{notFoundContent:u?Object(y.jsx)(Xc.Spin,{size:"small"}):"No data","data-testid":"filter-by-crops-select-input",value:t,onChange:function(e){var a,r,c=null===e||void 0===e||null===(a=e.filter((function(e){return!(null!==t&&void 0!==t&&t.includes(e))})))||void 0===a?void 0:a[0];c&&function(e){j.sendEventToAmplitude(j.events.epic.YieldV2.loads.selectCrop,{crop:e})}(null===(r=p.find((function(e){return e.id===c})))||void 0===r?void 0:r.name);n(e)},open:i,onDropdownVisibleChange:function(e){return o(e)},showArrow:!0,suffixIcon:Object(y.jsx)("img",{src:Di,style:{transform:i?"rotate(180deg)":null},height:18,width:18,alt:"Select dropdown icon"}),mode:"multiple",style:{width:"100%"},placeholder:"All Crops",tagRender:f,optionLabelProp:"label",maxTagCount:"responsive",maxTagPlaceholder:m,showSearch:!1,children:p.map((function(e){return Object(y.jsx)(Xc.Select.Option,{className:"select-option",value:e.id,label:e.name,children:Object(y.jsxs)("div",{className:"flex items-center h-8 pl-4 py-1.5",children:[Object(y.jsx)(Xc.Checkbox,{checked:t.includes(e.id),className:"mr-4"}),Object(y.jsx)(Ag,{cropObject:e,size:16}),Object(y.jsx)("div",{className:"ml-2",children:e.name})]})},e.id)}))})})}V5.defaultProps={onClose:function(){},cropsOfSelectedSeasons:[],isGlobalCropSeasonLoading:!1,value:[]},B5.defaultProps={omittedValues:[]},U5.defaultProps={cropsFilterValue:[""],cropsFilterValueChange:function(){}};n(1692);function z5(e){var t=e.searchValue,n=e.onSearchChange,r=e.cropsFilterValue,c=e.cropsFilterValueChange,i=e.onFilterButtonClick,o=e.areFiltersApplied,s=e.addYieldLoads,l=Object(a.useContext)(we);return Object(y.jsxs)("div",{"data-testid":"actions-topbar",className:"flex items-center justify-between h-16",children:[Object(y.jsxs)("div",{className:"flex items-center gap-4 flex-1 max-w-3xl",children:[Object(y.jsx)("div",{"data-testid":"search-loads-input",className:"flex-1",children:Object(y.jsx)(Xc.Input,{className:"search-loads-input",type:"default",style:{margin:0},prefix:Object(y.jsx)("img",{alt:"Search icon",src:Fi}),placeholder:"Search loads",allowClear:!0,size:"middle",value:t,onChange:function(e){return n(e.target.value)}})}),Object(y.jsx)("div",{"data-testid":"crops-input",className:"flex-1 z-10",children:Object(y.jsx)(U5,{cropsFilterValue:r,cropsFilterValueChange:c})}),Object(y.jsx)("div",{className:"h-max filter-button","data-testid":"filter-button",children:Object(y.jsx)(Xc.Badge,{dot:!0,color:"#0092E4",size:"default",count:o?1:0,showZero:!1,children:Object(y.jsx)(m.Button,{type:"outline",style:{height:"100%"},onClick:i,icon:Object(y.jsx)("img",{src:oB,alt:"Filter button"}),children:"Filter"})})})]}),Object(y.jsx)("div",{"data-testid":"add-yield-load",children:Object(y.jsx)(m.Button,{icon:Object(y.jsx)(Ii.a,{}),type:"primary",onClick:function(){l.sendEventToAmplitude(l.events.epic.YieldV2.addYield.createYield),s()},children:"Yield Loads"})})]})}z5.defaultProps={cropsFilterValue:[],cropsFilterValueChange:function(){},onSearchChange:function(){},onFilterButtonClick:function(){},addYieldLoads:function(){},areFiltersApplied:!1,searchValue:""};var Z5=n.p+"static/media/filter_outlined_white.495f083c.svg";function Y5(e){var t=e.addYieldLoads,n=e.areFiltersApplied,r=e.onAdjustFilters,c=e.onClearFilters,i=e.isSearchApplied,o=Object(a.useContext)(we);return i?Object(y.jsx)(jw,{overlayIcon:fw,title:"No Loads Found",message:"Change the selected season or try a different search."}):n?Object(y.jsx)(jw,{overlayIcon:fw,title:"No Loads Found",message:"Clear or adjust filter selections to see load information.",button:Object(y.jsxs)("div",{className:"flex items-center gap-2",children:[Object(y.jsx)(m.Button,{icon:Object(y.jsx)("img",{src:Z5,alt:"Filter button"}),type:"primary",onClick:r,children:"Adjust filters"}),Object(y.jsx)(m.Button,{type:"outline",onClick:c,children:"Clear Selections"})]})}):Object(y.jsx)(jw,{overlayIcon:pw,title:"No Loads Found",message:"Add a new Yield Load or change the selected season.",button:Object(y.jsx)(m.Button,{icon:Object(y.jsx)(Ii.a,{}),type:"primary",onClick:function(){o.sendEventToAmplitude(o.events.epic.YieldV2.addYield.createYield),t()},children:"Yield Loads"})})}Y5.defaultProps={addYieldLoads:function(){},onAdjustFilters:function(){},onClearFilters:function(){},areFiltersApplied:!1,isSearchApplied:!1};var H5=n.p+"static/media/properties.7d98863c.svg",G5=n.p+"static/media/storefront.4650b676.svg",W5=n.p+"static/media/arrow-forward.fc4d4e89.svg",q5=function(e){var t=e.icon,n=e.name;return Object(y.jsxs)("div",{className:"flex",children:[Object(y.jsx)("img",{src:t,alt:"".concat(n,"-icon"),className:"w-20px h-20px mr-1"}),Object(y.jsx)("span",{className:"text-black font-sans text-sm font-normal leading-5 tracking-tight",children:n})]})},J5={Properties:Object(y.jsx)(q5,{icon:H5,name:"Properties"}),Sale:Object(y.jsx)(q5,{icon:G5,name:"Sale"}),Storage:Object(y.jsx)(q5,{icon:zZ,name:"Storage"})},K5=function(e){var t,n=e.value,a=e.from,r=e.to,c=Object(Zi.h)().values;return Object(y.jsxs)("div",{className:"flex items-center py-6px cwf-yield-load-type",children:[Object(y.jsx)(Qi,{control:m.Checkbox,name:"loadtype",value:n,checked:null===(t=c.loadtype)||void 0===t?void 0:t.includes(n)}),Object(y.jsxs)("div",{className:"flex items-center ml-2",children:[a,Object(y.jsx)("img",{src:W5,alt:"load-target",className:"mx-1"}),r]})]})},Q5=function(e){var t=e.title,n=e.children,r=e.collapsible,c=e.extraInfo,i=Object(a.useState)(!1),o=Object(b.a)(i,2),s=o[0],l=o[1];return Object(y.jsx)("section",{className:"pl-5 pr-28px ".concat(r?"":"pb-5"," border-b border-neutral-20 border-solid"),children:r?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("button",{className:"w-full flex flex-row items-center justify-between focus:outline-none py-18px",type:"button",onClick:function(){l(!s)},children:[Object(y.jsx)("span",{className:"text-black font-sans text-normal font-semibold leading-5 tracking-tight",children:t}),Object(y.jsx)("img",{className:"pr-4",src:s?EP:Di,alt:"expand collapse accordion"})]}),s&&Object(y.jsx)("div",{className:"pb-4",children:n})]}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("h1",{className:"w-full flex flex-row items-center justify-between py-18px text-black font-sans text-normal font-semibold leading-5 tracking-tight",children:[t,c]}),n]})})};Q5.defaultProps={collapsible:!1,extraInfo:null};var X5=Q5,$5=function(e){var t=e.filters,n=B0(),r=n.isLoadingSaleLocationList,c=n.getSaleLocationList,i=n.saleLocationList,o=Object(a.useContext)(ac),s=Object(b.a)(o,1)[0].organization;return Object(a.useEffect)((function(){c(s.id)}),[]),Object(y.jsx)(y.Fragment,{children:r?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(y.Fragment,{children:(null===i||void 0===i?void 0:i.length)>0?null===i||void 0===i?void 0:i.map((function(e){var n;return Object(y.jsxs)("div",{className:"flex items-center py-6px",children:[Object(y.jsx)(Qi,{control:m.Checkbox,name:"saleIds",value:e.id,checked:null===(n=t.saleIds)||void 0===n?void 0:n.includes(e.id)}),Object(y.jsx)("p",{className:"ml-2",children:null===e||void 0===e?void 0:e.name})]},null===e||void 0===e?void 0:e.id)})):Object(y.jsx)("div",{className:"text-neutral-60 text-sm ",children:"No sale locations found."})})})},e3=function(e){var t=e.filters,n=T$(),r=n.loading,c=n.fetchStorageLocations,i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1];return Object(a.useEffect)((function(){var e=function(){var e=Object(Y.a)(G.a.mark((function e(){var t,n;return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c();case 2:t=e.sent,n=t.data,l(n);case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}),[]),Object(y.jsx)(y.Fragment,{children:r?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(y.Fragment,{children:(null===s||void 0===s?void 0:s.length)>0?null===s||void 0===s?void 0:s.map((function(e){var n;return Object(y.jsxs)("div",{className:"flex items-center pl-2 py-6px",children:[Object(y.jsx)(Qi,{control:m.Checkbox,name:"storageIds",value:e.id,checked:null===(n=t.storageIds)||void 0===n?void 0:n.includes(e.id)}),Object(y.jsx)("p",{className:"ml-2",children:null===e||void 0===e?void 0:e.name})]},null===e||void 0===e?void 0:e.id)})):Object(y.jsx)("div",{className:"text-neutral-60 text-sm ",children:"No storage locations found."})})})},t3=n.p+"static/media/crop_zone_primary.b3f5e999.svg",n3=function(e){var t,n=e.hideClearButton,r=Object(a.useState)(!1),c=Object(b.a)(r,2),i=c[0],o=c[1],s=Object(Zi.h)(),l=s.setFieldValue,d=s.values,u=(null===d||void 0===d||null===(t=d.cropZones)||void 0===t?void 0:t.length)||0;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex justify-center gap-4",children:[Object(y.jsx)(m.Button,{ghost:!0,type:"primary",className:"w-full",onClick:function(){return o(!0)},icon:Object(y.jsx)("img",{src:t3,alt:"cropzone icon"}),children:"Select Properties"}),!n&&Object(y.jsx)(m.Button,{type:"outline",onClick:function(){l("cropZones",[]),l("totalAcres",null)},className:"w-full",disabled:!u,children:"Clear Selections"})]}),i&&Object(y.jsx)(Y2,{open:!0,onClose:function(){return o(!1)}})]})};n3.defaultProps={hideClearButton:!1};var a3=n3,r3=(n(1693),{"properties-to-storage":{sourceType:"CROP_ZONE",destinationType:"STORAGE"},"properties-to-sale":{sourceType:"CROP_ZONE",destinationType:"SALE"},"storage-to-storage":{sourceType:"STORAGE",destinationType:"STORAGE"},"storage-to-sale":{sourceType:"STORAGE",destinationType:"SALE"}}),c3=function(e){return e?e.map((function(e){var t=e.sourceType,n=e.destinationType;return Object.keys(r3).find((function(e){return r3[e].sourceType===t&&r3[e].destinationType===n}))})).filter((function(e){return void 0!==e})):[]},i3=function(e){var t=e.visible,n=e.appliedFilters,r=e.onApplyFilters,c=e.onClearFilters,i=e.onClose,o=Object(a.useState)(n),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useMemo)((function(){return Object.values(n).every((function(e){return 0===(null===e||void 0===e?void 0:e.length)}))&&Object.values(l).every((function(e){return 0===(null===e||void 0===e?void 0:e.length)}))}),[n,l]);return Object(y.jsx)(Zi.e,{enableReinitialize:!0,initialValues:Object(I.a)(Object(I.a)({},n),{},{loadtype:c3(null===n||void 0===n?void 0:n.loadtype)}),onSubmit:function(e){var t,n=Object(I.a)(Object(I.a)({},e),{},{loadtype:null!==e&&void 0!==e&&null!==(t=e.loadtype)&&void 0!==t&&t.length?null===e||void 0===e?void 0:e.loadtype.map((function(e){return r3[e]})):void 0});r(n),i()},onReset:function(){d({}),c(),i()},validate:d,children:function(e){var n,a,r=e.handleSubmit,c=e.resetForm,o=e.values;return Object(y.jsx)(Xc.Drawer,{maskClosable:!0,open:t,className:"cwf-yield-loads-filter-drawer",placement:"right",closable:!1,onClose:i,bodyStyle:{padding:0},width:"360px",footer:Object(y.jsxs)(Xc.Row,{justify:"end",children:[Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.default,className:"mr-10px bg-transparent border-0",onClick:i,children:"Cancel"}),Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.primary,onClick:r,disabled:u,children:"Apply"})]}),children:Object(y.jsxs)("div",{className:"h-full","data-testid":"loads-filter-drawer",children:[Object(y.jsxs)("header",{className:"flex justify-between pl-5 pb-21px pr-28px pt-26px",children:[Object(y.jsx)("h1",{className:"font-sans text-xl font-semibold leading-7 tracking-tighter",children:"Filter"}),Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.outline,size:"small",onClick:c,disabled:u,children:"Clear All"})]}),Object(y.jsx)(X5,{title:"Date Range",children:Object(y.jsx)(Qi,{control:m.DatePicker,id:"daterange",name:"daterange",isRangePicker:!0})}),Object(y.jsxs)(X5,{title:"Load Type",children:[Object(y.jsx)(K5,{value:"properties-to-storage",from:J5.Properties,to:J5.Storage}),Object(y.jsx)(K5,{value:"properties-to-sale",from:J5.Properties,to:J5.Sale}),Object(y.jsx)(K5,{value:"storage-to-storage",from:J5.Storage,to:J5.Storage}),Object(y.jsx)(K5,{value:"storage-to-sale",from:J5.Storage,to:J5.Sale})]}),Object(y.jsx)(X5,{title:"Properties",extraInfo:Object(y.jsxs)("div",{className:"text-normal font-normal leading-5 tracking-tighter",children:[Object(y.jsx)("span",{className:"text-neutral-60 opacity-50 border-r border-solid pr-2",children:"".concat((null===o||void 0===o||null===(n=o.cropZones)||void 0===n?void 0:n.length)||0," crop zone").concat(1===(null===o||void 0===o||null===(a=o.cropZones)||void 0===a?void 0:a.length)?"":"s")}),Object(y.jsxs)("span",{className:"text-neutral-60 opacity-50 pl-2",children:[(null===o||void 0===o?void 0:o.totalArea)||"0"," ac"]})]}),children:Object(y.jsx)(a3,{})}),Object(y.jsx)(X5,{title:"Storage Locations",collapsible:!0,children:Object(y.jsx)(e3,{filters:o})}),Object(y.jsx)(X5,{title:"Sale Locations",collapsible:!0,children:Object(y.jsx)($5,{filters:o})})]})})}},JSON.stringify(n))};i3.defaultProps={appliedFilters:{}};var o3=i3,s3=function(e){var t=e.id,n=e.open,r=e.onCancel,c=e.onResult,i=VZ(),o=i.deleteLoad,s=i.loading,l=Object(a.useContext)(we),d=function(){var e=Object(Y.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l.sendEventToAmplitude(l.events.epic.YieldV2.loads.deleteYield),e.next=3,o({id:t}).then((function(e){c(200===e?{type:"success",title:"Load deleted.",message:"",showToast:!0}:{type:"error",title:"Unable to delete load.",message:"An error prevented your load from being deleted. Please try again.",showToast:!0}),r(!1)}));case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return n?s?Object(y.jsx)(si,{open:!0,message:"Deleting Load..."}):Object(y.jsx)(ib,{open:n,type:"error",itemType:"Load",onCancel:r,onDelete:d}):null},l3=function(){var e,t,n,r=Object(p.h)(),c=Object(a.useContext)(ac),i=Object(b.a)(c,1)[0],o=i.cropSeasons,s=i.isGlobalCropSeasonLoading,l=Object(a.useRef)(0),d=Object(a.useState)(""),u=Object(b.a)(d,2),j=u[0],f=u[1],v=zi(j,300),O=Object(a.useState)([]),h=Object(b.a)(O,2),x=h[0],g=h[1],C=Object(a.useState)(!1),P=Object(b.a)(C,2),A=P[0],S=P[1],T=Object(a.useState)({}),N=Object(b.a)(T,2),E=N[0],w=N[1],_=QM({}),R=_.reactUiKitTableOnChange,I=_.reactUiKitTablePaginationProp,D=_.page,k=_.pageSize,L=_.sortBy,F=_.sortDir,M=_.setTotalItemsCount,V=VZ(),B=V.getLoads,U=V.loading,z=Object(a.useState)([]),Z=Object(b.a)(z,2),Y=Z[0],H=Z[1],G=Object(a.useState)(""),W=Object(b.a)(G,2),q=W[0],J=W[1],K=Object(a.useState)(!1),Q=Object(b.a)(K,2),X=Q[0],$=Q[1],ee=Object(a.useMemo)((function(){return!!E&&Object.values(E).some((function(e){return Array.isArray(e)?e.length>0:!!e}))}),[E]),te=Object(a.useMemo)((function(){return null!==o&&void 0!==o&&o.length?JSON.parse(localStorage.getItem("selectedCropSeasons")):[]}),[o]),ne=function(){var e,t;l.current+=1;var n=l.current;B({limit:k,page:D-1,sortBy:L,sortDir:{ascend:"asc",descend:"desc"}[F],seasonIds:te,cropIds:x,searchQuery:v,startDate:null===E||void 0===E||null===(e=E.daterange)||void 0===e?void 0:e[0],endDate:null===E||void 0===E||null===(t=E.daterange)||void 0===t?void 0:t[1],loadTypes:null===E||void 0===E?void 0:E.loadtype,cropZoneIds:null===E||void 0===E?void 0:E.cropZones,storageIds:null===E||void 0===E?void 0:E.storageIds,saleIds:null===E||void 0===E?void 0:E.saleIds}).then((function(e){n===l.current&&(M(null===e||void 0===e?void 0:e.elements),H(null===e||void 0===e?void 0:e.data))}))};Object(a.useEffect)((function(){null!==te&&void 0!==te&&te.length&&ne()}),[te,x,v,E,D,L,F]),Object(a.useEffect)((function(){var e=new URLSearchParams(location.search),t=e.get("search"),n=e.get("cropsFilters"),a=e.get("filters");t&&f(t),n&&g(n.split(",")),a&&w(JSON.parse(a))}),[]),Object(a.useEffect)((function(){!function(){var e=new URLSearchParams;v&&e.set("search",v),x.length&&e.set("cropsFilters",x.join(",")),Object.keys(E).length&&e.set("filters",JSON.stringify(E)),r.replace({search:e.toString()})}()}),[v,x,r,E]);var ae=function(){S((function(e){return!e}))},re=function(){w({})},ce=function(){var e=JSON.parse(localStorage.getItem("selectedCropSeasons"));if(e.length>1){var t=null===o||void 0===o?void 0:o.find((function(t){var n;return e.includes(null===t||void 0===t?void 0:t.id)&&(null===t||void 0===t||null===(n=t.crops)||void 0===n?void 0:n.length)>0}));t&&localStorage.setItem("selectedCropSeasons",JSON.stringify([null===t||void 0===t?void 0:t.id]))}r.push("".concat(Cc.yieldV2,"/create"))},ie=Object(a.useCallback)((function(e){r.push("".concat(Cc.yieldV2,"/loads/").concat(e,"/view"))}),[r]),oe=Object(a.useState)(null===(e=r.location)||void 0===e||null===(t=e.toast)||void 0===t?void 0:t.showToast),se=Object(b.a)(oe,2),le=se[0],de=se[1],ue=Object(a.useState)(null===(n=r.location)||void 0===n?void 0:n.toast),be=Object(b.a)(ue,2),je=be[0],pe=be[1],fe=Object(a.useContext)(ac),me=Object(b.a)(fe,2)[1];return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(s3,{id:q,open:X,onCancel:$,onResult:function(e){pe(e),de(!0),"success"===(null===e||void 0===e?void 0:e.type)&&ne()}}),Object(y.jsx)(lo,{hideCropSeasonDropdown:!1,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Loads",isLast:!0})}),Object(y.jsxs)("div",{"data-testid":"loads-container ",className:"h-full max-h-full px-4",children:[Object(y.jsx)(z5,{searchValue:j,onSearchChange:function(e){f(e)},cropsFilterValue:x,cropsFilterValueChange:function(e){g(e)},onFilterButtonClick:ae,areFiltersApplied:ee,addYieldLoads:ce}),U||s?Object(y.jsxs)("div",{"data-testid":"loading-container",className:"bg-white rounded-lg shadow-sm-card border-1 border-neutral-30 h-90/100 flex flex-col items-center justify-center",children:[Object(y.jsx)("div",{children:Object(y.jsx)(m.Spinner,{})}),Boolean(v)&&Object(y.jsx)("p",{className:"font-semibold text-base leading-6 tracking-tight text-center mt-4",children:"Searching Loads..."}),ee&&Object(y.jsx)("p",{className:"font-semibold text-base leading-6 tracking-tight text-center mt-4",children:"Filtering Loads..."})]}):Object(y.jsx)(y.Fragment,{children:0===(null===Y||void 0===Y?void 0:Y.length)?Object(y.jsx)("div",{"data-testid":"empty-state-container",className:"py-20 bg-white rounded-lg shadow-sm-card border-1 border-neutral-30",children:Object(y.jsx)(Y5,{addYieldLoads:ce,areFiltersApplied:ee,onAdjustFilters:ae,onClearFilters:re,isSearchApplied:Boolean(v)})}):Object(y.jsx)(GZ,{tableData:Y,onRecordView:ie,onRecordDelete:function(e){J(e),$(!0)},onRecordEdit:function(e){r.push("".concat(Cc.yieldV2,"/loads/").concat(e,"/edit"))},pagination:I,onChange:R,sortBy:L,sortDir:F})})]}),Object(y.jsx)(o3,{appliedFilters:E,visible:A,onClose:ae,onApplyFilters:function(e){w(e)},onClearFilters:re}),Object(y.jsx)(A5,{onCloseHandler:function(){me({type:Zr,payload:"null"}),me({type:zr,payload:"null"}),me({type:Ur,payload:!1}),me({type:Yr,payload:!1}),de(!1)},showToast:le,toastType:null===je||void 0===je?void 0:je.type,title:null===je||void 0===je?void 0:je.title,description:null===je||void 0===je?void 0:je.message})]})},d3=Object(a.createContext)(),u3=function(e){var t=e.children,n=Object(p.h)(),r=function(){n.push("".concat(Cc.yieldV2,"/sale-locations/create"))},c=Object(a.useMemo)((function(){return{handleCreate:r}}),[]);return Object(y.jsx)(d3.Provider,{value:c,children:t})};u3.defaultProps={children:null};var b3=function(e){var t=e.elementList,n=e.type,a=e.typeIcon,r=e.headerActions,c=e.setValueSelected,i=e.selectedValueId,o=e.isLoadingLeftSide,s=e.emptyState,l=e.getSaleLocationById,d=e.renderItem;return Object(y.jsxs)("div",{className:"w-332px h-full bg-white","data-testid":"left-side-layout",children:[Object(y.jsxs)("div",{className:"w-full h-120px p-4 border-b",children:[Object(y.jsxs)("div",{className:"flex flex-row items-center",children:[Object(y.jsx)("img",{className:"mr-1 ml-1",src:a,alt:"Icon"}),Object(y.jsx)("span",{className:"font-semibold text-2xl",children:n})]}),r]}),Object(y.jsx)("div",{className:"overflow-y-auto flex flex-col pb-4 default-fft h-84/100",children:o?Object(y.jsx)(m.Spinner,{size:"lg"}):Object(y.jsx)(y.Fragment,{children:t.length?Object(y.jsx)(m.Table,{children:null===t||void 0===t?void 0:t.map((function(e){return Object(y.jsx)(m.Table.Row,{onClick:function(){return function(e){i!==e.id&&(l(e.id),c(e))}(e)},className:e.id===i?"bg-selectedBlue":"",children:Object(y.jsx)(m.Table.Cell,{children:Object(y.jsx)(d,{element:e,isSelected:e.id===i})})},e.id)}))}):s})})]})};b3.defaultProps={type:"",setValueSelected:function(){},emptyState:null,selectedValueId:"",renderItem:function(){},getSaleLocationById:function(){}};var j3=b3,p3=function(e){var t=e.open,n=e.loading,a=e.onCancel,r=e.onSubmit;return t?n?Object(y.jsx)(si,{open:!0,message:"Deleting Sale Location..."}):Object(y.jsx)(m.SimpleModal,{title:Object(y.jsx)("span",{className:"font-semibold",children:"Delete Location?"}),type:"error",open:t,close:a,confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:r,children:Object(y.jsx)("div",{className:"pr-6",children:"Are you sure you want to delete this location?"})}):null},f3=function(e){var t=e.header,n=e.saleLocationId,r=e.saleLocationList,c=e.setSaleLocationList,i=e.isFetchingSaleLocation,o=e.hasAssociatedYields,s=Object(p.h)(),l=Object(a.useState)(),d=Object(b.a)(l,2),u=d[0],j=d[1],f=Object(a.useContext)(we),v=B0(),O=v.deleteSaleLocation,h=v.isDeletingSaleLocation,x=function(){j(!1)};return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)("div",{className:"flex flex-row items-center bg-white border border-t-0 h-16 justify-between p-6",children:i?Object(y.jsx)(m.Spinner,{size:"lg"}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)("img",{className:"mr-2",src:G5,alt:"Icon"}),Object(y.jsx)("span",{className:"font-semibold text-2xl",children:t})]}),Object(y.jsxs)("div",{className:"flex flex flex-row w-50 justify-end",children:[Object(y.jsx)(Xc.Button,{onClick:function(){s.push("".concat(Cc.yieldV2,"/sale-locations/").concat(n,"/edit"))},type:Xc.ButtonType.outline,icon:Object(y.jsx)("img",{className:"mr-1",width:18,src:DI,alt:"edit icon"}),children:"Edit"}),Object(y.jsx)("div",{className:"w-4"}),Object(y.jsx)(Xc.Tooltip,{overlayClassName:"max-w-full",title:o?"Locations that are associated with loads cannot be deleted":null,placement:"topRight",children:Object(y.jsx)("div",{children:Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.outline,disabled:o,onClick:function(){j(!0)},icon:Object(y.jsx)(BX,{width:18}),children:"Delete"})})})]})]})}),Object(y.jsx)(p3,{open:u,loading:h,onCancel:x,onSubmit:function(){f.sendEventToAmplitude(f.events.epic.YieldV2.saleLocations.deleteSaleLocation),O(n,x,r,c)}})]})},m3=function(e){var t=e.children,n=e.optionalClasses;return Object(y.jsx)("div",{className:"shadow-card rounded-md bg-white h-auto w-96/100 p-8 ".concat(n),"data-testid":"details-container",children:t})};m3.defaultProps={optionalClasses:""};var v3=m3,O3=function(e){var t,n=e.selectedLocation,a=e.saleLocationList,r=e.setSaleLocationList,c=e.isFetchingSaleLocation,i="w-1/4",o="w-3/4",s="mt-2 mb-4",l=n||{},d=l.id,u=l.name,b=l.email,j=l.phone,p=l.addressLineOne,f=l.addressLineTwo,v=l.city,O=l.state,h=l.zipCode,x=l.notes,g=l.hasAssociatedYields,C=(n.company||{}).name;(p||f||v||O||h)&&(t=[p&&"".concat(p,"\n"),f&&"".concat(f,"\n"),v&&"".concat(v,","),O&&"".concat(O),h&&" ".concat(h)].filter(Boolean).join(" ").trim());return Object(y.jsx)("div",{"data-testid":"sale-location-details",className:"w-full h-full",children:c?Object(y.jsx)(m.Spinner,{size:"lg"}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(f3,{header:u,saleLocationId:d,saleLocationList:a,setSaleLocationList:r,hasAssociatedYields:g}),Object(y.jsxs)("div",{className:"flex flex-col items-center mt-2",children:[Object(y.jsxs)(v3,{optionalClasses:s,children:[Object(y.jsx)(oE,{label:"Email Address",value:b,WidthLabel:i,widthValue:o,ghostValue:!b}),Object(y.jsx)(oE,{label:"Phone",value:J0(null!==j&&void 0!==j?j:""),WidthLabel:i,widthValue:o,ghostValue:!j}),Object(y.jsx)(oE,{label:"Company",value:C,icon:q0,displayIcon:C,WidthLabel:i,widthValue:o,ghostValue:!C}),Object(y.jsx)(oE,{label:"Address",value:t,WidthLabel:i,widthValue:o,ghostValue:!t})]},"generalInfo"),Object(y.jsxs)(v3,{className:s,children:[Object(y.jsx)("span",{className:"font-semibold text-base",children:"Notes"}),Object(y.jsx)("p",{className:"text-sm font-normal mt-2 ".concat(!x&&"text-gray-500"),children:x||"None Entered"})]},"noteInfo")]})]})})};O3.defaultProps={selectedLocation:{email:"",phone:"",company:{},addressLineOne:"",addressLineTwo:"",city:"",state:"",zipCode:"",notes:""}};var h3=O3,x3=function(){return Object(y.jsx)("div",{className:"h-full w-full flex flex-row justify-center mt-8",children:Object(y.jsx)("span",{children:"No sale locations found"})})},g3=function(e){var t=e.sortItems,n=e.onSort,r=e.orgId,c=e.sortRules,i=e.setSortRules,o=Object(a.useState)(!1),s=Object(b.a)(o,2),l=s[0],d=s[1],u=Object(a.useState)(0),j=Object(b.a)(u,2),p=j[0],f=j[1],v=Object(a.useRef)(null);return Object(a.useEffect)((function(){c&&n(r,c)}),[c]),Object(a.useEffect)((function(){return c?(f(t.findIndex((function(e){return(null===e||void 0===e?void 0:e.sortKey)===(null===c||void 0===c?void 0:c.sortBy)}))),n(r,c),function(){}):(i({sortBy:t[p].sortKey,sortDir:t[p].sortDirection}),function(){})}),[r]),Object(a.useEffect)((function(){var e=function(e){v.current&&!v.current.contains(e.target)&&d(!1)};return document.addEventListener("click",e),function(){document.removeEventListener("click",e)}}),[]),Object(y.jsxs)("div",{style:{width:"45%"},ref:v,children:[Object(y.jsxs)(m.Button,{onClick:function(){d(!l)},style:{width:"100%"},type:"outline",ghost:!0,children:[Object(y.jsx)("div",{className:"flex flex-row relative bg-color",children:Object(y.jsx)("img",{className:"mr-1",src:l0,alt:"Sort Icon"})}),"Sort"]}),l&&Object(y.jsx)("div",{className:"w-40 h-35 absolute bg-white z-50 mt-2 shadow-card rounded ",children:Object(y.jsx)("div",{className:"w-full h-full flex flex-col justify-center",children:null===t||void 0===t?void 0:t.map((function(e,t){return Object(y.jsx)(pu,{className:"".concat(t===p?"bg-selectedBlue":"",' "h-8 '),onClick:function(){return function(e,t,n){f(e),i({sortBy:t,sortDir:n}),d(!1)}(t,e.sortKey,e.sortDirection)},children:Object(y.jsx)("div",{className:"w-full h-full p-2 ".concat(t===p&&"font-semibold"),children:e.sortLabel})},e.sortKey)}))})})]})},C3="(A \u2192 Z)",y3=[{sortLabel:"Location Name ".concat(C3),sortKey:"name",sortDirection:"asc"},{sortLabel:"City ".concat(C3),sortKey:"city",sortDirection:"asc"},{sortLabel:"Company ".concat(C3),sortKey:"company",sortDirection:"asc"}],P3=function(e){var t=e.onCreate,n=e.onSort,r=Object(a.useContext)(ac),c=Object(b.a)(r,2),i=c[0],o=i.organization,s=i.sortRules,l=c[1];return Object(y.jsxs)("div",{className:"w-full flex flex-row justify-around pt-3",children:[Object(y.jsx)(m.Button,{style:{width:"45%"},icon:Object(y.jsx)(Ii.a,{style:{width:"70%"}}),type:"primary",onClick:t,children:Object(y.jsx)("span",{style:{marginLeft:"-4px"},children:"Create New"})}),Object(y.jsx)(g3,{sortItems:y3,onSort:n,orgId:o.id,sortRules:s,setSortRules:function(e){jc(l,qr,e)}})]})},A3=function(e){var t=e.element,n=e.isSelected,a=t||{},r=a.name,c=a.company,i=a.city,o=a.state,s=(c||{}).name,l=function(){return Object(y.jsx)("div",{className:"h-20px w-1px bg-neutral-20 mx-2"})};return Object(y.jsx)("div",{className:"w-full h-56px pl-2",children:Object(y.jsxs)("div",{className:"flex flex-row h-full items-center",children:[n&&Object(y.jsx)("div",{"data-testid":"selected-indicator",className:"w-1 h-90/100 flex-shrink-0 rounded-r-md bg-blue-50 absolute left-0"}),Object(y.jsxs)("div",{className:"flex flex-col justify-start",children:[Object(y.jsx)("p",{className:"text-left text-base ".concat(n?"font-semibold":"font-normal"),children:r}),Object(y.jsx)("div",{children:Object(y.jsx)("p",{className:"text-sm text-left font-normal flex flex-row items-center text-neutral-60 pt-2","data-testid":"sub-element",children:[s,i&&s&&Object(y.jsxs)(y.Fragment,{children:[l(),i,o&&", "]}),i&&!s&&Object(y.jsxs)(y.Fragment,{children:[i,o&&", "]}),!i&&" ",o&&Object(y.jsxs)(y.Fragment,{children:[s&&!i&&l(),o]})]})})]})]})})};A3.defaultProps={};var S3=A3,T3=function(){var e=Object(p.h)(),t=B0(),n=t.getSaleLocationList,r=t.saleLocationList,c=t.setSaleLocationList,i=t.isLoadingSaleLocationList,o=t.getSaleLocationById,s=t.isFetchingSaleLocation,l=t.saleLocation,d=Object(a.useContext)(d3).handleCreate,u=Object(a.useContext)(ac),j=Object(b.a)(u,2),f=j[0],v=f.showToastSaleLocation,O=f.toastType,h=f.selectedLocation,x=f.organization,g=f.loadingOrg,C=j[1],P=Object(a.useState)(),A=Object(b.a)(P,2),S=A[0],T=A[1],N=function(t){var n=new URLSearchParams(location.search).get("saleId");if(null!==t&&void 0!==t&&t.id&&n!==(null===t||void 0===t?void 0:t.id)){var a=new URLSearchParams;a.set("saleId",t.id),e.replace({search:a.toString()})}jc(C,Jr,t)};return Object(a.useEffect)((function(){if(!i&&r.length&&!g){var e,t,n=new URLSearchParams(location.search).get("saleId");if(!n)return N(null!==h&&void 0!==h&&h.id?h:r[0]),void o(null!==(e=null===h||void 0===h?void 0:h.id)&&void 0!==e?e:null===(t=r[0])||void 0===t?void 0:t.id);var a=r.find((function(e){return e.id===n}));if(!a)return N(r[0]),void o(r[0].id);N(a),o(a.id)}}),[r,i,x]),Object(a.useEffect)((function(){var e=Object(I.a)(Object(I.a)({},h),l);jc(C,Jr,e)}),[l]),Object(a.useEffect)((function(){T(v)}),[v]),Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(lo,{children:Object(y.jsx)(lo.Item,{title:"Yield",value:"Sale Locations",isLast:!0})}),g?Object(y.jsx)(m.Spinner,{size:"lg"}):Object(y.jsxs)("div",{className:"w-full h-full flex flex-row",children:[Object(y.jsx)("div",{children:Object(y.jsx)(j3,{emptyState:Object(y.jsx)(x3,{}),type:"Sale",typeIcon:G5,headerActions:Object(y.jsx)(P3,{onCreate:d,onSort:n}),elementList:r,setValueSelected:N,valueSelected:h,isLoadingLeftSide:i,renderItem:S3,selectedValueId:null===h||void 0===h?void 0:h.id,getSaleLocationById:o})}),!i&&(r.length>0&&Object(y.jsx)(h3,{selectedLocation:h,saleLocationList:r,setSaleLocationList:c,isFetchingSaleLocation:s})||Object(y.jsx)("div",{className:"bg-white m-4 h-356px w-full rounded-lg shadow-sm-card",children:Object(y.jsx)(jw,{overlayIcon:BV,title:"No Sale Locations Found",button:Object(y.jsx)(Xc.Button,{style:{width:"160px"},icon:Object(y.jsx)(Ii.a,{}),type:"primary",onClick:d,children:"Create Location"})})}))]}),S&&Object(y.jsx)(U0,{showToast:S,setShowToast:function(e){jc(C,Wr,e)},state:O})]})},N3=function(){return Object(y.jsx)(u3,{children:Object(y.jsx)(T3,{})})},E3=n.p+"static/media/yield_icon.01e078df.svg",w3=(n(1694),function(e){return{type:"Feature",geometry:null===e||void 0===e?void 0:e.geometry,properties:{name:null===e||void 0===e?void 0:e.name}}}),_3=function(e){var t,n,r=e.visible,c=e.onClose,i=e.load,o=e.cropSeasonHandler,s=e.sourcesQnt,l=e.cropzoneTotalArea,d=rv({fetchType:xm}),u=d.dataSorted,j=d.reloadData,p=Object(a.useState)(null),f=Object(b.a)(p,2),m=f[0],v=f[1];return Object(a.useEffect)((function(){j()}),[]),Object(a.useEffect)((function(){var e,t,n,a=null===i||void 0===i||null===(e=i.sources)||void 0===e?void 0:e.map((function(e){return e.id})),r=function(e){return e.map((function(e){var t;return{title:e.name,key:e.id,children:null===(t=e.fields)||void 0===t?void 0:t.map((function(e){var t;return{title:e.name,key:e.id,children:null===(t=e.cropzones)||void 0===t?void 0:t.map((function(e){return{title:e.name,key:e.id}}))}}))}}))}((t=u.properties,n=a,t.map((function(e){var t=e.fields.map((function(e){return Object(I.a)(Object(I.a)({},e),{},{cropzones:e.cropzones.filter((function(e){return n.includes(e.id)}))})}));return Object(I.a)(Object(I.a)({},e),{},{fields:t.filter((function(e){return e.cropzones.length>0}))})})).filter((function(e){return e.fields.length>0}))));v(r)}),[u]),Object(y.jsx)(Xc.Drawer,{className:"load-product-drawer",width:"80%",open:r,placement:"right",closable:!0,maskClosable:!1,onClose:function(){c("right")},footer:Object(y.jsx)(Xc.Button,{type:Xc.ButtonType.outline,className:"mr-10px",onClick:function(){c("right")},children:Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)("img",{className:"mr-1",src:nT,alt:"chevron icon"}),Object(y.jsx)("div",{children:"Back"})]})}),children:Object(y.jsxs)("div",{className:"flex flex-row h-full",children:[Object(y.jsxs)("section",{className:"w-1/3 mr-6",children:[Object(y.jsx)("h1",{className:"font-semibold text-xl",children:"View Selected Properties"}),Object(y.jsx)("div",{className:"mt-10",children:Object(y.jsx)(CB,{drawer:!0,loadDetailsDrawer:!0,onChange:function(){},placeholder:"Search Properties"})}),Object(y.jsx)("div",{className:"font-semibold text-base mt-4",children:"PROPERTIES"}),Object(y.jsx)("div",{className:"mt-4",children:Object(y.jsx)(Xc.Tree,{multiple:!0,treeData:m})})]}),Object(y.jsxs)("section",{className:"w-2/3 h-full",children:[Object(y.jsxs)("div",{className:"font-normal text-base",children:["Crop Season: ",o()]}),Object(y.jsxs)("div",{className:"flex flex-row mb-4",children:[Object(y.jsx)("div",{className:"mr-1",children:"".concat(s," crop zone").concat(s>1?"s":""," selected")}),Object(y.jsx)("img",{className:"mx-2",src:I2,alt:"divider icon"}),Object(y.jsx)("img",{className:"ml-1",src:R2,alt:"field icon"}),Object(y.jsxs)("div",{children:["Total area:"," ",Object(y.jsx)(yf,{roundedTo:2,children:l}),"ac"]})]}),Object(y.jsx)("div",{className:"my-auto ",children:Object(y.jsx)(mm,{displayOnly:!0,geoJSONCollection:Object(W.featureCollection)(null===(t=i.sources)||void 0===t?void 0:t.map(w3)),currentCoordinates:Object(W.featureCollection)(null===(n=i.sources)||void 0===n?void 0:n.map(w3)),visible:r})})]})]})})},R3=n.p+"static/media/open_in_new_blue.090992e1.svg",I3={STORAGE:zZ,SALE:G5},D3=function(e){var t,n,a=e.load,r=Object(I.a)(Object(I.a)({},a),{},{name:null===a||void 0===a||null===(t=a.cropName)||void 0===t?void 0:t.replace(/ /g,"")}),c=null!==r&&void 0!==r&&null!==(n=r.name)&&void 0!==n&&n.includes(":")?null===r||void 0===r?void 0:r.name.split(":")[0].trim():null===r||void 0===r?void 0:r.name;return Object(y.jsxs)("div",{className:"flex flex-row items-center",children:[c in yg?Object(y.jsx)(Ag,{cropObject:r}):Object(y.jsx)("img",{src:LI.default,alt:""}),Object(y.jsx)("div",{className:"pl-1",children:a.cropName})]})},k3=function(e,t){var n=null===e||void 0===e?void 0:e.find((function(e){return(null===e||void 0===e?void 0:e.id)===t}));return null===n||void 0===n?void 0:n.name},L3=Object(eb.default)({accessToken:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw"}),F3="cropzones-map-preview",M3="cropzones-map-preview-loading",V3=function(e){var t=e.cropzones,n=e.className,r=e.fieldColor,c=e.isLoading,i=Object(a.useMemo)((function(){var e;if(c)return{centroId:[0,0],boundingBox:null};var n=t.map(w3),a=n.some((function(e){var t;return!(null===e||void 0===e||null===(t=e.geometry)||void 0===t||!t.coordinates)})),r=mj({features:n}),i={type:"FeatureCollection",features:a?n:[]};if(!a)return{centroId:[0,0],boundingBox:null,featureCollection:i};var o=Object(W.bbox)(i);return{centroId:(null===r||void 0===r||null===(e=r.geometry)||void 0===e?void 0:e.coordinates)||[0,0],boundingBox:o,featureCollection:i}}),[t,c]),o=i.centroId,s=i.boundingBox,l=i.featureCollection;return c?Object(y.jsx)("div",{"data-testid":M3,className:"".concat(n," flex justify-center items-center h-full bg-gray-200"),children:Object(y.jsx)(m.Spinner,{})}):Object(y.jsx)(L3,{style:"mapbox://styles/mapbox/satellite-streets-v11",center:o,fitBounds:s,fitBoundsOptions:{padding:4},className:"".concat(n," w-full h-full"),logoPosition:"none","data-testid":F3,children:Object(y.jsx)(eb.GeoJSONLayer,{data:l,symbolLayout:{"text-field":["get","name"],"text-size":10,"text-letter-spacing":.05,"text-allow-overlap":!0,"text-offset":[0,.5],"symbol-placement":"point","text-anchor":"top"},symbolPaint:{"text-color":"#fff","text-halo-color":"#000","text-halo-width":1},fillLayout:{visibility:"visible"},fillPaint:{"fill-color":r,"fill-opacity":.4},linePaint:{"line-color":r,"line-width":2}})})};V3.defaultProps={className:"",fieldColor:"#31B4F2",isLoading:!1,cropzones:[]};var B3,U3=V3,z3=function(e){var t,n,r,c,i=e.load,o=e.visible,s=e.showDrawer,l=e.cropzoneTotalArea,d=Object(a.useContext)(ac),u=Object(b.a)(d,1)[0],j=u.isSidebarOpen,p=u.cropSeasons,f=(null===(t=i.sources)||void 0===t?void 0:t.length)||0,v=(null===i||void 0===i||null===(n=i.load)||void 0===n||null===(r=n.toString())||void 0===r?void 0:r.length)>=9;return Object(y.jsxs)(y.Fragment,{children:[Object(y.jsxs)("section",{"data-testid":"property-as-source-details",className:"w-3/6 px-8 py-4 bg-white rounded-lg shadow-lg",children:[Object(y.jsx)(Y$,{labelColWidth:"w-2/5 ms",valueColWidth:"w-3/5",label:"Source",value:"".concat(f," crop zone").concat(f>1?"s":""," | ").concat(iX.format(l)," ac")}),Object(y.jsx)(Y$,{label:"Destination",labelColWidth:"w-2/5",valueColWidth:"w-3/5",value:null!==i&&void 0!==i&&null!==(c=i.destination)&&void 0!==c&&c.name?Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("img",{className:"mr-1",width:20,src:I3[i.destinationType],alt:"".concat(i.destinationType," icon")}),i.destination.name]}):null}),Object(y.jsx)(Y$,{labelColWidth:"w-2/5",valueColWidth:"w-3/5",label:"Date & Time",value:null!==i&&void 0!==i&&i.date?mA(i.date,"MMM d, yyyy hh:mm a"):null}),Object(y.jsx)(Y$,{labelColWidth:"w-2/5",valueColWidth:"w-3/5",label:"Crop Season",value:k3(p,i.cropSeasonId)}),Object(y.jsx)(Y$,{labelColWidth:"w-2/5",valueColWidth:"w-3/5",label:"Crop",value:Object(y.jsx)(D3,{load:i})})]}),Object(y.jsxs)("section",{className:"".concat(j?v?"w-2/6":"w-2/5":v?"w-2/5":"w-3/6"," rounded-lg shadow-lg overflow-hidden relative"),children:[Object(y.jsxs)(m.Button,{className:"top-60 left-60 ",type:"outline",style:{position:"absolute",top:"12px",right:"12px",zIndex:"".concat(o?0:5e3)},onClick:function(){s("right")},children:[Object(y.jsx)("img",{className:"mr-1",src:R3,alt:"view icon"}),Object(y.jsx)("div",{className:"text-info-dark-blue",children:" View Details"})]}),Object(y.jsx)(U3,{cropzones:i.sources},"resize-".concat(j))]})]})},Z3="Sale Info",Y3="Yield Details",H3="Load Attributes",G3="Weight",W3="Counts",q3="Other",J3="Notes",K3={salePrice:"Sale Price",grossRevenue:"Gross Revenue",infoSection:"Info Section",harvestedYieldQuantity:"Harvested Yield Quantity",avgHarvestedQuantity:"Avg. Harvested Quantity",shrink:"Shrink",shrinkPercentage:"Shrink Percentage",damage:"Damage",failingNumber:"Failing Number",foreignMaterial:"Foreign Material",lintWeight:"Lint Weight",moisture:"Moisture",plump:"Plump",protein:"Protein",quality:"Quality",slm:"SLM",testWeight:"Test Weight",sugar:"Sugar",seedWeight:"Seed Weight",grossWeight:"Gross Weight",tareWeight:"Tare Weight",netWeight:"Net Weight",boxCount:"Box Count",largeSquareBaleCount:"Large Square Bale Count",miniModuleCount:"Mini Module Count",roundBaleCount:"Round Bale Count",moduleCount:"Module Count",squareBaleCount:"Square Bale Count",truck:"Truck",driver:"Driver",billOfLading:"Bill of lading",secondaryCommodity:"Secondary Commodity",notes:"Notes"},Q3="mx-4",X3=(B3={},Object(et.a)(B3,h0,{saleTab:[],yieldTab:[],weightTab:[],countsTab:[],loudAttributeTab:[],otherTab:[K3.billOfLading,K3.secondaryCommodity],notesTab:[]}),Object(et.a)(B3,x0,{saleTab:[],yieldTab:[],weightTab:[],countsTab:[],loudAttributeTab:[K3.failingNumber,K3.lintWeight,K3.plump,K3.protein,K3.quality,K3.seedWeight,K3.shrink,K3.shrinkPercentage,K3.slm,K3.sugar],otherTab:[K3.billOfLading,K3.secondaryCommodity],notesTab:[]}),Object(et.a)(B3,g0,{saleTab:[],yieldTab:[],weightTab:[],countsTab:[],loudAttributeTab:[K3.failingNumber,K3.lintWeight,K3.plump,K3.protein,K3.moisture,K3.seedWeight,K3.shrink,K3.shrinkPercentage,K3.slm,K3.sugar,K3.testWeight],otherTab:[K3.billOfLading,K3.secondaryCommodity],notesTab:[]}),B3),$3=function(e,t,n){var r=t.source,c=t.destination,i=Object(a.useState)([]),o=Object(b.a)(i,2),s=o[0],l=o[1];return n||(n=h0),Object(a.useEffect)((function(){if(r||c){var t,a=(t={},Object(et.a)(t,Z3,X3[n].saleTab),Object(et.a)(t,Y3,X3[n].yieldTab),Object(et.a)(t,G3,X3[n].weightTab),Object(et.a)(t,H3,X3[n].loudAttributeTab),Object(et.a)(t,W3,X3[n].countsTab),Object(et.a)(t,q3,X3[n].otherTab),Object(et.a)(t,J3,X3[n].notesTab),t),i=ae.a.cloneDeep(a[e]);e===Y3&&"CROP_ZONE"!==r&&i.push(K3.avgHarvestedQuantity),i&&l(i)}}),[e,r,c,n]),{removeAttributes:s}};$3.propTypes={tab:wc.a.string.isRequired,sourceAndDestination:wc.a.shape({source:wc.a.string,destination:wc.a.string}),templateType:wc.a.string},$3.defaultProps={sourceAndDestination:{source:"",destination:""}};var e6=$3,t6=function(e){var t=e.children;return e.isRender?t:null};t6.propTypes={children:wc.a.element,isRender:wc.a.bool},t6.defaultProps={children:null,isRender:!0};var n6=t6;function a6(e){var t=e.removeAttributes,n=e.label,a=e.value,r=e.ghostValue;return Object(y.jsx)(n6,{isRender:!(null!==t&&void 0!==t&&t.includes(n)),children:Object(y.jsx)(oE,{label:n,value:a,ghostValue:r})})}function r6(e){var t=e.properties,n=e.values,a=e.removeAttributes,r="property-grid-item";return Object(y.jsx)("div",{className:Q3,children:Object(y.jsx)("div",{className:"grid grid-cols-2 gap-x-12",children:t.map((function(e){var t,c,i=Object(cc.generate)();return"string"===typeof e?Object(y.jsx)(a6,{"data-testid":r,label:K3[e],removeAttributes:a,value:n[e],ghostValue:!n[e]},i):Object(y.jsx)(a6,{"data-testid":r,label:K3[e.name],removeAttributes:a,value:null!==(t=e.value)&&void 0!==t?t:n[e.name],ghostValue:null!==(c=e.ghostValue)&&void 0!==c?c:!n[e.name]},i)}))})})}a6.defaultProps={value:void 0,ghostValue:!0};var c6=function(){var e=Object(Zi.h)().values,t=e.salePrice,n=e.loadUnit,r=e.grossRevenue,c=e.templateType,i=e6(Z3,{source:!0},c).removeAttributes,o=Object(a.useState)([]),s=Object(b.a)(o,2),l=s[0],d=s[1];return Object(a.useEffect)((function(){d([{name:"salePrice",value:ZZ(t,Object(va.g)(n))},{name:"grossRevenue",value:CR(r)}])}),[t,n,r]),Object(y.jsxs)("div",{children:[Object(y.jsx)(r6,{values:e,properties:l,removeAttributes:i}),Object(y.jsx)("div",{className:"mt-10",children:Object(y.jsx)(n6,{isRender:!(null!==i&&void 0!==i&&i.includes(K3.infoSection)),children:Object(y.jsxs)("p",{className:"flex flex-row",children:[Object(y.jsx)("img",{alt:"info",src:B_,className:"mr-2"}),Object(y.jsx)("span",{className:"flex flex-row items-center",children:"All yield delivered to a Sale Location will count towards total gross revenue."})]})})})]})};function i6(e,t){var n=0;return e&&t&&(n=FS.b.divideSafeRound(t,e,4)),gR(n)}function o6(e,t,n){if(e&&t&&n)return xR(FS.b.divideSafeRound(e,n,2),"".concat(Object(va.g)(t)," / ac"))}function s6(e,t,n){if(e&&t&&n)return xR(FS.b.multiplyRound(e,n,2),Object(va.g)(t),2)}var l6=function(e){var t=e.cropzoneTotalArea,n=Object(Zi.h)().values,r=n.loadUnit,c=n.harvestedQuantity,i=n.sourceType,o=n.shrink,s=n.shrinkType,l=n.templateType,d=Object(a.useState)([]),u=Object(b.a)(d,2),j=u[0],p=u[1];Object(a.useEffect)((function(){p([{name:"harvestedYieldQuantity",value:xR(c,Object(va.g)(r),2),ghostValue:!c},{name:"avgHarvestedQuantity",value:o6(c,r,t),ghostValue:!(c&&r&&t)},{name:"shrink",value:s===C0.BY_QUANTITY?xR(o,Object(va.g)(r),2):s6(c,r,o)},{name:"shrinkPercentage",value:s===C0.BY_QUANTITY?i6(c,o):gR(o),ghostValue:!(c&&o)}])}),[t,c,r,o,s]);var f=e6(Y3,{source:i},l).removeAttributes;return Object(y.jsx)(r6,{removeAttributes:f,properties:j,values:n})},d6=function(){var e=Object(Zi.h)().values,t=e.templateType,n=e.damage,r=e.foreignMaterial,c=e.moisture,i=e.testWeight,o=e.testWeightUnit,s=e6(H3,{source:!0},t).removeAttributes,l=Object(a.useState)([]),d=Object(b.a)(l,2),u=d[0],j=d[1];return Object(a.useEffect)((function(){j([{name:"damage",value:gR(n)},"failingNumber",{name:"foreignMaterial",value:gR(r)},"lintWeight",{name:"moisture",value:gR(c)},"plump","protein","quality","seedWeight","slm",{name:"testWeight",value:xR(i,Object(va.g)(o))}])}),[n,r,c,i,o]),Object(y.jsx)(r6,{removeAttributes:s,properties:u,values:e})},u6=function(){var e=Object(Zi.h)().values,t=e.grossWeight,n=e.tareWeight,r=e.netWeight,c=e.weightUnit,i=e.sourceType,o=e6(G3,i).removeAttributes,s=Object(a.useState)([]),l=Object(b.a)(s,2),d=l[0],u=l[1];return Object(a.useEffect)((function(){u([{name:"grossWeight",value:xR(t,Object(va.g)(c),2)},{name:"tareWeight",value:xR(n,Object(va.g)(c),2)},{name:"netWeight",value:xR(r,Object(va.g)(c),2)}])}),[t,c,n,r]),Object(y.jsx)(r6,{properties:d,removeAttributes:o,values:e})},b6=["boxCount","miniModuleCount","roundBaleCount","largeSquareBaleCount","moduleCount","squareBaleCount"],j6=function(){var e=Object(Zi.h)().values,t=e.templateType,n=e6(H3,{source:!0},t).removeAttributes,r=Object(a.useState)([]),c=Object(b.a)(r,2),i=c[0],o=c[1];return Object(a.useEffect)((function(){o(b6)}),[]),Object(y.jsx)(r6,{removeAttributes:n,values:e,properties:i})},p6=function(){var e,t,n=Object(Zi.h)().values,r=n.driverId,c=n.truckId,i=n.billOfLading,o=n.templateType,s=e6(q3,{source:!0},o).removeAttributes,l=Object(a.useState)([]),d=Object(b.a)(l,2),u=d[0],j=d[1],p=Ro("equipments",["name","equipmentType"],"name",0),f=p.items,m=p.loaded,v=Ro("worker/people",["contactInfo.name.givenName","contactInfo.name.surname"],"contactInfo.name.givenName",0),O=v.items,h=v.loaded,x=m?null===(e=f.find((function(e){return e.id===c})))||void 0===e?void 0:e.name:"Loading...",g=h?null===(t=O.find((function(e){return e.id===r})))||void 0===t?void 0:t.name:"Loading...";return Object(a.useEffect)((function(){j([{name:"truck",value:x,ghostValue:!m||!x},{name:"driver",value:g,ghostValue:!h||!g},{name:"billOfLading",values:i},"secondaryCommodity"])}),[x,m,h,g,i]),Object(y.jsx)(r6,{removeAttributes:s,properties:u,values:n})},f6=function(){var e=Object(Zi.h)().values.notes;return Object(y.jsx)("div",{className:Q3,children:Object(y.jsx)("p",{className:e?null:"text-gray-500",children:e||"None entered"})})},m6=function(e,t){var n=ae.a.cloneDeep(e);return t===Z4?(delete n[Z3],n):e},v6=function(e,t){var n=ae.a.cloneDeep(e);return t===B4||t===U4||t===z4?n:e},O6=function(e,t,n){var a=ae.a.cloneDeep(e);switch(t){case x0:null!==n&&void 0!==n&&n.shrink||delete a[Y3],delete a[W3];break;case g0:delete a[Y3],delete a[W3];break;default:delete a[Y3],delete a[H3],delete a[W3]}return a},h6=function(e){var t,n=e.load,a=e.cropzoneTotalArea,r=n.sourceType,c=n.destinationType,i=n.templateType,o=(t={},Object(et.a)(t,Z3,Object(y.jsx)(c6,{})),Object(et.a)(t,Y3,Object(y.jsx)(l6,{cropzoneTotalArea:a})),Object(et.a)(t,H3,Object(y.jsx)(d6,{})),Object(et.a)(t,G3,Object(y.jsx)(u6,{})),Object(et.a)(t,W3,Object(y.jsx)(j6,{})),Object(et.a)(t,q3,Object(y.jsx)(p6,{})),Object(et.a)(t,J3,Object(y.jsx)(f6,{})),t);return Object(y.jsx)("div",{className:"mt-4",children:Object(y.jsx)(Zi.e,{initialValues:Object(I.a)({},n),children:Object(y.jsx)(m.Tabs,{pane:!0,children:Object.entries(function(){var e,t=ae.a.cloneDeep(o);return e=O6(t,i,n),e=m6(e,c),e=v6(e,r)}()).map((function(e){var t=Object(b.a)(e,2),n=t[0],a=t[1];return Object(y.jsx)(m.Tabs.Tab,{label:z$(n),children:Object(y.jsx)("div",{className:"pt-4 pr-4 pl-4 pb-8",children:a})},n)}))})})})},x6=function(e){var t,n,r,c=e.load,i=Object(a.useContext)(ac),o=Object(b.a)(i,1)[0].cropSeasons;return Object(y.jsxs)("section",{className:"w-full flex flex-row px-8 py-4 bg-white rounded-lg shadow-lg",children:[Object(y.jsxs)("div",{className:"w-1/2 mr-6",children:[Object(y.jsx)(Y$,{labelColWidth:"w-1/5",wrapperClassName:"justify-start",label:"Source",value:null!==c&&void 0!==c&&null!==(t=c.sources)&&void 0!==t&&null!==(n=t[0])&&void 0!==n&&n.name?Object(y.jsxs)("div",{className:"ml-1 flex flex-row",children:[Object(y.jsx)("img",{className:"mr-1",width:20,src:I3[c.sourceType],alt:"".concat(c.sourceType," icon")}),Object(y.jsx)("div",{children:c.sources[0].name})]}):null}),Object(y.jsx)(Y$,{labelColWidth:"w-1/5",wrapperClassName:"justify-start",label:"Date & Time",value:null!==c&&void 0!==c&&c.date?mA(c.date,"MMM d, yyyy hh:mm a"):null}),Object(y.jsx)(Y$,{labelColWidth:"w-1/5",wrapperClassName:"justify-start",label:"Crop",value:Object(y.jsx)(D3,{load:c})})]}),Object(y.jsxs)("div",{className:"w-1/2",children:[Object(y.jsx)(Y$,{labelColWidth:"w-1/5",wrapperClassName:"justify-start",label:"Destination",value:null!==c&&void 0!==c&&null!==(r=c.destination)&&void 0!==r&&r.name?Object(y.jsxs)("div",{className:"flex items-center",children:[Object(y.jsx)("img",{className:"mr-1",width:20,src:I3[c.destinationType],alt:"".concat(c.destinationType," icon")}),c.destination.name]}):null}),Object(y.jsx)(Y$,{labelColWidth:"w-1/5",wrapperClassName:"justify-start",label:"Crop Season",value:k3(o,c.cropSeasonId)})]})]})},g6=function(e){var t,n=e.load,r=e.treeData,c=e.cropzoneTotalArea,i=Object(p.h)(),o=(null===n||void 0===n||null===(t=n.sources)||void 0===t?void 0:t.length)||0,s=Object(a.useContext)(ac),l=Object(b.a)(s,1)[0].cropSeasons,d=Object(a.useState)(!1),u=Object(b.a)(d,2),j=u[0],f=u[1],v="".concat(null===n||void 0===n?void 0:n.sourceType,"_").concat(null===n||void 0===n?void 0:n.destinationType),O=Object(a.useState)(!1),h=Object(b.a)(O,2),x=h[0],g=h[1],C=function(){f(!0)};return n?Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(s3,{id:n.id,open:x,onCancel:g,onResult:function(e){i.push({pathname:"".concat(Cc.yieldV2,"/loads"),toast:e})}}),Object(y.jsxs)("div",{className:"w-full flex items-center justify-between p-4 bg-white border-b",children:[Object(y.jsxs)("div",{className:"flex items-center gap-6",children:[Object(y.jsx)(m.Button,{onClick:i.goBack,icon:Object(y.jsx)(ui.a,{"data-testid":"chevron-left-icon",icon:di.e,size:"xs",style:{marginRight:"4px"}}),type:"outline",children:"Back"}),Object(y.jsxs)("h1",{className:"text-2xl font-semibold flex flex-row",children:[Object(y.jsx)("img",{className:"mr-3",src:q4[v],alt:v}),null===n||void 0===n?void 0:n.name]})]}),Object(y.jsxs)("div",{className:"flex items-center gap-2",children:[" ",Object(y.jsx)(m.Button,{icon:Object(y.jsx)("img",{width:18,src:DI,alt:"edit icon"}),type:"outline",onClick:function(){i.push("".concat(Cc.yieldV2,"/loads/").concat(n.id,"/edit"))},children:"Edit"}),Object(y.jsx)(m.Button,{icon:Object(y.jsx)("img",{width:18,src:X4,alt:"delete icon"}),type:"outline",onClick:function(){return g(!0)},children:"Delete"})]})]}),Object(y.jsxs)("div",{className:"w-full p-4",children:[Object(y.jsxs)("div",{className:"flex gap-4",children:[Object(y.jsxs)("section",{className:"items-center bg-white rounded-lg shadow-sm-card",children:[Object(y.jsxs)("div",{className:"w-full border-b py-3 flex flex-row",children:[Object(y.jsx)("img",{className:"ml-4",src:E3,alt:"yield icon"}),Object(y.jsx)("div",{className:"ml-2 font-normal",children:"Yield"})]}),Object(y.jsxs)("div",{className:"m-4 mb-0",children:[Object(y.jsx)("div",{className:"text-neutral-60",children:"Yield quantity"}),Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)("div",{className:"font-semibold text-3xl flex flex-row",children:Object(y.jsx)(yf,{roundedTo:2,children:null===n||void 0===n?void 0:n.load})}),Object(y.jsx)("div",{className:"text-sm font-normal\tpt-4 ml-1",children:Object(va.g)(null===n||void 0===n?void 0:n.loadUnit)})]})]}),(null===n||void 0===n?void 0:n.sourceType)!==U4?Object(y.jsxs)("div",{className:"m-4 mb-0",children:[Object(y.jsx)("div",{className:"text-neutral-60",children:"Avg. quantity"}),Object(y.jsxs)("div",{className:"flex flex-row",children:[Object(y.jsx)("div",{className:"font-semibold text-3xl flex flex-row",children:Object(y.jsx)(yf,{roundedTo:2,children:parseFloat(null===n||void 0===n?void 0:n.load)/(null===n||void 0===n?void 0:n.sources.reduce((function(e,t){return e+t.area}),0))})}),Object(y.jsx)("div",{className:"pt-4 ml-1",children:"".concat(Object(va.g)(n.loadUnit)," / ac")})]})]}):null,"bu"===(null===n||void 0===n?void 0:n.loadUnit)?Object(y.jsx)("div",{className:"mt-4 ml-4 mb-2 text-neutral-60",children:"1.00 bushel = 56.00 lbs"}):null]}),(null===n||void 0===n?void 0:n.sourceType)===B4?Object(y.jsx)(z3,{cropzoneTotalArea:c,visible:j,showDrawer:C,load:n}):(null===n||void 0===n?void 0:n.sourceType)===U4?Object(y.jsx)(x6,{load:n}):null]}),Object(y.jsx)(_3,{cropzoneTotalArea:c,sourcesQnt:o,cropSeasonHandler:function(){var e=null===l||void 0===l?void 0:l.find((function(e){return(null===e||void 0===e?void 0:e.id)===(null===n||void 0===n?void 0:n.cropSeasonId)}));return null===e||void 0===e?void 0:e.name},visible:j,onClose:function(){f(!1)},load:n,treeData:r}),Object(y.jsx)(h6,{load:n,cropzoneTotalArea:c})]})]}):null};g6.defaultProps={cropzoneTotalArea:0,treeData:null};var C6=g6,y6=function(){var e=Object(p.j)().id,t=Object(a.useState)(),n=Object(b.a)(t,2),r=n[0],c=n[1],i=Object(a.useState)(0),o=Object(b.a)(i,2),s=o[0],l=o[1],d=VZ().getLoadDetails,u=Object(a.useState)(!0),j=Object(b.a)(u,2),f=j[0],v=j[1],O=Object(a.useContext)(ac),h=Object(b.a)(O,2),x=h[0],g=x.showToastChangesSaved,C=x.isGlobalCropSeasonLoading,P=h[1];Object(a.useEffect)((function(){e&&d(e).then((function(e){c(e),v(!1)}))}),[e]),Object(a.useEffect)((function(){var e;l(null===r||void 0===r||null===(e=r.sources)||void 0===e?void 0:e.map((function(e){return e.area})).reduce((function(e,t){return e+t}),0))}),[r]);return Object(y.jsxs)("div",{className:"h-full w-full flex flex-col","data-testid":"load-details-view",children:[Object(y.jsx)(lo,{disabled:!0,hideCropSeasonDropdown:!0,children:Object(y.jsx)(lo.Item,{title:"Yield",value:"".concat(null===r||void 0===r?void 0:r.name),isLast:!0})}),f||C?Object(y.jsx)(m.Spinner,{}):Object(y.jsx)(C6,{cropzoneTotalArea:s,load:r}),g&&Object(y.jsx)(D0,{state:"success",isBold:!0,showToast:!0,title:"Changes saved.",setShowToast:function(e){P({type:"SET_SHOW_TOAST_CHANGES_SAVED",payload:e})}})]})},P6=[{id:"yield",key:"yieldV2",label:"YieldV2",path:Cc.yieldV2,exact:!0,secure:!0,disabled:!1,icon:ad,nav:"leftNav",subRoutes:[{id:"commodity-summary",key:"commodity-summary",label:"Commodity Summary",path:"".concat(Cc.yieldV2,"/commodity-summary"),exact:!0,secure:!0,disabled:!1},{id:"loads",key:"loads",label:"Loads",path:"".concat(Cc.yieldV2,"/loads"),exact:!0,secure:!0,disabled:!1},{id:"storage-locations",key:"storage-locations",label:"Storage Locations",path:"".concat(Cc.yieldV2,"/storage-locations"),exact:!0,secure:!0,disabled:!1},{id:"sale-locations",key:"sale-locations",label:"Sale Locations",path:"".concat(Cc.yieldV2,"/sale-locations"),exact:!0,secure:!0,disabled:!1}]},{id:"commodity-summary",key:"commodity-summary",label:"",path:"".concat(Cc.yieldV2,"/commodity-summary"),exact:!0,secure:!0,disabled:!0,component:s2},{id:"create-yield",key:"create-yield",label:"",path:"".concat(Cc.yield,"/create"),exact:!0,secure:!0,disabled:!0},{id:"sale-locations",key:"sale-locations",label:"",path:"".concat(Cc.yieldV2,"/sale-locations"),exact:!0,secure:!0,disabled:!0,component:N3},{id:"create-sale-location",key:"create-sale-locations",label:"",path:"".concat(Cc.yieldV2,"/sale-locations/create"),exact:!0,secure:!0,disabled:!0,component:n1},{id:"edit-sale-location",key:"edit-sale-locations",label:"",path:"".concat(Cc.yieldV2,"/sale-locations/:id/edit"),exact:!0,secure:!0,disabled:!0,component:r1},{id:"yieldV2-storage-locations",key:"storage-locations",label:"Storage",path:"".concat(Cc.yieldV2,"/storage-locations"),exact:!0,secure:!0,disabled:!1,component:V0},{id:"create-storage-location",key:"create-storage-locations",label:"Storage",path:"".concat(Cc.yieldV2,"/storage-locations/:action(create|edit)/:locationId?"),exact:!0,secure:!0,disabled:!1,component:V0},{id:"edit-yield",key:"edit-yield",label:"",path:"".concat(Cc.yield,"/:id/edit"),exact:!0,secure:!0,disabled:!0,component:v$},{id:"loads",key:"loads",label:"Loads",path:"".concat(Cc.yieldV2,"/loads"),exact:!0,secure:!0,disabled:!1,component:l3},{id:"load-details",key:"load-details",label:"Load Details",path:"".concat(Cc.yieldV2,"/loads/:id/view"),exact:!0,secure:!0,disabled:!1,component:y6},{id:"add-yield",key:"add-yield",label:"",path:"".concat(Cc.yieldV2,"/create"),exact:!0,secure:!0,disabled:!1,component:k5},{id:"edit-yield-load",key:"edit-yield-load",label:"",path:"".concat(Cc.yieldV2,"/loads/:id/edit"),exact:!0,secure:!0,disabled:!1,component:M5}],A6=[];A6.push.apply(A6,Object(v.a)(kD)),A6.push.apply(A6,Object(v.a)(jG)),A6.push.apply(A6,Object(v.a)(Nv)),A6.push.apply(A6,Object(v.a)(hM)),A6.push.apply(A6,Object(v.a)(iq)),A6.push.apply(A6,Object(v.a)(BQ)),A6.push.apply(A6,Object(v.a)(YR)),A6.push.apply(A6,Object(v.a)(QV)),A6.push.apply(A6,Object(v.a)(Ak)),A6.push.apply(A6,Object(v.a)(ld)),A6.push.apply(A6,Object(v.a)(pO)),A6.push.apply(A6,Object(v.a)(Gw)),A6.push.apply(A6,Object(v.a)(GI)),A6.push.apply(A6,Object(v.a)(KJ)),A6.push.apply(A6,Object(v.a)(O$)),A6.push.apply(A6,Object(v.a)(aB)),A6.push.apply(A6,Object(v.a)(YQ)),A6.push.apply(A6,Object(v.a)(P6));var S6=[{id:"appcontainer",key:"appcontainer",path:"/app",secure:!0,component:po,routes:A6}],T6=n(146),N6=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return t?"".concat(Object(T6.f)(t).toLowerCase()).concat(Object(ne.upperFirst)(e.toLowerCase())):e.toLowerCase()},E6=function(e){return N6("entry",e)},w6=function(e){var t=Object.keys(e).reduce((function(t,n){return"object"===typeof e[n]?"disabled"===e[n].entry&&t.add(E6(n)):"disabled"===e[n]&&(t.add(function(e){return N6(e)}(n)),t.add(E6(n))),t}),new Set);return Array.from(t)},_6=function(e){var t=w6(pt()),n=e.findIndex((function(e){return"appcontainer"===e.id})),a=e[n],r=a.routes,c=r.filter((function(e){var n=e.id;return t.includes(n)})).map((function(e){return Object(I.a)(Object(I.a)({},e),{},{component:wi,disabled:!0})})),i=Object(ne.differenceBy)(r,c,"id");return e.splice(n,1),[Object(I.a)(Object(I.a)({},a),{},{routes:[].concat(Object(v.a)(i),Object(v.a)(c))})].concat(Object(v.a)(e))}([].concat(Object(v.a)(S6),[{id:"login",key:"login",path:["/login","/authenticate"],exact:!0,secure:!1,component:Qa},{id:"landing",key:"landing",path:"/welcome",exact:!0,secure:!1,component:Ka},{id:"PDF",key:"PDF",path:"/PDF",exact:!0,secure:!1,component:Ya}])),R6={key:"user_key",name:"User name",email:"user@email.com"},I6=function(){var e=Object(a.useState)(Le()),t=Object(b.a)(e,2),n=t[0],r=t[1],c=We(),i=c.fetchUserProfile,o=c.user,s=c.logout,l=Object(f.useFlags)().feLandManagementUndergoingMaintenanceMessaging;R6.userId=null===o||void 0===o?void 0:o.id,R6.userEmail=null===o||void 0===o?void 0:o.email;var d=bi().createChatWidget;return Object(a.useEffect)((function(){l&&""!==l&&o&&s()}),[l]),Object(a.useEffect)((function(){n&&i()}),[n,i]),Object(a.useEffect)((function(){o&&(r(!1),d())}),[o]),Object(y.jsx)(j.a,{children:n?Object(y.jsx)("div",{className:"w-full h-screen m-auto",children:Object(y.jsx)(m.Spinner,{})}):Object(y.jsxs)(y.Fragment,{children:[Object(y.jsx)(p.c,{exact:!0,path:"/",children:Object(y.jsx)(p.b,{to:Cc.properties})}),Object(y.jsx)(p.c,{exact:!0,path:"/app",children:Object(y.jsx)(p.b,{to:Cc.properties})}),_6.map((function(e){return e.secure?Object(y.jsx)(p.c,{path:e.path,exact:e.exact,render:function(){return Le()?Object(y.jsxs)(rc,{children:[Object(y.jsx)(ai,{}),Object(y.jsx)(e.component,{routes:e.routes})]}):Object(y.jsx)(p.b,{to:"/welcome"})}},e.key):Object(y.jsx)(p.c,{path:e.path,exact:e.exact,render:function(){return Object(y.jsx)(e.component,{routes:e.routes})}},e.key)}))]})})},D6=Object(f.withLDProvider)({clientSideID:"6384e10156c30611b231c457",user:R6})((function(){return Object(y.jsx)("div",{"data-testid":"app",className:"min-w-1024",children:Object(y.jsx)(j.a,{children:Object(y.jsx)(I6,{})})})}));Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));var k6;n(1695),n(1696),n(1697);o.a({release:(k6=Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).SENTRY_CODEBUILD_WEBHOOK_TRIGGER,(null===k6||void 0===k6?void 0:k6.length)>0?k6.replace(/[/.-]/g,""):"v1.0.0"),dsn:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",integrations:[new s.a],environment:"qa",tracesSampleRate:parseFloat("1")||1}),d.a.init("2e4e8daf83c4937253a99516982b6482e03be4f5",{region:"us",version:"nextgen"});var L6=!1;(u.l&&(L6=!0),L6)&&(0,n(2750).makeServer)({environment:"qa"});!function(){var e="resetUserSession_".concat("qa");ke.getItem(e)&&(Me(),document.cookie="".concat(e,"= ; domain=cropwise.com; expires = Thu, 01 Jan 1970 00:00:00 GMT"),window.location.href=Be)}(),i.a.render(Object(y.jsx)(_e,{children:Object(y.jsx)(Ge,{children:Object(y.jsx)(D6,{})})}),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()}))},2750:function(e,t,n){"use strict";n.r(t),n.d(t,"makeServer",(function(){return ut}));var a=n(38),r=n(146),c=n(41),i=n(36),o=n(17),s=n.n(o),l=function(){function e(){Object(c.a)(this,e),this.ids=new Set}return Object(i.a)(e,[{key:"fetch",value:function(){for(var e=s.a.random.uuid();this.ids.has(e);)e=s.a.random.uuid();return this.ids.add(e),e}},{key:"set",value:function(e){if(this.ids.has(e))throw new Error("ID ".concat(e," has already been used."));this.ids.add(e)}},{key:"reset",value:function(){this.ids.clear()}}]),e}(),d=n(2844),u={active:function(){return!0},createdAt:function(){return s.a.date.past()},updatedAt:function(){return s.a.date.recent()},version:function(){return s.a.random.number()}},b={name:function(){return"Area ".concat(s.a.random.alphaNumeric(3).toUpperCase())},cropName:function(){return"Alfalfa"},representedArea:function(){return s.a.random.number({min:1e4,max:2e5})},calculatedArea:function(){return s.a.random.boolean()?s.a.random.number({min:1e4,max:2e5}):0},boundedArea:function(e){if(0===e){var t=Object(d.a)();return"shapes/".concat(t)}return"shapes/".concat(Object(d.a)())},areas:function(){return[]},centroid:function(){return null},sourceId:function(){return s.a.random.uuid()},source:function(){return s.a.company.companyName()},insuranceId:function(){return s.a.random.number()},seedSource:function(){return{name:"Example Source"}},seedLotId:function(){return"123"},label:function(){return s.a.lorem.word()},fsaArea:function(){return s.a.random.number()},permitId:function(){return"123"},siteId:function(){return"123"},cropZoneBlockId:function(){return"123"},tillageSystem:function(){return"Plow"},fieldNotes:function(){return s.a.lorem.sentence()},irrigated:function(){return s.a.random.boolean()},pumpPressure:function(){return s.a.random.number()},waterSource:function(){return"well"},pumpLift:function(){return s.a.random.number({min:1,max:10})},waterOrigin:function(){return"acquifer"},pumpEnergySource:function(){return"diesel"},irrigationSystem:function(){return"basin"},usePolyacrylamide:function(){return s.a.random.boolean()},atrazineProhibitionArea:function(){return s.a.random.boolean()},applicationDate:function(){return s.a.date.recent()},neighboringSensitiveCrops:function(){return["crop 1","crop 2"]},cropSeason:function(){return{cropSeasonLabel:"2003",startDate:s.a.date.recent(),endDate:s.a.date.recent()}},cropYear:function(){return{cropYearLabel:"2003",startDate:s.a.date.recent(),endDate:s.a.date.recent()}},active:function(){return u.active()},createdAt:function(){return u.createdAt()},updatedAt:function(){return u.updatedAt()},version:function(){return 1},includeOnMaps:function(){return!0},tags:function(){return[]},geometry:{coordinates:[[[-90.78879187678417,36.062604240615585],[-90.78963484462349,36.062646830198304],[-90.79219009088709,36.06128395211192],[-90.79358625637123,36.06049602744949],[-90.79503510734551,36.0603469597344],[-90.79732692615912,36.06028307348382],[-90.79753766811895,36.060048823456015],[-90.79761669635398,36.054937740165045],[-90.79753766811895,36.0547886619202],[-90.79703715596428,36.05468217728652],[-90.78881821952906,36.05476736500508],[-90.78879187678417,36.062604240615585]]],type:"Polygon"}},j=a.a.extend(b),p=n(4),f=Object(p.a)({id:function(){return s.a.random.uuid()},crop:function(){return s.a.random.arrayElement(["Corn","Soybean","Tobacco"])},costPerAcre:function(){return parseFloat(s.a.commerce.price())}},u),m=a.a.extend(f),v=Object(p.a)({addresses:function(e){return[{address1:s.a.address.streetAddress(),address2:e%2===0?s.a.address.secondaryAddress():"",postalCode:s.a.address.zipCode(),city:s.a.address.city(),state:s.a.address.stateAbbr(),country:s.a.random.arrayElement(["United States","Canada","France"]),addressType:s.a.random.arrayElement(["shipping","billing","location"])}]},emails:function(){return[s.a.internet.email(),s.a.internet.email()]},phoneNumbers:function(){return[{phoneType:"Home",name:"The House",value:s.a.phone.phoneNumber()}]},legalName:function(){return s.a.company.companyName()},commonName:function(){return s.a.company.companyName()},notes:function(){return s.a.lorem.paragraph()},flag:function(){return s.a.random.arrayElement(["ethanol","diesel","test"])}},u),O=a.a.extend(v),h=Object(p.a)({id:function(){return s.a.random.uuid()},name:function(e){return"Plant ".concat(e)},Status:function(){return s.a.random.boolean()?"Active":"Discontinued"}},u),x=a.a.extend(h),g={dismissed:!0,items:[{title:"AddProperty",completed:!0},{title:"AssignCrops",completed:!0},{title:"CreatePlan",completed:!1},{title:"CreateTask",completed:!1}]},C=Object(p.a)({id:function(){return"25046b78-2904-4740-ad5d-d7986050ca34"},onboarding:function(){return g},items:function(){return[{title:"CostPerAcre",options:{}}]}},u),y=a.a.extend(C),P=function(e){return s.a.random.boolean()?0:s.a.random.number(e)},A=Object(p.a)({name:function(){var e=s.a.random.arrayElement(["Ford","Chevy","Toyota","Dodge"]),t=s.a.random.arrayElement(["Case IH","John Deere","Fendt","New Holland"]);return s.a.random.arrayElement(["".concat(e," Truck"),"".concat(t," Tractor")])},valuations:function(){return Array.from({length:s.a.random.number(5)},(function(){return{amount:s.a.random.number({min:200,max:5e3}),date:s.a.date.past(10)}}))},notes:function(){return s.a.random.boolean()?s.a.lorem.paragraph():""},manufacturedYear:function(){return s.a.date.past(5).getFullYear()},make:function(){return this.name.split(" ")[0]},model:"",modelYear:function(){return this.manufacturedYear},serialNumber:function(){return s.a.random.alphaNumeric(15)},licenseNumber:function(){return s.a.random.alphaNumeric(15)},mileage:function(){return P(1e5)},hours:function(){return P(1e5)},unitID:function(){return P(1e5).toString()},purchasePrice:function(){return P(1e5)},purchaseDate:function(){return s.a.date.past(5)},sellPrice:function(){return P(1e5)},equipmentType:function(){var e=this.name.split(" ");return e[e.length-1]},currentStatus:function(){return s.a.random.arrayElement(["owned","leased"])},currentStatusDate:function(){return s.a.date.recent()},operationCost:function(){return Number(s.a.finance.amount(0,2e4,2))}},u),S=a.a.extend(A),T=["","Black Hills","Fifth Principal","Boise","Chickasaw","Choctaw","Cimarron","Copper River","Fairbanks","First Principal","Fourth Principal","Extended","Fourth Principal","Gila and Salt River","Humboldt","Huntsville","Indian","Kateel River","Louisiana","Michigan","Montana Principal","Mount Diablo","Navajo","New Mexico Principal","Saint Helena","Saint Stephens","Salt Lake","San Bernardino","Second Principal","Seward","Sixth Principal","Tallahassee","Third Principal","Uintah","Uniat","Ute","Washington","Willamette","Wind River"],N=["clay","silt","sand","loam","siltyClay","sandyClayLoam","siltyClayLoam","clayLoam","siltyLoam","sandyLoam","loamySand"],E=["A","B","C","D","A/D","B/D","C/D"],w=["irrigationDistrict","municipal","onFarmPond","reservoir","river","stream","tailwater","well"],_=["diesel","electric","naturalGas","propane"],R=["basin","border","drip","flood","furrow","linear","microSprinkler","pivot","subsurface","travelingGun","wheelLines"],I=["noTileDrain","standardDensity","standardDensityWithDrainageWaterManagement","highDensity","highDensityWithDrainageWaterManagement"],D=["TN","KY"],k=[["Knox","Davidson","Sevier"],["Benton","Caldwell","Henry"]],L=Object(p.a)({name:function(){return"".concat(s.a.address.city()," Field")},state:function(){return s.a.random.arrayElement(D)},county:function(){var e=this;return s.a.random.arrayElement(k[D.findIndex((function(t){return e.state()===t}))])},notes:function(){return s.a.lorem.paragraph()},propertyOwner:function(){return"N/A"},legalInfo:function(){return Array.from({length:s.a.random.number({max:8})},(function(){return{name:s.a.company.companyName(),value:s.a.random.boolean()?"":s.a.random.uuid()}}))},calculatedArea:s.a.random.number({min:2e4,max:1e5}),reportedArea:function(){return s.a.random.boolean()?{}:{unit:s.a.random.arrayElement(["acre","hectare"]),value:s.a.random.number({min:2e4,max:1e5})}},centroid:function(){return null},cropHistory:function(){var e=["Alfalfa","Edamame","Melon"],t=["reduced","intensive","conventional","no-till"],n=s.a.finance.amount(1e3,5e3),a=s.a.random.number(5),r=(new Date).getFullYear()-a;return Array.from({length:a},(function(a,c){return{_id:c,year:r+c,tillage:s.a.random.arrayElement(t),area:n,crop:s.a.random.arrayElement(e)}}))},fsa:function(){return{fsaFarmNum:s.a.random.number().toString(),fsaArea:s.a.random.number(),fsaTractNum:s.a.random.number().toString(),fsaRentType:s.a.random.arrayElement(["cashRent","cropShare","other"]),fsaFieldNum:s.a.random.number().toString(),fsaLandOwnerPercent:s.a.random.number({min:0,max:1,precision:.01}),fsaCluId:s.a.random.number().toString(),tenantPercent:s.a.random.number({max:1,precision:.01})}},landSurvey:function(){return{townshipVal:s.a.lorem.word(),townshipCardinal:s.a.random.arrayElement(["","N","S"]),range:s.a.lorem.word(),rangeCardinal:s.a.random.arrayElement(["","E","W"]),section:s.a.lorem.word(),meridian:s.a.random.arrayElement(T),taxId:s.a.random.number(),parcelNum:s.a.random.number().toString(),shortDescription:s.a.lorem.sentence(),legalDescription:s.a.lorem.sentences()}},landInfo:function(){return{slope:s.a.random.number({max:100}),soilTexture:s.a.random.arrayElement(N),slopeLength:s.a.random.number(),hydrologyGroup:s.a.random.arrayElement(E)}},water:function(){return{irrigated:s.a.random.boolean(),pumpPressure:s.a.random.number(),waterSource:s.a.random.arrayElement(w),pumpLift:s.a.random.number({max:100}),waterOrigin:s.a.random.arrayElement(["aquifer","watershed"]),pumpEnergySource:s.a.random.arrayElement(_),irrigationSystem:s.a.random.arrayElement(R),usePolyacrylamide:s.a.random.boolean(),primaryWaterSource:""}},tileDrainage:function(){return s.a.random.arrayElement(I)},regulatoryPermit:function(){return{permitId:s.a.random.number().toString(),siteId:s.a.random.number().toString()}},areas:[],geometry:function(e){return 0===e?{coordinates:[[[-90.76199131245554,36.025170241307976],[-90.76210284815565,36.0215980237914],[-90.75333614209377,36.0215980237914],[-90.75331383495374,36.02455684173634],[-90.75425073483788,36.024574882968764],[-90.75478610620095,36.02502591242671],[-90.75487533476105,36.025170241307976],[-90.76199131245554,36.025170241307976]]],type:"Polygon"}:{coordinates:[[[-90.78879187678417,36.062604240615585],[-90.78963484462349,36.062646830198304],[-90.79219009088709,36.06128395211192],[-90.79358625637123,36.06049602744949],[-90.79503510734551,36.0603469597344],[-90.79732692615912,36.06028307348382],[-90.79753766811895,36.060048823456015],[-90.79761669635398,36.054937740165045],[-90.79753766811895,36.0547886619202],[-90.79703715596428,36.05468217728652],[-90.78881821952906,36.05476736500508],[-90.78879187678417,36.062604240615585]]],type:"Polygon"}}},u),F=a.a.extend(L),M=n.p+"static/media/vrmap 1.42f5cc7a.png",V=Object(p.a)({url:M,alt:"map of a farm"},u),B=a.a.extend(V),U={oktaId:"",organizationId:"",userId:function(){return s.a.random.uuid()},role:"",financial:"",active:function(){return!0},version:function(){return s.a.random.number()}},z=a.a.extend(U),Z=Object(p.a)({name:function(e){var t=["18-46-0","0-0-60","32-0-0","Acuron","Quilt Xcel","Endigo","Spraying","Spreading","Planting","GH Corn seed","NK Soybean seed","AgriPro Wheat seed"];return e<t.length?t[e]:"Product"},manufacturer:function(){return s.a.company.companyName()},type:function(){return"CropProtection"},status:function(){return s.a.random.arrayElement(["Active","Inactive"])},makeup:function(){return s.a.random.arrayElement(["Liquid","Dry"])},density:function(){return s.a.random.number({max:10})},signal_word:function(){return"WARNING"},rei:function(){return null},phi:function(){return null},carbamate:function(){return null},organophosphate:function(){return null},geneticallyEnhanced:function(){return null},restrictedUse:function(){return!1},oralNotification:function(){return null},activeIngredients:function(){return[{id:s.a.random.uuid(),name:"Azoxystrobin",percentage:13.5},{id:s.a.random.uuid(),name:"Propiconazole",percentage:11.3}]},area:function(){return s.a.random.number({max:60})},rate:function(){return s.a.random.number({max:1500})},rateUnit:function(){return s.a.random.arrayElement(["Gal","Ker"])},pricePerUnit:function(){return s.a.finance.amount()},coverage:function(){return s.a.random.number({max:100})},totalProduct:function(){return s.a.random.number()},totalCost:function(){return s.a.finance.amount()},growerCost:function(){return s.a.finance.amount()}},u),Y=a.a.extend(Z),H=Object(p.a)({tagType:function(){return"farm"},tagValue:function(e){return"Farm ".concat(e)}},u),G=a.a.extend(H),W={name:function(){return"JS 210521 ".concat(s.a.random.number())},status:function(){return"ready"},startDate:function(){return s.a.date.recent()},dueDate:function(){return s.a.date.future()},flags:function(e){return 0===e?[{name:"Corn",color:"#C1462B"},{name:"Tag 2",color:"#9A6412"},{name:"Season",color:"#8354D6"},{name:"Tag 4",color:"#217C74"},{name:"Really Long Tag Name Example",color:"#217C74"},{name:"Corn",color:"#C1462B"}]:e%2?[{name:"High Priority",color:"#0071CD"},{name:"Active",color:"#14803C"}]:[{name:"Corn",color:"#C1462B"},{name:"Tag 2",color:"#9A6412"}]},properties:function(){return[{id:s.a.random.uuid()}]},totalAcres:function(){return s.a.random.number({min:200,max:3e3})},products:function(){return[{id:s.a.random.uuid()}]},totalTaskCost:function(){return s.a.finance.amount()},cropSeasons:function(){return["Corn 2021","Corn"]},authorizedDate:function(){return s.a.date.recent()},timingEvent:function(){return"Harvest"},source:function(){return"Example Plan"},duration:function(){return"".concat(s.a.random.number({min:1,max:20})," hours")},type:function(){return"Spreading"},createdOn:function(){return s.a.date.recent()},sources:function(){return[{type:"product",id:s.a.random.uuid()},{type:"recommendation",id:s.a.random.uuid()},{type:"invoice",id:s.a.random.uuid()},{type:"plan",id:s.a.random.uuid()}]},bufferZone:function(){return"".concat(s.a.random.number({min:1,max:20})," Feet")},bufferReason:function(){return"Pollen Drift"},notes:function(){return s.a.lorem.paragraph()},startWeather:function(){return{date:"2021-11-25T23:15:30.562Z",windSpeed:11,windDirection:"N",skyCondition:"cloudy",temperature:69,soilMoisture:"Dry",humidity:86}},endWeather:function(){return{date:"2021-11-25T23:15:30.562Z",windSpeed:11,windDirection:203,skyCondition:"Cloudy",temperature:69,soilMoisture:10,humidity:86}},afterCreate:function(e,t){var n=t.createList("person",2),a=t.createList("member",1);e.update({applicators:n,assignees:a,authorizedBy:t.db.people[0]})}},q=a.a.extend(W),J=n(14),K=n(262),Q=n(420),X=n.n(Q),$=Object(p.a)(Object(p.a)({oktaId:function(){return s.a.random.boolean()?"":s.a.random.uuid()},oktaEmail:function(){return s.a.internet.email()},organizationId:"",licenses:function(){return Array.from({length:s.a.random.number({min:1,max:3})},(function(){var e=s.a.random.arrayElement(["Applicator","Planter","Harvestor"]);return{_id:s.a.random.uuid(),licenseType:e,value:e.charAt(0).toLowerCase(),expiry:s.a.date.future(s.a.random.number({max:5}))}}))},contactInfo:function(){var e=s.a.name.firstName(),t=s.a.name.firstName().charAt(0),n=s.a.name.lastName(),a=s.a.random.boolean()?s.a.random.arrayElement(["Dr","Mr","Mrs","Ms","Miss"]):"",r=s.a.random.boolean()?s.a.random.arrayElement(["II","III","IV","Jr","Sr"]):"",c=s.a.internet.email(e,n);return{name:{givenName:e,middleInit:t,surname:n,prefix:a,suffix:r},notes:"",addresses:Array.from({length:s.a.random.number({max:10})/8<=1?1:2},(function(){return{address1:s.a.address.streetAddress(),address2:s.a.random.boolean()?s.a.address.secondaryAddress():"",postalCode:s.a.address.zipCode(),city:s.a.address.city(),country:X.a.whereAlpha2(s.a.address.countryCode()).alpha3,state:s.a.address.stateAbbr(),addressType:""}})),emails:[c,this.oktaEmail].concat(Object(J.a)(s.a.random.boolean()?[]:[s.a.internet.email()])),phoneNumbers:Array.from({length:s.a.random.boolean()?1:2},(function(){return{phoneType:s.a.random.boolean()?"mobile":s.a.random.arrayElement(["home","work","fax","pager"]),value:s.a.phone.phoneNumber(),name:""}}))}}},u),{},{afterCreate:function(e,t){""===e.attrs.organizationId&&e.update({organizationId:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6"}),t.createList("invitation",3,{name:"".concat(e.attrs.contactInfo.name.givenName," ").concat(e.attrs.contactInfo.name.surname),email:e.attrs.oktaEmail});var n=window.location.search?Object(K.parse)(window.location.search.substr(1)):{};t.create("permission",{organizationId:e.attrs.organizationId,oktaId:e.attrs.oktaId,role:n.role||"admin",financial:n.financial||"none"})}}),ee=a.a.extend($),te={oktaId:function(){return s.a.random.boolean()?"":s.a.random.uuid()},name:function(){return"".concat(s.a.name.firstName()," ").concat(s.a.name.lastName())},organizationId:"",licenses:function(){return Array.from({length:s.a.random.number({min:1,max:3})},(function(){var e=s.a.random.arrayElement(["Applicator","Planter","Harvestor"]);return{_id:s.a.random.uuid(),licenseType:e,value:e.charAt(0).toLowerCase(),expiry:s.a.date.future(s.a.random.number({max:5}))}}))},contactInfo:function(){var e=s.a.name.firstName(),t=s.a.name.firstName().charAt(0),n=s.a.name.lastName(),a=s.a.random.boolean()?s.a.random.arrayElement(["Dr","Mr","Mrs","Ms","Miss"]):"",r=s.a.random.boolean()?s.a.random.arrayElement(["II","III","IV","Jr","Sr"]):"",c=s.a.internet.email(e,n);return{name:{givenName:e,middleInit:t,surname:n,prefix:a,suffix:r},notes:"",addresses:Array.from({length:s.a.random.number({max:10})/8<=1?1:2},(function(){return{address1:s.a.address.streetAddress(),address2:s.a.random.boolean()?s.a.address.secondaryAddress():"",postalCode:s.a.address.zipCode(),city:s.a.address.city(),country:X.a.whereAlpha2(s.a.address.countryCode()).alpha3,state:s.a.address.stateAbbr(),addressType:""}})),emails:[c].concat(Object(J.a)(s.a.random.boolean()?[]:[s.a.internet.email()])),phoneNumbers:Array.from({length:s.a.random.boolean()?1:2},(function(){return{phoneType:s.a.random.boolean()?"mobile":s.a.random.arrayElement(["home","work","fax","pager"]),value:s.a.phone.phoneNumber(),name:""}}))}}},ne=a.a.extend(te),ae=n(25),re={name:function(){return"Mirage Organization"},primaryContact:function(){return"Guy Fieri"},primaryContactEmail:function(){return"guy.fieri@flavortown.com"},primaryContactPhoneNumber:function(){return"5555555555"},billingAddress:function(){return{address1:"",address2:"",postCode:"",state:"",country:""}},afterCreate:function(e,t){return function(e,t){ae.l&&(e.createList("user",4,{organizationId:t}),e.createList("member",9,{organizationId:t}),e.createList("equipment",10,{organizationId:t})),e.createList("company",5,{organizationId:t})}(t,e.attrs.id),!0}},ce=a.a.extend(re),ie=Object(p.a)({current:{updatedAt:s.a.date.recent(),forecast:s.a.random.arrayElement(["cloudy","sunny","rainy"]),temperature:{value:56,unit:"f"}},location:{city:"denver",stateAbbr:"co"},today:{high:{value:s.a.random.number({min:50,max:100}),unit:"f"},low:{value:s.a.random.number({min:20,max:49}),unit:"f"},humidity:"".concat(s.a.random.number({min:0,max:100}),"%"),wind:{direction:"ssw",speed:"".concat(s.a.random.number({min:0,max:20})," m/h'")},precipitation:'.1"',dewPoint:22},upcoming:["Sunday","Monday","Tuesday","Wednesday","Thursday"]},u),oe=a.a.extend(ie),se={name:"",email:"",role:function(){return s.a.random.arrayElement(["Admin","FullControl","Author","ViewOnly"])},financial:function(){return s.a.random.arrayElement(["edit","view","none"])},status:function(){return s.a.random.arrayElement(["active","accepted","cancelled","expired","declined","revoked"])},memberSince:function(){return s.a.date.past(20)},inviteId:function(){return s.a.random.uuid()},organizationId:"",invitedUserId:function(){return s.a.random.uuid()},invitedOktaId:function(){return s.a.internet.password(10,!1,/[0-9A-Z]/)},senderUserId:function(){return s.a.random.uuid()},senderOktaId:function(){return s.a.internet.password(10,!1,/[0-9A-Z]/)},createdAt:function(){return s.a.date.recent()},expiry:function(){return s.a.date.future(s.a.random.number({max:77}))},afterCreate:function(e,t){if(""===e.attrs.organizationId){var n=t.schema.organizations.all(),a=s.a.random.number({min:0,max:n.length-1}),r=n.models[a];e.update({organizationId:r&&r.attrs.id})}}},le=a.a.extend(se),de=["clear","becomingClear","mostlyClear","becomingMostlyClear","partlyCloudy","becomingPartlyCloudy","partlyClear","becomingPartlyClear","mostlyCloudy","becomingMostlyCloudy","cloudy","becomingCloudy","fair","becomingFair","fewClouds","fewCloudsDeveloping","scatteredClouds","scatteredCloudsDeveloping","brokenOvercast","becomingBrokenOvercast","overcast","becomingOvercast","clouds","decreasingClouds","increasingClouds","variableClouds","numerousClouds","numerousCloudsDeveloping","sunny","becomingSunny","mostlySunny","becomingMostlySunny","partlySunny","becomingPartlySunny","considerableCloudiness","becomingConsiderableCloudiness","considerableCloudinessDeveloping"],ue=["variableWinds","N","NE","NNE","NW","NNW","S","SE","SSE","SW","SSW","E","ENE","ESE","W","WSW","WNW"],be=Object(p.a)({eventDateTime:function(){return s.a.date.future()},startDateTime:function(){return s.a.date.future()},endDateTime:function(){return s.a.date.future()},temperatureUnit:function(){return s.a.random.arrayElement(["\xb0F","\xb0C","\xb0"])},temperature:function(){return"\xb0F"===this.temperatureUnit()?s.a.random.number({min:-50,max:100}):s.a.random.number({min:-10,max:40})},relativeHumidity:function(){return s.a.random.number(100)},windSpeedUnit:function(){return s.a.random.arrayElement(["mph","km/h"])},windSpeed:function(){return"mph"===this.windSpeedUnit()?s.a.random.number(200):s.a.random.number(300)},windDirection:function(){return s.a.random.arrayElement(ue)},skyCondition:function(){return s.a.random.arrayElement(de)}},u),je=a.a.extend(be),pe=["rent","equipment","insurance","labor","repairs","taxes","returnToManagement"],fe=Object(p.a)(Object(p.a)({name:function(){return"Plant ".concat(s.a.random.word())},crops:function(){var e=[{$id:s.a.random.uuid(),$ref:"Crop"}];return e},area:function(){return s.a.random.number()},notes:function(){return s.a.lorem.sentences()},costs:function(){for(var e=[],t=0;t<5;t+=1)e.push({costType:s.a.random.arrayElement(pe),costValue:s.a.random.number(),costStructure:s.a.random.arrayElement(["byArea","total"])});return e},revenue:function(){return{yieldPerArea:s.a.random.number(),salePricePerUnit:parseFloat(s.a.finance.amount()),fsaPayment:s.a.random.number(),cropShare:s.a.random.number({min:0,max:100})}},flag:function(){return s.a.random.word()},cropSeason:function(e){return{cropSeasonLabel:e<3?"2020":"2019",startDate:s.a.date.recent(),endDate:s.a.date.future()}},cropYear:function(){return{cropYearLabel:s.a.random.word(),startDate:s.a.date.recent(),endDate:s.a.date.future()}},fields:function(){return null},productApplication:function(){return null}},u),{},{afterCreate:function(e,t){t.create("crop",{id:e.crops[0].$id}),e.update({productApplication:{products:t.createList("product",5),timingEvent:s.a.random.arrayElement(["prePlant","planting","growing","harvest","storage","annual"]),timingTag:s.a.random.word(),targetDate:s.a.date.future(),applicationCount:s.a.random.number()}})}}),me=a.a.extend(fe),ve={applicatorLicenseNumber:function(){return"8299103475"},applicatorLicenseExpirationDate:function(){return s.a.date.future()},name:function(){return"".concat(s.a.name.firstName()," ").concat(s.a.name.lastName())},company:function(){return"".concat(s.a.name.firstName()," company")}},Oe=a.a.extend(ve),he=n(7),xe=n(26),ge=["data"],Ce=function(e,t){return e.map((function(e){return{$ref:t,$id:e}}))},ye=function(e,t,n,r){var c=a.d.prototype.serialize.apply(t,n),i=c.data,o=Object(xe.a)(c,ge),s=function(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""},l=s(r||e.slice(0,-1));return i=Array.isArray(i)?i.map((function(t){return Object(p.a)(Object(p.a)({},t),t[e]?Object(he.a)({},e,Ce(t[e],l)):null)})):Object(p.a)(Object(p.a)({},i),i[e]?Object(he.a)({},e,Ce(i[e],l)):null),Object(p.a)(Object(p.a)({},o),{},{data:i})},Pe=n(9),Ae=function(e,t,n,a){var r=e;return"like"===n&&(r=r.filter((function(e){var n=a.replace(/%/g,".*");return Object(Pe.get)(e.attrs,t).match(new RegExp(n,"i"))}))),r},Se=function(e){var t=Object.keys(e)[0];return{key:t,value:e[t]}},Te=function(e,t){return Object(K.parse)("".concat(t,"=").concat(e[t]))},Ne=function e(t,n){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=Se(n),c=r.key,i=r.value,o="".concat(a).concat(c);if(Object(Pe.isObject)(i))return e(t,i,"".concat(o,"."));var s=i.substring(0,i.indexOf("(")),l=i.substring(i.indexOf("(")+1,i.indexOf(")"));return Ae(t,o,s,l)},Ee=function(e,t){var n=Object(Pe.cloneDeep)(e),a=function(e){var t=[];return e["sort[0]"]&&e["sort[1]"]&&(t=[e["sort[0]"],e["sort[1]"]]),t}(t);if(a.length){var r=a,c=r[0].substring(0,r[0].indexOf("(")),i=r.map((function(e){return e.substring(e.indexOf("(")+1,e.indexOf(")"))}));n.models=function(e,t,n){for(var a=e,r=Object(Pe.cloneDeep)(n),c=[t],i=0;i<r.length;i+=1)r[i]="attrs.".concat(r[i]),c.push(t);return Object(Pe.orderBy)(a,r,c)}(n.models,c,i)}if(t.limit){var o=void 0===t.offset?0:parseInt(t.offset,10);n=n.slice(o,o+parseInt(t.limit,10))}for(var s=0;s<Object.keys(t).length;s+=1){var l=Object.keys(t)[s],d=Te(t,l),u=Se(d).key;u in n.models[0].attrs&&"active"!==u&&(n.models=Ne(n.models,d))}return n},we=function(){return new a.c(404,{},{message:"Unable to Authorize User"})},_e=function(e,t){return new a.c(404,{},{message:"Unable to retrieve ".concat(t," with id: ").concat(e)})},Re=function(e){return new a.c(400,{},{message:e})},Ie=function(e){return Re("'".concat(e,"' is not allowed"))},De=function(e,t){return Re("'".concat(e,"' is required on ").concat(t))},ke=function(e,t){return function(n,a){var r,c=a.method,i=a.requestBody,o=JSON.parse(i);return"POST"===c&&(r=function(e,t){var n=["_id","active","createdAt","updatedAt","version"].find((function(t){return Object.prototype.hasOwnProperty.call(e,t)}));if(n)return Ie(n);if(t){var a=[];if(t.forEach((function(n){t.find((function(){return Object.prototype.hasOwnProperty.call(e,n)}))||a.push(n)})),a.length>0)return De(a.join(),"POST")}return null}(o,t)),"PUT"===c&&(r=function(e,t){var n=void 0!==t?t:[],a=["_id","active","createdAt","updatedAt"].find((function(t){return Object.prototype.hasOwnProperty.call(e,t)}));if(a)return Ie(a);n.push("version");var r=[];return n.forEach((function(t){n.find((function(){return Object.prototype.hasOwnProperty.call(e,t)}))||r.push(t)})),r.length>0?De(r.join(),"PUT"):null}(o,t)),r||e(n,a)}},Le=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t?e.filter((function(e){return e.active})):e},Fe=["version"],Me=function(e,t,n){return"organization"===n&&Object(Pe.has)(e._factoryMap[t].attrs,"organizationId")},Ve=function(e,t,n){var a="".concat(t,"Id");return Object(Pe.has)(e.queryParams,a)?{}:Object(he.a)({},a,n)},Be=function(e,t,n){var a=e.inflector.pluralize(t),r=e.inflector.pluralize(n);return function(c,i){var o=i.params.parentId,s=i.queryParams.default,l=c[r].find(o);if(!l)return _e(o,Object(Pe.capitalize)(r));var d=Me(e,t,n)?c[a].where(Ve(i,n,l.attrs.id)):c[a].all(),u=Le(d,s);return Ee(u,i.queryParams)}},Ue=function(e,t,n){var a=e.inflector.pluralize(t),r=e.inflector.pluralize(n);return function(e,t){var n=t.params,c=n.parentId,i=n.id;if(!e[r].find(c))return _e(c,Object(Pe.capitalize)(r));var o=e[a].find(i);return o||_e(i,Object(Pe.capitalize)(a))}},ze=function(e,t,n,a){var r=e.inflector.pluralize(t),c=e.inflector.pluralize(n);return ke((function(e,t){var n=t.params,i=n.id,o=n.parentId;if(!e[c].find(o))return _e(o,Object(Pe.capitalize)(c));var s=e[r].find(i);if(s){var l=JSON.parse(t.requestBody),d=l.version,u=Object(xe.a)(l,Fe),b=a?a(u):u;return s.update(Object(p.a)(Object(p.a)({},b),{},{version:d+1,updatedAt:new Date}))}return _e(i,Object(Pe.capitalize)(r))}))},Ze=function(e,t,n){var a=e.inflector.pluralize(t),r=e.inflector.pluralize(n);return ke((function(c,i){var o=i.params.parentId;if(!c[r].find(o))return _e(o,Object(Pe.capitalize)(r));var s=Me(e,t,n),l=Object(p.a)(Object(p.a)({},JSON.parse(i.requestBody)),s?Ve(i,n,o):null);return c[a].create(Object(p.a)(Object(p.a)({},l),{},{active:!0,createdAt:new Date,version:0}))}))},Ye=function(e,t,n){var a=e.inflector.pluralize(t),r=e.inflector.pluralize(n);return function(e,t){var n=t.params,c=n.id,i=n.parentId;if(!e[r].find(i))return _e(i,Object(Pe.capitalize)(r));var o=e[a].find(c);return o?o.update({active:!1}):_e(c,Object(Pe.capitalize)(a))}},He=["version"],Ge=function(e,t){var n=e.inflector.pluralize(t);return function(e,t){var a=t.queryParams.default,r=Le(e[n].all(),a);return Ee(r,t.queryParams)}},We=function(e,t){var n=e.inflector.pluralize(t);return function(e,t){var a=t.params.id,r=e[n].find(a);return r||_e(a,Object(Pe.capitalize)(n))}},qe=function(e,t,n,a){var r=e.inflector.pluralize(t);return ke((function(e,t){var n=t.params,c=t.requestBody,i=n.id,o=e[r].find(i);if(o){var s=JSON.parse(c),l=s.version,d=Object(xe.a)(s,He),u=a?a(d):d;return o.update(Object(p.a)(Object(p.a)({},u),{},{version:l+1,updatedAt:new Date}))}return _e(i,Object(Pe.capitalize)(r))}),n)},Je=function(e,t,n){var a=e.inflector.pluralize(t);return ke((function(e,t){return e[a].create(Object(p.a)(Object(p.a)({},JSON.parse(t.requestBody)),{},{active:!0,createdAt:new Date,version:0}))}),n)},Ke=function(e,t){var n=e.inflector.pluralize(t);return function(e,t){var a=t.params.id,r=e[n].find(a);return r?r.update({active:!1}):_e(a,Object(Pe.capitalize)(n))}},Qe=function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=a.namePlural,c=a.parentNamePlural,i=a.customHandlers,o=void 0===i?{}:i,s=r||e.inflector.pluralize(t),l=c||e.inflector.pluralize(n),d="/".concat(l,"/:parentId/").concat(s);e.get(d,Be(e,t,n)),e.get("".concat(d,"/:id"),Ue(e,t,n)),e.post(d,Ze(e,t,n)),e.put("".concat(d,"/:id"),ze(e,t,n,o.beforeUpdate)),e.delete("".concat(d,"/:id"),Ye(e,t,n),200)},Xe=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=n.namePlural,r=n.orgRoutes,c=void 0===r||r,i=n.requiredFields,o=n.customHandlers,s=void 0===o?{}:o,l=a||e.inflector.pluralize(t);e.get("/".concat(l),Ge(e,t)),e.get("/".concat(l,"/:id"),We(e,t)),e.put("/".concat(l,"/:id"),s.update||qe(e,t,i,s.beforeUpdate)),e.post("/".concat(l),Je(e,t,i)),e.delete("".concat(l,"/:id"),Ke(e,t)),c&&Qe(e,t,"organization",{customHandlers:s})},$e=function(e){Xe(e,"tags",{orgRoutes:!1,customHandlers:{update:function(e,t){for(var n=t.params.id,a=JSON.parse(t.requestBody),r=e.fields.where((function(e){return e.farm.id===n})),c=0;c<r.models.length;c+=1){r.models[c].farm.name=a.name}var i=e.tags.where({id:n});return i.update({name:a.name}),i}}})},et=n(73),tt=function(e,t,n){return e.where({organizationId:t,oktaId:n})},nt=function(e){var t=e.match(/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/g);return Array.isArray(t)?t[0]:t},at=n(10),rt=n(6),ct=n.n(rt),it="9a1a1673-6926-41fa-9d71-a5aad6f67cb6",ot=function(){var e=window.XMLHttpRequest.prototype.send;window.XMLHttpRequest.prototype.send=function(){e.apply(this,arguments);var t=this,n=this._passthroughRequest;n&&(n.onload=function(e){"arraybuffer"!==t.responseType&&(t.response=n.response),t.dispatchEvent(e)})}},st=a.d.extend({keyForModel:function(){return"content"},keyForCollection:function(){return"content"}}),lt=a.d.extend({keyForModel:function(){return"data"},keyForCollection:function(){return"data"}}).extend({keyForAttribute:function(e){return"id"===e?"_id":e}}),dt=a.d.extend({root:!1,embed:!0});function ut(e){var t=e.environment,n=void 0===t?"development":t,r=new a.e({environment:n,identityManagers:{area:l,crop:l,company:l,equipment:l,field:l,tag:l,permission:l,product:l,plan:l,user:l,member:l,organization:l,invitation:l,weather:l,task:l,person:l},serializers:{application:st,area:lt.extend({serialize:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return ye("areas",this,t)}}),crop:dt,company:lt,equipment:lt,field:lt.extend({include:["areas"],embed:!0}),tag:lt,permission:dt,person:st,product:lt,plan:lt,user:st,member:st,organization:st,invitation:dt,weather:st,task:st.extend({include:["applicators","assignees"],embed:!0})},models:{area:a.b.extend({areas:Object(a.f)()}),crop:a.b,costPerAcre:a.b,company:a.b,dashboard:a.b,equipment:a.b,field:a.b.extend({areas:Object(a.f)()}),imagery:a.b,tag:a.b,permission:a.b,person:a.b,plan:a.b.extend({fields:Object(a.f)()}),product:a.b,task:a.b.extend({applicators:Object(a.f)("person"),assignees:Object(a.f)("member")}),user:a.b,member:a.b,organization:a.b.extend({members:Object(a.f)()}),dashboardWeather:a.b,invitation:a.b,weather:a.b},factories:{area:j,crop:x,costPerAcre:m,company:O,dashboard:y,dashboardWeather:oe,equipment:S,field:F,imagery:B,tag:G,permission:z,person:Oe,plan:me,product:Y,task:q,user:ee,member:ne,organization:ce,invitation:le,weather:je},seeds:function(e){e.create("organization"),e.createList("member",2),e.createList("field",2),e.createList("area",1),e.createList("permission",5),e.createList("crop",10),e.create("dashboard"),e.createList("cost-per-acre",6),e.create("dashboardWeather"),e.create("imagery"),e.createList("tag",5),e.createList("plan",5),e.createList("product",12),e.createList("weather",10),e.createList("company",10),e.createList("task",2,{status:"ready"}),e.createList("task",2,{status:"in-progress"}),e.createList("task",2,{status:"complete"})},routes:function(){var e;this.namespace="",this.timing="test"===n?1:500,Xe(e=this,"area",{orgRoutes:!1}),Qe(e,"area","field"),e.get("areas/:id",(function(e,t){var n=t.params.id,a=e.areas.find(n);return a||(a=e.areas.first()),a})),e.put("organizations/:organizationId/fields/:fieldId/areas/:areaId",(function(e,t){var n=JSON.parse(t.requestBody),a=t.params.areaId;if(n.areas){n.areaIds=[];for(var r=0;r<n.areas.length;r+=1)n.areaIds.push(n.areas[r].$id);delete n.areas}var c=e.areas.find(a);if(c||(c=e.areas.first()),n.boundedArea&&"{"===n.boundedArea.charAt(0)){var i=JSON.parse(n.boundedArea),o=nt(c.boundedArea);if(o){var s=e.shapes.find(o);s.attrs.body=i,s.save(),n.boundedArea="/shapes/".concat(o)}}return c.update(n)})),function(e){Xe(e,"crop",{orgRoutes:!1}),e.get("crops",(function(e,t){for(var n=[],a=e.crops.all(),r=0;r<a.models.length;r+=1){var c=a.models[r].attrs;c.Id=c.id,delete c.id,c.Name=c.name,delete c.name,n.push(c)}return{Crops:n}})),e.get("crops/:id",(function(e,t){var n=t.params.id,a=e.crops.find(n).attrs;return a.Id=a.id,delete a.id,a.Name=a.name,delete a.name,{Crop:a}}))}(this),function(e){Xe(e,"company")}(this),function(e){Xe(e,"dashboard",{orgRoutes:!1})}(this),function(e){Xe(e,"equipment")}(this),function(e){e.get("organizations/:id/fields",(function(e,t){return e.fields.all()})),e.get("organizations/:id/fields/:fieldId",(function(e,t){var n=t.params.fieldId;return e.fields.find(n)||e.fields.first()}))}(this),function(e){e.get("".concat(ae.k,"/organizations"),(function(e,t){var n=Object(et.d)(t.requestHeaders);if(null!==n){var a=e.permissions.all().filter((function(e){return e.oktaId===n.uid}));if(a)return a}return _e("No permissions found","Permission")})),e.get("".concat(ae.k,"/users"),(function(e,t){var n=Object(et.d)(t.requestHeaders);if(null!==n){var a=t.queryParams.organizationId,r=e.permissions.where({organizationId:a,oktaId:n.uid});if(r)return r}return _e("Permission not found","Permission")})),e.put(ae.k,(function(e,t){var n=Object(et.d)(t.requestHeaders);if(null!==n){var a=JSON.parse(t.requestBody),r=tt(e.permissions,a.organizationId,n.uid);return r.length>0?r.update(JSON.parse(t.requestBody)):_e("Permission not updated","Permission")}return _e("Permission not updated","Permission")})),e.post("".concat(ae.k),(function(e,t){var n=Object(et.d)(t.requestHeaders);if(null!==n){var a=JSON.parse(t.requestBody);return a.oktaId=n.uid,a.version=0,e.permissions.create(a)}return _e("No Bearer Token","Permission")})),e.delete("".concat(ae.k),(function(e,t){var n=Object(et.d)(t.requestHeaders);if(null!==n){var a=JSON.parse(t.requestBody),r=tt(e.permissions,a.organizationId,n.uid);if(r)return r.destroy()}return _e("Permission Not Found","Permission")}),200)}(this),function(e){e.get("organizations/:id/people",(function(e){return e.people.all()}))}(this),function(e){Xe(e,"plan")}(this),function(e){Xe(e,"product")}(this),$e(this),function(e){e.get("organizations/:id/tasks",(function(e,t){return e.tasks.all()})),e.get("organizations/:id/tasks/:taskId",(function(e,t){var n=t.params.taskId;return e.tasks.find(n)||e.tasks.first()}))}(this),function(e){Xe(e,"users",{orgRoutes:!1}),e.get("/users",(function(e,t){var n=t.queryParams,a=n.default,r=n.organizationId;if(r)return e.users.where({organizationId:r});var c=Le(e.users.all(),a);return Ee(c,n)}))}(this),function(e){e.get("organizations/:id/members",(function(e,t){return e.members.all()}))}(this),function(e){e.get("organizations",(function(e,t){return e.organizations.all()})),e.get("organizations/:id",(function(e,t){var n=t.params.id;return e.organizations.find(n)||e.organizations.first()})),e.get("organizations/:id/accounts",(function(e,t){return e.members.all()})),e.put("organizations/:id",(function(e,t){var n=JSON.parse(t.requestBody),a=t.params.id;return(e.organizations.find(a)||e.organizations.first()).update(n)})),e.delete("organizations/:id",(function(e,t){var n=t.params.id;return(e.organizations.find(n)||e.organizations.first()).destroy()}))}(this),function(e){e.get("".concat(ae.f,"/invites"),function(){var e=Object(at.a)(ct.a.mark((function e(t,n){var a,r,c;return ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n.queryParams.status,r=n.queryParams.organizationId,c=t.invitations.all().filter((function(e){return e.attrs.organizationId===r})),a&&(c=c.filter((function(e){return e.attrs.status===a}))),!c){e.next=6;break}return e.abrupt("return",c);case 6:return e.abrupt("return",_e(r,"Invitations"));case 7:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()),e.get("".concat(ae.f,"/invites/:id"),function(){var e=Object(at.a)(ct.a.mark((function e(t,n){var a,r,c,i;return ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n.params.id,r=t.invitations.all(),c=n.queryParams.organizationId,(i=Object(et.d)(n.requestHeaders))&&(r=r.filter((function(e){return e.attrs.emailAddress===i.sub}))),a&&(r=r.filter((function(e){return e.attrs.id===a}))),c&&(r=r.filter((function(e){return e.attrs.organizationId===c}))),!r){e.next=9;break}return e.abrupt("return",r);case 9:return e.abrupt("return",_e(c,"Invitations"));case 10:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()),e.delete("".concat(ae.f,"/invitations/:id"),(function(e,t){var n=t.params.id,a=e.invitations.find(n);return null!==Object(et.d)(t.requestHeaders)?a?a.destroy():_e(n,"Invitation"):we()})),e.put("".concat(ae.f,"/invitations/:id"),(function(e,t){var n=t.params.id,a=e.invitations.find(n);return null!==Object(et.d)(t.requestHeaders)?a?a.update(JSON.parse(t.requestBody)):_e(n,"Invitation"):we()})),e.post("".concat(ae.f,"/invites"),function(){var e=Object(at.a)(ct.a.mark((function e(t,n){var a,r,c,i;return ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.members.where({organizationId:it});case 2:if(!(a=e.sent)){e.next=13;break}if(r=JSON.parse(n.requestBody),c=a.models.find((function(e){return e.attrs.contactInfo.emails.includes(r.emailAddress)})),i=Object(et.d)(n.requestHeaders),c){e.next=10;break}return e.next=10,t.members.create({active:!0,oktaId:i.uid,organizationId:it,contactInfo:{name:{givenName:r.firstName,surname:r.lastName},emails:[r.emailAddress]}});case 10:if(null===i){e.next=12;break}return e.abrupt("return",t.invitations.create(Object(p.a)(Object(p.a)({},r),{},{email:r.emailAddress,name:"".concat(r.firstName," ").concat(r.lastName),financial:r.financial,role:r.permissionLevel,expiry:r.expirationDate,createdBy:i.uid,createdDate:(new Date).toISOString(),status:"active"})));case 12:return e.abrupt("return",we());case 13:return e.abrupt("return",_e());case 14:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()),e.post("".concat(ae.f,"/acceptInvitation"),(function(e,t){if(null!==Object(et.d)(t.requestHeaders)){var n=JSON.parse(t.requestBody),a=e.invitations.find(n.id);if(a)return a.update({status:"accepted",acceptedDate:(new Date).toISOString()})}return we()})),e.post("".concat(ae.f,"/resendInvitation"),(function(){})),e.post("".concat(ae.f,"/cancelInvitation"),(function(e,t){var n=JSON.parse(t.requestBody),a=e.invitations.all().filter((function(e){return e.emailAddress===n.emailAddress}));return a?a.update({status:"cancelled",cancelledDate:(new Date).toISOString()}):we()})),e.post("".concat(ae.f,"/declineInvitation"),(function(e,t){var n=JSON.parse(t.requestBody);if(null!==Object(et.d)(t.requestHeaders)){var a=e.invitations.find(n.id);if(a)return a.update({status:"declined",declinedDate:(new Date).toISOString()})}return we()}))}(this),function(e){Xe(e,"weather",{orgRoutes:!1}),Qe(e,"weather","tasks")}(this),this.get("/cost-per-acres",(function(e){return e.costPerAcres.all()})),this.get("/imagery",(function(e){return e.imageries.first()})),this.get("/dashboardWeather",(function(e){return e.dashboardWeathers.all()})),this.passthrough("".concat(Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).REACT_APP_API_URL,"/**")),this.passthrough("".concat(Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).REACT_APP_PERMISSIONSERVICE_API_URL,"/**")),this.passthrough("".concat(Object({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_Y_AND_P_PROFITABILITY_DATASET_ID:"aefba8c4-d6f1-46cd-874f-beec2aedb266",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_DATASET_ID:"babdf04e-fccb-4a96-948d-b2f98f3e33f5",REACT_APP_NOTICE_OF_APPLICATION_EMBED_REPORT_ID:"98d753c5-add3-4427-9819-de6e08857a47,d9d4c75d-bc7b-43d3-91bc-874d63e6c76f",REACT_APP_AG_CLEAR_APP_ID:"e152930f",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_DATASET_ID:"074dc791-d670-4e7c-8162-3fe6f8bdba14",REACT_APP_CROPWISE_CONNECT_API_URL:"https://uat-api.databus.cropwise.com",REACT_APP_SMART_LOOK_REGION:"us",REACT_APP_POWERBI_GROUP_ID:"aa609fd5-6c0e-48c7-8203-1a0f9964b4fa",REACT_APP_MASTERLIST_PASSWORD:"jDPEU8Mda65BJwf7",REACT_APP_APPLIED_PRODUCTS_DETAILS_EMBED_REPORT_ID:"0e9b6888-47dc-466b-b94e-840ea4e73989,13ca93d3-b035-4b3b-9ce6-9a6d85daad7f",REACT_APP_APPLIED_PRODUCTS_SUMMARY_EMBED_REPORT_ID:"03116c00-d230-4c0a-902d-dc51595e76fa,beb7f8e7-21f5-4fb1-8648-570e8877eb2b",REACT_APP_FIELDS_BY_CROP_LAYOUT_DATASET_ID:"20f29a73-5dca-4fa5-9032-55ecef7d2720",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_DATASET_ID:"d9236def-f34c-4d10-a236-ed841cc1000e",REACT_APP_APPLIED_PRODUCTS_DICAMBA_EMBED_REPORT_ID:"c4c95188-4ef0-429d-ba41-455deef30822,7929688e-b52c-4636-882d-e476704df76f",REACT_APP_DEVTEST_ORGANIZATIONID:"9a1a1673-6926-41fa-9d71-a5aad6f67cb6",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_DATASET_ID:"e3dc8556-4438-4683-8709-87ffa8dc7572",REACT_APP_CLIENT_ID:"ddcd4fe8157148fc90b0fe95753f2bd0",REACT_APP_MASTERLIST_USER:"cwf_ml",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_EMBED_REPORT_ID:"b7137425-9780-4227-8ebd-c554d92b8dcc,db62dbdd-088f-4e7b-b9c5-b770646109ca",REACT_APP_MAPBOX_ACCESS_TOKEN:"pk.eyJ1Ijoic3RyaWRlcmVuZ2luZWVyaW5nIiwiYSI6ImNsdWs5ZG1vNzA2azYyam1scHljMjNyc3kifQ.YBj-8NtAHftqXroxqmbxXw",REACT_APP_SENTRY_SAMPLE_RATE:"1",REACT_APP_PESTICIDE_USAGE_BY_CROP_DATASET_ID:"c478bd25-04f1-49f9-91b1-e38f83a4ec73",REACT_APP_APPLIED_PRODUCTS_REI_DATASET_ID:"58179a3d-155d-4b32-8ce3-08769217d401",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_EMBED_REPORT_ID:"78333e90-e6fd-4116-9d60-7732c5d38c28,73f7c1ea-dce0-47d9-9f3c-c51401dfaf58",REACT_APP_Y_AND_P_PROFITABILITY_EMBED_REPORT_ID:"8391c710-f300-47a5-b069-cb65ec294ee3,eae80a20-80e2-41c5-8654-747d58d8692b",REACT_APP_PRODUCTION_RECORDS_PRINT_INVOICES_EMBED_REPORT_ID:"0d55139a-bc33-4090-a5ec-6caf6167622c,910d5b03-9e6d-4dc8-b1a9-75f0525c247e",REACT_APP_APPLIED_PRODUCTS_PHI_DATASET_ID:"b0621b3e-fd42-4af0-9f4b-11f6a311de33",REACT_APP_APPLIED_PRODUCTS_BY_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe",REACT_APP_CROPWISE_PROXY_V2_URL:"https://api-v2-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_DATASET_ID:"adf5b1f8-e73a-4108-810f-394a06910d93",REACT_APP_ZENDESK_WIDGET:"https://static.zdassets.com/ekr/snippet.js?key=9a46f5c8-0947-4716-a5cd-05541a8d5d52",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EMBED_REPORT_ID:"db268a5d-867e-4fc0-b100-7d76f4a5556b,b4c9dd80-c35a-4bd3-ba21-2c2cd79787fb",REACT_APP_HIDE_PROPERTIES:"true",REACT_APP_PRODUCTS_PLAN_SUMMARY_DATASET_ID:"0c1300a7-ff25-40fb-bbd1-8c3ceeb1f677",REACT_APP_CROPWISE_PROXY_URL:"https://api-qa.financials.cropwise.com",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_DATASET_ID:"a9b0e341-65ff-43e7-8796-90b5c0d57a18",REACT_APP_MASTERLIST_PROXY_URL:"https://masterlist-proxy-api-staging.landdb.com/api",REACT_APP_AG_CLEAR_APP_ROOT_URL:"https://ag.us.clearapis.com",REACT_APP_AG_CLEAR_APP_KEY:"c8680d7e198295202a7bd1838a5cd76d",REACT_APP_Y_AND_P_YIELD_PRODUCTION_DATASET_ID:"89a2a80f-3bd7-4901-bda6-f342db4cc693",REACT_APP_SENTRY_DSN:"https://3dc4f6ed59a640eda9f9af2aba42b0f2@o49647.ingest.sentry.io/6555748",REACT_APP_ORG_INVITE_REDIRECT_QA_URL:"https://qa.financials.cropwise.com/app/property-landing",REACT_APP_PRODUCTS_INVENTORY_SUMMARY_EMBED_REPORT_ID:"7a76700f-2f2e-4a7d-826e-746494fdad51,778f6090-a1da-4129-81f7-e438c4b5a4c7",REACT_APP_AMPLITUDE_KEY:"e1cc15ce421fdc13c7194b57e60ba78e",REACT_APP_FIELDS_BY_CROP_LAYOUT_EMBED_REPORT_ID:"f446a47e-85de-4cfd-bfc3-79a7dd8906f7,217c16e4-bd2d-4f91-b668-f8d92fd2e8bb",REACT_APP_SMART_LOOK_KEY:"2e4e8daf83c4937253a99516982b6482e03be4f5",REACT_APP_HOST_URL:"https://qa.financials.cropwise.com",REACT_APP_ENV_NAME:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_PLANS_EMBED_REPORT_ID:"0128abaa-e9ee-4e2e-a3ba-81b8895c95e3,d9746965-b289-4f46-9caa-3f923d4b9a5c",REACT_APP_ROLE_CONTEXT_PERMISSIONS_UPDATE:"app:76aa065c-ba35-47d5-bea9-33ce777c4afa",REACT_APP_EXCEL_REPORT_DATASET_ID:"82564c52-53b2-4c7e-ae34-2056d32557be",REACT_APP_APPLIED_PRODUCTS_SUMMARY_DETAILS_DATASET_ID:"0e68c788-75bd-486b-8be7-b6aeddd20681",REACT_APP_BASE_AUTH_HEADER:"ZGRjZDRmZTgxNTcxNDhmYzkwYjBmZTk1NzUzZjJiZDA6",REACT_APP_INTEGRATIONS_CALAG_WEBSITE:"https://calagtest.calicosol.com",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_DATASET_ID:"30e84bd7-da03-4427-b925-41568e41af5e",REACT_APP_ENVIRONMENT:"qa",REACT_APP_LOG_LEVEL:"ALL",REACT_APP_APPLIED_PRODUCTS_REI_EMBED_REPORT_ID:"48aeb492-c56e-495b-b00e-b3e5dd9366fe,5d24dc9d-14fa-4d88-9c16-a7b5784c17a2",REACT_APP_APPLIED_PRODUCTS_REGULATORY_DATASET_ID:"4b60ac54-3c5e-4955-ad33-306aadfc3ed8",REACT_APP_APPLIED_PRODUCTS_PHI_EMBED_REPORT_ID:"fab03ebd-7de2-40b7-89f6-cb20d862bbfe,a063b2c6-68ab-495b-ad62-72254ff3f578",REACT_APP_SMART_LOOK_VERSION:"nextgen",REACT_APP_PRODUCTION_RECORDS_PRINT_RECOMMENDATIONS_EMBED_REPORT_ID:"3899fdb7-5975-4a78-9819-9a92af066294,f9787c57-ecb7-43a2-b857-04aa57529251",REACT_APP_APPLIED_PRODUCTS_BY_DAY_DATASET_ID:"cfa6afe9-2968-40fa-b872-5ab053d3d0f9",REACT_APP_CAMPAIGN_LINK:"https://staging.accounts.cropwise.com/signup?source_campaign=M2FlN2VjM2ItNjVjMy00YzA5LTk4MWItMzEzOTc5ODZjYzIzOjoyNmRlYWQ0ZS1mNjVmLTQwYmUtOGEzMC02NDZiYWNjYjhlY2M6OkNyb3BXaXNl",REACT_APP_LC_CLIENT_KEY:"6384e10156c30611b231c457",REACT_APP_ENV:"qa",REACT_APP_PRODUCTION_RECORDS_PRINT_TASKS_EMBED_REPORT_ID:"e58f51e2-1f8b-499a-8694-a692fff22c05,965b5d8c-92c1-465b-817e-d871a0e9fb38",REACT_APP_SEGMENT_SOURCE_ID:"7EfMqzDYRfDzoqjfSlAMCsP0hjNA3fJD",REACT_APP_NOTICE_OF_APPLICATION_DATASET_ID:"e804c2c2-be11-4cc0-8b81-476f6b46bc03",REACT_APP_PRODUCTS_PLAN_SUMMARY_EMBED_REPORT_ID:"40cc8458-6888-4729-9139-b099b03463f9,3f19636a-8386-4102-b17f-88bea7081ffb",REACT_APP_Y_AND_P_YIELD_PRODUCTION_EMBED_REPORT_ID:"4c12edd0-d377-470b-b85d-2c3de0fe1239,4a7a5d39-8e8a-4342-9273-ca18bc9beb3c",REACT_APP_CROPWISE_BASE_API_CROPS:"api.staging.base.cropwise.com",REACT_APP_AG_CLEAR_APP_HOURLY_HISTORICAL_PATH:"historical/hourly",REACT_APP_APPLIED_PRODUCTS_BY_FIELD_EXPORT_REPORT_ID:"2ed1e364-74a7-4b7e-a71d-5e1b402f8766",REACT_APP_AG_CLEAR_APP_HOURLY_FORECAST_PATH:"forecast/hourly",REACT_APP_SIMPLOT_CLIENT_ID:"44ad8ad0-5abc-43e5-be3d-0934f00631be",REACT_APP_APPLIED_PRODUCTS_DETAILS_DATASET_ID:"9accfbe8-b383-493d-988a-316b8c8e0f48",REACT_APP_PESTICIDE_USAGE_EMBED_REPORT_ID:"a7ce0e2f-48c6-4582-b874-b1b84f0ef5df,3d2b6ed6-b61c-433e-9a85-df954cb6acb5",REACT_APP_HIDE_PROPERTIESV2:"false",REACT_APP_APPLIED_PRODUCTS_BY_CROP_DETAILS_EMBED_REPORT_ID:"b515803d-056d-47c2-986f-fd7c1b898277,fb422ca0-e4b9-4157-965a-c75e68aecad9",REACT_APP_EXCEL_REPORT_EMBED_REPORT_ID:"b1b5e76e-5aeb-46a4-971c-ed33ad638cbe,4224d39c-1032-4228-8d76-f5dd0dffea54",REACT_APP_APPLIED_PRODUCTS_DICAMBA_DATASET_ID:"73e5cab0-c5e7-40e1-80a1-28192b8439e6",REACT_APP_APPLIED_PRODUCTS_REGULATORY_EMBED_REPORT_ID:"ca205366-567f-4e3e-a0b9-aab1775ccffe,30e9fe2e-79ef-4102-b58e-d76e94ce752a",REACT_APP_PROPERTIES_BY_CROP_ZONE_INFO_DATASET_ID:"da9d4f3a-b7ba-41b3-98fb-367a0beaa06b",REACT_APP_HIDE_INVOICES:"false",REACT_APP_APPLIED_PRODUCTS_BY_DAY_EMBED_REPORT_ID:"20feadf1-e797-42c6-9a01-cab34f2e291b,6d599db6-a89b-4355-821d-95279ecbaa11",REACT_APP_BASE_API:"https://api.staging.base.cropwise.com",REACT_APP_APPLIED_PRODUCTS_FERTILIZER_BY_CROP_DATASET_ID:"be8bba95-88b7-4404-8419-b9cfa38d548d",REACT_APP_CROPWISE_BASE_API_URL:"staging.accounts.cropwise.com"}).REACT_APP_INVITE_API_URL,"/**")),this.passthrough("/invite-proxy/**"),this.passthrough("https://api.mapbox.com/**"),this.passthrough("https://events.mapbox.com/**"),this.passthrough("https://auth-dev.landdb.com/**"),this.passthrough("https://auth-qa.landdb.com/**"),this.passthrough("https://auth-staging.landdb.com/**"),this.passthrough("https://auth-prod.landdb.com/**"),this.passthrough("https://vnext-api-geojson-qa.S3.amazonaws.com/**"),this.passthrough("http://localhost:4000/**"),this.passthrough("https://masterlist.agconnections.com/**"),this.passthrough("https://".concat("staging.accounts.cropwise.com","/v2/accounts/**")),this.passthrough("https://".concat("staging.accounts.cropwise.com","/oauth/token")),this.passthrough("https://vnext-api-qa.landdb.com/**")}});return ot(),r}Object(r.d)("en",(function(e){e.irregular("weather","weather"),e.irregular("person","people")}))},370:function(e,t,n){},39:function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return s}));var a=n(41),r=n(36),c=n(60),i=n.n(c),o=15,s=function(){function e(){Object(a.a)(this,e)}return Object(r.a)(e,null,[{key:"divideSafeRound",value:function(t,n){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:i.a.ROUND_HALF_EVEN,c=e._round(this.divide(t,n),a,r);return c.isNaN()||!c.isFinite()?0:c.toNumber()}},{key:"divide",value:function(e,t){return new i.a(e).div(t)}},{key:"multiplyRound",value:function(t,n){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o;return e._round(e.multiply(t,n),a).toNumber()}},{key:"multiply",value:function(e,t){return new i.a(e).mul(t)}},{key:"plusRound",value:function(t,n){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o;return e._round(e.plus(t,n),a).toNumber()}},{key:"plus",value:function(e,t){return new i.a(e).plus(t)}},{key:"minusRound",value:function(t,n){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o;return e._round(e.minus(t,n),a).toNumber()}},{key:"minus",value:function(e,t){return new i.a(e).minus(t)}},{key:"parseFloatRound",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.a.ROUND_HALF_EVEN;try{var r=new i.a(t);return r.isFinite()?e._round(r,n,a).toNumber():NaN}catch(c){return NaN}}},{key:"_round",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.a.ROUND_HALF_EVEN;return e.toDecimalPlaces(t,n)}}]),e}()},69:function(e,t,n){"use strict";n.r(t),n.d(t,"specialCaseUnit",(function(){return b})),n.d(t,"getCompatibleUnits",(function(){return O})),n.d(t,"roundValue",(function(){return h})),n.d(t,"getConvertUnitFromTo",(function(){return x})),n.d(t,"setConversionFactor",(function(){return g})),n.d(t,"calcSpecialCase",(function(){return C})),n.d(t,"unitsAreSame",(function(){return y})),n.d(t,"calcConversions",(function(){return P})),n.d(t,"calculateProductValues",(function(){return N})),n.d(t,"calculateNumberOfApplications",(function(){return E}));var a=n(4),r=n(14),c=n(70),i=n(20),o=n(60),s=n.n(o),l=n(9),d=n(39),u=n(107),b=["bag","box","bulk","bushel","can","crate","dispenser","kernal","kernel","load","package","plant","roll","seed","tablet","tray","pound"],j=["kg","feet","cubic feet","square feet"],p=["second","hour","day","year"],f=function(e){return Object(u.a)(e.map((function(e){return{key:e.key,value:Object(i.g)(e.value)}})),"value")},m=function(e){return Object(r.a)(new Set(e))},v=function(e){return e.map((function(e){return{key:e,value:e}}))},O=function(e,t){var n=e[0],a=e[1],o=[];if(b.includes(n)||b.includes(a))return o.push.apply(o,Object(r.a)(e)),"unit"!==a&&["kernal","kernel","seed","pound"].includes(n)&&o.push("bag"),f(v(m([].concat(o,[n]))));if(0===t)return i.b.includes(n)?o.push.apply(o,Object(r.a)(i.c)):i.d.includes(n)?o.push.apply(o,Object(r.a)(i.e)):o.push(n,a),f(v(m([].concat(o,[n]))));if(i.d.includes(n))o.push.apply(o,Object(r.a)(i.e).concat(Object(r.a)(i.c)));else if(i.b.includes(n))o.push.apply(o,Object(r.a)(i.c));else{var s=Object(c.convert)(0,function(e){return e?e/1:0}(t)).from(n).possibilities();o.push.apply(o,Object(r.a)(function(e){var t=[];return e.forEach((function(e){e.endsWith("s")||j.includes(e.toLowerCase())||t.push(e)})),t}(s)))}return p.includes(n)&&!b.includes(a)&&o.push.apply(o,p),f(v(m([].concat(o,[n]))))},h=function(e){return Math.round(100*(e+Number.EPSILON))/100},x=function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=a.density,i=a.productDensity,o=a.stdfactor,s=a.stdunit,l=a.stdpackageunit;if(0===e)return{Value:0};if(!e||!t||!n)return{Value:1};if(t===n)return{Value:e};if(b.includes(t)){if(t===s&&n===l)return{Value:e/o};if(t===l&&n===s||t!==s&&n===l)return{Value:e*o};throw new Error("unknown conversion")}var d=r||i;return Object(c.convert)(e,d).from(t).to(n).toJSON()},g=function(e,t){return e?1/t:t},C=function(e,t,n,a,r){var c=0,i=e?1:g(r,a);return n>0&&(c=e?t/n:t/i/n),c},y=function(e,t){return e===t},P=function(e,t,n,a,r){var c=0;if(a)c=e;else{var i=x(Number.parseFloat(e),t,n,r);c=null===i||void 0===i?void 0:i.Value}return c},A=["ratePerAreaValue","ByRatePerArea"],S=["totalProductValue","ByTotalProduct"],T=["ratePerTankValue","ByRatePerTank"],N=function(e,t,n,r,i){var o,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},j=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},p=0,f=0,m=0,v=0,O=(null===r||void 0===r?void 0:r.changedArea)||u.appliedAreaValue,h=(null===r||void 0===r?void 0:r.changedPct)||u.coveragePercent,x=(null===n||void 0===n?void 0:n.rateUnit)||u.ratePerAreaUnit,g=(null===n||void 0===n?void 0:n.totalProdUnit)||u.totalProductUnit,N=(null===n||void 0===n?void 0:n.tankUnit)||u.ratePerTankUnit,E=i||u.averagePriceAtTimeOfCreation,w=null===(o=j.tankInformation)||void 0===o?void 0:o.tankCount,_=y(x,u.stdpackageunit),R=y(N,u.stdpackageunit),I=y(g,u.stdpackageunit),D=b.includes(u.stdpackageunit),k=1,L=1;if(!D&&!b.includes(x)&&!b.includes(N)){var F=u.density||u.productDensity,M=Object(c.convert)(1,F);k=M.from(u.stdunit).to(x).toJSON()._value,L=M.from(u.stdunit).to(N).toJSON()._value}var V=u.stdfactor,B=V*k,U=V*L;if(A.includes(e)){var z=y(x,g),Z=y(g,N),Y=t*O;if(D)p=C(z,Y,1,B,_),f=C(Z,p,w,U,I);else if(p=P(Y,x,g,z,u),w>0){var H=p/w;f=P(H,x,N,Z)}m=t}if(S.includes(e)){var G=y(g,x),W=y(g,N);if(D)m=C(G,t,O,B,I),f=C(W,t,w,U,I);else{if(O>0){var q=t/O;m=P(q,g,x,G,u)}if(w>0){var J=t/w;f=P(J,g,N,W,u)}}p=t}if(T.includes(e)){if(w>0){var K=y(N,x),Q=y(N,g),X=t*w;if(D)m=C(K,X,O,B,R),p=C(Q,X,1,B,R);else{if(O>0){var $=X/O;m=P($,N,x,K,u)}p=P(X,N,g,Q,u)}}f=t}if(I)v=p*E;else{var ee=D?C(I,p,O,B,I):P(p,g,null===u||void 0===u?void 0:u.stdpackageunit,I,u);v=ee*E}return Object(a.a)(Object(a.a)({},u),{},{totalProductValue:Object(l.isNumber)(p)?d.b.parseFloatRound(p,d.a,s.a.ROUND_HALF_UP):p,ratePerAreaValue:Object(l.isNumber)(m)?d.b.parseFloatRound(m,d.a,s.a.ROUND_HALF_UP):m,ratePerTankValue:Object(l.isNumber)(f)?d.b.parseFloatRound(f,d.a,s.a.ROUND_HALF_UP):f,totalCostAtTimeOfCreation:Object(l.isNumber)(v)?d.b.parseFloatRound(v,d.a,s.a.ROUND_HALF_UP):v,averagePriceAtTimeOfCreation:E,ratePerAreaUnit:x,ratePerTankUnit:N,totalProductUnit:g,appliedAreaValue:O,coveragePercent:h})},E=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=e.appliedAreaValue,r=e.ratePerAreaValue,c=e.totalProductUnit,i=e.averagePriceAtTimeOfCreation,o=e.stdunit,s=e.stdpackageunit,l=e.stdfactor,d=e.density,u=e.productDensity,b=e.ratePerAreaUnit,j=r*n*t;if(b!==o){var p=x(j,b,o,{density:d,productDensity:u,stdfactor:l,stdunit:o,stdpackageunit:s}).Value;j=p}if(o!==c){var f=x(j,o,c,{density:d,productDensity:u,stdfactor:l,stdunit:o,stdpackageunit:s}).Value;j=f}var m=j*i;return Object(a.a)(Object(a.a)({},e),{},{applicationCount:t,totalProductValue:h(j),totalCostAtTimeOfCreation:h(m)})}},715:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/berries.8eefdd3e.svg"},716:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/broccoli.f16341f1.svg"},717:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/corn.06add398.svg"},718:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/grapes.2c25a53d.svg"},719:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/hemp.980a019a.svg"},720:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/mustardRed.d891b915.svg"},721:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/turnips.c67efb92.svg"},73:function(e,t,n){"use strict";n.d(t,"d",(function(){return s})),n.d(t,"b",(function(){return l})),n.d(t,"a",(function(){return d})),n.d(t,"c",(function(){return u})),n.d(t,"e",(function(){return b}));var a=n(3),r=n(4),c=n(60),i=n.n(c),o=n(39),s=function(e){var t;return void 0!==e.Authorization&&(t=e.Authorization),void 0!==e.authorization&&(t=e.authorization),void 0!==t?function(e){var t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(t).split("").map((function(e){return"%".concat("00".concat(e.charCodeAt(0).toString(16)).slice(-2))})).join(""));return JSON.parse(n)}(t.split(" ")[1]):null},l=function(e){return e.reduce((function(e,t){return e+(t.reportedArea||t.originalAcres)}),0)},d=function(e,t,n){return n.map((function(n){var a=0;Number.isFinite(t/100)&&(a=e/100);var c=a*(n.reportedArea||n.originalAcres);return Object(r.a)(Object(r.a)({},n),{},{areaValue:o.b.parseFloatRound(c,2,i.a.ROUND_HALF_UP),coveragePct:o.b.parseFloatRound(100*a,2,i.a.ROUND_HALF_UP)})}))},u=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;try{return JSON.parse(e)}catch(n){return t}},b=function e(t){if("object"!==typeof t||null===t||t instanceof Date)return t;var n=Array.isArray(t)?[]:{};return Object.entries(t).forEach((function(t){var r=Object(a.a)(t,2),c=r[0],i=r[1];void 0===i||""===i||"string"===typeof i&&!i.trim().length?n[c]=null:n[c]="object"===typeof i?e(i):i})),n}},780:function(e,t){e.exports={}},908:function(e,t){},910:function(e,t){},938:function(e,t){},939:function(e,t){}},[[2747,1,2]]]);
//# sourceMappingURL=main.6817b44c.chunk.js.map